]> git.mxchange.org Git - friendica.git/blobdiff - include/directory.php
Resubmit all profiles on directory change
[friendica.git] / include / directory.php
index 4fdcf4928165fb03abf493c3adb9b16a364ce24d..4a221fac0c3565ca2b598403e8131c0f084d7a6b 100644 (file)
@@ -1,28 +1,41 @@
 <?php
+use \Friendica\Core\Config;
 
-       require_once("boot.php");
+function directory_run(&$argv, &$argc){
+       $dir = get_config('system', 'directory');
 
-       $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)
+       if (!strlen($dir)) {
                return;
+       }
 
-       load_config('system');
-
-       $a->set_baseurl(get_config('system','url'));
+       if ($argc < 2) {
+               directory_update_all();
+               return;
+       }
 
-       $dir = get_config('system','directory_submit_url');
+       $dir .= "/submit";
 
-       if(! strlen($dir))
-               exit;
+       $arr = array('url' => $argv[1]);
 
-       fetch_url($dir . '?url=' . bin2hex($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']);
+               }
+       }
+}