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