Your IP : 216.73.216.39


Current Path : /home/wirbesti/public_html/
Upload File :
Current File : /home/wirbesti/public_html/deleteoldpdf.php

<?php
try {
    $files = glob("/home/wirbesti/public_html/*.pdf");
    $now = time();
    //echo 'files = '.count($files).PHP_EOL;
    foreach ($files as $file) {
        //echo 'looking at file '.$file.PHP_EOL;
        if (is_file($file)) {
            //echo $file.' is a file '.PHP_EOL;
            if ($now - filectime($file) >= 60 * 60 * 24) { // 1 day
                //echo 'deleting file '.$file.PHP_EOL;
                unlink($file);
            } else {
                //echo 'file is younger than 1 day '.$file.' ('.$now.' - '.filemtime($file).') >= '.(60 * 60 * 24).PHP_EOL;
            }
        } else {
            //echo $file.' is not a file '.PHP_EOL;
        }
    }
} catch (Exception $ex) {
    echo $ex->getMessage() . PHP_EOL;
}