Changeset 672
- Timestamp:
- Jan 6, 2005, 11:16:21 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r670 r672 768 768 } 769 769 770 // my_error returns (or send to standard output) the message concerning the771 // error occured for the last mysql query.772 function my_error($header, $echo = true)773 {774 $error = $header.'<span style="font-weight:bold;">N°= '.mysql_errno();775 $error.= ' -->> '.mysql_error()."</span><br /><br />\n";776 if ($echo)777 {778 echo $error;779 }780 else781 {782 return $error;783 }784 }785 786 770 /** 787 771 * inserts multiple lines in a table … … 911 895 } 912 896 } 897 898 $temporary_tablename = $tablename.'_'.micro_seconds(); 899 913 900 $query = ' 914 CREATE T EMPORARY TABLE '.$tablename.'_temporary901 CREATE TABLE '.$temporary_tablename.' 915 902 ( 916 903 '.implode(",\n", $columns).', … … 919 906 ;'; 920 907 pwg_query($query); 921 mass_inserts($t ablename.'_temporary', $all_fields, $datas);908 mass_inserts($temporary_tablename, $all_fields, $datas); 922 909 // update of images table by joining with temporary table 923 910 $query = ' 924 UPDATE '.$tablename.' AS t1, '.$t ablename.'_temporaryAS t2911 UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2 925 912 SET '.implode("\n , ", 926 913 array_map( … … 934 921 pwg_query($query); 935 922 $query = ' 936 DROP TABLE '.$t ablename.'_temporary923 DROP TABLE '.$temporary_tablename.' 937 924 ;'; 938 925 pwg_query($query); … … 1194 1181 } 1195 1182 1196 // filling $uppercats_array : to each category id the uppercats list is 1197 // associated 1198 $uppercats_array = array(); 1199 1200 $query = ' 1201 SELECT id, uppercats 1183 // caching galleries_url 1184 $query = ' 1185 SELECT id, galleries_url 1186 FROM '.SITES_TABLE.' 1187 ;'; 1188 $result = pwg_query($query); 1189 $galleries_url = array(); 1190 while ($row = mysql_fetch_array($result)) 1191 { 1192 $galleries_url[$row['id']] = $row['galleries_url']; 1193 } 1194 1195 // categories : id, site_id, uppercats 1196 $categories = array(); 1197 1198 $query = ' 1199 SELECT id, uppercats, site_id 1202 1200 FROM '.CATEGORIES_TABLE.' 1203 1201 WHERE id IN ( … … 1207 1205 while ($row = mysql_fetch_array($result)) 1208 1206 { 1209 $uppercats_array[$row['id']] = $row['uppercats']; 1210 } 1211 1212 $query = ' 1213 SELECT galleries_url 1214 FROM '.SITES_TABLE.' 1215 WHERE id = 1 1216 '; 1217 $row = mysql_fetch_array(pwg_query($query)); 1218 $basedir = $row['galleries_url']; 1207 array_push($categories, $row); 1208 } 1219 1209 1220 1210 // filling $cat_fulldirs 1221 1211 $cat_fulldirs = array(); 1222 foreach ($uppercats_array as $cat_id => $uppercats) 1223 { 1224 $uppercats = str_replace(',', '/', $uppercats); 1225 $cat_fulldirs[$cat_id] = $basedir.preg_replace('/(\d+)/e', 1226 "\$cat_dirs['$1']", 1227 $uppercats); 1212 foreach ($categories as $category) 1213 { 1214 $uppercats = str_replace(',', '/', $category['uppercats']); 1215 $cat_fulldirs[$category['id']] = $galleries_url[$category['site_id']]; 1216 $cat_fulldirs[$category['id']].= preg_replace('/(\d+)/e', 1217 "\$cat_dirs['$1']", 1218 $uppercats); 1228 1219 } 1229 1220 … … 1318 1309 return $fs; 1319 1310 } 1311 1312 /** 1313 * stupidly returns the current microsecond since Unix epoch 1314 */ 1315 function micro_seconds() 1316 { 1317 $t1 = explode(' ', microtime()); 1318 $t2 = explode('.', $t1[0]); 1319 $t2 = $t1[1].substr($t2[1], 0, 6); 1320 return $t2; 1321 } 1320 1322 ?> -
trunk/include/functions.inc.php
r667 r672 487 487 function pwg_query($query) 488 488 { 489 global $conf,$ count_queries,$queries_time;489 global $conf,$page; 490 490 491 491 $start = get_moment(); 492 $result = mysql_query($query) ;492 $result = mysql_query($query) or my_error($query."\n"); 493 493 494 494 $time = get_moment() - $start; 495 $count_queries++; 496 $queries_time+= $time; 495 496 if (!isset($page['count_queries'])) 497 { 498 $page['count_queries'] = 0; 499 $page['queries_time'] = 0; 500 } 501 502 $page['count_queries']++; 503 $page['queries_time']+= $time; 497 504 498 505 if ($conf['show_queries']) 499 506 { 500 507 $output = ''; 501 $output.= '<pre>['.$count_queries.'] '."\n".$query; 502 $output.= "\n".'(this query time : '.number_format( $time, 3, '.', ' ').' s)</b>'; 503 $output.= "\n".'(total SQL time : '.number_format( $queries_time, 3, '.', ' ').' s)'; 508 $output.= '<pre>['.$page['count_queries'].'] '; 509 $output.= "\n".$query; 510 $output.= "\n".'(this query time : '; 511 $output.= number_format($time, 3, '.', ' ').' s)</b>'; 512 $output.= "\n".'(total SQL time : '; 513 $output.= number_format($page['queries_time'], 3, '.', ' ').' s)'; 504 514 $output.= '</pre>'; 505 515 … … 625 635 return $src; 626 636 } 637 638 // my_error returns (or send to standard output) the message concerning the 639 // error occured for the last mysql query. 640 function my_error($header, $echo = true) 641 { 642 $error = '<pre>'; 643 $error.= $header; 644 $error.= '[mysql error '.mysql_errno().'] '; 645 $error.= mysql_error(); 646 $error.= '</pre>'; 647 if ($echo) 648 { 649 echo $error; 650 } 651 else 652 { 653 return $error; 654 } 655 } 627 656 ?> -
trunk/include/functions_category.inc.php
r657 r672 222 222 $cat['comment'] = nl2br($cat['comment']); 223 223 224 $cat['name'] = array(); 225 224 $names = array(); 226 225 $query = ' 227 226 SELECT name,id 228 227 FROM '.CATEGORIES_TABLE.' 229 228 WHERE id IN ('.$cat['uppercats'].') 230 ORDER BY id ASC231 229 ;'; 232 230 $result = pwg_query($query); 233 231 while($row = mysql_fetch_array($result)) 234 232 { 235 $cat['name'][$row['id']] = $row['name']; 233 $names[$row['id']] = $row['name']; 234 } 235 236 // category names must be in the same order than uppercats list 237 $cat['name'] = array(); 238 foreach (explode(',', $cat['uppercats']) as $cat_id) 239 { 240 $cat['name'][$cat_id] = $names[$cat_id]; 236 241 } 237 242 -
trunk/include/functions_user.inc.php
r661 r672 209 209 function setup_style($style) 210 210 { 211 $template_path = 'template/' ; 212 $template_name = $style ; 213 $template = new Template(PHPWG_ROOT_PATH . $template_path . $template_name); 214 return $template; 211 return new Template(PHPWG_ROOT_PATH.'template/'.$style); 215 212 } 216 213 -
trunk/include/page_tail.php
r660 r672 43 43 $time = get_elapsed_time($t2, get_moment()); 44 44 45 if (!isset($ count_queries))45 if (!isset($page['count_queries'])) 46 46 { 47 $ count_queries= 0;48 $ queries_time= 0;47 $page['count_queries'] = 0; 48 $page['queries_time'] = 0; 49 49 } 50 50 … … 52 52 'debug', 53 53 array('TIME' => $time, 54 'NB_QUERIES' => $ count_queries,55 'SQL_TIME' => number_format($ queries_time, 3, '.',' ').' s'));54 'NB_QUERIES' => $page['count_queries'], 55 'SQL_TIME' => number_format($page['queries_time'],3,'.',' ').' s')); 56 56 } 57 57 -
trunk/install/config.sql
r653 r672 21 21 INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('recent_period','7','Period within which pictures are displayed as new (in days)'); 22 22 INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('auto_expand','false','Auto expand of the category tree'); 23 INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('show_nb_comments',' true','Show the number of comments under the thumbnails');23 INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('show_nb_comments','false','Show the number of comments under the thumbnails'); 24 24 INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('use_iptc','false','Use IPTC data during database synchronization with files metadata'); 25 25 INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('use_exif','true','Use EXIF data during database synchronization with files metadata');
Note: See TracChangeset
for help on using the changeset viewer.