- remake of Remote sites and Synchronize:

- synchronization for remote and local sites are done by the same code
  - remote sites can update metadata now (not before) - bug 279
  - fixes bug 82: has_high column

- improve feature 280: user sort by filename

- fix path to template mimetypes icons

- bug 284: session cookie lifetime, deletion on logout and corrected issue 
when db upgrades were missing 

git-svn-id: http://piwigo.org/svn/trunk@1029 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2006-02-08 01:17:07 +00:00
parent 687a7ca122
commit 0e78db47de
22 changed files with 1770 additions and 36 deletions

View file

@ -65,6 +65,7 @@ $template->set_filenames(array('admin' => 'admin.tpl'));
$template->assign_vars(
array(
'U_SITE_MANAGER'=> $link_start.'site_manager',
'U_HISTORY'=> $link_start.'stats',
'U_FAQ'=> $link_start.'help',
'U_SITES'=> $link_start.'remote_site',

View file

@ -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))
{

260
admin/site_manager.php Normal file
View file

@ -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.= '&amp;site='.$row['id'];
$base_url.= '&amp;action=';
$update_url = PHPWG_ROOT_PATH.'admin.php';
$update_url.= '?page=site_update';
$update_url.= '&amp;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');
?>

254
admin/site_reader_local.php Normal file
View file

@ -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;
}
}
?>

View file

@ -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);
}
}
}
}
?>

813
admin/site_update.php Normal file
View file

@ -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');
?>

View file

@ -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']);

View file

@ -37,7 +37,7 @@ if ( isset( $_GET['act'] )
$_SESSION = array();
session_unset();
session_destroy();
setcookie(session_name(),'',0,'/');
setcookie(session_name(),'',0, cookie_path() );
$url = 'category.php';
redirect( $url );
}

View file

@ -51,6 +51,7 @@ SELECT '.$conf['user_fields']['id'].' AS id,
{
$session_length = $conf['remember_me_length'];
}
session_set_cookie_params($session_length);
session_start();
$_SESSION['id'] = $row['id'];
redirect('category.php');

View file

@ -147,6 +147,7 @@ SELECT id
// which upgrades need to be applied?
if (count(array_diff($existing, $applied)) > 0)
{
ob_start();// buffer output so that cookies work
echo
'<p>'
.'Some database upgrades are missing, '

View file

@ -973,6 +973,20 @@ SELECT '.$conf['user_fields']['email'].'
return $email;
}
/**
* returns the $str in current language if possible or $str enclosed
* in special chars
*/
function get_lang($str)
{
global $lang;
if ( isset($lang[$str]) )
{
return $lang[$str];
}
return '@@'.$str.'@@';
}
/**
* which upgrades are available ?
*

View file

@ -321,13 +321,14 @@ SELECT galleries_url
// returns an array of image orders available for users/visitors
function get_category_preferred_image_orders()
{
global $lang, $conf;
global $conf;
return array(
array('Default', '', true),
array($lang['best_rated_cat'], 'average_rate DESC', $conf['rate']),
array($lang['most_visited_cat'], 'hit DESC', true),
array($lang['Creation date'], 'date_creation DESC', true),
array($lang['Availability date'], 'date_available DESC', true)
array(get_lang('best_rated_cat'), 'average_rate DESC', $conf['rate']),
array(get_lang('most_visited_cat'), 'hit DESC', true),
array(get_lang('Creation date'), 'date_creation DESC', true),
array(get_lang('Availability date'), 'date_available DESC', true),
array(get_lang('File name'), 'file ASC', true)
);
}

View file

@ -69,7 +69,25 @@ if (isset($conf['session_save_handler'])
ini_set('session.use_only_cookies', $conf['session_use_only_cookies']);
ini_set('session.use_trans_sid', intval($conf['session_use_trans_sid']));
ini_set('session.name', $conf['session_name']);
ini_set('session.cookie_path', dirname($_SERVER['PHP_SELF']));
ini_set('session.cookie_path', cookie_path() );
}
// cookie_path returns the path to use for the PhpWebGallery cookie.
// If PhpWebGallery is installed on :
// http://domain.org/meeting/gallery/category.php
// cookie_path will return : "/meeting/gallery"
function cookie_path()
{
if ( isset($_SERVER['REDIRECT_URL']) )
{ // mod_rewrite is activated for upper level directories. we must set the
// cookie to the path shown in the browser otherwise it will be discarded.
$scr = $_SERVER['REDIRECT_URL'];
}
else
{
$scr = $_SERVER['PHP_SELF'];
}
return substr($scr,0,strrpos( $scr,'/'));
}
/**

View file

@ -64,6 +64,7 @@ $lang['Email address'] = 'Email address';
$lang['Enter your personnal informations'] = 'Enter your personnal informations';
$lang['Error sending email'] = 'Error sending email';
$lang['File'] = 'File';
$lang['File name'] = 'File name';
$lang['Filesize'] = 'Filesize';
$lang['Filter and display'] = 'Filter and display';
$lang['Filter'] = 'Filter';

View file

@ -63,6 +63,7 @@ $lang['Email address'] = 'Adresse e-mail';
$lang['Enter your personnal informations'] = 'Entrer vos informations personnelles';
$lang['Error sending email'] = 'Erreur à l\'envoi du mail';
$lang['File'] = 'Fichier';
$lang['File name'] = 'Nom du fichier';
$lang['Filesize'] = 'Poids';
$lang['Filter and display'] = 'Filtrer et afficher';
$lang['Filter'] = 'Filtre';

View file

@ -249,20 +249,10 @@ foreach (array('prev', 'current', 'next') as $i)
// high quality picture
if ($i == 'current')
{
$url_high=$cat_directory.'/pwg_high/'.$row['file'];
if (url_is_remote($cat_directory))
if ($row['has_high']=='true')
{
if ($row['has_high'])
{
$picture[$i]['high'] = $url_high;
}
}
else
{
if (@fopen($url_high, 'r'))
{
$picture[$i]['high'] = $url_high;
}
$url_high=$cat_directory.'/pwg_high/'.$row['file'];
$picture[$i]['high'] = $url_high;
}
}
}
@ -1054,7 +1044,7 @@ if ($page['show_comments'])
// navigation bar creation
$url = PHPWG_ROOT_PATH.'picture.php';
$url.= get_query_string_diff(array('rate','add_fav'));
$url.= get_query_string_diff(array('rate','add_fav','start'));
if (!isset( $_GET['start'] )
or !is_numeric( $_GET['start'] )

View file

@ -14,6 +14,7 @@
<dd>
<ul>
<li><a href="{U_FAQ}">{lang:instructions}</a></li>
<li><a href="{U_SITE_MANAGER}">{lang:Site manager}</a></li>
<li><a href="{U_SITES}">{lang:remote_sites}</a></li>
<li><a href="{U_HISTORY}">{lang:history}</a></li>
<li><a href="{U_CAT_UPDATE}">{lang:update}</a></li>
@ -67,7 +68,7 @@
<div id="content">
<!-- BEGIN errors -->
<div id="errors">
<div class="errors">
<ul>
<!-- BEGIN error -->
<li>{errors.error.ERROR}</li>

View file

@ -0,0 +1,49 @@
<!-- $Id: remote_site.tpl 980 2005-12-10 15:24:53Z chrisaga $ -->
<div class="titrePage">
<ul class="categoryActions">
<li><a href="{U_HELP}" onclick="popuphelp(this.href); return false;" title="{lang:Help}"><img src="{themeconf:icon_dir}/help.png" class="button" alt="(?)"></a></li>
</ul>
<h2>{lang:remote_sites}</h2>
</div>
<!-- BEGIN remote_output -->
<div class="remoteOutput">
<ul>
<!-- BEGIN remote_line -->
<li class="{remote_output.remote_line.CLASS}">{remote_output.remote_line.CONTENT}</li>
<!-- END remote_line -->
</ul>
</div>
<!-- END remote_output -->
<!-- BEGIN sites -->
<table border="1" cellpadding="0" cellspacing="0">
<!-- BEGIN site -->
<tr align="left"><td>
<a href="{sites.site.NAME}" target="_blank">{sites.site.NAME}</a><br>({sites.site.TYPE}, {sites.site.CATEGORIES} {lang:categories}, {sites.site.IMAGES} {lang:picture}s)
</td><td>
[<a href="{sites.site.U_UPDATE}" title="{lang:update this site}">{lang:remote_site_update}</a>]
<!-- BEGIN delete -->
[<a href="{sites.site.delete.U_DELETE}" onclick="return confirm('{lang:remote_site_delete_hint}.\n{sites.site.NAME}\n{lang:Are you sure}?');"
title="{lang:remote_site_delete_hint}">{lang:remote_site_delete}</a>]
<!-- END delete -->
<!-- BEGIN remote -->
<br>
[<a href="{sites.site.remote.U_TEST}" title="{lang:@@}">{lang:Test}</a>]
[<a href="{sites.site.remote.U_GENERATE}" title="{lang:remote_site_generate_hint}">{lang:remote_site_generate}</a>]
[<a href="{sites.site.remote.U_CLEAN}" title="{lang:remote_site_clean_hint}">{lang:remote_site_clean}</a>]
<!-- END remote -->
</td></tr>
<!-- END site -->
</table>
<!-- END sites -->
<form action="{F_ACTION}" method="post">
<p>
<label for="galleries_url" >{lang:remote_site_create}</label>
<input type="text" name="galleries_url" id="galleries_url" />
</p>
<p>
<input type="submit" name="submit" value="{lang:submit}" />
</p>
</form>

View file

@ -0,0 +1,108 @@
<!-- $Id: update.tpl 980 2005-12-10 15:24:53Z chrisaga $ -->
<div class="titrePage">
<ul class="categoryActions">
<li><a href="{U_HELP}" onclick="popuphelp(this.href); return false;" title="{lang:Help}"><img src="{themeconf:icon_dir}/help.png" class="button" alt="(?)"></a></li>
</ul>
<h2>{lang:title_update}: <a href="{SITE_URL}" target="_blank">{SITE_URL}</a></h2>
</div>
<!-- BEGIN update_result -->
<h3>{L_RESULT_UPDATE}</h3>
<ul>
<li class="update_summary_new">{update_result.NB_NEW_CATEGORIES} {lang:update_nb_new_categories}</li>
<li class="update_summary_new">{update_result.NB_NEW_ELEMENTS} {lang:update_nb_new_elements}</li>
<li class="update_summary_del">{update_result.NB_DEL_CATEGORIES} {lang:update_nb_del_categories}</li>
<li class="update_summary_del">{update_result.NB_DEL_ELEMENTS} {lang:update_nb_del_elements}</li>
<li class="update_summary_err">{update_result.NB_ERRORS} {lang:update_nb_errors}</li>
</ul>
<!-- END update_result -->
<!-- BEGIN metadata_result -->
<h3>{L_RESULT_METADATA}</h3>
<ul>
<li>{metadata_result.NB_ELEMENTS_DONE} {lang:update_elements_metadata_sync}</li>
<li>{metadata_result.NB_ELEMENTS_CANDIDATES} {lang:elements available for synchronization}</li>
<li>{lang:update_used_metadata} : {METADATA_LIST}</li>
</ul>
<!-- END metadata_result -->
<!-- BEGIN sync_errors -->
<h3>{lang:update_error_list_title}</h3>
<div class="errors">
<ul>
<!-- BEGIN error -->
<li>[{sync_errors.error.ELEMENT}] {sync_errors.error.LABEL}</li>
<!-- END error -->
</ul>
</div>
<h3>{lang:update_errors_caption}</h3>
<ul>
<!-- BEGIN error_caption -->
<li><strong>{sync_errors.error_caption.TYPE}</strong>: {sync_errors.error_caption.LABEL}</li>
<!-- END error_caption -->
</ul>
<!-- END sync_errors -->
<!-- BEGIN sync_infos -->
<h3>{lang:update_infos_title}</h3>
<div class="infos">
<ul>
<!-- BEGIN info -->
<li>[{sync_infos.info.ELEMENT}] {sync_infos.info.LABEL}</li>
<!-- END sync_infos -->
</ul>
</div>
<!-- END infos -->
<!-- BEGIN introduction -->
<h3>{lang:update_default_title}</h3>
<form action="{F_ACTION}" method="post" id="update">
<fieldset>
<legend>{lang:update_sync_files}</legend>
<ul>
<li><label><input type="radio" name="sync" value="dirs" {SYNC_DIRS_CHECKED} /> {lang:update_sync_dirs}</label></li>
<li><label><input type="radio" name="sync" value="files" {SYNC_ALL_CHECKED} /> {lang:update_sync_all}</label></li>
<li><label><input type="checkbox" name="display_info" value="1" {DISPLAY_INFO_CHECKED} /> {lang:update_display_info}</label></li>
</ul>
</fieldset>
<fieldset>
<legend>{lang:update_sync_metadata}</legend>
{lang:update_used_metadata} : {METADATA_LIST}.<br/>
<ul>
<li><label><input type="radio" name="sync" value="metadata_new" {SYNC_META_NEW_CHECKED} /> {lang:update_sync_metadata_new}</label></li>
<li><label><input type="radio" name="sync" value="metadata_all" {SYNC_META_ALL_CHECKED} /> {lang:update_sync_metadata_all}</label></li>
</ul>
</fieldset>
<fieldset>
<legend></legend>
<ul><li><label><input type="checkbox" name="simulate" value="1" checked="checked" /> {lang:update_simulate}</label></li></ul>
</fieldset>
<fieldset>
<legend>{lang:update_cats_subset}</legend>
<ul>
<li>
<select style="width:500px" name="cat" size="10">
<!-- BEGIN category_option -->
<option {introduction.category_option.SELECTED} value="{introduction.category_option.VALUE}">{introduction.category_option.OPTION}</option>
<!-- END category_option -->
</select>
</li>
<li><label><input type="checkbox" name="subcats-included" value="1" {SUBCATS_INCLUDED_CHECKED} /> {lang:search_subcats_included}</label></li>
</ul>
</fieldset>
<p class="bottomButtons">
<input type="submit" value="{lang:submit}" name="submit" />
<input type="reset" value="{lang:reset}" name="reset" />
</p>
</form>
<!-- END introduction -->
<a href="{U_SITE_MANAGER}">{lang:Site manager}</a>

View file

@ -4,6 +4,6 @@ $themeconf = array(
'theme' => 'clear',
'icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon',
'admin_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/admin',
'mime_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/mymetypes'
'mime_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/mimetypes/'
);
?>

View file

@ -4,6 +4,6 @@ $themeconf = array(
'theme' => 'dark',
'icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon',
'admin_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/admin',
'mime_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/mymetypes'
'mime_icon_dir' => PHPWG_ROOT_PATH.'template/yoga/icon/mimetypes/'
);
?>

View file

@ -44,10 +44,14 @@ $conf['picture_ext'] = array('jpg','JPG','png','PNG','gif','GIF');
// listing.xml file and the PhpWebGallery version you're running
$conf['version'] = '%PWGVERSION%';
// $conf['use_exif'] set to true if you want to use Exif Date as "creation
// date" for the element, otherwise, set to false
// $conf['use_exif'] set to true if you want to use Exif information
$conf['use_exif'] = true;
// use_exif_mapping: same behaviour as use_iptc_mapping
$conf['use_exif_mapping'] = array(
'date_creation' => 'DateTimeOriginal'
);
// $conf['use_iptc'] set to true if you want to use IPTC informations of the
// element according to get_sync_iptc_data function mapping, otherwise, set
// to false
@ -320,6 +324,7 @@ function get_dirs($basedir, $indent, $level)
{
if ($file != '.'
and $file != '..'
and $file != '.svn'
and $file != 'thumbnail'
and $file != 'pwg_high'
and $file != 'pwg_representative'
@ -344,7 +349,7 @@ function get_dirs($basedir, $indent, $level)
$dirs.= get_dirs($basedir.'/'.$fs_dir, $indent.' ', $level + 1);
$dirs.= "\n".$indent.'</dir'.$level.'>';
}
return $dirs;
return $dirs;
}
// get_extension returns the part of the string after the last "."
@ -425,13 +430,25 @@ function get_pictures($dir, $indent)
{
if ($exif = @read_exif_data($dir.'/'.$fs_file))
{
if (isset($exif['DateTime']))
foreach ($conf['use_exif_mapping'] as $pwg_key => $exif_key )
{
preg_match('/^(\d{4}):(\d{2}):(\d{2})/'
,$exif['DateTime']
,$matches);
$element['date_creation'] =
$matches[1].'-'.$matches[2].'-'.$matches[3];
if (isset($exif[$exif_key]))
{
if ( in_array($pwg_key, array('date_creation','date_available') ) )
{
if (preg_match('/^(\d{4}):(\d{2}):(\d{2})/'
,$exif[$exif_key]
,$matches))
{
$element[$pwg_key] =
$matches[1].'-'.$matches[2].'-'.$matches[3];
}
}
else
{
$element[$pwg_key] = $exif[$exif_key];
}
}
}
}
}
@ -525,6 +542,17 @@ switch ($page['action'])
$listing.= ' generation_date="'.date('Y-m-d').'"';
$listing.= ' phpwg_version="'.$conf{'version'}.'"';
$attrs=array();
if ($conf['use_iptc'])
{
$attrs = array_merge($attrs, array_keys($conf['use_iptc_mapping']) );
}
if ($conf['use_exif'])
{
$attrs = array_merge($attrs, array_keys($conf['use_exif_mapping']) );
}
$listing.= ' metadata="'.implode(',',array_unique($attrs)).'"';
$end = strrpos($_SERVER['PHP_SELF'], '/') + 1;
$local_folder = substr($_SERVER['PHP_SELF'], 0, $end);
$page['url'] = 'http://'.$_SERVER['HTTP_HOST'].$local_folder;