summaryrefslogtreecommitdiff
path: root/code/admin/utils.php
diff options
context:
space:
mode:
Diffstat (limited to 'code/admin/utils.php')
-rw-r--r--code/admin/utils.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/code/admin/utils.php b/code/admin/utils.php
index 4db2d2d..30d3788 100644
--- a/code/admin/utils.php
+++ b/code/admin/utils.php
@@ -4,6 +4,11 @@
define('RE_LANG_IDENT_CLEANER', '/[^a-zA-Z\/\_-]+/');
define('RE_RELPATH_CLEANER', '/[^a-zA-Z0-9_\/-]+/'); // Never put \. in this regex
+ define('E_INVALID_ACTION', -1);
+ define('E_INVALID_PATH', -2);
+ define('E_INVALID_NAME', -3);
+ define('E_SYSTEM_ERROR', -4);
+
function sanitize($arg_array, $arg_key, $replace_chars_re, $default_value) {
//FIXME : should check string type and strlen !
if ( ! array_key_exists($arg_key, $arg_array) ) return $default_value;
@@ -140,14 +145,15 @@
echo "</ul>\n";
}
+ // TODO : choose between unix convention (0 is fine, else is error) and PHP one (FALSE is error, else is okay)
function safe_put_file($path, $content) {
//FIXME : if exists, then mktemp, put in it then rm and mv. Right preservation problems ?
- $res=FALSE;
+ $res=-1;
if ($handle = fopen($path, 'w')) {
$res = fwrite($handle, $content);
fclose($handle);
}
- return $res;
+ return ($res===strlen($content))?0:E_SYSTEM_ERROR;
}
function _write_ini_file_r(&$content, $assoc_arr, $has_sections)