Changeset 672 for trunk/admin/include/functions.php
- Timestamp:
- Jan 6, 2005, 11:16:21 PM (19 years ago)
- File:
-
- 1 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 ?>
Note: See TracChangeset
for help on using the changeset viewer.