Ignore:
Timestamp:
Mar 6, 2012, 9:27:41 PM (12 years ago)
Author:
rvelices
Message:

remove remote sites feature

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/site_manager.php

    r12922 r13488  
    3939}
    4040
    41 /**
    42  * requests the given $url (a remote create_listing_file.php) and fills a
    43  * list of lines corresponding to request output
    44  *
    45  * @param string $url
    46  * @return void
    47  */
    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 tags
    56     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' => $line
    66            )
    67          );
    68       }
    69     }
    70   }
    71   else
    72   {
    73     array_push($page['errors'], l10n('file create_listing_file.php on remote site was not found'));
    74   }
    75 }
    76 
    77 
    7841// +-----------------------------------------------------------------------+
    7942// |                             template init                             |
     
    8750{
    8851  $is_remote = url_is_remote( $_POST['galleries_url'] );
     52  if ($is_remote)
     53  {
     54    fatal_error('remote sites not supported');
     55  }
    8956  $url = preg_replace('/[\/]*$/', '', $_POST['galleries_url']);
    9057  $url.= '/';
    91   if (! $is_remote)
     58  if ( ! (strpos($url, '.') === 0 ) )
    9259  {
    93     if ( ! (strpos($url, '.') === 0 ) )
    94     {
    95       $url = './' . $url;
    96     }
     60    $url = './' . $url;
    9761  }
    9862
     
    11175  if (count($page['errors']) == 0)
    11276  {
    113     if ($is_remote)
     77    if ( ! file_exists($url) )
    11478    {
    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.']');
    14581    }
    14682  }
     
    177113  switch($_GET['action'])
    178114  {
    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     }
    197115    case 'delete' :
    198116    {
     
    212130    )
    213131  );
    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 }
    231132
    232133$query = '
     
    267168     );
    268169     
    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 
    279170  if ($row['id'] != 1)
    280171  {
     
    290181
    291182  $template->append('sites', $tpl_var);
    292 
    293   if ( isset($local_listing_site_url) and
    294        $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   }
    304183}
    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' => true
    312       )
    313     );
    314 }
    315 
    316184
    317185$template->assign_var_from_handle('ADMIN_CONTENT', 'site_manager');
Note: See TracChangeset for help on using the changeset viewer.