X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fmain.inc;h=ee604df88e275e7e3c34b34903353066e787eab0;hb=7286bbfc939360b0fcb573ae075b2b8e899d96c8;hp=f01bcddcd30dc4f97a502a3942d2663a40c65b2f;hpb=d497aeb2d93ed1c705007fa6ff84a4c470f7f538;p=fa-stable.git diff --git a/includes/main.inc b/includes/main.inc index f01bcddc..ee604df8 100644 --- a/includes/main.inc +++ b/includes/main.inc @@ -15,7 +15,6 @@ include_once($path_to_root . "/includes/errors.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/prefs/sysprefs.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"); @@ -48,20 +47,23 @@ function page($title, $no_menu=false, $is_index=false, $onload="", $js="", $scri } } -function end_page($no_menu=false, $is_index=false) +function end_page($no_menu=false, $is_index=false, $hide_back_link=false) { - global $path_to_root, $Ajax; - $hide_menu = $no_menu; - div_end(); // _page_body section - include($path_to_root . "/includes/page/footer.inc"); - page_footer($no_menu, $is_index); + global $path_to_root; + + if (!$is_index && !$hide_back_link && function_exists('hyperlink_back')) + hyperlink_back(true, $no_menu); + div_end(); // end of _page_body section + + include($path_to_root . "/includes/page/footer.inc"); + page_footer($no_menu, $is_index, $hide_back_link); } function flush_dir($path, $wipe = false) { $dir = opendir($path); while(false !== ($fname = readdir($dir))) { - if($fname=='.' || $fname=='..' || (!$wipe && $fname=='index.php')) continue; + if($fname=='.' || $fname=='..' || $fname=='CVS' || (!$wipe && $fname=='index.php')) continue; if(is_dir($path.'/'.$fname)) { flush_dir($path.'/'.$fname, $wipe); if ($wipe) @rmdir($path.'/'.$fname); @@ -259,36 +261,55 @@ function js_compress($sJS) } return $sJS; } -//----------------------------------------------------------------------------- -// Inserts $elements into $array at position $index. -// $elements is list of any objects -// -function array_insert(&$array, $index, $elements) -{ - if (!is_array($elements)) $elements = array($elements); - - $head = array_splice($array, 0, $index); - $array = array_merge($head, $elements, $array); -} -function array_remove(&$array, $index, $len=1) +/* + Check if file can be updated, restoring subdirectories + if needed. Returns 1 when no confilcts, -1 when file exists and is writable +*/ +function check_write($path) { - array_splice($array, $index, $len); + if ($path == ''//|| $path == '.' || $path == '..' + ) return 0; + + return is_writable($path) ? (is_dir($path) ? 1 : -1) + : ($path =='.' ? 0 : check_write(dirname($path))); } -function array_replace(&$array, $index, $len, $elements) +/* + Copies set of files. When $strict is set + also removes files from the $to which + does not exists in $from directory but arelisted in $flist. +*/ +function copy_files($flist, $from, $to, $strict=false) { - array_splice($array, $index, $len); - array_insert($array, $index, $elements); + foreach ($flist as $file) { + if (file_exists($from.'/'.$file)) + if (!copy_file($file, $from, $to)) + return false; + if ($strict && !is_file($from.'/'.$file)) // if + unlink($to.'/'.$file); + } + return true; } -function array_append(&$array, $elements) +/* + Copies file from base to target directory, restoring subdirectories + if needed. +*/ +function copy_file($file, $from, $to) { - foreach($elements as $key => $el) { - if(is_int($key)) - $array[] = $el; - else - $array[$key] = $el; + + if (!is_dir(dirname($file=='.' ? $to : ($to.'/'.$file)))) { + if (!copy_file(dirname($file), null, $to)) + return false; + } + if (!$from) { + // error_log( 'dodanie katalogu '.$to.'/'.$file); + return @mkdir($file=='.' ? $to : ($to.'/'.$file)); + } + else { + // error_log( 'skopiowanie '.$to.'/'.$file); + return @copy($from.'/'.$file, $to.'/'.$file); } }