require_once('include/features.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica');
- define ( 'FRIENDICA_VERSION', '3.0.1545' );
+ define ( 'FRIENDICA_VERSION', '3.1.1559' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1157 );
$this->is_tablet = $mobile_detect->isTablet();
}
+ function get_basepath() {
+
+ $basepath = get_config("system", "basepath");
+
+ if ($basepath == "")
+ $basepath = $_SERVER["DOCUMENT_ROOT"];
+
+ if ($basepath == "")
+ $basepath = $_SERVER["PWD"];
+
+ return($basepath);
+ }
+
function get_baseurl($ssl = false) {
$scheme = $this->scheme;
$fullpath = $path."/".$file;
if ((filetype($fullpath) == "dir") and ($file != ".") and ($file != ".."))
clear_cache($basepath, $fullpath);
- if ((filetype($fullpath) == "file") and filectime($fullpath) < (time() - $cachetime))
+ if ((filetype($fullpath) == "file") and (filectime($fullpath) < (time() - $cachetime)))
unlink($fullpath);
}
closedir($dh);
require_once("boot.php");
+function RemoveReply($subject) {
+ while (in_array(strtolower(substr($subject, 0, 3)), array("re:", "aw:")))
+ $subject = trim(substr($subject, 4));
+
+ return($subject);
+}
+
function onepoll_run(&$argv, &$argc){
global $a, $db;
if($contact['network'] === NETWORK_DFRN) {
+
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
if(intval($contact['duplex']) && $contact['dfrn-id'])
$idtosend = '0:' . $orig_id;
// they have permission to write to us. We already filtered this in the contact query.
$perm = 'rw';
+ // But this may be our first communication, so set the writable flag if it isn't set already.
+
+ if(! intval($contact['writable']))
+ q("update contact set writable = 1 where id = %d limit 1", intval($contact['id']));
+
+
$url = $contact['poll'] . '?dfrn_id=' . $idtosend
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
. '&type=data&last_update=' . $last_update
// $datarray['parent-uri'] = $r[0]['uri'];
}
-
- if(! x($datarray,'parent-uri'))
- $datarray['parent-uri'] = $datarray['uri'];
-
// Decoding the header
$subject = imap_mime_header_decode($meta->subject);
$datarray['title'] = "";
//$datarray['title'] = notags(trim($meta->subject));
$datarray['created'] = datetime_convert('UTC','UTC',$meta->date);
- // Is it reply?
+ // Is it a reply?
$reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or
(substr(strtolower($datarray['title']), 0, 3) == "re-") or
(raw_refs != ""));
+ // Remove Reply-signs in the subject
+ $datarray['title'] = RemoveReply($datarray['title']);
+
+ // If it seems to be a reply but a header couldn't be found take the last message with matching subject
+ if(!x($datarray,'parent-uri') and $reply) {
+ $r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) ORDER BY `created` DESC LIMIT 1",
+ besc(protect_sprintf($datarray['title'])));
+ if(count($r))
+ $datarray['parent-uri'] = $r[0]['parent-uri'];
+ }
+
+ if(! x($datarray,'parent-uri'))
+ $datarray['parent-uri'] = $datarray['uri'];
+
+
$r = email_get_msg($mbox,$msg_uid, $reply);
if(! $r) {
logger("Mail: can't fetch msg ".$msg_uid." for ".$mailconf[0]['user']);