]> git.mxchange.org Git - friendica.git/commitdiff
fix path for photo and proxy
authorJohannes Schwab <mail@jschwab.org>
Mon, 7 Dec 2015 23:10:12 +0000 (00:10 +0100)
committerJohannes Schwab <mail@jschwab.org>
Tue, 8 Dec 2015 10:31:50 +0000 (11:31 +0100)
mod/photo.php
mod/proxy.php

index fab34a62f03b395f33749d12e5cbb7b0e2634319..4166b4d53949d4f9cb5b1f9467c045b224ef98e0 100644 (file)
@@ -197,12 +197,13 @@ function photo_init(&$a) {
        // If the photo is public and there is an existing photo directory store the photo there
        if ($public and ($file != "")) {
                // If the photo path isn't there, try to create it
        // If the photo is public and there is an existing photo directory store the photo there
        if ($public and ($file != "")) {
                // If the photo path isn't there, try to create it
-               if (!is_dir($_SERVER["DOCUMENT_ROOT"]."/photo"))
-                       if (is_writable($_SERVER["DOCUMENT_ROOT"]))
-                               mkdir($_SERVER["DOCUMENT_ROOT"]."/photo");
+               $basepath = $a->get_basepath();
+               if (!is_dir($basepath."/photo"))
+                       if (is_writable($basepath))
+                               mkdir($basepath."/photo");
 
 
-               if (is_dir($_SERVER["DOCUMENT_ROOT"]."/photo"))
-                       file_put_contents($_SERVER["DOCUMENT_ROOT"]."/photo/".$file, $data);
+               if (is_dir($basepath."/photo"))
+                       file_put_contents($basepath."/photo/".$file, $data);
        }
 
        killme();
        }
 
        killme();
index d26967dddf2f1e6e21d1749728f213236cbab419..c6bf6530218c55085330211c252fbca9073feee4 100644 (file)
@@ -44,14 +44,15 @@ function proxy_init() {
        $thumb = false;
        $size = 1024;
        $sizetype = "";
        $thumb = false;
        $size = 1024;
        $sizetype = "";
+       $basepath = $a->get_basepath();
 
        // If the cache path isn't there, try to create it
 
        // If the cache path isn't there, try to create it
-       if (!is_dir($_SERVER["DOCUMENT_ROOT"]."/proxy"))
-               if (is_writable($_SERVER["DOCUMENT_ROOT"]))
-                       mkdir($_SERVER["DOCUMENT_ROOT"]."/proxy");
+       if (!is_dir($basepath."/proxy"))
+               if (is_writable($basepath))
+                       mkdir($basepath."/proxy");
 
        // Checking if caching into a folder in the webroot is activated and working
 
        // Checking if caching into a folder in the webroot is activated and working
-       $direct_cache = (is_dir($_SERVER["DOCUMENT_ROOT"]."/proxy") AND is_writable($_SERVER["DOCUMENT_ROOT"]."/proxy"));
+       $direct_cache = (is_dir($basepath."/proxy") AND is_writable($basepath."/proxy"));
 
        // Look for filename in the arguments
        if ((isset($a->argv[1]) OR isset($a->argv[2]) OR isset($a->argv[3])) AND !isset($_REQUEST["url"])) {
 
        // Look for filename in the arguments
        if ((isset($a->argv[1]) OR isset($a->argv[2]) OR isset($a->argv[3])) AND !isset($_REQUEST["url"])) {
@@ -211,9 +212,9 @@ function proxy_init() {
        // advantage: real file access is really fast
        // Otherwise write in cachefile
        if ($valid AND $direct_cache) {
        // advantage: real file access is really fast
        // Otherwise write in cachefile
        if ($valid AND $direct_cache) {
-               file_put_contents($_SERVER["DOCUMENT_ROOT"]."/proxy/".proxy_url($_REQUEST['url'], true), $img_str_orig);
+               file_put_contents($basepath."/proxy/".proxy_url($_REQUEST['url'], true), $img_str_orig);
                if ($sizetype <> '')
                if ($sizetype <> '')
-                       file_put_contents($_SERVER["DOCUMENT_ROOT"]."/proxy/".proxy_url($_REQUEST['url'], true).$sizetype, $img_str);
+                       file_put_contents($basepath."/proxy/".proxy_url($_REQUEST['url'], true).$sizetype, $img_str);
        } elseif ($cachefile != '')
                file_put_contents($cachefile, $img_str_orig);
 
        } elseif ($cachefile != '')
                file_put_contents($cachefile, $img_str_orig);
 
@@ -247,7 +248,7 @@ function proxy_url($url, $writemode = false, $size = "") {
                return($url);
 
        // Creating a sub directory to reduce the amount of files in the cache directory
                return($url);
 
        // Creating a sub directory to reduce the amount of files in the cache directory
-       $basepath = $_SERVER["DOCUMENT_ROOT"]."/proxy";
+       $basepath = $a->get_basepath()."/proxy";
 
        $path = substr(hash("md5", $url), 0, 2);
 
 
        $path = substr(hash("md5", $url), 0, 2);