aboutsummaryrefslogtreecommitdiffstats
path: root/include/directory.php
blob: 5b56987684049d35d6af1f2be3e60771bd78e90c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once('boot.php');
require_once('include/zot.php');
require_once('include/cli_startup.php');

function find_upstream_directory($dirmode) {
	return;
}

function directory_run($argv, $argc){

	cli_startup();		 

	if($argc != 2)
		return;

	$dirmode = get_config('system','directory_mode');
	if($dirmode === false)
		$dirmode = DIRECTORY_MODE_NORMAL;

	if(($dirmode == DIRECTORY_MODE_PRIMARY) || ($dirmode == DIRECTORY_MODE_STANDALONE)) {
		// syncdirs();
		return;
	}

	$x = q("select * from channel where channel_id = %d limit 1",
		intval($argv[1])
	);
	if(! $x)
		return;

	$channel = $x[0];

	// is channel profile visible to the public?
	// FIXME - remove dir entry if permission is revoked

	if(! perm_is_allowed($channel['channel_id'],null,'view_profile'))
		return;

	$directory = find_upstream_directory($dirmode);

	if($directory) {
		$url = $directory['url'];
	}
	else {
		$url = DIRECTORY_FALLBACK_MASTER . '/post';
	}

	$packet = zot_build_packet($channel,'refresh');
	$z = zot_zot($url,$packet);

	// re-queue if unsuccessful

}

if (array_search(__file__,get_included_files())===0){
  directory_run($argv,$argc);
  killme();
}