Changeset 13


Ignore:
Timestamp:
May 17, 2003, 1:42:03 PM (21 years ago)
Author:
z0rglub
Message:

* empty log message *

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r12 r13  
    2020function is_image( $filename, $create_thumbnail = false )
    2121{
    22   global $tab_ext_create_TN, $conf;
    23 
    24   $is_image = false;
     22  global $conf;
    2523
    2624  if ( is_file ( $filename ) )
     
    3533           and ( $size[2] == 1 or $size[2] == 2 or $size[2] == 3 ) )
    3634      {
    37         $is_image = true;
     35        return true;
    3836      }
    3937    }
     
    4341           and ( $size[2] == 2 or $size[2] == 3 ) )
    4442      {
    45         $is_image = true;
     43        return true;
    4644      }
    4745    }
    4846  }
    49   return $is_image;
     47  return false;
    5048}
    5149       
  • trunk/include/config.inc.php

    r2 r13  
    2121$lang = array();
    2222
    23 include_once( PREFIXE_INCLUDE.'./include/mysql.inc.php' );
    2423include_once( PREFIXE_INCLUDE.'./include/functions.inc.php' );
    2524include_once( PREFIXE_INCLUDE.'./include/vtemplate.class.php' );
    26 //
     25
    2726// How to change the order of display for images in a category ?
    2827//
     
    4746$conf['site_url']           = 'http://www.phpwebgallery.net';
    4847$conf['forum_url']          = 'http://forum.phpwebgallery.net';
     48$conf['picture_ext']        = array ( 'jpg','JPG','gif','GIF','png','PNG' );
     49$conf['document_ext']       = array( 'doc','pdf','zip' );
    4950
    5051database_connection();
     
    7475  $query.= $infos[$i];
    7576}
    76 $query .= ' from '.$prefixeTable.'config;';
     77$query .= ' from '.PREFIX_TABLE.'config;';
    7778
    7879$row = mysql_fetch_array( mysql_query( $query ) );
  • trunk/include/functions.inc.php

    r9 r13  
    1818include( 'functions_session.inc.php' );
    1919include( 'functions_category.inc.php' );
     20include( 'functions_xml.inc.php' );
    2021
    2122//----------------------------------------------------------- generic functions
     
    129130}
    130131
     132// get_extension returns the part of the string after the last "."
     133function get_extension( $filename )
     134{
     135  return substr( strrchr( $filename, '.' ), 1, strlen ( $filename ) );
     136}
     137
     138// get_filename_wo_extension returns the part of the string before the last
     139// ".".
     140// get_filename_wo_extension( 'test.tar.gz' ) -> 'test.tar'
     141function get_filename_wo_extension( $filename )
     142{
     143  return substr( $filename, 0, strrpos( $filename, '.' ) );
     144}
     145
    131146// get_dirs retourne un tableau contenant tous les sous-répertoires d'un
    132147// répertoire
     
    203218  return $picture_size;
    204219}
    205 
    206220//-------------------------------------------- PhpWebGallery specific functions
    207221
     
    279293function database_connection()
    280294{
    281   global $cfgHote,$cfgUser,$cfgPassword,$cfgBase;
     295  // $cfgHote,$cfgUser,$cfgPassword,$cfgBase;
     296
     297  $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' );
     298  $mysql_conf = getChild( $xml_content, 'mysql' );
     299
     300  $cfgHote     = getAttribute( $mysql_conf, 'host' );
     301  $cfgUser     = getAttribute( $mysql_conf, 'user' );
     302  $cfgPassword = getAttribute( $mysql_conf, 'password' );
     303  $cfgBase     = getAttribute( $mysql_conf, 'base' );
     304
    282305  @mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
    283306    or die ( "Could not connect to server" );
    284307  @mysql_select_db( $cfgBase )
    285308    or die ( "Could not connect to database" );
     309
     310  define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) );
    286311}
    287312
    288313function pwg_log( $file, $category, $picture = '' )
    289314{
    290   global $conf, $user, $prefixeTable;
     315  global $conf, $user;
    291316
    292317  if ( $conf['log'] )
    293318  {
    294     $query = 'insert into '.$prefixeTable.'history';
     319    $query = 'insert into '.PREFIX_TABLE.'history';
    295320    $query.= ' (date,login,IP,file,category,picture) values';
    296321    $query.= " (".time().", '".$user['pseudo']."'";
  • trunk/include/functions_category.inc.php

    r9 r13  
    1717function get_subcats_id( $cat_id )
    1818{
    19   global $prefixeTable;
    20                
    2119  $restricted_cat = array();
    2220  $i = 0;
    2321               
    24   $query = "select id";
    25   $query.= " from $prefixeTable"."categories";
    26   $query.= " where id_uppercat = $cat_id;";
     22  $query = 'select id';
     23  $query.= ' from '.PREFIX_TABLE.'categories';
     24  $query.= ' where id_uppercat = '.$cat_id;
     25  $query.= ';';
    2726  $result = mysql_query( $query );
    2827  while ( $row = mysql_fetch_array( $result ) )
     
    4140function check_restrictions( $category_id )
    4241{
    43   global $user,$lang,$prefixeTable;
     42  global $user,$lang;
    4443
    4544  if ( is_user_allowed( $category_id, $user['restrictions'] ) > 0 )
     
    5857function check_cat_id( $cat )
    5958{
    60   global $page,$prefixeTable;
     59  global $page;
     60
    6161  unset( $page['cat'] );
    6262  if ( isset( $cat ) )
     
    6464    if ( is_numeric( $cat ) )
    6565    {
    66       $query = "select id from $prefixeTable"."categories where id = $cat;";
     66      $query = 'select id';
     67      $query.= ' from '.PREFIX_TABLE.'categories';
     68      $query.= ' where id = '.$cat;
     69      $query. ';';
    6770      $result = mysql_query( $query );
    6871      if ( mysql_num_rows( $result ) != 0 )
     
    8184function display_cat( $id_uppercat, $indent, $restriction, $tab_expand )
    8285{
    83   global $prefixeTable,$user,$lang,$conf,$page,$vtp,$handle;
     86  global $user,$lang,$conf,$page,$vtp,$handle;
    8487 
    8588  $query = 'select name,id,date_dernier,nb_images,dir';
    86   $query.= ' from '.$prefixeTable.'categories';
     89  $query.= ' from '.PREFIX_TABLE.'categories';
    8790  $query.= ' where id_uppercat';
    8891  if ( $id_uppercat == "" )
     
    202205function get_nb_subcats( $id )
    203206{
    204   global $prefixeTable,$user;
     207  global $user;
    205208               
    206209  $query = 'select count(*) as count';
    207   $query.= ' from '.$prefixeTable.'categories';
     210  $query.= ' from '.PREFIX_TABLE.'categories';
    208211  $query.= ' where id_uppercat = '.$id;
    209212  for ( $i = 0; $i < sizeof( $user['restrictions'] ); $i++ )
     
    219222function get_total_image( $id, $restriction )
    220223{
    221   global $prefixeTable;
    222                
    223224  $total = 0;
    224225               
    225226  $query = 'select id,nb_images';
    226   $query.= ' from '.$prefixeTable.'categories';
     227  $query.= ' from '.PREFIX_TABLE.'categories';
    227228  $query.= ' where id_uppercat';
    228229  if ( !is_numeric( $id ) )
     
    260261function get_cat_info( $id )
    261262{
    262   global $prefixeTable;
    263                
    264263  $cat = array();
    265264  $cat['name'] = array();
    266265               
    267266  $query = 'select nb_images,id_uppercat,comment,site_id,galleries_url,dir';
    268   $query.= ' from '.$prefixeTable.'categories as a';
    269   $query.= ', '.$prefixeTable.'sites as b';
     267  $query.= ' from '.PREFIX_TABLE.'categories as a';
     268  $query.= ', '.PREFIX_TABLE.'sites as b';
    270269  $query.= ' where a.id = '.$id;
    271270  $query.= ' and a.site_id = b.id;';
     
    285284  {
    286285    $query = 'select name,dir,id_uppercat';
    287     $query.= ' from '.$prefixeTable.'categories';
     286    $query.= ' from '.PREFIX_TABLE.'categories';
    288287    $query.= ' where id = '.$row['id_uppercat'].';';
    289288    $row = mysql_fetch_array( mysql_query( $query ) );
     
    360359function initialize_category( $calling_page = 'category' )
    361360{
    362   global $prefixeTable,$page,$lang,$user,$conf;
     361  global $page,$lang,$user,$conf;
    363362 
    364363  if ( isset( $page['cat'] ) )
     
    398397
    399398        $query = 'select count(*) as nb_total_images';
    400         $query.= ' from '.$prefixeTable.'images';
     399        $query.= ' from '.PREFIX_TABLE.'images';
    401400        $query.= $page['where'];
    402401        $query.= ';';
     
    409408        $page['title'] = $lang['favorites'];
    410409
    411         $page['where'] = ', '.$prefixeTable.'favorites';
     410        $page['where'] = ', '.PREFIX_TABLE.'favorites';
    412411        $page['where'].= ' where user_id = '.$user['id'];
    413412        $page['where'].= ' and image_id = id';
    414413     
    415414        $query = 'select count(*) as nb_total_images';
    416         $query.= ' from '.$prefixeTable.'favorites';
     415        $query.= ' from '.PREFIX_TABLE.'favorites';
    417416        $query.= ' where user_id = '.$user['id'];
    418417        $query.= ';';
     
    429428
    430429        $query = 'select count(*) as nb_total_images';
    431         $query.= ' from '.$prefixeTable.'images';
     430        $query.= ' from '.PREFIX_TABLE.'images';
    432431        $query.= $page['where'];
    433432        $query.= ';';
  • trunk/include/functions_session.inc.php

    r9 r13  
    3737      $key .= chr( mt_rand( 65, 90 ) );
    3838    }
    39     elseif ( $c == 1 )
    40       {
    41         $key .= chr( mt_rand( 97, 122 ) );
    42       }
     39    else if ( $c == 1 )
     40    {
     41      $key .= chr( mt_rand( 97, 122 ) );
     42    }
    4343    else
    4444    {
     
    5151function session_create( $username )
    5252{
    53   global $conf,$prefixeTable,$REMOTE_ADDR;
     53  global $conf;
    5454  // 1. searching an unused sesison key
    5555  $id_found = false;
     
    5858    $generated_id = generate_key();
    5959    $query = 'select id';
    60     $query.= ' from '.$prefixeTable.'sessions';
     60    $query.= ' from '.PREFIX_TABLE.'sessions';
    6161    $query.= " where id = '".$generated_id."';";
    6262    $result = mysql_query( $query );
     
    6868  // 2. retrieving id of the username given in parameter
    6969  $query = 'select id';
    70   $query.= ' from '.$prefixeTable.'users';
     70  $query.= ' from '.PREFIX_TABLE.'users';
    7171  $query.= " where username = '".$username."';";
    7272  $row = mysql_fetch_array( mysql_query( $query ) );
    7373  $user_id = $row['id'];
    7474  // 3. inserting session in database
    75   $expiration = $conf['session_time']*60+time();
    76   $query = 'insert into '.$prefixeTable.'sessions';
     75  $expiration = $conf['session_time'] * 60 + time();
     76  $query = 'insert into '.PREFIX_TABLE.'sessions';
    7777  $query.= ' (id,user_id,expiration,ip) values';
    7878  $query.= "('".$generated_id."','".$user_id;
    79   $query.= "','".$expiration."','".$REMOTE_ADDR."');";
     79  $query.= "','".$expiration."','".$_SERVER['REMOTE_ADDR']."');";
    8080  mysql_query( $query );
    8181               
  • trunk/include/functions_user.inc.php

    r9 r13  
    3939  $login, $password, $password_conf, $mail_address, $status = 'guest' )
    4040{
    41   global $prefixeTable, $lang;
     41  global $lang;
    4242
    4343  $error = array();
     
    6767  {
    6868    $query = 'select id';
    69     $query.= ' from '.$prefixeTable.'users';
     69    $query.= ' from '.PREFIX_TABLE.'users';
    7070    $query.= " where username = '".$login."';";
    7171    $result = mysql_query( $query );
     
    107107      $query.= $infos[$i];
    108108    }
    109     $query.= ' from '.$prefixeTable.'users';
     109    $query.= ' from '.PREFIX_TABLE.'users';
    110110    $query.= " where username = 'guest';";
    111111    $row = mysql_fetch_array( mysql_query( $query ) );
    112112    // 2. adding new user
    113     $query = 'insert into '.$prefixeTable.'users';
     113    $query = 'insert into '.PREFIX_TABLE.'users';
    114114    $query.= ' (';
    115115    $query.= ' username,password,mail_address,status';
     
    146146    // 3. retrieving the id of the newly created user
    147147    $query = 'select id';
    148     $query.= ' from '.$prefixeTable.'users';
     148    $query.= ' from '.PREFIX_TABLE.'users';
    149149    $query.= " where username = '".$login."';";
    150150    $row = mysql_fetch_array( mysql_query( $query ) );
     
    152152    // 4. adding restrictions to the new user, the same as the user "guest"
    153153    $query = 'select cat_id';
    154     $query.= ' from '.$prefixeTable.'restrictions as r';
    155     $query.=      ','.$prefixeTable.'users as u ';
     154    $query.= ' from '.PREFIX_TABLE.'restrictions as r';
     155    $query.=      ','.PREFIX_TABLE.'users as u ';
    156156    $query.= ' where u.id = r.user_id';
    157157    $query.= " and u.username = 'guest';";
     
    159159    while( $row = mysql_fetch_array( $result ) )
    160160    {
    161       $query = 'insert into '.$prefixeTable.'restrictions';
     161      $query = 'insert into '.PREFIX_TABLE.'restrictions';
    162162      $query.= ' (user_id,cat_id) values';
    163163      $query.= ' ('.$user_id.','.$row['cat_id'].');';
     
    171171                      $use_new_password = false, $password = '' )
    172172{
    173   global $prefixeTable;
    174 
    175173  $error = array();
    176174  $i = 0;
     
    184182  if ( sizeof( $error ) == 0 )
    185183  {
    186     $query = 'update '.$prefixeTable.'users';
     184    $query = 'update '.PREFIX_TABLE.'users';
    187185    $query.= " set status = '".$status."'";
    188186    if ( $use_new_password )
     
    225223function get_restrictions( $user_id, $user_status, $check_invisible )
    226224{
    227   global $prefixeTable;
    228                
    229225  // 1. getting the ids of the restricted categories
    230   $query = "select cat_id";
    231   $query.= " from $prefixeTable"."restrictions";
    232   $query.= " where user_id = $user_id;";
     226  $query = 'select cat_id';
     227  $query.= ' from '.PREFIX_TABLE.'restrictions';
     228  $query.= ' where user_id = '.$user_id;
     229  $query.= ';';
    233230  $result = mysql_query( $query );
    234231  $i = 0;
     
    244241    {
    245242      $query = 'select id';
    246       $query.= ' from '.$prefixeTable.'categories';
     243      $query.= ' from '.PREFIX_TABLE.'categories';
    247244      $query.= " where status='invisible';";
    248245      $result = mysql_query( $query );
     
    261258function get_all_restrictions( $user_id, $user_status )
    262259{
    263   global $prefixeTable;
    264                
    265260  $restricted_cat = get_restrictions( $user_id, $user_status, true );
    266261  $i = sizeof( $restricted_cat );
     
    282277function is_user_allowed( $category_id, $restrictions )
    283278{
    284   global $user,$prefixeTable;
     279  global $user;
    285280               
    286281  $lowest_category_id = $category_id;
     
    289284  while ( !$is_root and !in_array( $category_id, $restrictions ) )
    290285  {
    291     $query = "select id_uppercat";
    292     $query.= " from $prefixeTable"."categories";
    293     $query.= " where id = $category_id;";
     286    $query = 'select id_uppercat';
     287    $query.= ' from '.PREFIX_TABLE.'categories';
     288    $query.= ' where id = '.$category_id;
     289    $query.= ';';
    294290    $row = mysql_fetch_array( mysql_query( $query ) );
    295291    if ( $row['id_uppercat'] == "" )
  • trunk/include/user.inc.php

    r9 r13  
    3838  $query_user.= $infos[$i];
    3939}
    40 $query_user.= ' from '.$prefixeTable.'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 $prefixeTable"."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']."'";
     50  $query.= ';';
    5051  $result = mysql_query( $query );
    5152  if ( mysql_num_rows( $result ) > 0 )
     
    5657      // deletion of the session from the database,
    5758      // because it is out-of-date
    58       $delete_query = "delete from ".$prefixeTable."sessions";
    59       $delete_query.= " where id = ".$page['session_id'].";";
     59      $delete_query = 'delete from '.PREFIX_TABLE.'sessions';
     60      $delete_query.= " where id = '".$page['session_id']."'";
     61      $delete_query.= ';';
    6062      mysql_query( $delete_query );
    6163    }
    6264    else
    6365    {
    64       if ( $REMOTE_ADDR == $row['ip'] )
     66      if ( $_SERVER['REMOTE_ADDR'] == $row['ip'] )
    6567      {
    6668        $query_user .= ' where id = '.$row['user_id'];
     
    8486{
    8587  $user[$infos[$i]] = $row[$infos[$i]];
    86   // If the field is true or false, the variable is transformed into a boolean
    87   // value.
     88  // If the field is true or false, the variable is transformed into a
     89  // boolean value.
    8890  if ( $row[$infos[$i]] == 'true' || $row[$infos[$i]] == 'false' )
    8991  {
  • trunk/language/francais.php

    r9 r13  
    204204if ( $isadmin )
    205205{
     206// start version 1.3
     207  // general for admin section
     208  $lang['remote_site'] = 'Site distant';
     209// end version 1.3
     210 
    206211  // page admin
    207212// start version 1.3
     
    292297  $lang['conf_comments_comments_number_info'] = 'nombre de commentaire à afficher sur chaque page. Le nombre de commentaires pour une image reste illimité. Entrer un nombre entre 5 et 50.';
    293298  $lang['conf_err_comment_number'] = 'le nombre de commentaires par page doit être compris entre 5 et 50 inclus.';
    294   $lang['conf_remote_site_title'] = 'Site distant';
     299// start version 1.3
     300  // $lang['conf_remote_site_title'] = 'Site distant';
     301// end version 1.3
    295302  $lang['conf_remote_site_delete_info'] = 'Supprimer un site revient à supprimer toutes les images et les catégories en relation avec ce site.';
    296303  $lang['conf_upload_title'] = 'Configurer l\'upload des utilisateurs';
     
    506513  $lang['help_database'][0] = 'Une fois les fichiers placés correctement et les miniatures placées ou créées, cliquez sur "MaJ base d\'images" dans le menu de la zone d\'administration.';
    507514
    508   $lang['help_remote_title'] = 'Site distant';
     515// start version 1.3
     516  // $lang['help_remote_title'] = 'Site distant';
     517// end version 1.3
    509518  $lang['help_remote'][0] = 'PhpWebGallery offre la possibilité d\'utiliser plusieurs serveurs pour stocker les images qui composeront votre galerie. Cela peut être utile si votre galerie est installée sur une espace limité et que vous avez une grande quantité d\'images à montrer. Suivez la procédure suivante :';
    510519  $lang['help_remote'][1] = '1. éditez le fichier "create_listing_file.php" (vous le trouverez dans le répertoire "admin"), en modifiant la ligne "$prefixe_thumbnail = "TN-";" si le préfixe pour vos miniatures n\'est pas "TN-".';
  • trunk/template/default/upload.vtp

    r2 r13  
    11<html>
    22  <head>
    3     {#page_style}
    4     <title>{#upload_page_title}</title>
     3    {#style}
     4    <title>{#upload_title}</title>
    55  </head>
    66  <body>
     
    5252                </tr>
    5353                <tr>
    54                   <td class="menu">{#reg_mail_address}</td>
     54                  <td class="menu">{#mail_address}</td>
    5555                  <td align="center" style="padding:10px;">
    5656                    <input name="mail_address" type="text" value="{#user_mail_address}" />
Note: See TracChangeset for help on using the changeset viewer.