Changeset 13488 for trunk/admin/site_manager.php
- Timestamp:
- Mar 6, 2012, 9:27:41 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/site_manager.php
r12922 r13488 39 39 } 40 40 41 /**42 * requests the given $url (a remote create_listing_file.php) and fills a43 * list of lines corresponding to request output44 *45 * @param string $url46 * @return void47 */48 function remote_output($url)49 {50 global $template, $page;51 52 if (fetchRemote($url, $result))53 {54 $lines = explode("\r\n", $result);55 // cleaning lines from HTML tags56 foreach ($lines as $line)57 {58 $line = trim(strip_tags($line));59 if (preg_match('/^PWG-([A-Z]+)-/', $line, $matches))60 {61 $template->append(62 'remote_output',63 array(64 'CLASS' => 'remote'.ucfirst(strtolower($matches[1])),65 'CONTENT' => $line66 )67 );68 }69 }70 }71 else72 {73 array_push($page['errors'], l10n('file create_listing_file.php on remote site was not found'));74 }75 }76 77 78 41 // +-----------------------------------------------------------------------+ 79 42 // | template init | … … 87 50 { 88 51 $is_remote = url_is_remote( $_POST['galleries_url'] ); 52 if ($is_remote) 53 { 54 fatal_error('remote sites not supported'); 55 } 89 56 $url = preg_replace('/[\/]*$/', '', $_POST['galleries_url']); 90 57 $url.= '/'; 91 if ( ! $is_remote)58 if ( ! (strpos($url, '.') === 0 ) ) 92 59 { 93 if ( ! (strpos($url, '.') === 0 ) ) 94 { 95 $url = './' . $url; 96 } 60 $url = './' . $url; 97 61 } 98 62 … … 111 75 if (count($page['errors']) == 0) 112 76 { 113 if ( $is_remote)77 if ( ! file_exists($url) ) 114 78 { 115 if ( ! isset($_POST['no_check']) ) 116 { 117 $clf_url = $url.'create_listing_file.php'; 118 $get_data = array( 119 'action' => 'test', 120 'version' => PHPWG_VERSION, 121 ); 122 if (fetchRemote($clf_url, $result, $get_data)) 123 { 124 $lines = explode("\r\n", $result); 125 $first_line = strip_tags($lines[0]); 126 if (!preg_match('/^PWG-INFO-2:/', $first_line)) 127 { 128 array_push($page['errors'], 129 l10n('an error happened').' : '.$first_line); 130 } 131 } 132 else 133 { 134 array_push($page['errors'], l10n('file create_listing_file.php on remote site was not found') ); 135 } 136 } 137 } 138 else 139 { // local directory 140 if ( ! file_exists($url) ) 141 { 142 array_push($page['errors'], 143 l10n('Directory does not exist').' ['.$url.']'); 144 } 79 array_push($page['errors'], 80 l10n('Directory does not exist').' ['.$url.']'); 145 81 } 146 82 } … … 177 113 switch($_GET['action']) 178 114 { 179 case 'generate' :180 {181 $title = $galleries_url.' : '.l10n('generate listing');182 remote_output($galleries_url.'create_listing_file.php?action=generate');183 break;184 }185 case 'test' :186 {187 $title = $galleries_url.' : '.l10n('test');188 remote_output($galleries_url.'create_listing_file.php?action=test&version='.PHPWG_VERSION);189 break;190 }191 case 'clean' :192 {193 $title = $galleries_url.' : '.l10n('clean');194 remote_output($galleries_url.'create_listing_file.php?action=clean');195 break;196 }197 115 case 'delete' : 198 116 { … … 212 130 ) 213 131 ); 214 215 // +-----------------------------------------------------------------------+216 // | remote sites list |217 // +-----------------------------------------------------------------------+218 219 if ( is_file(PHPWG_ROOT_PATH.'listing.xml') )220 {221 $xml_content = getXmlCode(PHPWG_ROOT_PATH.'listing.xml');222 $local_listing_site_url = getAttribute(223 getChild($xml_content, 'informations'),224 'url'225 );226 if ( !url_is_remote($local_listing_site_url) )227 {228 $local_listing_site_url = null;229 }230 }231 132 232 133 $query = ' … … 267 168 ); 268 169 269 if ($is_remote)270 {271 $tpl_var['remote'] =272 array(273 'U_TEST' => $base_url.'test',274 'U_GENERATE' => $row['galleries_url'].'create_listing_file.php?action=generate',275 'U_CLEAN' => $base_url.'clean',276 );277 }278 279 170 if ($row['id'] != 1) 280 171 { … … 290 181 291 182 $template->append('sites', $tpl_var); 292 293 if ( isset($local_listing_site_url) and294 $row['galleries_url']==$local_listing_site_url )295 {296 $local_listing_site_id = $row['id'];297 $template->assign( 'local_listing',298 array(299 'URL' => $local_listing_site_url,300 'U_SYNCHRONIZE' => $update_url.'&local_listing=1'301 )302 );303 }304 183 } 305 306 if ( isset($local_listing_site_url) and !isset($local_listing_site_id) )307 {308 $template->assign( 'local_listing',309 array(310 'URL' => $local_listing_site_url,311 'CREATE' => true312 )313 );314 }315 316 184 317 185 $template->assign_var_from_handle('ADMIN_CONTENT', 'site_manager');
Note: See TracChangeset
for help on using the changeset viewer.