zoneclearFeedServer/cron-script.php

93 lines
1.9 KiB
PHP
Raw Normal View History

2015-04-25 19:25:03 +00:00
#!/usr/bin/env php
<?php
# This file is highly based cron-script.php
# From Dotclear extension called planet
# By Olivier Meunier and contributors
# Licensed under the GPL version 2.0 license
$opts = getopt('d:c:b:u:h');
function help($status=0)
{
echo
"Options: \n".
" -h shows this help\n".
" -d DotClear root path\n".
" -c DotClear conf path\n".
" -b Blog ID\n".
" -u User ID\n\n";
exit($status);
2015-04-25 19:25:03 +00:00
}
if (isset($opts['h'])) {
help();
2015-04-25 19:25:03 +00:00
}
$dc_root = null;
$dc_conf = null;
$blog_id = null;
if (isset($opts['d'])) {
$dc_root = $opts['d'];
2015-04-25 19:25:03 +00:00
} elseif (isset($_SERVER['DC_ROOT'])) {
$dc_root = $_SERVER['DC_ROOT'];
2015-04-25 19:25:03 +00:00
}
if (isset($opts['c'])) {
$dc_conf = realpath($opts['c']);
2015-04-25 19:25:03 +00:00
} elseif (isset($_SERVER['DC_RC_PATH'])) {
$dc_conf = realpath($_SERVER['DC_RC_PATH']);
2015-04-25 19:25:03 +00:00
}
if (isset($opts['b'])) {
$blog_id = $opts['b'];
2015-04-25 19:25:03 +00:00
} elseif (isset($_SERVER['DC_BLOG_ID'])) {
$blog_id = $opts['DC_BLOG_ID'];
2015-04-25 19:25:03 +00:00
}
if (!$dc_root || !is_dir($dc_root)) {
fwrite(STDERR,"DotClear root path is not defined\n\n");
help(1);
2015-04-25 19:25:03 +00:00
}
if (!$dc_conf || !is_readable($dc_conf)) {
fwrite(STDERR,"DotClear configuration not found\n\n");
help(1);
2015-04-25 19:25:03 +00:00
}
if (!$blog_id) {
fwrite(STDERR,"Blog ID is not defined\n\n");
help(1);
2015-04-25 19:25:03 +00:00
}
$_SERVER['DC_RC_PATH'] = $dc_conf;
unset($dc_conf);
define('DC_BLOG_ID',$blog_id);
unset($blog_id);
require $dc_root.'/inc/prepend.php';
unset($dc_root);
$core->setBlog(DC_BLOG_ID);
if ($core->blog->id == null) {
fwrite(STDERR,"Blog is not defined\n");
exit(1);
2015-04-25 19:25:03 +00:00
}
if (!isset($opts['u']) || !$core->auth->checkUser($opts['u'])) {
fwrite(STDERR,"Unable to set user\n");
exit(1);
2015-04-25 19:25:03 +00:00
}
$core->plugins->loadModules(DC_PLUGINS_ROOT);
$core->blog->settings->addNamespace('zoneclearFeedServer');
try {
$zc = new zoneclearFeedServer($core);
$zc->checkFeedsUpdate();
2015-04-25 19:25:03 +00:00
} catch (Exception $e) {
fwrite(STDERR,$e->getMessage()."\n");
exit(1);
2015-04-25 19:25:03 +00:00
}