Fixed source compatibility to PHP 5.0, fixed bug in epassword reset feature.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 20 Apr 2015 14:15:10 +0000 (16:15 +0200)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 20 Apr 2015 14:15:10 +0000 (16:15 +0200)
includes/current_user.inc
includes/main.inc
includes/system_tests.inc
sales/includes/ui/sales_credit_ui.inc
sales/includes/ui/sales_order_ui.inc

index fa676ec2cc570b93b379b01b8f0a48ea99004a65..62d729b628963c11f352412f549b42faa7f886bd 100644 (file)
@@ -154,14 +154,12 @@ class current_user
 
                if ($user != false) {
 
-                       $bytes = openssl_random_pseudo_bytes(8, $cstrong);
-                       $password   = base64_encode($bytes);
-
+                       $password = generate_password();
                        $hash = md5($password);
 
                        update_user_password($user['id'], $user['user_id'], $hash);
 
-                       mail($myrow['email'], _("New password for")." ".$SysPrefs->app_title, $password);
+                       mail($email, _("New password for")." ".$SysPrefs->app_title, $password);
 
                        return true;
                }
index 11746a288b386bc254d0ea2b6ab4fdd6b436480e..38ceaa1df9730e4c5ba5b5200b2893e10cf36035 100644 (file)
@@ -383,3 +383,23 @@ function clean_file_name($filename) {
     return preg_replace('/[^a-zA-Z0-9.\-_]/', '_', $filename);
 }
 
+/*
+       Simple random password generator.
+*/
+function generate_password()
+{
+       if (PHP_VERSION >= '5.3')
+               $bytes = openssl_random_pseudo_bytes(8, $cstrong);
+       else
+               $bytes = sprintf("08%x", mt_rand(0,0xffffffff));
+
+       return  base64_encode($bytes);
+}
+
+if (!function_exists('array_fill_keys')) // since 5.2
+{
+       function array_fill_keys($keys, $value)
+       {
+               return array_combine($keys, array_fill(count($keys), $value));
+       }
+}
index f4955627cf9e2e805857063aa19d7e90f8f4c7e5..1e8881a164842600a784819921764d8c41703134 100644 (file)
@@ -43,11 +43,11 @@ function tst_phpmysql()
 
 function tst_php() 
 {
-       $test['descr'] = _('PHP version').' >=4.3.3';
+       $test['descr'] = _('PHP version').' >=5.0.0';
        $test['type'] = 3;
        $test['test'] = phpversion();
-       $test['result'] = $test['test']>='4.3.3';
-       $test['comments'] = _('Upgrade PHP to version at least 4.3.3');
+       $test['result'] = $test['test']>='5.0.0';
+       $test['comments'] = _('Upgrade PHP to version at least 5.0.0');
 
        return $test;
 }
index 627358ecc4059c9c44c913d6eeb0dd62d01b717a..f0cff322eb4dea805e621042602be2d988c8211e 100644 (file)
@@ -45,7 +45,7 @@ function display_credit_header(&$order)
                ($order->Branch != $_POST['branch_id']))
          {
 
-                               $old_order = (PHP_VERSION<5) ? $order : clone( $order );
+                               $old_order = (PHP_VERSION<5) ? $order : clone $order;
                                $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
 
                                $_POST['Location'] = $order->Location;
index 043d2514b5d2d4184576f84cb53d0dc44316b578..c1209dc758269c4abf39140bc47d77b7ead351bd 100644 (file)
@@ -295,7 +295,7 @@ function display_order_header(&$order, $editable, $date_text)
                        else
                        {
 
-                               $old_order = (PHP_VERSION<5) ? $order : clone( $order );
+                               $old_order = (PHP_VERSION<5) ? $order : clone $order;
 
                                $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']);
                                $_POST['Location'] = $order->Location;