]> git.mxchange.org Git - friendica.git/blobdiff - include/poller.php
Merge commit 'upstream/master'
[friendica.git] / include / poller.php
index 65fafda4c86fb42c1d26768fa3869a0d8190b17a..499483d007dea6ecaffde1d9c4d0fffb420e79e3 100755 (executable)
@@ -25,10 +25,20 @@ function poller_run($argv, $argc){
        require_once('include/Contact.php');
        require_once('include/email.php');
        require_once('include/socgraph.php');
+       require_once('include/pidfile.php');
 
        load_config('config');
        load_config('system');
 
+       $lockpath = get_config('system','lockpath');
+       if ($lockpath != '') {
+               $pidfile = new pidfile($lockpath, 'poller.lck');
+               if($pidfile->is_already_running()) {
+                       logger("poller: Already running");
+                       exit;
+               }
+       }
+
        $a->set_baseurl(get_config('system','url'));
 
        load_hooks();
@@ -75,7 +85,7 @@ function poller_run($argv, $argc){
                if ($dh = opendir($cache)) {
                        while (($file = readdir($dh)) !== false) {
                                $fullpath = $cache."/".$file;
-                               if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - 1800))
+                               if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - 86400))
                                        unlink($fullpath);
                        }
                        closedir($dh);
@@ -232,7 +242,7 @@ function poller_run($argv, $argc){
 
                        $importer_uid = $contact['uid'];
                
-                       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
+                       $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
                                intval($importer_uid)
                        );
                        if(! count($r))
@@ -504,7 +514,12 @@ function poller_run($argv, $argc){
                                                        //$datarray['title'] = notags(trim($meta->subject));
                                                        $datarray['created'] = datetime_convert('UTC','UTC',$meta->date);
 
-                                                       $r = email_get_msg($mbox,$msg_uid);
+                                                       // Is it  reply?
+                                                       $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or
+                                                               (substr(strtolower($datarray['title']), 0, 3) == "re-") or
+                                                               (raw_refs != ""));
+
+                                                       $r = email_get_msg($mbox,$msg_uid, $reply);
                                                        if(! $r) {
                                                                logger("Mail: can't fetch msg ".$msg_uid);
                                                                continue;