Changeset 14


Ignore:
Timestamp:
May 18, 2003, 11:42:32 PM (21 years ago)
Author:
z0rglub
Message:

* empty log message *

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/edit_cat.php

    r10 r14  
    11<?php
    22/***************************************************************************
    3  *                edit_cat.php is a part of PhpWebGallery                  *
     3 *                              edit_cat.php is                            *
    44 *                            -------------------                          *
    5  *   last update          : Tuesday, July 16, 2002                         *
    6  *   email                : pierrick@z0rglub.com                           *
     5 *   application          : PhpWebGallery 1.3                              *
     6 *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
    77 *                                                                         *
    88 ***************************************************************************/
     
    1515 *                                                                         *
    1616 ***************************************************************************/
    17         include_once( "./include/isadmin.inc.php" );
    18        
    19         if ( $HTTP_GET_VARS['valider'] == 1 )
    20         {
    21                 $query = "update PREFIX_TABLE"."categories ";
    22                 if ( $HTTP_POST_VARS['name'] == "" )
    23                 {
    24                         $query.= "set name = NULL, ";
    25                 }
    26                 else
    27                 {
    28                         $query.= "set name = '".htmlspecialchars( $HTTP_POST_VARS['name'], ENT_QUOTES)."', ";
    29                 }
    30                 if ( $HTTP_POST_VARS['comment'] == "" )
    31                 {
    32                         $query.= "comment = NULL, ";
    33                 }
    34                 else
    35                 {
    36                         $query.= "comment = '".htmlspecialchars( $HTTP_POST_VARS['comment'], ENT_QUOTES )."', ";
    37                 }
    38                 $query.= "status = '".$HTTP_POST_VARS['status']."' ";
    39                 $query.= "where id = '".$HTTP_GET_VARS['cat']."';";
    40                 mysql_query( $query );
    41                
    42                 $result = mysql_query( "select id from PREFIX_TABLE"."users where pseudo != '".$conf['webmaster']."';" );
    43                 while ( $row = mysql_fetch_array ( $result ) )
    44                 {
    45                         check_favorites( $row['id'] );
    46                 }
    47                
    48                 echo"<div style=\"color:red;text-align:center;\">".$lang['editcat_confirm']." [ <a href=\"".add_session_id_to_url( "./admin.php?page=cat" )."\">".$lang['editcat_back']."</a> ]</div>";         
    49         }
    50        
    51         echo "
    52         <form action=\"".add_session_id_to_url( "./admin.php?page=edit_cat&amp;cat=".$HTTP_GET_VARS['cat']."&amp;valider=1" )."\" method=\"post\">
    53                 <table style=\"width:100%;\">";
    54         $query = "select a.id,name,dir,status,comment,id_uppercat,site_id,galleries_url";
    55         $query.= " from PREFIX_TABLE"."categories as a, PREFIX_TABLE"."sites as b";
    56         $query.= " where a.id = ".$HTTP_GET_VARS['cat'];
    57         $query.= " and a.site_id = b.id;";
    58         $row = mysql_fetch_array( mysql_query( $query ) );
    59         $result = get_cat_info( $row['id'] );
    60         $array_cat_names = $result['name'];
    61         echo "
    62                         <tr>
    63                                 <th colspan=\"2\">".$lang['editcat_title1']." ".$lang['category']." \"".get_cat_display_name( $array_cat_names, " - ", "font-style:italic;" )."\" [ dir : ".$row['dir']." ]</th>
    64                         </tr>";
    65         if ( $row['site_id'] != 1 )
    66         {
    67                 echo "
    68                         <tr>
    69                                 <td style=\"width:20%;\">Server</td>
    70                                 <td class=\"row2\">".$row['galleries_url']."</td>
    71                         </tr>";
    72         }
    73         echo "
    74                         <tr>
    75                                 <td style=\"width:20%;\">".$lang['editcat_name']."</td>
    76                                 <td class=\"row2\"><input type=\"text\" name=\"name\" value=\"".$row['name']."\" maxlength=\"255\"/></td>
    77                         </tr>
    78                         <tr>
    79                                 <td style=\"width:20%;\">".$lang['editcat_comment']."</td>
    80                                 <td class=\"row2\"><textarea name=\"comment\" rows=\"5\" cols=\"50\" style=\"overflow:auto\">".$row['comment']."</textarea></td>
    81                         </tr>
    82                         <tr>
    83                                 <td style=\"width:20%;\">".$lang['editcat_status']."</td>
    84                                 <td class=\"row2\">
    85                                         <select name=\"status\">";
    86         // on récupère toutes les status possibles dans la base
    87         // par l'intermédiaire de la fonction get_enums trouvable
    88         // dans le fichier config.php
    89         $option = get_enums( PREFIX_TABLE."categories", "status" );
    90         for ( $i = 0; $i < sizeof( $option ); $i++ )
    91         {
    92                 if ( $option[$i] == $row['status'] )
    93                 {
    94                         echo"
    95                                                 <option selected>$option[$i]</option>";
    96                 }
    97                 else
    98                 {
    99                         echo"
    100                                                 <option>$option[$i]</option>";
    101                 }
    102         }
    103         echo"
    104                                         </select>
    105                                         ".$lang['editcat_status_info']."
    106                                 </td>
    107                         </tr>
    108                         <tr>
    109                                 <td colspan=\"2\">&nbsp;</td>
    110                         </tr>
    111                         <tr>
    112                                 <td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"".$lang['submit']."\"/></td>
    113                         </tr>
    114                 </table>
    115         </form>";
     17
     18include_once( './include/isadmin.inc.php' );
     19//----------------------------------------------------- template initialization
     20$sub = $vtp->Open( '../template/'.$user['template'].'/admin/edit_cat.vtp' );
     21$tpl = array( 'remote_site','editcat_confirm','editcat_back','editcat_title1',
     22              'editcat_name', 'editcat_comment', 'editcat_status',
     23              'editcat_status_info', 'submit' );
     24templatize_array( $tpl, 'lang', $sub );
     25//--------------------------------------------------------- form criteria check
     26if ( isset( $_POST['submit'] ) )
     27{
     28  $query = 'UPDATE '.PREFIX_TABLE.'categories';
     29  if ( $_POST['name'] == '' )
     30  {
     31    $query.= ' SET name = NULL';
     32  }
     33  else
     34  {
     35    $query.= " SET name = '".htmlentities( $_POST['name'], ENT_QUOTES)."'";
     36  }
     37  if ( $_POST['comment'] == '' )
     38  {
     39    $query.= ', comment = NULL';
     40  }
     41  else
     42  {
     43    $query.= ", comment = '".htmlentities( $_POST['comment'], ENT_QUOTES )."'";
     44  }
     45  $query.= ", status = '".$_POST['status']."'";
     46  $query.= " WHERE id = '".$_GET['cat']."'";
     47  $query.= ';';
     48  mysql_query( $query );
     49
     50  $query = 'SELECT id';
     51  $query.= ' FROM '.PREFIX_TABLE.'users';
     52  $query.= " WHERE username != '".$conf['webmaster']."'";
     53  $query.= ';';
     54  $result = mysql_query( $query );
     55  while ( $row = mysql_fetch_array ( $result ) )
     56  {
     57    check_favorites( $row['id'] );
     58  }
     59  $vtp->addSession( $sub, 'confirmation' );
     60  $url = add_session_id( './admin.php?page=cat' );
     61  $vtp->setVar( $sub, 'confirmation.back_url', $url );
     62  $vtp->closeSession( $sub, 'confirmation' );
     63}
     64//------------------------------------------------------------------------ form
     65$form_action = './admin.php?page=edit_cat&amp;cat='.$_GET['cat'];
     66$vtp->setVar( $sub, 'form_action', add_session_id( $form_action ) );
     67
     68$query = 'SELECT a.id,name,dir,status,comment';
     69$query.= ',id_uppercat,site_id,galleries_url';
     70$query.= ' FROM '.PREFIX_TABLE.'categories as a, '.PREFIX_TABLE.'sites as b';
     71$query.= ' WHERE a.id = '.$_GET['cat'];
     72$query.= ' AND a.site_id = b.id';
     73$query.= ';';
     74$row = mysql_fetch_array( mysql_query( $query ) );
     75$result = get_cat_info( $row['id'] );
     76
     77$cat_name = get_cat_display_name( $result['name'], ' - ', '' );
     78$vtp->setVar( $sub, 'cat:name', $cat_name );
     79$vtp->setVar( $sub, 'cat:dir', $row['dir'] );
     80if ( $row['site_id'] != 1 )
     81{
     82  $vtp->addSession( $sub, 'server' );
     83  $vtp->setVar( $sub, 'server.url', $row['galleries_url'] );
     84  $vtp->closeSession( $sub, 'server' );
     85}
     86$vtp->setVar( $sub, 'name',    $row['name'] );
     87$vtp->setVar( $sub, 'comment', $row['comment'] );
     88$options = get_enums( PREFIX_TABLE.'categories', 'status' );
     89foreach ( $options as $option  ) {
     90  $vtp->addSession( $sub, 'status_option' );
     91  $vtp->setVar( $sub, 'status_option.option', $option );
     92  if ( $option == $row['status'] )
     93  {
     94    $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' ); 
     95  }
     96  $vtp->closeSession( $sub, 'status_option' );
     97}
     98//----------------------------------------------------------- sending html code
     99$vtp->Parse( $handle , 'sub', $sub );
    116100?>
  • trunk/admin/include/functions.php

    r13 r14  
    1616 ***************************************************************************/
    1717
    18 $tab_ext_create_TN = array ( 'jpg', 'png' );
     18$tab_ext_create_TN = array ( 'jpg', 'png', 'JPG', 'PNG' );
    1919
    2020function is_image( $filename, $create_thumbnail = false )
    2121{
    22   global $conf;
     22  global $conf, $tab_ext_create_TN;
    2323
    2424  if ( is_file ( $filename ) )
  • trunk/admin/infos_images.php

    r10 r14  
    11<?php
    22/***************************************************************************
    3  *             infos_images.php is a part of PhpWebGallery                 *
    4  *                            -------------------                          *
    5  *   last update          : Wednesday, July 25, 2002                       *
    6  *   email                : pierrick@z0rglub.com                           *
     3 *                             infos_images.php                            *
     4 *                            ------------------                           *
     5 *   application          : PhpWebGallery 1.3                              *
     6 *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
    77 *                                                                         *
    88 ***************************************************************************/
     
    1515 *                                                                         *
    1616 ***************************************************************************/
    17         function check_date_format ( $date )
    18         {
    19                 // la date arrive à ce format : JJ/MM/AAAA
    20                 // checkdate ( int month, int day, int year)
    21                 $tab_date = explode( "/", $date );
    22                 return checkdate ( $tab_date[1], $tab_date[0], $tab_date[2]);
    23         }
    24        
    25         function date_convert( $date )
    26         {
    27                 // la date arrive à ce format : JJ/MM/AAAA
    28                 // il faut la transformer en AAAA-MM-JJ
    29                 $tab_date = explode( "/", $date );
    30                 return $tab_date[2]."-".$tab_date[1]."-".$tab_date[0];
    31         }
    32        
    33         function date_convert_back( $date )
    34         {
    35                 // la date arrive à ce format : AAAA-MM-JJ
    36                 // il faut la transformer en JJ/MM/AAAA
    37                 if ( $date != "" )
    38                 {
    39                         $tab_date = explode( "-", $date );
    40                         return $tab_date[2]."/".$tab_date[1]."/".$tab_date[0];
    41                 }
    42                 else
    43                 {
    44                         return "";
    45                 }
    46         }
    47        
    48         include_once( "./include/isadmin.inc.php" );
    49         $page['nb_image_page'] = 5;
    50         check_cat_id( $HTTP_GET_VARS['cat_id'] );
    51         if ( isset( $page['cat'] ) )
    52         {
    53                 //------------------------------------------------------------mises à jour
    54                 // 1. options individuelles
    55                 $query = "select id,file ";
    56                 $query.= "from PREFIX_TABLE"."images ";
    57                 $query.= "where cat_id = ".$page['cat']." ";
    58                 $result = mysql_query( $query );
    59                 $i = 1;
    60                 while ( $row = mysql_fetch_array( $result ) )
    61                 {
    62                         $name = "name-".$row['id'];
    63                         $author = "author-".$row['id'];
    64                         $comment = "comment-".$row['id'];
    65                         $date_creation = "date_creation-".$row['id'];
    66                         if ( isset( $HTTP_POST_VARS[$name] ) )
    67                         {
    68                                 $query = "update PREFIX_TABLE"."images ";
    69                                 if ( $HTTP_POST_VARS[$name] == "" )
    70                                 {
    71                                         $query.= "set name = NULL ";
    72                                 }
    73                                 else
    74                                 {
    75                                         $query.= "set name = '".htmlspecialchars( $HTTP_POST_VARS[$name], ENT_QUOTES )."' ";
    76                                 }
    77                                 if ( $HTTP_POST_VARS[$author] == "" )
    78                                 {
    79                                         $query.= ", author = NULL ";
    80                                 }
    81                                 else
    82                                 {
    83                                         $query.= ", author = '".htmlspecialchars( $HTTP_POST_VARS[$author], ENT_QUOTES )."' ";
    84                                 }
    85                                 if ( $HTTP_POST_VARS[$comment] == "" )
    86                                 {
    87                                         $query.= ", comment = NULL ";
    88                                 }
    89                                 else
    90                                 {
    91                                         $query.= ", comment = '".htmlspecialchars( $HTTP_POST_VARS[$comment], ENT_QUOTES )."' ";
    92                                 }
    93                                 if ( check_date_format( $HTTP_POST_VARS[$date_creation] ) )
    94                                 {
    95                                         $date = date_convert( $HTTP_POST_VARS[$date_creation] );
    96                                         $query.= ", date_creation = '$date' ";
    97                                 }
    98                                 else if ( $HTTP_POST_VARS[$date_creation] == "" )
    99                                 {
    100                                         $query.= ", date_creation = NULL ";
    101                                 }
    102                                 $query.= "where id = '".$row['id']."';";
    103                                 mysql_query( $query );
    104                         }
    105                 }
    106                 // 2. options générales
    107                 if ( $HTTP_POST_VARS['use_common_author'] == 1 )
    108                 {
    109                         $query = "update PREFIX_TABLE"."images ";
    110                         if ( $HTTP_POST_VARS['author_cat'] == "" )
    111                         {
    112                                 $query.= "set author = NULL ";
    113                         }
    114                         else
    115                         {
    116                                 $query.= "set author = '".$HTTP_POST_VARS['author_cat']."' ";
    117                         }
    118                         $query.= "where cat_id = ".$page['cat'].";";
    119                         mysql_query( $query );
    120                 }
    121                 if ( $HTTP_POST_VARS['use_common_date_creation'] == 1 )
    122                 {
    123                         // la date arrive à ce format : JJ/MM/AAAA
    124                         // il faut la transformer en AAAA-MM-JJ
    125                         if ( check_date_format( $HTTP_POST_VARS['date_creation_cat'] ) )
    126                         {
    127                                 $date = date_convert( $HTTP_POST_VARS['date_creation_cat'] );
    128                                 $query = "update PREFIX_TABLE"."images ";
    129                                 if ( $HTTP_POST_VARS['date_creation_cat'] == "" )
    130                                 {
    131                                         $query.= "set date_creation = NULL ";
    132                                 }
    133                                 else
    134                                 {
    135                                         $query.= "set date_creation = '$date' ";
    136                                 }
    137                                 $query.= "where cat_id = ".$page['cat'].";";
    138                                 mysql_query( $query );
    139                         }
    140                         else
    141                         {
    142                                 echo $lang['infoimage_err_date'];
    143                         }
    144                 }
    145                 //----------------------------------------------------affichage de la page
    146                 // détection de la page en cours
    147                 if( !isset( $HTTP_GET_VARS['start'] ) || !is_numeric( $HTTP_GET_VARS['start'] ) || ( is_numeric( $HTTP_GET_VARS['start'] ) && $HTTP_GET_VARS['start'] < 0 ) )
    148                 {
    149                         $page['start'] = 0;
    150                 }
    151                 else
    152                 {
    153                         $page['start'] = $HTTP_GET_VARS['start'];
    154                 }
    155                
    156                 if ( is_numeric( $HTTP_GET_VARS['num'] ) && $HTTP_GET_VARS['num'] >= 0 )
    157                 {
    158                         $page['start'] = floor( $HTTP_GET_VARS['num'] / $page['nb_image_page'] ) * $page['nb_image_page'];
    159                 }
    160                 // retrieving category information
    161                 $result = get_cat_info( $page['cat'] );
    162                 $cat['local_dir'] = $result['local_dir'];
    163                 $cat['dir'] = $result['dir'];
    164                 $cat['name'] = $result['name'];
    165                 $cat['site_id'] = $result['site_id'];
    166                 $cat['nb_images'] = $result['nb_images'];
    167                
    168                 $url = "./admin.php?page=infos_images&amp;cat_id=".$page['cat'];
    169                 $page['navigation_bar'] = create_navigation_bar( $url, $cat['nb_images'], $page['start'], $page['nb_image_page'], "" );
    170                 echo"
    171                 <form method=\"post\" action=\"".add_session_id_to_url( "./admin.php?page=infos_images&amp;cat_id=".$page['cat']."&amp;start=".$page['start'] )."\">
    172                         <table width=\"100%\">
    173                                 <tr>
    174                                         <th colspan=\"3\">".$lang['infoimage_general']." \"".get_cat_display_name( $cat['name'], " - ", "font-style:italic;" )."\"</th>
    175                                 </tr>
    176                                 <tr>
    177                                         <td><div style=\"margin-left:50px;\">".$lang['author']."</div></td>
    178                                         <td style=\"text-align:center;\"><input type=\"text\" name=\"author_cat\" value=\"\" maxlength=\"255\"/></td>
    179                                         <td style=\"text-align:left;\"><input type=\"checkbox\" name=\"use_common_author\" value=\"1\"/>".$lang['infoimage_useforall']."</td>
    180                                 </tr>
    181                                 <tr>
    182                                         <td><div style=\"margin-left:50px;\">".$lang['infoimage_creation_date']." [DD/MM/YYYY]</div></td>
    183                                         <td style=\"text-align:center;\"><input type=\"text\" name=\"date_creation_cat\" value=\"\" size=\"12\" maxlength=\"10\"/></td>
    184                                         <td style=\"text-align:left;\"><input type=\"checkbox\" name=\"use_common_date_creation\" value=\"1\"/>".$lang['infoimage_useforall']."</td>
    185                                 </tr>
    186                         </table>";
    187                 echo"
    188                         <table width=\"100%\">
    189                                 <tr>
    190                                         <th colspan=\"5\">".$lang['infoimage_detailed']."</th>
    191                                 </tr>
    192                                 <tr>
    193                                         <td colspan=\"5\" align=\"center\">".$page['navigation_bar']."</td>
    194                                 </tr>
    195                                 <tr>
    196                                         <td class=\"row2\" style=\"text-align:center;\">".$lang['thumbnail']."</td>
    197                                         <td class=\"row2\" style=\"text-align:center;\">".$lang['infoimage_title']."</td>
    198                                         <td class=\"row2\" style=\"text-align:center;\">".$lang['author']."</td>
    199                                         <td class=\"row2\" style=\"text-align:center;\">".$lang['infoimage_comment']."</td>
    200                                         <td class=\"row2\" style=\"text-align:center;\">".$lang['infoimage_creation_date']."</td>
    201                                 </tr>";
    202                 $query = "select id,file,comment,author,tn_ext,name,date_creation";
    203                 $query.= " from PREFIX_TABLE"."images";
    204                 $query.= " where cat_id = ".$page['cat'];
    205                 $query.= $conf['order_by'];
    206                 $query.= " limit ".$page['start'].",".$page['nb_image_page'];
    207                 $query.= ";";
    208                 $result = mysql_query( $query );
    209                 $i = 1;
    210                 while ( $row = mysql_fetch_array( $result ) )
    211                 {
    212                         echo"
    213                                 <tr>";
    214                         // création des liens vers la miniature
    215                         $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
    216                         if ( $cat['site_id'] == 1 )
    217                         {
    218                                 $lien_thumbnail = "../galleries/".$cat['local_dir']."/";
    219                         }
    220                         else
    221                         {
    222                                 $lien_thumbnail = $cat['dir'];
    223                         }
    224                         $lien_thumbnail.= "thumbnail/".$conf['prefixe_thumbnail'].$file.".".$row['tn_ext'];
    225                         // création du "style" de la ligne
    226                         $style = "style=\"text-align:center;\"";
    227                         if ( $i%2 == 0 )
    228                         {
    229                                 $style.= " class=\"row2\"";
    230                         }
    231                         echo"
    232                                         <td $style><a name=\"".$row['id']."\"><img src=\"$lien_thumbnail\" alt=\"\" class=\"miniature\" title=\"".$row['file']."\"/></td>
    233                                         <td $style>$file<br /><input type=\"text\" name=\"name-".$row['id']."\" value=\"".$row['name']."\" maxlength=\"255\"/></td>
    234                                         <td $style><input type=\"text\" name=\"author-".$row['id']."\" value=\"".$row['author']."\" maxlength=\"255\"/></td>
    235                                         <td $style><textarea name=\"comment-".$row['id']."\" rows=\"3\" cols=\"40\" style=\"overflow:auto\">".$row['comment']."</textarea></td>
    236                                         <td $style><input type=\"text\" name=\"date_creation-".$row['id']."\" value=\"".date_convert_back( $row['date_creation'] )."\" maxlength=\"10\" size=\"12\"/></td>";
    237                         echo"
    238                                 </tr>";
    239                         $i++;
    240                 }
    241                 echo"
    242                                 <tr>
    243                                         <td colspan=\"5\" style=\"text-align:center;\"><input type=\"submit\" value=\"".$lang['submit']."\"/></td>
    244                                 </tr>
    245                         </table>
    246                 </form>";
    247         }
     17
     18include_once( './include/isadmin.inc.php' );
     19include_once( '../template/'.$user['template'].'/htmlfunctions.inc.php' );
     20//------------------------------------------------------------------- functions
     21function check_date_format ( $date )
     22{
     23  // date arrives at this format : DD/MM/YYYY
     24  // checkdate ( int month, int day, int year)
     25  $tab_date = explode( '/', $date );
     26  return checkdate ( $tab_date[1], $tab_date[0], $tab_date[2]);
     27}
     28
     29function date_convert( $date )
     30{
     31  // date arrives at this format : DD/MM/YYYY
     32  // It must be transformed in YYYY-MM-DD
     33  $tab_date = explode( '/', $date );
     34  return $tab_date[2].'-'.$tab_date[1].'-'.$tab_date[0];
     35}
     36
     37function date_convert_back( $date )
     38{
     39  // date arrives at this format : YYYY-MM-DD
     40  // It must be transformed in DD/MM/YYYY
     41  if ( $date != '' )
     42  {
     43    $tab_date = explode( '-', $date );
     44    return $tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0];
     45  }
     46  else
     47  {
     48    return '';
     49  }
     50}
     51//-------------------------------------------------------------- initialization
     52check_cat_id( $_GET['cat_id'] );
     53
     54if ( isset( $page['cat'] ) )
     55{
     56//--------------------------------------------------- update individual options
     57  $query = 'SELECT id,file';
     58  $query.= ' FROM '.PREFIX_TABLE.'images';
     59  $query.= ' WHERE cat_id = '.$page['cat'];
     60  $query.= ';';
     61  $result = mysql_query( $query );
     62  $i = 1;
     63  while ( $row = mysql_fetch_array( $result ) )
     64  {
     65    $name          = 'name-'.$row['id'];
     66    $author        = 'author-'.$row['id'];
     67    $comment       = 'comment-'.$row['id'];
     68    $date_creation = 'date_creation-'.$row['id'];
     69    if ( isset( $_POST[$name] ) )
     70    {
     71      $query = 'UPDATE '.PREFIX_TABLE.'images';
     72      if ( $_POST[$name] == '' )
     73      {
     74        $query.= ' SET name = NULL';
     75      }
     76      else
     77      {
     78        $query.= " SET name = '".htmlentities( $_POST[$name], ENT_QUOTES )."'";
     79      }
     80      if ( $_POST[$author] == '' )
     81      {
     82        $query.= ', author = NULL';
     83      }
     84      else
     85      {
     86        $query.= ", author = '".htmlentities($_POST[$author],ENT_QUOTES)."'";
     87      }
     88      if ( $_POST[$comment] == '' )
     89      {
     90        $query.= ', comment = NULL';
     91      }
     92      else
     93      {
     94        $query.= ", comment = '".htmlentities($_POST[$comment],ENT_QUOTES)."'";
     95      }
     96      if ( check_date_format( $_POST[$date_creation] ) )
     97      {
     98        $date = date_convert( $_POST[$date_creation] );
     99        $query.= ", date_creation = '".$date."'";
     100      }
     101      else if ( $_POST[$date_creation] == '' )
     102      {
     103        $query.= ', date_creation = NULL';
     104      }
     105      $query.= ' WHERE id = '.$row['id'];
     106      $query.= ';';
     107      mysql_query( $query );
     108    }
     109  }
     110//------------------------------------------------------ update general options
     111  if ( $_POST['use_common_author'] == 1 )
     112  {
     113    $query = 'UPDATE '.PREFIX_TABLE.'images';
     114    if ( $_POST['author_cat'] == '' )
     115    {
     116      $query.= ' SET author = NULL';
     117    }
     118    else
     119    {
     120      $query.= ' SET author = ';
     121      $query.= "'".htmlentities( $_POST['author_cat'], ENT_QUOTES )."'";
     122    }
     123    $query.= ' WHERE cat_id = '.$page['cat'];
     124    $query.= ';';
     125    mysql_query( $query );
     126  }
     127  if ( $_POST['use_common_date_creation'] == 1 )
     128  {
     129    if ( check_date_format( $_POST['date_creation_cat'] ) )
     130    {
     131      $date = date_convert( $_POST['date_creation_cat'] );
     132      $query = 'UPDATE '.PREFIX_TABLE.'images';
     133      if ( $_POST['date_creation_cat'] == '' )
     134      {
     135        $query.= ' SET date_creation = NULL';
     136      }
     137      else
     138      {
     139        $query.= " SET date_creation = '".$date."'";
     140      }
     141      $query.= ' WHERE cat_id = '.$page['cat'];
     142      $query.= ';';
     143      mysql_query( $query );
     144    }
     145    else
     146    {
     147      echo $lang['infoimage_err_date'];
     148    }
     149  }
     150//--------------------------------------------------------- form initialization
     151  $page['nb_image_page'] = 5;
     152
     153  if( !isset( $_GET['start'] )
     154      or !is_numeric( $_GET['start'] )
     155      or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
     156  {
     157    $page['start'] = 0;
     158  }
     159  else
     160  {
     161    $page['start'] = $_GET['start'];
     162  }
     163
     164  if ( is_numeric( $_GET['num'] ) and $_GET['num'] >= 0 )
     165  {
     166    $page['start'] = floor( $_GET['num'] / $page['nb_image_page'] ) * $page['nb_image_page'];
     167  }
     168  // retrieving category information
     169  $result = get_cat_info( $page['cat'] );
     170  $cat['local_dir'] = $result['local_dir'];
     171  $cat['dir'] = $result['dir'];
     172  $cat['name'] = $result['name'];
     173  $cat['site_id'] = $result['site_id'];
     174  $cat['nb_images'] = $result['nb_images'];
     175//----------------------------------------------------- template initialization
     176  $sub = $vtp->Open('../template/'.$user['template'].'/admin/infos_image.vtp');
     177  $tpl = array( 'infoimage_general','author','infoimage_useforall','submit',
     178                'infoimage_creation_date','infoimage_detailed','thumbnail',
     179                'infoimage_title','infoimage_comment',
     180                'infoimage_creation_date' );
     181  templatize_array( $tpl, 'lang', $sub );
     182//------------------------------------------------------------------------ form
     183  $url = './admin.php?page=infos_images&amp;cat_id='.$page['cat'];
     184  $url.= '&amp;start='.$page['start'];
     185  $vtp->setVar( $sub, 'form_action', add_session_id( $url ) );
     186  $page['navigation_bar'] = create_navigation_bar(
     187    $url, $cat['nb_images'],$page['start'], $page['nb_image_page'], '' );
     188  $vtp->setVar( $sub, 'navigation_bar', $page['navigation_bar'] );
     189  $cat_name = get_cat_display_name( $cat['name'], ' - ', 'font-style:italic;');
     190  $vtp->setVar( $sub, 'cat_name', $cat_name );
     191
     192  $query = 'SELECT id,file,comment,author,tn_ext,name,date_creation';
     193  $query.= ' FROM '.PREFIX_TABLE.'images';
     194  $query.= ' WHERE cat_id = '.$page['cat'];
     195  $query.= $conf['order_by'];
     196  $query.= ' LIMIT '.$page['start'].','.$page['nb_image_page'];
     197  $query.= ';';
     198  $result = mysql_query( $query );
     199  while ( $row = mysql_fetch_array( $result ) )
     200  {
     201    $vtp->addSession( $sub, 'picture' );
     202    $vtp->setVar( $sub, 'picture.id', $row['id'] );
     203    $vtp->setVar( $sub, 'picture.filename', $row['file'] );
     204    $vtp->setVar( $sub, 'picture.name', $row['name'] );
     205    $vtp->setVar( $sub, 'picture.author', $row['author'] );
     206    $vtp->setVar( $sub, 'picture.comment', $row['comment'] );
     207    $vtp->setVar( $sub, 'picture.date_creation',
     208                  date_convert_back( $row['date_creation'] ) );
     209    $file = get_filename_wo_extension( $row['file'] );
     210    $vtp->setVar( $sub, 'picture.default_name', $file );
     211    // creating url to thumbnail
     212    if ( $cat['site_id'] == 1 )
     213    {
     214      $thumbnail_url = '../galleries/'.$cat['local_dir'].'/';
     215    }
     216    else
     217    {
     218      $thumbnail_url = $cat['dir'];
     219    }
     220    $thumbnail_url.= 'thumbnail/';
     221    $thumbnail_url.= $conf['prefixe_thumbnail'].$file.".".$row['tn_ext'];
     222    $vtp->setVar( $sub, 'picture.thumbnail_url', $thumbnail_url );
     223    $vtp->closeSession( $sub, 'picture' );
     224  }
     225}
     226//----------------------------------------------------------- sending html code
     227$vtp->Parse( $handle , 'sub', $sub );
    248228?>
  • trunk/category.php

    r10 r14  
    102102templatize_array( $tpl, 'conf', $handle );
    103103
    104 $tpl = array( 'short_period','long_period','style','lien_collapsed',
    105               'username' );
     104$tpl = array( 'short_period','long_period','lien_collapsed', 'username' );
    106105templatize_array( $tpl, 'user', $handle );
    107106
     
    466465  if ( isset( $page['comment'] ) and $page['comment'] != '' )
    467466  {
    468     $vtp->addSession( $handle, 'cat_comment' );
    469     $vtp->closeSession( $handle, 'cat_navigation' );
     467    $vtp->addSession( $handle, 'comment' );
     468    $vtp->setVar( $handle, 'comment.cat_comment', $page['comment'] );
     469    $vtp->closeSession( $handle, 'comment' );
    470470  }
    471471  // total number of pictures in the category
  • trunk/include/config.inc.php

    r13 r14  
    3838//    will only order pictures by file ascending
    3939//    without taking into account the date_available
    40 $conf['order_by'] = " order by date_available desc, file asc";
     40$conf['order_by'] = ' order by date_available desc, file asc';
    4141
    4242$conf['repertoire_image']   = './images/';
    43 $conf['nb_image_row']       = array ('4','5','6','7','8');
    44 $conf['nb_row_page']        = array ('2','3','4','5','6','7','10','20','1000');
     43$conf['nb_image_row']       = array('4','5','6','7','8');
     44$conf['nb_row_page']        = array('2','3','4','5','6','7','10','20','1000');
    4545$conf['version']            = '1.3';
    4646$conf['site_url']           = 'http://www.phpwebgallery.net';
    4747$conf['forum_url']          = 'http://forum.phpwebgallery.net';
    48 $conf['picture_ext']        = array ( 'jpg','JPG','gif','GIF','png','PNG' );
    49 $conf['document_ext']       = array( 'doc','pdf','zip' );
     48$conf['picture_ext']        = array('jpg','JPG','gif','GIF','png','PNG');
     49$conf['document_ext']       = array('doc','pdf','zip');
    5050
    5151database_connection();
     
    6262                'upload_maxheight_thumbnail' );
    6363
    64 $query  = 'select';
     64$query  = 'SELECT';
    6565for ( $i = 0; $i < sizeof( $infos ); $i++ )
    6666{
     
    7575  $query.= $infos[$i];
    7676}
    77 $query .= ' from '.PREFIX_TABLE.'config;';
     77$query .= ' FROM '.PREFIX_TABLE.'config;';
    7878
    7979$row = mysql_fetch_array( mysql_query( $query ) );
     
    9191  }
    9292}
    93 $conf['log']                        = false;
    94 $conf['top_number']                 = 10;
     93$conf['log']        = false;
     94$conf['top_number'] = 20;
    9595?>
  • trunk/include/functions_session.inc.php

    r13 r14  
    1919  global $conf;
    2020  $md5 = md5( substr( microtime(), 2, 6 ).$conf['session_keyword'] );
    21   $init = "";
     21  $init = '';
    2222  for ( $i = 0; $i < strlen( $md5 ); $i++ )
    2323  {
    2424    if ( is_numeric( $md5[$i] ) )
    2525    {
    26       $init.= "$md5[$i]";
     26      $init.= $md5[$i];
    2727    }
    2828  }
    2929  $init = substr( $init, 0, 8 );
    3030  mt_srand( $init );
    31   $key = "";
     31  $key = '';
    3232  for ( $i = 0; $i < $conf['session_id_size']; $i++ )
    3333  {
  • trunk/include/functions_user.inc.php

    r13 r14  
    208208{
    209209  global $user,$lang,$conf,$page;
     210
    210211  if ( $user['is_the_guest']
    211212       and ( $conf['acces'] == 'restreint' or $page['cat'] == 'fav' ) )
  • trunk/profile.php

    r10 r14  
    11<?php
    22/***************************************************************************
    3  *                    profile.php is a part of PhpWebGallery               *
     3 *                                profile.php                              *
    44 *                            -------------------                          *
    5  *   last update          : Tuesday, July 16, 2002                         *
    6  *   email                : pierrick@z0rglub.com                           *
     5 *   application          : PhpWebGallery 1.3                              *
     6 *   author               : Pierrick LE GALL <pierrick@z0rglub.com>        *
    77 *                                                                         *
    88 ***************************************************************************/
     
    145145$vtp = new VTemplate;
    146146$handle = $vtp->Open( './template/'.$user['template'].'/profile.vtp' );
    147 // language
    148 $vtp->setGlobalVar( $handle, 'customize_page_title',
    149                     $lang['customize_page_title'] );
    150 $vtp->setGlobalVar( $handle, 'customize_title',  $lang['customize_title'] );
    151 $vtp->setGlobalVar( $handle, 'password',         $lang['password'] );
    152 $vtp->setGlobalVar( $handle, 'new',              $lang['new'] );
    153 $vtp->setGlobalVar( $handle, 'reg_confirm',      $lang['reg_confirm'] );
    154 $vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
    155 
    156147initialize_template();
     148$tpl = array( 'customize_page_title','customize_title','password','new',
     149              'reg_confirm','submit' );
     150templatize_array( $tpl, 'lang', $handle );
    157151//----------------------------------------------------------------- form action
    158152$url = './profile.php?cat='.$page['cat'].'&amp;expand='.$page['expand'];
  • trunk/template/default/htmlfunctions.inc.php

    r2 r14  
    3939  return $output;
    4040}
    41 /*
    42 function affiche_icone_recent( $date_comparaison )
    43 {
    44   global $user, $conf;
    45   $difference = time() - $date_comparaison;
    46   $jours = 24*60*60;
    47   $output = '';
    48   if ( $difference < $conf['periode_longue'] * $jours )
    49   {
    50     $icon_url = './theme/'.$user['theme'].'/';
    51     if ( $difference < $conf['periode_courte'] * $jours )
    52     {
    53       $icon_url.= 'new_long.gif';
    54     }
    55     else
    56     {
    57       $icon_url.= 'new_short.gif';
    58     }
    59     $size = getimagesize( $icon_url );
    60     $output = '<img src="'.$icon_url.'" style="border:0;height:'.$size[1].'px;width:'.$size[0].'px" alt="" />';
    61   }
    62   return $output;
    63 }
    64 */
    6541
    6642function create_navigation_bar( $url, $nb_element, $start,
     
    12298  return '<table style="width:';
    12399}
    124 /*
     100
    125101function get_frame_begin()
    126102{
    127103  return ';">
    128104            <tr>
    129               <td style="border:2px solid lightgreen;width:100%;padding:5px;background-color:black;">';
     105              <td style="border:1px dashed gray;width:100%;padding:5px;background-color:white;">';
    130106}
    131107
     
    137113          </table>';
    138114}
    139 */       
     115/*
    140116function get_frame_begin()
    141117{
     
    172148          </table>';
    173149}
    174 
     150*/
    175151function initialize_template()
    176152{
    177153  global $vtp, $handle, $user;
    178154
     155  $vtp->setGlobalVar( $handle, 'style', $user['style'] );
    179156  $vtp->setGlobalVar( $handle, 'frame_start', get_frame_start() );
    180157  $vtp->setGlobalVar( $handle, 'frame_begin', get_frame_begin() );
  • trunk/template/default/profile.vtp

    r2 r14  
    11<html>
    22  <head>
    3     {#page_style}
     3    {#style}
    44    <title>{#customize_page_title}</title>
    5     </head>
     5  </head>
    66  <body>
     7    {#header}
    78    <table style="width:100%;height:100%">
    89      <tr align="center" valign="middle">
     
    8182      </tr>
    8283    </table>
     84    {#footer}
    8385  </body>
    8486</html>
Note: See TracChangeset for help on using the changeset viewer.