<?php
//EXAMPLE without data base.
require_once('class.cron.php');
$crontab=new crontab("/cron/", "filename", 'a'); //if u want to delete the old pass the 'w' parameter instead of 'a'
$crontab->setDateParams($min, $hour, $day, $month, "*"); //min , hour , day , month , dayofweek
$crontab->setCommand("curl http://somedomain.com/index.php?mod=sendcron");
$crontab->savetodb();
$crontab->saveCronFile();
$crontab->addToCrontab();
$crontab->destroyFilePoint(); // OPTIONAL
/********************************************************************************************/
//ANOTHER EXAMPLE using connection to db
require_once('class.cron.php');
$crontab=new crontab("/cron/", "filename", 'w');
$crontab->prefix = $DBprefix;
$crontab->connectDatabase('localhost','user','password','database');
$crontab->title = $_POST["title"];
$crontab->setDateParams($min, $hour, $day, $month, "*");
$crontab->setCommand("wget http://somedomain.com/index.php?mod=sendcron");
$crontab->savetodb();
/*
If you want to add more croncommand use:
$crontab->clearParameters();
$crontab->setDateParams(5, 10, 5, 5, "*");
$crontab->setCommand("curl http://somedomain.com/index.php?mod=sendcron");
$crontab->savetodb();
*/
$crontab->saveCronFilebydb();
$crontab->addToCrontab();
//$crontab->showerror();
$crontab->destroyFilePoint();
$crontab->closeDB();
/**********************************************************************************************/
//ANOTHER EXAMPLE TO RETRIEVE THE DATA FROM THE DB
require_once('class.cron.php');
$crontab=new crontab("/cron/", "filename", 'w');
$crontab->prefix = $DBprefix;
$crontab->connectDatabase('localhost','user','password','database');
$result = $crontab->retrievedb();
foreach($result as $key => $item) {
echo $item["title"]."<br>\n";
}
$crontab->closeDB();
?>
|