Changeset 21


Ignore:
Timestamp:
Jul 1, 2003, 11:27:20 AM (21 years ago)
Author:
z0rglub
Message:

* empty log message *

Location:
trunk
Files:
13 added
5 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/admin.php

    r10 r21  
    2626//--------------------------------------- validating page and creation of title
    2727$page_valide = false;
     28$title = '';
    2829switch ( $_GET['page'] )
    2930{
    3031 case 'user_add':
    31    $titre = $lang['title_add'];           $page_valide = true; break;
     32   $title = $lang['title_add'];           $page_valide = true; break;
    3233 case 'user_list':
    33    $titre = $lang['title_liste_users'];   $page_valide = true; break;
     34   $title = $lang['title_liste_users'];   $page_valide = true; break;
    3435 case 'user_modify':
    35    $titre = $lang['title_modify'];        $page_valide = true; break;
     36   $title = $lang['title_modify'];        $page_valide = true; break;
     37 case 'user_perm':
     38   if ( !is_numeric( $_GET['user_id'] ) ) $_GET['user_id'] = -1;
     39   $query = 'SELECT status,username';
     40   $query.= ' FROM '.PREFIX_TABLE.'users';
     41   $query.= ' WHERE id = '.$_GET['user_id'];
     42   $query.= ';';
     43   $result = mysql_query( $query );
     44   if ( mysql_num_rows( $result ) > 0 )
     45   {
     46     $row = mysql_fetch_array( $result );
     47     $page['user_status']   = $row['status'];
     48     if ( $row['username'] == 'guest' ) $row['username'] = $lang['guest'];
     49     $page['user_username'] = $row['username'];
     50     $page_valide = true;
     51     $title = $lang['title_user_perm'].' "'.$page['user_username'].'"';
     52   }
     53   else
     54   {
     55     $page_valide = false;
     56   }
     57   break;
     58 case 'group_list' :
     59   $title = $lang['title_groups'];        $page_valide = true; break;
     60 case 'group_perm' :
     61   if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1;
     62   $query = 'SELECT name';
     63   $query.= ' FROM '.PREFIX_TABLE.'groups';
     64   $query.= ' WHERE id = '.$_GET['group_id'];
     65   $query.= ';';
     66   $result = mysql_query( $query );
     67   if ( mysql_num_rows( $result ) > 0 )
     68   {
     69     $row = mysql_fetch_array( $result );
     70     $title = $lang['title_group_perm'].' "'.$row['name'].'"';
     71     $page_valide = true;
     72   }
     73   else
     74   {
     75     $page_valide = false;
     76   }
     77   break;
    3678 case 'historique':
    37    $titre = $lang['title_history'];       $page_valide = true; break;
     79   $title = $lang['title_history'];       $page_valide = true; break;
    3880 case 'update':
    39    $titre = $lang['title_update'];        $page_valide = true; break;
     81   $title = $lang['title_update'];        $page_valide = true; break;
    4082 case 'configuration':
    41    $titre = $lang['title_configuration']; $page_valide = true; break;
     83   $title = $lang['title_configuration']; $page_valide = true; break;
    4284 case 'manuel':
    43    $titre = $lang['title_instructions'];  $page_valide = true; break;
    44  case 'perm':
    45    $titre = $lang['title_permissions'];   $page_valide = true; break;
    46  case 'cat':
    47    $titre = $lang['title_categories'];    $page_valide = true; break;
    48  case 'edit_cat':
    49    $titre = $lang['title_edit_cat'];      $page_valide = true; break;
     85   $title = $lang['title_instructions'];  $page_valide = true; break;
     86 case 'cat_perm':
     87   $title = $lang['title_cat_perm'];
     88   if ( isset( $_GET['cat_id'] ) )
     89   {
     90     check_cat_id( $_GET['cat_id'] );
     91     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
     92     {
     93       $result = get_cat_info( $page['cat'] );
     94       $name = get_cat_display_name( $result['name'],' > ', '' );
     95       $title.= ' "'.$name.'"';
     96     }
     97   }
     98   $page_valide = true;
     99   break;
     100 case 'cat_list':
     101   $title = $lang['title_categories'];    $page_valide = true; break;
     102 case 'cat_modify':
     103   $title = $lang['title_edit_cat'];      $page_valide = true; break;
    50104 case 'infos_images':
    51    $titre = $lang['title_info_images'];   $page_valide = true; break;
     105   $title = $lang['title_info_images'];   $page_valide = true; break;
    52106 case 'waiting':
    53    $titre = $lang['title_waiting'];       $page_valide = true; break;
     107   $title = $lang['title_waiting'];       $page_valide = true; break;
    54108 case 'thumbnail':
    55    $titre = $lang['title_thumbnails'];
     109   $title = $lang['title_thumbnails'];
    56110   if ( isset( $_GET['dir'] ) )
    57111   {
    58      $titre.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';
     112     $title.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';
    59113     // $_GET['dir'] contient :
    60114     // ../galleries/vieux_lyon ou
     
    62116     // ../galleries/vieux_lyon/visite/truc ...
    63117     $dir = explode( "/", $_GET['dir'] );
    64      $titre.= $dir[2];
     118     $title.= $dir[2];
    65119     for ( $i = 3; $i < sizeof( $dir ) - 1; $i++ )
    66120     {
    67        $titre.= ' &gt; '.$dir[$i];
     121       $title.= ' &gt; '.$dir[$i];
    68122     }
    69      $titre.= "</span>";
     123     $title.= "</span>";
    70124   }
    71125   $page_valide = true;
    72126   break;
    73127 default:
    74    $titre = $lang['title_default']; break;
    75 }
    76 $vtp->setGlobalVar( $handle, 'title', $titre );
     128   $title = $lang['title_default']; break;
     129}
     130if ( $title == '' ) $title = $lang['title_default'];
     131$vtp->setGlobalVar( $handle, 'title', $title );
    77132//--------------------------------------------------------------------- summary
    78133$link_start = './admin.php?page=';
     
    88143$vtp->setVar( $handle, 'summary.indent', '' );
    89144$vtp->setVar( $handle, 'summary.link',
    90               add_session_id( $link_start.'liste_users' ) );
     145              add_session_id( $link_start.'user_list' ) );
    91146$vtp->setVar( $handle, 'summary.name', $lang['menu_users'] );
    92147$vtp->closeSession( $handle, 'summary' );
     
    105160$vtp->setVar( $handle, 'summary.name', $lang['menu_add_user'] );
    106161$vtp->closeSession( $handle, 'summary' );
     162// groups
     163$vtp->addSession( $handle, 'summary' );
     164$vtp->setVar( $handle, 'summary.indent', '' );
     165$vtp->setVar( $handle, 'summary.link',
     166              add_session_id( $link_start.'group_list' ) );
     167$vtp->setVar( $handle, 'summary.name', $lang['menu_groups'] );
     168$vtp->closeSession( $handle, 'summary' );
    107169// categories
    108170$vtp->addSession( $handle, 'summary' );
    109171$vtp->setVar( $handle, 'summary.indent', '' );
    110 $vtp->setVar( $handle, 'summary.link', add_session_id( $link_start.'cat' ) );
     172$vtp->setVar( $handle, 'summary.link',add_session_id( $link_start.'cat_list'));
    111173$vtp->setVar( $handle, 'summary.name', $lang['menu_categories'] );
    112174$vtp->closeSession( $handle, 'summary' );
  • trunk/admin/configuration.php

    r20 r21  
    1616 *                                                                         *
    1717 ***************************************************************************/
    18  
     18
    1919include_once( './include/isadmin.inc.php' );
    2020       
     
    4949if ( isset( $_POST['submit'] ) )
    5050{
    51   //purge de la table des session si demandé
     51  $int_pattern = '/^\d+$/';
     52  // empty session table if asked
    5253  if ( $_POST['empty_session_table'] == 1 )
    5354  {
     
    8081  }
    8182  // periods must be integer values, they represents number of days
    82   if ( !is_int( $_POST['short_period'] )
    83        or !is_int( $_POST['long_period'] ) )
     83  if ( !preg_match( $int_pattern, $_POST['short_period'] )
     84       or !preg_match( $int_pattern, $_POST['long_period'] ) )
    8485  {
    8586    array_push( $error, $lang['err_periods'] );
     
    9596  }
    9697  // session_id size must be an integer between 4 and 50
    97   if ( !is_int( $_POST['session_id_size'] )
     98  if ( !preg_match( $int_pattern, $_POST['session_id_size'] )
    9899       or $_POST['session_id_size'] < 4
    99100       or $_POST['session_id_size'] > 50 )
     
    102103  }
    103104  // session_time must be an integer between 5 and 60, in minutes
    104   if ( !is_int( $_POST['session_time'] )
     105  if ( !preg_match( $int_pattern, $_POST['session_time'] )
    105106       or $_POST['session_time'] < 5
    106107       or $_POST['session_time'] > 60 )
     
    109110  }
    110111  // max_user_listbox must be an integer between 0 and 255 included
    111   if ( !is_int( $_POST['max_user_listbox'] )
     112  if ( !preg_match( $int_pattern, $_POST['max_user_listbox'] )
    112113       or $_POST['max_user_listbox'] < 0
    113114       or $_POST['max_user_listbox'] > 255 )
     
    117118  // the number of comments per page must be an integer between 5 and 50
    118119  // included
    119   if ( !is_int( $_POST['nb_comment_page'] )
     120  if ( !preg_match( $int_pattern, $_POST['nb_comment_page'] )
    120121       or $_POST['nb_comment_page'] < 5
    121122       or $_POST['nb_comment_page'] > 50 )
     
    124125  }
    125126  // the maximum upload filesize must be an integer between 10 and 1000
    126   if ( !is_int( $_POST['upload_maxfilesize'] )
     127  if ( !preg_match( $int_pattern, $_POST['upload_maxfilesize'] )
    127128       or $_POST['upload_maxfilesize'] < 10
    128129       or $_POST['upload_maxfilesize'] > 1000 )
     
    132133  // the maximum width of uploaded pictures must be an integer superior to
    133134  // 10
    134   if ( !is_int( $_POST['upload_maxwidth'] )
     135  if ( !preg_match( $int_pattern, $_POST['upload_maxwidth'] )
    135136       or $_POST['upload_maxwidth'] < 10 )
    136137  {
     
    139140  // the maximum height  of uploaded pictures must be an integer superior to
    140141  // 10
    141   if ( !is_int( $_POST['upload_maxheight'] )
     142  if ( !preg_match( $int_pattern, $_POST['upload_maxheight'] )
    142143       or $_POST['upload_maxheight'] < 10 )
    143144  {
     
    146147  // the maximum width of uploaded thumbnails must be an integer superior to
    147148  // 10
    148   if ( !is_int( $_POST['upload_maxwidth_thumbnail'] )
     149  if ( !preg_match( $int_pattern, $_POST['upload_maxwidth_thumbnail'] )
    149150       or $_POST['upload_maxwidth_thumbnail'] < 10 )
    150151  {
     
    153154  // the maximum width of uploaded thumbnails must be an integer superior to
    154155  // 10
    155   if ( !is_int( $_POST['upload_maxheight_thumbnail'] )
     156  if ( !preg_match( $int_pattern, $_POST['upload_maxheight_thumbnail'] )
    156157       or $_POST['upload_maxheight_thumbnail'] < 10 )
    157158  {
    158159    array_push( $error, $lang['conf_err_upload_maxheight_thumbnail'] );
    159160  }
    160   $test = '';
    161   if ( is_int( $test ) ) echo 'salut'; exit();
    162   if ( $_POST['maxwidth'] != '' )
    163   {
    164     if ( !ereg( "^[0-9]{2,}$", $_POST['maxwidth'] )
    165          or $_POST['maxwidth'] < 50 )
    166     {
    167       $error[$i++] = $lang['err_maxwidth'];
    168     }
    169   }
    170   if ( $_POST['maxheight'] != '' )
    171   {
    172     if ( !ereg( "^[0-9]{2,}$", $_POST['maxheight'] )
    173          or $_POST['maxheight'] < 50 )
    174     {
    175       $error[$i++] = $lang['err_maxheight'];
    176     }
    177   }
    178   // on met à jour les paramètres de l'application
    179   // dans le cas où il n'y aucune erreurs
    180   if ( sizeof( $error ) == 0 )
    181   {
    182     mysql_query( 'delete from '.PREFIX_TABLE.'config;' );
    183     $query = 'insert into '.PREFIX_TABLE.'config';
     161
     162  if ( $_POST['maxwidth'] != ''
     163       and ( !preg_match( $int_pattern, $_POST['maxwidth'] )
     164             or $_POST['maxwidth'] < 50 ) )
     165  {
     166    array_push( $error, $lang['err_maxwidth'] );
     167  }
     168  if ( $_POST['maxheight']
     169       and ( !preg_match( $int_pattern, $_POST['maxheight'] )
     170             or $_POST['maxheight'] < 50 ) )
     171  {
     172    array_push( $error, $lang['err_maxheight'] );
     173  }
     174  // updating configuraiton if no error found
     175  if ( count( $error ) == 0 )
     176  {
     177    mysql_query( 'DELETE FROM '.PREFIX_TABLE.'config;' );
     178    $query = 'INSERT INTO '.PREFIX_TABLE.'config';
    184179    $query.= ' (';
    185180    foreach ( $conf_infos as $i => $conf_info ) {
     
    188183    }
    189184    $query.= ')';
    190     $query.= ' values';
     185    $query.= ' VALUES';
    191186    $query.= ' (';
    192187    foreach ( $conf_infos as $i => $conf_info ) {
     
    261256}
    262257//----------------------------------------------------- template initialization
    263 $sub = $vtp->Open( '../template/'.$user['template'].
    264                    '/admin/configuration.vtp' );
    265 // language
    266 $vtp->setGlobalVar( $sub, 'conf_confirmation',  $lang['conf_confirmation'] );
    267 $vtp->setGlobalVar( $sub, 'remote_site',        $lang['remote_site'] );
    268 $vtp->setGlobalVar( $sub, 'delete',             $lang['delete'] );
    269 $vtp->setGlobalVar( $sub, 'conf_remote_site_delete_info',
    270                     $lang['conf_remote_site_delete_info'] );
    271 $vtp->setGlobalVar( $sub, 'submit',             $lang['submit'] );
     258$sub = $vtp->Open(
     259  '../template/'.$user['template'].'/admin/configuration.vtp' );
     260
     261$tpl = array( 'conf_confirmation','remote_site','delete',
     262              'conf_remote_site_delete_info','submit' );
     263templatize_array( $tpl, 'lang', $sub );
    272264//-------------------------------------------------------------- errors display
    273265if ( sizeof( $error ) != 0 )
     
    346338$vtp->setVar( $sub, 'radio.option', $lang['conf_general_access_1'] );
    347339$checked = '';
    348 echo $access.'<br />';
    349340if ( $access == 'free' )
    350341{
  • trunk/admin/include/functions.php

    r19 r21  
    102102    delete_image( $row['id'] );
    103103  }
    104                
    105   // destruction of the restrictions linked to the category
    106   $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions';
     104
     105  // destruction of the access linked to the category
     106  $query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
    107107  $query.= ' WHERE cat_id = '.$id;
    108108  $query.= ';';
    109109  mysql_query( $query );
    110                
     110  $query = 'DELETE FROM '.PREFIX_TABLE.'group_access';
     111  $query.= ' WHERE cat_id = '.$id;
     112  $query.= ';';
     113  mysql_query( $query );
     114
    111115  // destruction of the sub-categories
    112116  $query = 'SELECT id';
     
    119123    delete_category( $row['id'] );
    120124  }
    121                
     125
    122126  // destruction of the category
    123127  $query = 'DELETE FROM '.PREFIX_TABLE.'categories';
     
    157161// The delete_user function delete a user identified by the $user_id
    158162// It also deletes :
    159 //     - all the restrictions linked to this user
     163//     - all the access linked to this user
     164//     - all the links to any group
    160165//     - all the favorites linked to this user
     166//     - all sessions linked to this user
    161167function delete_user( $user_id )
    162168{
    163   // destruction of the restrictions linked to the user
    164   $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions';
    165   $query.= ' WHERE user_id = '.$user_id;
    166   $query.= ';';
    167   mysql_query( $query );
    168                
     169  // destruction of the access linked to the user
     170  $query = 'DELETE FROM '.PREFIX_TABLE.'user_access';
     171  $query.= ' WHERE user_id = '.$user_id;
     172  $query.= ';';
     173  mysql_query( $query );
     174
     175  // destruction of the group links for this user
     176  $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
     177  $query.= ' WHERE user_id = '.$user_id;
     178  $query.= ';';
     179  mysql_query( $query );
     180
    169181  // destruction of the favorites associated with the user
    170182  $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
     183  $query.= ' WHERE user_id = '.$user_id;
     184  $query.= ';';
     185  mysql_query( $query );
     186
     187  // destruction of the sessions linked with the user
     188  $query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
    171189  $query.= ' WHERE user_id = '.$user_id;
    172190  $query.= ';';
     
    179197  mysql_query( $query );
    180198}
    181        
     199
     200// delete_group deletes a group identified by its $group_id.
     201// It also deletes :
     202//     - all the access linked to this group
     203//     - all the links between this group and any user
     204function delete_group( $group_id )
     205{
     206  // destruction of the access linked to the group
     207  $query = 'DELETE FROM '.PREFIX_TABLE.'group_access';
     208  $query.= ' WHERE group_id = '.$group_id;
     209  $query.= ';';
     210  mysql_query( $query );
     211
     212  // destruction of the group links for this group
     213  $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
     214  $query.= ' WHERE group_id = '.$group_id;
     215  $query.= ';';
     216  mysql_query( $query );
     217
     218  // destruction of the group
     219  $query = 'DELETE FROM '.PREFIX_TABLE.'groups';
     220  $query.= ' WHERE id = '.$group_id;
     221  $query.= ';';
     222  mysql_query( $query );
     223}
     224
    182225// The check_favorites function deletes all the favorites of a user if he is
    183226// not allowed to see them (the category or an upper category is restricted
  • trunk/admin/include/isadmin.inc.php

    r2 r21  
    1515 *                                                                         *
    1616 ***************************************************************************/
    17 define( PREFIXE_INCLUDE, '.' );
     17define( PREFIX_INCLUDE, '.' );
    1818
    1919include_once( '../include/config.inc.php' );
    2020include_once( '../include/user.inc.php' );
    2121include( './include/functions.php' );
    22 
    23 $conf['lien_puce'] = $conf['repertoire_image'].'puce.gif';
    2422
    2523$isadmin = true;
  • trunk/admin/user_list.php

    r10 r21  
    1818//----------------------------------------------------- template initialization
    1919$sub = $vtp->Open( '../template/'.$user['template'].'/admin/user_list.vtp' );
    20 // language
    21 $vtp->setGlobalVar( $sub, 'listuser_confirm',  $lang['listuser_confirm'] );
    22 $vtp->setGlobalVar( $sub, 'listuser_modify_hint',
    23                     $lang['listuser_modify_hint'] );
    24 $vtp->setGlobalVar( $sub, 'listuser_modify', $lang['listuser_modify'] );
    25 $vtp->setGlobalVar( $sub, 'listuser_permission',
    26                     $lang['listuser_permission'] );
    27 $vtp->setGlobalVar( $sub, 'listuser_permission_hint',
    28                     $lang['listuser_permission_hint'] );
    29 $vtp->setGlobalVar( $sub, 'listuser_delete_hint',
    30                     $lang['listuser_delete_hint'] );
    31 $vtp->setGlobalVar( $sub, 'listuser_delete',   $lang['listuser_delete'] );
    32 $vtp->setGlobalVar( $sub, 'yes',               $lang['yes'] );
    33 $vtp->setGlobalVar( $sub, 'no',                $lang['no'] );
    34 $vtp->setGlobalVar( $sub, 'listuser_button_all',
    35                     $lang['listuser_button_all'] );
    36 $vtp->setGlobalVar( $sub, 'listuser_button_invert',
    37                     $lang['listuser_button_invert'] );
    38 $vtp->setGlobalVar( $sub, 'listuser_button_create_address',
    39                     $lang['listuser_button_create_address'] );
     20$tpl = array( 'listuser_confirm','listuser_modify_hint','listuser_modify',
     21              'listuser_permission','listuser_permission_hint',
     22              'listuser_delete_hint','listuser_delete','yes','no',
     23              'listuser_button_all','listuser_button_invert',
     24              'listuser_button_create_address' );
     25templatize_array( $tpl, 'lang', $sub );
    4026//--------------------------------------------------------------- delete a user
    4127if ( isset ( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) )
    4228{
    43   $query = 'select username';
    44   $query.= ' from '.PREFIX_TABLE.'users';
    45   $query.= ' where id = '.$_GET['delete'];
     29  $query = 'SELECT username';
     30  $query.= ' FROM '.PREFIX_TABLE.'users';
     31  $query.= ' WHERE id = '.$_GET['delete'];
    4632  $query.= ';';
    4733  $row = mysql_fetch_array( mysql_query( $query ) );
     
    6551         and $row['username'] != $conf['webmaster'] )
    6652    {
    67       $query = 'select count(*) as nb_result';
    68       $query.= ' from '.PREFIX_TABLE.'users';
    69       $query.= ' where id = '.$_GET['delete'];
     53      $query = 'SELECT COUNT(*) AS nb_result';
     54      $query.= ' FROM '.PREFIX_TABLE.'users';
     55      $query.= ' WHERE id = '.$_GET['delete'];
    7056      $query.= ';';
    7157      $row2 = mysql_fetch_array( mysql_query( $query ) );
     
    10389  $vtp->setVar( $sub, 'users.form_action', $action );
    10490
    105   $query = 'select id,username,status,mail_address';
    106   $query.= ' from '.PREFIX_TABLE.'users';
    107   $query.= ' order by status asc, username asc';
     91  $query = 'SELECT id,username,status,mail_address';
     92  $query.= ' FROM '.PREFIX_TABLE.'users';
     93  $query.= ' ORDER BY status ASC, username ASC';
    10894  $query.= ';';
    10995  $result = mysql_query( $query );
     
    123109      switch ( $row['status'] )
    124110      {
    125       case 'admin' :
    126       {
    127         $title.= $lang['adduser_status_admin'];
    128         break;
    129       }
    130       case 'guest' :
    131       {
    132         $title.= $lang['adduser_status_guest'];
    133         break;
    134       }
     111      case 'admin' : $title.= $lang['adduser_status_admin']; break;
     112      case 'guest' : $title.= $lang['adduser_status_guest']; break;
    135113      }
    136114      $vtp->setVar( $sub, 'category.title', $title );
     
    153131    {
    154132      $vtp->setVar( $sub, 'user.color', 'green' );
    155     }
    156     if ( $row['username'] == 'guest' )
    157     {
    158133      $vtp->setVar( $sub, 'user.login', $lang['guest'] );
    159134    }
     
    180155    }
    181156    // manage permission or not ?
    182     if ( $row['username'] == $conf['webmaster'] )
     157    if ( $row['username'] == $conf['webmaster']
     158         and $user['username'] != $conf['webmaster'] )
    183159    {
    184160      $vtp->addSession( $sub, 'not_permission' );
     
    188164    {
    189165      $vtp->addSession( $sub, 'permission' );
    190       $url = './admin.php?page=perm&amp;user_id='.$row['id'];
     166      $url = './admin.php?page=user_perm&amp;user_id='.$row['id'];
    191167      $vtp->setVar( $sub, 'permission.url', add_session_id( $url ) );
    192168      $vtp->setVar( $sub, 'permission.login', $row['username'] );
     
    216192    $mail_address = array();
    217193    $i = 0;
    218     $query = 'select';
    219     $query.= ' id,mail_address';
    220     $query.= ' from '.PREFIX_TABLE.'users';
     194    $query = 'SELECT id,mail_address';
     195    $query.= ' FROM '.PREFIX_TABLE.'users';
    221196    $query.= ';';
    222197    $result = mysql_query( $query );
  • trunk/admin/user_modify.php

    r10 r21  
    2121$tpl = array( 'adduser_info_message', 'adduser_info_back', 'adduser_fill_form',
    2222              'login', 'new', 'password', 'mail_address', 'adduser_status',
    23               'submit', 'adduser_info_password_updated' );
     23              'submit', 'adduser_info_password_updated','menu_groups',
     24              'dissociate','adduser_associate' );
    2425templatize_array( $tpl, 'lang', $sub );
    2526//--------------------------------------------------------- form criteria check
     
    3536$query.= ';';
    3637$row = mysql_fetch_array( mysql_query( $query ) );
    37 
     38$page['username'] = $row['username'];
     39$page['status'] = $row['status'];
     40$page['mail_address'] = $row['mail_address'];
    3841// user is not modifiable if :
    3942//   1. the selected user is the user "guest"
     
    6770                          $_POST['password'] ) );
    6871}
     72// association with groups management
     73if ( isset( $_POST['submit'] ) )
     74{
     75  // deletion of checked groups
     76  $query = 'SELECT id,name';
     77  $query.= ' FROM '.PREFIX_TABLE.'groups';
     78  $query.= ' ORDER BY id ASC';
     79  $query.= ';';
     80  $result = mysql_query( $query );
     81  while ( $row = mysql_fetch_array( $result ) )
     82  {
     83    $dissociate = 'dissociate-'.$row['id'];
     84    if ( $_POST[$dissociate] == 1 )
     85    {
     86      $query = 'DELETE FROM '.PREFIX_TABLE.'user_group';
     87      $query.= ' WHERE user_id = '.$_GET['user_id'];
     88      $query.= ' AND group_id ='.$row['id'];
     89      $query.= ';';
     90      mysql_query( $query );
     91    }
     92  }
     93  // create a new association between the user and a group
     94  $query = 'INSERT INTO '.PREFIX_TABLE.'user_group';
     95  $query.= ' (user_id,group_id) VALUES';
     96  $query.= ' ('.$_GET['user_id'].','.$_POST['associate'].')';
     97  $query.= ';';
     98  mysql_query( $query );
     99}
    69100//-------------------------------------------------------------- errors display
    70101if ( sizeof( $error ) != 0 )
     
    83114{
    84115  $vtp->addSession( $sub, 'confirmation' );
    85   $vtp->setVar( $sub, 'confirmation.username', $row['username'] );
     116  $vtp->setVar( $sub, 'confirmation.username', $page['username'] );
    86117  $url = add_session_id( './admin.php?page=user_list' );
    87118  $vtp->setVar( $sub, 'confirmation.url', $url );
     
    92123    $vtp->closeSession( $sub, 'password_updated' );
    93124  }
    94   $display_form = false;
    95125}
    96126//------------------------------------------------------------------------ form
     
    100130  $action = './admin.php?page=user_modify&amp;user_id='.$_GET['user_id'];
    101131  $vtp->setVar( $sub, 'form.form_action', add_session_id( $action ) );
    102   $vtp->setVar( $sub, 'form.user:username',     $row['username'] );
    103   $vtp->setVar( $sub, 'form.user:password',     $_POST['password'] );
    104   $vtp->setVar( $sub, 'form.user:mail_address', $_POST['mail_address'] );
    105 
    106   if ( !isset( $_POST['status'] ) )
    107   {
    108     $_POST['status'] = 'guest';
     132  $vtp->setVar( $sub, 'form.user:username',     $page['username'] );
     133  if ( isset( $_POST['mail_address'] ) )
     134  {
     135    $page['mail_address'] = $_POST['mail_address'];
     136  }
     137  $vtp->setVar( $sub, 'form.user:mail_address', $page['mail_address'] );
     138  if ( isset( $_POST['status'] ) )
     139  {
     140    $page['status'] = $_POST['status'];
    109141  }
    110142  $option = get_enums( PREFIX_TABLE.'users', 'status' );
     
    115147    $vtp->setVar( $sub, 'status_option.option',
    116148                  $lang['adduser_status_'.$option[$i]] );
    117     if( $option[$i] == $_POST['status'] )
     149    if( $option[$i] == $page['status'] )
    118150    {
    119151      $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' );
     
    121153    $vtp->closeSession( $sub, 'status_option' );
    122154  }
     155  // groups linked with this user
     156  $query = 'SELECT id,name';
     157  $query.= ' FROM '.PREFIX_TABLE.'user_group, '.PREFIX_TABLE.'groups';
     158  $query.= ' WHERE group_id = id';
     159  $query.= ' AND user_id = '.$_GET['user_id'];
     160  $query.= ';';
     161  $result = mysql_query( $query );
     162  $user_groups = array();
     163  if ( mysql_num_rows( $result ) > 0 )
     164  {
     165    $vtp->addSession( $sub, 'groups' );
     166    while ( $row = mysql_fetch_array( $result ) )
     167    {
     168      $vtp->addSession( $sub, 'group' );
     169      $vtp->setVar( $sub, 'group.name', $row['name'] );
     170      $vtp->setVar( $sub, 'group.dissociate_id', $row['id'] );
     171      $vtp->closeSession( $sub, 'group' );
     172      array_push( $user_groups, $row['id'] );
     173    }
     174    $vtp->closeSession( $sub, 'groups' );
     175  }
     176  // empty group not to take into account
     177  $vtp->addSession( $sub, 'associate_group' );
     178  $vtp->setVar( $sub, 'associate_group.value', 'undef' );
     179  $vtp->setVar( $sub, 'associate_group.option', '' );
     180  $vtp->closeSession( $sub, 'associate_group' );
     181  // groups not linked yet to the user
     182  $query = 'SELECT id,name';
     183  $query.= ' FROM '.PREFIX_TABLE.'groups';
     184  $query.= ' ORDER BY id ASC';
     185  $query.= ';';
     186  $result = mysql_query( $query );
     187  while ( $row = mysql_fetch_array( $result ) )
     188  {
     189    if ( !in_array( $row['id'], $user_groups ) )
     190    {
     191      $vtp->addSession( $sub, 'associate_group' );
     192      $vtp->setVar( $sub, 'associate_group.value', $row['id'] );
     193      $vtp->setVar( $sub, 'associate_group.option', $row['name'] );
     194      $vtp->closeSession( $sub, 'associate_group' );
     195    }
     196  }
     197
    123198  $url = add_session_id( './admin.php?page=user_list' );
    124199  $vtp->setVar( $sub, 'form.url_back', $url );
  • trunk/include/config.inc.php

    r20 r21  
    2121$lang = array();
    2222
    23 include_once( PREFIXE_INCLUDE.'./include/functions.inc.php' );
    24 include_once( PREFIXE_INCLUDE.'./include/vtemplate.class.php' );
     23include_once( PREFIX_INCLUDE.'./include/functions.inc.php' );
     24include_once( PREFIX_INCLUDE.'./include/vtemplate.class.php' );
    2525
    2626// How to change the order of display for images in a category ?
  • trunk/include/functions.inc.php

    r17 r21  
    1919include( 'functions_category.inc.php' );
    2020include( 'functions_xml.inc.php' );
     21include( 'functions_group.inc.php' );
    2122
    2223//----------------------------------------------------------- generic functions
     
    320321function database_connection()
    321322{
    322   // $cfgHote,$cfgUser,$cfgPassword,$cfgBase;
    323 
    324   $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' );
    325   $mysql_conf = getChild( $xml_content, 'mysql' );
    326 
    327   $cfgHote     = getAttribute( $mysql_conf, 'host' );
    328   $cfgUser     = getAttribute( $mysql_conf, 'user' );
    329   $cfgPassword = getAttribute( $mysql_conf, 'password' );
    330   $cfgBase     = getAttribute( $mysql_conf, 'base' );
     323//   $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' );
     324//   $mysql_conf = getChild( $xml_content, 'mysql' );
     325
     326//   $cfgHote     = getAttribute( $mysql_conf, 'host' );
     327//   $cfgUser     = getAttribute( $mysql_conf, 'user' );
     328//   $cfgPassword = getAttribute( $mysql_conf, 'password' );
     329//   $cfgBase     = getAttribute( $mysql_conf, 'base' );
     330//   define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) );
     331
     332  include( PREFIX_INCLUDE.'./include/mysql.inc.php' );
     333  define( PREFIX_TABLE, $prefix_table );
    331334
    332335  @mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
     
    334337  @mysql_select_db( $cfgBase )
    335338    or die ( "Could not connect to database" );
    336 
    337   define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) );
    338339}
    339340
  • trunk/include/functions_category.inc.php

    r19 r21  
    1515 *                                                                         *
    1616 ***************************************************************************/
     17
    1718function get_subcats_id( $cat_id )
    1819{
    19   $restricted_cat = array();
    20   $i = 0;
     20  $restricted_cats = array();
    2121               
    22   $query = 'select id';
    23   $query.= ' from '.PREFIX_TABLE.'categories';
    24   $query.= ' where id_uppercat = '.$cat_id;
     22  $query = 'SELECT id';
     23  $query.= ' FROM '.PREFIX_TABLE.'categories';
     24  $query.= ' WHERE id_uppercat = '.$cat_id;
    2525  $query.= ';';
    2626  $result = mysql_query( $query );
    2727  while ( $row = mysql_fetch_array( $result ) )
    2828  {
    29     $restricted_cat[$i++] = $row['id'];
    30     $sub_restricted_cat = get_subcats_id( $row['id'] );
    31     for ( $j = 0; $j < sizeof( $sub_restricted_cat ); $j++ )
    32     {
    33       $restricted_cat[$i++] = $sub_restricted_cat[$j];
    34     }
    35   }
    36                
    37   return $restricted_cat;
     29    array_push( $restricted_cats, $row['id'] );
     30    $sub_restricted_cats = get_subcats_id( $row['id'] );
     31    foreach ( $sub_restricted_cats as $sub_restricted_cat ) {
     32      array_push( $restricted_cats, $sub_restricted_cat );
     33    }
     34  }
     35  return $restricted_cats;
    3836}
    3937
  • trunk/include/functions_user.inc.php

    r16 r21  
    145145    mysql_query( $query );
    146146    // 3. retrieving the id of the newly created user
    147     $query = 'select id';
    148     $query.= ' from '.PREFIX_TABLE.'users';
    149     $query.= " where username = '".$login."';";
     147    $query = 'SELECT id';
     148    $query.= ' FROM '.PREFIX_TABLE.'users';
     149    $query.= " WHERE username = '".$login."';";
    150150    $row = mysql_fetch_array( mysql_query( $query ) );
    151151    $user_id = $row['id'];
    152     // 4. adding restrictions to the new user, the same as the user "guest"
    153     $query = 'select cat_id';
    154     $query.= ' from '.PREFIX_TABLE.'restrictions as r';
     152    // 4. adding access to the new user, the same as the user "guest"
     153    $query = 'SELECT cat_id';
     154    $query.= ' FROM '.PREFIX_TABLE.'user_access as ua';
    155155    $query.=      ','.PREFIX_TABLE.'users as u ';
    156     $query.= ' where u.id = r.user_id';
     156    $query.= ' where u.id = ua.user_id';
    157157    $query.= " and u.username = 'guest';";
    158158    $result = mysql_query( $query );
    159159    while( $row = mysql_fetch_array( $result ) )
    160160    {
    161       $query = 'insert into '.PREFIX_TABLE.'restrictions';
    162       $query.= ' (user_id,cat_id) values';
     161      $query = 'INSERT INTO '.PREFIX_TABLE.'user_access';
     162      $query.= ' (user_id,cat_id) VALUES';
    163163      $query.= ' ('.$user_id.','.$row['cat_id'].');';
    164164      mysql_query ( $query );
     
    182182  if ( sizeof( $error ) == 0 )
    183183  {
    184     $query = 'update '.PREFIX_TABLE.'users';
    185     $query.= " set status = '".$status."'";
     184    $query = 'UPDATE '.PREFIX_TABLE.'users';
     185    $query.= " SET status = '".$status."'";
    186186    if ( $use_new_password )
    187187    {
     
    197197      $query.= 'NULL';
    198198    }
    199     $query.= ' where id = '.$user_id;
     199    $query.= ' WHERE id = '.$user_id;
    200200    $query.= ';';
    201     echo $query;
    202201    mysql_query( $query );
    203202  }
     
    210209
    211210  if ( $user['is_the_guest']
    212        and ( $conf['acces'] == 'restreint' or $page['cat'] == 'fav' ) )
     211       and ( $conf['access'] == 'restricted' or $page['cat'] == 'fav' ) )
    213212  {
    214213    echo '<div style="text-align:center;">'.$lang['only_members'].'<br />';
     
    222221// If the $check_invisible parameter is set to true, invisible categories
    223222// are added to the restricted one in the array.
    224 function get_restrictions( $user_id, $user_status, $check_invisible )
    225 {
    226   // 1. getting the ids of the restricted categories
     223function get_restrictions( $user_id, $user_status,
     224                           $check_invisible, $use_groups = true )
     225{
     226  // 1. retrieving ids of private categories
     227  $query = 'SELECT id';
     228  $query.= ' FROM '.PREFIX_TABLE.'categories';
     229  $query.= " WHERE status = 'private'";
     230  $query.= ';';
     231  $result = mysql_query( $query );
     232  $privates = array();
     233  while ( $row = mysql_fetch_array( $result ) )
     234  {
     235    array_push( $privates, $row['id'] );
     236  }
     237  // 2. retrieving all authorized categories for the user
     238  $authorized = array();
     239  // 2.1. retrieving authorized categories thanks to personnal user
     240  //      authorization
    227241  $query = 'SELECT cat_id';
    228   $query.= ' FROM '.PREFIX_TABLE.'restrictions';
     242  $query.= ' FROM '.PREFIX_TABLE.'user_access';
    229243  $query.= ' WHERE user_id = '.$user_id;
    230244  $query.= ';';
    231245  $result = mysql_query( $query );
    232 
    233   $restriction = array();
    234246  while ( $row = mysql_fetch_array( $result ) )
    235247  {
    236     array_push( $restriction, $row['cat_id'] );
    237   }
     248    array_push( $authorized, $row['cat_id'] );
     249  }
     250  // 2.2. retrieving authorized categories thanks to group authorization to
     251  //      which the user is a member
     252  if ( $use_groups )
     253  {
     254    $query = 'SELECT ga.cat_id';
     255    $query.= ' FROM '.PREFIX_TABLE.'user_group as ug';
     256    $query.= ', '.PREFIX_TABLE.'group_access as ga';
     257    $query.= ' WHERE ug.group_id = ga.group_id';
     258    $query.= ' AND ug.user_id = '.$user_id;
     259    $query.= ';';
     260    $result = mysql_query( $query );
     261    while ( $row = mysql_fetch_array( $result ) )
     262    {
     263      array_push( $authorized, $row['cat_id'] );
     264    }
     265    $authorized = array_unique( $authorized );
     266  }
     267
     268  $forbidden = array();
     269  foreach ( $privates as $private ) {
     270    if ( !in_array( $private, $authorized ) )
     271    {
     272      array_push( $forbidden, $private );
     273    }
     274  }
     275
    238276  if ( $check_invisible )
    239277  {
    240     // 2. adding to the restricted categories, the invisible ones
     278    // 3. adding to the restricted categories, the invisible ones
    241279    if ( $user_status != 'admin' )
    242280    {
    243281      $query = 'SELECT id';
    244282      $query.= ' FROM '.PREFIX_TABLE.'categories';
    245       $query.= " WHERE status = 'invisible';";
     283      $query.= " WHERE visible = 'false';";
    246284      $result = mysql_query( $query );
    247285      while ( $row = mysql_fetch_array( $result ) )
    248286      {
    249         array_push( $restriction, $row['id'] );
    250       }
    251     }
    252   }
    253   return $restriction;
     287        array_push( $forbidden, $row['id'] );
     288      }
     289    }
     290  }
     291  return array_unique( $forbidden );
    254292}
    255293
     
    259297function get_all_restrictions( $user_id, $user_status )
    260298{
    261   $restricted_cat = get_restrictions( $user_id, $user_status, true );
    262   $i = sizeof( $restricted_cat );
    263   for ( $k = 0; $k < sizeof( $restricted_cat ); $k++ )
    264   {
    265     $sub_restricted_cat = get_subcats_id( $restricted_cat[$k] );
    266     for ( $j = 0; $j < sizeof( $sub_restricted_cat ); $j++ )
    267     {
    268       $restricted_cat[$i++] = $sub_restricted_cat[$j];
    269     }
    270   }
    271   return $restricted_cat;
     299  $restricted_cats = get_restrictions( $user_id, $user_status, true );
     300  foreach ( $restricted_cats as $restricted_cat ) {
     301    $sub_restricted_cats = get_subcats_id( $restricted_cat );
     302    foreach ( $sub_restricted_cats as $sub_restricted_cat ) {
     303      array_push( $restricted_cats, $sub_restricted_cat );
     304    }
     305  }
     306  return $restricted_cats;
    272307}
    273308
     
    278313function is_user_allowed( $category_id, $restrictions )
    279314{
    280   global $user;
    281                
    282315  $lowest_category_id = $category_id;
    283316               
     
    285318  while ( !$is_root and !in_array( $category_id, $restrictions ) )
    286319  {
    287     $query = 'select id_uppercat';
    288     $query.= ' from '.PREFIX_TABLE.'categories';
    289     $query.= ' where id = '.$category_id;
     320    $query = 'SELECT id_uppercat';
     321    $query.= ' FROM '.PREFIX_TABLE.'categories';
     322    $query.= ' WHERE id = '.$category_id;
    290323    $query.= ';';
    291324    $row = mysql_fetch_array( mysql_query( $query ) );
    292     if ( $row['id_uppercat'] == "" )
     325    if ( $row['id_uppercat'] == '' )
    293326    {
    294327      $is_root = true;
  • trunk/include/functions_xml.inc.php

    r13 r21  
    1919define( ATT_REG, '\w+' );
    2020define( VAL_REG, '[^"]*' );
    21 
    2221//------------------------------------------------------------------- functions
    2322// getContent returns the content of a tag
     
    3332  $content = preg_replace( '/^<[^>]+>/', '', $element );
    3433  // deleting end of the tag
    35   $content = preg_replace( '/<\/\w+>$/', '', $content );
     34  $content = preg_replace( '/<\/[^>]+>$/', '', $content );
    3635  // replacing multiple instance of space character
    3736  $content = preg_replace( '/\s+/', ' ', $content );
     
    4039}
    4140
    42 // The function get Attribute returns the value corresponding to the attribute
    43 // $attribute for the tag $element.
     41// The function get Attribute returns the value corresponding to the
     42// attribute $attribute for the tag $element.
    4443function getAttribute( $element, $attribute )
    4544{
  • trunk/include/init.inc.php

    r9 r21  
    1515 *                                                                         *
    1616 ***************************************************************************/
    17 define( PREFIXE_INCLUDE, '' );
    18        
     17define( PREFIX_INCLUDE, '' );
     18
    1919include_once( './include/config.inc.php' );
    2020include_once( './include/user.inc.php' );
  • trunk/include/user.inc.php

    r13 r21  
    2525                'long_period', 'template' );
    2626
    27 $query_user  = 'select';
     27$query_user  = 'SELECT';
    2828for ( $i = 0; $i < sizeof( $infos ); $i++ )
    2929{
     
    3838  $query_user.= $infos[$i];
    3939}
    40 $query_user.= ' from '.PREFIX_TABLE.'users';
     40$query_user.= ' FROM '.PREFIX_TABLE.'users';
    4141$query_done = false;
    4242$user['is_the_guest'] = false;
     
    4545{
    4646  $page['session_id'] = $_GET['id'];
    47   $query = 'select user_id,expiration,ip';
    48   $query.= ' from '.PREFIX_TABLE.'sessions';
    49   $query.= " where id = '".$_GET['id']."'";
     47  $query = 'SELECT user_id,expiration,ip';
     48  $query.= ' FROM '.PREFIX_TABLE.'sessions';
     49  $query.= " WHERE id = '".$_GET['id']."'";
    5050  $query.= ';';
    5151  $result = mysql_query( $query );
     
    5757      // deletion of the session from the database,
    5858      // because it is out-of-date
    59       $delete_query = 'delete from '.PREFIX_TABLE.'sessions';
    60       $delete_query.= " where id = '".$page['session_id']."'";
     59      $delete_query = 'DELETE FROM '.PREFIX_TABLE.'sessions';
     60      $delete_query.= " WHERE id = '".$page['session_id']."'";
    6161      $delete_query.= ';';
    6262      mysql_query( $delete_query );
     
    6666      if ( $_SERVER['REMOTE_ADDR'] == $row['ip'] )
    6767      {
    68         $query_user .= ' where id = '.$row['user_id'];
     68        $query_user .= ' WHERE id = '.$row['user_id'];
    6969        $query_done = true;
    7070      }
     
    7474if ( !$query_done )
    7575{
    76   $query_user .= ' where id = 2';
     76  $query_user .= ' WHERE id = 2';
    7777  $user['is_the_guest'] = true;
    7878}
     
    8383// affectation of each value retrieved in the users table into a variable
    8484// of the array $user.
    85 for ( $i = 0; $i < sizeof( $infos ); $i++ )
    86 {
    87   $user[$infos[$i]] = $row[$infos[$i]];
     85foreach ( $infos as $info ) {
     86  $user[$info] = $row[$info];
    8887  // If the field is true or false, the variable is transformed into a
    8988  // boolean value.
    90   if ( $row[$infos[$i]] == 'true' || $row[$infos[$i]] == 'false' )
     89  if ( $row[$info] == 'true' or $row[$info] == 'false' )
    9190  {
    92     $user[$infos[$i]] = get_boolean( $row[$infos[$i]] );
     91    $user[$info] = get_boolean( $row[$info] );
    9392  }
    9493}
  • trunk/include/vtemplate.class.php

    r2 r21  
    33 *                      VIRTUAL-TEMPLATE
    44 *
    5  * Version : 1.3.1 Base Edition ( Juillet 2002 ) build 6
     5 * Version : 1.3.2 Base Edition ( Decembre 2003 ) build 1
    66 *
    77 * Address : http://vtemplate.sourceforge.net
    88 *
    99 * Authors:
    10  *   + THIEBAUT Jean-Baptiste(J.Baptiste@leweby.com) - http://www.leweby.com .
     10 *   + THIEBAUT Jean-Baptiste(J.Baptiste@leweby.com)  - http://www.leweby.com .
    1111 *   + CAMPANA François (fc@netouaibe.com).
    1212 * Licence: GPL.
     13 *
     14 *
    1315 *
    14  *
     16 *                       
    1517 *****************************************************************/
    1618
    17 if ( !isset($DEFINE_VTEMPLATE) )
    18 {
    19   define("ALL",1);
    20   define("VARTAG","{#"); // Tag d'ouverture des variables :
    21                          //  vous pouvez changer ce paramètre.
    22   define("VTEMPLATE_VERSION","1.3.1");
    23   define("VTEMPLATE_TYPE","BA");
    24   define("VTEMPLATE_BUILD","6");
    25  
    26  
    27   class Err
    28     {
    29       var $msg;
    30       var $titre;
    31      
    32       function error( $errno, $arg = "", $code = 0, $disp = 0 )
    33         {
     19if ( !isset($DEFINE_VTEMPLATE) ){
     20define("ALL",1);
     21define("VARTAG","{#"); // Tag d'ouverture des variables : vous pouvez changer ce paramètre.
     22define("VTEMPLATE_VERSION","1.3.1");
     23define("VTEMPLATE_TYPE","BA");
     24define("VTEMPLATE_BUILD","6");
     25
     26
     27class Err {
     28var $msg;
     29var $titre;
     30
     31function error($errno,$arg="",$code=0,$disp=0){
    3432// Gestion des erreurs
    35           switch($errno)
    36           {
    37           case 1:
    38             $this->titre="Erreur de session n° $code";
    39             $this->msg = "La zone $arg est déjà ouverte.Avant d'ajouter une session sur cette zone, vous devez la fermer à l'aide de la fonction closeSession().<br>"   ;
    40             break;
    41           case 2:
    42             $this->titre="Erreur de session n° $code";
    43             $this->msg = "Vous tentez de fermer une session de la zone $arg alors qu'aucune session pour cette zone n'existe.Pour ouvrir une session, utilisez la fonction addSession().<br>";
    44             break;
    45           case 3:
    46             $this->titre="Erreur de session n° $code";
    47             $var = $arg[1];
    48             $zone = $arg[0];
    49             $this->msg = "Vous essayez de valoriser la variable $var sans avoir créer de session de la zone $zone.Utilisez la fonction addSession() pour créer une session, puis setVar pour valoriser une variable.<br>";
    50             break;
    51           case 4:
    52             $this->titre="Erreur de session n° $code";
    53             $var = $arg[1];
    54             $zone = $arg[0];
    55             $this->msg = "La variable $var que vous souhaitez valoriser n'existe pas dans la zone $zone.<br>";
    56             break;
    57           case 5:
    58             $this->titre="Erreur de parsing n° $code";
    59             $this->msg = "Vous utilisez des caractère non autorisés pour déclarer vos zones.Vous pouvez utiliser tous les caractères à l'exception de \'{\' , \'#\' \'}\' et \'|\'.<br>";
    60           break;
    61         case 6:
    62           $this->titre="Erreur de parsing n° $code";
    63           $this->msg = "Vous ne pouvez pas utiliser le même nom ($arg)de zone plusieurs fois.<br>";
    64           break;
    65         case 7:
    66           $this->titre="Erreur de parsing n° $code";
    67           $this->msg = "Vous avez oublié de fermer la zone $arg.<br>";
    68           break;
    69         case 8:
    70           $this->titre="Erreur de traitement n° $code";
    71           $this->msg = "Le fichier template $arg est introuvable.<br>";
    72           break;
    73         case 9:
    74           $this->titre="Erreur de traitement n° $code";
    75           $this->msg = "Impossible d'ouvrir le fichier $arg.Vérifiez les droits de ce fichier.<br>";
    76           break;
    77         case 10:
    78           $this->titre="Erreur de traitement n° $code";
    79           $this->msg = "Impossible de lire le fichier template $arg.<br>";     
    80           break;
    81         case 11:
    82           $this->titre="Erreur de traitement n° $code";
    83           $this->msg = "La zone $arg est introuvable.Vérifiez la syntaxe de cette zone.<br>";
    84           break;
    85         case 12: 
    86           $this->titre="Erreur de traitement n° $code";
    87           $this->msg = "La variable $arg est introuvable .Vérifiez la syntaxe de la variable.<br>";     
    88           break;
    89         case 13:
    90           $this->titre="Erreur de traitement n° $code";
    91           $this->msg = "L'identifiant de fichier spécifié n'existe pas.Vérifiez les fonctions Open() de votre script.<br>";
    92           break; 
    93         case 14:
    94           $this->titre="Erreur de traitement n° $code";
    95           $var = $arg[1];
    96           $file = $arg[0];
    97           $this->msg = "La variable $var dans le fichier $file est introuvable.Vérifiez la syntaxe de la variable.<br>";       
    98           break; 
    99         case 15:
    100           $this->titre="Erreur de traitement n° $code";
    101           $var = $arg[2];
    102           $zone = $arg[1];
    103           $fichier = $arg[0];
    104           $this->msg = "La variable $var dans la zone $zone du fichier $fichier est introuvable.Vérifiez la syntaxe de la variable et du nom de la zone.<br>"; 
    105           break;
    106         default:
    107           $this->titre = "Erreur inconnue $code";       
    108           $this->msg = "Veuillez le rapporter aux auteurs de la classe.";
    109         }
    110         $this->titre .= ": <br>";
    111         if ($disp){
    112           $web = "Pour plus d'informations, consultez la <a href=\"http://www.virtual-solution.net/vtemplate/docs/debug-mod.php?version=".VTEMPLATE_VERSION."&build=".VTEMPLATE_BUILD."&type=".VTEMPLATE_TYPE."&error=$code\" target=\"_blank\">doc en ligne</a>";
    113           echo "<font face=verdana size=2 color=red><u>$this->titre</u><i>$this->msg</i>$web<br><br></font>";
    114         }
    115         return -1;
    116       }
     33switch($errno){
     34  case 1:
     35    $this->titre="Erreur de session n° $code";
     36    $this->msg = "La zone $arg est déjà ouverte.Avant d'ajouter une session sur cette zone, vous devez la fermer à l'aide de la fonction closeSession().<br>"   ;
     37  break;
     38  case 2:
     39    $this->titre="Erreur de session n° $code";
     40    $this->msg = "Vous tentez de fermer une session de la zone $arg alors qu'aucune session pour cette zone n'existe.Pour ouvrir une session, utilisez la fonction addSession().<br>";
     41  break;
     42  case 3:
     43    $this->titre="Erreur de session n° $code";
     44        $var = $arg[1];
     45        $zone = $arg[0];
     46    $this->msg = "Vous essayez de valoriser la variable $var sans avoir créer de session de la zone $zone.Utilisez la fonction addSession() pour créer une session, puis setVar pour valoriser une variable.<br>";
     47  break;
     48  case 4:
     49    $this->titre="Erreur de session n° $code";
     50        $var = $arg[1];
     51        $zone = $arg[0];
     52    $this->msg = "La variable $var que vous souhaitez valoriser n'existe pas dans la zone $zone.<br>";
     53  break;
     54  case 5:
     55    $this->titre="Erreur de parsing n° $code";
     56    $this->msg = "Vous utilisez des caractère non autorisés pour déclarer vos zones.Vous pouvez utiliser tous les caractères à l'exception de \'{\' , \'#\' \'}\' et \'|\'.<br>";
     57  break;
     58  case 6:
     59    $this->titre="Erreur de parsing n° $code";
     60    $this->msg = "Vous ne pouvez pas utiliser le même nom ($arg)de zone plusieurs fois.<br>";
     61  break;
     62  case 7:
     63    $this->titre="Erreur de parsing n° $code";
     64    $this->msg = "Vous avez oublié de fermer la zone $arg.<br>";
     65  break;
     66  case 8:
     67    $this->titre="Erreur de traitement n° $code";
     68    $this->msg = "Le fichier template $arg est introuvable.<br>";
     69  break;
     70  case 9:
     71    $this->titre="Erreur de traitement n° $code";
     72    $this->msg = "Impossible d'ouvrir le fichier $arg.Vérifiez les droits de ce fichier.<br>";
     73  break;
     74  case 10:
     75    $this->titre="Erreur de traitement n° $code";
     76    $this->msg = "Impossible de lire le fichier template $arg.<br>";   
     77  break;
     78  case 11:
     79    $this->titre="Erreur de traitement n° $code";
     80    $this->msg = "La zone $arg est introuvable.Vérifiez la syntaxe de cette zone.<br>";
     81  break;
     82  case 12: 
     83    $this->titre="Erreur de traitement n° $code";
     84    $this->msg = "La variable $arg est introuvable .Vérifiez la syntaxe de la variable.<br>";   
     85  break;
     86  case 13:
     87    $this->titre="Erreur de traitement n° $code";
     88    $this->msg = "L'identifiant de fichier spécifié n'existe pas.Vérifiez les fonctions Open() de votre script.<br>";
     89  break; 
     90  case 14:
     91    $this->titre="Erreur de traitement n° $code";
     92        $var = $arg[1];
     93        $file = $arg[0];
     94    $this->msg = "La variable $var dans le fichier $file est introuvable.Vérifiez la syntaxe de la variable.<br>";     
     95  break; 
     96  case 15:
     97    $this->titre="Erreur de traitement n° $code";
     98        $var = $arg[2];
     99        $zone = $arg[1];
     100        $fichier = $arg[0];
     101    $this->msg = "La variable $var dans la zone $zone du fichier $fichier est introuvable.Vérifiez la syntaxe de la variable et du nom de la zone.<br>";       
     102  break;
     103  default:
     104         $this->titre = "Erreur inconnue $code";         
     105     $this->msg = "Veuillez le rapporter aux auteurs de la classe.";
     106}
     107$this->titre .= ": <br>";
     108if ($disp){
     109        $web = "Pour plus d'informations, consultez la <a href=\"http://www.virtual-solution.net/vtemplate/docs/debug-mod.php?version=".VTEMPLATE_VERSION."&build=".VTEMPLATE_BUILD."&type=".VTEMPLATE_TYPE."&error=$code\" target=\"_blank\">doc en ligne</a>";
     110        echo "<font face=verdana size=2 color=red><u>$this->titre</u><i>$this->msg</i>$web<br><br></font>";
     111}
     112return -1;
     113}
    117114// Fin classe
     115}
     116
     117class Session extends err{
     118
     119var $name;              // Name of the session
     120var $globalvar = array();  // List of global variable of the session
     121var $varlist = array();  // List of var in this session
     122var $subzone = array(); // list of sub-zone
     123var $temp; // Generated code for the current session
     124var $generated = NULL; // The final code
     125var $source; // Source code
     126var $used=0; // Indicates if the session contain used variable
     127var $stored; // Give the filename were is stored the session
     128
     129function Session($name,$source,$stored){
     130 $this->name = $name;
     131 $this->source = $source;
     132 $this->stored = $stored;
     133 $this->parseVar();
     134}
     135
     136function parseVar(){
     137 // Récupération des noms des variables
     138 $regle = "|".VARTAG."(.*)}|sU";
     139 preg_match_all ($regle,$this->source,$var1);
     140 // Création du tableau de variable  à partir de la liste parsée.
     141 $this->varlist=@array_merge($var[1],$var1[1]);
     142return 1;
     143}
     144
     145function init(){
     146if($this->used) return $this->error(1,array($this->stored,$this->name),"SESSION1",1);
     147// Reset generated code
     148$this->temp = $this->source;
     149$this->used = 1;
     150}
     151function closeSession(){
     152// Check if the zone has been used.   
     153if(!$this->used) return $this->error(2,array($this->stored,$this->name),"SESSION2",1);
     154// Set Globals vars.
     155$this->generateCode();
     156$this->used=0;
     157return 1;
     158}
     159
     160function reset(){
     161$this->used = 0;
     162$this->generated = NULL;
     163return 1;
     164}
     165
     166function addSubZone(&$subzone){
     167$this->subzone[$subzone->name] = &$subzone;
     168return 1;
     169}
     170
     171function setVar($varname,$value){
     172if (!$this->used) return $this->error(3,array($this->stored,$this->name,$varname),"SESSION3",1);
     173if (!in_array($varname,$this->varlist)) return $this->error(4,array($this->name,$varname),"SESSION4",1);
     174$regle = "(\\".VARTAG."$varname\})";
     175$this->temp = preg_replace($regle,$value,$this->temp);
     176return 1;
     177}
     178
     179function dispVar(){
     180 echo "Liste variables de $this->name:<br>";
     181 foreach ( $this->varlist as $vars )
     182    echo "$vars <br>";
     183}
     184
     185function setGlobalVar($varname,$value){
     186$set = 0;
     187if (in_array($varname,$this->varlist)){
     188  // Replace the var into this session
     189  $this->globalvar[$varname]=$value;   
     190  $set = 1;
     191}
     192  // Replace the var into sub zones
     193  foreach(array_keys($this->subzone) as $subzone){
     194      $set = $this->subzone[$subzone]->setGlobalVar($varname,$value) || $set;
     195  }
     196  return $set;
     197}
     198
     199function replaceGlobalVar(){
     200if ( count($this->globalvar) )
     201foreach($this->globalvar as $varname => $value){
     202  $regle = "(\\".VARTAG."$varname\})";
     203  $this->temp = preg_replace($regle,$value,$this->temp);
     204}
     205}
     206
     207
     208function generateCode(){
     209    if ($this->used == 0) return $this->generated;
     210    // Replace global var.
     211        if ( count($this->globalvar) ) $this->replaceGlobalVar();
     212        // Replace all unused variable by ""
     213    $regle = "|\\".VARTAG."([^}]*)\}|";
     214        $this->temp = preg_replace($regle,"",$this->temp);
     215        // Generate the subzone(s) code
     216        if(count($this->subzone)){
     217          foreach(array_keys($this->subzone) as $subzone){
     218                $text = ($this->subzone[$subzone]->used) ? $this->subzone[$subzone]->generateCode() : $this->subzone[$subzone]->generated;
     219                $this->temp = preg_replace("(\|$subzone\|)",$text,$this->temp);         
     220                $this->subzone[$subzone]->reset();
     221          }
    118222    }
    119 
    120   class Session extends err{
    121 
    122     var $name;          // Name of the session
    123     var $globalvar = array();  // List of global variable of the session
    124     var $varlist = array();  // List of var in this session
    125     var $subzone = array(); // list of sub-zone
    126     var $temp; // Generated code for the current session
    127     var $generated = NULL; // The final code
    128     var $source; // Source code
    129     var $used=0; // Indicates if the session contain used variable
    130     var $stored; // Give the filename were is stored the session
    131 
    132     function Session($name,$source,$stored){
    133       $this->name = $name;
    134       $this->source = $source;
    135       $this->stored = $stored;
    136       $this->parseVar();
    137     }
    138 
    139     function parseVar(){
    140       // Récupération des noms des variables
    141       $regle = "|".VARTAG."(.*)}|sU";
    142       preg_match_all ($regle,$this->source,$var1);
    143       // Création du tableau de variable  à partir de la liste parsée.
    144       $this->varlist=@array_merge($var[1],$var1[1]);
    145       return 1;
    146     }
    147 
    148     function init(){
    149       if($this->used) return $this->error(1,array($this->stored,$this->name),"SESSION1",1);
    150 // Reset generated code
    151       $this->temp = $this->source;
    152       $this->used = 1;
    153     }
    154     function closeSession(){
    155 // Check if the zone has been used.   
    156       if(!$this->used) return $this->error(2,array($this->stored,$this->name),"SESSION2",1);
    157 // Set Globals vars.
    158       $this->generateCode();
    159       $this->used=0;
    160       return 1;
    161     }
    162 
    163     function reset(){
    164       $this->used = 0;
    165       $this->generated = NULL;
    166       return 1;
    167     }
    168 
    169     function addSubZone(&$subzone){
    170       $this->subzone[$subzone->name] = &$subzone;
    171       return 1;
    172     }
    173 
    174     function setVar($varname,$value){
    175       if (!$this->used) return $this->error(3,array($this->stored,$this->name,$varname),"SESSION3",1);
    176       if (!in_array($varname,$this->varlist)) return $this->error(4,array($this->name,$varname),"SESSION4",1);
    177       $regle = "(\\".VARTAG."$varname\})";
    178       $this->temp = preg_replace($regle,$value,$this->temp);
    179       return 1;
    180     }
    181 
    182     function dispVar(){
    183       echo "Liste variables de $this->name:<br>";
    184       foreach ( $this->varlist as $vars )
    185         echo "$vars <br>";
    186     }
    187 
    188     function setGlobalVar($varname,$value){
    189       $set = 0;
    190       if (in_array($varname,$this->varlist)){
    191         // Replace the var into this session
    192         $this->globalvar[$varname]=$value;   
    193         $set = 1;
    194       }
    195       // Replace the var into sub zones
    196       foreach(array_keys($this->subzone) as $subzone){
    197         $set = $this->subzone[$subzone]->setGlobalVar($varname,$value) || $set;
    198       }
    199       return $set;
    200     }
    201 
    202     function replaceGlobalVar(){
    203       if ( count($this->globalvar) )
    204         foreach($this->globalvar as $varname => $value){
    205         $regle = "(\\".VARTAG."$varname\})";
    206         $this->temp = preg_replace($regle,$value,$this->temp);
    207       }
    208     }
    209 
    210 
    211     function generateCode(){
    212       if ($this->used == 0) return $this->generated;
    213       // Replace global var.
    214       if ( count($this->globalvar) ) $this->replaceGlobalVar();
    215       // Replace all unused variable by ""
    216       $regle = "|\\".VARTAG."(.*)\}|";
    217       $this->temp = preg_replace($regle,"",$this->temp);
    218       // Generate the subzone(s) code
    219       if(count($this->subzone)){
    220         foreach(array_keys($this->subzone) as $subzone){
    221           $text = ($this->subzone[$subzone]->used) ? $this->subzone[$subzone]->generateCode() : $this->subzone[$subzone]->generated;
    222           $this->temp = preg_replace("(\|$subzone\|)",$text,$this->temp);       
    223           $this->subzone[$subzone]->reset();
    224         }
    225       }
    226       $this->generated .= $this->temp;
    227       return $this->generated;
    228     }
    229 
    230     function inVarList($varname){
    231       return in_array($varname,$this->varlist);
    232     }
     223$this->generated .= $this->temp;
     224return $this->generated;
     225}
     226
     227function inVarList($varname){
     228return in_array($varname,$this->varlist);
     229}
    233230
    234231// Fin classe
    235   }
    236 
    237   class VTemplate_Private extends Err{
     232}
     233
     234class VTemplate_Private extends Err{
    238235/****************************************
    239  *         Private Class.               *
    240  * ***************************************/
    241 
    242     var $sources=array(); // Sources des zones issues de la premiere partie du parsing.
    243     var $sessions=array(); // Tableau de sessions
    244     var $v_global=array(); // Globla var array.
     236*          Private Class.               *
     237* ***************************************/
     238
     239var $sources=array(); // Sources des zones issues de la premiere partie du parsing.
     240var $sessions=array(); // Tableau de sessions
     241var $v_global=array(); // Globla var array.
    245242
    246243/****************************************************************
    247244            Parsing Functions for Template files.  ( PF 1.0 )
    248 ****************************************************************/
    249 
    250     function getNom($code){
     245 ****************************************************************/
     246
     247function getNom($code){
    251248// Retourne le premier nom de zone qu'il trouve dans le code
    252249
    253       preg_match("(<!--VTP_([^()]+)-->)sU",$code,$reg);
     250   preg_match("(<!--VTP_([^()]+)-->)sU",$code,$reg);
    254251   
    255       // Tester la présence des caratère invalides dans le nom ( | et {});
    256       if (@count(explode("|",$reg[1]))>1 || @count(explode("{",$reg[1]))>1 || @count(explode("}",$reg[1]))>1) exit($this->error(5,$reg[1],"PARSE1",1));
     252   // Tester la présence des caratère invalides dans le nom ( | et {});
     253   if (@count(explode("|",$reg[1]))>1 || @count(explode("{",$reg[1]))>1 || @count(explode("}",$reg[1]))>1) exit($this->error(5,$reg[1],"PARSE1",1));
    257254   
    258       return @$reg[1];
    259     }
    260 
    261     function endTag($code,$nom){
     255   return @$reg[1];
     256}
     257
     258function endTag($code,$nom){
    262259// Renvoie TRUE(1) si le tag de fermeture est présent.
    263260
    264       preg_match("(<!--/VTP_$nom-->)sU",$code,$reg);
    265 
    266       return ($reg[0]!="<!--/VTP_$nom-->") ? 0 : 1;
    267     }
    268 
    269     function getSource($code,$nom,$type=0){
     261   preg_match("(<!--/VTP_$nom-->)sU",$code,$reg);
     262
     263return ($reg[0]!="<!--/VTP_$nom-->") ? 0 : 1;
     264}
     265
     266function getSource($code,$nom,$type=0){
    270267// Retourne le source de la zone de nom $nom
    271268
    272       preg_match_all ("(<!--VTP_$nom-->(.*)<!--/VTP_$nom-->)sU",$code,$reg);
    273 
    274       return $reg[$type][0];
    275     }
    276 
    277     function parseZone($code_source,$nom_zone="|root|"){
     269   preg_match_all ("(<!--VTP_$nom-->(.*)<!--/VTP_$nom-->)sU",$code,$reg);
     270
     271return $reg[$type][0];
     272}
     273
     274function parseZone($code_source,$nom_zone="|root|"){
    278275// Fonction récursive de parsing du fichier template
    279       // Vérification que la zone n'existe pas
    280       if (isset($this->sources[$nom_zone])) exit($this->error(6,$nom_zone,"PARSE2",1));
    281 
    282       // Enregistrement du code source
    283       $this->sources[$nom_zone]["source"]=$code_source;
    284 
    285       // Rappel de la fonction pour chaque fils.
    286       while($nom_fils=$this->getNom($this->sources[$nom_zone]["source"])){
    287 
    288         // Vérification que le tag de fin est présent.
    289         if (!$this->endTag($code_source,$nom_fils)) exit($this->error(7,$nom_fils,"PARSE3",1));
    290 
    291         // Parse le fils
    292         $this->parseZone($this->getSource($this->sources[$nom_zone]["source"],$nom_fils,1),$nom_fils);
    293 
    294         // Enregistre le nom du fils dans la liste des fils
    295         $this->sources[$nom_zone]["fils"][]=$nom_fils;
    296 
    297         // Remplace le code du fils dans le source du père
    298         $this->sources[$nom_zone]["source"]=str_replace(
    299           $this->getSource($this->sources[$nom_zone]["source"],$nom_fils,0),
    300           "|$nom_fils|",
    301           $this->sources[$nom_zone]["source"]
    302           );
    303         // Teste si la zone $nom_fils n'existe pas plusieurs fois dans la zone $nom_zone
    304         if (count(explode("|$nom_fils|",$this->sources[$nom_zone]["source"]))>2) exit($this->error(6,$nom_fils,"PARSE4",1));
    305       }// fin While
    306 
    307       return 1;
    308     }
     276   // Vérification que la zone n'existe pas
     277   if (isset($this->sources[$nom_zone])) exit($this->error(6,$nom_zone,"PARSE2",1));
     278
     279   // Enregistrement du code source
     280   $this->sources[$nom_zone]["source"]=$code_source;
     281
     282   // Rappel de la fonction pour chaque fils.
     283   while($nom_fils=$this->getNom($this->sources[$nom_zone]["source"])){
     284
     285     // Vérification que le tag de fin est présent.
     286     if (!$this->endTag($code_source,$nom_fils)) exit($this->error(7,$nom_fils,"PARSE3",1));
     287
     288     // Parse le fils
     289     $this->parseZone($this->getSource($this->sources[$nom_zone]["source"],$nom_fils,1),$nom_fils);
     290
     291     // Enregistre le nom du fils dans la liste des fils
     292     $this->sources[$nom_zone]["fils"][]=$nom_fils;
     293
     294     // Remplace le code du fils dans le source du père
     295     $this->sources[$nom_zone]["source"]=str_replace(
     296                                     $this->getSource($this->sources[$nom_zone]["source"],$nom_fils,0),
     297                                     "|$nom_fils|",
     298                                     $this->sources[$nom_zone]["source"]
     299                                     );
     300     // Teste si la zone $nom_fils n'existe pas plusieurs fois dans la zone $nom_zone
     301     if (count(explode("|$nom_fils|",$this->sources[$nom_zone]["source"]))>2) exit($this->error(6,$nom_fils,"PARSE4",1));
     302   }// fin While
     303
     304return 1;
     305}
    309306
    310307/****************************************************************
    311308            Session Management functions ( SMF 1.0 )
    312 ****************************************************************/
    313 
    314     function createSession($handle,$zone = "|root|"){
     309 ****************************************************************/
     310
     311function createSession($handle,$zone = "|root|"){
    315312// Create a new session of the zone
    316       $this->sessions[$handle][$zone] = new Session($zone,$this->sources[$zone]["source"],$this->file_name[$handle]);
     313$this->sessions[$handle][$zone] = new Session($zone,$this->sources[$zone]["source"],$this->file_name[$handle]);
    317314
    318315// Create sub-zone
    319       if (@count($this->sources[$zone]["fils"])){
    320         foreach($this->sources[$zone]["fils"] as $subzone){       
    321           $this->createSession($handle,$subzone);
    322           $this->sessions[$handle][$zone]->addSubZone($this->sessions[$handle][$subzone]);
    323         }
    324       }
     316if (@count($this->sources[$zone]["fils"])){
     317   foreach($this->sources[$zone]["fils"] as $subzone){   
     318    $this->createSession($handle,$subzone);
     319    $this->sessions[$handle][$zone]->addSubZone($this->sessions[$handle][$subzone]);
     320   }
     321}
    325322                                 
    326323//end createSession
    327     }
     324}
    328325
    329326
    330327/****************************************************************
    331328            Global Variable Management Functions ( GVMF 1.0 )
    332 ****************************************************************/
    333 
    334     function setGZone($handle,$zone,$var,$value){
    335       // Define Global var for $zone and its sub-zone.
    336       // Set global value to $zone vars.
    337       return $this->sessions[$handle][$zone]->setGlobalVar($var,$value);
    338     }
    339 
    340     function setGFile($handle,$var,$value) {
    341       return $this->sessions[$handle]["|root|"]->setGlobalVar($var,$value);
    342     }
    343 
    344     function setGAll($var,$value){
    345       $declare = 0;
    346       $this->v_global[$var]=$value;
    347       if (is_array($this->sessions)){
    348         foreach($this->sessions as $handle => $v){
    349           $declare = $this->setGFile($handle,$var,$value) || $declare;
    350         }       
    351       }
    352       return $declare;
    353     }
    354 
    355     function setGOpened($handle){
     329 ****************************************************************/
     330
     331 function setGZone($handle,$zone,$var,$value){
     332 // Define Global var for $zone and its sub-zone.
     333   // Set global value to $zone vars.
     334  return $this->sessions[$handle][$zone]->setGlobalVar($var,$value);
     335}
     336
     337function setGFile($handle,$var,$value) {
     338  return $this->sessions[$handle]["|root|"]->setGlobalVar($var,$value);
     339}
     340
     341function setGAll($var,$value){
     342$declare = 0;
     343$this->v_global[$var]=$value;
     344if (is_array($this->sessions)){
     345    foreach($this->sessions as $handle => $v){
     346                $declare = $this->setGFile($handle,$var,$value) || $declare;
     347                }       
     348  }
     349return $declare;
     350}
     351
     352function setGOpened($handle){
    356353// Set Global var into the opened file
    357       foreach($this->v_global as $name => $val){
    358         $this->setGFile($handle,$name,$val);
    359       }
    360       return 1;
    361     }
     354foreach($this->v_global as $name => $val){
     355  $this->setGFile($handle,$name,$val);
     356}
     357return 1;
     358}
    362359 
    363360// Fin VTemplate_Private
    364   }
    365 
    366 
    367   class VTemplate extends VTemplate_Private{
     361}
     362
     363
     364class VTemplate extends VTemplate_Private{
    368365/****************************************
    369  *         Public Class.                *
    370  * ***************************************/
     366*          Public Class.                *
     367* ***************************************/
    371368
    372369
     
    376373
    377374
    378     function Open($nomfichier){
     375function Open($nomfichier){
    379376// Ouverture d'un fichier source et retourne le handle de ce fichier
    380377// Création du handle:
    381       $handle =  "{".count($this->sessions)."}" ;
     378$handle =  "{".count($this->sessions)."}" ;
    382379
    383380
    384381// Récupération du source à parser
    385       if (!@file_exists($nomfichier)) return $this->error(8,$nomfichier,"TTT1",1);
    386       if (!$f_id=@fopen($nomfichier,"r")) return $this->error(9,$nomfichier,"TTT2",1);
    387       if (!$source=@fread($f_id, filesize($nomfichier))) return $this->error(10,$nomfichier,"TTT3",1);
    388       clearstatcache();
    389       fclose($f_id);
     382if (!@file_exists($nomfichier)) return $this->error(8,$nomfichier,"TTT1",1);
     383if (!$f_id=@fopen($nomfichier,"r")) return $this->error(9,$nomfichier,"TTT2",1);
     384if (!$source=@fread($f_id, filesize($nomfichier))) return $this->error(10,$nomfichier,"TTT3",1);
     385clearstatcache();
     386fclose($f_id);
    390387
    391388// Store the filename
    392       $this->file_name[$handle]=$nomfichier;
     389$this->file_name[$handle]=$nomfichier;
    393390
    394391// Parse les zones
    395       $this->parseZone($source);
     392$this->parseZone($source);
    396393
    397394// Création du tableau de session
    398       $this->createSession($handle);
     395$this->createSession($handle);
    399396
    400397//Nettoyage des variables temporaires
    401       $this->sources=NULL;
     398$this->sources=NULL;
    402399
    403400// Set global var.
    404       $this->setGOpened($handle);
    405 
    406       $this->addSession($handle);
    407       return $handle;
    408     }
    409 
    410     function newSession($handle="{0}",$nom_zone = "|root|"){
    411       if ( $this->sessions[$handle][$nom_zone]->used ) $this->closeSession($handle,$nom_zone);
    412       $this->addSession($handle,$nom_zone,$cache,$time,$num_session);
    413       return 1;
    414     }
    415 
    416     function addSession($handle="{0}",$nom_zone = "|root|"){
    417       // Does the zone exist ?
    418       if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT4",1);   
    419       $this->sessions[$handle][$nom_zone]->init();
    420       return 1;
    421     }
    422 
    423     function closeSession($handle="{0}",$nom_zone = "|root|"){
     401$this->setGOpened($handle);
     402
     403$this->addSession($handle);
     404return $handle;
     405}
     406
     407function newSession($handle="{0}",$nom_zone = "|root|"){
     408if ( $this->sessions[$handle][$nom_zone]->used ) $this->closeSession($handle,$nom_zone);
     409$this->addSession($handle,$nom_zone,$cache,$time,$num_session);
     410return 1;
     411}
     412
     413function addSession($handle="{0}",$nom_zone = "|root|"){
     414        // Does the zone exist ?
     415   if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT4",1);   
     416   $this->sessions[$handle][$nom_zone]->init();
     417   return 1;
     418}
     419
     420function closeSession($handle="{0}",$nom_zone = "|root|"){
    424421// Close the current session and all his sub-session
    425       // Check if the zone exists.
    426       if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT5",1);
    427       // Closing sub-zone
    428       $this->sessions[$handle][$nom_zone]->closeSession();     
    429       return 1;
    430     }
    431 
    432     function setGlobalVar($arg1,$arg2,$arg3){
    433       if ($arg1 == 1){
    434         if (!$this->setGAll($arg2,$arg3)) return $this->error(12,$arg2,"TTT6",1);
    435         return 1;
    436       }
    437       if (!isset($this->sessions[$arg1])) return $this->error(13,$arg1,"TTT7",1);
    438       $tab=explode(".",$arg2);
    439       if (count($tab)==1){
    440         if (!$this->setGFile($arg1,$arg2,$arg3)) return $this->error(14,array($this->file_name[$arg1],$arg2),"TTT8",1);
    441       }
    442       else if (count($tab==2)){
    443         if (!isset($this->sessions[$arg1][$tab[0]])) return $this->error(11,array($tab[0],$this->file_name[$arg1],"TTT9",1));
    444         if (!$this->setGZone($arg1,$tab[0],$tab[1],$arg3)) return $this->error(15,array($this->file_name[$arg1],$tab[0],$tab[1]),"TTT10",1);
    445       }
    446       return 1;
    447     }
    448 
    449     function setVar($handle,$zone_var,$val){
    450       // Fill the variable
    451       $tab=explode(".",$zone_var);
    452       if(count($tab)==2){
    453         $zone=$tab[0];
    454         $var=$tab[1];
    455       }
    456       else
    457       {
    458         $zone="|root|";
    459         $var=$tab[0];
    460       }
    461 
    462       // Teste l'existence de la zone dans la liste
    463       if (!isset($this->sessions[$handle][$zone])) return $this->error(11,array($this->file_name[$handle],$zone),"TTT11",1);
    464 
    465       //Enregistre la variable
    466       return $this->sessions[$handle][$zone]->setVar($var,$val);
    467     }
    468 
    469     function Parse($handle_dest,$zone_var_dest,$handle_source,$zone_source="|root|"){
    470       if($this->sessions[$handle_source][$zone_source]->used == 1) $this->closeSession($handle_source,$zone_source);
    471       $this->setVar($handle_dest,$zone_var_dest, $this->sessions[$handle_source][$zone_source]->generated);
    472     }
    473 
    474     function setVarF($handle,$zone_var,$file){
     422          // Check if the zone exists.
     423        if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT5",1);
     424     // Closing sub-zone
     425     $this->sessions[$handle][$nom_zone]->closeSession();       
     426   return 1;
     427}
     428
     429function setGlobalVar($arg1,$arg2,$arg3){
     430if ($arg1 == 1){
     431  if (!$this->setGAll($arg2,$arg3)) return $this->error(12,$arg2,"TTT6",1);
     432  return 1;
     433}
     434if (!isset($this->sessions[$arg1])) return $this->error(13,$arg1,"TTT7",1);
     435 $tab=explode(".",$arg2);
     436 if (count($tab)==1){
     437    if (!$this->setGFile($arg1,$arg2,$arg3)) return $this->error(14,array($this->file_name[$arg1],$arg2),"TTT8",1);
     438 }
     439 else if (count($tab==2)){
     440    if (!isset($this->sessions[$arg1][$tab[0]])) return $this->error(11,array($tab[0],$this->file_name[$arg1],"TTT9",1));
     441    if (!$this->setGZone($arg1,$tab[0],$tab[1],$arg3)) return $this->error(15,array($this->file_name[$arg1],$tab[0],$tab[1]),"TTT10",1);
     442 }
     443return 1;
     444}
     445
     446function setVar($handle,$zone_var,$val){
     447 // Fill the variable
     448$tab=explode(".",$zone_var);
     449 if(count($tab)==2){
     450   $zone=$tab[0];
     451   $var=$tab[1];
     452 }
     453 else
     454 {
     455  $zone="|root|";
     456  $var=$tab[0];
     457 }
     458
     459 // Teste l'existence de la zone dans la liste
     460 if (!isset($this->sessions[$handle][$zone])) return $this->error(11,array($this->file_name[$handle],$zone),"TTT11",1);
     461
     462 //Enregistre la variable
     463 return $this->sessions[$handle][$zone]->setVar($var,$val);
     464}
     465
     466function Parse($handle_dest,$zone_var_dest,$handle_source,$zone_source="|root|"){
     467        if($this->sessions[$handle_source][$zone_source]->used == 1) $this->closeSession($handle_source,$zone_source);
     468          $this->setVar($handle_dest,$zone_var_dest, $this->sessions[$handle_source][$zone_source]->generated);
     469}
     470
     471function setVarF($handle,$zone_var,$file){
    475472// Fonction qui ouvre le fichier file et copie ce qu'il y a dedans dans une variable.
    476       $tab=explode(".",$zone_var);
     473$tab=explode(".",$zone_var);
    477474
    478475// Récupération nom de la zone et de la variable.
    479       if(count($tab)==2){
    480         $zone=$tab[0];
    481         $var=$tab[1];
    482       }
    483       else
    484       {
    485         $zone="|root|";
    486         $var=$tab[0];
    487       }
     476 if(count($tab)==2){
     477   $zone=$tab[0];
     478   $var=$tab[1];
     479 }
     480 else
     481 {
     482  $zone="|root|";
     483  $var=$tab[0];
     484 }
    488485// Teste l'existence de la zone dans la liste
    489       if (!is_object($this->sessions[$handle][$zone])) return $this->error(11,array($handle,$zone),"TTT12",1);
    490 
    491       // Récupération du source à lire
    492       if (!@file_exists($file)) return $this->error(8,$file,"TTT13",1);
    493       if (!$f_id=@fopen($file,"r")) return $this->error(9,$file,"TTT14",1);
    494       if (!$val=@fread($f_id, filesize($file))) return $this->error(10,$file,"TTT15",1);
    495       clearstatcache();
    496       fclose($f_id);
     486 if (!is_object($this->sessions[$handle][$zone])) return $this->error(11,array($handle,$zone),"TTT12",1);
     487
     488 // Récupération du source à lire
     489if (!@file_exists($file)) return $this->error(8,$file,"TTT13",1);
     490if (!$f_id=@fopen($file,"r")) return $this->error(9,$file,"TTT14",1);
     491if (!$val=@fread($f_id, filesize($file))) return $this->error(10,$file,"TTT15",1);
     492clearstatcache();
     493fclose($f_id);
    497494
    498495//Enregistre la variable
    499       return $this->sessions[$handle][$zone]->setVar($var,$val);
    500     }
    501 
    502     function isZone($handle, $zone="|root|")
    503       {
    504         return isset($this->sessions[$handle][$zone]) ;
    505       }
    506 
    507     function Display($handle="{0}",$display=1,$zone="|root|"){
    508       $this->closeSession($handle,$zone);
    509       $c_genere = $this->sessions[$handle][$zone]->generated;
     496return $this->sessions[$handle][$zone]->setVar($var,$val);
     497}
     498
     499
     500
     501
     502
     503function isZone($handle, $zone="|root|")
     504{
     505return isset($this->sessions[$handle][$zone]) ;
     506}
     507
     508function Display($handle="{0}",$display=1,$zone="|root|"){
     509        $this->closeSession($handle,$zone);
     510        $c_genere = $this->sessions[$handle][$zone]->generated;
    510511       
    511       if ($display) echo $c_genere; else return ($c_genere);
    512     }
     512        if ($display) echo $c_genere; else return ($c_genere);
     513}
     514//fonction complementaire version BETA
     515
     516/*
     517*
     518On peut l'utiliser :
     519- SetVarTab($array): tout les couples clef/valeur sont valorisées
     520- SetVarTab($array,$index) seuls les couples clef/valeur dont la clef est dans le tableau index ou dont la valeur == $index (si pas tableau)
     521Si $index contient ou est une clef de type zone.clef, la clef sera extraite du texte est servira d'index pour $array
     522
     523Vincent
     524*/
     525
     526function setVarTab($handle,$zones,$index = array()){
     527        if (is_array($index))
     528        {
     529                if (count($index)>0)
     530                {
     531                        reset($index);
     532                        while (list (, $key) = each ($index))
     533                        {
     534                                $tab=explode(".",$key);
     535                                if(count($tab)==2){
     536                                        $var=$tab[1];
     537                                }
     538                                else
     539                                {
     540                                        $var=$tab[0];
     541                                }
     542                                setVar($handle,$key,$zones[$var]);
     543                        }
     544                }
     545                else
     546                {
     547                        reset($zones);
     548                        while (list ($key, $val) = each ($zones))
     549                        {
     550                                setVar($handle,$key,$val);
     551                        }
     552                }
     553        }
     554        else
     555        {
     556                setVar($handle,$index,$zones[$index]);
     557        }
     558}
     559
     560function setGlobalVarTab($handle,$zones,$index = array()){
     561
     562        if (is_array($index))
     563        {
     564                if (count($index)>0)
     565                {
     566                        reset($index);
     567                        while (list (, $key) = each ($index))
     568                        {
     569                                $tab=explode(".",$key);
     570                                if(count($tab)==2){
     571                                        $var=$tab[1];
     572                                }
     573                                else
     574                                {
     575                                        $var=$tab[0];
     576                                }
     577                                setGlobalVar($handle,$key,$zones[$var]);
     578                        }
     579                }
     580                else
     581                {
     582                        reset($zones);
     583                        while (list ($key, $val) = each ($zones))
     584                        {
     585                                GlobalVar($handle,$key,$val);
     586                        }
     587                }
     588        }
     589        else
     590        {
     591                setBlobalVar($handle,$index,$zones[$index]);
     592        }
     593}
     594
     595
     596
     597
    513598
    514599
    515600// End VTemplate
    516   }
    517   $DEFINE_VTEMPLATE = 1;
     601}
     602$DEFINE_VTEMPLATE = 1;
    518603}
    519604?>
  • trunk/index.php

    r10 r21  
    11<?php
    2 include_once( './include/mysql.inc.php' );
     2define( PREFIX_INCLUDE, '' );
    33include_once( './include/functions.inc.php' );
    44database_connection();
    5 // récupération des informations de configuration du site
    6 $query  = 'select acces ';
    7 $query .= 'from '.PREFIX_TABLE.'config;';
     5// retrieving configuration informations
     6$query = 'SELECT access';
     7$query.= ' FROM '.PREFIX_TABLE.'config;';
    88$row = mysql_fetch_array( mysql_query( $query ) );
    9 $url = 'category';
    10 if ( $row['acces'] == 'restreint' )
    11 {
    12   $url = 'identification';
    13 }
     9if ( $row['access'] == 'restricted' ) $url = 'identification';
     10else                                  $url = 'category';
    1411// redirection
    1512$url.= '.php';
  • trunk/language/francais.php

    r20 r21  
    1616$lang['guest'] = 'visiteur';
    1717$lang['mail_address'] = 'adresse mail';
     18$lang['public'] = 'publique';
     19$lang['private'] = 'privée';
     20$lang['add'] = 'ajouter';
     21$lang['dissociate'] = 'dissocier';
    1822// end version 1.3
    1923
     
    219223  $lang['title_add'] = 'Ajouter un utilisateur';
    220224  $lang['title_modify'] = 'Modifier un utilisateur';
     225  $lang['title_groups'] = 'Gestion des groupes';
    221226// end version 1.3
    222227  $lang['title_liste_users'] = 'Liste des utilisateurs';
     
    225230  $lang['title_configuration'] = 'Configuration de PhpWebGallery';
    226231  $lang['title_instructions'] = 'Instructions';
    227   $lang['title_permissions'] = 'Modifier les permissions pour un utilisateur';
     232// start version 1.3
     233// $lang['title_permissions'] = 'Modifier les permissions pour un utilisateur';
     234  $lang['title_user_perm'] = 'Modifier les permissions pour l\'utilisateur';
     235  $lang['title_cat_perm'] = 'Modifier les permissions pour la catégorie';
     236  $lang['title_group_perm'] = 'Modifier les permissions pour le groupe';
     237// end version 1.3
    228238  $lang['title_categories'] = 'Gestion des catégories';
    229239  $lang['title_edit_cat'] = 'Editer une catégorie';
     
    232242  $lang['title_thumbnails_2'] = 'pour';
    233243  $lang['title_default'] = 'Administration de PhpWebGallery';
    234                
     244       
    235245  $lang['menu_title'] = 'Administration';
    236246  $lang['menu_config'] = 'Configuration';
     
    244254  $lang['menu_instructions'] = 'Instructions';
    245255  $lang['menu_back'] = 'Page diapo';
    246 
     256// start version 1.3
     257  $lang['menu_groups'] = 'Groupes';
     258// end version 1.3
     259 
    247260  $lang['title_waiting'] = 'Images en attente de validation';
    248261  $lang['menu_waiting'] = 'En attente';
     
    384397// start version 1.3
    385398//  $lang['adduser_status_member'] = 'membre';
     399  $lang['adduser_associate'] = 'Associer au groupe';
    386400// end version 1.3
    387401  $lang['adduser_status_guest'] = 'visiteur';
    388                
     402
     403// start version 1.3
     404  $lang['group_add'] = 'Ajouter un groupe';
     405  $lang['group_add_error1'] = 'Le nom du groupe ne doit pas comporter de " ou de \'';
     406  $lang['group_add_error2'] = 'Ce nom de groupe est déjà utilisé';
     407  $lang['group_confirm'] = 'Etes-vous sûr de vouloir supprimer le groupe';
     408  $lang['group_list_title'] = 'Liste des groupes existants';
     409  $lang['group_err_unknown'] = 'Ce groupe n\'existe pas dans la base de données';
     410// end version 1.3
     411
    389412  // page permissions
    390413  $lang['permuser_info_message'] = 'Permissions enregistrées';
     
    394417  $lang['permuser_forbidden'] = 'interdit';
    395418  $lang['permuser_parent_forbidden'] = 'catégorie parente interdite';
    396   $lang['permuser_cat_title'] = 'Modifier les permissions pour ';
     419// start version 1.3
     420// $lang['permuser_cat_title'] = 'Modifier les permissions pour ';
     421// end version 1.3
    397422               
    398423  // page liste utilisateurs
     
    434459  $lang['editcat_status'] = 'Status';
    435460  $lang['editcat_status_info'] = '(invisible sauf pour les administrateurs)';
    436                
     461// start version 1.3
     462  $lang['editcat_visible'] = 'Visible';
     463// end version 1.3
    437464  // page info images
    438465  $lang['infoimage_err_date'] = 'date erronée';
  • trunk/picture.php

    r19 r21  
    2929}
    3030//---------------------------------------- incrementation of the number of hits
    31 $query = 'update '.PREFIX_TABLE.'images';
    32 $query.= ' set hit=hit+1';
    33 $query.= ' where id='.$_GET['image_id'];
     31$query = 'UPDATE '.PREFIX_TABLE.'images';
     32$query.= ' SET hit=hit+1';
     33$query.= ' WHERE id='.$_GET['image_id'];
    3434$query.= ';';
    3535@mysql_query( $query );
     
    3838$cat_directory = $page['cat_dir']; // by default
    3939//------------------------------------- main picture information initialization
    40 $query = 'select id,date_available,comment,hit';
     40$query = 'SELECT id,date_available,comment,hit';
    4141$query.= ',author,name,file,date_creation,filesize,width,height,cat_id';
    42 $query.= ' from '.PREFIX_TABLE.'images';
     42$query.= ' FROM '.PREFIX_TABLE.'images';
    4343$query.= $page['where'];
    44 $query.= ' and id = '.$_GET['image_id'];
     44$query.= ' AND id = '.$_GET['image_id'];
    4545$query.= $conf['order_by'];
    4646$query.= ';';
     
    6060$page['cat_id']         = $row['cat_id'];
    6161// retrieving the number of the picture in its category (in order)
    62 $query = 'select id';
    63 $query.= ' from '.PREFIX_TABLE.'images';
     62$query = 'SELECT id';
     63$query.= ' FROM '.PREFIX_TABLE.'images';
    6464$query.= $page['where'];
    6565$query.= $conf['order_by'];
     
    7979  {
    8080    // verify if the picture is already in the favorite of the user
    81     $query = 'select count(*) as nb_fav';
    82     $query.= ' from '.PREFIX_TABLE.'favorites';
    83     $query.= ' where image_id = '.$page['id'];
    84     $query.= ' and user_id = '.$user['id'];
     81    $query = 'SELECT COUNT(*) AS nb_fav';
     82    $query.= ' FROM '.PREFIX_TABLE.'favorites';
     83    $query.= ' WHERE image_id = '.$page['id'];
     84    $query.= ' AND user_id = '.$user['id'];
    8585    $query.= ';';
    8686    $result = mysql_query( $query );
     
    8888    if ( $row['nb_fav'] == 0 )
    8989    {
    90       $query = 'insert into '.PREFIX_TABLE.'favorites';
    91       $query.= ' (image_id,user_id) values';
     90      $query = 'INSERT INTO '.PREFIX_TABLE.'favorites';
     91      $query.= ' (image_id,user_id) VALUES';
    9292      $query.= ' ('.$page['id'].','.$user['id'].')';
    9393      $query.= ';';
     
    9797  if ( $_GET['add_fav'] == 0 )
    9898  {
    99     $query = 'delete from '.PREFIX_TABLE.'favorites';
    100     $query.= ' where user_id = '.$user['id'];
    101     $query.= ' and image_id = '.$page['id'];
     99    $query = 'DELETE FROM '.PREFIX_TABLE.'favorites';
     100    $query.= ' WHERE user_id = '.$user['id'];
     101    $query.= ' AND image_id = '.$page['id'];
    102102    $query.= ';';
    103103    $result = mysql_query( $query );
     
    121121      $page['num'] = 0;
    122122    }
    123     $query = 'select id';
    124     $query.= ' from '.PREFIX_TABLE.'images';
     123    $query = 'SELECT id';
     124    $query.= ' FROM '.PREFIX_TABLE.'images';
    125125    $query.= $page['where'];
    126126    $query.= $conf['order_by'];
    127     $query.= ' limit '.$page['num'].',1';
     127    $query.= ' LIMIT '.$page['num'].',1';
    128128    $query.= ';';
    129129    $result = mysql_query( $query );
     
    144144//----------------------------------------------------- template initialization
    145145$vtp = new VTemplate;
    146 $handle = $vtp->Open( './template/default/picture.vtp' );
    147 // language
    148 $vtp->setGlobalVar( $handle, 'back',             $lang['back'] );
    149 $vtp->setGlobalVar( $handle, 'submit',           $lang['submit'] );
    150 $vtp->setGlobalVar( $handle, 'comments_title',   $lang['comments_title'] );
    151 $vtp->setGlobalVar( $handle, 'comments_del',     $lang['comments_del'] );
    152 $vtp->setGlobalVar( $handle, 'delete',           $lang['delete'] );
    153 $vtp->setGlobalVar( $handle, 'comments_add',     $lang['comments_add'] );
    154 $vtp->setGlobalVar( $handle, 'author',           $lang['author'] );
    155 // user
    156 $vtp->setGlobalVar( $handle, 'page_style',       $user['style'] );
    157 $vtp->setGlobalVar( $handle, 'text_color',       $user['couleur_text'] );
    158 // structure
    159 $vtp->setGlobalVar( $handle, 'frame_start',      get_frame_start() );
    160 $vtp->setGlobalVar( $handle, 'frame_begin',      get_frame_begin() );
    161 $vtp->setGlobalVar( $handle, 'frame_end',        get_frame_end() );
     146$handle = $vtp->Open( './template/'.$user['template'].'/picture.vtp' );
     147initialize_template();
     148
     149$tpl = array( 'back','submit','comments_title','comments_del','delete',
     150              'comments_add','author' );
     151templatize_array( $tpl, 'lang', $handle );
     152$vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] );
    162153//------------------------------------------------------------------ page title
    163 if ( $page['name'] != "" )
     154if ( $page['name'] != '' )
    164155{
    165156  $vtp->setGlobalVar( $handle, 'page_title', $page['name'] );
     
    173164{
    174165  $prev = $page['num'] - 1;
    175   $query = 'select id,name,file,tn_ext,cat_id';
    176   $query.= ' from '.PREFIX_TABLE.'images';
     166  $query = 'SELECT id,name,file,tn_ext,cat_id';
     167  $query.= ' FROM '.PREFIX_TABLE.'images';
    177168  $query.= $page['where'];
    178169  $query.= $conf['order_by'];
    179   $query.= ' limit '.$prev.',1';
     170  $query.= ' LIMIT '.$prev.',1';
    180171  $query.= ';';
    181172  $result = mysql_query( $query );
     
    198189  $prev_title = $lang['previous_image'].' : ';
    199190  $alt_thumbnaill = '';
    200   if ( $row['name'] != "" )
    201   {
    202     $alt_thumbnail = $row['name'];
    203   }
    204   else
    205   {
    206     $alt_thumbnail = $file;
    207   }
     191  if ( $row['name'] != '' ) $alt_thumbnail = $row['name'];
     192  else                      $alt_thumbnail = $file;
    208193  $prev_title.= $alt_thumbnail;
    209194 
     
    321306  $vtp->addSession( $handle, 'info_line' );
    322307  $vtp->setVar( $handle, 'info_line.name', $lang['creation_date'].' : ' );
    323   $tab_date = explode( '-', $page['date_creation'] );
     308  list( $year,$month,$day ) = explode( '-', $page['date_creation'] );
    324309  $vtp->setVar( $handle, 'info_line.content',
    325                 $tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0] );
     310                $day.'/'.$month.'/'.$year );
    326311  $vtp->closeSession( $handle, 'info_line' );
    327312}
     
    329314$vtp->addSession( $handle, 'info_line' );
    330315$vtp->setVar( $handle, 'info_line.name', $lang['registration_date'].' : ' );
    331 $tab_date = explode( '-', $page['date_available'] );
     316list( $year,$month,$day ) = explode( '-', $page['date_available'] );
    332317$vtp->setVar( $handle, 'info_line.content',
    333               $tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0] );
     318              $day.'/'.$month.'/'.$year );
    334319$vtp->closeSession( $handle, 'info_line' );
    335320// size in pixels
    336321$vtp->addSession( $handle, 'info_line' );
    337322$vtp->setVar( $handle, 'info_line.name', $lang['size'].' : ' );
    338 if ( $original_width != $final_width || $original_height != $final_height )
     323if ( $original_width != $final_width or $original_height != $final_height )
    339324{
    340325  $content = '[ <a href="'.$lien_image.'" title="'.$lang['true_size'].'">';
     
    380365$vtp->closeSession( $handle, 'info_line' );
    381366//------------------------------------------------------- favorite manipulation
    382 if ( $page['cat'] != 'fav' && !$user['is_the_guest'] )
     367if ( $page['cat'] != 'fav' and !$user['is_the_guest'] )
    383368{
    384369  $url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
     
    442427
    443428  $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") );
    444   $lien_thumbnail = $cat_directory."thumbnail/";
     429  $lien_thumbnail = $cat_directory.'thumbnail/';
    445430  $lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext'];
    446431 
     
    481466  if ( isset( $_POST['content'] ) && $_POST['content'] != '' )
    482467  {
    483     $author = $user['pseudo'];
    484     if ( $_POST['author'] != "" )
     468    $author = $user['username'];
     469    if ( $_POST['author'] != '' )
    485470    {
    486471      $author = $_POST['author'];
    487472    }
    488     $query = 'insert into '.PREFIX_TABLE.'comments';
    489     $query.= ' (author,date,image_id,content) values';
     473    $query = 'INSERT INTO '.PREFIX_TABLE.'comments';
     474    $query.= ' (author,date,image_id,content) VALUES';
    490475    $query.= " ('".$author."',".time().",".$page['id'];
    491476    $query.= ",'".htmlspecialchars( $_POST['content'], ENT_QUOTES)."');";
     
    497482       && $user['status'] == 'admin' )
    498483  {
    499     $query = 'delete from '.PREFIX_TABLE.'comments';
    500     $query.= ' where id = '.$_GET['del'].';';
     484    $query = 'DELETE FROM '.PREFIX_TABLE.'comments';
     485    $query.= ' WHERE id = '.$_GET['del'].';';
    501486    mysql_query( $query );
    502487  }
    503488  // number of comment for this picture
    504   $query = 'select count(*) as nb_comments';
    505   $query.= ' from '.PREFIX_TABLE.'comments';
    506   $query.= ' where image_id = '.$page['id'].';';
     489  $query = 'SELECT COUNT(*) AS nb_comments';
     490  $query.= ' FROM '.PREFIX_TABLE.'comments';
     491  $query.= ' WHERE image_id = '.$page['id'].';';
    507492  $row = mysql_fetch_array( mysql_query( $query ) );
    508493  $page['nb_comments'] = $row['nb_comments'];
     
    515500  }
    516501  if( !isset( $_GET['start'] )
    517       || !is_numeric( $_GET['start'] )
    518       || ( is_numeric( $_GET['start'] ) && $_GET['start'] < 0 ) )
     502      or !is_numeric( $_GET['start'] )
     503      or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) )
    519504  {
    520505    $page['start'] = 0;
     
    532517  $vtp->setGlobalVar( $handle, 'nb_comments', $page['nb_comments'] );
    533518
    534   $query = 'select id,author,date,image_id,content';
    535   $query.= ' from '.PREFIX_TABLE.'comments';
    536   $query.= ' where image_id = '.$page['id'];
    537   $query.= ' order by date asc';
    538   $query.= ' limit '.$page['start'].', '.$conf['nb_comment_page'].';';
     519  $query = 'SELECT id,author,date,image_id,content';
     520  $query.= ' FROM '.PREFIX_TABLE.'comments';
     521  $query.= ' WHERE image_id = '.$page['id'];
     522  $query.= ' ORDER BY date ASC';
     523  $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';';
    539524  $result = mysql_query( $query );
    540525               
     
    581566$code = $vtp->Display( $handle, 0 );
    582567echo $code;
    583 //------------------------------------------------------------ log informations
    584 $query = 'insert into '.PREFIX_TABLE.'history';
    585 $query.= ' (date,login,IP,page,titre,categorie) values';
    586 $query.= " (".time().", '".$user['pseudo']."','".$_SERVER['REMOTE_ADDR']."'";
    587 $query.= ",'picture','".$page['file']."','".$intitule_cat."');";
    588 @mysql_query( $query );
    589568?>
  • trunk/register.php

    r2 r21  
    1717
    1818//----------------------------------------------------------- personnal include
    19 include_once( "./include/init.inc.php" );
     19include_once( './include/init.inc.php' );
    2020//-------------------------------------------------- access authorization check
    21 if ( $conf['acces'] == "restreint" )
     21if ( $conf['access'] == "restricted" )
    2222{
    2323  echo $lang['only_members'];
  • trunk/template/default/admin/user_modify.vtp

    r9 r21  
    3535          <tr>
    3636            <td>{#new} {#password}<input type="checkbox" name="use_new_pwd" value="1" /></td>
    37             <td><input type="text" name="password" value="{#user:password}" /></td>
     37            <td><input type="text" name="password" value="" /></td>
    3838          </tr>
    3939          <tr>
     
    4848                <option value="{#value}"{#selected}>{#option}</option>
    4949                <!--/VTP_status_option-->
     50              </select>
     51            </td>
     52          </tr>
     53          <!--VTP_groups-->
     54          <tr>
     55            <td valign="top">{#menu_groups}</td>
     56            <td>
     57              <table>
     58                <!--VTP_group-->
     59                <tr>
     60                  <td>{#name}</td>
     61                  <td><input type="checkbox" name="dissociate-{#dissociate_id}" value="1" /> {#dissociate}</td>
     62                </tr>
     63                <!--/VTP_group-->
     64              </table>
     65            </td>
     66          </tr>
     67          <!--/VTP_groups-->
     68          <tr>
     69            <td>{#adduser_associate}</td>
     70            <td>
     71              <select name="associate">
     72                <!--VTP_associate_group-->
     73                <option value="{#value}">{#option}</option>
     74                <!--/VTP_associate_group-->
    5075              </select>
    5176            </td>
  • trunk/template/default/picture.vtp

    r2 r21  
    11<html>
    22  <head>
    3     {#page_style}
     3    {#style}
    44    <!-- Specific style to picture.php-->
    55    <style type="text/css">
     
    4545  </head>
    4646  <body>
     47    {#header}
    4748    <table style="width:100%;height:100%;">
    4849      <tr align="center" valign="middle">
     
    163164      <!--/VTP_comments-->
    164165    </table>
     166    {#footer}
    165167  </body>
    166168</html>
Note: See TracChangeset for help on using the changeset viewer.