From 35e707bfeb8d82d713acb49d78b08062374269f6 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Wed, 25 Oct 2017 15:02:52 -0400 Subject: Restyle address format and change background image --- dash/dash_functions.php | 25 ++++++++++++++++++++++++- dash/img/0.jpg | Bin 2475730 -> 3140015 bytes dash/profile.php | 36 +++++++++++++++++++++++++++++------- 3 files changed, 53 insertions(+), 8 deletions(-) (limited to 'dash') diff --git a/dash/dash_functions.php b/dash/dash_functions.php index 9aaa78f..ab32e3b 100644 --- a/dash/dash_functions.php +++ b/dash/dash_functions.php @@ -26,6 +26,29 @@ function genpicstr () { function picture_format ($picstr = null) { return is_null($picstr) ? 'uimg/default.png' : htmlentities($picstr); } +function address_format ($addrstr) { + if (is_null($addrstr)) return 'No address supplied.'; + $addr = array_filter(address_split($addrstr)); + return htmlentities(implode(', ', $addr)); +} +function address_split ($addrstr) { + return array_map(trim, explode(';', $addrstr)); +} +function address_join ($addr) { + return implode(';', array_map(trim, $addr)); +} +function validate_address ($addr) { + $patterns = array( + '/^\d+\s(\w+\s)+\w+$/', + '/^.*$/', + '/^.+$/', + '/^[A-Z]{2}$/', + ); + foreach ($addr as $k => $addrpt) { + if (!preg_match($patterns[$k], $addrpt)) die($addrpt); + } + return true; +} function draw_norate_p () { ?>
@@ -113,7 +136,7 @@ function draw_app ($row) {

-

No address listed.' : htmlentities($row['address']);?>

+

No comment included.' : htmlentities($row['comment']);?>

diff --git a/dash/img/0.jpg b/dash/img/0.jpg index 6431af3..a3685d3 100644 Binary files a/dash/img/0.jpg and b/dash/img/0.jpg differ diff --git a/dash/profile.php b/dash/profile.php index fa3ee8e..a59109c 100644 --- a/dash/profile.php +++ b/dash/profile.php @@ -39,7 +39,7 @@ $phonelink = '+'.preg_replace('/[^0-9]/', '', $user['phone']);

Phone:


Address

-

No address specified.' : htmlentities($user['address']));?>

+

Zipcode:


Chat

@@ -74,10 +74,24 @@ $result->free(); escape_string($_POST['bio']).'\''; - if (!empty($_POST['address'])) { - if (!geolocate($_POST['address'], $b_user['zipcode'])) dash_fatal('The address provided is not valid.'); + // Address validation + $addr = array_map(trim, array( + $_POST['address1'], + $_POST['address2'], + $_POST['addrcity'], + $_POST['addrstate'], + )); + $addrfull = array_reduce($addr, function ($carry, $item) { + return $carry || !empty($item); + }, false); + if ($addrfull) { + if (validate_address($addr)) + $addr_q = '\''.$db->escape_string(address_join($addr)).'\''; + else + dash_fatal('The address you supplied appears to be incomplete or invalid.'); + } else { + $addr_q = 'NULL'; } - $addr = empty($_POST['address']) ? 'NULL' : '\''.$db->escape_string($_POST['address']).'\''; $patterns = array( 'email' => '/^.+@.+\..+$/', 'zip' => '/^\d{5}([-\s]\d{4})?$/', @@ -106,7 +120,7 @@ $result->free(); @unlink($b_user['picture']); @imagedestroy($img); } - $db->query('UPDATE users SET email = \''.$db->escape_string($_POST['email']).'\', zipcode = \''.$db->escape_string($_POST['zip']).'\', phone = \''.$db->escape_string($_POST['phone']).'\', address = '.$addr.', bio = '.$bio.$usepropic.$deactivate.' WHERE id = '.$b_user['id']) or dash_fatal($db->error); + $db->query('UPDATE users SET email = \''.$db->escape_string($_POST['email']).'\', zipcode = \''.$db->escape_string($_POST['zip']).'\', phone = \''.$db->escape_string($_POST['phone']).'\', address = '.$addr_q.', bio = '.$bio.$usepropic.$deactivate.' WHERE id = '.$b_user['id']) or dash_fatal($db->error); dash_fatal('Your profile has been updated. If you have changed your email, you will need to verify it before returning to Bulletin.', $b_config['base_url'].'dash/profile.php'); } else { ?> @@ -142,8 +156,16 @@ $result->free();

Basic Information

-

-

+ +

+

+

+

+ + +

-- cgit v1.2.3