X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fmain.inc;h=6ac3fc14837a177c57974203b947a01f91f949d0;hb=6ae59a0b8741ce89f30b64c2d0f376835eb0a778;hp=1101584eca779028dd8b6f1bec7547fddad91b7b;hpb=1571869d54be48452fdbe08f25130972ff0a7b5a;p=fa-stable.git diff --git a/includes/main.inc b/includes/main.inc index 1101584e..6ac3fc14 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,7 +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); } -?> \ No newline at end of file