From: Janusz Dobrowolski Date: Tue, 19 Dec 2017 12:01:44 +0000 (+0100) Subject: Added VARLIB_PATH and VARLOG_PATH defines to simplify packaging. X-Git-Tag: v2.4.4~36 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=4a37a28c49bf900dcc370fd3f21186cedcd632c9;p=fa-stable.git Added VARLIB_PATH and VARLOG_PATH defines to simplify packaging. --- diff --git a/admin/includes/fa_patch.class.inc b/admin/includes/fa_patch.class.inc index d1666405..0af328f5 100644 --- a/admin/includes/fa_patch.class.inc +++ b/admin/includes/fa_patch.class.inc @@ -115,7 +115,7 @@ class fa_patch { $this->errors = array(); $this->backup = null; - $this->save_log = ini_set('error_log', dirname(__FILE__).'/../../tmp/upgrade.'.$this->cur_company.'.log'); + $this->save_log = ini_set('error_log', VARLOG_PATH.'/upgrade.'.$this->cur_company.'.log'); $this->log_error(sprintf(_("Upgrade started for company %s."), $this->cur_company), 'Info'); if (!set_global_connection($this->cur_company)) diff --git a/admin/inst_upgrade.php b/admin/inst_upgrade.php index 2fb9ac07..5e5e1a98 100644 --- a/admin/inst_upgrade.php +++ b/admin/inst_upgrade.php @@ -50,7 +50,7 @@ if (get_post('Upgrade')) $i = find_submit('Clear'); if ($i != -1) { - unlink($path_to_root.'/tmp/upgrade.'.$i.'.log'); + unlink(VARLOG_PATH.'/upgrade.'.$i.'.log'); $Ajax->activate('_page_body'); } if (get_post('_select_comp_update')) @@ -77,7 +77,7 @@ foreach($site_status as $i => $comp) label_cell($comp['version'], 'align=center' .($status ? '':' class=redfg')/*, 'class='.( $status ? 'ok' : 'error')*/); - $log = $path_to_root.'/tmp/upgrade.'.$i.'.log'; + $log = VARLOG_PATH.'/upgrade.'.$i.'.log'; if (file_exists($log)) { label_cell(viewer_link(_('View log'), "admin/view/view_upgrade_log.php?id=$i", null, $i, 'log.png') diff --git a/admin/view/view_upgrade_log.php b/admin/view/view_upgrade_log.php index e1cbd0f4..eff1b15a 100644 --- a/admin/view/view_upgrade_log.php +++ b/admin/view/view_upgrade_log.php @@ -30,7 +30,7 @@ br(); start_table(); start_row(); - $log = strtr(file_get_contents($path_to_root.'/tmp/upgrade.'.$_GET['id'].'.log'), + $log = strtr(file_get_contents(VARLOG_PATH.'/upgrade.'.$_GET['id'].'.log'), array('Fatal error' => 'Fatal error')); // prevent misinterpretation in output_handler label_cells(null, nl2br(html_specials_encode($log))); end_row(); diff --git a/config.default.php b/config.default.php index c50cb9d9..ab77a57b 100644 --- a/config.default.php +++ b/config.default.php @@ -29,7 +29,7 @@ if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_ // writable by www server. When set to empty string logging is switched off. // Special value 'syslog' can be used for system logger usage (see php manual). //$error_logfile = ''; - $error_logfile = $path_to_root.'/tmp/errors.log'; + $error_logfile = VARLOG_PATH.'/errors.log'; $debug = 1; // show sql on database errors $show_sql = 0; // show all sql queries in page footer for debugging purposes diff --git a/gl/includes/db/gl_db_rates.inc b/gl/includes/db/gl_db_rates.inc index 46e0aa02..98791b7c 100644 --- a/gl/includes/db/gl_db_rates.inc +++ b/gl/includes/db/gl_db_rates.inc @@ -167,7 +167,7 @@ function get_extern_rate($curr_b, $provider = 'ECB', $date) do { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $proto.$site.$filename); - curl_setopt ($ch, CURLOPT_COOKIEJAR, "$path_to_root/tmp/cookie.txt"); + curl_setopt ($ch, CURLOPT_COOKIEJAR, VARLIB_PATH."/cookie.txt"); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // prevent warning while safe_mode/open_basedir on (redirection doesn't occur at least on ECB page) diff --git a/includes/packages.inc b/includes/packages.inc index 6389d5e5..54d16abf 100644 --- a/includes/packages.inc +++ b/includes/packages.inc @@ -282,7 +282,7 @@ function get_pkg_or_list($type = null, $pkgname = null, $filter=array(), $outkey // and check remote signature with local copy of public key // $loclist = PKG_CACHE_PATH.'/Release.gz'; - $target_dir = $download==true ? "$path_to_root/tmp/" : $download; + $target_dir = $download==true ? VARLIB_PATH."/" : $download; if (isset($type) && !is_array($type)) { $type = array($type); @@ -622,7 +622,7 @@ function install_language($pkg_name) uninstall_package($old_pkg); } - $package = new package("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + $package = new package(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); if ($package->install()) { $lang = array( 'name' => $pkg['Name'], @@ -636,7 +636,7 @@ function install_language($pkg_name) $lang['rtl'] = true; $installed_languages[$i] = $lang; write_lang($installed_languages); - unlink("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + unlink(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); $Ajax->activate('lang_tbl'); } else { display_error(implode('
', $package->error)); @@ -657,7 +657,7 @@ function install_extension($pkg_name) $pkg = get_pkg_or_list(array('extension', 'theme', 'chart'), $pkg_name); if ($pkg) { - $package = new package("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + $package = new package(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); $local_exts = get_company_extensions(); if ($package->install()) { $ext_id = array_search_key($pkg['Package'], $local_exts, 'package'); @@ -690,7 +690,7 @@ function install_extension($pkg_name) activate_hooks($ext['package'], $comp); } - unlink("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + unlink(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); $Ajax->activate('ext_tbl'); return $ret; } else { diff --git a/includes/session.inc b/includes/session.inc index 5008d028..3f8c525d 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -9,6 +9,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ +define('VARLIB_PATH', $path_to_root.'/tmp'); +define('VARLOG_PATH', $path_to_root.'/tmp'); class SessionManager { @@ -227,9 +229,9 @@ function write_login_filelog($login, $result) $msg .= "*/\n"; $msg .= "\$login_faillog = " .var_export($login_faillog, true). ";\n"; - $filename = $path_to_root."/tmp/faillog.php"; + $filename = VARLIB_PATH."/faillog.php"; - if ((!file_exists($filename) && is_writable($path_to_root.'/tmp')) || is_writable($filename)) + if ((!file_exists($filename) && is_writable(VARLIB_PATH)) || is_writable($filename)) { file_put_contents($filename, $msg); cache_invalidate($filename); @@ -425,7 +427,7 @@ if ($SysPrefs->error_logfile != '') { to avoid unexpeced session timeouts. Make sure this directory exists and is writable! */ -// ini_set('session.save_path', dirname(__FILE__).'/../tmp/'); +// ini_set('session.save_path', VARLIB_PATH.'/'); ini_set('session.gc_maxlifetime', 36000); // 10hrs @@ -436,8 +438,8 @@ header("Cache-control: private"); get_text_init(); -if ($SysPrefs->login_delay > 0 && file_exists($path_to_root . "/tmp/faillog.php")) - include_once($path_to_root . "/tmp/faillog.php"); +if ($SysPrefs->login_delay > 0 && file_exists(VARLIB_PATH."/faillog.php")) + include_once(VARLIB_PATH."/faillog.php"); // Page Initialisation if (!isset($_SESSION['wa_current_user']) || !$_SESSION['wa_current_user']->logged_in() diff --git a/includes/system_tests.inc b/includes/system_tests.inc index 50add593..17d89b63 100644 --- a/includes/system_tests.inc +++ b/includes/system_tests.inc @@ -224,7 +224,7 @@ function tst_tmpdir() $test['descr'] = _('Temporary directory'); $test['type'] = 3; - $test['test'] = $path_to_root.'/tmp'; + $test['test'] = VARLIB_PATH; $test['result'] = is_dir($test['test']) && is_writable($test['test']); $test['comments'][] = sprintf(_("'%s' is not writeable"), $test['test']); return $test; diff --git a/install/isession.inc b/install/isession.inc index 274f1f57..05e7dc26 100644 --- a/install/isession.inc +++ b/install/isession.inc @@ -9,6 +9,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ +define('VARLIB_PATH', $path_to_root.'/tmp'); +define('VARLOG_PATH', $path_to_root.'/tmp'); + function output_html($text) { global $before_box, $Ajax, $messages;