palm-paste/cronjob.php

19 lines
680 B
PHP
Raw Permalink Normal View History

<?php
2016-06-16 15:34:00 +01:00
include_once "config/config.php";
function RemoveExpiredPastes(){
$conn = GetConnectionToDB();
2016-06-16 15:34:00 +01:00
$time = time();
$stmt = $conn->prepare("DELETE from `pastes` where `expire`<:time and `expire`>0");
$stmt->bindValue(':time', $time);
$stmt->execute();
$conn = null; //close connection to database
echo 'OK! 200';
}
if (isset($_GET["key"])){
2016-06-16 15:34:00 +01:00
if($_GET["key"]==$CRON_ExpireKey){ //Delete expired pastes
RemoveExpiredPastes();
}
}
2016-06-16 15:34:00 +01:00
//Cron job example: */5 * * * * curl --silent http://127.0.0.1/paste/cronjob.php?key=fgd45fb5fb15gb > /dev/null
//More about cron jobs: http://www.shellhacks.com/en/Adding-Cron-Jobs-in-Linux-Crontab-Usage-and-Examples
?>