Old ineffective sql_trail superseded by new improved db_trail logging only calls...
[fa-stable.git] / includes / current_user.inc
index e6f051885848068c5abe02ef574776594dbff276..5d4d5f0e3282b3da3e4235949765154cbb5270f9 100644 (file)
@@ -59,7 +59,7 @@ class current_user
 
        function login($company, $loginname, $password)
        {
-               global $security_areas, $security_groups, $security_headings, $path_to_root, $dflt_lang, $SysPrefs;
+               global $security_areas, $security_groups, $security_headings, $path_to_root, $dflt_lang, $SysPrefs, $src_version, $db_version, $installed_extensions;
 
                $this->set_company($company);
            $this->logged = false;
@@ -132,7 +132,7 @@ class current_user
                    $this->prefs = new user_prefs($myrow);
                    $this->user = @$myrow["id"];
                 $this->email = @$myrow["email"];
-                       update_user_visitdate($this->username);
+                       update_user_visitdate($this->username, $src_version, $db_version, $installed_extensions);
                        $this->logged = true;
                                $this->last_act = time();
                                $this->timeout = session_timeout();
@@ -158,8 +158,14 @@ class current_user
                        $hash = md5($password);
 
                        update_user_password($user['id'], $user['user_id'], $hash);
+                       
+                       $sender = get_company_pref('email');
+                       if (empty($sender))
+                               $header = "";
+                       else
+                               $header = "From: $sender";
 
-                       mail($email, _("New password for")." ".$SysPrefs->app_title, $password);
+                       mail($email, _("New password for")." ".$SysPrefs->app_title, $password, $header);
 
                        return true;
                }
@@ -311,11 +317,11 @@ function number_format2($number, $decimals=0)
                $dec = 15 - floor(log10(abs($number)));
        else {
                $delta = ($number < 0 ? -.0000000001 : .0000000001);
-               $number += $delta;
+               @$number += $delta;
                $dec = $decimals;
        }
 
-       $num = number_format($number, $dec, $dsep, $tsep);
+       $num = number_format($number, intval($dec), $dsep, $tsep);
 
        return $decimals==='max' ? rtrim($num, '0') : $num;
 
@@ -353,7 +359,7 @@ function price_decimal_format($number, &$dec)
        if ($pos !== false)
        {
                $len = strlen(substr($str, $pos + 1));
-               if ($len > $dec)
+               if ($len > $dec && $len < ini_get('precision')-3)
                        $dec = $len;
        }
        return number_format2($number, $dec);
@@ -732,6 +738,8 @@ function recalculate_cols(&$cols)
 
 function flush_dir($path, $wipe = false) 
 {
+       if (!file_exists($path))
+               return;
        $dir = @opendir($path);
        if(!$dir)
                return;