summaryrefslogtreecommitdiff
path: root/code/admin/utils.php
diff options
context:
space:
mode:
authorLudovic Pouzenc <lpouzenc@gmail.com>2013-11-06 20:34:17 +0100
committerLudovic Pouzenc <lpouzenc@gmail.com>2013-11-06 20:34:17 +0100
commit7c2e5898630b076faf3c64ccc364fa37be2de9e9 (patch)
tree8e74bcadf860773c82417ee76db4f8231d347252 /code/admin/utils.php
parentef40bdc69152658ea6660787f4c1e4283f7fed5f (diff)
downloadeditablesite-master.tar.gz
editablesite-master.tar.bz2
editablesite-master.zip
Gestion des erreurs dans add.php coté php. Pas de feedback user encore.HEADmaster
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)