From 2fa9252446a78d349ca2f50096430591cc5e012f Mon Sep 17 00:00:00 2001 From: z0rglub Date: Mon, 21 Jul 2003 19:47:14 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: http://piwigo.org/svn/trunk@26 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/admin.php | 38 +- admin/configuration.php | 97 ++- admin/historique.php | 102 --- admin/images/arrow_up.gif | Bin 88 -> 0 bytes admin/images/moins.gif | Bin 867 -> 0 bytes admin/images/plus.gif | Bin 870 -> 0 bytes admin/images/puce.gif | Bin 839 -> 0 bytes admin/include/functions.php | 7 +- admin/infos_images.php | 6 +- admin/thumbnail.php | 680 +++++++----------- admin/update.php | 55 +- admin/waiting.php | 223 +++--- category.php | 138 ++-- identification.php | 8 +- include/config.inc.php | 13 +- include/functions.inc.php | 29 +- include/functions_category.inc.php | 393 +++++----- include/functions_user.inc.php | 19 +- include/init.inc.php | 6 +- include/user.inc.php | 18 +- language/francais.php | 66 +- picture.php | 82 ++- profile.php | 125 +--- .../default/images/php_sqreuil_artistes.gif | Bin 0 -> 17884 bytes upload.php | 83 ++- 25 files changed, 1065 insertions(+), 1123 deletions(-) delete mode 100644 admin/historique.php delete mode 100644 admin/images/arrow_up.gif delete mode 100644 admin/images/moins.gif delete mode 100644 admin/images/plus.gif delete mode 100644 admin/images/puce.gif create mode 100755 template/default/images/php_sqreuil_artistes.gif diff --git a/admin/admin.php b/admin/admin.php index 3825ca71a..388ce9eb0 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -21,8 +21,8 @@ include_once( './include/isadmin.inc.php' ); $vtp = new VTemplate; $handle = $vtp->Open( '../template/'.$user['template'].'/admin/admin.vtp' ); // language -$vtp->setGlobalVar( $handle, 'page_title', $lang['title_default'] ); -$vtp->setGlobalVar( $handle, 'menu_title', $lang['menu_title'] ); +$tpl = array( 'menu_title', 'title_default', 'charset' ); +templatize_array( $tpl, 'lang', $handle ); //--------------------------------------- validating page and creation of title $page_valide = false; $title = ''; @@ -75,13 +75,13 @@ switch ( $_GET['page'] ) $page_valide = false; } break; - case 'historique': + case 'stats': $title = $lang['title_history']; $page_valide = true; break; case 'update': $title = $lang['title_update']; $page_valide = true; break; case 'configuration': $title = $lang['title_configuration']; $page_valide = true; break; - case 'manuel': + case 'help': $title = $lang['title_instructions']; $page_valide = true; break; case 'cat_perm': $title = $lang['title_cat_perm']; @@ -124,6 +124,10 @@ switch ( $_GET['page'] ) } $page_valide = true; break; + case 'comments' : + $title = $lang['title_comments']; + $page_valide = true; + break; default: $title = $lang['title_default']; break; } @@ -177,7 +181,10 @@ $vtp->addSession( $handle, 'summary' ); $vtp->setVar( $handle, 'summary.indent', '' ); $vtp->setVar( $handle, 'summary.link', add_session_id( $link_start.'waiting' ) ); -$query = 'select id from '.PREFIX_TABLE.'waiting;'; +$query = 'SELECT id'; +$query.= ' FROM '.PREFIX_TABLE.'waiting'; +$query.= " WHERE validated='false'"; +$query.= ';'; $result = mysql_query( $query ); $nb_waiting = ''; if ( mysql_num_rows( $result ) > 0 ) @@ -186,6 +193,23 @@ if ( mysql_num_rows( $result ) > 0 ) } $vtp->setVar( $handle, 'summary.name', $lang['menu_waiting'].$nb_waiting ); $vtp->closeSession( $handle, 'summary' ); +// comments +$vtp->addSession( $handle, 'summary' ); +$vtp->setVar( $handle, 'summary.indent', '' ); +$vtp->setVar( $handle, 'summary.link', + add_session_id( $link_start.'comments' ) ); +$query = 'SELECT id'; +$query.= ' FROM '.PREFIX_TABLE.'comments'; +$query.= " WHERE validated='false'"; +$query.= ';'; +$result = mysql_query( $query ); +$nb_waiting = ''; +if ( mysql_num_rows( $result ) > 0 ) +{ + $nb_waiting = ' [ '.mysql_num_rows( $result ).' ]'; +} +$vtp->setVar( $handle, 'summary.name', $lang['menu_comments'].$nb_waiting ); +$vtp->closeSession( $handle, 'summary' ); // update $vtp->addSession( $handle, 'summary' ); $vtp->setVar( $handle, 'summary.indent', '' ); @@ -204,14 +228,14 @@ $vtp->closeSession( $handle, 'summary' ); $vtp->addSession( $handle, 'summary' ); $vtp->setVar( $handle, 'summary.indent', '' ); $vtp->setVar( $handle, 'summary.link', - add_session_id( $link_start.'historique' ) ); + add_session_id( $link_start.'stats' ) ); $vtp->setVar( $handle, 'summary.name', $lang['menu_history'] ); $vtp->closeSession( $handle, 'summary' ); // instructions $vtp->addSession( $handle, 'summary' ); $vtp->setVar( $handle, 'summary.indent', '' ); $vtp->setVar( $handle, 'summary.link', - add_session_id( $link_start.'manuel' ) ); + add_session_id( $link_start.'help' ) ); $vtp->setVar( $handle, 'summary.name', $lang['menu_instructions'] ); $vtp->closeSession( $handle, 'summary' ); // back to thumbnails page diff --git a/admin/configuration.php b/admin/configuration.php index 34e148c4d..3292ffbc2 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -40,9 +40,10 @@ array( 'prefix_thumbnail','webmaster','mail_webmaster','access', 'session_id_size','session_time','session_keyword','max_user_listbox', 'show_comments','nb_comment_page','upload_available', 'upload_maxfilesize', 'upload_maxwidth','upload_maxheight', - 'upload_maxwidth_thumbnail','upload_maxheight_thumbnail' ); + 'upload_maxwidth_thumbnail','upload_maxheight_thumbnail','log', + 'comments_validation' ); $default_user_infos = -array( 'nb_image_line','nb_line_page','theme','language','maxwidth', +array( 'nb_image_line','nb_line_page','language','maxwidth', 'maxheight','expand','show_nb_comments','short_period','long_period', 'template' ); $error = array(); @@ -73,7 +74,7 @@ if ( isset( $_POST['submit'] ) ) { array_push( $error, $lang['conf_err_prefixe'] ); } - // mail mail must be formatted as follows : name@server.com + // mail must be formatted as follows : name@server.com $pattern = '/^[\w-]+(\.[\w-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/'; if ( !preg_match( $pattern, $_POST['mail_webmaster'] ) ) { @@ -194,9 +195,6 @@ if ( isset( $_POST['submit'] ) ) echo $query; mysql_query( $query ); - $tab_theme = explode( ' - ', $_POST['theme'] ); - $_POST['theme'] = $tab_theme[0].'/'.$tab_theme[1]; - $query = 'UPDATE '.PREFIX_TABLE.'users'; $query.= ' SET'; foreach ( $default_user_infos as $i => $default_user_info ) { @@ -371,6 +369,38 @@ $vtp->setVar( $sub, 'param_line.def', $lang['conf_general_max_user_listbox_info'] ); $vtp->closeSession( $sub, 'param_line' ); $vtp->closeSession( $sub, 'line' ); +// activate log +$vtp->addSession( $sub, 'line' ); +$vtp->addSession( $sub, 'param_line' ); +$vtp->setVar( $sub, 'param_line.name', $lang['conf_general_log'] ); +$vtp->addSession( $sub, 'group' ); +$vtp->addSession( $sub, 'radio' ); +$vtp->setVar( $sub, 'radio.name', 'log' ); +$vtp->setVar( $sub, 'radio.value', 'true' ); +$vtp->setVar( $sub, 'radio.option', $lang['yes'] ); +$checked = ''; +if ( $log == 'true' ) +{ + $checked = ' checked="checked"'; +} +$vtp->setVar( $sub, 'radio.checked', $checked ); +$vtp->closeSession( $sub, 'radio' ); +$vtp->addSession( $sub, 'radio' ); +$vtp->setVar( $sub, 'radio.name', 'log' ); +$vtp->setVar( $sub, 'radio.value', 'false' ); +$vtp->setVar( $sub, 'radio.option', $lang['no'] ); +$checked = ''; +if ( $log == 'false' ) +{ + $checked = ' checked="checked"'; +} +$vtp->setVar( $sub, 'radio.checked', $checked ); +$vtp->closeSession( $sub, 'radio' ); +$vtp->closeSession( $sub, 'group' ); +$vtp->setVar( $sub, 'param_line.def', + $lang['conf_general_log_info'] ); +$vtp->closeSession( $sub, 'param_line' ); +$vtp->closeSession( $sub, 'line' ); $vtp->addSession( $sub, 'line' ); $vtp->addSession( $sub, 'space_line' ); @@ -432,6 +462,38 @@ $vtp->setVar( $sub, 'param_line.def', $lang['conf_comments_comments_number_info'] ); $vtp->closeSession( $sub, 'param_line' ); $vtp->closeSession( $sub, 'line' ); +// coments validation +$vtp->addSession( $sub, 'line' ); +$vtp->addSession( $sub, 'param_line' ); +$vtp->setVar( $sub, 'param_line.name', $lang['conf_comments_validation'] ); +$vtp->addSession( $sub, 'group' ); +$vtp->addSession( $sub, 'radio' ); +$vtp->setVar( $sub, 'radio.name', 'comments_validation' ); +$vtp->setVar( $sub, 'radio.value', 'true' ); +$vtp->setVar( $sub, 'radio.option', $lang['yes'] ); +$checked = ''; +if ( $comments_validation == 'true' ) +{ + $checked = ' checked="checked"'; +} +$vtp->setVar( $sub, 'radio.checked', $checked ); +$vtp->closeSession( $sub, 'radio' ); +$vtp->addSession( $sub, 'radio' ); +$vtp->setVar( $sub, 'radio.name', 'comments_validation' ); +$vtp->setVar( $sub, 'radio.value', 'false' ); +$vtp->setVar( $sub, 'radio.option', $lang['no'] ); +$checked = ''; +if ( $comments_validation == 'false' ) +{ + $checked = ' checked="checked"'; +} +$vtp->setVar( $sub, 'radio.checked', $checked ); +$vtp->closeSession( $sub, 'radio' ); +$vtp->closeSession( $sub, 'group' ); +$vtp->setVar( $sub, 'param_line.def', + $lang['conf_comments_validation_info'] ); +$vtp->closeSession( $sub, 'param_line' ); +$vtp->closeSession( $sub, 'line' ); $vtp->addSession( $sub, 'line' ); $vtp->addSession( $sub, 'space_line' ); @@ -514,7 +576,7 @@ $vtp->closeSession( $sub, 'line' ); // template $vtp->addSession( $sub, 'line' ); $vtp->addSession( $sub, 'param_line' ); -$vtp->setVar( $sub, 'param_line.name', $lang['customize_template'] ); +$vtp->setVar( $sub, 'param_line.name', $lang['customize_theme'] ); $vtp->addSession( $sub, 'select' ); $vtp->setVar( $sub, 'select.name', 'template' ); $option = get_dirs( '../template/' ); @@ -529,27 +591,6 @@ for ( $i = 0; $i < sizeof( $option ); $i++ ) $vtp->closeSession( $sub, 'option' ); } $vtp->closeSession( $sub, 'select' ); -$vtp->setVar( $sub, 'param_line.def', $lang['conf_default_template_info'] ); -$vtp->closeSession( $sub, 'param_line' ); -$vtp->closeSession( $sub, 'line' ); -// theme -$vtp->addSession( $sub, 'line' ); -$vtp->addSession( $sub, 'param_line' ); -$vtp->setVar( $sub, 'param_line.name', $lang['customize_theme'] ); -$vtp->addSession( $sub, 'select' ); -$vtp->setVar( $sub, 'select.name', 'theme' ); -$option = get_themes( '../theme/' ); -for ( $i = 0; $i < sizeof( $option ); $i++ ) -{ - $vtp->addSession( $sub, 'option' ); - $vtp->setVar( $sub, 'option.option', $option[$i] ); - if ( $option[$i] == str_replace( "/", " - ", $theme ) ) - { - $vtp->setVar( $sub, 'option.selected', ' selected="selected"' ); - } - $vtp->closeSession( $sub, 'option' ); -} -$vtp->closeSession( $sub, 'select' ); $vtp->setVar( $sub, 'param_line.def', $lang['conf_default_theme_info'] ); $vtp->closeSession( $sub, 'param_line' ); $vtp->closeSession( $sub, 'line' ); diff --git a/admin/historique.php b/admin/historique.php deleted file mode 100644 index eda2b1b27..000000000 --- a/admin/historique.php +++ /dev/null @@ -1,102 +0,0 @@ - '$date_ref' order by date desc;"); - echo"
empty / vider
"; - echo"
"; - // affichage de la date du jour - echo $tJours[date("w")] ." "; - echo date("j").(date("j") == 1 ? "er " : " "); - echo $tMois[date("n")-1]." ".date("Y")." "; - echo " à ".date("G")."h".date("i"); - echo"
"; -?> - - - - - - - - - - - - - - - - - - - - "; - // 2. affichage de tous les évènements pour le jour donné - // entre la veille à 23h59m59s et le jour même 23h59m59s - $result = mysql_query("select date,login,IP,categorie,page,titre,commentaire from PREFIX_TABLE"."history where date > '$debut' and date < '$fin' order by date desc;"); - $fin = $debut; - // on recule le début d'une journée complète - $debut = $debut - 24*60*60; - while($row=mysql_fetch_array($result)) - { - $date = date("G\hi s", $row[date]); - $date = str_replace ( " ","min ", $date ); - $date .= " sec"; - // on réduit la taille du commentaire à ses premiers caractères - $affichage_commentaire = ""; - if($row[commentaire] != '') - { - $affichage_commentaire = substr($row[commentaire],0,10); - $affichage_commentaire .= "..."; - } - echo" - - - - - - - "; - } - } - echo"
dateloginIPpagecategorieimage
"; - echo"  "; - echo $tJours[date("w",$fin)] ." "; - echo date("j",$fin).(date("j",$fin) == 1 ? "er " : " "); - echo $tMois[date("n",$fin)-1]." ".date("Y",$fin).""; - echo"      
 |-  $date$row[login]$row[IP]$row[page]$row[categorie]$row[titre]
- "; -?> \ No newline at end of file diff --git a/admin/images/arrow_up.gif b/admin/images/arrow_up.gif deleted file mode 100644 index 90da978cdef95e4467e1ff4bbd0e8435211621d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 88 zcmZ?wbhEHbRAUfhXkY+=|Ns9h{$yblVPIs?0r5dH3{3hx{VPwu nm4HXrm6WuMs!j86A6jg4`COLwPS4F$SEY(F@@nFBO^PPSVzhN2gfEB T4iOdxg9XbQ=36r}F<1itlEV36 diff --git a/admin/images/puce.gif b/admin/images/puce.gif deleted file mode 100644 index b8494bb77ed201d91c6cdc053ed46904345077d9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 839 zcmaJ=L1+_E5S`tP&6)(YQEbFOQW5DvLLg9Ti<;V4qop+`@vzXuW;XT;{uzTU+aNntn z4?JK4SxnQa7UvdlE5Be`0T2vFJ0w)Z2i}Uf zA*Bp|`kfh4MC4kW{tjIp}louA!e0z|*Q zwh*u5EUhgc1U)GTqVUNxsxb|6;N diff --git a/admin/include/functions.php b/admin/include/functions.php index cd58d0822..6a5ed195e 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -17,11 +17,16 @@ $tab_ext_create_TN = array ( 'jpg', 'png', 'JPG', 'PNG' ); +// is_image returns true if the given $filename (including the path) is a +// picture according to its format and its extension. +// As GD library can only generate pictures from jpeg and png files, if you +// ask if the filename is an image for thumbnail creation (second parameter +// set to true), the only authorized formats are jpeg and png. function is_image( $filename, $create_thumbnail = false ) { global $conf, $tab_ext_create_TN; - if ( is_file ( $filename ) ) + if ( is_file( $filename ) ) { $size = getimagesize( $filename ); // $size[2] == 1 means GIF diff --git a/admin/infos_images.php b/admin/infos_images.php index 7735caba2..29957b478 100644 --- a/admin/infos_images.php +++ b/admin/infos_images.php @@ -18,7 +18,7 @@ include_once( './include/isadmin.inc.php' ); include_once( '../template/'.$user['template'].'/htmlfunctions.inc.php' ); //------------------------------------------------------------------- functions -function check_date_format ( $date ) +function check_date_format( $date ) { // date arrives at this format : DD/MM/YYYY // checkdate ( int month, int day, int year) @@ -144,7 +144,7 @@ if ( isset( $page['cat'] ) ) } else { - echo $lang['infoimage_err_date']; + echo $lang['err_date']; } } //--------------------------------------------------------- form initialization @@ -221,6 +221,8 @@ if ( isset( $page['cat'] ) ) $thumbnail_url.= 'thumbnail/'; $thumbnail_url.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext']; $vtp->setVar( $sub, 'picture.thumbnail_url', $thumbnail_url ); + $url = '../picture.php?cat='.$_GET['cat_id'].'&image_id='.$row['id']; + $vtp->setVar( $sub, 'picture.url', add_session_id( $url ) ); $vtp->closeSession( $sub, 'picture' ); } } diff --git a/admin/thumbnail.php b/admin/thumbnail.php index 72f384a45..538b536b7 100644 --- a/admin/thumbnail.php +++ b/admin/thumbnail.php @@ -1,9 +1,9 @@ * * * ***************************************************************************/ @@ -14,116 +14,116 @@ * the Free Software Foundation; * * * ***************************************************************************/ -include_once( "./include/isadmin.inc.php" ); - -function get_subdirs( $rep ) +include_once( './include/isadmin.inc.php' ); +//------------------------------------------------------------------- functions +// get_subdirs returns an array containing all sub directory names, +// excepting : '.', '..' and 'thumbnail'. +function get_subdirs( $dir ) { - $sub_rep = array(); - $i = 0; - if ( $opendir = opendir ( $rep ) ) + $sub_dirs = array(); + if ( $opendir = opendir( $dir ) ) { - while ( $file = readdir ( $opendir ) ) + while ( $file = readdir( $opendir ) ) { - if ( $file != "thumbnail" && $file != "." - && $file != ".." && is_dir ( $rep.$file ) ) + if ( $file != 'thumbnail' and $file != '.' + and $file != '..' and is_dir( $dir.'/'.$file ) ) { - $sub_rep[$i++] = $file; + array_push( $sub_dirs, $file ); } } } - return $sub_rep; + return $sub_dirs; } -/* - $tab_ext = array ( 'jpg', 'JPG','png','PNG' ); - $tab_tn_ext = array ( 'jpg', 'JPG','png','PNG', 'gif', 'GIF' ); -*/ +// get_images_without_thumbnail returns an array with all the picture names +// that don't have associated thumbnail in the directory. Each picture name +// is associated with the width, heigh and filesize of the picture. function get_images_without_thumbnail( $dir ) { - $i = 0; - if ( $opendir = opendir ( $dir ) ) + $images = array(); + if ( $opendir = opendir( $dir ) ) { - while ( $file = readdir ( $opendir ) ) + while ( $file = readdir( $opendir ) ) { - $lien_image = $dir."/".$file; - if ( is_image( $lien_image, true ) ) + $path = $dir.'/'.$file; + if ( is_image( $path, true ) ) { - if ( !TN_exist( $dir, $file ) ) + if ( !TN_exists( $dir, $file ) ) { - $taille_image = getimagesize( $lien_image ); - $size = floor ( filesize( $lien_image ) / 1024 ). " KB"; - $images[$i++] = array( 'name' => $file, - 'width' => $taille_image[0], - 'height' => $taille_image[1], - 'size' => $size - ); + $image_infos = getimagesize( $path ); + $size = floor( filesize( $path ) / 1024 ). ' KB'; + array_push( $images, array( 'name' => $file, + 'width' => $image_infos[0], + 'height' => $image_infos[1], + 'size' => $size ) ); } } } } return $images; } - -function scandir( $DIR, $width, $height ) + +// scandir scans a dir to find pictures without thumbnails. Once found, +// creation of the thumbnails (RatioResizeImg). Only the first $_POST['n'] +// pictures without thumbnails are treated. +// scandir returns an array with the generation time of each thumbnail (for +// statistics purpose) +function scandir( $dir, $width, $height ) { - global $HTTP_POST_VARS, $conf, $output; - $compteur = 0; - $temps = array(); - if ( $ODIR = opendir( $DIR ) ) + global $conf; + $stats = array(); + if ( $opendir = opendir( $dir ) ) { - while ( $FILE = readdir ( $ODIR ) ) + while ( $file = readdir ( $opendir ) ) { - $TMP = $DIR."/".$FILE; - if ( is_image ( $TMP, true ) ) + $path = $dir.'/'.$file; + if ( is_image( $path, true ) ) { - if ( $compteur < $HTTP_POST_VARS['n'] && !TN_exist( $DIR, $FILE ) ) + if ( count( $stats ) < $_POST['n'] and !TN_exists( $dir, $file ) ) { - $t1 = explode( " ", microtime() ); - $t2 = explode( ".", $t1[0] ); - $t2 = $t1[1].".".$t2[1]; - $info = RatioResizeImg( $FILE, $width, $height, $DIR."/", "jpg" ); - $t3 = explode( " ", microtime() ); - $t4 = explode( ".", $t3[0] ); - $t4 = $t3[1].".".$t4[1]; - $info['temps'] = ( $t4 - $t2 ) * 1000; - $temps[$compteur++] = $info; - //$output.= " (".number_format( $temps[$compteur-1], 2, '.', ' ')." ms)
";; + $starttime = get_moment(); + $info = RatioResizeImg( $file, $width, $height, $dir.'/', 'jpg' ); + $endtime = get_moment(); + $info['time'] = ( $endtime - $starttime ) * 1000; + array_push( $stats, $info ); } } } } - return $temps; + return $stats; } - -function RatioResizeImg( $image, $newWidth, $newHeight, $path, $extension) + +// RatioResizeImg creates a new picture (a thumbnail since it is supposed to +// be smaller than original picture !) in the sub directory named +// "thumbnail". +function RatioResizeImg( $filename, $newWidth, $newHeight, $path, $tn_ext ) { - global $conf, $HTTP_POST_VARS; - // chemin complet de l'image : - $chemin = $path.$image; - // détéction du type de l'image - eregi( "(...)$", $chemin, $regs); - $type = $regs[1]; - switch( $type ) + global $conf, $lang; + // full path to picture + $filepath = $path.$filename; + // extension of the picture filename + $extension = get_extension( $filepath ); + switch( $extension ) { - case "jpg": $srcImage = @imagecreatefromjpeg( $chemin ); break; - case "JPG": $srcImage = @imagecreatefromjpeg( $chemin ); break; - case "png": $srcImage = @imagecreatefrompng( $chemin ); break; - case "PNG": $srcImage = @imagecreatefrompng( $chemin ); break; - default : unset( $type ); break; + case 'jpg': $srcImage = @imagecreatefromjpeg( $filepath ); break; + case 'JPG': $srcImage = @imagecreatefromjpeg( $filepath ); break; + case 'png': $srcImage = @imagecreatefrompng( $filepath ); break; + case 'PNG': $srcImage = @imagecreatefrompng( $filepath ); break; + default : unset( $extension ); break; } - if( $srcImage ) + if ( isset( $srcImage ) ) { - // hauteurs/largeurs - $srcWidth = imagesx( $srcImage ); - $srcHeight = imagesy( $srcImage ); - $ratioWidth = $srcWidth/$newWidth; + // width/height + $srcWidth = imagesx( $srcImage ); + $srcHeight = imagesy( $srcImage ); + $ratioWidth = $srcWidth/$newWidth; $ratioHeight = $srcHeight/$newHeight; - - // taille maximale dépassée ? - if (($ratioWidth > 1) || ($ratioHeight > 1)) + + // maximal size exceeded ? + if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) ) { - if( $ratioWidth < $ratioHeight) + if ( $ratioWidth < $ratioHeight) { $destWidth = $srcWidth/$ratioHeight; $destHeight = $newHeight; @@ -139,58 +139,59 @@ function RatioResizeImg( $image, $newWidth, $newHeight, $path, $extension) $destWidth = $srcWidth; $destHeight = $srcHeight; } - // selon votre version de GD installée sur le serveur hébergeur - if ( $HTTP_POST_VARS['gd'] == 2 ) + // according to the GD version installed on the server + if ( $_POST['gd'] == 2 ) { - // Partie 1 : GD 2.0 ou supérieur, résultat très bons + // GD 2.0 or more recent -> good results (but slower) $destImage = imagecreatetruecolor( $destWidth, $destHeight); - imagecopyresampled( $destImage, $srcImage, 0, 0, 0, 0, $destWidth,$destHeight,$srcWidth,$srcHeight ); + imagecopyresampled( $destImage, $srcImage, 0, 0, 0, 0, + $destWidth,$destHeight,$srcWidth,$srcHeight ); } else { - // Partie 2 : GD inférieur à 2, résultat très moyens + // GD prior to version 2 -> pretty bad results :-/ (but fast) $destImage = imagecreate( $destWidth, $destHeight); - imagecopyresized( $destImage, $srcImage, 0, 0, 0, 0, $destWidth,$destHeight,$srcWidth,$srcHeight ); + imagecopyresized( $destImage, $srcImage, 0, 0, 0, 0, + $destWidth,$destHeight,$srcWidth,$srcHeight ); } - if( !is_dir( $path."thumbnail" ) ) + if( !is_dir( $path.'thumbnail' ) ) { - umask(0000); - mkdir( $path."thumbnail", 0777 ); + umask( 0000 ); + mkdir( $path.'thumbnail', 0777 ); } - $dest_file = $path."thumbnail/".$conf['prefix_thumbnail'].substr ( $image, 0, strrpos ( $image, ".") ).".".$extension; + $dest_file = $path.'thumbnail/'.$conf['prefix_thumbnail']; + $dest_file.= get_filename_wo_extension( $filename ); + $dest_file.= '.'.$tn_ext; - // création et sauvegarde de l'image finale - imagejpeg($destImage, $dest_file); - // libère la mémoire + // creation and backup of final picture + imagejpeg( $destImage, $dest_file ); + // freeing memory ressources imagedestroy( $srcImage ); imagedestroy( $destImage ); - // renvoit l'URL de l'image - //return $dest_file; - $taille_image = getimagesize( $chemin ); - $size = number_format( floor ( filesize( $chemin ) / 1024 ), 0, '', ' ')." KB"; - $tn_taille_image = getimagesize( $dest_file ); - $tn_size = number_format( floor ( filesize( $dest_file ) ), 0, '', ' ')." octets"; - $info = array( 'name' => $image, - 'width' => $taille_image[0], - 'height' => $taille_image[1], - 'size' => $size, - 'tn_name' => $conf['prefix_thumbnail'].substr ( $image, 0, strrpos ( $image, ".") ).".".$extension, - 'tn_width' => $tn_taille_image[0], - 'tn_height' => $tn_taille_image[1], - 'tn_size' => $tn_size - ); + list( $width,$height ) = getimagesize( $filepath ); + $size = floor( filesize( $filepath ) / 1024 ).' KB'; + list( $tn_width,$tn_height ) = getimagesize( $dest_file ); + $tn_size = floor( filesize( $dest_file ) / 1024 ).' KB'; + $info = array( 'file' => $filename, + 'width' => $width, + 'height' => $height, + 'size' => $size, + 'tn_file' => $dest_file, + 'tn_width' => $tn_width, + 'tn_height' => $tn_height, + 'tn_size' => $tn_size ); return $info; } - // erreur + // error else { echo $lang['tn_no_support']." "; - if ($type) + if ( isset( $extenstion ) ) { - echo $lang['tn_format']." $type"; + echo $lang['tn_format'].' '.$extension; } else { @@ -199,370 +200,227 @@ function RatioResizeImg( $image, $newWidth, $newHeight, $path, $extension) exit(); } } - + +// array_max returns the highest value of the given array function array_max( $array ) { - $max = 0; - for ( $i = 0; $i < sizeof( $array ); $i++ ) - { - if ( $array[$i] > $max ) - { - $max = $array[$i]; - } - } - return $max; + sort( $array, SORT_NUMERIC ); + return array_pop( $array ); } - + +// array_min returns the lowest value of the given array function array_min( $array ) { - $min = 99999999999999; - for ( $i = 0; $i < sizeof( $array ); $i++ ) - { - if ( $array[$i] < $min ) - { - $min = $array[$i]; - } - } - return $min; + sort( $array, SORT_NUMERIC ); + return array_shift( $array ); } - -function array_moy( $array ) + +// array_avg returns the average value of the array +function array_avg( $array ) { return array_sum( $array ) / sizeof( $array ); } -// get_dirs retourne un tableau contenant tous les sous-répertoires d'un répertoire -function get_displayed_dirs( $rep, $indent ) +// get_displayed_dirs builds the tree of dirs under "galleries". If a +// directory contains pictures without thumbnails, the become linked to the +// page of thumbnails creation. +function get_displayed_dirs( $dir, $indent ) { - global $conf,$lang; + global $conf,$lang,$vtp,$sub; - $sub_rep = array(); - $i = 0; - $dirs = ""; - if ( $opendir = opendir ( $rep ) ) - { - while ( $file = readdir ( $opendir ) ) - { - if ( $file != "." && $file != ".." && is_dir ( $rep."/".$file ) && $file != "thumbnail" ) - { - $sub_rep[$i++] = $file; - } - } - } + $sub_dirs = get_subdirs( $dir ); // write of the dirs - for ( $i = 0; $i < sizeof( $sub_rep ); $i++ ) - { - $images = get_images_without_thumbnail( $rep."/".$sub_rep[$i] ); - $nb_picture_without_TN = sizeof( $images ); - $dirs.= $indent; - if ( $nb_picture_without_TN > 0 ) + foreach ( $sub_dirs as $sub_dir ) { + $pictures = get_images_without_thumbnail( $dir.'/'.$sub_dir ); + $vtp->addSession( $sub, 'dir' ); + $vtp->setVar( $sub, 'dir.indent', $indent ); + if ( count( $pictures ) > 0 ) { - $dirs.= ""; + $vtp->addSession( $sub, 'linked' ); + $url = './admin.php?page=thumbnail&dir='.$dir."/".$sub_dir; + $vtp->setVar( $sub, 'linked.url', add_session_id( $url ) ); + $vtp->setVar( $sub, 'linked.name', $sub_dir ); + $vtp->setVar( $sub, 'linked.nb_pic', count( $pictures ) ); + $vtp->closeSession( $sub, 'linked' ); } - $dirs.= "\">\"/".$sub_rep[$i]; - if ( $nb_picture_without_TN > 0 ) + else { - $dirs.= ""; + $vtp->addSession( $sub, 'unlinked' ); + $vtp->setVar( $sub, 'unlinked.name', $sub_dir ); + $vtp->closeSession( $sub, 'unlinked' ); } - if ( $nb_picture_without_TN > 0 ) - { - $dirs.= " [ $nb_picture_without_TN ".$lang['tn_dirs_alone']." ]"; - } - $dirs.= "
"; - $dirs.= get_displayed_dirs( $rep."/".$sub_rep[$i], $indent."        " ); + $vtp->closeSession( $sub, 'dir' ); + // recursive call + $dirs.= get_displayed_dirs( $dir.'/'.$sub_dir, + $indent+30 ); + } - return $dirs; } - -$output = ""; - -if ( isset( $HTTP_GET_VARS['dir'] ) ) +//----------------------------------------------------- template initialization +$sub = $vtp->Open( '../template/'.$user['template'].'/admin/thumbnail.vtp' ); +$tpl = array( + 'tn_dirs_title','tn_dirs_alone','tn_params_title','tn_params_GD', + 'tn_params_GD_info','tn_width','tn_params_width_info','tn_height', + 'tn_params_height_info','tn_params_create','tn_params_create_info', + 'tn_params_format','tn_params_format_info','submit','tn_alone_title', + 'filesize','tn_picture','tn_results_title','thumbnail', + 'tn_results_gen_time','tn_stats','tn_stats_nb','tn_stats_total', + 'tn_stats_max','tn_stats_min','tn_stats_mean' ); +templatize_array( $tpl, 'lang', $sub ); +//----------------------------------------------------- miniaturization results +if ( isset( $_GET['dir'] ) ) { - //---------------vérification de la présence d'images sans thumbnail - $images = get_images_without_thumbnail( $HTTP_GET_VARS['dir'] ); - if ( sizeof( $images ) == 0 ) + $pictures = get_images_without_thumbnail( $_GET['dir'] ); + if ( count( $pictures ) == 0 ) { - $output.= "
[ 0 ".$lang['tn_dirs_alone']." ]
"; + $vtp->addSession( $sub, 'warning' ); + $vtp->closeSession( $sub, 'warning' ); } - else if ( isset( $HTTP_POST_VARS['submit'] ) ) + elseif ( isset( $_POST['submit'] ) ) { - //----------------------------------------vérification des variables - $nb_erreur = 0; - $erreur = ""; - if ( !ereg( "^[0-9]{2,3}$", $HTTP_POST_VARS['width'] ) || $HTTP_POST_VARS['width'] < 10 ) + // checking criteria + $errors = array(); + if ( !ereg( "^[0-9]{2,3}$", $_POST['width'] ) or $_POST['width'] < 10 ) { - $nb_erreur++; - $erreur.= "
  • ".$lang['tn_err_width']." 10
  • "; + array_push( $errors, $lang['tn_err_width'].' 10' ); } - if ( !ereg( "^[0-9]{2,3}$", $HTTP_POST_VARS['height'] ) || $HTTP_POST_VARS['height'] < 10 ) + if ( !ereg( "^[0-9]{2,3}$", $_POST['height'] ) or $_POST['height'] < 10 ) { - $nb_erreur++; - $erreur.= "
  • ".$lang['tn_err_height']." 10
  • "; + array_push( $errors, $lang['tn_err_height'].' 10' ); } - if ( !isset( $HTTP_POST_VARS['gd'] ) ) + // picture miniaturization + if ( count( $errors ) == 0 ) { - $nb_erreur++; - $erreur.= "
  • ".$lang['tn_err_GD']."
  • "; - } - - //---------------------------------------------listing des résultats - if ( $nb_erreur == 0 ) - { - $style = "class=\"row2\" style=\"text-align:center;font-weight:bold;"; - $output.= " - - - - - - - - - - - - - - - - "; - $tab_infos = scandir( $HTTP_GET_VARS['dir'], $HTTP_POST_VARS['width'], $HTTP_POST_VARS['height'] ); - for ( $i = 0; $i < sizeof ( $tab_infos ); $i++ ) - { - $temps[$i] = $tab_infos[$i]['temps']; + $vtp->addSession( $sub, 'results' ); + $stats = scandir( $_GET['dir'], $_POST['width'], $_POST['height'] ); + $times = array(); + foreach ( $stats as $stat ) { + array_push( $times, $stat['time'] ); } - $max = array_max( $temps ); - $min = array_min( $temps ); - for ( $i = 0; $i < sizeof ( $tab_infos ); $i++ ) - { - $temps[$i] = $tab_infos[$i]['temps']; - $num = $i + 1; - $class = ""; - if ( $i%2 == 1 ) + $max = array_max( $times ); + $min = array_min( $times ); + foreach ( $stats as $i => $stat ) { + $vtp->addSession( $sub, 'picture' ); + if ( $i % 2 == 1 ) { - $class = "class=\"row2\""; + $vtp->setVar( $sub, 'picture.class', 'row2' ); } - $output.= " - - - - - - - - - - - - "; + $vtp->closeSession( $sub, 'picture' ); } - $output.= " - - - -
    ".$lang['tn_results_title']."
     ".$lang['tn_picture']."".$lang['tn_filesize']."".$lang['tn_width']."".$lang['tn_height']."".$lang['tn_results_gen_time']."".$lang['thumbnail']."".$lang['tn_filesize']."".$lang['tn_width']."".$lang['tn_height']."
    $num".$tab_infos[$i]['name']."".$tab_infos[$i]['size']."".$tab_infos[$i]['width']."".$tab_infos[$i]['height']."
    setVar( $sub, 'picture.num', ($i+1) ); + $vtp->setVar( $sub, 'picture.file', $stat['file'] ); + $vtp->setVar( $sub, 'picture.filesize', $stat['size'] ); + $vtp->setVar( $sub, 'picture.width', $stat['width'] ); + $vtp->setVar( $sub, 'picture.height', $stat['height'] ); + $vtp->setVar( $sub, 'picture.thumb_file', $stat['tn_file'] ); + $vtp->setVar( $sub, 'picture.thumb_filesize', $stat['tn_size'] ); + $vtp->setVar( $sub, 'picture.thumb_width', $stat['tn_width'] ); + $vtp->setVar( $sub, 'picture.thumb_height', $stat['tn_height'] ); + $vtp->setVar( $sub, 'picture.time', + number_format( $stat['time'], 2, '.', ' ').' ms' ); + if ( $stat['time'] == $max ) { - $output.= "color:red;"; + $vtp->setVar( $sub, 'picture.color', 'red' ); } - if ( $tab_infos[$i]['temps'] == $min ) + else if ( $stat['time'] == $min ) { - $output.= "color:green;"; + $vtp->setVar( $sub, 'picture.color', 'green' ); } - $output.= "\">".number_format( $tab_infos[$i]['temps'], 2, '.', ' ')." ms
    ".$tab_infos[$i]['tn_name']."".$tab_infos[$i]['tn_size']."".$tab_infos[$i]['tn_width']."".$tab_infos[$i]['tn_height']."
     
    - - - - - - - - - - - - - - - - - - - - - - - - -
    ".$lang['tn_stats']."
    ".$lang['tn_stats_nb']." : ".sizeof( $temps )."
    ".$lang['tn_stats_total']." : ".number_format( array_sum( $temps ), 2, '.', ' ')." ms
    ".$lang['tn_stats_max']." : ".number_format( $max, 2, '.', ' ')." ms
    ".$lang['tn_stats_min']." : ".number_format( $min, 2, '.', ' ')." ms
    ".$lang['tn_stats_mean']." : ".number_format( array_moy( $temps ), 2, '.', ' ')." ms
    - - - - -
     
    "; + // general statistics + $vtp->setVar( $sub, 'results.stats_nb', count( $stats ) ); + $vtp->setVar( $sub, 'results.stats_total', + number_format( array_sum( $times ), 2, '.', ' ').' ms' ); + $vtp->setVar( $sub, 'results.stats_max', + number_format( $max, 2, '.', ' ').' ms' ); + $vtp->setVar( $sub, 'results.stats_min', + number_format( $min, 2, '.', ' ').' ms' ); + $vtp->setVar( $sub, 'results.stats_mean', + number_format( array_avg( $times ), 2, '.', ' ').' ms' ); + $vtp->closeSession( $sub, 'results' ); } else { - $output.= " -
    ".$lang['tn_err']."
    -
    -
      - $erreur -
    -
    "; + $vtp->addSession( $sub, 'errors' ); + foreach ( $errors as $error ) { + $vtp->addSession( $sub, 'li' ); + $vtp->setVar( $sub, 'li.li', $error ); + $vtp->closeSession( $sub, 'li' ); + } + $vtp->closeSession( $sub, 'errors' ); } } - //-------------------------------------paramètres de miniaturisation - if ( sizeof( $images ) != 0 ) +//-------------------------------------------------- miniaturization parameters + if ( sizeof( $pictures ) != 0 ) { - $output.= " - "; - $output.= " -
    - - - - "; - $output.= " - - - "; - $output.= " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "; - $output.= " -
    ".$lang['tn_params_title']."
     
    ".$lang['tn_params_GD']."
    - 2.x - addSession( $sub, 'params' ); + $url = './admin.php?page=thumbnail&dir='.$_GET['dir']; + $vtp->setVar( $sub, 'params.action', add_session_id( $url ) ); + // GD version selected... + if ( $_POST['gd'] == 1 ) { - $output.= " checked=\"checked\""; - } - $output.= "/>1.x - ".$lang['tn_params_GD_info']."
    ".$lang['tn_width']."
    setVar( $sub, 'params.gd1_checked', ' checked="checked"' ); } else { - $output.= "128"; + $vtp->setVar( $sub, 'params.gd2_checked', ' checked="checked"' ); } - $output.="\"/>".$lang['tn_params_width_info']."
    ".$lang['tn_height']."
    setVar( $sub, 'params.width_value', $_POST['width'] ); } else { - $output.= "96"; + $vtp->setVar( $sub, 'params.width_value', '128' ); } - $output.="\"/>".$lang['tn_params_height_info']."
    ".$lang['tn_params_create']."
    - - ".$lang['tn_params_create_info']."
    ".$lang['tn_params_format']."
    jpeg".$lang['tn_params_format_info']."
     
    - -
    -
    "; - //-----------------------------------liste des images sans miniature - $images = get_images_without_thumbnail( $HTTP_GET_VARS['dir'] ); - $style = "class=\"row2\" style=\"text-align:center;font-weight:bold;"; - $output.= " - - - - - - - - - - - "; - for ( $i = 0; $i < sizeof( $images ); $i++ ) + // height value + if ( isset( $_POST['height'] ) ) { - $num = $i + 1; - $class = ""; - if ( $i%2 == 1 ) + $vtp->setVar( $sub, 'params.height_value', $_POST['height'] ); + } + else + { + $vtp->setVar( $sub, 'params.height_value', '96' ); + } + // options for the number of picture to miniaturize : "n" + $options = array( 5,10,20,40 ); + foreach ( $options as $option ) { + $vtp->addSession( $sub, 'n_option' ); + $vtp->setVar( $sub, 'n_option.option', $option ); + if ( $option == $_POST['n'] ) { - $class = " class=\"row2\""; + $vtp->setVar( $sub, 'n_option.selected', ' selected="selected"' ); } - $output.= " - - - - - - - "; + $vtp->closeSession( $sub, 'n_option' ); } - $output.= " -
    ".sizeof( $images )." ".$lang['tn_alone_title']."
     ".$lang['tn_picture']."".$lang['tn_filesize']."".$lang['tn_width']."".$lang['tn_height']."
    ".$num."
    ".$images[$i]['name']."
    ".$images[$i]['size']."
    ".$images[$i]['width']."
    ".$images[$i]['height']."
    "; + $vtp->closeSession( $sub, 'params' ); +//---------------------------------------------------------- remaining pictures + $vtp->addSession( $sub, 'remainings' ); + $pictures = get_images_without_thumbnail( $_GET['dir'] ); + $vtp->setVar( $sub, 'remainings.total', count( $pictures ) ); + foreach ( $pictures as $i => $picture ) { + $vtp->addSession( $sub, 'remaining' ); + if ( $i % 2 == 1 ) + { + $vtp->setVar( $sub, 'remaining.class', 'row2' ); + } + $vtp->setVar( $sub, 'remaining.num', ($i+1) ); + $vtp->setVar( $sub, 'remaining.file', $picture['name'] ); + $vtp->setVar( $sub, 'remaining.filesize', $picture['size'] ); + $vtp->setVar( $sub, 'remaining.width', $picture['width'] ); + $vtp->setVar( $sub, 'remaining.height', $picture['height'] ); + $vtp->closeSession( $sub, 'remaining' ); + } + $vtp->closeSession( $sub, 'remainings' ); } } -//-----------------------------------liste des répertoires -//-------------------------si aucun répertoire selectionné +//-------------------------------------------------------------- directory list else { - $output = " - - - - "; - $output.= " - - - -
    ".$lang['tn_dirs_title']."
    -
    - \"\"/galleries"; - $output.= "
    "; - $output.= get_displayed_dirs( "../galleries", "        " ); - $output.= " -
    -
    "; + $vtp->addSession( $sub, 'directory_list' ); + get_displayed_dirs( '../galleries', 60 ); + $vtp->closeSession( $sub, 'directory_list' ); } -echo $output; +//----------------------------------------------------------- sending html code +$vtp->Parse( $handle , 'sub', $sub ); ?> \ No newline at end of file diff --git a/admin/update.php b/admin/update.php index bdd4d8a43..eefd913c1 100644 --- a/admin/update.php +++ b/admin/update.php @@ -187,20 +187,21 @@ function insert_local_image( $rep, $category_id ) // searching the new images in the directory $pictures = array(); $tn_ext = ''; - if ( $opendir = opendir ( $rep ) ) + if ( $opendir = opendir( $rep ) ) { - while ( $file = readdir ( $opendir ) ) + while ( $file = readdir( $opendir ) ) { if ( is_file( $rep.'/'.$file ) and is_image( $rep.'/'.$file ) ) { // is the picture waiting for validation by an administrator ? - $query = 'SELECT id'; + $query = 'SELECT id,validated,infos'; $query.= ' FROM '.PREFIX_TABLE.'waiting'; $query.= ' WHERE cat_id = '.$category_id; $query.= " AND file = '".$file."'"; $query.= ';'; $result = mysql_query( $query ); - if ( mysql_num_rows( $result ) == 0 ) + $waiting = mysql_fetch_array( $result ); + if (mysql_num_rows( $result ) == 0 or $waiting['validated'] == 'true') { if ( $tn_ext = TN_exists( $rep, $file ) ) { @@ -214,13 +215,33 @@ function insert_local_image( $rep, $category_id ) if ( mysql_num_rows( $result ) == 0 ) { $picture = array(); - $picture['file'] = $file; - $picture['tn_ext'] = $tn_ext; + $picture['file'] = $file; + $picture['tn_ext'] = $tn_ext; $picture['date'] = date( 'Y-m-d', filemtime ( $rep.'/'.$file ) ); $picture['filesize'] = floor( filesize( $rep.'/'.$file ) / 1024); $image_size = @getimagesize( $rep.'/'.$file ); - $picture['width'] = $image_size[0]; - $picture['height'] = $image_size[1]; + $picture['width'] = $image_size[0]; + $picture['height'] = $image_size[1]; + if ( $waiting['validated'] == 'true' ) + { + // retrieving infos from the XML description of + // $waiting['infos'] + $infos = nl2br( $waiting['infos'] ); + $picture['author'] = getAttribute( $infos, 'author' ); + $picture['comment'] = getAttribute( $infos, 'comment' ); + $unixtime = getAttribute( $infos, 'date_creation' ); + $picture['date_creation'] = ''; + if ( $unixtime != '' ) + { + $picture['date_creation'] = date( 'Y-m-d', $unixtime ); + } + $picture['name'] = getAttribute( $infos, 'name' ); + // deleting the waiting element + $query = 'DELETE FROM '.PREFIX_TABLE.'waiting'; + $query.= ' WHERE id = '.$waiting['id']; + $query.= ';'; + mysql_query( $query ); + } array_push( $pictures, $picture ); } } @@ -242,13 +263,23 @@ function insert_local_image( $rep, $category_id ) // inserting the pictures found in the directory foreach ( $pictures as $picture ) { $query = 'INSERT INTO '.PREFIX_TABLE.'images'; - $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height)'; + $query.= ' (file,cat_id,date_available,tn_ext,filesize,width,height'; + $query.= ',name,author,comment,date_creation)'; $query.= ' VALUES '; $query.= "('".$picture['file']."','".$category_id."'"; $query.= ",'".$picture['date']."','".$picture['tn_ext']."'"; $query.= ",'".$picture['filesize']."','".$picture['width']."'"; - $query.= ",'".$picture['height']."')"; - $query.= ';'; + $query.= ",'".$picture['height']."','".$picture['name']."'"; + $query.= ",'".$picture['author']."','".$picture['comment']."'"; + if ( $picture['date_creation'] != '' ) + { + $query.= ",'".$picture['date_creation']."'"; + } + else + { + $query.= ',NULL'; + } + $query.= ');'; mysql_query( $query ); $count_new++; @@ -283,7 +314,7 @@ function update_cat_info( $category_id ) $nb_images = $row['nb_images']; $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= " SET date_dernier = '".$date_last."'"; + $query.= " SET date_last = '".$date_last."'"; $query.= ', nb_images = '.$nb_images; $query.= ' where id = '.$category_id; $query.= ';'; diff --git a/admin/waiting.php b/admin/waiting.php index 2f1964266..2525c95ab 100644 --- a/admin/waiting.php +++ b/admin/waiting.php @@ -1,9 +1,9 @@ * * * ***************************************************************************/ @@ -14,104 +14,121 @@ * the Free Software Foundation; * * * ***************************************************************************/ - include_once( "./include/isadmin.inc.php" ); - //-------------------------------------------------------------- mise à jour - if ( isset( $HTTP_POST_VARS['submit'] ) ) - { - $query = "select id,cat_id,file,tn_ext"; - $query.= " from PREFIX_TABLE"."waiting"; - $query.= ";"; - $result = mysql_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) - { - $key = "validate-".$row['id']; - if ( isset( $HTTP_POST_VARS[$key] ) ) - { - $query = "delete from PREFIX_TABLE"."waiting"; - $query.= " where id = ".$row['id']; - $query.= ";"; - mysql_query( $query ); - if ( $HTTP_POST_VARS[$key] == "false" ) - { - // we have to delete the picture and the thumbnail if it exists - $cat = get_cat_info( $row['cat_id'] ); - unlink( ".".$cat['dir'].$row['file'] ); - if ( $row['tn_ext'] != "" ) - { - $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); - unlink( ".".$cat['dir']."thumbnail/".$conf['prefix_thumbnail'].$file.".".$row['tn_ext'] ); - } - } - } - } - } - //--------------------------------------------------------------- formulaire - $cat_names = array(); - echo " -
    - - - - - - - - - "; - $query = "select id,cat_id,file,username,mail_address,date,tn_ext"; - $query.= " from PREFIX_TABLE"."waiting"; - $query.= " order by cat_id"; - $query.= ";"; - $result = mysql_query( $query ); - $i = 0; - while ( $row = mysql_fetch_array( $result ) ) - { - $style = ""; - if ( $i%2 == 0 ) - { - $style = "class=\"row2\""; - } - if ( !isset( $cat_names[$row['cat_id']] ) ) - { - $cat = get_cat_info( $row['cat_id'] ); - $cat_names[$row['cat_id']] = array(); - $cat_names[$row['cat_id']]['dir'] = ".".$cat['dir']; - $cat_names[$row['cat_id']]['display_name'] = get_cat_display_name( $cat['name'], " - ", "font-style:italic;" ); - } - echo " - - - - - - - - - "; - $i++; - } - echo " - - - "; - echo " -
    ".$lang['category']."".$lang['date']."".$lang['file']."".$lang['thumbnail']."".$lang['author']." 
    ".$cat_names[$row['cat_id']]['display_name']."".$lang['day'][date( "w", $row['date'] )].date( " j ", $row['date'] ).$lang['month'][date( "n", $row['date'] )].date( " Y G:i", $row['date'] )." - ".$row['file'].""; - if ( $row['tn_ext'] != "" ) - { - $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); - echo "".$conf['prefix_thumbnail'].$file.".".$row['tn_ext']; - } - else - { - echo " "; - } - echo " - - ".$row['username']." - - ".$lang['submit']." - ".$lang['delete']." -
    -
    "; +include_once( './include/isadmin.inc.php' ); +//--------------------------------------------------------------------- updates +if ( isset( $_POST['submit'] ) ) +{ + $query = 'SELECT id,cat_id,file,tn_ext'; + $query.= ' FROM '.PREFIX_TABLE.'waiting'; + $query.= " WHERE validated = 'false'"; + $query.= ';'; + $result = mysql_query( $query ); + while ( $row = mysql_fetch_array( $result ) ) + { + $key = 'validate-'.$row['id']; + if ( isset( $_POST[$key] ) ) + { + if ( $_POST[$key] == 'true' ) + { + // The uploaded element was validated, we have to set the + // "validated" field to "true" + $query = 'UPDATE '.PREFIX_TABLE.'waiting'; + $query.= " SET validated = 'true'"; + $query.= ' WHERE id = '.$row['id']; + $query.= ';'; + mysql_query( $query ); + } + else + { + // The uploaded element was refused, we have to delete its reference + // in the database and to delete the element as well. + $query = 'DELETE FROM '.PREFIX_TABLE.'waiting'; + $query.= ' WHERE id = '.$row['id']; + $query.= ';'; + mysql_query( $query ); + // deletion of the associated files + $cat = get_cat_info( $row['cat_id'] ); + unlink( '.'.$cat['dir'].$row['file'] ); + if ( $row['tn_ext'] != '' ) + { + $thumbnail = $conf['prefix_thumbnail']; + $thumbnail.= get_filename_wo_extension( $row['file'] ); + $thumbnail.= '.'.$row['tn_ext']; + $url = '.'.$cat['dir'].'thumbnail/'.$thumbnail; + unlink( $url ); + } + } + } + } +} +//----------------------------------------------------- template initialization +$sub = $vtp->Open( '../template/'.$user['template'].'/admin/waiting.vtp' ); +$tpl = array( 'category','date','author','thumbnail','file','delete', + 'submit' ); +templatize_array( $tpl, 'lang', $sub ); +//---------------------------------------------------------------- form display +$cat_names = array(); +$query = 'SELECT id,cat_id,file,username,mail_address,date,tn_ext'; +$query.= ' FROM '.PREFIX_TABLE.'waiting'; +$query.= " WHERE validated = 'false'"; +$query.= ' ORDER BY cat_id'; +$query.= ';'; +$result = mysql_query( $query ); +$i = 0; +while ( $row = mysql_fetch_array( $result ) ) +{ + $vtp->addSession( $sub, 'picture' ); + $vtp->setVar( $sub, 'picture.id', $row['id'] ); + if ( $i++ % 2 == 0 ) + { + $vtp->setVar( $sub, 'picture.class', 'row2' ); + } + if ( !isset( $cat_names[$row['cat_id']] ) ) + { + $cat = get_cat_info( $row['cat_id'] ); + $cat_names[$row['cat_id']] = array(); + $cat_names[$row['cat_id']]['dir'] = '.'.$cat['dir']; + $cat_names[$row['cat_id']]['display_name'] = + get_cat_display_name( $cat['name'], ' > ', 'font-weight:bold;' ); + } + // category name + $vtp->setVar( $sub, 'picture.cat_name', + $cat_names[$row['cat_id']]['display_name'] ); + // date displayed like this (in English ) : + // Sunday 15 June 2003 21:29 + $date = $lang['day'][date( 'w', $row['date'] )]; // Sunday + $date.= date( ' j ', $row['date'] ); // 15 + $date.= $lang['month'][date( 'n', $row['date'] )]; // June + $date.= date( ' Y G:i', $row['date'] ); // 2003 21:29 + $vtp->setVar( $sub, 'picture.date', $date ); + // file preview link + $url = $cat_names[$row['cat_id']]['dir'].$row['file']; + $vtp->setVar( $sub, 'picture.preview_url', $url ); + // file name + $vtp->setVar( $sub, 'picture.file', $row['file'] ); + // is there an existing associated thumnail ? + if ( $row['tn_ext'] != '' ) + { + $vtp->addSession( $sub, 'thumbnail' ); + $thumbnail = $conf['prefix_thumbnail']; + $thumbnail.= get_filename_wo_extension( $row['file'] ); + $thumbnail.= '.'.$row['tn_ext']; + $url = $cat_names[$row['cat_id']]['dir'].'thumbnail/'.$thumbnail; + $vtp->setVar( $sub, 'thumbnail.preview_url', $url ); + $vtp->setVar( $sub, 'thumbnail.file', $thumbnail ); + $vtp->closeSession( $sub, 'thumbnail' ); + } + else + { + $vtp->addSession( $sub, 'no_thumbnail' ); + $vtp->closeSession( $sub, 'no_thumbnail' ); + } + // username and associated mail address + $vtp->setVar( $sub, 'picture.mail_address', $row['mail_address'] ); + $vtp->setVar( $sub, 'picture.username', $row['username'] ); + + $vtp->closeSession( $sub, 'picture' ); +} +//----------------------------------------------------------- sending html code +$vtp->Parse( $handle , 'sub', $sub ); ?> \ No newline at end of file diff --git a/category.php b/category.php index 37e7deea0..0e5c8077d 100644 --- a/category.php +++ b/category.php @@ -20,7 +20,13 @@ $t2 = explode( '.', $t1[0] ); $t2 = $t1[1].'.'.$t2[1]; //----------------------------------------------------------- personnal include include_once( './include/init.inc.php' ); +$output.= 'after init.inc.php : '.get_elapsed_time( $t2, get_moment() ).'
    '; //-------------------------------------------------- access authorization check +// creating the plain structure : array of all the available categories and +// their relative informations, see the definition of the function +// get_plain_structure for further details. +$page['plain_structure'] = get_plain_structure(); + check_cat_id( $_GET['cat'] ); check_login_authorization(); if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) @@ -34,33 +40,18 @@ if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) $page['tab_expand'] = array(); if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' ) { - $j = 0; - $tab_expand = explode( ",", $_GET['expand'] ); - $size = sizeof( $tab_expand ); - for ( $i = 0; $i < $size; $i++ ) - { - if ( is_numeric( $tab_expand[$i] ) ) - { - $page['tab_expand'][$j++] = $tab_expand[$i]; - } + $tab_expand = explode( ',', $_GET['expand'] ); + foreach ( $tab_expand as $id ) { + if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id ); } $page['expand'] = implode( ',', $page['tab_expand'] ); } // in case of expanding all authorized cats // The $page['expand'] equals 'all' and // $page['tab_expand'] contains all the authorized cat ids -if ( $user['expand'] == 'true' or $_GET['expand'] == 'all' ) +if ( $user['expand'] or $_GET['expand'] == 'all' ) { $page['tab_expand'] = array(); - $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE id_uppercat IS NULL;'; - $result = mysql_query( $query ); - $i = 0; - while ( $row = mysql_fetch_array( $result ) ) - { - $page['tab_expand'][$i++] = $row['id']; - } $page['expand'] = 'all'; } // detection of the start picture to display @@ -83,23 +74,28 @@ if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 ) $page['start'] = floor( $_GET['num'] / $user['nb_image_page'] ); $page['start']*= $user['nb_image_page']; } +// creating the structure of the categories (useful for displaying the menu) +$page['structure'] = create_structure( '', $user['restrictions'] ); +$page['structure'] = update_structure( $page['structure'] ); initialize_category(); +$output.= 'before template init : '.get_elapsed_time( $t2, get_moment() ).'
    '; //----------------------------------------------------- template initialization $vtp = new VTemplate; $handle = $vtp->Open( './template/'.$user['template'].'/category.vtp' ); initialize_template(); - -$tpl = array( 'categories','hint_category','sub-cat','images_available', - 'total','title_menu','nb_image_category','send_mail', - 'title_send_mail','generation_time','upload_name', - 'connected_user','recent_image','days','generation_time', - 'favorite_cat_hint','favorite_cat','stats', - 'most_visited_cat_hint','most_visited_cat','recent_cat', - 'recent_cat_hint' ); +$output.= 'before lang array : '.get_elapsed_time( $t2, get_moment() ).'
    '; +$tpl = array( + 'categories','hint_category','sub-cat','images_available','total', + 'title_menu','nb_image_category','send_mail','title_send_mail', + 'generation_time','connected_user','recent_image','days','generation_time', + 'favorite_cat_hint','favorite_cat','stats','most_visited_cat_hint', + 'most_visited_cat','recent_cat','recent_cat_hint','upload_picture' ); templatize_array( $tpl, 'lang', $handle ); +$output.= 'after lang array : '.get_elapsed_time( $t2, get_moment() ).'
    '; $tpl = array( 'mail_webmaster','webmaster','top_number','version','site_url' ); templatize_array( $tpl, 'conf', $handle ); +$output.= 'after conf array : '.get_elapsed_time( $t2, get_moment() ).'
    '; $tpl = array( 'short_period','long_period','lien_collapsed', 'username' ); templatize_array( $tpl, 'user', $handle ); @@ -111,17 +107,22 @@ templatize_array( $tpl, 'page', $handle ); $vtp->setGlobalVar( $handle, 'icon_short', get_icon( time() ) ); $icon_long = get_icon( time() - ( $user['short_period'] * 24 * 60 * 60 + 1 ) ); $vtp->setGlobalVar( $handle, 'icon_long', $icon_long ); -$nb_total_pictures = get_total_image( "", $user['restrictions'] ); +$nb_total_pictures = count_images( $page['structure'] ); $vtp->setGlobalVar( $handle, 'nb_total_pictures',$nb_total_pictures ); //------------------------------------------------------------- categories menu +$output.= 'before menu : '.get_elapsed_time( $t2, get_moment() ).'
    '; // normal categories -display_cat( '', ' ', $user['restrictions'], $page['tab_expand'] ); +foreach ( $page['structure'] as $category ) { + // display category is a function relative to the template + display_category( $category, ' ', $handle ); +} +$output.= 'after menu : '.get_elapsed_time( $t2, get_moment() ).'
    '; // favorites cat if ( !$user['is_the_guest'] ) { $vtp->addSession( $handle, 'favorites' ); - $url = add_session_id('./category.php?cat=fav&expand='.$page['expand'] ); - $vtp->setVar( $handle, 'favorites.url', $url ); + $url = './category.php?cat=fav&expand='.$page['expand']; + $vtp->setVar( $handle, 'favorites.url', add_session_id( $url ) ); // searching the number of favorite picture $query = 'SELECT COUNT(*) AS count'; $query.= ' FROM '.PREFIX_TABLE.'favorites'; @@ -132,27 +133,23 @@ if ( !$user['is_the_guest'] ) $vtp->closeSession( $handle, 'favorites' ); } // most visited pictures category -$url = add_session_id( './category.php?cat=most_visited'. - '&expand='.$page['expand'] ); -$vtp->setGlobalVar( $handle, 'most_visited_url', $url ); +$url = './category.php?cat=most_visited&expand='.$page['expand']; +$vtp->setGlobalVar( $handle, 'most_visited_url', add_session_id( $url ) ); // recent pictures -$url = add_session_id( './category.php?cat=recent'. - '&expand='.$page['expand'] ); -$vtp->setGlobalVar( $handle, 'recent_url', $url ); +$url = './category.php?cat=recent&expand='.$page['expand']; +$vtp->setGlobalVar( $handle, 'recent_url', add_session_id( $url ) ); //--------------------------------------------------------------------- summary $vtp->addSession( $handle, 'summary' ); $vtp->setVar( $handle, 'summary.url', './identification.php' ); if ( !$user['is_the_guest'] ) { $vtp->setVar( $handle, 'summary.title', '' ); - $vtp->setVar( $handle, 'summary.name', - replace_space( $lang['change_login'] ) ); + $vtp->setVar( $handle, 'summary.name',replace_space($lang['change_login'])); } else { $vtp->setVar( $handle, 'summary.title', $lang['hint_login'] ); - $vtp->setVar( $handle, 'summary.name', - replace_space( $lang['login'] ) ); + $vtp->setVar( $handle, 'summary.name', replace_space( $lang['login'] ) ); } $vtp->closeSession( $handle, 'summary' ); // links for registered users @@ -185,8 +182,8 @@ $vtp->setVar( $handle, 'summary.name', replace_space( $lang['search'] ) ); $vtp->closeSession( $handle, 'summary' ); // about link $vtp->addSession( $handle, 'summary' ); -$vtp->setVar( $handle, 'summary.url', - add_session_id( './about.php?'.$_SERVER['QUERY_STRING'] ) ); +$vtp->setVar( $handle, 'summary.url', './about.php?'. + str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) ); $vtp->setVar( $handle, 'summary.title', $lang['hint_about'] ); $vtp->setVar( $handle, 'summary.name', replace_space( $lang['about'] ) ); $vtp->closeSession( $handle, 'summary' ); @@ -226,6 +223,7 @@ else replace_space( $lang['no_category'] ) ); } //------------------------------------------------------------------ thumbnails +$output.= 'before thumbs : '.get_elapsed_time( $t2, get_moment() ).'
    '; if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 ) { if ( is_numeric( $page['cat'] ) ) @@ -317,6 +315,7 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 ) $query = 'SELECT COUNT(*) AS nb_comments'; $query.= ' FROM '.PREFIX_TABLE.'comments'; $query.= ' WHERE image_id = '.$row['id']; + $query.= " AND validated = 'true'"; $query.= ';'; $row = mysql_fetch_array( mysql_query( $query ) ); $vtp->setVar( $handle, 'nb_comments.nb', $row['nb_comments'] ); @@ -341,65 +340,58 @@ if ( isset( $page['cat'] ) and $page['cat_nb_images'] != 0 ) } $vtp->closeSession( $handle, 'thumbnails' ); } -elseif ( isset( $page['cat'] ) - and is_numeric( $page['cat'] ) - and $page['cat_nb_images'] == 0 ) +//-------------------------------------------------------------- empty category +elseif ( ( isset( $page['cat'] ) + and is_numeric( $page['cat'] ) + and $page['cat_nb_images'] == 0 ) + or $_GET['cat'] == '' ) { $vtp->addSession( $handle, 'thumbnails' ); $vtp->addSession( $handle, 'line' ); - $subcats = get_non_empty_sub_cat_ids( $page['cat'] ); + $subcats = get_non_empty_subcat_ids( $page['cat'] ); $cell_number = 1; - foreach ( $subcats as $id => $subcat ) { - $result = get_cat_info( $subcat['non_empty_cat'] ); - $cat_directory = $result['dir']; + $i = 0; + foreach ( $subcats as $subcat_id => $non_empty_id ) { + $subcat_infos = get_cat_info( $subcat_id ); + $non_empty_infos = get_cat_info( $non_empty_id ); - $name = '[ '; - if ( $subcat['name'] != '' ) - { - $name.= $subcat['name']; - } - else - { - $name.= $subcat['dir']; - } + $name ='[ '; + $name.= $subcat_infos['name'][0]; $name.= ' ]'; - $name = replace_space( $name ); $query = 'SELECT file,tn_ext'; $query.= ' FROM '.PREFIX_TABLE.'images'; - $query.= ' WHERE cat_id = '.$subcat['non_empty_cat']; + $query.= ' WHERE cat_id = '.$non_empty_id; $query.= ' ORDER BY RAND()'; $query.= ' LIMIT 0,1'; $query.= ';'; $image_result = mysql_query( $query ); - $image_row = mysql_fetch_array( $image_result ); + $image_row = mysql_fetch_array( $image_result ); $file = get_filename_wo_extension( $image_row['file'] ); // creating links for thumbnail and associated category - $lien_image = $cat_directory; - $lien_thumbnail = $lien_image; - $lien_thumbnail.= 'thumbnail/'.$conf['prefix_thumbnail']; - $lien_thumbnail.= $file.'.'.$image_row['tn_ext']; - $lien_image.= $image_row['file']; + $thumbnail_link = $non_empty_infos['dir']; + $thumbnail_link.= 'thumbnail/'.$conf['prefix_thumbnail']; + $thumbnail_link.= $file.'.'.$image_row['tn_ext']; $thumbnail_title = $lang['hint_category']; - $url_link = './category.php?cat='.$subcat['id']; + $url_link = './category.php?cat='.$subcat_id; if ( !in_array( $page['cat'], $page['tab_expand'] ) ) { array_push( $page['tab_expand'], $page['cat'] ); $page['expand'] = implode( ',', $page['tab_expand'] ); } $url_link.= '&expand='.$page['expand']; - list( $year,$month,$day ) = explode( '-', $subcat['date_dernier'] ); + list( $year,$month,$day ) = explode( '-', $subcat_infos['date_last'] ); $date = mktime( 0, 0, 0, $month, $day, $year ); // sending vars to display $vtp->addSession( $handle, 'thumbnail' ); $vtp->setVar( $handle, 'thumbnail.url', add_session_id( $url_link ) ); - $vtp->setVar( $handle, 'thumbnail.src', $lien_thumbnail ); + $vtp->setVar( $handle, 'thumbnail.src', $thumbnail_link ); $vtp->setVar( $handle, 'thumbnail.alt', $image_row['file'] ); $vtp->setVar( $handle, 'thumbnail.title', $thumbnail_title ); $vtp->setVar( $handle, 'thumbnail.name', $name ); @@ -411,18 +403,19 @@ elseif ( isset( $page['cat'] ) $vtp->closeSession( $handle, 'line' ); $cell_number = 1; // we open a new line if the subcat was not the last one - if ( $id < count( $subcats ) - 1 ) + if ( $i++ < count( $subcats ) - 1 ) { $vtp->addSession( $handle, 'line' ); } } } - if ( $id < count( $subcats ) - 1 ) + if ( $i < count( $subcats ) - 1 ) { $vtp->closeSession( $handle, 'line' ); } $vtp->closeSession( $handle, 'thumbnails' ); } +$output.= 'after thumbs : '.get_elapsed_time( $t2, get_moment() ).'
    '; //------------------------------------------------------- category informations if ( isset ( $page['cat'] ) ) { @@ -469,5 +462,6 @@ $time = get_elapsed_time( $t2, get_moment() ); $vtp->setGlobalVar( $handle, 'time', $time ); //----------------------------------------------------------- html code display $code = $vtp->Display( $handle, 0 ); +echo $output; echo $code; ?> \ No newline at end of file diff --git a/identification.php b/identification.php index 5f10f106a..c88719d03 100644 --- a/identification.php +++ b/identification.php @@ -57,12 +57,8 @@ $vtp->setGlobalVar( $handle, 'ident_forgotten_password', // conf $vtp->setGlobalVar( $handle, 'mail_webmaster', $conf['mail_webmaster'] ); // user -$vtp->setGlobalVar( $handle, 'page_style', $user['style'] ); -$vtp->setGlobalVar( $handle, 'user_theme', $user['theme'] ); -// structure -$vtp->setGlobalVar( $handle, 'frame_start', get_frame_start() ); -$vtp->setGlobalVar( $handle, 'frame_begin', get_frame_begin() ); -$vtp->setGlobalVar( $handle, 'frame_end', get_frame_end() ); +$vtp->setGlobalVar( $handle, 'user_template', $user['template'] ); +initialize_template(); //-------------------------------------------------------------- errors display if ( sizeof( $error ) != 0 ) { diff --git a/include/config.inc.php b/include/config.inc.php index 7df262d11..e664d37e5 100644 --- a/include/config.inc.php +++ b/include/config.inc.php @@ -22,7 +22,6 @@ $lang = array(); include_once( PREFIX_INCLUDE.'./include/functions.inc.php' ); include_once( PREFIX_INCLUDE.'./include/vtemplate.class.php' ); - // How to change the order of display for images in a category ? // // You have to modify $conf['order_by']. @@ -39,8 +38,10 @@ include_once( PREFIX_INCLUDE.'./include/vtemplate.class.php' ); // without taking into account the date_available $conf['order_by'] = ' ORDER BY date_available DESC, file ASC'; -$conf['nb_image_row'] = array('4','5','6','7','8'); -$conf['nb_row_page'] = array('2','3','4','5','6','7','10','20','1000'); +$conf['nb_image_row'] = array(4,5,6,7,8); +$conf['nb_row_page'] = array(2,3,4,5,6,7,10,20,1000); +$conf['slideshow_period'] = array(2,5,10); +$conf['last_days'] = array(1,2,3,10,30,365); $conf['version'] = '1.3'; $conf['site_url'] = 'http://www.phpwebgallery.net'; $conf['forum_url'] = 'http://forum.phpwebgallery.net'; @@ -58,12 +59,11 @@ $infos = array( 'prefix_thumbnail', 'webmaster', 'mail_webmaster', 'access', 'max_user_listbox', 'show_comments', 'nb_comment_page', 'upload_available', 'upload_maxfilesize', 'upload_maxwidth', 'upload_maxheight', 'upload_maxwidth_thumbnail', - 'upload_maxheight_thumbnail' ); + 'upload_maxheight_thumbnail','log','comments_validation' ); -$query = 'SELECT'; +$query = 'SELECT '; foreach ( $infos as $i => $info ) { if ( $i > 0 ) $query.= ','; - else $query.= ' '; $query.= $info; } $query.= ' FROM '.PREFIX_TABLE.'config;'; @@ -81,6 +81,5 @@ foreach ( $infos as $info ) { $conf[$info] = get_boolean( $row[$info] ); } } -$conf['log'] = false; $conf['top_number'] = 20; ?> \ No newline at end of file diff --git a/include/functions.inc.php b/include/functions.inc.php index ec9081dce..5a672a0d4 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -66,16 +66,14 @@ function get_boolean( $string ) // this array. function array_remove( $array, $value ) { - $i = 0; $output = array(); - foreach ( $array as $v ) + foreach ( $array as $v ) { + if ( $v != $value ) { - if ( $v != $value ) - { - $output[$i++] = $v; - } + array_push( $output, $v ); } - return implode( ',', $output ); + } + return $output; } // The function get_moment returns a float value coresponding to the number @@ -320,15 +318,6 @@ function replace_search( $string, $search ) function database_connection() { -// $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' ); -// $mysql_conf = getChild( $xml_content, 'mysql' ); - -// $cfgHote = getAttribute( $mysql_conf, 'host' ); -// $cfgUser = getAttribute( $mysql_conf, 'user' ); -// $cfgPassword = getAttribute( $mysql_conf, 'password' ); -// $cfgBase = getAttribute( $mysql_conf, 'base' ); -// define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) ); - include( PREFIX_INCLUDE.'./include/mysql.inc.php' ); define( PREFIX_TABLE, $prefix_table ); @@ -346,7 +335,7 @@ function pwg_log( $file, $category, $picture = '' ) { $query = 'insert into '.PREFIX_TABLE.'history'; $query.= ' (date,login,IP,file,category,picture) values'; - $query.= " (".time().", '".$user['pseudo']."'"; + $query.= " (".time().", '".$user['username']."'"; $query.= ",'".$_SERVER['REMOTE_ADDR']."'"; $query.= ",'".$file."','".$category."','".$picture."');"; mysql_query( $query ); @@ -357,10 +346,8 @@ function templatize_array( $array, $global_array_name, $handle ) { global $vtp, $lang, $page, $user, $conf; - for( $i = 0; $i < sizeof( $array ); $i++ ) - { - $vtp->setGlobalVar( $handle, $array[$i], - ${$global_array_name}[$array[$i]] ); + foreach ( $array as $value ) { + $vtp->setGlobalVar( $handle, $value, ${$global_array_name}[$value] ); } } ?> \ No newline at end of file diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index de868db82..989349466 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -59,11 +59,18 @@ function check_cat_id( $cat ) unset( $page['cat'] ); if ( isset( $cat ) ) { - if ( is_numeric( $cat ) ) + if ( isset( $page['plain_structure'] ) ) { - $query = 'select id'; - $query.= ' from '.PREFIX_TABLE.'categories'; - $query.= ' where id = '.$cat; + if ( isset( $page['plain_structure'][$cat] ) ) + { + $page['cat'] = $cat; + } + } + else if ( is_numeric( $cat ) ) + { + $query = 'SELECT id'; + $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' WHERE id = '.$cat; $query. ';'; $result = mysql_query( $query ); if ( mysql_num_rows( $result ) != 0 ) @@ -71,176 +78,189 @@ function check_cat_id( $cat ) $page['cat'] = $cat; } } - if ( $cat == 'fav' or $cat == 'search' or $cat == 'most_visited' - or $cat == 'best_rated' or $cat == 'recent' ) + if ( $cat == 'fav' + or $cat == 'search' + or $cat == 'most_visited' + or $cat == 'best_rated' + or $cat == 'recent' ) { $page['cat'] = $cat; } } } -function display_cat( $id_uppercat, $indent, $restriction, $tab_expand ) +function get_plain_structure() { - global $user,$lang,$conf,$page,$vtp,$handle; + $infos = array( 'name','id','date_last','nb_images','dir','id_uppercat', + 'rank'); - $query = 'select name,id,date_dernier,nb_images,dir'; - $query.= ' from '.PREFIX_TABLE.'categories'; - $query.= ' where id_uppercat'; - if ( $id_uppercat == "" ) - { - $query.= ' is NULL'; + $query = 'SELECT '; + foreach ( $infos as $i => $info ) { + if ( $i > 0 ) $query.= ','; + $query.= $info; } - else - { - $query.= ' = '.$id_uppercat; - } - $query.= ' order by rank asc;'; + $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' ORDER BY id_uppercat ASC, rank ASC'; + $query.= ';'; + + $plain_structure = array(); $result = mysql_query( $query ); while ( $row = mysql_fetch_array( $result ) ) { - if ( !in_array( $row['id'], $restriction ) ) - { - $nb_subcats = get_nb_subcats( $row['id'] ); - - $expand = ""; - // si la catégorie n'a pas de sous catégorie - // ou que l'on doit développer toutes les catégories par défaut - // alors on utilise l'expand par défaut - if ( $nb_subcats == 0 or $user['expand'] == "true" ) + $category = array(); + foreach ( $infos as $info ) { + $category[$info] = $row[$info]; + if ( $info == 'date_last' ) { - $expand = $page['expand']; - } - // si la catégorie n'est pas dans les catégories à développer - // alors on l'ajoute aux catégories à développer - else if ( !in_array( $row['id'], $tab_expand ) ) - { - $expand = implode( ",", $tab_expand ); - if ( strlen( $expand ) > 0 ) - { - $expand.= ","; - } - $expand.= $row['id']; - } - // si la catégorie est déjà dans les catégories à développer - // alors on la retire des catégories à développer - else - { - $expand = array_remove( $tab_expand, $row['id'] ); - } - $url = "./category.php?cat=".$page['cat']."&expand=$expand"; - if ( $page['cat'] == 'search' ) - { - $url.= "&search=".$_GET['search'].'&mode='.$_GET['mode']; - } - $lien_cat = add_session_id( $url ); - if ( $row['name'] == "" ) - { - $name = str_replace( "_", " ", $row['dir'] ); - } - else - { - $name = $row['name']; - } - - $vtp->addSession( $handle, 'category' ); - $vtp->setVar( $handle, 'category.indent', $indent ); - - if ( $user['expand'] == "true" or $nb_subcats == 0 ) - { - $vtp->addSession( $handle, 'bullet_wo_link' ); - $vtp->setVar( $handle, 'bullet_wo_link.bullet_url', - $user['lien_collapsed'] ); - $vtp->setVar( $handle, 'bullet_wo_link.bullet_alt', '>' ); - $vtp->closeSession( $handle, 'bullet_wo_link' ); - } - else - { - $vtp->addSession( $handle, 'bullet_w_link' ); - $vtp->setVar( $handle, 'bullet_w_link.bullet_link', $lien_cat ); - $vtp->setVar( $handle, 'bullet_w_link.bullet_alt', '>' ); - if ( in_array( $row['id'], $tab_expand ) ) - { - $vtp->setVar( $handle, 'bullet_w_link.bullet_url', - $user['lien_expanded'] ); - } - else - { - $vtp->setVar( $handle, 'bullet_w_link.bullet_url', - $user['lien_collapsed'] ); - } - $vtp->closeSession( $handle, 'bullet_w_link' ); - } - $vtp->setVar( $handle, 'category.link_url', - add_session_id( './category.php?cat='. - $row['id'].'&expand='.$expand ) ); - $vtp->setVar( $handle, 'category.link_name', $name ); - if ( $id_uppercat == "" ) - { - $vtp->setVar( $handle, 'category.name_style', 'font-weight:bold;' ); - } - if ( $nb_subcats > 0 ) - { - $vtp->addSession( $handle, 'subcat' ); - $vtp->setVar( $handle, 'subcat.nb_subcats', $nb_subcats ); - $vtp->closeSession( $handle, 'subcat' ); - } - $vtp->setVar( $handle, 'category.total_cat', $row['nb_images'] ); - $date_dispo = explode( "-", $row['date_dernier'] ); - $date_cat = mktime( 0, 0, 0, $date_dispo[1], $date_dispo[2], - $date_dispo[0] ); - $vtp->setVar( $handle, 'category.cat_icon', get_icon( $date_cat ) ); - $vtp->closeSession( $handle, 'category' ); - - if ( in_array( $row['id'], $tab_expand ) or $user['expand'] == "true" ) - { - display_cat( $row['id'], $indent.'    ', - $restriction, $tab_expand ); + list($year,$month,$day) = explode( '-', $row[$info] ); + $category[$info] = mktime(0,0,0,$month,$day,$year); } } + $plain_structure[$row['id']] = $category; } + + return $plain_structure; } - -function get_nb_subcats( $id ) + +function create_structure( $id_uppercat, $restrictions ) { - global $user; - - $query = 'select count(*) as count'; - $query.= ' from '.PREFIX_TABLE.'categories'; - $query.= ' where id_uppercat = '.$id; - for ( $i = 0; $i < sizeof( $user['restrictions'] ); $i++ ) - { - $query.= " and id != ".$user['restrictions'][$i]; + global $page; + + $structure = array(); + $ids = get_subcat_ids( $id_uppercat ); + foreach ( $ids as $id ) { + if ( !in_array( $id, $restrictions ) ) + { + $category = $page['plain_structure'][$id]; + $category['subcats'] = create_structure( $id, $restrictions ); + array_push( $structure, $category ); + } } - $query.= ';'; - $result = mysql_query( $query ); - $row = mysql_fetch_array( $result ); - return $row['count']; + return $structure; } - -function get_total_image( $id, $restriction ) + +function get_subcat_ids( $id_uppercat ) +{ + global $page; + + $ids = array(); + foreach ( $page['plain_structure'] as $id => $category ) { + if ( $category['id_uppercat'] == $id_uppercat ) array_push( $ids, $id ); + else if ( count( $ids ) > 0 ) return $ids; + } + return $ids; +} + +// update_structure updates or add informations about each node of the +// structure : the last date, should the category be expanded in the menu ?, +// the associated expand string "48,14,54" +// +// 1. last date +// for each category of the structure, we have to find the most recent +// subcat so that the parent cat has the same last_date info. +// For example : we have : +// > pets (2003.02.15) +// > dogs (2003.06.14) +// > rex (2003.06.18) +// > toby (2003.06.13) +// > kitten (2003.07.05) +// We finally want to have : +// > pets (2003.07.05) <- changed to pets > kitten last date +// > dogs (2003.06.18) <- changed to pets > dogs > rex last date +// > rex (2003.06.18) +// > toby (2003.06.13) +// > kitten (2003.07.05) +// +// 2. should the category be expanded in the menu ? +// If the category has to be expanded (ie its id is in the +// $page['tab_expand'] or all the categories must be expanded by default), +// $category['expanded'] is set to true. +// +// 3. associated expand string +// in the menu, there is a expand string (used in the URL) to tell which +// categories must be expanded in the menu if this category is chosen +function update_structure( $categories ) +{ + global $page, $user; + + $updated_categories = array(); + + foreach ( $categories as $category ) { + // update the last date of the category + $last_date = search_last_date( $category ); + $category['date_last'] = $last_date; + // update the "expanded" key + if ( $user['expand'] + or $page['expand'] == 'all' + or in_array( $category['id'], $page['tab_expand'] ) ) + { + $category['expanded'] = true; + } + else + { + $category['expanded'] = false; + } + // update the "expand_string" key + if ( $page['expand'] == 'all' ) + { + $category['expand_string'] = 'all'; + } + else + { + $tab_expand = $page['tab_expand']; + if ( in_array( $category['id'], $page['tab_expand'] ) ) + { + // the expand string corresponds to the $page['tab_expand'] without + // the $category['id'] + $tab_expand = array_diff( $page['tab_expand'],array($category['id']) ); + } + else if ( count( $category['subcats'] ) > 0 ) + { + // we have this time to add the $category['id']... + $tab_expand = array_merge($page['tab_expand'],array($category['id'])); + } + $category['expand_string'] = implode( ',', $tab_expand ); + } + // recursive call + $category['subcats'] = update_structure( $category['subcats'] ); + // adding the updated category + array_push( $updated_categories, $category ); + } + + return $updated_categories; +} + +// search_last_date searchs the last date for a given category. If we take +// back the example given for update_last_dates, we should have : +// search_last_date( pets ) --> 2003.07.05 +// search_last_date( pets > dogs ) --> 2003.06.18 +// and so on +function search_last_date( $category ) +{ + $date_last = $category['date_last']; + foreach ( $category['subcats'] as $subcat ) { + $subcat_date_last = search_last_date( $subcat ); + if ( $subcat_date_last > $date_last ) + { + $date_last = $subcat_date_last; + } + } + return $date_last; +} + +// count_images returns the number of pictures contained in the given +// category represented by an array, in this array, we have (among other +// things) : +// $category['nb_images'] -> number of pictures in this category +// $category['subcats'] -> array of sub-categories +// count_images goes to the deepest sub-category to find the total number of +// pictures contained in the given given category +function count_images( $categories ) { $total = 0; - - $query = 'select id,nb_images'; - $query.= ' from '.PREFIX_TABLE.'categories'; - $query.= ' where id_uppercat'; - if ( !is_numeric( $id ) ) - { - $query.= ' is NULL'; - } - else - { - $query.= ' = '.$id; - } - $query.= ";"; - $result = mysql_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) - { - if ( !in_array( $row['id'], $restriction ) ) - { - $total+= $row['nb_images']; - $total+= get_total_image( $row['id'], $restriction ); - } + foreach ( $categories as $category ) { + $total+= $category['nb_images']; + $total+= count_images( $category['subcats'] ); } return $total; } @@ -261,17 +281,19 @@ function get_cat_info( $id ) $cat = array(); $cat['name'] = array(); - $query = 'select nb_images,id_uppercat,comment,site_id,galleries_url,dir'; - $query.= ' from '.PREFIX_TABLE.'categories as a'; - $query.= ', '.PREFIX_TABLE.'sites as b'; - $query.= ' where a.id = '.$id; - $query.= ' and a.site_id = b.id;'; + $query = 'SELECT nb_images,id_uppercat,comment,site_id,galleries_url,dir'; + $query.= ',date_last'; + $query.= ' FROM '.PREFIX_TABLE.'categories AS a'; + $query.= ', '.PREFIX_TABLE.'sites AS b'; + $query.= ' WHERE a.id = '.$id; + $query.= ' AND a.site_id = b.id;'; $row = mysql_fetch_array( mysql_query( $query ) ); $cat['site_id'] = $row['site_id']; $cat['id_uppercat'] = $row['id_uppercat']; $cat['comment'] = nl2br( $row['comment'] ); $cat['nb_images'] = $row['nb_images']; $cat['last_dir'] = $row['dir']; + $cat['date_last'] = $row['date_last']; $galleries_url = $row['galleries_url']; $cat['dir'] = ""; @@ -280,11 +302,11 @@ function get_cat_info( $id ) $row['id_uppercat'] = $id; while ( !$is_root ) { - $query = 'select name,dir,id_uppercat'; - $query.= ' from '.PREFIX_TABLE.'categories'; - $query.= ' where id = '.$row['id_uppercat'].';'; + $query = 'SELECT name,dir,id_uppercat'; + $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' WHERE id = '.$row['id_uppercat'].';'; $row = mysql_fetch_array( mysql_query( $query ) ); - $cat['dir'] = $row['dir']."/".$cat['dir']; + $cat['dir'] = $row['dir'].'/'.$cat['dir']; if ( $row['name'] == "" ) { $cat['name'][$i] = str_replace( "_", " ", $row['dir'] ); @@ -502,42 +524,36 @@ function initialize_category( $calling_page = 'category' ) } } -// get_non_empty_sub_cat_ids returns an array composing of the infos of the -// direct sub-categories of the given uppercat id. Each of these infos is -// associated to the first found non empty category id. eg : +// get_non_empty_subcat_ids returns an array with sub-categories id +// associated with their first non empty category id. +// +// example : // // - catname [cat_id] // - cat1 [1] -> given uppercat -// - cat1.1 [2] (empty) +// - cat1.1 [12] (empty) // - cat1.1.1 [5] (empty) // - cat1.1.2 [6] // - cat1.2 [3] // - cat1.3 [4] // // get_non_empty_sub_cat_ids will return : -// $cats[0]['id'] = 2; -// $cats[0]['name'] = ''; -// $cats[0]['dir'] = 'cat1'; -// $cats[0]['date_dernier'] = '2003-05-17'; -// $cats[0]['non_empty_cat'] = 6; -// -// $cats[1]['id'] = 3; -// $cats[1]['non_empty_cat'] = 3; -// -// $cats[1]['id'] = 4; -// $cats[1]['non_empty_cat'] = 4; -function get_non_empty_sub_cat_ids( $id_uppercat ) +// $ids[12] = 6; +// $ids[3] = 3; +// $ids[4] = 4; +function get_non_empty_subcat_ids( $id_uppercat ) { global $user; - $cats = array(); + $ids = array(); - $query = 'SELECT id,name,dir,date_dernier,nb_images'; + $query = 'SELECT id,nb_images'; $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE id_uppercat = '.$id_uppercat; + $query.= ' WHERE id_uppercat '; + if ( !is_numeric( $id_uppercat ) ) $query.= 'is NULL'; + else $query.= '= '.$id_uppercat; // we must not show pictures of a forbidden category - $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); - foreach ( $restricted_cats as $restricted_cat ) { + foreach ( $user['restrictions'] as $restricted_cat ) { $query.= ' AND id != '.$restricted_cat; } $query.= ' ORDER BY rank'; @@ -551,16 +567,10 @@ function get_non_empty_sub_cat_ids( $id_uppercat ) if ( ( $row['nb_images'] != 0 and $non_empty_cat = $row['id'] ) or $non_empty_cat = get_first_non_empty_cat_id( $row['id'] ) ) { - $temp_cat = array( - 'id' => $row['id'], - 'name' => $row['name'], - 'dir' => $row['dir'], - 'date_dernier' => $row['date_dernier'], - 'non_empty_cat' => $non_empty_cat ); - array_push( $cats, $temp_cat ); + $ids[$row['id']] = $non_empty_cat; } } - return $cats; + return $ids; } // get_first_non_empty_cat_id returns the id of the first non empty @@ -574,8 +584,7 @@ function get_first_non_empty_cat_id( $id_uppercat ) $query.= ' FROM '.PREFIX_TABLE.'categories'; $query.= ' WHERE id_uppercat = '.$id_uppercat; // we must not show pictures of a forbidden category - $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); - foreach ( $restricted_cats as $restricted_cat ) { + foreach ( $user['restrictions'] as $restricted_cat ) { $query.= ' AND id != '.$restricted_cat; } $query.= ' ORDER BY RAND()'; diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 0f286b970..1d55d4bbe 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -313,7 +313,7 @@ function get_all_restrictions( $user_id, $user_status ) function is_user_allowed( $category_id, $restrictions ) { $lowest_category_id = $category_id; - + $is_root = false; while ( !$is_root and !in_array( $category_id, $restrictions ) ) { @@ -322,21 +322,12 @@ function is_user_allowed( $category_id, $restrictions ) $query.= ' WHERE id = '.$category_id; $query.= ';'; $row = mysql_fetch_array( mysql_query( $query ) ); - if ( $row['id_uppercat'] == '' ) - { - $is_root = true; - } + if ( $row['id_uppercat'] == '' ) $is_root = true; $category_id = $row['id_uppercat']; } - - if ( in_array( $lowest_category_id, $restrictions ) ) - { - return 1; - } - if ( in_array( $category_id, $restrictions ) ) - { - return 2; - } + + if ( in_array( $lowest_category_id, $restrictions ) ) return 1; + if ( in_array( $category_id, $restrictions ) ) return 2; // this user is allowed to go in this category return 0; } diff --git a/include/init.inc.php b/include/init.inc.php index ad25a679b..823695753 100644 --- a/include/init.inc.php +++ b/include/init.inc.php @@ -18,10 +18,7 @@ define( PREFIX_INCLUDE, '' ); include_once( './include/config.inc.php' ); include_once( './include/user.inc.php' ); - -include( './theme/'.$user['theme'].'/conf.php' ); -$user['lien_expanded'] = './theme/'.$user['theme'].'/expanded.gif'; -$user['lien_collapsed'] = './theme/'.$user['theme'].'/collapsed.gif'; + // calculation of the number of picture to display per page $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; // retrieving the restrictions for this user @@ -35,6 +32,5 @@ if ( $user['is_the_guest'] ) { $user['username'] = $lang['guest']; } -include_once( './template/'.$user['template'].'/style.inc.php' ); include_once( './template/'.$user['template'].'/htmlfunctions.inc.php' ); ?> \ No newline at end of file diff --git a/include/user.inc.php b/include/user.inc.php index 8efd8219f..f950b3a1e 100644 --- a/include/user.inc.php +++ b/include/user.inc.php @@ -20,22 +20,14 @@ // Example : // status --> $user['status'] $infos = array( 'id', 'username', 'mail_address', 'nb_image_line', - 'nb_line_page', 'status', 'theme', 'language', 'maxwidth', + 'nb_line_page', 'status', 'language', 'maxwidth', 'maxheight', 'expand', 'show_nb_comments', 'short_period', 'long_period', 'template' ); -$query_user = 'SELECT'; -for ( $i = 0; $i < sizeof( $infos ); $i++ ) -{ - if ( $i > 0 ) - { - $query_user.= ','; - } - else - { - $query_user.= ' '; - } - $query_user.= $infos[$i]; +$query_user = 'SELECT '; +foreach ( $infos as $i => $info ) { + if ( $i > 0 ) $query_user.= ','; + $query_user.= $info; } $query_user.= ' FROM '.PREFIX_TABLE.'users'; $query_done = false; diff --git a/language/francais.php b/language/francais.php index cbf36d2bd..cba6596c4 100644 --- a/language/francais.php +++ b/language/francais.php @@ -1,4 +1,7 @@ Open( './template/'.$user['template'].'/picture.vtp' ); initialize_template(); $tpl = array( 'back','submit','comments_title','comments_del','delete', - 'comments_add','author' ); + 'comments_add','author','slideshow','slideshow_stop', + 'period_seconds' ); templatize_array( $tpl, 'lang', $handle ); +$vtp->setGlobalVar( $handle, 'user_template', $user['template'] ); $vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] ); +//-------------------------------------------------------- slideshow management +if ( isset( $_GET['slideshow'] ) ) +{ + if ( !is_numeric( $_GET['slideshow'] ) ) + $_GET['slideshow'] = $conf['slideshow_period'][0]; + $vtp->addSession( $handle, 'stop_slideshow' ); + $url = './picture.php'; + $url.= '?image_id='.$page['id']; + $url.= '&cat='.$page['cat']; + $url.= '&expand='.$_GET['expand']; + if ( $page['cat'] == 'search' ) + { + $url.= '&search='.$_GET['search']; + $url.= '&mode='.$_GET['mode']; + } + $vtp->setVar( $handle, 'stop_slideshow.url', add_session_id( $url ) ); + $vtp->closeSession( $handle, 'stop_slideshow' ); +} +else +{ + $vtp->addSession( $handle, 'start_slideshow' ); + foreach ( $conf['slideshow_period'] as $option ) { + $vtp->addSession( $handle, 'second' ); + $vtp->setVar( $handle, 'second.option', $option ); + $url = './picture.php'; + $url.= '?image_id='.$page['id']; + $url.= '&cat='.$page['cat']; + $url.= '&expand='.$_GET['expand']; + if ( $page['cat'] == 'search' ) + { + $url.= '&search='.$_GET['search']; + $url.= '&mode='.$_GET['mode']; + } + $url.= '&slideshow='.$option; + $vtp->setVar( $handle, 'second.url', add_session_id( $url ) ); + $vtp->closeSession( $handle, 'second' ); + } + $vtp->closeSession( $handle, 'start_slideshow' ); +} //------------------------------------------------------------------ page title if ( $page['name'] != '' ) { @@ -376,7 +415,7 @@ if ( $page['cat'] != 'fav' and !$user['is_the_guest'] ) $vtp->setVar( $handle, 'favorite.link', add_session_id( $url ) ); $vtp->setVar( $handle, 'favorite.title', $lang['add_favorites_hint'] ); $vtp->setVar( $handle, 'favorite.src', - './theme/'.$user['theme'].'/favorite.gif' ); + './template/'.$user['template'].'/theme/favorite.gif' ); $vtp->setVar( $handle, 'favorite.alt','[ '.$lang['add_favorites_alt'].' ]' ); $vtp->closeSession( $handle, 'favorite' ); } @@ -388,7 +427,7 @@ if ( $page['cat'] == 'fav' ) $vtp->setVar( $handle, 'favorite.link', add_session_id( $url ) ); $vtp->setVar( $handle, 'favorite.title', $lang['del_favorites_hint'] ); $vtp->setVar( $handle, 'favorite.src', - './theme/'.$user['theme'].'/del_favorite.gif' ); + './template/'.$user['template'].'/theme/del_favorite.gif' ); $vtp->setVar( $handle, 'favorite.alt','[ '.$lang['del_favorites_alt'].' ]' ); $vtp->closeSession( $handle, 'favorite' ); } @@ -452,6 +491,15 @@ if ( $page['num'] < $page['cat_nb_images']-1 ) $vtp->setGlobalVar( $handle, 'next.src', $lien_thumbnail ); $vtp->setGlobalVar( $handle, 'next.alt', $alt_thumbnail ); $vtp->closeSession( $handle, 'next' ); + // slideshow + if ( isset( $_GET['slideshow'] ) ) + { + $vtp->addSession( $handle, 'refresh' ); + $vtp->setVar( $handle, 'refresh.time', 2 ); + $url = $url_link.'&slideshow='.$_GET['slideshow']; + $vtp->setVar( $handle, 'refresh.url', add_session_id( $url ) ); + $vtp->closeSession( $handle, 'refresh' ); + } } else { @@ -471,10 +519,23 @@ if ( $conf['show_comments'] ) $author = $_POST['author']; } $query = 'INSERT INTO '.PREFIX_TABLE.'comments'; - $query.= ' (author,date,image_id,content) VALUES'; + $query.= ' (author,date,image_id,content,validated) VALUES'; $query.= " ('".$author."',".time().",".$page['id']; - $query.= ",'".htmlspecialchars( $_POST['content'], ENT_QUOTES)."');"; + $query.= ",'".htmlspecialchars( $_POST['content'], ENT_QUOTES)."'"; + if ( !$conf['comments_validation'] or $user['status'] == 'admin' ) + $query.= ",'true'"; + else + $query.= ",'false'"; + $query.= ');'; mysql_query( $query ); + $vtp->addSession( $handle, 'information' ); + $message = $lang['comment_added']; + if ( $conf['comments_validation'] and $user['status'] != 'admin' ) + { + $message.= '
    '.$lang['comment_to_validate']; + } + $vtp->setVar( $handle, 'information.content', $message ); + $vtp->closeSession( $handle, 'information' ); } // comment deletion if ( isset( $_GET['del'] ) @@ -488,7 +549,9 @@ if ( $conf['show_comments'] ) // number of comment for this picture $query = 'SELECT COUNT(*) AS nb_comments'; $query.= ' FROM '.PREFIX_TABLE.'comments'; - $query.= ' WHERE image_id = '.$page['id'].';'; + $query.= ' WHERE image_id = '.$page['id']; + $query.= " AND validated = 'true'"; + $query.= ';'; $row = mysql_fetch_array( mysql_query( $query ) ); $page['nb_comments'] = $row['nb_comments']; // navigation bar creation @@ -519,6 +582,7 @@ if ( $conf['show_comments'] ) $query = 'SELECT id,author,date,image_id,content'; $query.= ' FROM '.PREFIX_TABLE.'comments'; $query.= ' WHERE image_id = '.$page['id']; + $query.= " AND validated = 'true'"; $query.= ' ORDER BY date ASC'; $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';'; $result = mysql_query( $query ); @@ -530,7 +594,7 @@ if ( $conf['show_comments'] ) $displayed_date = $lang['day'][date( "w", $row['date'] )]; $displayed_date.= date( " j ", $row['date'] ); $displayed_date.= $lang['month'][date( "n", $row['date'] )]; - $displayed_date.= date( " Y G:i", $row['date'] ); + $displayed_date.= date( ' Y G:i', $row['date'] ); $vtp->setVar( $handle, 'comment.date', $displayed_date ); $vtp->setVar( $handle, 'comment.content', nl2br( $row['content'] ) ); if ( $user['status'] == 'admin' ) diff --git a/profile.php b/profile.php index 30e28c256..7a47783a5 100644 --- a/profile.php +++ b/profile.php @@ -28,111 +28,86 @@ if ( $user['is_the_guest'] ) //-------------------------------------------------------------- initialization check_cat_id( $_GET['cat'] ); //------------------------------------------------------ update & customization -$infos = array( 'nb_image_line', 'nb_line_page', 'theme', 'language', +$infos = array( 'nb_image_line', 'nb_line_page', 'language', 'maxwidth', 'maxheight', 'expand', 'show_nb_comments', 'short_period', 'long_period', 'template', 'mail_address' ); // mise à jour dans la base de données des valeurs // des paramètres pour l'utilisateur courant // - on teste si chacune des variables est passée en argument à la page // - ce qui signifie que l'on doit venir de la page de personnalisation -$error = array(); +$errors = array(); if ( isset( $_POST['submit'] ) ) { - $i = 0; - if ( $_POST['maxwidth'] != '' ) + $int_pattern = '/^\d+$/'; + if ( $_POST['maxwidth'] != '' + and ( !preg_match( $int_pattern, $_POST['maxwidth'] ) + or $_POST['maxwidth'] < 50 ) ) { - if ( !ereg( "^[0-9]{2,}$", $_POST['maxwidth'] ) - || $_POST['maxwidth'] < 50 ) - { - $error[$i++] = $lang['err_maxwidth']; - } + array_push( $errors, $lang['err_maxwidth'] ); } - if ( $_POST['maxheight'] != '' ) + if ( $_POST['maxheight'] + and ( !preg_match( $int_pattern, $_POST['maxheight'] ) + or $_POST['maxheight'] < 50 ) ) { - if ( !ereg( "^[0-9]{2,}$", $_POST['maxheight'] ) - || $_POST['maxheight'] < 50 ) - { - $error[$i++] = $lang['err_maxheight']; - } + array_push( $errors, $lang['err_maxheight'] ); } - // les période doivent être des entiers, il représentent des nombres de jours - if ( !ereg( "^[0-9]*$", $_POST['short_period'] ) - || !ereg("^[0-9]*$", $_POST['long_period'] ) ) + // periods must be integer values, they represents number of days + if ( !preg_match( $int_pattern, $_POST['short_period'] ) + or !preg_match( $int_pattern, $_POST['long_period'] ) ) { - $error[$i++] = $lang['err_periods']; + array_push( $errors, $lang['err_periods'] ); } else { - // la période longue doit être supérieure à la période courte + // long period must be longer than short period if ( $_POST['long_period'] <= $_POST['short_period'] - || $_POST['short_period'] <= 0 ) + or $_POST['short_period'] <= 0 ) { - $error[$i++] = $lang['err_periods_2']; + array_push( $errors, $lang['err_periods_2'] ); } } - // le mail doit être conforme à qqch du type : nom@serveur.com - if( $_POST['mail_address'] != "" - && !ereg( "([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)", - $_POST['mail_address'] ) ) + $mail_error = validate_mail_address( $_POST['mail_address'] ); + if ( $mail_error != '' ) { - $error[$i++] = $lang['reg_err_mail_address']; + array_push( $errors, $mail_error ); } if ( $_POST['use_new_pwd'] == 1 ) { - // on vérifie que le password rentré correspond bien - // à la confirmation faite par l'utilisateur + // password must be the same as its confirmation if ( $_POST['password'] != $_POST['passwordConf'] ) { - $error[$i++] = $lang['reg_err_pass']; + array_push( $errors, $lang['reg_err_pass'] ); } } - if ( sizeof( $error ) == 0 ) + if ( count( $errors ) == 0 ) { - $tab_theme = explode( ' - ', $_POST['theme'] ); - $_POST['theme'] = $tab_theme[0].'/'.$tab_theme[1]; - - $query = 'update '.PREFIX_TABLE.'users'; - $query.= ' set'; - for ( $i = 0; $i < sizeof( $infos ); $i++ ) - { - if ( $i > 0 ) - { - $query.= ','; - } - else - { - $query.= ' '; - } - $query.= $infos[$i]; + $query = 'UPDATE '.PREFIX_TABLE.'users'; + $query.= ' SET '; + foreach ( $infos as $i => $info ) { + if ( $i > 0 ) $query.= ','; + $query.= $info; $query.= ' = '; - if ( $_POST[$infos[$i]] == '' ) - { - $query.= 'NULL'; - } - else - { - $query.= "'".$_POST[$infos[$i]]."'"; - } + if ( $_POST[$info] == '' ) $query.= 'NULL'; + else $query.= "'".$_POST[$info]."'"; } - $query.= ' where id = '.$user['id']; + $query.= ' WHERE id = '.$user['id']; $query.= ';'; mysql_query( $query ); if ( $_POST['use_new_pwd'] == 1 ) { - $query = 'update '.PREFIX_TABLE.'users'; - $query.= " set password = '".md5( $_POST['password'] )."'"; - $query.= ' where id = '.$user['id']; + $query = 'UPDATE '.PREFIX_TABLE.'users'; + $query.= " SET password = '".md5( $_POST['password'] )."'"; + $query.= ' WHERE id = '.$user['id']; $query.= ';'; mysql_query( $query ); - echo '
    '.$query; } // redirection $url = 'category.php?cat='.$page['cat'].'&expand='.$_GET['expand']; if ( $page['cat'] == 'search' ) { - $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; + $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; } $url = add_session_id( $url, true ); header( 'Request-URI: '.$url ); @@ -156,13 +131,12 @@ if ( $page['cat'] == 'search' ) } $vtp->setGlobalVar( $handle, 'form_action', add_session_id( $url ) ); //-------------------------------------------------------------- errors display -if ( sizeof( $error ) != 0 ) +if ( count( $errors ) != 0 ) { $vtp->addSession( $handle, 'errors' ); - for ( $i = 0; $i < sizeof( $error ); $i++ ) - { + foreach ( $errors as $error ) { $vtp->addSession( $handle, 'li' ); - $vtp->setVar( $handle, 'li.li', $error[$i] ); + $vtp->setVar( $handle, 'li.li', $error ); $vtp->closeSession( $handle, 'li' ); } $vtp->closeSession( $handle, 'errors' ); @@ -228,27 +202,6 @@ if ( in_array( 'template', $infos ) ) $vtp->closeSession( $handle, 'select' ); $vtp->closeSession( $handle, 'line' ); } -//----------------------------------------------------------------------- theme -if ( in_array( 'theme', $infos ) ) -{ - $vtp->addSession( $handle, 'line' ); - $vtp->setVar( $handle, 'line.name', $lang['customize_theme'] ); - $vtp->addSession( $handle, 'select' ); - $vtp->setVar( $handle, 'select.name', 'theme' ); - $option = get_themes( './theme/' ); - for ( $i = 0; $i < sizeof( $option ); $i++ ) - { - $vtp->addSession( $handle, 'option' ); - $vtp->setVar( $handle, 'option.option', $option[$i] ); - if ( $option[$i] == str_replace( '/', ' - ', $user['theme'] ) ) - { - $vtp->setVar( $handle, 'option.selected', ' selected="selected"' ); - } - $vtp->closeSession( $handle, 'option' ); - } - $vtp->closeSession( $handle, 'select' ); - $vtp->closeSession( $handle, 'line' ); -} //-------------------------------------------------------------------- language if ( in_array( 'language', $infos ) ) { diff --git a/template/default/images/php_sqreuil_artistes.gif b/template/default/images/php_sqreuil_artistes.gif new file mode 100755 index 0000000000000000000000000000000000000000..88cff0c010cc17fe257f2d082f77a2c58dea5cc4 GIT binary patch literal 17884 zcmWie`8(8)*T&zonEhgA3}ZLLVC*xtkeIRWjj=D)*aRbJSE?8LHQQi6%(jy*Hl>XCLP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Hm0f<&MmHZTxT)QG7t&9k@C080l;Zsk7AW#sQ|>lldG z@W(Z@2a|PoxTxfm(@7!l6FXqKs^jtzHxS07{_mdwb{RB)U=qOz3Yox&GG0>{VAW?? zph(`b*(mr$1M-6-e%y3@7Ub3U>P(;~OL_G(0q8|1kJ55G+#=7^p*J8u$soL`X3> z7+WxyNnlV=u;V%?JshKCMO$mdQV7_?Vn`XlCBPIASi{5|N;wEsC_+$JFfuwSwgV7? zjh3DsMEEIi3{&XJrj!cc3Rn}+3aCm(PXRxmJ+$qnW_^tZkZo^5KuBW10~kngl1G51 z07p_pIshk5y#NUV4ES^@6+Ma-v-n8^X;vB`fuu1wAYeuw0H}~4ki#H>r5{!H{ZW>z zSOS_f^C6glb4Jdc`2raDVo@F&dI^5$D-%k|j43}#2@oaVzz7CuUA{F6BRJ3r?c$s_ z2lMp{7#ZNYXv?A<=GgH8luZ~A_)&+7M?Fmr5SSziLBlf$SWa0obf{P|bg9rQ!#+QG{_c8C= zcQQu{1Qg7E3W=ic01^;DD(wz|@cURc%HlWi20TMJY8c=vy=)RF=#5L9AO|1=2$)WQ z1!nkxj3}}wAVUH_ByhD-77FKJxyD5hXDpB?8j(<-A0-UPj|o72 z7y!ddWUQ{i8;=~XKPG0d5P%Z<5CEVg|Cmye5cf7RBf6lFUm=K`ZUjP*P7t^~Oyt1?Px_<})dY)kaPANKZLJ-* zTyuc~jerGou_Cl{kwo@gdFLghh^d6>Q@mBHjh9}3|3!mVfa&RXV1o}v7{r1TX1HNO c_VssRhbN}EVpp!UIAe`jDec@J0)hYlJMN--uK)l5 literal 0 HcmV?d00001 diff --git a/upload.php b/upload.php index a03824de2..7e320c1fa 100644 --- a/upload.php +++ b/upload.php @@ -16,7 +16,6 @@ ***************************************************************************/ //------------------------------------------------------------------- functions - // The validate_upload function checks if the image of the given path is valid. // A picture is valid when : // - width, height and filesize are not higher than the maximum @@ -114,10 +113,10 @@ else } if ( $access_forbidden == true or $page['cat_site_id'] != 1 - or $conf['upload_available'] == 'false' ) + or !$conf['upload_available'] ) { echo '
    '.$lang['upload_forbidden'].'
    '; - echo ''; + echo ''; echo $lang['thumbnails'].'
    '; exit(); } @@ -127,44 +126,66 @@ $handle = $vtp->Open( './template/'.$user['template'].'/upload.vtp' ); initialize_template(); $tpl = array( 'upload_title', 'upload_username', 'mail_address', 'submit', - 'upload_successful', 'search_return_main_page' ); -templatize_array( $tpl, 'lang', $sub ); -// user -$vtp->setGlobalVar( $handle, 'style', $user['style'] ); -$vtp->setGlobalVar( $handle, 'user_login', $user['username'] ); -$vtp->setGlobalVar( $handle, 'user_mail_address',$user['mail_address'] ); + 'upload_successful', 'search_return_main_page','upload_author', + 'upload_name','upload_creation_date','upload_comment', + 'mandatory' ); +templatize_array( $tpl, 'lang', $handle ); $error = array(); -$i = 0; $page['upload_successful'] = false; if ( isset( $_GET['waiting_id'] ) ) { $page['waiting_id'] = $_GET['waiting_id']; } //-------------------------------------------------------------- picture upload -// vérification de la présence et de la validité des champs. +// verfying fields if ( isset( $_POST['submit'] ) and !isset( $_GET['waiting_id'] ) ) { $path = $page['cat_dir'].$_FILES['picture']['name']; if ( @is_file( $path ) ) { - $error[$i++] = $lang['upload_file_exists']; + array_push( $error, $lang['upload_file_exists'] ); } // test de la présence des champs obligatoires - if ( $_FILES['picture']['name'] == "" ) + if ( $_FILES['picture']['name'] == '' ) { - $error[$i++] = $lang['upload_filenotfound']; + array_push( $error, $lang['upload_filenotfound'] ); } if ( !ereg( "([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)", $_POST['mail_address'] ) ) { - $error[$i++] = $lang['reg_err_mail_address']; + array_push( $error, $lang['reg_err_mail_address'] ); } if ( $_POST['username'] == '' ) { - $error[$i++] = $lang['upload_err_username']; + array_push( $error, $lang['upload_err_username'] ); } + if ( $_POST['date_creation'] != '' ) + { + list( $day,$month,$year ) = explode( '/', $_POST['date_creation'] ); + // int checkdate ( int month, int day, int year) + if ( checkdate( $month, $day, $year ) ) + { + // int mktime ( int hour, int minute, int second, + // int month, int day, int year [, int is_dst]) + $date_creation = mktime( 0, 0, 0, $month, $day, $year ); + } + else + { + array_push( $error, $lang['err_date'] ); + } + } + // creation of the "infos" field : + // + $xml_infos = 'setGlobalVar( $handle, 'form_action', $url ); + $vtp->setGlobalVar( $handle, 'form_action', add_session_id( $url ) ); //--------------------------------------------------------------------- advises if ( $conf['upload_maxfilesize'] != '' ) { @@ -307,7 +328,27 @@ if ( !$page['upload_successful'] ) if ( !isset( $page['waiting_id'] ) ) { $vtp->addSession( $handle, 'fields' ); + // username + if ( isset( $_POST['username'] ) ) $username = $_POST['username']; + else $username = $user['username']; + $vtp->setVar( $handle, 'fields.username', $username ); + // mail address + if ( isset( $_POST['mail_address'] ) )$mail_address=$_POST['mail_address']; + else $mail_address=$user['mail_address']; + $vtp->setGlobalVar( $handle, 'user_mail_address',$user['mail_address'] ); + // name of the picture + $vtp->setVar( $handle, 'fields.name', $_POST['name'] ); + // author + $vtp->setVar( $handle, 'fields.author', $_POST['author'] ); + // date of creation + $vtp->setVar( $handle, 'fields.date_creation', $_POST['date_creation'] ); + // comment + $vtp->setVar( $handle, 'fields.comment', $_POST['comment'] ); + $vtp->closeSession( $handle, 'fields' ); + + $vtp->addSession( $handle, 'note' ); + $vtp->closeSession( $handle, 'note' ); } $vtp->closeSession( $handle, 'upload_not_successful' ); }