aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to 'admin')
-rw-r--r--admin/site_manager.php150
-rw-r--r--admin/site_reader_remote.php249
-rw-r--r--admin/site_update.php20
-rw-r--r--admin/themes/default/template/site_manager.tpl25
4 files changed, 9 insertions, 435 deletions
diff --git a/admin/site_manager.php b/admin/site_manager.php
index 8b2134b04..e4b318959 100644
--- a/admin/site_manager.php
+++ b/admin/site_manager.php
@@ -38,43 +38,6 @@ if (!empty($_POST) or isset($_GET['action']))
check_pwg_token();
}
-/**
- * requests the given $url (a remote create_listing_file.php) and fills a
- * list of lines corresponding to request output
- *
- * @param string $url
- * @return void
- */
-function remote_output($url)
-{
- global $template, $page;
-
- if (fetchRemote($url, $result))
- {
- $lines = explode("\r\n", $result);
- // cleaning lines from HTML tags
- foreach ($lines as $line)
- {
- $line = trim(strip_tags($line));
- if (preg_match('/^PWG-([A-Z]+)-/', $line, $matches))
- {
- $template->append(
- 'remote_output',
- array(
- 'CLASS' => 'remote'.ucfirst(strtolower($matches[1])),
- 'CONTENT' => $line
- )
- );
- }
- }
- }
- else
- {
- array_push($page['errors'], l10n('file create_listing_file.php on remote site was not found'));
- }
-}
-
-
// +-----------------------------------------------------------------------+
// | template init |
// +-----------------------------------------------------------------------+
@@ -86,14 +49,15 @@ $template->set_filenames(array('site_manager'=>'site_manager.tpl'));
if (isset($_POST['submit']) and !empty($_POST['galleries_url']))
{
$is_remote = url_is_remote( $_POST['galleries_url'] );
+ if ($is_remote)
+ {
+ fatal_error('remote sites not supported');
+ }
$url = preg_replace('/[\/]*$/', '', $_POST['galleries_url']);
$url.= '/';
- if (! $is_remote)
+ if ( ! (strpos($url, '.') === 0 ) )
{
- if ( ! (strpos($url, '.') === 0 ) )
- {
- $url = './' . $url;
- }
+ $url = './' . $url;
}
// site must not exists
@@ -110,38 +74,10 @@ SELECT COUNT(id) AS count
}
if (count($page['errors']) == 0)
{
- if ($is_remote)
+ if ( ! file_exists($url) )
{
- if ( ! isset($_POST['no_check']) )
- {
- $clf_url = $url.'create_listing_file.php';
- $get_data = array(
- 'action' => 'test',
- 'version' => PHPWG_VERSION,
- );
- if (fetchRemote($clf_url, $result, $get_data))
- {
- $lines = explode("\r\n", $result);
- $first_line = strip_tags($lines[0]);
- if (!preg_match('/^PWG-INFO-2:/', $first_line))
- {
- array_push($page['errors'],
- l10n('an error happened').' : '.$first_line);
- }
- }
- else
- {
- array_push($page['errors'], l10n('file create_listing_file.php on remote site was not found') );
- }
- }
- }
- else
- { // local directory
- if ( ! file_exists($url) )
- {
- array_push($page['errors'],
- l10n('Directory does not exist').' ['.$url.']');
- }
+ array_push($page['errors'],
+ l10n('Directory does not exist').' ['.$url.']');
}
}
@@ -176,24 +112,6 @@ SELECT galleries_url
list($galleries_url) = pwg_db_fetch_row(pwg_query($query));
switch($_GET['action'])
{
- case 'generate' :
- {
- $title = $galleries_url.' : '.l10n('generate listing');
- remote_output($galleries_url.'create_listing_file.php?action=generate');
- break;
- }
- case 'test' :
- {
- $title = $galleries_url.' : '.l10n('test');
- remote_output($galleries_url.'create_listing_file.php?action=test&version='.PHPWG_VERSION);
- break;
- }
- case 'clean' :
- {
- $title = $galleries_url.' : '.l10n('clean');
- remote_output($galleries_url.'create_listing_file.php?action=clean');
- break;
- }
case 'delete' :
{
delete_site($page['site']);
@@ -212,23 +130,6 @@ $template->assign(
)
);
-// +-----------------------------------------------------------------------+
-// | remote sites list |
-// +-----------------------------------------------------------------------+
-
-if ( is_file(PHPWG_ROOT_PATH.'listing.xml') )
-{
- $xml_content = getXmlCode(PHPWG_ROOT_PATH.'listing.xml');
- $local_listing_site_url = getAttribute(
- getChild($xml_content, 'informations'),
- 'url'
- );
- if ( !url_is_remote($local_listing_site_url) )
- {
- $local_listing_site_url = null;
- }
-}
-
$query = '
SELECT c.site_id, COUNT(DISTINCT c.id) AS nb_categories, COUNT(i.id) AS nb_images
FROM '.CATEGORIES_TABLE.' AS c LEFT JOIN '.IMAGES_TABLE.' AS i
@@ -266,16 +167,6 @@ while ($row = pwg_db_fetch_assoc($result))
'U_SYNCHRONIZE' => $update_url
);
- if ($is_remote)
- {
- $tpl_var['remote'] =
- array(
- 'U_TEST' => $base_url.'test',
- 'U_GENERATE' => $row['galleries_url'].'create_listing_file.php?action=generate',
- 'U_CLEAN' => $base_url.'clean',
- );
- }
-
if ($row['id'] != 1)
{
$tpl_var['U_DELETE'] = $base_url.'delete';
@@ -289,30 +180,7 @@ while ($row = pwg_db_fetch_assoc($result))
$tpl_var['plugin_links'] = $plugin_links;
$template->append('sites', $tpl_var);
-
- if ( isset($local_listing_site_url) and
- $row['galleries_url']==$local_listing_site_url )
- {
- $local_listing_site_id = $row['id'];
- $template->assign( 'local_listing',
- array(
- 'URL' => $local_listing_site_url,
- 'U_SYNCHRONIZE' => $update_url.'&local_listing=1'
- )
- );
- }
}
-if ( isset($local_listing_site_url) and !isset($local_listing_site_id) )
-{
- $template->assign( 'local_listing',
- array(
- 'URL' => $local_listing_site_url,
- 'CREATE' => true
- )
- );
-}
-
-
$template->assign_var_from_handle('ADMIN_CONTENT', 'site_manager');
?>
diff --git a/admin/site_reader_remote.php b/admin/site_reader_remote.php
deleted file mode 100644
index bec4c63ee..000000000
--- a/admin/site_reader_remote.php
+++ /dev/null
@@ -1,249 +0,0 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | Piwigo - a PHP based photo gallery |
-// +-----------------------------------------------------------------------+
-// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
-// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
-// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
-// +-----------------------------------------------------------------------+
-// | This program is free software; you can redistribute it and/or modify |
-// | it under the terms of the GNU General Public License as published by |
-// | the Free Software Foundation |
-// | |
-// | This program is distributed in the hope that it will be useful, but |
-// | WITHOUT ANY WARRANTY; without even the implied warranty of |
-// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
-// | General Public License for more details. |
-// | |
-// | You should have received a copy of the GNU General Public License |
-// | along with this program; if not, write to the Free Software |
-// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
-// | USA. |
-// +-----------------------------------------------------------------------+
-
-
-// provides data for site synchronization from a remote listing.xml
-class RemoteSiteReader
-{
-
-var $site_url;
-var $listing_url;
-var $site_dirs;
-var $site_files;
-var $insert_attributes;
-var $metadata_attributes;
-
-function RemoteSiteReader($url, $listing_url)
-{
- $this->site_url = $url;
- $this->insert_attributes = array(
- 'tn_ext',
- );
- $this->update_attributes = array(
- 'tn_ext', 'representative_ext', 'has_high',
- );
- $this->metadata_attributes = array(
- 'filesize', 'width', 'height', 'high_filesize', 'high_width', 'high_height',
- );
-
- if (!isset($listing_url))
- {
- $this->listing_url = $this->site_url.'listing.xml';
- }
- else
- {
- $this->listing_url = $listing_url;
- }
-}
-
-/**
- * Is this remote site ok ?
- *
- * @return true on success, false otherwise
- */
-function open()
-{
- global $errors;
-
- if ($xml_content = getXmlCode($this->listing_url))
- {
- $this->site_dirs = array();
- $this->site_files = array();
- $info_xml_element = getChild($xml_content, 'informations');
- if (getAttribute($info_xml_element , 'phpwg_version') != PHPWG_VERSION)
- {
- array_push(
- $errors,
- array(
- 'path' => $this->listing_url,
- 'type' => 'PWG-ERROR-VERSION'
- )
- );
-
- return false;
- }
-
- $additional_metadata = getAttribute($info_xml_element, 'metadata');
-
- if ($additional_metadata != '')
- {
- $this->metadata_attributes = array_merge(
- $this->metadata_attributes,
- explode(',', $additional_metadata)
- );
- }
-
- $this->build_structure($xml_content, '', 0);
-
- return true;
- }
- else
- {
- array_push(
- $errors,
- array(
- 'path' => $this->listing_url,
- 'type' => 'PWG-ERROR-NOLISTING'
- )
- );
-
- return false;
- }
-}
-
-// retrieve xml sub-directories fulldirs
-function get_full_directories($basedir)
-{
- $dirs = array();
- foreach ( array_keys($this->site_dirs) as $dir)
- {
- $full_dir = $this->site_url . $dir;
- if ($full_dir != $basedir
- and strpos($full_dir, $basedir) === 0
- )
- {
- array_push($dirs, $full_dir);
- }
- }
- return $dirs;
-}
-
-/**
- * Returns a hash with all elements (images and files) inside the full $path
- * according to listing.xml
- * @param string $path recurse in this directory only
- * @return array like "pic.jpg"=>array('tn_ext'=>'jpg' ... )
- */
-function get_elements($path)
-{
- $elements = array();
- foreach ( $this->site_dirs as $dir=>$files)
- {
- $full_dir = $this->site_url . $dir;
- if (strpos($full_dir, $path) === 0)
- {
- foreach ($files as $file)
- {
- $data = $this->get_element_attributes(
- $file,
- $this->insert_attributes
- );
- $elements[$file] = $data;
- }
- }
- }
-
- return $elements;
-}
-
-// returns the name of the attributes that are supported for
-// files update/synchronization
-function get_update_attributes()
-{
- return $this->update_attributes;
-}
-
-function get_element_update_attributes($file)
-{
- return $this->get_element_attributes(
- $file,
- $this->update_attributes
- );
-}
-
-// returns the name of the attributes that are supported for
-// metadata update/synchronization according to listing.xml
-function get_metadata_attributes()
-{
- return $this->metadata_attributes;
-}
-
-// returns a hash of attributes (metadata+width,...) for file
-function get_element_metadata($file, $has_high = false)
-{
- return $this->get_element_attributes(
- $file,
- $this->metadata_attributes
- );
-}
-
-//-------------------------------------------------- private functions --------
-/**
- * Returns a hash of image/file attributes
- * @param string $file fully qualified file name
- * @param array $attributes specifies which attributes to retrieve
- * returned
-*/
-function get_element_attributes($file, $attributes)
-{
- $xml_element = $this->site_files[$file];
- if (!isset($xml_element))
- {
- return null;
- }
- $data = array();
- foreach($attributes as $att)
- {
- if (getAttribute($xml_element, $att) != '')
- {
- $val = getAttribute($xml_element, $att);
- $data[$att] = addslashes($val);
- }
- }
- return $data;
-}
-
-// recursively parse the xml_content for later usage
-function build_structure($xml_content, $basedir, $level)
-{
- $temp_dirs = getChildren($xml_content, 'dir'.$level);
- foreach ($temp_dirs as $temp_dir)
- {
- $dir_name = $basedir;
- if ($dir_name != '' )
- {
- $dir_name .= '/';
- }
- $dir_name .= getAttribute($temp_dir, 'name');
- $this->site_dirs[ $dir_name ] = array();
- $this->build_structure($temp_dir, $dir_name, $level+1);
- }
-
- if ($basedir != '')
- {
- $xml_elements = getChildren(
- getChild($xml_content, 'root'),
- 'element'
- );
- foreach ($xml_elements as $xml_element)
- {
- $path = getAttribute($xml_element, 'path');
- $this->site_files[$path] = $xml_element;
- array_push($this->site_dirs[$basedir], $path);
- }
- }
-}
-
-}
-
-?>
diff --git a/admin/site_update.php b/admin/site_update.php
index 2021ac984..2861dc81f 100644
--- a/admin/site_update.php
+++ b/admin/site_update.php
@@ -58,22 +58,10 @@ $error_labels = array(
l10n('wrong filename'),
l10n('The name of directories and files must be composed of letters, numbers, "-", "_" or "."')
),
- 'PWG-UPDATE-2' => array(
- l10n('missing thumbnail'),
- l10n('a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory "thumbnail" of the album directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :').implode(',', $conf['picture_ext'])
- ),
'PWG-ERROR-NO-FS' => array(
l10n('File/directory read error'),
l10n('The file or directory cannot be accessed (either it does not exist or the access is denied)')
),
- 'PWG-ERROR-VERSION' => array(
- l10n('Piwigo version differs on the remote site'),
- l10n('Version of create_listing_file.php on the remote site and Piwigo must be the same')
- ),
- 'PWG-ERROR-NOLISTING' => array(
- l10n('listing.xml file was not found'),
- l10n('listing.xml file was not found on the remote site. This file is generated by choosing the "generate listing" command in the Site manager')
- )
);
$errors = array();
$infos = array();
@@ -81,14 +69,6 @@ $infos = array();
if ($site_is_remote)
{
fatal_error('remote sites not supported');
- include_once(PHPWG_ROOT_PATH.'admin/site_reader_remote.php');
- $local_listing = null;
- if ( isset($_GET['local_listing'])
- and $_GET['local_listing'] )
- {
- $local_listing = PHPWG_ROOT_PATH.'listing.xml';
- }
- $site_reader = new RemoteSiteReader($site_url, $local_listing);
}
else
{
diff --git a/admin/themes/default/template/site_manager.tpl b/admin/themes/default/template/site_manager.tpl
index 50320b935..b881220db 100644
--- a/admin/themes/default/template/site_manager.tpl
+++ b/admin/themes/default/template/site_manager.tpl
@@ -12,25 +12,6 @@
</div>
{/if}
-{if isset($local_listing)}
-{'A local listing.xml file has been found for'|@translate} {$local_listing.URL}
-{if isset($local_listing.CREATE)}
-<form action="{$F_ACTION}" method="post">
- <p>
- <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
- {'Create this site'|@translate}:
- <input type="hidden" name="no_check" value="1">
- <input type="hidden" name="galleries_url" value="{$local_listing.URL}">
- <input type="submit" name="submit" value="{'Submit'|@translate}">
- </p>
-</form>
-{/if}
-{if isset($local_listing.U_SYNCHRONIZE)}
-&nbsp;<a href="{$local_listing.U_SYNCHRONIZE}" title="{'read local listing.xml and update'|@translate}">{'Synchronize'|@translate}</a>
-<br><br>
-{/if}
-{/if}
-
{if not empty($sites)}
<table class="table2">
<tr class="throw">
@@ -46,12 +27,6 @@
[<a href="{$site.U_DELETE}" onclick="return confirm('{'Are you sure?'|@translate|escape:'javascript'}');"
title="{'delete this site and all its attached elements'|@translate}">{'delete'|@translate}</a>]
{/if}
- {if isset($site.remote)}
- <br>
- [<a href="{$site.remote.U_TEST}" title="{'test this remote site'|@translate}">{'test'|@translate}</a>]
- [<a href="{$site.remote.U_GENERATE}" title="{'generate file listing.xml on remote site'|@translate}">{'generate listing'|@translate}</a>]
- [<a href="{$site.remote.U_CLEAN}" title="{'remove remote listing.xml file'|@translate}">{'clean'|@translate}</a>]
- {/if}
{if not empty($site.plugin_links)}
<br>
{foreach from=$site.plugin_links item=plugin_link}