Ignore:
Timestamp:
Feb 2, 2004, 1:55:18 AM (20 years ago)
Author:
gweltas
Message:

Merge of the 1.3.1 release
Creation of an unique include file (common.php)
Creation of an unique define file (include/constants.php)
Modification of the installation procedure

File:
1 edited

Legend:

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

    r235 r345  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // |                           functions.inc.php                           |
    4 // +-----------------------------------------------------------------------+
    5 // | application   : PhpWebGallery 1.3 <http://phpwebgallery.net>          |
    6 // | author        : Pierrick LE GALL <pierrick@z0rglub.com>               |
    7 // +-----------------------------------------------------------------------+
    8 // | file          : $RCSfile$
    9 // | tag           : $Name$
    10 // | last update   : $Date$
    11 // | revision      : $Revision$
    12 // +-----------------------------------------------------------------------+
    13 // | This program is free software; you can redistribute it and/or modify  |
    14 // | it under the terms of the GNU General Public License as published by  |
    15 // | the Free Software Foundation;                                         |
    16 // +-----------------------------------------------------------------------+
    17 
     2/***************************************************************************
     3 *                             functions.inc.php                           *
     4 *                            -------------------                          *
     5 *   application   : PhpWebGallery 1.3 <http://phpwebgallery.net>          *
     6 *   author        : Pierrick LE GALL <pierrick@z0rglub.com>               *
     7 *                                                                         *
     8 *   $Id$
     9 *                                                                         *
     10 ***************************************************************************
     11
     12 ***************************************************************************
     13 *                                                                         *
     14 *   This program is free software; you can redistribute it and/or modify  *
     15 *   it under the terms of the GNU General Public License as published by  *
     16 *   the Free Software Foundation;                                         *
     17 *                                                                         *
     18 ***************************************************************************/
    1819include( PREFIX_INCLUDE.'./include/functions_user.inc.php' );
    1920include( PREFIX_INCLUDE.'./include/functions_session.inc.php' );
     
    167168}
    168169
    169 // get_dirs retourne un tableau contenant tous les sous-répertoires d'un
    170 // répertoire
    171 function get_dirs( $rep )
    172 {
    173   $sub_rep = array();
    174 
    175   if ( $opendir = opendir ( $rep ) )
     170/**
     171 * returns an array contening sub-directories
     172 *
     173 * @param string $dir
     174 * @return array
     175 */
     176function get_dirs( $directory )
     177{
     178  $sub_dirs = array();
     179
     180  if ( $opendir = opendir( $directory ) )
    176181  {
    177182    while ( $file = readdir ( $opendir ) )
    178183    {
    179       if ( $file != '.' and $file != '..' and is_dir ( $rep.$file ) )
     184      if ( $file != '.' and $file != '..' and is_dir ( $directory.'/'.$file ) )
    180185      {
    181         array_push( $sub_rep, $file );
     186        array_push( $sub_dirs, $file );
    182187      }
    183188    }
    184189  }
    185   return $sub_rep;
     190  return $sub_dirs;
    186191}
    187192
     
    266271}
    267272
    268 // get_themes retourne un tableau contenant tous les "template - couleur"
    269 function get_themes( $theme_dir )
    270 {
    271   $themes = array();
    272   $main_themes = get_dirs( $theme_dir );
    273   for ( $i = 0; $i < sizeof( $main_themes ); $i++ )
    274   {
    275     $colors = get_dirs( $theme_dir.$main_themes[$i].'/' );
    276     for ( $j = 0; $j < sizeof( $colors ); $j++ )
    277     {
    278       array_push( $themes, $main_themes[$i].' - '.$colors[$j] );
    279     }
    280   }
    281   return $themes;
    282 }
    283 
    284273// - add_style replaces the
    285274//         $search  into <span style="$style">$search</span>
     
    325314}
    326315
    327 function database_connection()
    328 {
    329   include( PREFIX_INCLUDE.'./include/mysql.inc.php' );
    330   define( "PREFIX_TABLE", $prefixeTable );
    331 
    332   @mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
    333     or die ( "Could not connect to server" );
    334   @mysql_select_db( $cfgBase )
    335     or die ( "Could not connect to database" );
    336 }
    337 
    338316function pwg_log( $file, $category, $picture = '' )
    339317{
     
    356334
    357335  foreach ( $array as $value ) {
     336  if (isset(${$global_array_name}[$value]))
    358337    $vtp->setGlobalVar( $handle, $value, ${$global_array_name}[$value] );
    359338  }
     
    433412  }
    434413}
     414
     415function pwg_write_debug()
     416{
     417  global $debug;
     418 
     419  $fp = @fopen( './log/debug.log', 'a+' );
     420  fwrite( $fp, "\n\n" );
     421  fwrite( $fp, $debug );
     422  fclose( $fp );
     423}
     424
     425function pwg_query( $query )
     426{
     427  global $count_queries,$queries_time;
     428
     429  $start = get_moment();
     430  $output = '';
     431 
     432  $count_queries++;
     433  $output.= '<br /><br />['.$count_queries.'] '.$query;
     434  $result = mysql_query( $query );
     435  $time = get_moment() - $start;
     436  $queries_time+= $time;
     437  $output.= '<b>('.number_format( $time, 3, '.', ' ').' s)</b>';
     438  $output.= '('.number_format( $queries_time, 3, '.', ' ').' s)';
     439
     440  // echo $output;
     441 
     442  return $result;
     443}
     444
     445function pwg_debug( $string )
     446{
     447  global $debug,$t2,$count_queries;
     448
     449  $now = explode( ' ', microtime() );
     450  $now2 = explode( '.', $now[0] );
     451  $now2 = $now[1].'.'.$now2[1];
     452  $time = number_format( $now2 - $t2, 3, '.', ' ').' s';
     453  $debug.= '['.$time.', ';
     454  $debug.= $count_queries.' queries] : '.$string;
     455  $debug.= "\n";
     456}
    435457?>
Note: See TracChangeset for help on using the changeset viewer.