// .. and verify existence of file. if (!file_exists($libsrc)) { die("Invalid CodeIgniter index path: {$options['ci-index']}\n"); } // If not called with any action-parameters (add,remove,list) assume cronjob call.. if (count(array_diff($actions, array_keys($options))) == count($actions)) { require_once $libsrc; exit; } else { define('CRONTAB_AS_LIB', TRUE); require_once $libsrc; } /** * Load crontab manager */ $crontab = new Crontab_Manager(); // Identify action to run foreach ($actions as $a) { if (array_key_exists($a, $options)) { $action = $a; break; } } // .. and run action! .. switch ($action) { case 'list': $crontab->load_jobs(); print_r($crontab->get_jobs()); break; case 'add': $cron_options = array();
if ($out !== FALSE) { $out = $result; } return $code; } } /** * If called from the command line, and not * from within CI and not with the flag CRONTAB_AS_LIB set, * assume this is a cronjob running and try to process it. */ if (strtolower(php_sapi_name()) == 'cli' and !defined('CRONTAB_AS_LIB') and !defined('BASEPATH')) { if (defined('CRONTAB_SCRIPT_CMD') and strlen(CRONTAB_SCRIPT_CMD)) { $crontab = new Crontab_Manager(CRONTAB_SCRIPT_CMD); } else { $crontab = new Crontab_Manager(); } $longopt = $crontab->_opts; foreach ($longopt as $k => $v) { switch ($k) { case 'job-id': $longopt[$k] = "{$v}:"; break; case 'ci-index': $longopt[$k] = "{$v}::"; case 'once': default: $longopt[$k] = "{$v}"; break; } }