]> git.mxchange.org Git - friendica.git/blob - include/directory.php
4a221fac0c3565ca2b598403e8131c0f084d7a6b
[friendica.git] / include / directory.php
1 <?php
2 use \Friendica\Core\Config;
3
4 function directory_run(&$argv, &$argc){
5         $dir = get_config('system', 'directory');
6
7         if (!strlen($dir)) {
8                 return;
9         }
10
11         if ($argc < 2) {
12                 directory_update_all();
13                 return;
14         }
15
16         $dir .= "/submit";
17
18         $arr = array('url' => $argv[1]);
19
20         call_hooks('globaldir_update', $arr);
21
22         logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
23         if (strlen($arr['url'])) {
24                 fetch_url($dir . '?url=' . bin2hex($arr['url']));
25         }
26         return;
27 }
28
29 function directory_update_all() {
30         $r = q("SELECT `url` FROM `contact`
31                 INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
32                 INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
33                         WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND
34                                 NOT `user`.`account_expired` AND `user`.`verified`");
35
36         if (dbm::is_result($r)) {
37                 foreach ($r AS $user) {
38                         proc_run(PRIORITY_LOW, 'include/directory.php', $user['url']);
39                 }
40         }
41 }