Changeset 345 for trunk/include/functions.inc.php
- Timestamp:
- Feb 2, 2004, 1:55:18 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r235 r345 1 1 <?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 ***************************************************************************/ 18 19 include( PREFIX_INCLUDE.'./include/functions_user.inc.php' ); 19 20 include( PREFIX_INCLUDE.'./include/functions_session.inc.php' ); … … 167 168 } 168 169 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 */ 176 function get_dirs( $directory ) 177 { 178 $sub_dirs = array(); 179 180 if ( $opendir = opendir( $directory ) ) 176 181 { 177 182 while ( $file = readdir ( $opendir ) ) 178 183 { 179 if ( $file != '.' and $file != '..' and is_dir ( $ rep.$file ) )184 if ( $file != '.' and $file != '..' and is_dir ( $directory.'/'.$file ) ) 180 185 { 181 array_push( $sub_ rep, $file );186 array_push( $sub_dirs, $file ); 182 187 } 183 188 } 184 189 } 185 return $sub_ rep;190 return $sub_dirs; 186 191 } 187 192 … … 266 271 } 267 272 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 284 273 // - add_style replaces the 285 274 // $search into <span style="$style">$search</span> … … 325 314 } 326 315 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 338 316 function pwg_log( $file, $category, $picture = '' ) 339 317 { … … 356 334 357 335 foreach ( $array as $value ) { 336 if (isset(${$global_array_name}[$value])) 358 337 $vtp->setGlobalVar( $handle, $value, ${$global_array_name}[$value] ); 359 338 } … … 433 412 } 434 413 } 414 415 function 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 425 function 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 445 function 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 } 435 457 ?>
Note: See TracChangeset
for help on using the changeset viewer.