comparison slbackup.php @ 159:d2905ee5ff9c

Add logging wrapper function.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 18 Sep 2017 09:50:23 +0300
parents 3b904b49ce57
children 58af72da7f60
comparison
equal deleted inserted replaced
158:f5c1861b48aa 159:d2905ee5ff9c
15 $dataName = "backup"; 15 $dataName = "backup";
16 $dataSuffix = ".sqlite3"; 16 $dataSuffix = ".sqlite3";
17 $dataMaxSize = 1024 * 1024; 17 $dataMaxSize = 1024 * 1024;
18 $dataBackups = 24; 18 $dataBackups = 24;
19 $configFile = "slbackup.cfg"; 19 $configFile = "slbackup.cfg";
20
21 if (file_exists($configFile))
22 require_once $configFile;
23 else
24 {
25 error_log("SyntilistaBackup: Configuration file '".$configFile."' does not exist!");
26 exit;
27 }
28 20
29 21
30 // 22 //
31 // Helper functions 23 // Helper functions
32 // 24 //
61 } 53 }
62 return TRUE; 54 return TRUE;
63 } 55 }
64 56
65 57
58 function stLog($msg)
59 {
60 error_log("SyntilistaBackup: ".$msg);
61 }
62
63
66 // 64 //
67 // Actual main code begins here 65 // Actual main code begins here
68 // 66 //
67 if (file_exists($configFile))
68 require_once $configFile;
69 else
70 {
71 stLog("Configuration file '".$configFile."' does not exist!");
72 exit;
73 }
74
75
69 $errorMsg = ""; 76 $errorMsg = "";
70 $errorSet = FALSE; 77 $errorSet = FALSE;
71 $index = "file"; 78 $index = "file";
72 79
73 if (!isset($dataSecret) || !isset($dataPath) || 80 if (!isset($dataSecret) || !isset($dataPath) ||
74 $dataSecret == "" || $dataPath == "") 81 $dataSecret == "" || $dataPath == "")
75 { 82 {
76 error_log("SyntilistaBackup: Invalid configuration."); 83 stLog("Invalid configuration.");
77 exit; 84 exit;
78 } 85 }
79 86
80 // Basic check for credentials .. 87 // Basic check for credentials ..
81 if (isset($_REQUEST["secret"]) && isset($_FILES[$index]) && 88 if (isset($_REQUEST["secret"]) && isset($_FILES[$index]) &&