diff options
Diffstat (limited to 'admin')
-rw-r--r-- | admin/include/functions_metadata.php | 6 | ||||
-rw-r--r-- | admin/site_manager.php | 260 | ||||
-rw-r--r-- | admin/site_reader_local.php | 254 | ||||
-rw-r--r-- | admin/site_reader_remote.php | 191 | ||||
-rw-r--r-- | admin/site_update.php | 813 | ||||
-rw-r--r-- | admin/update.php | 2 |
6 files changed, 1523 insertions, 3 deletions
diff --git a/admin/include/functions_metadata.php b/admin/include/functions_metadata.php index 3979e0e40..23dca79a9 100644 --- a/admin/include/functions_metadata.php +++ b/admin/include/functions_metadata.php @@ -175,11 +175,13 @@ function update_metadata($files) * path in the filesystem * * @param int id_uppercat + * @param int site_id * @param boolean recursive ? * @param boolean only newly added files ? * @return array */ -function get_filelist($category_id = '', $recursive = false, $only_new = false) +function get_filelist($category_id = '', $site_id=1, $recursive = false, + $only_new = false) { // filling $cat_ids : all categories required $cat_ids = array(); @@ -187,7 +189,7 @@ function get_filelist($category_id = '', $recursive = false, $only_new = false) $query = ' SELECT id FROM '.CATEGORIES_TABLE.' - WHERE site_id = 1 + WHERE site_id = '.$site_id.' AND dir IS NOT NULL'; if (is_numeric($category_id)) { diff --git a/admin/site_manager.php b/admin/site_manager.php new file mode 100644 index 000000000..478041dbf --- /dev/null +++ b/admin/site_manager.php @@ -0,0 +1,260 @@ +<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2006-01-31 21:46:26 -0500 (Tue, 31 Jan 2006) $
+// | last modifier : $Author: rvelices $
+// | revision : $Revision: 1020 $
+// +-----------------------------------------------------------------------+
+// | 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. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die ("Hacking attempt!");
+}
+include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
+
+/**
+ * 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($lines = @file($url))
+ {
+ $template->assign_block_vars('remote_output', array());
+ // cleaning lines from HTML tags
+ foreach ($lines as $line)
+ {
+ $line = trim(strip_tags($line));
+ if (preg_match('/^PWG-([A-Z]+)-/', $line, $matches))
+ {
+ $template->assign_block_vars(
+ 'remote_output.remote_line',
+ array(
+ 'CLASS' => 'remote'.ucfirst(strtolower($matches[1])),
+ 'CONTENT' => $line
+ )
+ );
+ }
+ }
+ }
+ else
+ {
+ array_push($page['errors'], get_lang('remote_site_file_not_found'));
+ }
+}
+
+
+// +-----------------------------------------------------------------------+
+// | template init |
+// +-----------------------------------------------------------------------+
+$template->set_filenames(array('site_manager'=>'admin/site_manager.tpl'));
+
+// +-----------------------------------------------------------------------+
+// | new site creation form |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['submit']))
+{
+ $is_remote = url_is_remote( $_POST['galleries_url'] );
+ $url = preg_replace('/[\/]*$/', '', $_POST['galleries_url']);
+ $url.= '/';
+ if (! $is_remote)
+ {
+ if ( ! (strpos($url, '.') === 0 ) )
+ {
+ $url = './' . $url;
+ }
+ }
+
+ // site must not exists
+ $query = '
+SELECT COUNT(id) AS count
+ FROM '.SITES_TABLE.'
+ WHERE galleries_url = \''.$url.'\'
+;';
+ $row = mysql_fetch_array(pwg_query($query));
+ if ($row['count'] > 0)
+ {
+ array_push($page['errors'],
+ get_lang('remote_site_already_exists').' ['.$url.']');
+ }
+ if (count($page['errors']) == 0)
+ {
+ if ($is_remote)
+ {
+ $clf_url = $url.'create_listing_file.php';
+ $clf_url.= '?action=test';
+ $clf_url.= '&version='.PHPWG_VERSION;
+ if ($lines = @file($clf_url))
+ {
+ $first_line = strip_tags($lines[0]);
+ if (!preg_match('/^PWG-INFO-2:/', $first_line))
+ {
+ array_push($page['errors'],
+ get_lang('remote_site_error').' : '.$first_line);
+ }
+ }
+ else
+ {
+ array_push($page['errors'], get_lang('remote_site_file_not_found') );
+ }
+ }
+ else
+ { // local directory
+ if ( ! file_exists($url) )
+ {
+ array_push($page['errors'],
+ get_lang('Directory does not exist').' ['.$url.']');
+ }
+ }
+ }
+
+ if (count($page['errors']) == 0)
+ {
+ $query = '
+INSERT INTO '.SITES_TABLE.'
+ (galleries_url)
+ VALUES
+ (\''.$url.'\')
+;';
+ pwg_query($query);
+ array_push($page['infos'],
+ $url.' '.get_lang('remote_site_created'));
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | actions on site |
+// +-----------------------------------------------------------------------+
+if (isset($_GET['site']) and is_numeric($_GET['site']))
+{
+ $page['site'] = $_GET['site'];
+}
+if (isset($_GET['action']) and isset($page['site']) )
+{
+ $query = '
+SELECT galleries_url
+ FROM '.SITES_TABLE.'
+ WHERE id = '.$page['site'].'
+;';
+ list($galleries_url) = mysql_fetch_array(pwg_query($query));
+ switch($_GET['action'])
+ {
+ case 'generate' :
+ {
+ $title = $galleries_url.' : '.get_lang('remote_site_generate');
+ $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
+ remote_output($galleries_url.'create_listing_file.php?action=generate');
+ break;
+ }
+ case 'test' :
+ {
+ $title = $galleries_url.' : '.get_lang('remote_site_test');
+ $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
+ remote_output($galleries_url.'create_listing_file.php?action=test&version='.PHPWG_VERSION);
+ break;
+ }
+ case 'clean' :
+ {
+ $title = $galleries_url.' : '.get_lang('remote_site_clean');
+ $template->assign_vars(array('REMOTE_SITE_TITLE'=>$title));
+ remote_output($galleries_url.'create_listing_file.php?action=clean');
+ break;
+ }
+ case 'delete' :
+ {
+ delete_site($page['site']);
+ array_push($page['infos'],
+ $galleries_url.' '.get_lang('remote_site_deleted'));
+ break;
+ }
+ }
+}
+
+$template->assign_vars( array(
+ 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php'
+ .get_query_string_diff( array('action','site') )
+ ) );
+
+// +-----------------------------------------------------------------------+
+// | remote sites list |
+// +-----------------------------------------------------------------------+
+
+$query = '
+SELECT s.*, COUNT(c.id) AS nb_categories, SUM(c.nb_images) AS nb_images
+FROM '.SITES_TABLE.' AS s LEFT JOIN '.CATEGORIES_TABLE.' AS c
+ON s.id=c.site_id
+GROUP BY s.id'.
+';';
+$result = pwg_query($query);
+
+if (mysql_num_rows($result) > 0)
+{
+ $template->assign_block_vars('sites', array());
+}
+while ($row = mysql_fetch_array($result))
+{
+ $is_remote = url_is_remote($row['galleries_url']);
+ $base_url = PHPWG_ROOT_PATH.'admin.php';
+ $base_url.= '?page=site_manager';
+ $base_url.= '&site='.$row['id'];
+ $base_url.= '&action=';
+
+ $update_url = PHPWG_ROOT_PATH.'admin.php';
+ $update_url.= '?page=site_update';
+ $update_url.= '&site='.$row['id'];
+
+ $template->assign_block_vars(
+ 'sites.site',
+ array(
+ 'NAME' => $row['galleries_url'],
+ 'TYPE' => get_lang( $is_remote ? 'Remote' : 'Local' ),
+ 'CATEGORIES' => $row['nb_categories'],
+ 'IMAGES' => isset($row['nb_images']) ? $row['nb_images'] : 0,
+ 'U_UPDATE' => $update_url
+ )
+ );
+
+ if ($is_remote)
+ {
+ $template->assign_block_vars('sites.site.remote',
+ array(
+ 'U_TEST' => $base_url.'test',
+ 'U_GENERATE' => $base_url.'generate',
+ 'U_CLEAN' => $base_url.'clean'
+ )
+ );
+ }
+
+ if ($row['id'] != 1)
+ {
+ $template->assign_block_vars( 'sites.site.delete',
+ array('U_DELETE' => $base_url.'delete') );
+ }
+}
+
+$template->assign_var_from_handle('ADMIN_CONTENT', 'site_manager');
+?>
\ No newline at end of file diff --git a/admin/site_reader_local.php b/admin/site_reader_local.php new file mode 100644 index 000000000..758906777 --- /dev/null +++ b/admin/site_reader_local.php @@ -0,0 +1,254 @@ +<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2005-12-03 17:03:58 -0500 (Sat, 03 Dec 2005) $
+// | last modifier : $Author: plg $
+// | revision : $Revision: 967 $
+// +-----------------------------------------------------------------------+
+// | 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 the local file system
+class LocalSiteReader
+{
+
+var $site_url;
+
+function LocalSiteReader($url)
+{
+ $this->site_url = $url;
+}
+
+/**
+ * Is this local site ok ?
+ *
+ * @return true on success, false otherwise
+ */
+function open()
+{
+ global $errors;
+ if (!is_dir($this->site_url))
+ {
+ array_push($errors, array('path' => $this->site_url, 'type' => 'PWG-ERROR-NODIR'));
+ return false;
+ }
+ return true;
+}
+
+// retrieve file system sub-directories fulldirs
+function get_full_directories($basedir)
+{
+ $fs_fulldirs = get_fs_directories($basedir);
+ return $fs_fulldirs;
+}
+
+/**
+ * Returns an array with all file system files according to $conf['file_ext']
+ * and $conf['picture_ext']
+ * @param string $path recurse in this directory
+ * @return array like "pic.jpg"=>array('tn_ext'=>'jpg' ... )
+ */
+function get_elements($path)
+{
+ global $conf;
+ if (!isset($conf['flip_picture_ext']))
+ {
+ $conf['flip_picture_ext'] = array_flip($conf['picture_ext']);
+ }
+ if (!isset($conf['flip_file_ext']))
+ {
+ $conf['flip_file_ext'] = array_flip($conf['file_ext']);
+ }
+
+ $subdirs = array();
+ $fs = array();
+ if (is_dir($path) && $contents = opendir($path) )
+ {
+ while (($node = readdir($contents)) !== false)
+ {
+ if (is_file($path.'/'.$node))
+ {
+ $extension = get_extension($node);
+ $filename_wo_ext = get_filename_wo_extension($node);
+
+ // searching the thumbnail
+ $tn_ext = $this->get_tn_ext($path, $filename_wo_ext);
+
+ if (isset($conf['flip_picture_ext'][$extension]))
+ {
+ $fs[ $path.'/'.$node ] = array(
+ 'tn_ext' => $tn_ext,
+ 'has_high' => $this->get_has_high($path, $node)
+ );
+ }
+ else if (isset($conf['flip_file_ext'][$extension]))
+ { // file not a picture
+ $representative_ext = $this->get_representative_ext($path, $filename_wo_ext);
+
+ $fs[ $path.'/'.$node ] = array(
+ 'tn_ext' => $tn_ext,
+ 'representative_ext' => $representative_ext
+ );
+ }
+
+ }
+ elseif (is_dir($path.'/'.$node)
+ and $node != '.'
+ and $node != '..'
+ and $node != 'pwg_high'
+ and $node != 'pwg_representative'
+ and $node != 'thumbnail' )
+ {
+ array_push($subdirs, $node);
+ }
+ } //end while readdir
+ closedir($contents);
+
+ foreach ($subdirs as $subdir)
+ {
+ $tmp_fs = $this->get_elements($path.'/'.$subdir);
+ $fs = array_merge($fs, $tmp_fs);
+ }
+ } //end if is_dir
+ return $fs;
+}
+
+// returns the name of the attributes that are supported for
+// update/synchronization according to configuration
+function get_update_attributes()
+{
+ global $conf;
+ $update_fields = array( 'has_high', 'representative_ext',
+ 'filesize', 'width', 'height' );
+ if ($conf['use_exif'])
+ {
+ $update_fields =
+ array_merge(
+ $update_fields,
+ array_keys($conf['use_exif_mapping'])
+ );
+ }
+
+ if ($conf['use_iptc'])
+ {
+ $update_fields =
+ array_merge(
+ $update_fields,
+ array_keys($conf['use_iptc_mapping'])
+ );
+ }
+ return $update_fields;
+}
+
+// returns a hash of attributes (metadata+filesize+width,...) for file
+function get_element_update_attributes($file)
+{
+ global $conf;
+ if (!is_file($file))
+ {
+ return null;
+ }
+
+ $data = array();
+
+ $filename = basename($file);
+ $data['has_high'] = $this->get_has_high( dirname($file), $filename );
+ $data['representative_ext'] = $this->get_representative_ext( dirname($file),
+ get_filename_wo_extension($filename) );
+
+ $data['filesize'] = floor(filesize($file)/1024);
+ if ($image_size = @getimagesize($file))
+ {
+ $data['width'] = $image_size[0];
+ $data['height'] = $image_size[1];
+ }
+
+ if ($conf['use_exif'])
+ {
+ $exif = get_sync_exif_data($file);
+
+ if (count($exif) > 0)
+ {
+ foreach (array_keys($exif) as $key)
+ {
+ $data[$key] = addslashes($exif[$key]);
+ }
+ }
+ }
+
+ if ($conf['use_iptc'])
+ {
+ $iptc = get_sync_iptc_data($file);
+ if (count($iptc) > 0)
+ {
+ foreach (array_keys($iptc) as $key)
+ {
+ $data[$key] = addslashes($iptc[$key]);
+ }
+ }
+ }
+ return $data;
+}
+
+
+//-------------------------------------------------- private functions --------
+function get_representative_ext($path, $filename_wo_ext)
+{
+ global $conf;
+ $base_test = $path.'/pwg_representative/';
+ $base_test.= $filename_wo_ext.'.';
+ foreach ($conf['picture_ext'] as $ext)
+ {
+ $test = $base_test.$ext;
+ if (is_file($test))
+ {
+ return $ext;
+ }
+ }
+ return null;
+}
+
+function get_tn_ext($path, $filename_wo_ext)
+{
+ global $conf;
+ $base_test = $path.'/thumbnail/';
+ $base_test.= $conf['prefix_thumbnail'].$filename_wo_ext.'.';
+ foreach ($conf['picture_ext'] as $ext)
+ {
+ $test = $base_test.$ext;
+ if (is_file($test))
+ {
+ return $ext;
+ }
+ }
+ return null;
+}
+
+function get_has_high($path, $filename)
+{
+ if (is_file($path.'/pwg_high/'.$filename))
+ {
+ return 'true';
+ }
+ return null;
+}
+
+}
+?>
\ No newline at end of file diff --git a/admin/site_reader_remote.php b/admin/site_reader_remote.php new file mode 100644 index 000000000..c76a37d04 --- /dev/null +++ b/admin/site_reader_remote.php @@ -0,0 +1,191 @@ +<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2005-12-03 17:03:58 -0500 (Sat, 03 Dec 2005) $
+// | last modifier : $Author: plg $
+// | revision : $Revision: 967 $
+// +-----------------------------------------------------------------------+
+// | 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 $site_dirs;
+var $site_files;
+var $insert_attributes;
+var $update_attributes;
+
+function RemoteSiteReader($url)
+{
+ $this->site_url = $url;
+ $this->insert_attributes = array('tn_ext', 'representative_ext', 'has_high');
+ $this->update_attributes = array( 'representative_ext', 'has_high', 'filesize', 'width', 'height' );
+}
+
+/**
+ * Is this remote site ok ?
+ *
+ * @return true on success, false otherwise
+ */
+function open()
+{
+ global $errors;
+ $listing_file = $this->site_url.'/listing.xml';
+ if (@fopen($listing_file, 'r'))
+ {
+ $this->site_dirs = array();
+ $this->site_files = array();
+ $xml_content = getXmlCode($listing_file);
+ $info_xml_element = getChild($xml_content, 'informations');
+ if ( getAttribute($info_xml_element , 'phpwg_version') != PHPWG_VERSION )
+ {
+ array_push($errors, array('path' => $listing_file, 'type' => 'PWG-ERROR-VERSION'));
+ return false;
+ }
+ $meta_attributes = explode ( ',',
+ getAttribute($info_xml_element , 'metadata') );
+ $this->update_attributes = array_merge( $this->update_attributes, $meta_attributes );
+ $this->build_structure($xml_content, '', 0);
+ return true;
+ }
+ else
+ {
+ array_push($errors, array('path' => $listing_file, 'type' => 'PWG-ERROR-NO-FS'));
+ 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
+// update/synchronization according to listing.xml
+function get_update_attributes()
+{
+ return $this->update_attributes;
+}
+
+// returns a hash of attributes (metadata+filesize+width,...) for file
+function get_element_update_attributes($file)
+{
+ return $this->get_element_attributes($file,
+ $this->update_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) != '')
+ {
+ $data[$att] = getAttribute($xml_element, $att);
+ }
+ }
+ 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);
+ }
+ }
+}
+
+}
+
+?>
\ No newline at end of file diff --git a/admin/site_update.php b/admin/site_update.php new file mode 100644 index 000000000..5d37ed114 --- /dev/null +++ b/admin/site_update.php @@ -0,0 +1,813 @@ +<?php
+// +-----------------------------------------------------------------------+
+// | PhpWebGallery - a PHP based picture gallery |
+// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
+// +-----------------------------------------------------------------------+
+// | branch : BSF (Best So Far)
+// | file : $RCSfile$
+// | last update : $Date: 2005-12-03 17:03:58 -0500 (Sat, 03 Dec 2005) $
+// | last modifier : $Author: plg $
+// | revision : $Revision: 967 $
+// +-----------------------------------------------------------------------+
+// | 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. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die ('Hacking attempt!');
+}
+include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
+
+if (! is_numeric($_GET['site']) )
+{
+ die ('site param missing or invalid');
+}
+$site_id = $_GET['site'];
+$query='SELECT galleries_url FROM '.SITES_TABLE.'
+WHERE id='.$site_id.'
+;';
+list($site_url)=mysql_fetch_row(pwg_query($query));
+if (! isset($site_url) )
+{
+ die ("site $site_id does not exist");
+}
+$site_is_remote = url_is_remote($site_url);
+
+list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
+define('CURRENT_DATE', $dbnow);
+
+$error_labels = array(
+ 'PWG-UPDATE-1' => array( get_lang('update_wrong_dirname_short'),
+ get_lang('update_wrong_dirname_info') ),
+ 'PWG-UPDATE-2' => array( get_lang('update_missing_tn_short'),
+ get_lang('update_missing_tn_info')
+ . implode(',', $conf['picture_ext']) ),
+ 'PWG-ERROR-NO-FS' => array( get_lang('Does not exist'),
+ get_lang('update_missing_file_or_dir_info')),
+ 'PWG-ERROR-VERSION' => array( get_lang('Invalid PhpWebGalley version'),
+ get_lang('update_pwg_version_differs_info')),
+ 'PWG-ERROR-NOLISTING' => array( get_lang('remote_site_listing_not_found'),
+ get_lang('remote_site_listing_not_found_info'))
+ );
+$errors = array();
+$infos = array();
+
+if ($site_is_remote)
+{
+ include_once( PHPWG_ROOT_PATH.'admin/site_reader_remote.php');
+ $site_reader = new RemoteSiteReader($site_url);
+}
+else
+{
+ include_once( PHPWG_ROOT_PATH.'admin/site_reader_local.php');
+ $site_reader = new LocalSiteReader($site_url);
+}
+
+$general_failure=true;
+if (isset($_POST['submit']))
+{
+ if ($site_reader->open())
+ {
+ $general_failure = false;
+ }
+ // shall we simulate only
+ if (isset($_POST['simulate']) and $_POST['simulate'] == 1)
+ {
+ $simulate = true;
+ }
+ else
+ {
+ $simulate = false;
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | directories / categories |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['submit'])
+ and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
+ and !$general_failure)
+{
+ $counts['new_categories'] = 0;
+ $counts['del_categories'] = 0;
+ $counts['del_elements'] = 0;
+ $counts['new_elements'] = 0;
+
+ $start = get_moment();
+ // which categories to update ?
+ $cat_ids = array();
+
+ $query = '
+SELECT id, uppercats, global_rank, status, visible
+ FROM '.CATEGORIES_TABLE.'
+ WHERE dir IS NOT NULL
+ AND site_id = '.$site_id;
+ if (isset($_POST['cat']) and is_numeric($_POST['cat']))
+ {
+ if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1)
+ {
+ $query.= '
+ AND uppercats REGEXP \'(^|,)'.$_POST['cat'].'(,|$)\'
+';
+ }
+ else
+ {
+ $query.= '
+ AND id = '.$_POST['cat'].'
+';
+ }
+ }
+ $query.= '
+;';
+ $result = pwg_query($query);
+
+ $db_categories = array();
+ while ($row = mysql_fetch_array($result))
+ {
+ $db_categories[$row['id']] = $row;
+ }
+
+ // get categort full directories in an array for comparison with file
+ // system directory tree
+ $db_fulldirs = get_fulldirs(array_keys($db_categories));
+
+ // what is the base directory to search file system sub-directories ?
+ if (isset($_POST['cat']) and is_numeric($_POST['cat']))
+ {
+ $basedir = $db_fulldirs[$_POST['cat']];
+ }
+ else
+ {
+ $basedir = preg_replace('#/*$#', '', $site_url);
+ }
+
+ // we need to have fulldirs as keys to make efficient comparison
+ $db_fulldirs = array_flip($db_fulldirs);
+
+ // finding next rank for each id_uppercat. By default, each category id
+ // has 1 for next rank on its sub-categories to create
+ $next_rank['NULL'] = 1;
+
+ $query = '
+SELECT id
+ FROM '.CATEGORIES_TABLE.'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $next_rank[$row['id']] = 1;
+ }
+
+ // let's see if some categories already have some sub-categories...
+ $query = '
+SELECT id_uppercat, MAX(rank)+1 AS next_rank
+ FROM '.CATEGORIES_TABLE.'
+ GROUP BY id_uppercat
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ // for the id_uppercat NULL, we write 'NULL' and not the empty string
+ if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
+ {
+ $row['id_uppercat'] = 'NULL';
+ }
+ $next_rank[$row['id_uppercat']] = $row['next_rank'];
+ }
+
+ // next category id available
+ $query = '
+SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_id
+ FROM '.CATEGORIES_TABLE.'
+;';
+ list($next_id) = mysql_fetch_array(pwg_query($query));
+
+ // retrieve sub-directories fulldirs from the site reader
+ $fs_fulldirs = $site_reader->get_full_directories($basedir);
+ //print_r( $fs_fulldirs ); echo "<br>";
+
+ // get_full_directories doesn't include the base directory, so if it's a
+ // category directory, we need to include it in our array
+ if (isset($_POST['cat']))
+ {
+ array_push($fs_fulldirs, $basedir);
+ }
+
+ $inserts = array();
+ // new categories are the directories not present yet in the database
+ foreach (array_diff($fs_fulldirs, array_keys($db_fulldirs)) as $fulldir)
+ {
+ $dir = basename($fulldir);
+ if (preg_match('/^[a-zA-Z0-9-_.]+$/', $dir))
+ {
+ $insert = array();
+
+ $insert{'id'} = $next_id++;
+ $insert{'dir'} = $dir;
+ $insert{'name'} = str_replace('_', ' ', $dir);
+ $insert{'site_id'} = $site_id;
+ $insert{'commentable'} = $conf['newcat_default_commentable'];
+ if (! $site_is_remote)
+ {
+ $insert{'uploadable'} = $conf['newcat_default_uploadable'];
+ }
+ else
+ {
+ $insert{'uploadable'} = false;
+ }
+ $insert{'status'} = $conf{'newcat_default_status'};
+ $insert{'visible'} = $conf{'newcat_default_visible'};
+
+ if (isset($db_fulldirs[dirname($fulldir)]))
+ {
+ $parent = $db_fulldirs[dirname($fulldir)];
+
+ $insert{'id_uppercat'} = $parent;
+ $insert{'uppercats'} =
+ $db_categories[$parent]['uppercats'].','.$insert{'id'};
+ $insert{'rank'} = $next_rank[$parent]++;
+ $insert{'global_rank'} =
+ $db_categories[$parent]['global_rank'].'.'.$insert{'rank'};
+ if ('private' == $db_categories[$parent]['status'])
+ {
+ $insert{'status'} = 'private';
+ }
+ if ('false' == $db_categories[$parent]['visible'])
+ {
+ $insert{'visible'} = 'false';
+ }
+ }
+ else
+ {
+ $insert{'uppercats'} = $insert{'id'};
+ $insert{'rank'} = $next_rank['NULL']++;
+ $insert{'global_rank'} = $insert{'rank'};
+ }
+
+ array_push($inserts, $insert);
+ array_push($infos, array('path' => $fulldir,
+ 'info' => get_lang('update_research_added')));
+
+ // add the new category to $db_categories and $db_fulldirs array
+ $db_categories[$insert{'id'}] =
+ array(
+ 'id' => $insert{'id'},
+ 'status' => $insert{'status'},
+ 'visible' => $insert{'visible'},
+ 'uppercats' => $insert{'uppercats'},
+ 'global_rank' => $insert{'global_rank'}
+ );
+ $db_fulldirs[$fulldir] = $insert{'id'};
+ $next_rank[$insert{'id'}] = 1;
+ }
+ else
+ {
+ array_push($errors, array('path' => $fulldir, 'type' => 'PWG-UPDATE-1'));
+ }
+ }
+
+ if (count($inserts) > 0)
+ {
+ if (!$simulate)
+ {
+ $dbfields = array(
+ 'id','dir','name','site_id','id_uppercat','uppercats','commentable',
+ 'uploadable','visible','status','rank','global_rank'
+ );
+ mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
+ }
+
+ $counts['new_categories'] = count($inserts);
+ }
+
+ // to delete categories
+ $to_delete = array();
+ foreach (array_diff(array_keys($db_fulldirs), $fs_fulldirs) as $fulldir)
+ {
+ array_push($to_delete, $db_fulldirs[$fulldir]);
+ unset($db_fulldirs[$fulldir]);
+ array_push($infos, array('path' => $fulldir,
+ 'info' => get_lang('update_research_deleted')));
+ }
+ if (count($to_delete) > 0)
+ {
+ if (!$simulate)
+ {
+ delete_categories($to_delete);
+ }
+ $counts['del_categories'] = count($to_delete);
+ }
+
+ echo '<!-- scanning dirs : ';
+ echo get_elapsed_time($start, get_moment());
+ echo ' -->'."\n";
+}
+// +-----------------------------------------------------------------------+
+// | files / elements |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['submit']) and $_POST['sync'] == 'files'
+ and !$general_failure)
+{
+ $start_files = get_moment();
+ $start= $start_files;
+
+ $fs = $site_reader->get_elements($basedir);
+ //print_r($fs); echo "<br>";
+ echo '<!-- get_elements: '.get_elapsed_time($start, get_moment())." -->\n";
+
+ $cat_ids = array_diff(array_keys($db_categories), $to_delete);
+
+ $db_elements = array();
+ $db_unvalidated = array();
+
+ if (count($cat_ids) > 0)
+ {
+ $query = '
+SELECT id, path
+ FROM '.IMAGES_TABLE.'
+ WHERE storage_category_id IN (
+'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $db_elements[$row['id']] = $row['path'];
+ }
+
+ // searching the unvalidated waiting elements (they must not be taken into
+ // account)
+ $query = '
+SELECT file,storage_category_id
+ FROM '.WAITING_TABLE.'
+ WHERE storage_category_id IN (
+'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
+ AND validated = \'false\'
+;';
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ array_push(
+ $db_unvalidated,
+ array_search($row['storage_category_id'],
+ $db_fulldirs).'/'.$row['file']
+ );
+ }
+ }
+
+ // next element id available
+ $query = '
+SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
+ FROM '.IMAGES_TABLE.'
+;';
+ list($next_element_id) = mysql_fetch_array(pwg_query($query));
+
+ $start = get_moment();
+
+ $inserts = array();
+ $insert_links = array();
+
+ foreach (array_diff(array_keys($fs), $db_elements, $db_unvalidated) as $path)
+ {
+ $insert = array();
+ // storage category must exist
+ $dirname = dirname($path);
+ if (!isset($db_fulldirs[$dirname]))
+ {
+ continue;
+ }
+ $filename = basename($path);
+ if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
+ {
+ array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-1'));
+ continue;
+ }
+
+ // 2 cases : the element is a picture or not. Indeed, for a picture
+ // thumbnail is mandatory and for non picture element, thumbnail and
+ // representative are optionnal
+ if (in_array(get_extension($filename), $conf['picture_ext']))
+ {
+ // if we found a thumnbnail corresponding to our picture...
+ if ( isset($fs[$path]['tn_ext']) )
+ {
+ $insert{'id'} = $next_element_id++;
+ $insert{'file'} = $filename;
+ $insert{'storage_category_id'} = $db_fulldirs[$dirname];
+ $insert{'date_available'} = CURRENT_DATE;
+ $insert{'tn_ext'} = $fs[$path]['tn_ext'];
+ $insert{'has_high'} = $fs[$path]['has_high'];
+ $insert{'path'} = $path;
+
+ array_push($inserts, $insert);
+ array_push($insert_links,
+ array('image_id' => $insert{'id'},
+ 'category_id' => $insert{'storage_category_id'}));
+ array_push($infos, array('path' => $insert{'path'},
+ 'info' => get_lang('update_research_added')));
+ }
+ else
+ {
+ array_push($errors, array('path' => $path, 'type' => 'PWG-UPDATE-2'));
+ }
+ }
+ else
+ {
+ $insert{'id'} = $next_element_id++;
+ $insert{'file'} = $filename;
+ $insert{'storage_category_id'} = $db_fulldirs[$dirname];
+ $insert{'date_available'} = CURRENT_DATE;
+ $insert{'has_high'} = $fs[$path]['has_high'];
+ $insert{'path'} = $path;
+
+ if ( isset($fs[$path]['tn_ext']) )
+ {
+ $insert{'tn_ext'} = $fs[$path]['tn_ext'];
+ }
+ if (isset($fs[$path]['representative_ext']))
+ {
+ $insert{'representative_ext'} = $fs[$path]['representative_ext'];
+ }
+
+ array_push($inserts, $insert);
+ array_push($insert_links,
+ array('image_id' => $insert{'id'},
+ 'category_id' => $insert{'storage_category_id'}));
+ array_push($infos, array('path' => $insert{'path'},
+ 'info' => get_lang('update_research_added')));
+ }
+ }
+
+ if (count($inserts) > 0)
+ {
+ if (!$simulate)
+ {
+ // inserts all new elements
+ $dbfields = array(
+ 'id','file','storage_category_id','date_available','tn_ext'
+ ,'representative_ext', 'has_high', 'path'
+ );
+ mass_inserts(IMAGES_TABLE, $dbfields, $inserts);
+
+ // insert all links between new elements and their storage category
+ $dbfields = array('image_id','category_id');
+ mass_inserts(IMAGE_CATEGORY_TABLE, $dbfields, $insert_links);
+ }
+ $counts['new_elements'] = count($inserts);
+ }
+
+ // delete elements that are in database but not in the filesystem
+ $to_delete_elements = array();
+ foreach (array_diff($db_elements, array_keys($fs)) as $path)
+ {
+ array_push($to_delete_elements, array_search($path, $db_elements));
+ array_push($infos, array('path' => $path,
+ 'info' => get_lang('update_research_deleted')));
+ }
+ if (count($to_delete_elements) > 0)
+ {
+ if (!$simulate)
+ {
+ delete_elements($to_delete_elements);
+ }
+ $counts['del_elements'] = count($to_delete_elements);
+ }
+
+ echo '<!-- scanning files : ';
+ echo get_elapsed_time($start_files, get_moment());
+ echo ' -->'."\n";
+
+ // retrieving informations given by uploaders
+ if (!$simulate and count($cat_ids) > 0)
+ {
+ $query = '
+SELECT id,file,storage_category_id,infos
+ FROM '.WAITING_TABLE.'
+ WHERE storage_category_id IN (
+'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
+ AND validated = \'true\'
+;';
+ $result = pwg_query($query);
+
+ $datas = array();
+ $fields =
+ array(
+ 'primary' => array('id'),
+ 'update' => array('date_creation', 'author', 'name', 'comment')
+ );
+
+ $waiting_to_delete = array();
+
+ while ($row = mysql_fetch_array($result))
+ {
+ $data = array();
+
+ $query = '
+SELECT id
+ FROM '.IMAGES_TABLE.'
+ WHERE storage_category_id = \''.$row['storage_category_id'].'\'
+ AND file = \''.$row['file'].'\'
+;';
+ list($data['id']) = mysql_fetch_array(pwg_query($query));
+
+ foreach ($fields['update'] as $field)
+ {
+ $data[$field] = getAttribute($row['infos'], $field);
+ }
+
+ array_push($datas, $data);
+ array_push($waiting_to_delete, $row['id']);
+ }
+
+ if (count($datas) > 0)
+ {
+ mass_updates(IMAGES_TABLE, $fields, $datas);
+
+ // delete now useless waiting elements
+ $query = '
+DELETE
+ FROM '.WAITING_TABLE.'
+ WHERE id IN ('.implode(',', $waiting_to_delete).')
+;';
+ pwg_query($query);
+ }
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | synchronize files |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['submit'])
+ and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
+{
+ $template->assign_block_vars(
+ 'update_result',
+ array(
+ 'NB_NEW_CATEGORIES'=>$counts['new_categories'],
+ 'NB_DEL_CATEGORIES'=>$counts['del_categories'],
+ 'NB_NEW_ELEMENTS'=>$counts['new_elements'],
+ 'NB_DEL_ELEMENTS'=>$counts['del_elements'],
+ 'NB_ERRORS'=>count($errors),
+ ));
+
+ if (!$simulate)
+ {
+ $start = get_moment();
+ update_category('all');
+ echo '<!-- update_category(all) : ';
+ echo get_elapsed_time($start,get_moment());
+ echo ' -->'."\n";
+ $start = get_moment();
+ ordering();
+ update_global_rank();
+ echo '<!-- ordering categories : ';
+ echo get_elapsed_time($start, get_moment());
+ echo ' -->'."\n";
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | synchronize metadata |
+// +-----------------------------------------------------------------------+
+if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync'])
+ and !$general_failure)
+{
+ // sync only never synchronized files ?
+ if ($_POST['sync'] == 'metadata_new')
+ {
+ $opts['only_new'] = true;
+ }
+ else
+ {
+ $opts['only_new'] = false;
+ }
+ $opts['category_id'] = '';
+ $opts['recursive'] = true;
+
+ if (isset($_POST['cat']))
+ {
+ $opts['category_id'] = $_POST['cat'];
+ // recursive ?
+ if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
+ {
+ $opts['recursive'] = false;
+ }
+ }
+ $start = get_moment();
+ $files = get_filelist($opts['category_id'], $site_id,
+ $opts['recursive'],
+ $opts['only_new']);
+
+ echo '<!-- get_filelist : ';
+ echo get_elapsed_time($start, get_moment());
+ echo ' -->'."\n";
+
+ $start = get_moment();
+ $datas = array();
+ foreach ( $files as $id=>$file )
+ {
+ $data = $site_reader->get_element_update_attributes($file);
+ if ( is_array($data) )
+ {
+ $data['date_metadata_update'] = CURRENT_DATE;
+ $data['id']=$id;
+ array_push($datas, $data);
+ }
+ else
+ {
+ array_push($errors, array('path' => $file, 'type' => 'PWG-ERROR-NO-FS'));
+ }
+ }
+ $update_fields = $site_reader->get_update_attributes();
+ $update_fields = array_merge($update_fields, 'date_metadata_update');
+ $fields =
+ array(
+ 'primary' => array('id'),
+ 'update' => array_unique($update_fields)
+ );
+ //print_r($datas);
+ if (!$simulate and count($datas)>0 )
+ {
+ mass_updates(IMAGES_TABLE, $fields, $datas);
+ }
+
+ echo '<!-- metadata update : ';
+ echo get_elapsed_time($start, get_moment());
+ echo ' -->'."\n";
+
+ $template->assign_block_vars(
+ 'metadata_result',
+ array(
+ 'NB_ELEMENTS_DONE' => count($datas),
+ 'NB_ELEMENTS_CANDIDATES' => count($files),
+ 'NB_ERRORS' => count($errors),
+ ));
+}
+
+// +-----------------------------------------------------------------------+
+// | template initialization |
+// +-----------------------------------------------------------------------+
+$template->set_filenames(array('update'=>'admin/site_update.tpl'));
+$result_title = '';
+if (isset($simulate) and $simulate)
+{
+ $result_title.= get_lang('update_simulation_title').' ';
+}
+
+// used_metadata string is displayed to inform admin which metadata will be
+// used from files for synchronization
+$used_metadata = implode( ', ', $site_reader->get_update_attributes());
+if ($site_is_remote and !isset($_POST['submit']) )
+{
+ $used_metadata.= ' + ' . get_lang('Aditionnal remote attributes');
+}
+
+$template->assign_vars(
+ array(
+ 'SITE_URL'=>$site_url,
+ 'U_SITE_MANAGER'=> PHPWG_ROOT_PATH.'admin.php?page=site_manager',
+ 'L_RESULT_UPDATE'=>$result_title.get_lang('update_part_research'),
+ 'L_RESULT_METADATA'=>$result_title.get_lang('update_result_metadata'),
+ 'METADATA_LIST' => $used_metadata
+ ));
+
+$template->assign_vars(
+ array(
+ 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=synchronize'
+ )
+ );
+// +-----------------------------------------------------------------------+
+// | introduction : choices |
+// +-----------------------------------------------------------------------+
+if (!isset($_POST['submit']) or (isset($simulate) and $simulate))
+{
+ $template->assign_block_vars('introduction', array());
+
+ if (isset($simulate) and $simulate)
+ {
+ switch ($_POST['sync'])
+ {
+ case 'dirs' :
+ {
+ $template->assign_vars(
+ array('SYNC_DIRS_CHECKED'=>'checked="checked"'));
+ break;
+ }
+ case 'files' :
+ {
+ $template->assign_vars(
+ array('SYNC_ALL_CHECKED'=>'checked="checked"'));
+ break;
+ }
+ case 'metadata_new' :
+ {
+ $template->assign_vars(
+ array('SYNC_META_NEW_CHECKED'=>'checked="checked"'));
+ break;
+ }
+ case 'metadata_all' :
+ {
+ $template->assign_vars(
+ array('SYNC_META_ALL_CHECKED'=>'checked="checked"'));
+ break;
+ }
+ }
+
+ if (isset($_POST['display_info']) and $_POST['display_info'] == 1)
+ {
+ $template->assign_vars(
+ array('DISPLAY_INFO_CHECKED'=>'checked="checked"'));
+ }
+
+ if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1)
+ {
+ $template->assign_vars(
+ array('SUBCATS_INCLUDED_CHECKED'=>'checked="checked"'));
+ }
+
+ if (isset($_POST['cat']) and is_numeric($_POST['cat']))
+ {
+ $cat_selected = array($_POST['cat']);
+ }
+ else
+ {
+ $cat_selected = array();
+ }
+ }
+ else
+ {
+ $template->assign_vars(
+ array('SYNC_DIRS_CHECKED' => 'checked="checked"',
+ 'SUBCATS_INCLUDED_CHECKED'=>'checked="checked"'));
+
+ $cat_selected = array();
+ }
+
+ $query = '
+SELECT id,name,uppercats,global_rank
+ FROM '.CATEGORIES_TABLE.'
+ WHERE site_id = '.$site_id.'
+;';
+ display_select_cat_wrapper($query,
+ $cat_selected,
+ 'introduction.category_option',
+ false);
+}
+
+if (count($errors) > 0)
+{
+ $template->assign_block_vars('sync_errors', array());
+ foreach ($errors as $error)
+ {
+ $template->assign_block_vars(
+ 'sync_errors.error',
+ array(
+ 'ELEMENT' => $error['path'],
+ 'LABEL' => $error['type'].' ('.$error_labels[$error['type']][0].')'
+ ));
+ }
+
+ foreach ($error_labels as $error_type=>$error_description)
+ {
+ $template->assign_block_vars(
+ 'sync_errors.error_caption',
+ array(
+ 'TYPE' => $error_type,
+ 'LABEL' => $error_description[1]
+ ));
+ }
+
+}
+if (count($infos) > 0
+ and isset($_POST['display_info'])
+ and $_POST['display_info'] == 1)
+{
+ $template->assign_block_vars('sync_infos', array());
+ foreach ($infos as $info)
+ {
+ $template->assign_block_vars(
+ 'sync_infos.info',
+ array(
+ 'ELEMENT' => $info['path'],
+ 'LABEL' => $info['info']
+ ));
+ }
+}
+
+// +-----------------------------------------------------------------------+
+// | sending html code |
+// +-----------------------------------------------------------------------+
+$template->assign_var_from_handle('ADMIN_CONTENT', 'update');
+?>
\ No newline at end of file diff --git a/admin/update.php b/admin/update.php index bb7133000..f19bc8a9e 100644 --- a/admin/update.php +++ b/admin/update.php @@ -743,7 +743,7 @@ else if (isset($_POST['submit']) and preg_match('/^metadata/', $_POST['sync'])) } } $start = get_moment(); - $files = get_filelist($opts['category_id'], + $files = get_filelist($opts['category_id'], 1, $opts['recursive'], $opts['only_new']); |