Functions |
// +-----------------------------------------------------------------------+
function pwg_test_start()
@@ -742,8 +1053,44 @@ function pwg_test_exit()
if (pwg_referer_is_me())
{
$g_header = ' : Test'."\n";
- $g_message = ' This script is tagged : '.$conf['version'].''."\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 = ereg_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 = ($info['JPG 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
{
@@ -815,85 +1162,6 @@ function pwg_clean_exit()
//~ pwg_log('<<<<< pwg_clean_exit() <<<<<'."\n");
}
-function pwg_protect_start()
-{
- //~ pwg_log('>>>>> pwg_protect_start() >>>>>'."\n");
-
- $_SESSION['scan_logs'] = pwg_get_file_list('.');
- sort($_SESSION['scan_list_fold']);
-
- // Erase first file list because root directory does not contain images.
- $_SESSION['scan_list_file'] = array();
-
- // What are we doing at next step
- if(count($_SESSION['scan_list_fold']) > 0)
- {
- $_SESSION['scan_step'] = 'list';
- }
- else
- {
- $_SESSION['scan_step'] = 'stop';
- }
-
- //~ pwg_log('<<<<< pwg_protect_start() <<<<<'."\n");
-}
-
-function pwg_protect_list()
-{
- //~ pwg_log('>>>>> pwg_protect_list() >>>>>'."\n");
-
- // Get list of files and directories
- $_SESSION['scan_logs'] .= pwg_get_file_list($_SESSION['scan_list_fold'][0]);
- sort($_SESSION['scan_list_fold']);
-
- // Delete unused file list
- $_SESSION['scan_list_file'] = array();
-
- // Position next step
- $_SESSION['scan_step'] = 'scan';
-
- //~ pwg_log('<<<<< pwg_protect_list() <<<<<'."\n");
-}
-
-function pwg_protect_scan()
-{
- //~ pwg_log('>>>>> pwg_protect_scan() >>>>>'."\n");
-
- $_SESSION['scan_logs'] .= pwg_protect_directories($_SESSION['scan_list_fold'][0]);
-
- if (isset($_SESSION['scan_list_fold'][1]))
- {
- array_shift($_SESSION['scan_list_fold']);
- $_SESSION['scan_step'] = 'list';
- }
- else
- {
- $_SESSION['scan_step'] = 'stop';
- }
-
- //~ pwg_log('<<<<< pwg_protect_scan() <<<<<'."\n");
-}
-
-function pwg_protect_stop()
-{
- //~ pwg_log('>>>>> pwg_protect_stop() >>>>>'."\n");
-
- global $g_header, $g_message, $g_footer, $pwg_conf;
-
- $time_elapsed = number_format(pwg_get_moment() - $_SESSION['scan_time'], 3, '.', ' ');
-
- $g_header = ' : Protect';
- $g_message = ' '."\n".$_SESSION['scan_logs'].'
'."\n";
- $g_message .= ' '.$_SESSION['scan_cnt_fold'].' directories protected
'."\n";
- $g_message .= ' Gallery protected in : '.$time_elapsed.' s
';
- $g_footer = '
';
-
- // What are we doing at next step
- $_SESSION['scan_step'] = 'exit';
-
- //~ pwg_log('<<<<< pwg_protect_stop() <<<<<'."\n");
-}
-
function pwg_generate_start()
{
//~ pwg_log('>>>>> pwg_generate_start() >>>>>'."\n");
@@ -929,7 +1197,7 @@ function pwg_generate_start()
// Initialization of directory and file lists
$_SESSION['scan_list_fold'] = array();
$_SESSION['scan_list_file'] = array();
- $_SESSION['scan_logs'] = pwg_get_file_list('.');
+ $_SESSION['scan_logs'] .= pwg_get_file_list('.');
sort($_SESSION['scan_list_fold']);
// Erase first file list because root directory does not contain images.
@@ -982,12 +1250,13 @@ function pwg_generate_scan()
//~ pwg_log('>>>>> pwg_generate_scan() >>>>>'."\n");
//~ pwg_log("GENARATE scan >>>\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE scan >>>\n");
- global $g_listing;
+ global $g_listing, $conf;
while (pwg_continue() and count($_SESSION['scan_list_file']) > 0)
{
$line = '';
$_SESSION['scan_logs'] .= pwg_scan_file($_SESSION['scan_list_file'][0], $line);
+
if (strlen($line) > 0)
{
fwrite($g_listing, $line);
@@ -999,43 +1268,62 @@ function pwg_generate_scan()
if (count($_SESSION['scan_list_file']) <= 0)
{
- // Flush line
- $line = pwg_get_indent('root').''."\n";
- fwrite($g_listing, $line);
-
- // How many directories to close
- $current_level = pwg_get_level($_SESSION['scan_list_fold'][0]);
- if (isset($_SESSION['scan_list_fold'][1]))
- {
- //~ pwg_log('---<< Pull of $_SESSION[scan_list_fold] value "'.$_SESSION['scan_list_fold'][0].'"'."\n");
- array_shift($_SESSION['scan_list_fold']);
- $_SESSION['scan_cnt_fold']++;
- $next_level = pwg_get_level($_SESSION['scan_list_fold'][0]);
- $_SESSION['scan_step'] = 'list';
- }
- else
- {
- $next_level = -1;
- $_SESSION['scan_step'] = 'stop';
- }
-
- if ($current_level == $next_level)
- {
- fwrite($g_listing, pwg_close_level($current_level, 1));
- }
- else
- {
- if (($current_level > $next_level))
- {
- fwrite($g_listing, pwg_close_level($current_level, $current_level-$next_level+1));
- } // Nothing to do if current_level < next_level
- }
+ $_SESSION['scan_step'] = 'prot';
}
//~ pwg_log("GENERATE scan <<<\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE scan <<<\n");
//~ pwg_log('<<<<< pwg_generate_scan() <<<<<'."\n");
}
+function pwg_generate_prot()
+{
+ //~ pwg_log('>>>>> pwg_generate_prot() >>>>>'."\n");
+ //~ pwg_log("GENARATE prot >>>\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE prot >>>\n");
+
+ global $conf, $g_listing;
+
+ // Flush line
+ $line = pwg_get_indent('root').''."\n";
+ fwrite($g_listing, $line);
+
+ if ($conf['protect'])
+ {
+ $_SESSION['scan_logs'] .= pwg_protect_directories($_SESSION['scan_list_fold'][0]);
+ }
+
+ // How many directories to close
+ $current_level = pwg_get_level($_SESSION['scan_list_fold'][0]);
+ if (isset($_SESSION['scan_list_fold'][1]))
+ {
+ //~ pwg_log('---<< Pull of $_SESSION[scan_list_fold] value "'.$_SESSION['scan_list_fold'][0].'"'."\n");
+ array_shift($_SESSION['scan_list_fold']);
+ $_SESSION['scan_cnt_fold']++;
+ $next_level = pwg_get_level($_SESSION['scan_list_fold'][0]);
+ $_SESSION['scan_step'] = 'list';
+ }
+ else
+ {
+ $next_level = -1;
+ $_SESSION['scan_cnt_fold']++;
+ $_SESSION['scan_step'] = 'stop';
+ }
+
+ if ($current_level == $next_level)
+ {
+ fwrite($g_listing, pwg_close_level($current_level, 1));
+ }
+ else
+ {
+ if (($current_level > $next_level))
+ {
+ fwrite($g_listing, pwg_close_level($current_level, $current_level-$next_level+1));
+ } // Nothing to do if current_level < next_level
+ }
+
+ //~ pwg_log("GENERATE prot <<<\n".var_export($_SESSION['scan_list_fold'], true)."\n".var_export($_SESSION['scan_list_file'], true)."\nGENERATE prot <<<\n");
+ //~ pwg_log('<<<<< pwg_generate_prot() <<<<<'."\n");
+}
+
function pwg_generate_stop()
{
//~ pwg_log('>>>>> pwg_generate_stop() >>>>>'."\n");
@@ -1152,6 +1440,7 @@ function pwg_init()
//~ pwg_log('>>>>> pwg_init() >>>>>'."\n");
global $g_message, $g_listing, $g_footer, $conf, $pwg_conf, $start_time;
+ $init_message = '';
// Lock other script sessions, this lock will be remove during 'exit' step
if (!isset($_SESSION['scan_step']))
@@ -1218,16 +1507,17 @@ function pwg_init()
$g_message .= ' Test'."\n";
$g_message .= ' Clean'."\n";
$g_message .= ' Listing'."\n";
- $g_message .= ' Protect'."\n";
$g_message .= ' '."\n";
$g_footer = '';
$g_footer .= '
'."\n";
$_SESSION['scan_step'] = 'exit';
+ $_SESSION['scan_action'] = '';
}
- // Open listing.xml
+ // Actions to do at the init of generate
if ($_SESSION['scan_action'] == 'generate')
{
+ // Open XML file
$mode = ($_SESSION['scan_step'] == 'init') ? 'w' : 'a'; // Erase old listing.xml at the beginning of generation (mode w)
$g_listing = @fopen('listing.xml', $mode);
if ($g_listing === false)
@@ -1240,8 +1530,11 @@ function pwg_init()
//~ pwg_log('<<<<< pwg_init() failure <<<<<'."\n");
return;
}
+
+ // Check graphical capabilities
+ $init_message = pwg_check_graphics();
}
-
+
// Initializing session counters. This counters will be completely unset during step 'exit'
if ($_SESSION['scan_step'] == 'init')
{
@@ -1251,7 +1544,7 @@ function pwg_init()
$_SESSION['scan_cnt_fold'] = 0;
$_SESSION['scan_time'] = $start_time;
$_SESSION['scan_step'] = 'start';
- $_SESSION['scan_logs'] = '';
+ $_SESSION['scan_logs'] = $init_message;
}
//~ pwg_log('<<<<< pwg_init() success <<<<<'."\n");
@@ -1290,8 +1583,8 @@ function pwg_exit()
$local_action = $_SESSION['scan_action'];
unset($_SESSION['scan_action']);
unset($_SESSION['scan_logs']);
-
-
+ session_destroy();
+
// Call specific action post process
if (is_callable('pwg_'.$local_action.'_exit'))
{
@@ -1302,8 +1595,9 @@ function pwg_exit()
}
// +-----------------------------------------------------------------------+
-// | script |
+// | Script |
// +-----------------------------------------------------------------------+
+session_save_path('.');
session_start();
$start_time = pwg_get_moment();