X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fmain.inc;h=f5ecd4d6f491659c21229184443e957aba89341c;hb=3b06c6c4718610a408cae2e9b76c3134ca30b84c;hp=1101584eca779028dd8b6f1bec7547fddad91b7b;hpb=53d942f2a0d20cce5e9c409c6485867ce0869e4d;p=fa-stable.git diff --git a/includes/main.inc b/includes/main.inc index 1101584e..f5ecd4d6 100644 --- a/includes/main.inc +++ b/includes/main.inc @@ -11,13 +11,12 @@ ***********************************************************************/ include_once($path_to_root . "/includes/db/connect_db.inc"); +include_once($path_to_root . "/admin/db/transactions_db.inc"); include_once($path_to_root . "/includes/types.inc"); -include_once($path_to_root . "/includes/systypes.inc"); include_once($path_to_root . "/includes/references.inc"); include_once($path_to_root . "/includes/db/comments_db.inc"); include_once($path_to_root . "/includes/db/sql_functions.inc"); include_once($path_to_root . "/includes/db/audit_trail_db.inc"); -//include_once($path_to_root . "/includes/validation.inc"); include_once($path_to_root . "/admin/db/users_db.inc"); include_once($path_to_root . "/includes/ui/ui_view.inc"); @@ -69,13 +68,34 @@ function cache_js_file($fpath, $text) if(!$go_debug) $text = js_compress($text); - $file = fopen($fpath, 'w'); + $file = force_open($fpath); if (!$file) return false; if (!fwrite($file, $text)) return false; return fclose($file); } +/* + Open file for writing with creration of subfolders if needed. +*/ +function force_open($fname) +{ + $file = pathinfo($fname); + + $path = $fname[0] == '/' ? '/' : ''; + $tree = explode('/', $file['dirname']); + foreach($tree as $level) { + $path .= $level; + if (!file_exists($path)) { + if (!mkdir($path)) { + return null; + } + } + $path .= '/'; + } + return fopen($fname, 'w'); +} + function add_js_file($filename) { global $js_static; @@ -353,6 +373,7 @@ function find_custom_file($rep) Changes all not POSIX compatible chars to underscore. */ function clean_file_name($filename) { + $filename = str_replace(chr(0), '', $filename); return preg_replace('/[^a-zA-Z0-9.\-_]/', '_', $filename); }