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');
|
|
|
|
|
2022-11-15 20:05:21 +00:00
|
|
|
function zchelp($status = 0)
|
2015-04-25 19:25:03 +00:00
|
|
|
{
|
2021-09-11 09:56:57 +00:00
|
|
|
echo
|
2021-11-06 15:30:19 +00:00
|
|
|
"Options: \n" .
|
|
|
|
" -h shows this help\n" .
|
|
|
|
" -d DotClear root path\n" .
|
|
|
|
" -c DotClear conf path\n" .
|
|
|
|
" -b Blog ID\n" .
|
2021-09-11 09:56:57 +00:00
|
|
|
" -u User ID\n\n";
|
|
|
|
exit($status);
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($opts['h'])) {
|
2022-11-15 20:05:21 +00:00
|
|
|
zchelp();
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$dc_root = null;
|
|
|
|
$dc_conf = null;
|
|
|
|
$blog_id = null;
|
|
|
|
|
|
|
|
if (isset($opts['d'])) {
|
2021-09-11 09:56:57 +00:00
|
|
|
$dc_root = $opts['d'];
|
2015-04-25 19:25:03 +00:00
|
|
|
} elseif (isset($_SERVER['DC_ROOT'])) {
|
2021-09-11 09:56:57 +00:00
|
|
|
$dc_root = $_SERVER['DC_ROOT'];
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($opts['c'])) {
|
2021-09-11 09:56:57 +00:00
|
|
|
$dc_conf = realpath($opts['c']);
|
2015-04-25 19:25:03 +00:00
|
|
|
} elseif (isset($_SERVER['DC_RC_PATH'])) {
|
2021-09-11 09:56:57 +00:00
|
|
|
$dc_conf = realpath($_SERVER['DC_RC_PATH']);
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($opts['b'])) {
|
2021-09-11 09:56:57 +00:00
|
|
|
$blog_id = $opts['b'];
|
2015-04-25 19:25:03 +00:00
|
|
|
} elseif (isset($_SERVER['DC_BLOG_ID'])) {
|
2021-09-11 09:56:57 +00:00
|
|
|
$blog_id = $opts['DC_BLOG_ID'];
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$dc_root || !is_dir($dc_root)) {
|
2021-11-06 15:30:19 +00:00
|
|
|
fwrite(STDERR, "DotClear root path is not defined\n\n");
|
2022-11-15 20:05:21 +00:00
|
|
|
zchelp(1);
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$dc_conf || !is_readable($dc_conf)) {
|
2021-11-06 15:30:19 +00:00
|
|
|
fwrite(STDERR, "DotClear configuration not found\n\n");
|
2022-11-15 20:05:21 +00:00
|
|
|
zchelp(1);
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$blog_id) {
|
2021-11-06 15:30:19 +00:00
|
|
|
fwrite(STDERR, "Blog ID is not defined\n\n");
|
2022-11-15 20:05:21 +00:00
|
|
|
zchelp(1);
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$_SERVER['DC_RC_PATH'] = $dc_conf;
|
|
|
|
unset($dc_conf);
|
|
|
|
|
2021-11-06 15:30:19 +00:00
|
|
|
define('DC_BLOG_ID', $blog_id);
|
2015-04-25 19:25:03 +00:00
|
|
|
unset($blog_id);
|
|
|
|
|
2021-11-06 15:30:19 +00:00
|
|
|
require $dc_root . '/inc/prepend.php';
|
2015-04-25 19:25:03 +00:00
|
|
|
unset($dc_root);
|
|
|
|
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->setBlog(DC_BLOG_ID);
|
|
|
|
if (dcCore::app()->blog->id == null) {
|
2021-11-06 15:30:19 +00:00
|
|
|
fwrite(STDERR, "Blog is not defined\n");
|
2021-09-11 09:56:57 +00:00
|
|
|
exit(1);
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-11-15 20:05:21 +00:00
|
|
|
if (!isset($opts['u']) || !dcCore::app()->auth->checkUser($opts['u'])) {
|
2021-11-06 15:30:19 +00:00
|
|
|
fwrite(STDERR, "Unable to set user\n");
|
2021-09-11 09:56:57 +00:00
|
|
|
exit(1);
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->plugins->loadModules(DC_PLUGINS_ROOT);
|
2015-04-25 19:25:03 +00:00
|
|
|
|
2022-12-11 19:18:26 +00:00
|
|
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
2015-04-25 19:25:03 +00:00
|
|
|
|
|
|
|
try {
|
2022-11-15 20:05:21 +00:00
|
|
|
$zc = new zoneclearFeedServer();
|
2021-09-11 09:56:57 +00:00
|
|
|
$zc->checkFeedsUpdate();
|
2015-04-25 19:25:03 +00:00
|
|
|
} catch (Exception $e) {
|
2021-11-06 15:30:19 +00:00
|
|
|
fwrite(STDERR, $e->getMessage() . "\n");
|
2021-09-11 09:56:57 +00:00
|
|
|
exit(1);
|
2021-11-06 15:30:19 +00:00
|
|
|
}
|