]> git.mxchange.org Git - friendica-addons.git/commitdiff
privacy_image_cache: Adding a file cache
authorMichael Vogel <icarus@dabo.de>
Wed, 25 Jul 2012 19:37:48 +0000 (21:37 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 25 Jul 2012 19:37:48 +0000 (21:37 +0200)
statusnet/twitter: Adding detection of another recycle sign

privacy_image_cache/privacy_image_cache.php
statusnet/statusnet.php
twitter/twitter.php

index f0d8e39ac55b24b2a5d4b31a1900d61911cc2bcc..e74054e9f5a92bb5241a58785ae9ec9a2e635132 100644 (file)
@@ -34,6 +34,9 @@ function privacy_image_cache_module() {}
 function privacy_image_cache_init() {
        global $a;
 
+       if ($a->config["system"]["db_log"] != "")
+               $stamp1 = microtime(true);
+
        if(function_exists('header_remove')) {
                header_remove('Pragma');
                header_remove('pragma');
@@ -57,18 +60,34 @@ function privacy_image_cache_init() {
 
                        echo $img_str;
 
+                       if ($a->config["system"]["db_log"] != "") {
+                               $stamp2 = microtime(true);
+                               $duration = round($stamp2-$stamp1, 3);
+                               if ($duration > $a->config["system"]["db_loglimit"])
+                                       @file_put_contents($a->config["system"]["db_log"], $duration."\t".strlen($img_str)."\t".$_REQUEST['url']."\n", FILE_APPEND);
+                       }
+
                        killme();
                }
        }
 
+       require_once("Photo.php");
+
        $r = q("SELECT * FROM `photo` WHERE `resource-id` in ('%s', '%s') LIMIT 1", $urlhash, $urlhash2);
        if (count($r)) {
                $img_str = $r[0]['data'];
                $mime = $r[0]["desc"];
                if ($mime == "") $mime = "image/jpeg";
-       } else {
-               require_once("Photo.php");
 
+               // Test
+               if ($mime == "image/jpeg") {
+                       $img = new Photo($img_str);
+                       if($img->is_valid()) {
+                               $img->scaleImage(1000);
+                               $img_str = $img->imageString();
+                       }
+               }
+       } else {
                // It shouldn't happen but it does - spaces in URL
                $_REQUEST['url'] = str_replace(" ", "+", $_REQUEST['url']);
 
@@ -110,6 +129,7 @@ function privacy_image_cache_init() {
                        $img = new Photo($img_str);
                        if($img->is_valid()) {
                                $img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
+                               $img->scaleImage(1000); // Test
                                $img_str = $img->imageString();
                        }
                        $mime = "image/jpeg";
@@ -126,6 +146,13 @@ function privacy_image_cache_init() {
 
        echo $img_str;
 
+       if ($a->config["system"]["db_log"] != "") {
+               $stamp2 = microtime(true);
+               $duration = round($stamp2-$stamp1, 3);
+               if ($duration > $a->config["system"]["db_loglimit"])
+                       @file_put_contents($a->config["system"]["db_log"], $duration."\t".strlen($img_str)."\t".$_REQUEST['url']."\n", FILE_APPEND);
+       }
+
        killme();
 }
 
index b433f57b2ae9ff6c3c7467662ca98ecd1b762859..46b3f03f520fa3fab23581da76839430bf54b10b 100755 (executable)
@@ -460,9 +460,9 @@ function statusnet_post_hook(&$a,&$b) {
                        // recycle 1
                        $recycle = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
                        $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
-                       // recycle 2
-                       //$recycle = html_entity_decode("&#x267B; ", ENT_QUOTES, 'UTF-8');
-                       //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
+                       // recycle 2 (test)
+                       $recycle = html_entity_decode("&#x25CC; ", ENT_QUOTES, 'UTF-8');
+                       $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
                 }
                 // preserve links to webpages
                 $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
index 04c1c87df4e147526075f19ba39693780e76b4e2..cb7b03bb37086faa6464443838a0fc00d404e982 100755 (executable)
@@ -326,9 +326,9 @@ function twitter_post_hook(&$a,&$b) {
                        // recycle 1
                        $recycle = html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8');
                        $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
-                       // recycle 2
-                       //$recycle = html_entity_decode("&#x267B; ", ENT_QUOTES, 'UTF-8');
-                       //$tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', 'RT @$2:', $tmp);
+                       // recycle 2 (Test)
+                       $recycle = html_entity_decode("&#x25CC; ", ENT_QUOTES, 'UTF-8');
+                       $tmp = preg_replace( '/'.$recycle.'\[url\=(\w+.*?)\](\w+.*?)\[\/url\]/i', $recycle.'$2', $tmp);
                 }
                 $tmp = preg_replace( '/\[url\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/url\]/i', '$2 $1', $tmp);
                 $tmp = preg_replace( '/\[bookmark\=(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)\](\w+.*?)\[\/bookmark\]/i', '$2 $1', $tmp);