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;
}
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));
+ }
+}
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;
}
($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;
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;