Give feedback');
$LAYOUT->addContentHeader('
');
debug('version: '.PSNG_VERSION, 'This is phpSitemapNG');
debug($SETTINGS, 'Merged settings');
debug($SETTINGS[PSNG_SETTINGS_STATE], 'last state');
$action = '';
if (isset($_REQUEST[PSNG_ACTION])) $action = $_REQUEST[PSNG_ACTION];
// handle some special actions, eg submit buttons without approriate hidden action tag
if (isset($_REQUEST[PSNG_ACTION_SETTINGS_RESET])) {
if ($_REQUEST[PSNG_ACTION_SETTINGS_RESET] != '') $action = PSNG_ACTION_SETTINGS_RESET;
}
$SETTINGS[PSNG_SETTINGS_STATE] = $action;
debug($SETTINGS[PSNG_SETTINGS_STATE], "current state");
$SETTINGS[PSNG_SETTINGS_EXECUTED][$action] = TRUE;
$SETTINGS[PSNG_TIMEOUT_IS] = FALSE;
$SETTINGS[PSNG_TIMEOUT_IS] = '';
if ($SETTINGS[PSNG_TIMEOUT] == PSNG_TIMEOUT_NONE) $SETTINGS[PSNG_TIMEOUT_TIME_DEADLINE] = time()+60*60*24; // timeout is now in 24 h
return $action;
}
function resetRunon() {
global $SETTINGS;
unset($SETTINGS[PSNG_TIMEOUT_DONE]);
unset($SETTINGS[PSNG_TIMEOUT_TODO]);
unset($SETTINGS[PSNG_TIMEOUT_FILE]);
unset($SETTINGS[PSNG_TIMEOUT_FILE_LASTRUN]);
unset($SETTINGS[PSNG_TIMEOUT_ACTION]);
unset($SETTINGS[PSNG_TIMEOUT_IS]);
unset($SETTINGS[PSNG_TIMEOUT_TIME]);
unset($SETTINGS[PSNG_TIMEOUT_TIME_START]);
// unset($SETTINGS[PSNG_TIMEOUT_TIME_DURATION]);
unset($SETTINGS[PSNG_TIMEOUT_TIME_SHUTDOWN]);
unset($SETTINGS[PSNG_TIMEOUT_TIME_DEADLINE]);
}
/**
* overwrite existing filelist-file
*/
function resetFiles() {
global $SETTINGS;
// write empty settings to file
storeSettings(array (), $SETTINGS['files_file'], "FILES");
// all settings are okay for now, so go on
return '
Your filelist '.$SETTINGS['files_file'].' is reseted now!
'.'You can now create your personal google sitemap
';
}
/**
* checks a given filename if it exists and is writable
* returns empty string, if okay; otherwise the error message
*/
function checkFile($filename) {
$file = @ fopen($filename, "r");
// check if writable
$msg = "";
if (!file_exists($filename)) {
$msg = "File ".$filename." does not exist; create file and set permission with chmod to 0666";
}
elseif (!is_writable($filename)) {
$msg = "File ".$filename." does exist but cannot be written; change permission with chmod to 0666";
}
elseif ($file === FALSE) {
$msg = "Error while opening ".$filename." for write access. Check existence and permission of file!";
}
@ fclose($file);
return $msg;
}
function getDateTimeISO($timestamp) {
return date("Y-m-d\TH:i:s", $timestamp) . substr(date("O"),0,3) . ":" . substr(date("O"),3);
}
function getDateTimeISO_short($timestamp) {
return date("Y-m-d", $timestamp);
}
function getFrequency($lastmod) {
// set changefreq
$age = time() - $lastmod;
$change_freq = "monthly"; // default value
if ($age < 10) {
$change_freq = "always";
} elseif ($age < 60*60) {
$change_freq = "hourly";
} elseif ($age < 60*60*24) {
$change_freq = "daily";
} elseif ($age < 60*60*24*7) {
$change_freq = "weekly";
} elseif ($age < 60*60*24*31) { // longest month has 31 days
$change_freq = "monthly";
} elseif ($age < 60*60*24*365) {
$change_freq = "yearly";
} else {
$change_freq = "never";
}
return $change_freq;
}
/* write settings to file */
function storeSettings($SETTINGS, $filename, $keyname) {
global $openFile_error;
$file = openFile($filename, TRUE);
if ($file === FALSE)
return $openFile_error;
fputs($file, " $val) {
if (is_array($val)) {
foreach ($val as $key2 => $val2) {
fputs($file, '$'.$keyname."['".stringToVariableName($key)."']['".stringToVariableName($key2)."'] = '".stringToVariableName($val2)."';\n");
}
continue;
}
fputs($file, '$'.$keyname."['".stringToVariableName($key)."'] = '".stringToVariableName($val)."';\n");
}
fputs($file, "?>\n");
fclose($file);
return NULL;
}
/* remove maybe existing ' in string */
function stringToVariableName($str) {
return ((!get_magic_quotes_gpc()) ? addslashes($str) : $str);
}
function variableNameToString($var_name) {
if(get_magic_quotes_gpc()) {
return stripslashes($var_name);
} else {
$res = $var_name;
if (substr($res, 0, 1) == "'")
$res = substr($res, 1);
if (substr($res, strlen($res) - 1) == "'")
$res = substr($res, 0, strlen($res) - 1);
return $res;
}
}
/* explodes the array for given deliminator and returns a correct array */
function toArray($str, $delim = "\n") {
$res = array ();
$res = explode($delim, $str);
for ($i = 0; $i < count($res); $i ++) {
$res[$i] = trim($res[$i]);
}
return $res;
}
/* returns a string of all entries of array with delim */
function arrToStringReadable($array, $delim) {
$res = "";
if (is_array($array)) {
$i = 0;
foreach ($array as $key => $val) {
if (is_array($val)) {
$res .= "$key: ".arrToStringReadable($val, $delim);
} else {
$res .= "$key: $val";
}
if ($i < (count($array) - 1))
$res .= $delim;
$i ++;
}
}
return $res;
}
/* returns a string of all entries of array with delim */
function arrToString($array, $delim = "\n") {
$res = "";
if (is_array($array)) {
for ($i = 0; $i < count($array); $i ++) {
$res .= $array[$i];
if ($i < (count($array) - 1))
$res .= $delim;
}
}
return $res;
}
?>