101 lines
5.8 KiB
Python
101 lines
5.8 KiB
Python
import re
|
|
|
|
with open('register.php', 'r') as f:
|
|
content = f.read()
|
|
|
|
# 1
|
|
content = content.replace(" 'plate_no' => '',", " 'plate_no' => '',\n 'bank_account' => '',\n 'bank_name' => '',\n 'bank_branch' => '',")
|
|
|
|
# 2
|
|
content = content.replace(" 'plate_no' => trim($_POST['plate_no'] ?? ''),", " 'plate_no' => trim($_POST['plate_no'] ?? ''),\n 'bank_account' => trim($_POST['bank_account'] ?? ''),\n 'bank_name' => trim($_POST['bank_name'] ?? ''),\n 'bank_branch' => trim($_POST['bank_branch'] ?? ''),")
|
|
|
|
# 3
|
|
content = content.replace(" $plateNo = trim($_POST['plate_no'] ?? '');", " $plateNo = trim($_POST['plate_no'] ?? '');\n $bankAccount = trim($_POST['bank_account'] ?? '');\n $bankName = trim($_POST['bank_name'] ?? '');\n $bankBranch = trim($_POST['bank_branch'] ?? '');")
|
|
|
|
# 4
|
|
s4 = " if ($truckType === '' || $loadCapacity === '' || $plateNo === '') {\n $errors[] = 'Please complete truck details.';\n } elseif (!is_numeric($loadCapacity) || (float)$loadCapacity <= 0) {"
|
|
r4 = " if ($truckType === '' || $loadCapacity === '' || $plateNo === '') {\n $errors[] = 'Please complete truck details.';\n } elseif ($bankAccount === '' || $bankName === '' || $bankBranch === '') {\n $errors[] = 'Please complete bank account details.';\n } elseif (!is_numeric($loadCapacity) || (float)$loadCapacity <= 0) {"
|
|
content = content.replace(s4, r4)
|
|
|
|
# 5
|
|
s5 = " $ownerStmt = $pdo->prepare(
|
|
\"INSERT INTO truck_owner_profiles (user_id, phone, country_id, city_id, address_line, truck_type, load_capacity, plate_no, id_card_path, truck_pic_path, registration_path)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\"
|
|
);
|
|
$ownerStmt->execute([
|
|
$userId,
|
|
$phone,
|
|
$countryId,
|
|
$cityId,
|
|
$addressLine,
|
|
$truckType,
|
|
$loadCapacity,
|
|
$plateNo,
|
|
json_encode($idCardPaths, JSON_UNESCAPED_SLASHES),
|
|
$truckPic,
|
|
json_encode($regPaths, JSON_UNESCAPED_SLASHES),
|
|
]);"
|
|
r5 = " $ownerStmt = $pdo->prepare(
|
|
\"INSERT INTO truck_owner_profiles (user_id, phone, country_id, city_id, address_line, truck_type, load_capacity, plate_no, bank_account, bank_name, bank_branch, id_card_path, truck_pic_path, registration_path)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\"
|
|
);
|
|
$ownerStmt->execute([
|
|
$userId,
|
|
$phone,
|
|
$countryId,
|
|
$cityId,
|
|
$addressLine,
|
|
$truckType,
|
|
$loadCapacity,
|
|
$plateNo,
|
|
$bankAccount,
|
|
$bankName,
|
|
$bankBranch,
|
|
json_encode($idCardPaths, JSON_UNESCAPED_SLASHES),
|
|
$truckPic,
|
|
json_encode($regPaths, JSON_UNESCAPED_SLASHES),
|
|
]);"
|
|
content = content.replace(s5, r5)
|
|
|
|
# 6
|
|
s6 = " 'plate_no' => '',"
|
|
r6 = " 'plate_no' => '',\n 'bank_account' => '',\n 'bank_name' => '',\n 'bank_branch' => '',"
|
|
# careful not to replace the first one again
|
|
parts = content.split(s6)
|
|
if len(parts) == 3:
|
|
content = parts[0] + s6 + parts[1] + r6 + parts[2]
|
|
elif len(parts) == 2:
|
|
# meaning the first one was already replaced by s1/r1 (which is the same search string!)
|
|
# wait, s1 and s6 are exactly the same?
|
|
# No, s1 is " 'plate_no' => ''," and s6 is " 'plate_no' => ''," (more spaces)
|
|
content = parts[0] + r6 + parts[1]
|
|
|
|
|
|
# 7
|
|
s7 = " <div class=\"col-md-4\">
|
|
<label class=\"form-label\" for=\"plate_no\">Plate number</label>
|
|
<input type=\"text\" name=\"plate_no\" id=\"plate_no\" class=\"form-control\" value=\"<?= e($values['plate_no']) ?>\">
|
|
</div>"
|
|
r7 = " <div class=\"col-md-4\">
|
|
<label class=\"form-label\" for=\"plate_no\">Plate number</label>
|
|
<input type=\"text\" name=\"plate_no\" id=\"plate_no\" class=\"form-control\" value=\"<?= e($values['plate_no']) ?>\">
|
|
</div>
|
|
|
|
<h3 class=\"h6 mt-4 w-100\">Bank Details for Payouts</h3>
|
|
<div class=\"col-md-4 mt-2\">
|
|
<label class=\"form-label\" for=\"bank_account\">Bank Account / IBAN</label>
|
|
<input type=\"text\" name=\"bank_account\" id=\"bank_account\" class=\"form-control\" value=\"<?= e($values['bank_account']) ?>\" required>
|
|
</div>
|
|
<div class=\"col-md-4 mt-2\">
|
|
<label class=\"form-label\" for=\"bank_name\">Bank Name</label>
|
|
<input type=\"text\" name=\"bank_name\" id=\"bank_name\" class=\"form-control\" value=\"<?= e($values['bank_name']) ?>\" required>
|
|
</div>
|
|
<div class=\"col-md-4 mt-2\">
|
|
<label class=\"form-label\" for=\"bank_branch\">Branch</label>
|
|
<input type=\"text\" name=\"bank_branch\" id=\"bank_branch\" class=\"form-control\" value=\"<?= e($values['bank_branch']) ?>\" required>
|
|
</div>"
|
|
content = content.replace(s7, r7)
|
|
|
|
with open('register.php', 'w') as f:
|
|
f.write(content)
|
|
|
|
print("Replaced in register.php")
|