22 lines
1.4 KiB
PHP
22 lines
1.4 KiB
PHP
<?php
|
|
$file = 'checkout.php';
|
|
$content = file_get_contents($file);
|
|
|
|
$search1 = "'email' => trim((string) (\$_POST['email'] ?? '')),";
|
|
$replace1 = $search1 . "\n 'password' => (string) (\$_POST['password'] ?? ''),";
|
|
$content = str_replace($search1, $replace1, $content);
|
|
|
|
$search2 = "if (!filter_var(\$form['email'], FILTER_VALIDATE_EMAIL)) {";
|
|
$replace2 = "if (empty(\$form['password']) || strlen(\$form['password']) < 6) {\n \$errors[] = t('Password must be at least 6 characters.', 'يجب أن تتكون كلمة المرور من 6 أحرف على الأقل.');\n }\n " . $search2;
|
|
$content = str_replace($search2, $replace2, $content);
|
|
|
|
$search3 = "'email' => \$form['email'],";
|
|
$replace3 = "'email' => \$form['email'],\n 'password' => password_hash(\$form['password'], PASSWORD_DEFAULT),";
|
|
$content = str_replace($search3, $replace3, $content);
|
|
|
|
$search4 = '/<div class="col-md-6">\s*<label class="form-label" for="email">.*?<\/div>/s';
|
|
$replace4 = '$0'."\n".' <div class="col-md-6">'."\n".' <label class="form-label" for="password"><?= h(t(\'Password\', \'كلمة المرور\')) ?></label>'."\n".' <input class="form-control" id="password" type="password" name="password" required>'."\n".' </div>';
|
|
$content = preg_replace($search4, $replace4, $content);
|
|
|
|
file_put_contents($file, $content);
|
|
echo "checkout.php patched\n"; |