コード例 #1
0
ファイル: cleanup.php プロジェクト: Monori/imgservice
<?php

require_once '../config/init.php';
require_once 'includes/cleanup_helpers.php';
require_once 'includes/global_helpers.php';
// ---- SETTINGS START ----
const NOTIFY_PERCENTAGE_CHANGE = 5;
const NOTIFY_MIN_SPACE_PERCENTAGE = 10;
const THUMBNAIL_MAX_AGE_DAYS = 7;
// ---- SETTINGS END ----
parseSettings();
// -- CLEANUP THUMBNAILS ---
echo chr(10) . '  [ CLEANING UNUSED THUMBNAILS ]' . chr(10) . chr(10);
$thumbnails = \NinjaImg\Model\ModelThumbnail::getByMaxAge(THUMBNAIL_MAX_AGE_DAYS);
if (!$thumbnails->hasRows()) {
    echo '   - No thumbnails found';
} else {
    /* @var $thumbnail \NinjaImg\Model\ModelThumbnail */
    foreach ($thumbnails->getRows() as $thumbnail) {
        echo '   - Deleting thumbnail: ' . $thumbnail->name . chr(10);
        $thumbnail->delete();
    }
}
echo chr(10) . chr(10);
// DETECT DISKSPACE CHANGES
echo '  [ CHECK CONTENT-PROVIDER DISKSPACE ]' . chr(10) . chr(10);
foreach (\NinjaImg\Model\ModelContentProvider::all(true) as $cdn) {
    echo '   + Checking ' . $cdn->name . chr(10);
    $total = $cdn->capacity_max_gb && $cdn->capacity_max_gb > 0 ? $cdn->capacity_max_gb : round(disk_total_space($cdn->path) / 1024 / 1024 / 1024);
    $capacity = round(disk_free_space($cdn->path) / 1024 / 1024 / 1024);
    $leftPercentage = round($capacity / $total * 100);
コード例 #2
0
include dirname(realpath(__FILE__)) . '/../includes/adodb/adodb.inc.php';
global $ourDBType;
$ourDBType = null;
// Default
// Start the output and conversion here
startOutput();
$settingsFile = dirname(realpath(__FILE__)) . "/../includes/settings.php";
showInfoBox('We are attempting to open and reads your settings.php file.', 'Reading Settings');
if (!file_exists($settingsFile)) {
    showInfoBox('<span style="color: #ff0000;font-weight: bold;">There was an error trying to read the settings.php file...\\nPlease make sure that you have created your settings.php file already...\\nAttempting to read file: $settingsFile</span>', 'ERROR');
    die;
}
$contents = file_get_contents($settingsFile);
showInfoBox('Successfully opened and read the settings.php file, we are attempting to parse now....', 'Parsing');
if (!isConverted()) {
    $keyval = parseSettings($contents);
    showInfoBox('Populating database.....', 'Database');
    //populateDatabase($keyval);
    writeToDB($keyval);
    if (createFile()) {
        showInfoBox('All done.. Please replace settings.php with the settings-new.php file that was created.');
    }
} else {
    showInfoBox("You appear to already be converted.  Congratulations.\nIf your settings are not working, please try to run the DB Fix tool.");
}
endOutput();
//-------------------------------------------------------------------------------------------//
/**
 * writeToDb writes the OBJECT to the database
 * @param Array $data
 */