Example #1
0
 /**
  * Delete IDs from given table if they are older than X mn
  *
  *@access private
  *@param string $table Table to clean
  *@param string $fieldname field from table containing timestamp
  *@param int $mins delete IDs older than $mins minutes
  *@return int 1 if success, 0 if error
  */
 function cleanId($table, $fieldname, $mins)
 {
     global $dbauth, $l;
     $this->error = "";
     $date = dateToTimestamp(nowDate());
     $date -= $mins * 60;
     $date = timestampToDate($date);
     $query = "DELETE FROM " . $table . " WHERE\n    " . $fieldname . " < " . $date;
     $res = $dbauth->query($query);
     if ($dbauth->error()) {
         $this->error = $l['str_trouble_with_db'];
         return 0;
     }
     return 1;
 }
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    $cliModTime = dateToTimestamp($_SERVER['HTTP_IF_MODIFIED_SINCE']);
    if (max($modTimes) <= $cliModTime) {
        header('HTTP/1.x 304 Not Modified');
        exit;
    }
}
/**
 * send last modified date of file to client so it will have date for server
 * on next request.
 * Technically we could just send the current time (as PEAR does) rather
 * than the actual modify time of the file since either way would get the
 * correct behavior, but since we already have the actual modified time of
 * the file, we'll just use that.
 */
$srvModDate = timestampToDate(max($modTimes));
header("Last-Modified: {$srvModDate}");
// Now include files
foreach ($cssFiles as $file) {
    if (file_exists('./' . $file . '.css')) {
        include './' . $file . '.css';
    }
}
// copied from PEAR HTTP Header.php (comments stripped)
// Author: Wolfram Kriesing <*****@*****.**>
// Changes: mktime() to gmmktime() to make work in timezones other than GMT
function dateToTimestamp($date)
{
    $months = array_flip(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
    preg_match('~[^,]*,\\s(\\d+)\\s(\\w+)\\s(\\d+)\\s(\\d+):(\\d+):(\\d+).*~', $date, $splitDate);
    $timestamp = @gmmktime($splitDate[4], $splitDate[5], $splitDate[6], $months[$splitDate[2]] + 1, $splitDate[1], $splitDate[3]);
function smarty_modifier_date($string, $format = "%b %e, %Y", $default_date = null)
{
    echo timestampToDate($string);
}
Example #4
0
                   } else {
                       if ($numbertodelete) {
                           $content .= sprintf($l['str_x_logs_purged'], $numbertodelete) . '<br>';
                       }
                   }
                   break;
               case "day":
                   $deletedate = timestampToDate($datets - 60 * 60 * 24);
                   $userlogs->deleteLogsBefore($deletedate);
                   break;
               case "month":
                   $deletedate = timestampToDate($datets - 60 * 60 * 24 * 30);
                   $userlogs->deleteLogsBefore($deletedate);
                   break;
               case "year":
                   $deletedate = timestampToDate($datets - 60 * 60 * 24 * 365);
                   $userlogs->deleteLogsBefore($deletedate);
                   break;
           }
           // end switch purge
           if ($userlogs->error) {
               $content .= sprintf($html->string_error, sprintf($l['str_while_purging_logs_x'], $userlogs->error)) . '<br>';
           }
       }
       // end if purge
       // print table with logs & delete
       $content .= '<form action="' . $_SERVER["PHP_SELF"] . '" method="get">
 ' . $hiddenfields . '
 <input type="hidden" name="sortcategory" value="' . $sortcategory . '"><input type="hidden" name="order" value="' . $order . '">
 ' . $l['str_sort_results'] . ':&nbsp;&nbsp; 
 <a href="' . $_SERVER["PHP_SELF"] . $link . '&amp;sortcategory=D">' . $l['str_per_date'] . '</a> &nbsp;&nbsp;