aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorz0rglub <z0rglub@piwigo.org>2004-01-22 22:46:46 +0000
committerz0rglub <z0rglub@piwigo.org>2004-01-22 22:46:46 +0000
commit316a3dca3eaeac79de850bce0bdae16415fd00f2 (patch)
treee22d902d20a38e9339a66cedd7e686cc557f516a
parent40a11658a9f54d04f94d3febc204d09a86622e3e (diff)
- Php warnings correction
- code refactoring git-svn-id: http://piwigo.org/svn/branches/release-1_3@312 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--picture.php80
-rw-r--r--profile.php25
2 files changed, 53 insertions, 52 deletions
diff --git a/picture.php b/picture.php
index 6c8815458..aefb2a3fe 100644
--- a/picture.php
+++ b/picture.php
@@ -180,7 +180,7 @@ if ( $page['num'] < $page['cat_nb_images']-1 )
$next_lien_thumbnail = $cat_directory.'thumbnail/';
$next_lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
- if ( $row['name'] != "" )
+ if ( isset( $row['name'] ) and $row['name'] != '' )
{
$next_alt_thumbnail = $row['name'];
}
@@ -190,8 +190,10 @@ if ( $page['num'] < $page['cat_nb_images']-1 )
}
$next_title = $lang['next_image']." : ".$next_alt_thumbnail;
- $next_url_link = './picture.php?image_id='.$row['id'].'&amp;cat='.$page['cat'];
- $next_url_link.= '&amp;expand='.$_GET['expand'];
+ $next_url_link = './picture.php?image_id='.$row['id'];
+ $next_url_link.= '&amp;cat='.$page['cat'];
+ if ( isset( $_GET['expand'] ) )
+ $next_url_link.= '&amp;expand='.$_GET['expand'];
if ( $page['cat'] == 'search' )
{
$next_url_link.= "&amp;search=".$_GET['search'].'&amp;mode='.$_GET['mode'];
@@ -290,13 +292,16 @@ if ( $page['num'] >= 1 )
$lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
$prev_title = $lang['previous_image'].' : ';
- $alt_thumbnaill = '';
- if ( $row['name'] != '' ) $alt_thumbnail = $row['name'];
- else $alt_thumbnail = $file;
+
+ if ( isset( $row['name'] ) and $row['name'] != '' )
+ $alt_thumbnail = $row['name'];
+ else
+ $alt_thumbnail = $file;
+
$prev_title.= $alt_thumbnail;
$url_link = './picture.php?image_id='.$row['id'].'&amp;cat='.$page['cat'];
- $url_link.= '&amp;expand='.$_GET['expand'];
+ if ( isset( $_GET['expand'] ) ) $url_link.= '&amp;expand='.$_GET['expand'];
if ( $page['cat'] == 'search' )
{
$url_link.= '&amp;search='.$_GET['search'].'&amp;mode='.$_GET['mode'];
@@ -470,7 +475,8 @@ if ( $page['keywords'] != '' )
$vtp->setVar( $handle, 'info_line.name', $lang['keywords'].' : ' );
$keywords = explode( ',', $page['keywords'] );
$content = '';
- $url = './category.php?cat=search&amp;expand='.$_GET['expand'];
+ $url = './category.php?cat=search';
+ if ( isset( $_GET['expand'] ) ) $url.= '&amp;expand='.$_GET['expand'];
$url.= '&amp;mode=OR&amp;search=';
foreach ( $keywords as $i => $keyword ) {
$local_url = add_session_id( $url.$keyword );
@@ -489,40 +495,42 @@ $vtp->closeSession( $handle, 'info_line' );
if ( !$user['is_the_guest'] )
{
// verify if the picture is already in the favorite of the user
- $query = 'SELECT COUNT(*) AS nb_fav FROM '.PREFIX_TABLE.'favorites WHERE image_id = '.$page['id'];
+ $query = 'SELECT COUNT(*) AS nb_fav';
+ $query.= ' FROM '.PREFIX_TABLE.'favorites';
+ $query.= ' WHERE image_id = '.$page['id'];
$query.= ' AND user_id = '.$user['id'].';';
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
if (!$row['nb_fav'])
-{
- $url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
- if (isset($_GET['expand']))
- $url.= '&amp;expand='.$_GET['expand'];
- $url.='&amp;add_fav=1';
- if ( $page['cat'] == 'search' )
{
- $url.= '&amp;search='.$_GET['search'].'&amp;mode='.$_GET['mode'];
+ $url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
+ if (isset($_GET['expand']))
+ $url.= '&amp;expand='.$_GET['expand'];
+ $url.='&amp;add_fav=1';
+ if ( $page['cat'] == 'search' )
+ {
+ $url.= '&amp;search='.$_GET['search'].'&amp;mode='.$_GET['mode'];
+ }
+ $vtp->addSession( $handle, 'favorite' );
+ $vtp->setVar( $handle, 'favorite.link', add_session_id( $url ) );
+ $vtp->setVar( $handle, 'favorite.title', $lang['add_favorites_hint'] );
+ $vtp->setVar( $handle, 'favorite.src',
+ './template/'.$user['template'].'/theme/favorite.gif' );
+ $vtp->setVar($handle,'favorite.alt','[ '.$lang['add_favorites_alt'].' ]');
+ $vtp->closeSession( $handle, 'favorite' );
+ }
+ else
+ {
+ $url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
+ $url.= '&amp;expand='.$_GET['expand'].'&amp;add_fav=0';
+ $vtp->addSession( $handle, 'favorite' );
+ $vtp->setVar( $handle, 'favorite.link', add_session_id( $url ) );
+ $vtp->setVar( $handle, 'favorite.title', $lang['del_favorites_hint'] );
+ $vtp->setVar( $handle, 'favorite.src',
+ './template/'.$user['template'].'/theme/del_favorite.gif' );
+ $vtp->setVar($handle,'favorite.alt','[ '.$lang['del_favorites_alt'].' ]');
+ $vtp->closeSession( $handle, 'favorite' );
}
- $vtp->addSession( $handle, 'favorite' );
- $vtp->setVar( $handle, 'favorite.link', add_session_id( $url ) );
- $vtp->setVar( $handle, 'favorite.title', $lang['add_favorites_hint'] );
- $vtp->setVar( $handle, 'favorite.src',
- './template/'.$user['template'].'/theme/favorite.gif' );
- $vtp->setVar( $handle, 'favorite.alt','[ '.$lang['add_favorites_alt'].' ]' );
- $vtp->closeSession( $handle, 'favorite' );
-}
-else
-{
- $url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
- $url.= '&amp;expand='.$_GET['expand'].'&amp;add_fav=0';
- $vtp->addSession( $handle, 'favorite' );
- $vtp->setVar( $handle, 'favorite.link', add_session_id( $url ) );
- $vtp->setVar( $handle, 'favorite.title', $lang['del_favorites_hint'] );
- $vtp->setVar( $handle, 'favorite.src',
- './template/'.$user['template'].'/theme/del_favorite.gif' );
- $vtp->setVar( $handle, 'favorite.alt','[ '.$lang['del_favorites_alt'].' ]' );
- $vtp->closeSession( $handle, 'favorite' );
-}
}
//------------------------------------ admin link for information modifications
if ( $user['status'] == 'admin' )
diff --git a/profile.php b/profile.php
index e9fb7dc93..5a8e196a7 100644
--- a/profile.php
+++ b/profile.php
@@ -67,19 +67,12 @@ if ( isset( $_POST['submit'] ) )
}
}
$mail_error = validate_mail_address( $_POST['mail_address'] );
- if ( $mail_error != '' )
- {
- array_push( $errors, $mail_error );
- }
- if ( $_POST['use_new_pwd'] == 1 )
- {
- // password must be the same as its confirmation
- if ( $_POST['password'] != $_POST['passwordConf'] )
- {
- array_push( $errors, $lang['reg_err_pass'] );
- }
- }
-
+ if ( $mail_error != '' ) array_push( $errors, $mail_error );
+ // password must be the same as its confirmation
+ if ( isset( $_POST['use_new_pwd'] )
+ and $_POST['password'] != $_POST['passwordConf'] )
+ array_push( $errors, $lang['reg_err_pass'] );
+
if ( count( $errors ) == 0 )
{
$query = 'UPDATE '.PREFIX_TABLE.'users';
@@ -95,7 +88,7 @@ if ( isset( $_POST['submit'] ) )
$query.= ';';
mysql_query( $query );
- if ( $_POST['use_new_pwd'] == 1 )
+ if ( isset( $_POST['use_new_pwd'] ) )
{
$query = 'UPDATE '.PREFIX_TABLE.'users';
$query.= " SET password = '".md5( $_POST['password'] )."'";
@@ -103,7 +96,7 @@ if ( isset( $_POST['submit'] ) )
$query.= ';';
mysql_query( $query );
}
- if ( $_POST['create_cookie'] == 1 )
+ if ( isset( $_POST['create_cookie'] ) )
{
setcookie( 'id',$page['session_id'],$_POST['cookie_expiration'],
cookie_path() );
@@ -116,7 +109,7 @@ if ( isset( $_POST['submit'] ) )
}
// redirection
$url = 'category.php';
- if ( $_POST['create_cookie'] != 1 ) $url = add_session_id( $url, true );
+ if ( isset( $_POST['create_cookie'] ) ) $url = add_session_id( $url,true );
header( 'Request-URI: '.$url );
header( 'Content-Location: '.$url );
header( 'Location: '.$url );