diff options
| -rw-r--r-- | dash/ads.php | 9 | ||||
| -rw-r--r-- | dash/apply.php | 9 | ||||
| -rw-r--r-- | dash/css/dash.css | 2 | ||||
| -rw-r--r-- | dash/css/profile.css | 93 | ||||
| -rw-r--r-- | dash/dash_functions.php | 16 | ||||
| -rw-r--r-- | dash/header.php | 5 | ||||
| -rw-r--r-- | dash/js/profile.js | 14 | ||||
| -rw-r--r-- | dash/profile.php | 123 | ||||
| -rw-r--r-- | dash/uimg/1.png | bin | 0 -> 21047 bytes | |||
| -rwxr-xr-x[-rw-r--r--] | dash/uimg/default.png | bin | 2735 -> 2735 bytes | |||
| -rw-r--r-- | inc/user.php | 2 | ||||
| -rw-r--r-- | index.php | 2 |
12 files changed, 256 insertions, 19 deletions
diff --git a/dash/ads.php b/dash/ads.php index fa7f715..97bfa3e 100644 --- a/dash/ads.php +++ b/dash/ads.php @@ -9,6 +9,7 @@ require('header.php'); $result = $db->query('SELECT ads.id, ads.title, ads.pay, ads.time, ads.location, ads.description, users.name, users.email, users.phone, users.picture, users.bio, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads INNER JOIN users ON users.id = ads.uid LEFT JOIN ratings ON ratings.rated = ads.uid WHERE ads.id = '.$adid.' LIMIT 1') or dash_fatal($db->error); if ($result->num_rows < 1) dash_fatal('No ad with this ID has been found.'); $row = $result->fetch_assoc(); +$result->free(); ?> <div id="fulljob"> <div id="fjheader"> @@ -28,12 +29,7 @@ else echo ' <img id="propic" src="uimg/'.intval($row['picture']).'.png" alt="Profile Picture" />'.PHP_EOL; ?> <p id="ename"><?=htmlentities($row['name']);?></p> -<?php -if (is_null($row['rating'])) - echo ' <p id="erating">Employer Not Rated</p>'.PHP_EOL; -else - echo ' <p id="erating">'.intval($row['rating']).' Star Employer</p>'.PHP_EOL; -?> + <p id="erating"><?=rating_format($row['rating']);?></p> </div> <div id="fjfright"> <p id="ebio"><?=(is_null($row['bio']) ? '<em>No bio included in profile.</em>' : htmlentities($row['bio']));?></p> @@ -50,6 +46,5 @@ $phonelink = '+'.preg_replace('/[^0-9]/', '', $row['phone']); </div> </div> <?php -$result->free(); require('footer.php'); ?> diff --git a/dash/apply.php b/dash/apply.php index be353ad..ab2652c 100644 --- a/dash/apply.php +++ b/dash/apply.php @@ -19,6 +19,7 @@ if (!empty($_POST['apply'])) { $result = $db->query('SELECT ads.id, ads.title, ads.pay, ads.time, ads.location, ads.description, users.name, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads INNER JOIN users ON users.id = ads.uid LEFT JOIN ratings ON ratings.rated = ads.uid WHERE ads.id = '.$adid.' LIMIT 1') or dash_fatal($db->error); if ($result->num_rows < 1) dash_fatal('No ad with this ID has been found.'); $row = $result->fetch_assoc(); +$result->free(); ?> <div id="fulljob" class="fjsettings"> <div id="fjheader"> @@ -38,12 +39,7 @@ else echo ' <img id="propic" src="uimg/'.intval($row['picture']).'.png" alt="Profile Picture" />'.PHP_EOL; ?> <p id="ename"><?=htmlentities($row['name']);?></p> -<?php -if (is_null($row['rating'])) - echo ' <p id="erating">Employer Not Rated</p>'.PHP_EOL; -else - echo ' <p id="erating">'.intval($row['rating']).' Star Employer</p>'.PHP_EOL; -?> + <p id="erating"><?=rating_format($row['rating']);?></p> </div> <div id="fjfright"> <form id="cform" action="<?=htmlentities($_SERVER['REQUEST_URI']);?>" method="post"> @@ -55,6 +51,5 @@ else </div> </div> <?php -$result->free(); require('footer.php'); ?> diff --git a/dash/css/dash.css b/dash/css/dash.css index 86982df..f5df815 100644 --- a/dash/css/dash.css +++ b/dash/css/dash.css @@ -277,7 +277,7 @@ body { } .fjsettings textarea { margin: 0.5em auto; - width: 500px; + width: 450px; height: 150px; resize: none; border: 1px solid #dddddd; diff --git a/dash/css/profile.css b/dash/css/profile.css new file mode 100644 index 0000000..79a908f --- /dev/null +++ b/dash/css/profile.css @@ -0,0 +1,93 @@ +.hidden { + display: none; +} +#profile { + width: 800px; + margin: 2em auto; + background-color: #ffffff; + padding: 1em; + border-radius: 5px; + box-shadow: 0px 0px 5px rgba(0,0,0,0.75); +} +#profile input { + margin-top: 0.35em; + margin-bottom: 0.35em; + font-family: 'Myriad Pro'; + font-size: 12pt; +} +#profile p, #profile h3, #profile h4 { + margin: 0; +} +input[type=text], input[type=password] { + width: 248px; + padding: 6px 12px; + border: 1px solid #dddddd; + border-radius: 5px; +} +input[type=submit], input[type=button], button { + background-color: #fb4d00; + padding: 5px 10px 3px; + border-style: none; + border-radius: 10px; + color: #ffffff; + cursor: pointer; +} +input[type=submit]:hover, input[type=button]:hover, button:hover { + background-color: #fb7700; +} +textarea { + margin: 0.25em auto; + width: 450px; + height: 150px; + resize: none; + border: 1px solid #dddddd; + border-radius: 5px; + padding: 5px; +} +#proheader { + text-align: center; + padding-bottom: 1em; + margin-bottom: 1em; + border-bottom: 1px solid #eeeeee; +} +#proleft { + float: left; + text-align: center; +} +#propic { + margin: 0.5em auto; + cursor: pointer; +} +#propic img { + width: 192px; + height: 192px; +} +#hoverupload { + position: relative; + top: -53px; + text-align: center; + width: 192px; + height: 20px; + background-color: rgba(251,77,0,0.4); + font-size: 20px; + padding: 14px 0; + display: none; +} +#propic:hover #hoverupload { + display: block; +} +#proright { + margin-left: calc(192px + 3em); + margin-bottom: 1em; +} +.public #probody { + margin: 1em 0; +} +a { + text-decoration: none; + color: #fb4d00; + cursor: pointer; +} +a:hover { + color: #fb7700; +} diff --git a/dash/dash_functions.php b/dash/dash_functions.php index 2cc7f8d..c5644ca 100644 --- a/dash/dash_functions.php +++ b/dash/dash_functions.php @@ -6,6 +6,20 @@ function dash_fatal ($msg = null, $link = null, $label = null) { require('footer.php'); die; } +function typestr ($type) { + switch ($type) { + case 'EMPLOYER': + return 'Employer'; + case 'EMPLOYEE': + return 'Employee'; + default: + return 'Team Member'; + } +} +function rating_format ($rating = null, $typestr = 'Employer') { + if (is_null($rating)) return $typestr.' Not Rated'; + return number_format($rating, 1).' Star '.$typestr; +} function draw_noads () { ?> <div class="job"> @@ -32,7 +46,7 @@ function draw_ad ($row) { if (is_null($row['rating'])) echo ' <p class="jobstars">Employer Not Rated</p>'.PHP_EOL; else - echo ' <p class="jobstars">'.intval($row['rating']).' Star Employer</p>'.PHP_EOL; + echo ' <p class="jobstars">'.$row['rating'].' Star Employer</p>'.PHP_EOL; ?> <p class="jobpay">Pays $<?=number_format($row['pay'], 2);?></p> <p class="jobblurb"><?=htmlentities(substr($row['description'], 0, min(strlen($row['description']), 160)));?> <a href="ads.php?id=<?=$row['id'];?>">[...]</a></p> diff --git a/dash/header.php b/dash/header.php index d854074..08a9bfc 100644 --- a/dash/header.php +++ b/dash/header.php @@ -15,7 +15,10 @@ $db = new bdb(); <script type="text/javascript" src="js/dash.js"></script> <script type="text/javascript" src="../js/auth.php"></script> <script type="text/javascript" src="../js/chat.js"></script> - </head> + <?php +if (!empty($extra_head)) echo $extra_head; +?> + </head> <body> <div id="nav"> <a id="navhome" href="<?=$b_config['base_url'];?>"> diff --git a/dash/js/profile.js b/dash/js/profile.js new file mode 100644 index 0000000..9c83aa5 --- /dev/null +++ b/dash/js/profile.js @@ -0,0 +1,14 @@ +$(function () { + $('#chpic').change(function() { + if (this.files && this.files[0]) { + var reader = new FileReader(); + reader.onload = function (e) { + $('#propic img').attr('src', e.target.result); + } + reader.readAsDataURL(this.files[0]); + } + }); + $('.private #propic').click(function () { + $('#chpic').click(); + }); +}); diff --git a/dash/profile.php b/dash/profile.php new file mode 100644 index 0000000..13fc8d7 --- /dev/null +++ b/dash/profile.php @@ -0,0 +1,123 @@ +<?php +define('HEIRARCHY', 1); + +require('dash_common.php'); +$public = intval($_GET['id']) > 0; +$title = 'Profile / Bulletin'; +$extra_head = ' <link rel="stylesheet" type="text/css" href="css/profile.css" />'.PHP_EOL; +if (!$public) $extra_head .= ' <script type="text/javascript" src="js/profile.js"></script>'.PHP_EOL; +require('header.php'); +$user = $b_user; +if ($public) { + $result = $db->query('SELECT users.*, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM users LEFT JOIN ratings ON ratings.rated = users.id LEFT JOIN responses ON responses.uid = users.id WHERE users.id = '.intval($_GET['id']).' AND users.active = 1 AND responses.matched = 1 LIMIT 1') or dash_fatal($db->error); + $user = $result->fetch_assoc(); + $result->free(); + if ($user['id'] < 1) dash_fatal('A user with that ID does not exist. You must have reached this page in error.'); +?> + <div id="profile" class="public"> + <div id="proheader"> + <h3 id="protitle"><?=htmlentities($user['name']);?></h3> + <p id="prostars"><?=rating_format($user['rating'], typestr($user['type']));?></p> + </div> + <div id="proleft"> + <div id="propic"> +<?php + if (is_null($user['picture'])) + echo ' <img src="uimg/default.png" alt="Profile Picture" />'.PHP_EOL; + else + echo ' <img src="uimg/'.$user['picture'].'.png" alt="Profile Picture" />'.PHP_EOL; +?> + </div> + </div> + <div id="proright"> + <div id="probody"> + <h4>Bio</h4> + <p><?=(is_null($user['bio']) ? '<em>No bio included in profile.</em>' : htmlentities($user['bio'])); ?></p> + </div> + <br /> + <div id="profoot"> + <h4>Personal Information</h4> + <p>Email: <a href="mailto:<?=htmlentities($user['email']);?>"><?=htmlentities($user['email']);?></a></p> +<?php +$phonelink = '+'.preg_replace('/[^0-9]/', '', $user['phone']); +?> + <p>Phone: <a href="tel:<?=$phonelink;?>"><?=htmlentities($user['phone']);?></a></p> + <br /> + <h4>Address</h4> + <p><?=(is_null($user['address']) ? '<em>No address specified.</em>' : htmlentities($user['address']));?></p> + <p>Zipcode: <?=htmlentities($user['zipcode']);?></p> + </div> + </div> + </div> +<?php +} else if (!empty($_POST['chprofile'])) { + $bio = empty($_POST['bio']) ? 'NULL' : '\''.$db->escape_string($_POST['bio']).'\''; + $addr = empty($_POST['address']) ? 'NULL' : '\''.$db->escape_string($_POST['address']).'\''; + $patterns = array( + 'email' => '/^.+@.+\..+$/', + 'zip' => '/^\d{5}([-\s]\d{4})?$/', + 'phone' => '/\+?\d{1,3}\s*\(?\d{3}\)?\s*\d{3}([-\s]*)\d{4}$/', + ); + $pkeys = array_keys($patterns); + foreach ($pkeys as $pkey) { + if (!preg_match($patterns[$pkey], $_POST[$pkey])) dash_fatal('Invalid field values have been entered.'); + } + $deactivate = ''; + $usepropic = ''; + if ($_POST['email'] != $b_user['email']) { + $deactivate = ', active = 0'; + mail($_POST['email'], 'Verify Your Bulletin Email', eml_tpl(array( + 'activation_vars' => 'uid='.$b_user['id'].'&key='.$b_user['session'], + )), "From: ".$b_config['mail_from']."\r\nContent-type: text/html") or dash_fatal('We couldn\'t send mail to your new email address, so your profile has not been updated.'); + } + if (!empty($_FILES['picture']['tmp_name'])) { + $usepropic = ', picture = id'; + $tmpfile = $_FILES['picture']['tmp_name']; + if (getimagesize($tmpfile) === false) dash_fatal('Your uploaded file is not an image.'); + @$img = imagecreatefromstring(file_get_contents($tmpfile)); + @imagepng($img, 'uimg/'.$b_user['id'].'.png'); + @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); + 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 { +?> + <div id="profile" class="private"> + <div id="proheader"> + <h3 id="protitle"><?=htmlentities($user['name']);?></h3> + <p id="prostars"><?=rating_format($user['rating'], typestr($user['type']));?></p> + </div> + <form action="<?=$_SERVER['REQUEST_URI'];?>" method="post" enctype="multipart/form-data"> + <div id="proleft"> + <h4>Profile Picture</h4> + <div id="propic"> +<?php + if (is_null($user['picture'])) + echo ' <img src="uimg/default.png" alt="Profile Picture" />'.PHP_EOL; + else + echo ' <img src="uimg/'.$user['picture'].'.png" alt="Profile Picture" />'.PHP_EOL; +?> + <p id="hoverupload">Upload New</p> + </div> + <p class="hidden"><input id="chpic" type="file" name="picture" type="image/*" value="Upload New" /></p> + </div> + <div id="proright"> + <div id="probody"> + <h4>Include a Bio</h4> + <p><textarea id="inpbio" name="bio" placeholder="No bio included."><?=htmlentities($user['bio']);?></textarea></p> + </div> + <div id="profoot"> + <h4>Basic Information</h4> + <p><input id="inpemail" name="email" type="text" value="<?=htmlentities($user['email']);?>" placeholder="Email" /></p> + <p><input id="inpphone" name="phone" type="text" value="<?=htmlentities($user['phone']);?>" placeholder="1 (555) 481-4475" /></p> + <p><input id="inpzip" name="zip" type="text" value="<?=htmlentities($user['zipcode']);?>" placeholder="Zipcode" /></p> + <p><input id="inpaddr" name="address" type="text" value="<?=htmlentities($user['address']);?>" placeholder="Address" /></p> + <p><input id="inpchprof" name="chprofile" type="submit" value="Update Profile" /></p> + </div> + </div> + </form> + </div> +<?php +} +require('footer.php'); +?> diff --git a/dash/uimg/1.png b/dash/uimg/1.png Binary files differnew file mode 100644 index 0000000..0bef227 --- /dev/null +++ b/dash/uimg/1.png diff --git a/dash/uimg/default.png b/dash/uimg/default.png Binary files differindex 243b10b..243b10b 100644..100755 --- a/dash/uimg/default.png +++ b/dash/uimg/default.png diff --git a/inc/user.php b/inc/user.php index 789586f..cf0dde8 100644 --- a/inc/user.php +++ b/inc/user.php @@ -9,7 +9,7 @@ if (empty($_COOKIE[$b_config['c_name']]) || !preg_match('/^(\d+);([0-9a-zA-Z\.]+ } else { $db = new bdb(); - $result = $db->query('SELECT * FROM users WHERE id = '.intval($matches[1]).' AND session = \''.hash('sha512', $matches[2]).'\' AND active = 1 LIMIT 1') or fatal($db->error); + $result = $db->query('SELECT users.*, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM users LEFT JOIN ratings ON ratings.rated = users.id WHERE users.id = '.intval($matches[1]).' AND users.session = \''.hash('sha512', $matches[2]).'\' AND users.active = 1 LIMIT 1') or fatal($db->error); if ($result->num_rows < 1) $b_user = $guest_user; else $b_user = $result->fetch_assoc(); $result->free(); @@ -60,7 +60,7 @@ require('inc/common.php'); <p>Post an ad and review your student applicants. Find the worker that's right for you to help you get some work done.</p> </div> <div class="bubble mbubble"> - <p class="bubbleflash">$5/Ad</p> + <p class="bubbleflash">FREE</p> </div> <div class="bubble rbubble"> <p class="bubblehead">Save Some Money</p> |
