From e1b59cb0a83e8b6cff7b05ea18cd8cdd985a9af7 Mon Sep 17 00:00:00 2001 From: gweltas Date: Sun, 11 Jan 2004 23:40:39 +0000 Subject: Corrections de quelques warnings php. git-svn-id: http://piwigo.org/svn/branches/release-1_3@274 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/admin.php | 1 + admin/include/isadmin.inc.php | 2 +- admin/install.php | 14 +++++++++----- category.php | 26 +++++++++++++++----------- comments.php | 4 ++-- include/functions.inc.php | 3 ++- include/user.inc.php | 3 +-- language/english.php | 2 +- language/francais.php | 4 +++- template/default/style.inc.php | 2 +- 10 files changed, 36 insertions(+), 25 deletions(-) diff --git a/admin/admin.php b/admin/admin.php index 66608a74d..fbdb590ae 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -35,6 +35,7 @@ if ( is_file( './install.php' ) ) //--------------------------------------- validating page and creation of title $page_valide = false; $title = ''; +if (isset( $_GET['page'] )) switch ( $_GET['page'] ) { case 'user_list': diff --git a/admin/include/isadmin.inc.php b/admin/include/isadmin.inc.php index d6f8c2cc5..e548d56bd 100644 --- a/admin/include/isadmin.inc.php +++ b/admin/include/isadmin.inc.php @@ -16,7 +16,7 @@ * the Free Software Foundation; * * * ***************************************************************************/ -define( PREFIX_INCLUDE, '.' ); +define( 'PREFIX_INCLUDE', '.' ); include_once( '../include/config.inc.php' ); include_once( '../include/user.inc.php' ); diff --git a/admin/install.php b/admin/install.php index 3b5a4619f..d8b641208 100644 --- a/admin/install.php +++ b/admin/install.php @@ -18,7 +18,7 @@ ***************************************************************************/ //-------------------------------------------------------------------- includes -define( PREFIX_INCLUDE, '.' ); +define( 'PREFIX_INCLUDE', '.' ); include( '../include/vtemplate.class.php' ); include( '../include/functions.inc.php' ); //----------------------------------------------------- template initialization @@ -45,7 +45,7 @@ if ( isset( $_GET['language'] ) ) $vtp->setGlobalVar( $handle, 'language', $_GET['language'] ); } //---------------------- Step 1 : connection informations, write of config file -if ( $_GET['step'] == 1 ) +if ( isset($_GET['step']) && $_GET['step'] == 1 ) { $errors = array(); $infos = array(); @@ -150,9 +150,11 @@ if ( $_GET['step'] == 1 ) else $vtp->setVar( $handle, 'step1.f_host', $_POST['cfgHote'] ); // user - $vtp->setVar( $handle, 'step1.f_user', $_POST['cfgUser'] ); + if ( isset( $_POST['cfgUser'] ) ) + $vtp->setVar( $handle, 'step1.f_user', $_POST['cfgUser'] ); // base - $vtp->setVar( $handle, 'step1.f_base', $_POST['cfgBase'] ); + if ( isset( $_POST['cfgBase'] ) ) + $vtp->setVar( $handle, 'step1.f_base', $_POST['cfgBase'] ); // prefixeTable if ( !isset( $_POST['prefixeTable'] ) ) $vtp->setVar( $handle, 'step1.f_prefixeTable', 'phpwebgallery_' ); @@ -163,7 +165,7 @@ if ( $_GET['step'] == 1 ) } } //------------------------------------- Step 2 : creation of tables in database -else if ( $_GET['step'] == 2 ) +else if ( isset($_GET['step']) && $_GET['step'] == 2 ) { $errors = array(); $infos = array(); @@ -267,7 +269,9 @@ else if ( $_GET['step'] == 2 ) if ( !isset( $_POST['submit'] ) or sizeof( $errors ) > 0 ) { $vtp->addSession( $handle, 'step2' ); + if ( isset( $_POST['webmaster'] )) $vtp->setVar( $handle, 'step2.f_webmaster', $_POST['webmaster'] ); + if ( isset( $_POST['mail_webmaster'] )) $vtp->setVar( $handle, 'step2.f_mail_webmaster', $_POST['mail_webmaster']); $vtp->closeSession( $handle, 'step2' ); } diff --git a/category.php b/category.php index 0ce7abc2b..23acd011a 100644 --- a/category.php +++ b/category.php @@ -23,7 +23,7 @@ $t2 = $t1[1].'.'.$t2[1]; //----------------------------------------------------------- personnal include include_once( './include/init.inc.php' ); //---------------------------------------------------------------------- logout -if ( $_GET['act'] == 'logout' and isset( $_COOKIE['id'] ) ) +if ( isset( $_GET['act'] ) && $_GET['act'] == 'logout' && isset( $_COOKIE['id'] ) ) { // cookie deletion if exists setcookie( 'id', '', 0, cookie_path() ); @@ -34,9 +34,10 @@ if ( $_GET['act'] == 'logout' and isset( $_COOKIE['id'] ) ) exit(); } //-------------------------------------------------- access authorization check -check_cat_id( $_GET['cat'] ); +if ( isset( $_GET['act'] )) + check_cat_id( $_GET['cat'] ); check_login_authorization(); -if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) +if ( isset( $page['cat'] ) && is_numeric( $page['cat'] ) ) { check_restrictions( $page['cat'] ); } @@ -62,7 +63,7 @@ if ( isset ( $_GET['expand'] ) and $_GET['expand'] != 'all' ) if ( is_numeric( $id ) ) array_push( $page['tab_expand'], $id ); } } -if ( is_numeric( $page['cat'] ) ) +if ( isset($page['cat']) && is_numeric( $page['cat'] ) ) { // the category displayed (in the URL cat=23) must be seen in the menu -> // parent categories must be expanded @@ -76,7 +77,7 @@ $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'] or $_GET['expand'] == 'all' ) +if ( $user['expand'] || (isset($_GET['expand']) && $_GET['expand'] == 'all' )) { $page['tab_expand'] = array(); $page['expand'] = 'all'; @@ -85,7 +86,7 @@ if ( $user['expand'] or $_GET['expand'] == 'all' ) // of the picture to show. This picture must be in the thumbnails page. // We have to find the right $page['start'] that show the num picture // in this category -if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 ) +if ( isset($_GET['num']) && is_numeric( $_GET['num'] ) && $_GET['num'] >= 0 ) { $page['start'] = floor( $_GET['num'] / $user['nb_image_page'] ); $page['start']*= $user['nb_image_page']; @@ -178,9 +179,10 @@ if ( !$user['is_the_guest'] ) $vtp->closeSession( $handle, 'summary' ); // customization link $vtp->addSession( $handle, 'summary' ); - $url = './profile.php?cat='.$page['cat']; - $url.= '&expand='.$page['expand']; - if ( $page['cat'] == 'search' ) + $url = './profile.php'; + if (isset($page['cat']) && isset($page['expand'])) + $url.='?cat='.$page['cat'].'&expand='.$page['expand']; + if ( isset($page['cat']) && $page['cat'] == 'search' ) { $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; } @@ -349,12 +351,14 @@ elseif ( ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) and $page['cat_nb_images'] == 0 and $page['plain_structure'][$page['cat']]['nb_sub_categories'] > 0) - or $_GET['cat'] == '' ) + or (!isset($_GET['cat']))) { $vtp->addSession( $handle, 'thumbnails' ); $vtp->addSession( $handle, 'line' ); - $subcats = get_non_empty_subcat_ids( $page['cat'] ); + $subcats=array(); + if (isset ($page['cat'] )) + $subcats = get_non_empty_subcat_ids( $page['cat'] ); $cell_number = 1; $i = 0; foreach ( $subcats as $subcat_id => $non_empty_id ) { diff --git a/comments.php b/comments.php index e4159a107..f90f4dcac 100644 --- a/comments.php +++ b/comments.php @@ -140,8 +140,8 @@ $tpl = array( 'title_comments','stats_last_days','search_return_main_page' ); templatize_array( $tpl, 'lang', $handle ); $vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] ); //--------------------------------------------------- number of days to display -if ( isset( $_GET['last_days'] ) ) define( MAX_DAYS, $_GET['last_days'] ); -else define( MAX_DAYS, 0 ); +if ( isset( $_GET['last_days'] ) ) define( 'MAX_DAYS', $_GET['last_days'] ); +else define( 'MAX_DAYS', 0 ); //----------------------------------------- non specific section initialization $array_cat_directories = array(); $array_cat_names = array(); diff --git a/include/functions.inc.php b/include/functions.inc.php index 7ff3eda67..94050d13b 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -306,7 +306,7 @@ function replace_search( $string, $search ) function database_connection() { include( PREFIX_INCLUDE.'./include/mysql.inc.php' ); - define( PREFIX_TABLE, $prefixeTable ); + define( 'PREFIX_TABLE', $prefixeTable ); @mysql_connect( $cfgHote, $cfgUser, $cfgPassword ) or die ( "Could not connect to server" ); @@ -334,6 +334,7 @@ function templatize_array( $array, $global_array_name, $handle ) global $vtp, $lang, $page, $user, $conf; foreach ( $array as $value ) { + if (isset(${$global_array_name}[$value])) $vtp->setGlobalVar( $handle, $value, ${$global_array_name}[$value] ); } } diff --git a/include/user.inc.php b/include/user.inc.php index e33809430..a640ec4eb 100644 --- a/include/user.inc.php +++ b/include/user.inc.php @@ -29,7 +29,7 @@ $infos = array( 'id', 'username', 'mail_address', 'nb_image_line', $query_user = 'SELECT '; foreach ( $infos as $i => $info ) { - if ( $i > 0 ) $query_user.= ','; + if ( $i > 0 ) $query_user.= ', '; $query_user.= $info; } $query_user.= ' FROM '.PREFIX_TABLE.'users'; @@ -97,7 +97,6 @@ if ( !$query_done ) $user['is_the_guest'] = true; } $query_user .= ';'; - $row = mysql_fetch_array( mysql_query( $query_user ) ); // affectation of each value retrieved in the users table into a variable diff --git a/language/english.php b/language/english.php index c897461d6..74cec46a5 100644 --- a/language/english.php +++ b/language/english.php @@ -155,7 +155,7 @@ $lang['upload_err_username'] = 'the username must be given'; $lang['upload_username'] = 'Username'; $lang['upload_successful'] = 'Picture uploaded with success, an administrator will validate it as soon as possible'; // new or modified in release 1.3 -$lang['charset'] = 'ISO_8859-1'; +$lang['charset'] = 'ISO-8859-1'; $lang['no'] = 'no'; $lang['yes'] = 'yes'; $lang['guest'] = 'guest'; diff --git a/language/francais.php b/language/francais.php index 6164b145c..969aae89f 100644 --- a/language/francais.php +++ b/language/francais.php @@ -147,7 +147,7 @@ $lang['upload_err_username'] = 'le nom de l\'utilisateur doit $lang['upload_username'] = 'Nom d\'utilisateur'; $lang['upload_successful'] = 'Image uploadée avec succès, un administrateur validera celle-ci dès que possible.'; // new or modified in release 1.3 -$lang['charset'] = 'ISO_8859-1'; +$lang['charset'] = 'ISO-8859-1'; $lang['no'] = 'non'; $lang['yes'] = 'oui'; $lang['guest'] = 'visiteur'; @@ -215,6 +215,7 @@ $lang['mail_new_upload_subject'] = 'Nouvelle image sur le site'; $lang['mail_new_upload_content'] = 'Une nouvelle image a été placée sur la galerie. Elle est en attente de validation. RDV dans la section d\'administration pour valider ou supprimer cette image.'; $lang['mail_new_comment_subject'] = 'Nouveau commentaire sur le site'; $lang['mail_new_comment_content'] = 'Un nouveau commentaire a été posté sur la galerie. Si vous avez activé la validation des commentaires, il faut d\'abord valider le commentaire dans la zone d\'administration pour le voir apparaître.'."\n\n".'Vous avez accès aux derniers commentaires dans la zone d\'administration.'; +if (isset($conf)) $lang['about_message'] = '
Informations sur le PhpWebGallery