modify classifier docs, make web app work if exec not allow, a=chris

Chris Pollett [2015-08-15 00:Aug:th]
modify classifier docs, make web app work if exec not allow, a=chris
Filename
src/configs/Config.php
src/controllers/components/SystemComponent.php
src/executables/ClassifierTool.php
src/library/Utility.php
src/models/GroupModel.php
diff --git a/src/configs/Config.php b/src/configs/Config.php
index 80a221ed3..e92f64808 100755
--- a/src/configs/Config.php
+++ b/src/configs/Config.php
@@ -484,8 +484,10 @@ function defineMemoryProfile()

     $memory = 4000000000; //assume have at least 4GB on a Mac (could use vm_stat)
     if (strstr(PHP_OS, "WIN")) {
-        exec('wmic memorychip get capacity', $memory_array);
-        $memory = array_sum($memory_array);
+        if (function_exists("exec")) {
+            exec('wmic memorychip get capacity', $memory_array);
+            $memory = array_sum($memory_array);
+        }
     } else if (stristr(PHP_OS, "LINUX")) {
         $data = preg_split("/\s+/", file_get_contents("/proc/meminfo"));
         $memory = 1024 * intval($data[1]);
diff --git a/src/controllers/components/SystemComponent.php b/src/controllers/components/SystemComponent.php
index b0bbaf3b2..ac70aec78 100755
--- a/src/controllers/components/SystemComponent.php
+++ b/src/controllers/components/SystemComponent.php
@@ -885,8 +885,8 @@ EOD;
         }
         $locale_tag = L\getLocaleTag();
         $not_null_fields = [
-            'LOGO' => "Resources/yioop.png",
-            'M_LOGO' => "Resources/m-yioop.png",
+            'LOGO' => "resources/yioop.png",
+            'M_LOGO' => "resources/m-yioop.png",
             'FAVICON' => C\BASE_URL."favicon.ico",
             'TIMEZONE' => 'America/Los_Angeles',
             'SESSION_NAME' => "yioopbiscuit",
diff --git a/src/executables/ClassifierTool.php b/src/executables/ClassifierTool.php
index e78c4f98a..b6711daa6 100755
--- a/src/executables/ClassifierTool.php
+++ b/src/executables/ClassifierTool.php
@@ -101,9 +101,10 @@ To build and evaluate a classifier for the label 'spam', trained using the
 two indexes "DATASET Neg" and "DATASET Pos", and a maximum of the top 25
 most informative features:

-php bin/ClassifierTool.php -a TrainAndTest -d 'DATASET' -l 'spam'
+php ClassifierTool.php -a TrainAndTest -d 'DATASET' -l 'spam'
     -I cls.chi2.max=25

+The above assume we are in the folder of ClassifierTool.php
 EOD;

 /*
diff --git a/src/library/Utility.php b/src/library/Utility.php
index 41c1e7f6e..49613f329 100755
--- a/src/library/Utility.php
+++ b/src/library/Utility.php
@@ -1851,21 +1851,25 @@ function mimeType($file_name)
     if (class_exists("\finfo")) {
         $finfo = new \finfo(FILEINFO_MIME);
         $mime_type = $finfo->file($file_name);
-    } else {
+    } else if(function_exists("exec")) {
         $mime_type = exec('file -b --mime-type ' . $file_name);
+    } else {
+        $last_chars = substr($file_name, -4);
+        $mime_types = [
+            ".avi" => "video/x-msvideo",
+            ".bmp" => "image/bmp",
+            ".css" => "text/css",
+            ".gif" => "image/gif",
+            ".jpg" => "image/jpeg",
+            ".mov" => "video/quicktime",
+            ".mp4" => "video/mp4",
+            ".png" => "image/png"
+        ];
+        if (isset($mime_types[$last_chars])) {
+            $mime_type = $mime_types['$last_chars'];
+        }
     }
-    if (substr($file_name, -4) == ".css") {
-        $mime_type = "text/css";
-    }
-    if(substr($file_name, -4) == ".mov"){
-        $mime_type = "video/quicktime";
-    }
-    if(substr($file_name, -4) == ".avi"){
-        $mime_type = "video/x-msvideo";
-    }
-    if(substr($file_name, -4) == ".mp4"){
-        $mime_type = "video/mp4";
-    }
+
     $mime_type = str_replace('application/ogg', 'video/ogg', $mime_type);
     return $mime_type;
 }
diff --git a/src/models/GroupModel.php b/src/models/GroupModel.php
index feba9b745..6a54499ed 100644
--- a/src/models/GroupModel.php
+++ b/src/models/GroupModel.php
@@ -1456,7 +1456,9 @@ class GroupModel extends Model implements MediaConstants
                 C\FFMPEG . " -i \"$folder/$file_name\" -vframes 1 -map 0:v:0".
                 " -vf \"scale=".C\THUMB_DIM.":".C\THUMB_DIM."\" ".
                 "\"$thumb_folder/$file_name.jpg\" 2>&1";
-            exec($make_thumb_string);
+            if (function_exists("exec")) {
+                exec($make_thumb_string);
+            }
             clearstatcache("$thumb_folder/$file_name.jpg");
             if ($file_size < C\MAX_VIDEO_CONVERT_SIZE) {
                 $convert_folder = C\WORK_DIRECTORY. self::CONVERT_FOLDER;
ViewGit