copy index.surrogator.html to index.html if it does not exist
[surrogator.git] / surrogator.php
index 393b0a2bd4e1bfb43f737ecc0f48f4848340ba5d..c7c9d5491d70ba4d5781f24518b06206950a955a 100755 (executable)
@@ -11,7 +11,7 @@
  * @package  Surrogator
  * @author   Christian Weiske <cweiske@cweiske.de>
  * @license  http://www.gnu.org/licenses/agpl.html AGPLv3 or later
- * @link     http://git.cweiske.de/?p=surrogator.git
+ * @link     https://sourceforge.net/p/surrogator/
  */
 namespace surrogator;
 $cfgFile = __DIR__ . '/data/surrogator.config.php';
@@ -115,6 +115,17 @@ foreach ($sizes as $size) {
         mkdir($varDir . '/' . $size, 0755);
     }
 }
+foreach (array('mm.png', 'default.png') as $resFile) {
+    if (!file_exists($rawDir . '/' . $resFile)) {
+        log($resFile . ' missing, copying it from res/', 2);
+        copy(__DIR__ . '/res/' . $resFile, $rawDir . '/' . $resFile);
+    }
+}
+
+if (!file_exists($wwwDir . '/index.html') && is_writable($wwwDir)) {
+    log('no index.html found, copying default over', 1);
+    copy($wwwDir . '/index.surrogator.html', $wwwDir . '/index.html');
+}
 
 if (count($files)) {
     $fileInfos = array();
@@ -146,6 +157,8 @@ foreach ($fileInfos as $fileInfo) {
 
     if ($fileName == 'default.png') {
         $md5 = $sha256 = 'default';
+    } else if ($fileName == 'mm.png') {
+        $md5 = $sha256 = 'mm';
     } else {
         list($md5, $sha256) = getHashes($fileName);
     }