streams/include/directory.php

64 lines
1.3 KiB
PHP
Raw Normal View History

2013-02-26 01:09:40 +00:00
<?php /** @file */
2012-10-23 08:35:06 +00:00
require_once('boot.php');
require_once('include/zot.php');
2012-10-23 08:35:06 +00:00
require_once('include/cli_startup.php');
require_once('include/dir_fns.php');
function directory_run($argv, $argc){
2012-10-23 08:35:06 +00:00
cli_startup();
if($argc != 2)
return;
2013-02-20 07:21:23 +00:00
logger('directory update', LOGGER_DEBUG);
$dirmode = get_config('system','directory_mode');
if($dirmode === false)
$dirmode = DIRECTORY_MODE_NORMAL;
$x = q("select * from channel where channel_id = %d limit 1",
intval($argv[1])
);
if(! $x)
return;
$channel = $x[0];
2013-06-18 09:51:43 +00:00
if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
syncdirs($argv[1]);
// Now update all the connections
proc_run('php','include/notifier.php','refresh_all',$channel['channel_id']);
return;
}
$directory = find_upstream_directory($dirmode);
if($directory) {
$url = $directory['url'];
}
else {
$url = DIRECTORY_FALLBACK_MASTER . '/post';
}
// ensure the upstream directory is updated
$packet = zot_build_packet($channel,'refresh');
$z = zot_zot($url,$packet);
// re-queue if unsuccessful
// Now update all the connections
2013-06-18 09:51:43 +00:00
proc_run('php','include/notifier.php','refresh_all',$channel['channel_id']);
}
if (array_search(__file__,get_included_files())===0){
directory_run($argv,$argc);
killme();
}