howardjones / network-weathermap

Network Weathermap draws diagrams from data
http://www.network-weathermap.com/
MIT License
423 stars 95 forks source link

Weathermap cannot run outside dir #235

Closed Hipska closed 4 years ago

Hipska commented 4 years ago

Running weathermap outside it's directory results in multiple errors: $ /opt/weathermap/weathermap

PHP Warning: opendir(/opt/weathermap//opt/weathermap/lib/lib/datasources): failed to open dir: No such file or directory in /opt/weathermap/lib/Weathermap.class.php on line 719 WARNING: Couldn't open data Plugin directory (/opt/weathermap/lib/lib/datasources). Things will probably go wrong. [WMWARN06] PHP Warning: opendir(/opt/weathermap//opt/weathermap/lib/lib/pre): failed to open dir: No such file or directory in /opt/weathermap/lib/Weathermap.class.php on line 719 WARNING: Couldn't open pre Plugin directory (/opt/weathermap/lib/lib/pre). Things will probably go wrong. [WMWARN06] PHP Warning: opendir(/opt/weathermap//opt/weathermap/lib/lib/post): failed to open dir: No such file or directory in /opt/weathermap/lib/Weathermap.class.php on line 719 WARNING: Couldn't open post Plugin directory (/opt/weathermap/lib/lib/post). Things will probably go wrong. [WMWARN06]

howardjones commented 4 years ago

Interesting. Which version is this? (I guess 0.98a?)

Hipska commented 4 years ago

Correct. Looking at the code, it’s completely normal behavior

howardjones commented 4 years ago

I'll check into it. It certainly did work once!

howardjones commented 4 years ago

OK, so it's since all the class php files went into lib/

Here's a one-line fix for it:

--- a/lib/Weathermap.class.php
+++ b/lib/Weathermap.class.php
@@ -708,14 +708,16 @@ function LoadPlugins( $type="data", $dir="lib/datasources" )
        wm_debug("Beginning to load $type plugins from $dir\n");

     if ( ! file_exists($dir)) {
-        $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . $dir;
+        $dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $dir;
         wm_debug("Relative path didn't exist. Trying $dir\n");
     }

That's line 711 of Weathermap.class.php with the actual change.

Hipska commented 4 years ago

Many thanks for the quick fix!