<?php
/**
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.
 *
 * 2019 - 2023 https://://www.bananas-playground.net/projekt/selfpaste
 */

/**
 * Use this example to create a cronjob to clean up the paste entries which are over livetime.
 * Usually the cleanup is done at creation and works well. But if you have a high load
 * or very low load, those lifetime limits will not be checked correctly
 *
 * rename this file into a php file and create a cronjob which executes this file as
 * php cli command
 *
 * example runs every sunday : 0 0 * * 0 php /path/to/this/file.php
 *
 * you need to change PATH_TO_MANCUBUS_CLASS to find the required PHP class
 */

# Encoding and error reporting setting
mb_http_output('UTF-8');
mb_internal_encoding('UTF-8');
error_reporting(-1); // E_ALL & E_STRICT

# default time setting
date_default_timezone_set('Europe/Berlin');

# PATH to mancubus.class.php
define('PATH_TO_MANCUBUS_CLASS','/path/to/selfpaste/mancubus.class.php');

# verbose output
# false no output
# true for output
$verbose=false;

require_once(PATH_TO_MANCUBUS_CLASS);

if($verbose == true) echo "Selfpaste cleanup start\n";
$mancubus = new Mancubus();
$mancubus->cleanupCronjob($verbose);
if($verbose == true) echo "Selfpaste cleanup end\n";
