Compare commits
No commits in common. "f1d68e0ce6a684b826900664aacd4ccb9e8d24ba" and "498a031cabcc5c138b95406075f2d4f1865b5d05" have entirely different histories.
f1d68e0ce6
...
498a031cab
|
@ -1,2 +0,0 @@
|
|||
order allow,deny
|
||||
deny from all
|
|
@ -1,9 +0,0 @@
|
|||
## Scripts intended for use by cron
|
||||
|
||||
Scripts in this folder are intended to be run by cron, likely as the user running the web server process.
|
||||
|
||||
* __clearextracts.php:__ Used to purge the folder used for extracting comics for viewing by clients. It should be run by the web service owner and takes a single parameter for the number of days to keep extracts before removing them.
|
||||
- "su" to root: `sudo su -`
|
||||
- Run crontab as web server owner: `sudo web -c "crontab -e"`
|
||||
- Add crontab line with frequency and days/age parameter
|
||||
- `15 3 * * * /usr/local/bin/php /var/www/htdocs/comics/cron/clearextracts.php 5 1>/dev/null 2>&1`
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
$projectRoot = dirname(dirname(__FILE__));
|
||||
|
||||
require "{$projectRoot}/header.php";
|
||||
|
||||
if ( $argc != 2 ) {
|
||||
echo "Invalid number of days to keep\n";
|
||||
exit();
|
||||
}
|
||||
$daysToKeep = intval($argv[1]);
|
||||
|
||||
$ed = $projectRoot . "/" . EXTRACTSDIR;
|
||||
$now = time();
|
||||
$maxAge = $now - (86400*$daysToKeep);
|
||||
|
||||
$it = new RecursiveDirectoryIterator($ed, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
$validExtensions = array("cbr","cbz");
|
||||
foreach ( $files as $file ) {
|
||||
if ( $file->isDir() && in_array($file->getExtension(), $validExtensions) ) {
|
||||
if ( filemtime($file->getRealPath()) <= $maxAge ) {
|
||||
echo "Found aged extracted comic: {$file->getFilename()}\n";
|
||||
exec("rm -rf \"{$file->getRealPath()}\"", $output, $retval);
|
||||
}
|
||||
}
|
||||
}
|
62
header.php
62
header.php
|
@ -9,43 +9,41 @@ require 'functions.php';
|
|||
// be named "require_login() and take no parameters
|
||||
require 'authfunctions.php';
|
||||
|
||||
if ( php_sapi_name() != "cli" ) {
|
||||
// Start the session
|
||||
session_name(SESSIONCOMICS);
|
||||
session_start();
|
||||
// Start the session
|
||||
session_name(SESSIONCOMICS);
|
||||
session_start();
|
||||
|
||||
// This session variable is TRUE when successfully logged in
|
||||
// If set to true, and using default authentication, no login will be required
|
||||
if ( !isset($_SESSION['validated']) ) {
|
||||
$_SESSION['validated'] = false;
|
||||
}
|
||||
// This session variable is TRUE when successfully logged in
|
||||
// If set to true, and using default authentication, no login will be required
|
||||
if ( !isset($_SESSION['validated']) ) {
|
||||
$_SESSION['validated'] = false;
|
||||
}
|
||||
|
||||
// This session variable is set to the current browsing folder.
|
||||
// It is relative to the COMICSDIR constant defined in variables.php
|
||||
if ( !isset($_SESSION['compath']) ) {
|
||||
$_SESSION['compath'] = '/';
|
||||
}
|
||||
if ( $_SESSION['compath'] == "" ) $_SESSION['compath'] = "/";
|
||||
// This session variable is set to the current browsing folder.
|
||||
// It is relative to the COMICSDIR constant defined in variables.php
|
||||
if ( !isset($_SESSION['compath']) ) {
|
||||
$_SESSION['compath'] = '/';
|
||||
}
|
||||
if ( $_SESSION['compath'] == "" ) $_SESSION['compath'] = "/";
|
||||
|
||||
// This session variable is set to the current comic in Base64
|
||||
if ( !isset($_SESSION['comfile']) ) {
|
||||
$_SESSION['comfile'] = "";
|
||||
}
|
||||
// This session variable is set to the current comic in Base64
|
||||
if ( !isset($_SESSION['comfile']) ) {
|
||||
$_SESSION['comfile'] = "";
|
||||
}
|
||||
|
||||
// Initialize the hash session variable used for SSO
|
||||
// Set the hash to the passed in value if it exists
|
||||
if ( !isset($_SESSION['hash']) ) {
|
||||
$_SESSION['hash'] = "";
|
||||
}
|
||||
if ( isset($_REQUEST['hash']) ) {
|
||||
$_SESSION['hash'] = $_REQUEST['hash'];
|
||||
}
|
||||
// Initialize the hash session variable used for SSO
|
||||
// Set the hash to the passed in value if it exists
|
||||
if ( !isset($_SESSION['hash']) ) {
|
||||
$_SESSION['hash'] = "";
|
||||
}
|
||||
if ( isset($_REQUEST['hash']) ) {
|
||||
$_SESSION['hash'] = $_REQUEST['hash'];
|
||||
}
|
||||
|
||||
// Sorting for folders.
|
||||
// Valid values (from constants): SORTBYNAME, SORTBYDATE
|
||||
if ( !isset($_SESSION['sortorder']) ) {
|
||||
$_SESSION['sortorder'] = SORTBYDATE;
|
||||
}
|
||||
// Sorting for folders.
|
||||
// Valid values (from constants): SORTBYNAME, SORTBYDATE
|
||||
if ( !isset($_SESSION['sortorder']) ) {
|
||||
$_SESSION['sortorder'] = SORTBYDATE;
|
||||
}
|
||||
|
||||
// Make our PDO database connection which will be used in all scripts
|
||||
|
|
Loading…
Reference in New Issue
Block a user