]> git.mxchange.org Git - friendica.git/blobdiff - include/directory.php
Resubmit all profiles on directory change
[friendica.git] / include / directory.php
index 5f835dc4bf58dc036a4ebbc33a46cfb3585bca0b..4a221fac0c3565ca2b598403e8131c0f084d7a6b 100644 (file)
@@ -1,28 +1,41 @@
 <?php
-
-       require_once("boot.php");
-
-       $a = new App;
-
-       @include(".htconfig.php");
-       require_once("dba.php");
-       $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-
-
-       if($argc != 2)
-               exit;
-
-       load_config('system');
-
-       $a->set_baseurl(get_config('system','url'));
-
-       $dir = get_config('system','directory_submit_url');
-
-       if(! strlen($dir))
-               exit;
-
-       fetch_url($dir . '?url=' . bin2hex($argv[1]));
-
-       exit;
-
+use \Friendica\Core\Config;
+
+function directory_run(&$argv, &$argc){
+       $dir = get_config('system', 'directory');
+
+       if (!strlen($dir)) {
+               return;
+       }
+
+       if ($argc < 2) {
+               directory_update_all();
+               return;
+       }
+
+       $dir .= "/submit";
+
+       $arr = array('url' => $argv[1]);
+
+       call_hooks('globaldir_update', $arr);
+
+       logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
+       if (strlen($arr['url'])) {
+               fetch_url($dir . '?url=' . bin2hex($arr['url']));
+       }
+       return;
+}
+
+function directory_update_all() {
+       $r = q("SELECT `url` FROM `contact`
+               INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
+               INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
+                       WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND
+                               NOT `user`.`account_expired` AND `user`.`verified`");
+
+       if (dbm::is_result($r)) {
+               foreach ($r AS $user) {
+                       proc_run(PRIORITY_LOW, 'include/directory.php', $user['url']);
+               }
+       }
+}