]> git.mxchange.org Git - friendica.git/blobdiff - include/onepoll.php
Opps ...
[friendica.git] / include / onepoll.php
index 552fea36fa9bd9c7d9d7dc15734e41a77953a63a..dfb0db9e37a59ad828f7fee8315a781cf649537d 100644 (file)
@@ -2,8 +2,7 @@
 
 use \Friendica\Core\Config;
 
-require_once("boot.php");
-require_once("include/follow.php");
+require_once('include/follow.php');
 
 function RemoveReply($subject) {
        while (in_array(strtolower(substr($subject, 0, 3)), array("re:", "aw:")))
@@ -13,20 +12,8 @@ function RemoveReply($subject) {
 }
 
 function onepoll_run(&$argv, &$argc){
-       global $a, $db;
+       global $a;
 
-       if (is_null($a)) {
-               $a = new App;
-       }
-
-       if (is_null($db)) {
-               @include(".htconfig.php");
-               require_once("include/dba.php");
-               $db = new dba($db_host, $db_user, $db_pass, $db_data);
-               unset($db_host, $db_user, $db_pass, $db_data);
-       };
-
-       require_once('include/session.php');
        require_once('include/datetime.php');
        require_once('include/items.php');
        require_once('include/Contact.php');
@@ -34,12 +21,6 @@ function onepoll_run(&$argv, &$argc){
        require_once('include/socgraph.php');
        require_once('include/queue_fn.php');
 
-       Config::load();
-
-       $a->set_baseurl(get_config('system','url'));
-
-       load_hooks();
-
        logger('onepoll: start');
 
        $manual_id  = 0;
@@ -61,13 +42,6 @@ function onepoll_run(&$argv, &$argc){
                return;
        }
 
-       // Don't check this stuff if the function is called by the poller
-       if (App::callstack() != "poller_run") {
-               if (App::is_already_running('onepoll'.$contact_id, '', 540)) {
-                       return;
-               }
-       }
-
        $d = datetime_convert();
 
        // Only poll from those with suitable relationships,
@@ -87,7 +61,7 @@ function onepoll_run(&$argv, &$argc){
                intval($contact_id)
        );
 
-       if (! count($contacts)) {
+       if (! dbm::is_result($contacts)) {
                return;
        }
 
@@ -463,16 +437,18 @@ function onepoll_run(&$argv, &$argc){
                                                if ($raw_refs) {
                                                        $refs_arr = explode(' ', $raw_refs);
                                                        if (count($refs_arr)) {
-                                                               for($x = 0; $x < count($refs_arr); $x ++)
+                                                               for ($x = 0; $x < count($refs_arr); $x ++) {
                                                                        $refs_arr[$x] = "'" . msgid2iri(str_replace(array('<','>',' '),array('','',''),dbesc($refs_arr[$x]))) . "'";
+                                                               }
                                                        }
                                                        $qstr = implode(',',$refs_arr);
                                                        $r = q("SELECT `uri` , `parent-uri` FROM `item` USE INDEX (`uid_uri`) WHERE `uri` IN ($qstr) AND `uid` = %d LIMIT 1",
                                                                intval($importer_uid)
                                                        );
-                                                       if (dbm::is_result($r))
+                                                       if (dbm::is_result($r)) {
                                                                $datarray['parent-uri'] = $r[0]['parent-uri'];  // Set the parent as the top-level item
-       //                                                      $datarray['parent-uri'] = $r[0]['uri'];
+                                                               //$datarray['parent-uri'] = $r[0]['uri'];
+                                                       }
                                                }
 
                                                // Decoding the header
@@ -697,8 +673,3 @@ function onepoll_run(&$argv, &$argc){
 
        return;
 }
-
-if (array_search(__file__,get_included_files())===0) {
-       onepoll_run($_SERVER["argv"],$_SERVER["argc"]);
-       killme();
-}