Changeset 12801 for extensions/add_index/admin/main_page.php
- Timestamp:
- Dec 28, 2011, 11:44:37 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/add_index/admin/main_page.php
r5196 r12801 1 1 <?php 2 2 // +-----------------------------------------------------------------------+ 3 // | Piwigo - a PHP based picture gallery | 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | 3 // | Add Index - a Piwigo Plugin | 4 // | Copyright (C) 2019-2011 Piwigo team | 8 5 // +-----------------------------------------------------------------------+ 9 6 // | This program is free software; you can redistribute it and/or modify | … … 51 48 * @return array 52 49 */ 53 function get_add_index_directories($path , $recursive = true)54 { 55 $dirs = array( );50 function get_add_index_directories($path) 51 { 52 $dirs = array($path); 56 53 57 54 if (is_dir($path)) … … 68 65 ) 69 66 { 70 array_push($dirs, $path.'/'.$node); 71 if ($recursive) 72 { 73 $dirs = array_merge($dirs, get_add_index_directories($path.'/'.$node)); 74 } 67 $dirs = array_merge($dirs, get_add_index_directories($path.'/'.$node)); 75 68 } 76 69 } … … 87 80 $index_file_src=$conf['add_index_source_directory_path'].$conf['add_index_filename']; 88 81 $overwrite_file=isset($_GET['overwrite']); 89 $site_id = (isset($_GET['site_id']) and is_numeric($_GET['site_id']) 90 ? $_GET['site_id'] 91 : 0); 82 $site_id=((isset($_GET['site_id']) and is_numeric($_GET['site_id'])) ? $_GET['site_id'] : 0); 92 83 93 84 // Init values … … 96 87 $count_skip = 0; 97 88 $count_error = 0; 89 $dir_list=array(); 98 90 99 91 if (@file_exists($index_file_src)) 100 92 { 93 if (empty($site_id)) 94 { 95 $dir_list[] = $conf['upload_dir']; 96 } 97 101 98 $query = ' 102 99 select … … 120 117 while (list($galleries_url) = mysql_fetch_row($result)) 121 118 { 122 if (!url_is_remote($galleries_url)) 119 $dir_list[] = $galleries_url; 120 } 121 } 122 123 foreach ($dir_list as $galleries_url) 124 { 125 //~ echo $galleries_url.'<BR>'; 126 if (!url_is_remote($galleries_url)) 127 { 128 foreach (get_add_index_directories($galleries_url) as $dir_galleries) 123 129 { 124 //echo $galleries_url.'<BR>';125 foreach (get_add_index_directories($galleries_url) as $dir_galleries)130 $file_dest = str_replace('//', '/', $dir_galleries.'/'.$conf['add_index_filename']); 131 if ($overwrite_file or !@file_exists($file_dest)) 126 132 { 127 $file_dest = str_replace('//', '/', $dir_galleries.'/'.$conf['add_index_filename']); 128 if ($overwrite_file or !@file_exists($file_dest)) 133 if (copy($index_file_src, $file_dest)) 129 134 { 130 if (copy($index_file_src, $file_dest)) 131 { 132 array_push($add_index_results, 133 sprintf(l10n('add_index_file_copied'), $file_dest)); 134 $count_copy++; 135 } 136 else 137 { 138 array_push($page['errors'], 139 sprintf(l10n('add_index_file_not_copied'), $file_dest)); 140 $count_error++; 141 } 135 array_push($add_index_results, 136 sprintf(l10n('add_index_file_copied'), $file_dest)); 137 $count_copy++; 142 138 } 143 139 else 144 140 { 145 $count_skip++; 141 array_push($page['errors'], 142 sprintf(l10n('add_index_file_not_copied'), $file_dest)); 143 $count_error++; 146 144 } 147 145 } 146 else 147 { 148 $count_skip++; 149 } 148 150 } 149 else 151 } 152 else 153 { 154 if (!empty($site_id)) 150 155 { 151 if (!empty($site_id)) 152 { 153 array_push($page['errors'], 154 sprintf(l10n('add_index_not_local_site'), 155 $galleries_url, $site_id)); 156 } 156 array_push($page['errors'], 157 sprintf(l10n('add_index_not_local_site'), 158 $galleries_url, $site_id)); 157 159 } 158 160 }
Note: See TracChangeset
for help on using the changeset viewer.