Changeset 1064 for trunk/admin/site_update.php
- Timestamp:
- Mar 5, 2006, 12:31:46 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/site_update.php
r1058 r1064 28 28 if (!defined('PHPWG_ROOT_PATH')) 29 29 { 30 die 30 die('Hacking attempt!'); 31 31 } 32 32 include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php'); 33 33 34 if (! is_numeric($_GET['site']))34 if (!is_numeric($_GET['site'])) 35 35 { 36 36 die ('site param missing or invalid'); 37 37 } 38 38 $site_id = $_GET['site']; 39 $query='SELECT galleries_url FROM '.SITES_TABLE.' 40 WHERE id='.$site_id.' 41 ;'; 42 list($site_url)=mysql_fetch_row(pwg_query($query)); 43 if (! isset($site_url) ) 44 { 45 die ("site $site_id does not exist"); 39 40 $query=' 41 SELECT galleries_url 42 FROM '.SITES_TABLE.' 43 WHERE id = '.$site_id.' 44 ;'; 45 list($site_url) = mysql_fetch_row(pwg_query($query)); 46 if (!isset($site_url)) 47 { 48 die('site '.$site_id.' does not exist'); 46 49 } 47 50 $site_is_remote = url_is_remote($site_url); … … 51 54 52 55 $error_labels = array( 53 'PWG-UPDATE-1' => array( l10n('update_wrong_dirname_short'), 54 l10n('update_wrong_dirname_info') ), 55 'PWG-UPDATE-2' => array( l10n('update_missing_tn_short'), 56 l10n('update_missing_tn_info') 57 . implode(',', $conf['picture_ext']) ), 58 'PWG-ERROR-NO-FS' => array( l10n('update_missing_file_or_dir'), 59 l10n('update_missing_file_or_dir_info')), 60 'PWG-ERROR-VERSION' => array( l10n('update_err_pwg_version_differs'), 61 l10n('update_err_pwg_version_differs_info')), 62 'PWG-ERROR-NOLISTING' => array( l10n('update_err_remote_listing_not_found'), 63 l10n('update_err_remote_listing_not_found_info')) 64 ); 56 'PWG-UPDATE-1' => array( 57 l10n('update_wrong_dirname_short'), 58 l10n('update_wrong_dirname_info') 59 ), 60 'PWG-UPDATE-2' => array( 61 l10n('update_missing_tn_short'), 62 l10n('update_missing_tn_info').implode(',', $conf['picture_ext']) 63 ), 64 'PWG-ERROR-NO-FS' => array( 65 l10n('update_missing_file_or_dir'), 66 l10n('update_missing_file_or_dir_info') 67 ), 68 'PWG-ERROR-VERSION' => array( 69 l10n('update_err_pwg_version_differs'), 70 l10n('update_err_pwg_version_differs_info') 71 ), 72 'PWG-ERROR-NOLISTING' => array( 73 l10n('update_err_remote_listing_not_found'), 74 l10n('update_err_remote_listing_not_found_info') 75 ) 76 ); 65 77 $errors = array(); 66 78 $infos = array(); … … 68 80 if ($site_is_remote) 69 81 { 70 include_once( 82 include_once(PHPWG_ROOT_PATH.'admin/site_reader_remote.php'); 71 83 $site_reader = new RemoteSiteReader($site_url); 72 84 } … … 77 89 } 78 90 79 $general_failure =true;91 $general_failure = true; 80 92 if (isset($_POST['submit'])) 81 93 { … … 214 226 if (preg_match('/^[a-zA-Z0-9-_.]+$/', $dir)) 215 227 { 216 $insert = array(); 217 218 $insert{'id'} = $next_id++; 219 $insert{'dir'} = $dir; 220 $insert{'name'} = str_replace('_', ' ', $dir); 221 $insert{'site_id'} = $site_id; 222 $insert{'commentable'} = $conf['newcat_default_commentable']; 223 if (! $site_is_remote) 224 { 225 $insert{'uploadable'} = $conf['newcat_default_uploadable']; 226 } 227 else 228 { 229 $insert{'uploadable'} = 'false'; 230 } 231 $insert{'status'} = $conf{'newcat_default_status'}; 232 $insert{'visible'} = $conf{'newcat_default_visible'}; 228 $insert = array( 229 'id' => $next_id++, 230 'dir' => $dir, 231 'name' => str_replace('_', ' ', $dir), 232 'site_id' => $site_id, 233 'commentable' => $conf['newcat_default_commentable'], 234 'uploadable' => $site_is_remote 235 ? false 236 : $conf['newcat_default_uploadable'], 237 'status' => $conf{'newcat_default_status'}, 238 'visible' => $conf{'newcat_default_visible'}, 239 ); 233 240 234 241 if (isset($db_fulldirs[dirname($fulldir)])) … … 259 266 260 267 array_push($inserts, $insert); 261 array_push($infos, array('path' => $fulldir, 262 'info' => l10n('update_research_added'))); 268 array_push( 269 $infos, 270 array( 271 'path' => $fulldir, 272 'info' => l10n('update_research_added') 273 ) 274 ); 263 275 264 276 // add the new category to $db_categories and $db_fulldirs array … … 276 288 else 277 289 { 278 array_push($errors, array('path' => $fulldir, 'type' => 'PWG-UPDATE-1')); 290 array_push( 291 $errors, 292 array( 293 'path' => $fulldir, 294 'type' => 'PWG-UPDATE-1' 295 ) 296 ); 279 297 } 280 298 } … … 339 357 SELECT id, path 340 358 FROM '.IMAGES_TABLE.' 341 WHERE storage_category_id IN ( 342 '.wordwrap(implode(', ', $cat_ids), 80, "\n").') 359 INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id 360 WHERE is_storage = \'true\' 361 AND category_id IN ('. 362 wordwrap( 363 implode(', ', $cat_ids), 364 80, 365 "\n" 366 ). 367 ') 343 368 ;'; 344 369 $result = pwg_query($query); … … 362 387 array_push( 363 388 $db_unvalidated, 364 array_search($row['storage_category_id'], 365 $db_fulldirs).'/'.$row['file'] 389 array_search( 390 $row['storage_category_id'], 391 $db_fulldirs) 392 .'/'.$row['file'] 366 393 ); 367 394 } … … 392 419 if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename)) 393 420 { 394 array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-1')); 421 array_push( 422 $errors, 423 array( 424 'path' => $path, 425 'type' => 'PWG-UPDATE-1' 426 ) 427 ); 428 395 429 continue; 396 430 } … … 402 436 { 403 437 // if we found a thumnbnail corresponding to our picture... 404 if ( isset($fs[$path]['tn_ext']))438 if (isset($fs[$path]['tn_ext'])) 405 439 { 406 $insert{'id'} = $next_element_id++; 407 $insert{'file'} = $filename; 408 $insert{'storage_category_id'} = $db_fulldirs[$dirname]; 409 $insert{'date_available'} = CURRENT_DATE; 410 $insert{'tn_ext'} = $fs[$path]['tn_ext']; 411 if ( isset($fs[$path]['has_high']) ) 412 { 413 $insert{'has_high'} = $fs[$path]['has_high']; 414 } 415 else 416 { 417 $insert{'has_high'} = null; 418 } 419 $insert{'path'} = $path; 420 421 array_push($inserts, $insert); 422 array_push($insert_links, 423 array('image_id' => $insert{'id'}, 424 'category_id' => $insert{'storage_category_id'})); 425 array_push($infos, array('path' => $insert{'path'}, 426 'info' => l10n('update_research_added'))); 440 $insert = array( 441 'id' => $next_element_id++, 442 'file' => $filename, 443 'date_available' => CURRENT_DATE, 444 'tn_ext' => $fs[$path]['tn_ext'], 445 'has_high' => isset($fs[$path]['has_high']) 446 ? $fs[$path]['has_high'] 447 : null, 448 'path' => $path, 449 ); 450 451 array_push( 452 $inserts, 453 $insert 454 ); 455 456 array_push( 457 $insert_links, 458 array( 459 'image_id' => $insert{'id'}, 460 'category_id' => $db_fulldirs[$dirname], 461 'is_storage' => 'true', 462 ) 463 ); 464 array_push( 465 $infos, 466 array( 467 'path' => $insert{'path'}, 468 'info' => l10n('update_research_added') 469 ) 470 ); 427 471 } 428 472 else 429 473 { 430 array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-2')); 474 array_push( 475 $errors, 476 array( 477 'path' => $path, 478 'type' => 'PWG-UPDATE-2' 479 ) 480 ); 431 481 } 432 482 } 433 483 else 434 484 { 435 $insert{'id'} = $next_element_id++; 436 $insert{'file'} = $filename; 437 $insert{'storage_category_id'} = $db_fulldirs[$dirname]; 438 $insert{'date_available'} = CURRENT_DATE; 439 $insert{'has_high'} = $fs[$path]['has_high']; 440 if ( isset($fs[$path]['has_high']) ) 441 { 442 $insert{'has_high'} = $fs[$path]['has_high']; 443 } 444 else 445 { 446 $insert{'has_high'} = null; 447 } 448 $insert{'path'} = $path; 449 450 if ( isset($fs[$path]['tn_ext']) ) 451 { 452 $insert{'tn_ext'} = $fs[$path]['tn_ext']; 453 } 454 if (isset($fs[$path]['representative_ext'])) 455 { 456 $insert{'representative_ext'} = $fs[$path]['representative_ext']; 457 } 458 459 array_push($inserts, $insert); 460 array_push($insert_links, 461 array('image_id' => $insert{'id'}, 462 'category_id' => $insert{'storage_category_id'})); 463 array_push($infos, array('path' => $insert{'path'}, 464 'info' => l10n('update_research_added'))); 485 $insert = array( 486 'id' => $next_element_id++, 487 'file' => $filename, 488 'date_available' => CURRENT_DATE, 489 'path' => $path, 490 'has_high' => isset($fs[$path]['has_high']) 491 ? $fs[$path]['has_high'] 492 : null, 493 'tn_ext' => isset($fs[$path]['tn_ext']) 494 ? $fs[$path]['tn_ext'] 495 : null, 496 'representative_ext' => isset($fs[$path]['representative_ext']) 497 ? $fs[$path]['representative_ext'] 498 : null, 499 ); 500 501 array_push( 502 $inserts, 503 $insert 504 ); 505 506 array_push( 507 $insert_links, 508 array( 509 'image_id' => $insert{'id'}, 510 'category_id' => $db_fulldirs[$dirname], 511 'is_storage' => 'true', 512 ) 513 ); 514 515 array_push( 516 $infos, 517 array( 518 'path' => $insert{'path'}, 519 'info' => l10n('update_research_added') 520 ) 521 ); 465 522 } 466 523 } … … 471 528 { 472 529 // inserts all new elements 473 $dbfields = array( 474 'id','file','storage_category_id','date_available','tn_ext' 475 ,'representative_ext', 'has_high', 'path' 476 ); 477 mass_inserts(IMAGES_TABLE, $dbfields, $inserts); 478 479 // insert all links between new elements and their storage category 480 $dbfields = array('image_id','category_id'); 481 mass_inserts(IMAGE_CATEGORY_TABLE, $dbfields, $insert_links); 530 mass_inserts( 531 IMAGES_TABLE, 532 array( 533 'id', 'file', 'date_available', 'tn_ext', 'representative_ext', 534 'has_high', 'path', 535 ), 536 $inserts 537 ); 538 539 // inserts all links between new elements and their storage category 540 mass_inserts( 541 IMAGE_CATEGORY_TABLE, 542 array( 543 'image_id','category_id', 'is_storage', 544 ), 545 $insert_links 546 ); 482 547 } 483 548 $counts['new_elements'] = count($inserts); … … 533 598 SELECT id 534 599 FROM '.IMAGES_TABLE.' 535 WHERE storage_category_id = \''.$row['storage_category_id'].'\' 600 INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON image_id = id 601 WHERE is_storage = \'true\' 602 AND category_id = '.$row['storage_category_id'].' 536 603 AND file = \''.$row['file'].'\' 537 604 ;'; … … 580 647 if (!$simulate) 581 648 { 649 $start = get_moment(); 650 check_links('all'); 651 echo '<!-- check_links(all) : '; 652 echo get_elapsed_time($start,get_moment()); 653 echo ' -->'."\n"; 582 654 $start = get_moment(); 583 655 update_category('all');
Note: See TracChangeset
for help on using the changeset viewer.