Added VARLIB_PATH and VARLOG_PATH defines to simplify packaging.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 19 Dec 2017 12:01:44 +0000 (13:01 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 19 Dec 2017 12:17:40 +0000 (13:17 +0100)
admin/includes/fa_patch.class.inc
admin/inst_upgrade.php
admin/view/view_upgrade_log.php
config.default.php
gl/includes/db/gl_db_rates.inc
includes/packages.inc
includes/session.inc
includes/system_tests.inc
install/isession.inc

index d16664053fcd835987e4363e9f8b5b519b97906f..0af328f54d914c04c99cb232c7c85cbf859d91a5 100644 (file)
@@ -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))
index 2fb9ac07e692294de6fe5d3109812dfa0d3ca21a..5e5e1a9809ff1a514011a2fe8d659fb659597234 100644 (file)
@@ -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')
index e1cbd0f4abad73ccaaf4a5f103d7d93420d41b46..eff1b15adcdf582b2afaaa87ed4b42ea11b7e856 100644 (file)
@@ -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();
index c50cb9d94f52dee58edfdb748f9e9f7a6a4f6018..ab77a57bf5198464ad1011cfe20e1c0239e3df89 100644 (file)
@@ -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
index 46e0aa0289f7d0d5aa9958462936354872da2e77..98791b7c10fa497b8d2ecf4a38dfadad9aac8849 100644 (file)
@@ -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)
index 6389d5e594ad19a1dba8c1ba2bfe9cc9893ad7a3..54d16abf5b4bf31cd15ff29f8b048a6acd0b9c94 100644 (file)
@@ -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('<br>', $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 {
index 5008d028027623253e0a94397116ae2f1020a786..3f8c525d32b80a2957642db34dbc036179a2badb 100644 (file)
@@ -9,6 +9,8 @@
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
+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()
index 50add5931709447a193f80d12584c8e0f2075e0d..17d89b63b433a26b44a9bcc8fa89b831c070f588 100644 (file)
@@ -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;
index 274f1f57a3f2f217404362c463271370863b4726..05e7dc26c67a4f21e1fee08817cb41482e9fa703 100644 (file)
@@ -9,6 +9,9 @@
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
+define('VARLIB_PATH', $path_to_root.'/tmp');
+define('VARLOG_PATH', $path_to_root.'/tmp');
+
 function output_html($text)
 {
        global $before_box, $Ajax, $messages;