Changeset 556 for trunk/plog-admin/plog-admin-functions.php
- Timestamp:
- 07/09/08 13:00:01 (4 months ago)
- Files:
-
- 1 modified
-
trunk/plog-admin/plog-admin-functions.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plog-admin/plog-admin-functions.php
r555 r556 454 454 if (!$collection) { 455 455 return array('errors' => plog_tr('No such collection')); 456 } ;456 } 457 457 458 458 // first delete all albums registered with this album … … 461 461 while ($row = mysql_fetch_assoc($result)) { 462 462 delete_album($row['id']); 463 } ;463 } 464 464 465 465 // XXX: un-register collection … … 473 473 474 474 $collection_directory = realpath($config['basedir'] . 'plog-content/images/'.$source_collection_name); 475 $relative_path = substr($collection_directory,0,strlen($config['basedir'])); 476 $collection_path = explode('/',substr($collection_directory,strlen($config['basedir']))); 477 // it needs to have 2 parts - images and collection name, if it doesn't, then there is something 478 // wrong with collection name and it's probably not safe to try to delete the directory 479 if ($relative_path == $config['basedir'] && sizeof($collection_path) == 2) { 475 // check to see if the collection_directory is a real directory and then try to delete it 476 if (is_dir($collection_directory)){ 480 477 @chmod($collection_directory,0777); 481 478 $delete_result = rmdir($collection_directory); 482 479 if (!$delete_result) { 483 480 return array('errors' => plog_tr('Collection directory still contains files after all albums have been deleted.')); 484 } ;481 } 485 482 486 483 } else { 487 484 return array('errors' => plog_tr('Collection has invalid path, not deleting directory')); 488 } ;485 } 489 486 return array(); 490 487 } … … 718 715 if (!$album) { 719 716 return array('errors' => plog_tr('No such album')); 720 } ;717 } 721 718 722 719 // first delete all pictures registered with this album … … 725 722 while ($row = mysql_fetch_assoc($result)) { 726 723 delete_picture($row['id']); 727 } ;724 } 728 725 729 726 // XXX: un-register album … … 738 735 739 736 $album_directory = realpath($config['basedir'] . 'plog-content/images/'.$source_collection_name."/".$source_album_name); 740 $relative_path = substr($album_directory,0,strlen($config['basedir'])); 741 $album_path = explode('/',substr($album_directory,strlen($config['basedir']))); 742 // it needs to have 3 parts - images, collection name and album name, if it doesn't, then there is something 743 // wrong with either collection or album name and it's probably not safe to try to delete the directory 744 if ($relative_path == $config['basedir'] && sizeof($album_path) == 3) { 737 // check to see if the album_directory is a real directory and then try to delete it 738 if (is_dir($album_directory)){ 745 739 @chmod($album_directory,0777); 746 740 $delete_result = rmdir($album_directory); 747 741 if (!$delete_result) { 748 742 return array('errors' => plog_tr('Album directory still contains files after all pictures have been deleted.')); 749 } ;743 } 750 744 751 745 } else { 752 746 return array('errors' => plog_tr('Album has invalid path, not deleting directory')); 753 } ;747 } 754 748 return array(); 755 749 }
