@@ -46,12 +27,6 @@
[{'delete'|@translate}]
{/if}
- {if isset($site.remote)}
-
- [{'test'|@translate}]
- [{'generate listing'|@translate}]
- [{'clean'|@translate}]
- {/if}
{if not empty($site.plugin_links)}
{foreach from=$site.plugin_links item=plugin_link}
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 2e4052ce9..77e00dd6a 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -25,7 +25,6 @@ include_once( PHPWG_ROOT_PATH .'include/functions_user.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_cookie.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_session.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_category.inc.php' );
-include_once( PHPWG_ROOT_PATH .'include/functions_xml.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_html.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_tag.inc.php' );
include_once( PHPWG_ROOT_PATH .'include/functions_url.inc.php' );
diff --git a/include/functions_xml.inc.php b/include/functions_xml.inc.php
deleted file mode 100644
index 00d69f3f8..000000000
--- a/include/functions_xml.inc.php
+++ /dev/null
@@ -1,134 +0,0 @@
-Joe" ) returns "Joe"
-//
-// It also works with strings containing themself sub-tags :
-// JeanBillie ->
-// JeanBillie
-function getContent( $element )
-{
- // deleting start of the tag
- $content = preg_replace( '/^<[^>]+>/', '', $element );
- // deleting end of the tag
- $content = preg_replace( '/<\/[^>]+>$/', '', $content );
- // replacing multiple instance of space character
- $content = preg_replace( '/\s+/', ' ', $content );
-
- return $content;
-}
-
-// The function get Attribute returns the value corresponding to the
-// attribute $attribute for the tag $element.
-function getAttribute( $element, $attribute )
-{
-// echo htmlentities($element).'
';
- $regex = '/^<\w+[^>]*\b'.$attribute.'\s*=\s*"('.VAL_REG.')"/i';
- if ( preg_match( $regex, $element, $out ) )
- {
- return html_entity_decode($out[1], ENT_QUOTES);
- }
- else return '';
-}
-
-// The function encode Attribute returns the xml attribute $attribute="$value"
-function encodeAttribute( $attribute, $value )
-{
- return $attribute.'="'.htmlspecialchars($value, ENT_QUOTES).'" ';
-}
-
-// The function getChild returns the first child
-// exemple : getChild( "
XXX
YYY
", "tr" )
-// returns "
XXX
"
-function getChild( $document, $node )
-{
- $regex = '/<'.$node.'(\s+'.ATT_REG.'="'.VAL_REG.'")*';
- $regex.= '(\s*\/>|>.*<\/'.$node.'>)/U';
-
- if
- (
- preg_match( $regex, $document, $out )
- or
- preg_last_error() == PREG_NO_ERROR
- )
- {
- return $out[0];
- }
- else
- {
- die('getChild: error ['.preg_last_error().'] with preg_match function');
- }
-}
-
-// getChildren returns a list of the children identified by the $node
-// example :
-// getChild( "
XXX
YYY
", "tr" )
-// returns an array with :
-// $array[0] equals "
XXX
"
-// $array[1] equals "
YYY
"
-function getChildren( $document, $node )
-{
- $regex = '/<'.$node.'(\s+'.ATT_REG.'="'.VAL_REG.'")*';
- $regex.= '(\s*\/>|>.*<\/'.$node.'>)/U';
-
- if
- (
- preg_match_all( $regex, $document, $out )
- or
- preg_last_error() == PREG_NO_ERROR
- )
- {
- return $out[0];
- }
- else
- {
- die('getChild: error ['.preg_last_error().'] with preg_match_all function');
- }
-}
-
-// get_CodeXML places the content of a text file in a PHP variable and
-// return it. If the file can't be opened, returns false.
-function getXmlCode( $filename )
-{
- if (function_exists('ini_set'))
- {
- // limit must be growed with php5 and "big" listing file
- ini_set("pcre.backtrack_limit", pow(2, 31));
- }
-
- if (!fetchRemote($filename, $xml_content))
- {
- return false;
- }
-
- $xml_content = str_replace( "\n", '', $xml_content );
- $xml_content = str_replace( "\t", '', $xml_content );
-
- return $xml_content;
-}
-?>
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index b74698a68..b46825c60 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -85,9 +85,7 @@ $lang['(this tag will be deleted)'] = '(this tag will be deleted)';
$lang['+ Add an upload box'] = '+ Add an upload box';
$lang[', click on'] = ", click on";
$lang['... or '] = '... or ';
-$lang['A local listing.xml file has been found for'] = "A local listing.xml file has been found for";
$lang['A new version of Piwigo is available.'] = "A new version of Piwigo is available.";
-$lang['a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory "thumbnail" of the album directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :'] = "a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory \"thumbnail\" of the album directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :";
$lang['Access type'] = "Access type";
$lang['ACCESS_0'] = "Free access";
$lang['ACCESS_1'] = "Access to all";
@@ -298,7 +296,6 @@ $lang['existing album'] = 'existing album';
$lang['Extend for templates'] = "Extend templates";
$lang['Extensions Update'] = 'Extensions Update';
$lang['Failed to write file to disk'] = 'Failed to write file to disk';
-$lang['file create_listing_file.php on remote site was not found'] = "file create_listing_file.php not found on the remote site";
$lang['File upload stopped by extension'] = 'File upload stopped by extension';
$lang['File'] = "File";
$lang['File/directory read error'] = "File/directory read error";
@@ -318,8 +315,6 @@ $lang['Gallery title'] = "Gallery title";
$lang['GD library is missing'] = "GD library is missing";
$lang['GD version'] = "GD version";
$lang['General statistics'] = "General statistics";
-$lang['generate file listing.xml on remote site'] = "generate file listing.xml on the remote site";
-$lang['generate listing'] = "generate listing";
$lang['Get Support on Piwigo Forum'] = 'Get support on Piwigo forum';
$lang['Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'] = 'Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation';
$lang['global mode'] = "global mode";
@@ -404,8 +399,6 @@ $lang['Level 8'] = "Admins";
$lang['Link all album photos to a new album'] = "Link all album photos to a new album";
$lang['Link all album photos to some existing albums'] = "Link all album photos to some existing albums";
$lang['Linked albums'] = "Linked albums";
-$lang['listing.xml file was not found on the remote site. This file is generated by choosing the "generate listing" command in the Site manager'] = "listing.xml file not found on the remote site. This file is generated with the \"generate listing\" command in the Site manager";
-$lang['listing.xml file was not found'] = "listing.xml file not found";
$lang['Local'] = "Local";
$lang['Lock albums'] = "Lock albums";
$lang['Lock gallery'] = "Lock gallery";
@@ -448,7 +441,6 @@ $lang['Minimum privacy level'] = "Minimum privacy level";
$lang['Miscellaneous'] = 'Miscellaneous';
$lang['Missing a temporary folder'] = 'Missing a temporary folder';
$lang['Missing Plugins'] = 'Missing Plugins';
-$lang['missing thumbnail'] = "missing thumbnail";
$lang['Modify information'] = "Modify information";
$lang['Month'] = "Month";
$lang['Move albums'] = "Move albums";
@@ -541,7 +533,6 @@ $lang['Piwigo cannot retrieve upgrade file from server'] = 'Piwigo cannot retrie
$lang['Piwigo configuration'] = "Piwigo configuration";
$lang['Piwigo Update'] = 'Piwigo Update';
$lang['Piwigo Uploader'] = 'Piwigo Uploader';
-$lang['Piwigo version differs on the remote site'] = "Piwigo version differs on the remote site";
$lang['Piwigo version'] = "Piwigo version";
$lang['pixels'] = 'pixels';
$lang['Please check "plugins" folder and sub-folders permissions (CHMOD).'] = "Please check \"plugins\" folder and sub-folders permissions (CHMOD).";
@@ -577,7 +568,6 @@ $lang['Rate date'] = "Rate date";
$lang['Rate'] = "Rate";
$lang['Rating by guests'] = "Rating by guests";
$lang['Rating'] = "Rating";
-$lang['read local listing.xml and update'] = "read local listing.xml and update";
$lang['Read Piwigo Documentation'] = 'Read Piwigo Documentation';
$lang['reduce to single existing albums'] = "reduce to single existing albums";
$lang['Refresh photo set'] = 'Refresh photo set';
@@ -593,7 +583,6 @@ $lang['Remove all filters'] = 'Remove all filters';
$lang['remove author'] = 'remove author';
$lang['remove creation date'] = 'remove creation date';
$lang['Remove from caddie'] = 'Remove from caddie';
-$lang['remove remote listing.xml file'] = "remove remote listing.xml file";
$lang['remove tags'] = "remove tags";
$lang['remove this filter'] = 'remove this filter';
$lang['remove title'] = 'remove title';
@@ -778,7 +767,6 @@ $lang['user_status_normal'] = "User";
$lang['user_status_webmaster'] = "Webmaster";
$lang['Validate'] = "Validate";
$lang['Validation'] = "Validation";
-$lang['Version of create_listing_file.php on the remote site and Piwigo must be the same'] = "Versions of create_listing_file.php on the remote site and Piwigo must be the same";
$lang['Version'] = "Version";
$lang['Virtual album added'] = "Virtual album added";
$lang['Virtual album deleted'] = "Virtual album deleted";
diff --git a/tools/create_listing_file.php b/tools/create_listing_file.php
deleted file mode 100644
index 62ce048ef..000000000
--- a/tools/create_listing_file.php
+++ /dev/null
@@ -1,1713 +0,0 @@
- 'DateTimeOriginal'
- );
-
-// ****** IPTC support functionality ****** //
-// $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
-$conf['use_iptc'] = false;
-
-// use_iptc_mapping : in which IPTC fields will Piwigo find image
-// information ? This setting is used during metadata synchronisation. It
-// associates a piwigo_images column name to a IPTC key
-$conf['use_iptc_mapping'] = array(
- 'keywords' => '2#025',
- 'date_creation' => '2#055',
- 'author' => '2#122',
- 'name' => '2#005',
- 'comment' => '2#120');
-
-// ****** Directory protection functionality ****** //
-// Define if directories have to be protected if they are not
-$conf['protect'] = false;
-
-// true/false : show/hide warnings
-$conf['protect_warnings'] = true;
-
-// ****** Thumbnails generation functionality ****** //
-// Define if images have to be reduced if they are not
-$conf['thumbnail'] = false;
-
-// Define method to generate thumbnails :
-// - fixed (width and height required);
-// - width (only width required);
-// - height (only height required);
-// - ratio (only ratio is required)
-// - exif (no other parameter required)
-$conf['thumbnail_method'] = 'ratio';
-
-// Height in pixels (greater than 0)
-$conf['thumbnail_height'] = 128;
-
-// Width in pixels (greater than 0)
-$conf['thumbnail_width'] = 128;
-
-// Ratio between original and thumbnail size (strictly between 0 and 1)
-$conf['thumbnail_ratio'] = 0.2;
-
-// Define thumbnail format : jpeg, png or gif (will be verified)
-$conf['thumbnail_format'] = 'jpeg';
-
-// ****** Directory mapping ****** //
-// directories names
-$conf['thumbs'] = 'thumbnail'; // thumbnails
-$conf['high'] = 'pwg_high'; // high resolution
-$conf['represent'] = 'pwg_representative'; // non pictures representative files
-
-
-// +-----------------------------------------------------------------------+
-// | Overload configurations |
-// +-----------------------------------------------------------------------+
-@include(dirname(__FILE__).'/'.basename(__FILE__, '.php').'_local.inc.php');
-
-
-// +-----------------------------------------------------------------------+
-// | Advanced script configuration |
-// +-----------------------------------------------------------------------+
-
-// url of icon directory in yoga template
-$pwg_conf['icon_dir'] = $conf['gallery'].'/template/yoga/icon/';
-
-// list of actions managed by this script
-$pwg_conf['scan_action'] = array('clean', 'test', 'generate');
-
-// url of this script
-$pwg_conf['this_url'] =
- (empty($_SERVER['HTTPS']) ? 'http://' : 'https://')
- .str_replace(':'.$_SERVER['SERVER_PORT'], '', $_SERVER['HTTP_HOST'])
- .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : '')
- .$_SERVER['PHP_SELF'];
-
-// list of reserved directory names
-$pwg_conf['reserved_directory_names'] = array($conf['thumbs'], $conf['high'], $conf['represent'], ".", "..", ".svn");
-
-// content of index.php generated in protect action
-$pwg_conf['protect_content'] = '';
-
-// backup of PHP safe_mode INI parameter (used for time limitation)
-$pwg_conf['safe_mode'] = (ini_get('safe_mode') == '1') ? true : false;
-
-// This parameter will be fixed in pwg_init()
-$pwg_conf['gd_version_major'] = '';
-$pwg_conf['gd_version_full'] = '';
-$pwg_conf['gd_supported_format'] = array();
-
-// +-----------------------------------------------------------------------+
-// | Functions |
-// +-----------------------------------------------------------------------+
-
-/**
- * write line in log file
- *
- * @param string line
- * @return string
- */
-function pwg_log($line)
-{
- $log_file = fopen(__FILE__.'.log', 'a');
- fwrite($log_file, $line);
- fclose($log_file);
-}
-
-/**
- * Check web server graphical capabilities
- *
- * @return string
- */
-function pwg_check_graphics()
-{
- //~ pwg_log('>>>>> pwg_check_graphics() >>>>>'."\n");
-
- global $conf, $pwg_conf;
- $log = '';
-
- // Verify gd library for thumbnail generation
- if ($conf['thumbnail'] and !is_callable('gd_info'))
- {
- $log .= ' Warning - Your server can not generate thumbnails. Thumbnail creation switched off. '."\n";
- // Switch off thumbnail generation
- $conf['thumbnail'] = false;
- return $log;
- }
-
- // Verify thumnail format
- if ($conf['thumbnail'])
- {
- $info = gd_info();
-
- // Backup GD major version
- $pwg_conf['gd_version_full'] = preg_replace('/[[:alpha:][:space:]()]+/', '', $info['GD Version']);
- list($pwg_conf['gd_version_major']) = preg_split('/[.]+/', $pwg_conf['gd_version_full']);
-
- // Backup input/output format support
- array_push($pwg_conf['gd_supported_format'], (isset($info['JPG Support']) and $info['JPG Support']) or (isset($info['JPEG Support']) and $info['JPEG Support']) ? 'jpeg' : NULL);
- array_push($pwg_conf['gd_supported_format'], $info['PNG Support'] ? 'png' : NULL);
- array_push($pwg_conf['gd_supported_format'], ($info['GIF Read Support'] and $info['GIF Create Support']) ? 'gif' : NULL);
-
- // Check output format support
- if (!in_array($conf['thumbnail_format'], $pwg_conf['gd_supported_format']))
- {
- $log .= ' Warning - Your server does not support thumbnail\'s ';
- $log .= $conf['thumbnail_format'].' format. Thumbnail creation switched off. '."\n";
- }
-
- switch ($conf['thumbnail_method'])
- {
- case 'exif':
- {
- // exif_thumbnail() must be callable
- if (!is_callable('exif_thumbnail'))
- {
- $log .= ' Warning - Your server does not support thumbnail creation through EXIF datas. Thumbnail creation switched off. '."\n";
- }
- break;
- }
- case 'fixed':
- {
- // $conf['thumbnail_width'] > 0
- if (!is_numeric($conf['thumbnail_width']) or $conf['thumbnail_width'] <= 0)
- {
- $log .= ' Failure - Bad value thumbnail_width = ';
- $log .= var_export($conf['thumbnail_width'], true).'. Thumbnail creation switched off. '."\n";
- }
- // $conf['thumbnail_height'] > 0
- if (!is_numeric($conf['thumbnail_height']) or $conf['thumbnail_height'] <= 0)
- {
- $log .= ' Failure - Bad value thumbnail_height = ';
- $log .= var_export($conf['thumbnail_height'], true).'. Thumbnail creation switched off. '."\n";
- }
- break;
- }
- case 'ratio':
- {
- // 0 < $conf['thumbnail_ratio'] < 1
- if (!is_numeric($conf['thumbnail_ratio']) or $conf['thumbnail_ratio'] <= 0 or $conf['thumbnail_ratio'] >= 1)
- {
- $log .= ' Failure - Bad value thumbnail_ratio = ';
- $log .= var_export($conf['thumbnail_ratio'], true).'. Thumbnail creation switched off. '."\n";
- }
- break;
- }
- case 'width':
- {
- // $conf['thumbnail_width'] > 0
- if (!is_numeric($conf['thumbnail_width']) or $conf['thumbnail_width'] <= 0)
- {
- $log .= ' Failure - Bad value thumbnail_width = ';
- $log .= var_export($conf['thumbnail_width'], true).'. Thumbnail creation switched off. '."\n";
- }
- break;
- }
- case 'height':
- {
- // $conf['thumbnail_height'] > 0
- if (!is_numeric($conf['thumbnail_height']) or $conf['thumbnail_height'] <= 0)
- {
- $log .= ' Failure - Bad value thumbnail_height = ';
- $log .= var_export($conf['thumbnail_height'], true).'. Thumbnail creation switched off. '."\n";
- }
- break;
- }
- default:
- {
- // unknown method
- $log .= ' Failure - Bad value thumbnail_method = ';
- $log .= var_export($conf['thumbnail_method'], true).'. Thumbnail creation switched off. '."\n";
- break;
- }
- }
-
- if (strlen($log))
- {
- $conf['thumbnail'] = false;
- }
- }
-
- //~ pwg_log('<<<<< pwg_check_graphics() returns '.var_export($log, TRUE).' <<<<<'."\n");
- return $log;
-}
-
-/**
- * returns xml lines
- *
- * @param integer $dir_start
- * @param integer $dir_number
- * @return string
- */
-function pwg_close_level($dir_start, $dir_number)
-{
- //~ pwg_log('>>>>> pwg_close_level($dir_start = '.var_export($dir_start, TRUE).', $dir_number = '.var_export($dir_number, TRUE).') >>>>>'."\n");
-
- $lines ='';
- do
- {
- $lines .= str_repeat(' ', 2*$dir_start).'\n";
- $dir_number--;
- $dir_start--;
- }
- while(($dir_number > 0) && ($dir_start >= 0));
-
- //~ pwg_log('<<<<< pwg_close_level returns '.var_export($lines, TRUE).' <<<<<'."\n");
- return $lines;
-}
-
-/**
- * return a cleaned IPTC value
- *
- * @param string value
- * @return string
- */
-function pwg_clean_iptc_value($value)
-{
- //~ pwg_log('>>>>> pwg_clean_iptc_value ($value = '.var_export($value, TRUE).') >>>>>'."\n");
-
- // strip leading zeros (weird Kodak Scanner software)
- while (isset($value[0]) and $value[0] == chr(0))
- {
- $value = substr($value, 1);
- }
- // remove binary nulls
- $value = str_replace(chr(0x00), ' ', $value);
-
- //~ pwg_log('<<<<< pwg_clean_iptc_value() returns '.var_export($value, TRUE).' <<<<<'."\n");
- return $value;
-}
-
-/**
- * returns informations from IPTC metadata, mapping is done at the beginning
- * of the function
- *
- * @param string $filename
- * @param string $map
- * @return array
- */
-function pwg_get_iptc_data($filename, $map)
-{
- //~ pwg_log('>>>>> pwg_get_iptc_data ($filename = '.var_export($filename, TRUE).', $map = '.var_export($map, TRUE).') >>>>>'."\n");
-
- $result = array();
-
- // Read IPTC data
- $iptc = array();
-
- $imginfo = array();
- getimagesize($filename, $imginfo);
-
- if (isset($imginfo['APP13']))
- {
- $iptc = iptcparse($imginfo['APP13']);
- if (is_array($iptc))
- {
- $rmap = array_flip($map);
- foreach (array_keys($rmap) as $iptc_key)
- {
- if (isset($iptc[$iptc_key][0]))
- {
- if ($iptc_key == '2#025')
- {
- $value = implode(',', array_map('pwg_clean_iptc_value', $iptc[$iptc_key]));
- }
- else
- {
- $value = pwg_clean_iptc_value($iptc[$iptc_key][0]);
- }
-
- foreach (array_keys($map, $iptc_key) as $pwg_key)
- {
- $result[$pwg_key] = $value;
- }
- }
- }
- }
- }
-
- //~ pwg_log('<<<<< pwg_get_iptc_data() returns '.var_export($result, TRUE).' <<<<<'."\n");
- return $result;
-}
-
-/**
- * returns informations from IPTC metadata
- *
- * @param string $file
- * @return array iptc
- */
-function pwg_get_sync_iptc_data($file)
-{
- //~ pwg_log('>>>>> pwg_get_sync_iptc_data ($file = '.var_export($file, TRUE).') >>>>>'."\n");
-
- global $conf;
-
- $map = $conf['use_iptc_mapping'];
- $datefields = array('date_creation', 'date_available');
-
- $iptc = pwg_get_iptc_data($file, $map);
-
- foreach ($iptc as $pwg_key => $value)
- {
- if (in_array($pwg_key, $datefields))
- {
- if ( preg_match('/(\d{4})(\d{2})(\d{2})/', $value, $matches))
- {
- $value = $matches[1].'-'.$matches[2].'-'.$matches[3];
- }
- }
- if ($pwg_key == 'keywords')
- {
- // official keywords separator is the comma
- $value = preg_replace('/[.;]/', ',', $value);
- $value = preg_replace('/^,+|,+$/', '', $value);
- }
- $iptc[$pwg_key] = htmlentities($value);
- }
-
- $iptc['keywords'] = isset($iptc['keywords']) ? implode(',', array_unique(explode(',', $iptc['keywords']))) : NULL;
-
- //~ pwg_log('<<<<< pwg_get_sync_iptc_data() returns '.var_export($iptc, TRUE).' <<<<<'."\n");
- return $iptc;
-}
-
-/**
- * return extension of the representative file
- *
- * @param string $file_dir
- * @param string $file_short
- * @return string
- */
-function pwg_get_representative_ext($file_dir, $file_short)
-{
- //~ pwg_log('>>>>> pwg_get_representative_ext($file_dir = '.var_export($file_dir, TRUE).', $file_short = '.var_export($file_short, TRUE).') >>>>>'."\n");
-
- global $conf;
-
- $rep_ext = '';
- foreach ($conf['picture_ext'] as $ext)
- {
- if (file_exists($file_dir.'/'.$conf['represent'].'/'.$file_short.'.'.$ext))
- {
- $rep_ext = $ext;
- break;
- }
- }
-
- //~ pwg_log('<<<<< pwg_get_representative_ext() returns '.var_export($rep_ext, TRUE).' <<<<<'."\n");
- return $rep_ext;
-}
-
-/**
- * return 'true' if high resolution picture exists else ''
- *
- * @param string $file_dir
- * @param string $file_base
- * @return boolean
- */
-function pwg_get_high($file_dir, $file_base)
-{
- //~ pwg_log('>>>>> pwg_get_high($file = '.var_export($file_dir, TRUE).', $line = '.var_export($file_base, TRUE).') >>>>>'."\n");
-
- global $conf;
-
- $high = false;
- if (file_exists($file_dir.'/'.$conf['high'].'/'.$file_base))
- {
- $high = true;
- }
-
- //~ pwg_log('<<<<< pwg_get_high() returns '.var_export($high, TRUE).' <<<<<'."\n");
- return $high;
-}
-
-/**
- * return filename without extension
- *
- * @param string $filename
- * @return string
- */
-function pwg_get_filename_wo_extension($filename)
-{
- //~ pwg_log('>>>>> _get_filename_wo_extension($filename = '.var_export($filename, TRUE).') >>>>>'."\n");
-
- $short_name = substr($filename, 0, strrpos($filename, '.'));
-
- //~ pwg_log('<<<<< _get_filename_wo_extension() returns '.var_export($short_name, TRUE).' <<<<<'."\n");
- return $short_name;
-}
-
-/**
- * return extension of the thumbnail and complete error_log
- *
- * @param string $file_dir
- * @param string $file_short
- * @param string $file_ext
- * @param string &$error_log
- * @return string
- */
-function pwg_get_thumbnail_ext($file_dir, $file_short, $file_ext, &$error_log, &$icon_log)
-{
- //~ pwg_log('>>>>> pwg_get_thumbnail_ext($file_dir = '.var_export($file_dir, TRUE).', $file_short = '.var_export($file_short, TRUE).') >>>>>'."\n");
-
- global $conf;
-
- $thumb_ext = '';
- foreach ($conf['picture_ext'] as $ext)
- {
- if (file_exists($file_dir.'/'.$conf['thumbs'].'/'.$conf['prefix_thumbnail'].$file_short.'.'.$ext))
- {
- $thumb_ext = $ext;
- break;
- }
- }
-
- if ($thumb_ext == '')
- {
- if ($conf['thumbnail'])
- {
- $log = pwg_icon_file($file_dir, $file_short, $file_ext);
- if (strpos($log, 'success'))
- {
- $thumb_ext = $conf['thumbnail_format'];
- }
- $icon_log .= $log;
- }
- }
-
- //~ pwg_log('<<<<< pwg_get_thumbnail_ext() returns '.var_export($thumb_ext, TRUE).' <<<<<'."\n");
- return $thumb_ext;
-}
-
-
-/**
- * return error logs
- *
- * @param string $file_dir
- * @param string $file_short
- * @param string $file_ext
- * @return string
- */
-function pwg_icon_file($file_dir, $file_short, $file_ext)
-{
- //~ pwg_log('>>>>> pwg_icon_file($file_dir = '.var_export($file_dir, TRUE).', $file_short = '.var_export($file_short, TRUE).') >>>>>'."\n");
-
- global $conf, $pwg_conf;
-
- $error_log = '';
-
- // Create thumbnail directory if not exists
- if (!file_exists($file_dir.'/'.$conf['thumbs']))
- {
- mkdir($file_dir.'/'.$conf['thumbs']);
- }
-
- // Get original properties (width, height)
- if ($image_size = getimagesize($file_dir.'/'.$file_short.'.'.$file_ext))
- {
- $src_width = $image_size[0];
- $src_height = $image_size[1];
- }
- else
- {
- $error_log .= ' Failure - Can not generate icon for ';
- $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.'';
- $error_log .= ' '."\n";
- return $error_log;
- }
-
- // Check input format
- $dst_format = $conf['thumbnail_format'];
- $src_format = ($file_ext == 'jpg' or $file_ext == 'JPG') ? 'jpeg' : strtolower($file_ext);
- if (!in_array($src_format, $pwg_conf['gd_supported_format']))
- {
- $error_log .= ' Failure - Can not generate icon for ';
- $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.'';
- $error_log .= ' '."\n";
- return $error_log;
- }
-
- // Calculate icon properties (width, height)
- switch ($conf['thumbnail_method'])
- {
- case 'fixed':
- {
- $dst_width = $conf['thumbnail_width'];
- $dst_height = $conf['thumbnail_height'];
- break;
- }
- case 'width':
- {
- $dst_width = $conf['thumbnail_width'];
- $dst_height = $dst_width * $src_height / $src_width;
- break;
- }
- case 'height':
- {
- $dst_height = $conf['thumbnail_height'];
- $dst_width = $dst_height * $src_width / $src_height;
- break;
- }
- case 'ratio':
- {
- $dst_width = round($src_width * $conf['thumbnail_ratio']);
- $dst_height = round($src_height * $conf['thumbnail_ratio']);
- break;
- }
- case 'exif':
- default:
- {
- // Nothing to do
- }
- }
-
- // Creating icon
- if ($conf['thumbnail_method'] == 'exif')
- {
- $src = exif_thumbnail($file_dir.'/'.$file_short.'.'.$file_ext, $width, $height, $imagetype);
- if ($src === false)
- {
- $error_log .= ' Failure - No EXIF thumbnail in ';
- $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.' '."\n";
- return $error_log;
- }
- $dst = imagecreatefromstring($src);
- if ($src === false)
- {
- $error_log .= ' Failure - EXIF thumbnail format not supported in ';
- $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.' '."\n";
- return $error_log;
- }
- }
- else
- {
- if (($pwg_conf['gd_version_major'] != 2)) // or ($conf['thumbnail_format'] == 'gif'))
- {
- $dst = imagecreate($dst_width, $dst_height);
- }
- else
- {
- $dst = imagecreatetruecolor($dst_width, $dst_height);
- }
- $src = call_user_func('imagecreatefrom'.$src_format, $file_dir.'/'.$file_short.'.'.$file_ext);
- if (!$src)
- {
- $error_log .= ' Failure - Internal error for imagecreatefrom'.$src_format.'()';
- $error_log .= 'with '.$file_dir.'/'.$file_short.'.'.$file_ext.' '."\n";
- return $error_log;
- }
-
- if (($pwg_conf['gd_version_major'] != 2))
- {
- if (!imagecopyresized($dst, $src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height))
- {
- $error_log .= ' Failure - Internal error for imagecopyresized()';
- $error_log .= 'with '.$file_dir.'/'.$file_short.'.'.$file_ext.' '."\n";
- return $error_log;
- }
- }
- else
- {
- if (!imagecopyresampled($dst, $src, 0, 0, 0, 0, $dst_width, $dst_height, $src_width, $src_height))
- {
- $error_log .= ' Failure - Internal error for imagecopyresampled()';
- $error_log .= 'with '.$file_dir.'/'.$file_short.'.'.$file_ext.' '."\n";
- return $error_log;
- }
- }
- }
-
- if (!call_user_func('image'.$dst_format, $dst, $file_dir.'/'.$conf['thumbs'].'/'.$conf['prefix_thumbnail'].$file_short.'.'.$conf['thumbnail_format']))
- {
- $error_log .= ' Failure - Can not write ';
- $error_log .= $file_dir.'/'.$conf['thumbs'].'/'.$conf['prefix_thumbnail'].$file_short.'.'.$file_ext.' to generate thumbnail '."\n";
- return $error_log;
- }
-
- $error_log .= ' Success - Thumbnail generated for ';
- $error_log .= $file_dir.'/'.$file_short.'.'.$file_ext.' '."\n";
-
- //~ pwg_log('<<<<< pwg_icon_file() returns '.var_export($error_log, TRUE).' <<<<<'."\n");
- return $error_log;
-}
-
-/**
- * completes xml line and returns error log
- *
- * @param string $file
- * @param string &$line
- * @return string
- */
-function pwg_scan_file($file_full, &$line)
-{
- //~ pwg_log('>>>>> pwg_scan_file($file = '.var_export($file_full, TRUE).', $line = '.var_export($line, TRUE).') >>>>>'."\n");
-
- global $conf, $pwg_conf;
-
- $error_log ='';
- $icon_log = '';
-
- $file_base = basename($file_full);
- $file_short = pwg_get_filename_wo_extension($file_base);
- $file_ext = pwg_get_file_extension($file_base);
- $file_dir = dirname($file_full);
-
- $element['file'] = $file_base;
- $element['path'] = dirname($pwg_conf['this_url']).substr($file_dir, 1).'/'.$file_base;
-
- if (in_array($file_ext, $conf['picture_ext']))
- {
- // Here we scan a picture : thumbnail is mandatory, high is optionnal, representative is not scanned
- $element['tn_ext'] = pwg_get_thumbnail_ext($file_dir, $file_short, $file_ext, $error_log, $icon_log);
- if ($element['tn_ext'] != '')
- {
- // picture has a thumbnail, get image width, heigth, size in Mo
- $element['filesize'] = floor(filesize($file_full) / 1024);
- if ($image_size = getimagesize($file_full))
- {
- $element['width'] = $image_size[0];
- $element['height'] = $image_size[1];
- }
-
- // get high resolution
- if (pwg_get_high($file_dir, $file_base))
- {
- $element['has_high'] = 'true';
-
- $high_file = $file_dir.'/'.$conf['high'].'/'.$file_base;
- $element['high_filesize'] = floor(filesize($high_file) / 1024);
-
- if ($high_size = @getimagesize($high_file))
- {
- $element['high_width'] = $high_size[0];
- $element['high_height'] = $high_size[1];
- }
- }
-
- // get EXIF meta datas
- if ($conf['use_exif'])
- {
- // Verify activation of exif module
- if (extension_loaded('exif'))
- {
- if ($exif = read_exif_data($file_full))
- {
- foreach ($conf['use_exif_mapping'] as $pwg_key => $exif_key )
- {
- 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];
- }
- }
- }
- }
- }
- }
-
- // get IPTC meta datas
- if ($conf['use_iptc'])
- {
- $iptc = pwg_get_sync_iptc_data($file_full);
- if (count($iptc) > 0)
- {
- foreach (array_keys($iptc) as $key)
- {
- $element[$key] = addslashes($iptc[$key]);
- }
- }
- }
-
- }
- else
- {
- $error_log .= ' Failure - Thumbnail is missing for '.$file_dir.'/'.$file_base.'';
- $error_log .= ' '."\n";
- }
- }
- else
- {
- // Here we scan a non picture file : thumbnail and high are unused, representative is optionnal
- $element['tn_ext'] = pwg_get_thumbnail_ext($file_dir, $file_short, $file_ext, $log);
- $ext = pwg_get_representative_ext($file_dir, $file_short);
- if ($ext != '')
- {
- $element['representative_ext'] = $ext;
- }
- $element['filesize'] = floor(filesize($file_full) / 1024);
- }
-
- if (strlen($error_log) == 0)
- {
- $line = pwg_get_indent('element').' $value)
- {
- $line .= $key.'="'.$value.'" ';
- }
- $line .= '/>'."\n";
- }
-
- // Adding Icon generation log to message
- $error_log .= $icon_log;
-
- //~ pwg_log('<<<<< pwg_scan_file() returns '.var_export($error_log, TRUE).' <<<<<'."\n");
- return $error_log;
-}
-
-/**
- * returns current level in tree
- *
- * @return integer
- */
-function pwg_get_level($dir)
-{
- //~ pwg_log('>>>>> pwg_get_level($dir = '.var_export($dir, TRUE).') >>>>>'."\n");
-
- $level = substr_count($dir, '/') - 1; // -1 because of ./ at the beginning of path
-
- //~ pwg_log('<<<<< pwg_get_level() returns '.var_export($level, TRUE).' <<<<<'."\n");
- return $level;
-}
-
-/**
- * returns indentation of element
- *
- * @param string $element_type : 'root', 'element', 'dir'
- * @return string
- */
-function pwg_get_indent($element_type)
-{
- //~ pwg_log('>>>>> pwg_get_indent($element_type = '.var_export($element_type, TRUE).') >>>>>'."\n");
-
- $level = substr_count($_SESSION['scan_list_fold'][0], '/') - 1; // because of ./ at the beginning
- switch($element_type)
- {
- case 'dir' :
- {
- $indent = str_repeat(' ', 2*pwg_get_level($_SESSION['scan_list_fold'][0]));
- break;
- }
- case 'root' :
- {
- $indent = str_repeat(' ', 2*pwg_get_level($_SESSION['scan_list_fold'][0])+2);
- break;
- }
- case 'element' :
- {
- $indent = str_repeat(' ', 2*pwg_get_level($_SESSION['scan_list_fold'][0])+4);
- break;
- }
- default :
- {
- $indent = '';
- break;
- }
- }
-
- //~ pwg_log('<<<<< pwg_get_indent() returns '.var_export(strlen($indent), TRUE).' spaces <<<<<'."\n");
- return $indent;
-}
-
-/**
- * create index.php in directory and reserved sub_directories, return logs
- *
- * @param string dir
- * @return string
- */
-function pwg_protect_directories($directory)
-{
- //~ pwg_log('>>>>> pwg_protect_directories($directory = '.var_export($directory, true).') >>>>>'."\n");
-
- global $conf;
-
- $error_log = '';
- $dirlist = array($directory, $directory.'/'.$conf['thumbs'], $directory.'/'.$conf['high'], $directory.'/'.$conf['represent']);
-
- foreach ($dirlist as $dir)
- {
- if (file_exists($dir))
- {
- if (!file_exists($dir.'/index.php'))
- {
- $file = @fopen($dir.'/index.php', 'w');
- if ($file != false)
- {
- fwrite($file, $pwg_conf['protect_content']); // the return code should be verified
- $error_log .= ' Success - index.php created in directory '.$dir." \n";
- }
- else
- {
- $error_log .= ' Failure - Can not create index.php in directory '.$dir." \n";
- }
- }
- else
- {
- if ($conf['protect_warnings'])
- {
- $error_log .= ' Warning - index.php already exists in directory '.$dir." \n";
- }
- }
- }
- }
-
- //~ pwg_log('<<<<< pwg_protect_directories() returns '.var_export($error_log, true).' <<<<<'."\n");
- return $error_log;
-}
-
-/**
- * returns file extension (.xxx)
- *
- * @param string $file
- * @return string
- */
-function pwg_get_file_extension($file)
-{
- //~ pwg_log('>>>>> pwg_get_file_extension($file = '.var_export($file, true).') >>>>>'."\n");
-
- $ext = substr(strrchr($file, '.'), 1, strlen ($file));
-
- //~ pwg_log('<<<<< pwg_get_file_extension() returns '.var_export($ext, true).' <<<<<'."\n");
- return $ext;
-}
-
-/**
- * completes directory list of supported files and returns error logs
- *
- * @param string $directory
- * @return string
- */
-function pwg_get_file_list($directory)
-{
- //~ pwg_log('>>>>> pwg_get_file_list($directory = '.var_export($directory, true).') >>>>>'."\n");
-
- global $conf, $pwg_conf;
-
- $errorLog = '';
- $dir = opendir($directory);
- while (($file = readdir($dir)) !== false)
- {
- switch (filetype($directory."/".$file))
- {
- case 'file' :
- {
- if (in_array(pwg_get_file_extension($file), $conf['file_ext']))
- {
- // The file pointed is a regular file with a supported extension
- array_push($_SESSION['scan_list_file'], $directory.'/'.$file);
- //~ pwg_log('--->> Push in $_SESSION[scan_list_file] value "'.$directory.'/'.$file.'"'."\n");
- if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $file))
- {
- $errorLog .= ' Failure - Invalid file name for '.$file.' in '.$directory.'';
- $errorLog .= ' > Push in $_SESSION[scan_list_fold] value "'.$directory.'/'.$file.'"'."\n");
- if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $file))
- {
- $errorLog .= ' Failure - Invalid directory name for '.$directory.'/'.$file.'';
- $errorLog .= ' >>>> pwg_get_moment() >>>>>'."\n");
-
- $t1 = explode(' ', microtime());
- $t2 = explode('.', $t1[0]);
- $t2 = $t1[1].'.'.$t2[1];
-
- //~ pwg_log('<<<<< pwg_get_moment() returns '.var_export($t2, true).' <<<<<'."\n");
- return $t2;
-}
-
-/**
- * return true if HTTP_REFERER and PHP_SELF are similar
- *
- * return boolean
- */
-function pwg_referer_is_me()
-{
- global $pwg_conf;
-
- //~ pwg_log('>>>>> pwg_referer_is_me() >>>>>'."\n");
-
- $response = false;
- $caller = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
-
- if (strcasecmp($pwg_conf['this_url'], $caller) == 0) {
- $response = true;
- }
-
- //~ pwg_log('<<<<< pwg_referer_is_me() returns '.var_export($response, true).' <<<<<'."\n");
- return $response;
-}
-
-// +-----------------------------------------------------------------------+
-// | pwg__ Functions |
-// +-----------------------------------------------------------------------+
-
-function pwg_test_start()
-{
- //~ pwg_log('>>>>> pwg_test_start() >>>>>'."\n");
-
- global $g_message, $conf;
-
- if (isset($_REQUEST['version']))
- {
- if ($_REQUEST['version'] != $conf['version'])
- {
- $g_message = '0';
- }
- else
- {
- $g_message = '1';
- }
- }
- else
- {
- $g_message = '1';
- }
- $_SESSION['scan_step'] = 'exit';
-
- //~ pwg_log('<<<<< pwg_test_start() <<<<<'."\n");
-}
-
-function pwg_test_exit()
-{
- //~ pwg_log('>>>>> pwg_test_exit() >>>>>'."\n");
-
- global $g_header, $g_message, $g_footer, $conf, $pwg_conf;
-
- if (pwg_referer_is_me())
- {
- $g_header = ' : Test'."\n";
- $g_footer = ''."\n";
-
- // Write version
- $g_message = '
Script version
'."\n";
- $g_message .= ' This script is tagged : '.$conf['version'].''."\n";
- // write GD support
- if (!is_callable('gd_info'))
- {
- $g_message .= ' Failure - Your server can not generate imagess '."\n";
- }
- else
- {
- $info = gd_info();
- $gd_full_version = preg_replace('/[[:alpha:][:space:]()]+/', '', $info['GD Version']);
- list($gd_version) = preg_split('/[.]+/', $gd_full_version);
-
- $g_message .= '
Image generation
'."\n";
- $g_message .= ' Success - Your server can generate images '."\n";
- $g_message .= ' Warning - Your server support GD'.$gd_version.' (v'.$gd_full_version.') '."\n";
- $format_list = array();
- $format = ($info['GIF Create Support']) ? 'gif' : NULL;
- array_push($format_list, $format);
- $format = ((isset($info['JPG Support']) and $info['JPG Support']) or (isset($info['JPEG Support']) and $info['JPEG Support'])) ? 'jpg' : NULL;
- array_push($format_list, $format);
- $format = ($info['PNG Support']) ? 'png' : NULL;
- array_push($format_list, $format);
- $g_message .= ' Warning - Your server support format: '.implode(', ', $format_list)."\n";
- }
-
- $g_message .= '
Directory parsing
'."\n";
- if ($pwg_conf['safe_mode'])
- {
- $g_message .= ' Warning - Your server does not support to resize execution time'."\n";
- }
- else
- {
- $g_message .= ' Success - Your server supports to resize execution time'."\n";
- }
- }
- else
- {
- // compare version in GET parameter with $conf['version']
- if ($g_message == '1')
- {
- exit('