From be8e64ca785c9281d09b42aeaa917e8a1673af42 Mon Sep 17 00:00:00 2001 From: cflem Date: Sun, 1 Jan 2017 19:46:20 -0700 Subject: Moved ad displaying to dash_functions.php; finished settings.php --- dash/css/dash.css | 22 ++++++++++++--- dash/dash_employee.php | 27 ++----------------- dash/dash_employer.php | 8 +++--- dash/dash_functions.php | 24 +++++++++++++++++ dash/footer.php | 1 + dash/headless.php | 24 +---------------- dash/settings.php | 71 ++++++++++++++++++++++++++++--------------------- inc/config.php | 6 ++--- inc/config.sample.php | 32 ++++++++++++++++++++++ inc/dash_fatal.tpl | 1 - 10 files changed, 126 insertions(+), 90 deletions(-) create mode 100644 inc/config.sample.php diff --git a/dash/css/dash.css b/dash/css/dash.css index f6f390d..8792c52 100644 --- a/dash/css/dash.css +++ b/dash/css/dash.css @@ -209,11 +209,11 @@ body { #fjfright { text-align: center; } -#fulljob a { +#fulljob a, .errbox a { text-decoration: none; color: #fb4d00; } -#fulljob a:hover { +#fulljob a:hover, .errbox a:hover { color: #fb7700; } #fulljob #ebio { @@ -222,7 +222,7 @@ body { } #fulljob.fjsettings { margin: 2em auto 0 auto; - height: 500px; + height: 455px; border-radius: 5px; } .fjsettings #fjbody { @@ -234,7 +234,7 @@ body { .fjsettings #fjbody p { margin: 0; } -.fjsettings form { +.fjsettings .pseudoform { margin-bottom: 1em; } .fjsettings input, .fjsettings select { @@ -271,3 +271,17 @@ body { .fjsettings input[type=submit]:hover { background-color: #fb7700; } +.errbox { + width: 512px; + margin: 2em auto; + background-color: #ffffff; + padding: 1em; + box-shadow: 0px 0px 5px rgba(0,0,0,0.75); + border-radius: 5px; + text-align: center; + word-break: break-all; +} +#setchgbtn { + margin: 0; + text-align: center; +} diff --git a/dash/dash_employee.php b/dash/dash_employee.php index 0c7e47c..d4a3df1 100644 --- a/dash/dash_employee.php +++ b/dash/dash_employee.php @@ -3,32 +3,9 @@ if (!defined('HEIRARCHY')) die; $title = 'Dashboard / Bulletin'; require('header.php'); $page = 1; -if (!empty($_GET['p'])) $page = max(1, intval($_GET['p'])); +// if (!empty($_GET['p'])) $page = max(1, intval($_GET['p'])); $result = $db->query('SELECT ads.*, categories.cat_name, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads LEFT JOIN categories ON ads.cat = categories.id LEFT JOIN ratings ON ads.uid = ratings.rated GROUP BY ads.id LIMIT ' . $b_config['ads_per_page']*($page-1) . ', '.$b_config['ads_per_page']) or fatal($db->error); -while ($row = $result->fetch_assoc()) { -?> -
- -

-Uncategorized

'.PHP_EOL; - else - echo '

'.htmlentities($row['cat_name']).'

'.PHP_EOL; -?> -

-Employer Not Rated

'.PHP_EOL; - else - echo '

'.intval($row['rating']).' Star Employer

'.PHP_EOL; -?> -

Pays $

-

[...]

-

-
-fetch_assoc()) draw_ad($row); $result->free(); require('footer.php'); ?> diff --git a/dash/dash_employer.php b/dash/dash_employer.php index 28c5ed1..78debfd 100644 --- a/dash/dash_employer.php +++ b/dash/dash_employer.php @@ -2,8 +2,10 @@ if (!defined('HEIRARCHY')) die; $title = 'Dashboard / Bulletin'; require('header.php'); -?> -

-query('SELECT ads.*, categories.cat_name, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads LEFT JOIN categories ON ads.cat = categories.id LEFT JOIN ratings ON ads.uid = ratings.rated GROUP BY ads.id LIMIT ' . $b_config['ads_per_page']*($page-1) . ', '.$b_config['ads_per_page']) or fatal($db->error); +while ($row = $result->fetch_assoc()) draw_ad($row); +$result->free(); require('footer.php'); ?> diff --git a/dash/dash_functions.php b/dash/dash_functions.php index 49664a3..b9fd9db 100644 --- a/dash/dash_functions.php +++ b/dash/dash_functions.php @@ -6,4 +6,28 @@ function dash_fatal ($msg = null, $link = null, $label = null) { require('footer.php'); die; } +function draw_ad ($row) { +?> +
+ +

+Uncategorized

'.PHP_EOL; + else + echo '

'.htmlentities($row['cat_name']).'

'.PHP_EOL; +?> +

+Employer Not Rated

'.PHP_EOL; + else + echo '

'.intval($row['rating']).' Star Employer

'.PHP_EOL; +?> +

Pays $

+

[...]

+

+
+ diff --git a/dash/footer.php b/dash/footer.php index 963d525..11e6462 100644 --- a/dash/footer.php +++ b/dash/footer.php @@ -1,5 +1,6 @@ close(); ?> diff --git a/dash/headless.php b/dash/headless.php index bc321f2..ca090aa 100644 --- a/dash/headless.php +++ b/dash/headless.php @@ -6,29 +6,7 @@ $db = new bdb(); $result = $db->query('SELECT ads.*, categories.cat_name, SUM(ratings.stars) / COUNT(ratings.stars) AS rating FROM ads LEFT JOIN categories ON ads.cat = categories.id LEFT JOIN ratings ON ads.uid = ratings.rated GROUP BY ads.id LIMIT '.($clicks+$b_config['ads_per_page']).', 1') or die(); if ($result->num_rows) { $row = $result->fetch_assoc(); -?> -
- -

-Uncategorized

'.PHP_EOL; - else - echo '

'.htmlentities($row['cat_name']).'

'.PHP_EOL; -?> -

-Employer Not Rated

'.PHP_EOL; - else - echo '

'.intval($row['rating']).' Star Employer

'.PHP_EOL; -?> -

Pays $

-

[...]

-

- -
-free(); $db->close(); diff --git a/dash/settings.php b/dash/settings.php index 5dc2e3d..9a7179a 100644 --- a/dash/settings.php +++ b/dash/settings.php @@ -2,16 +2,25 @@ define('HEIRARCHY', 1); require('dash_common.php'); +global $b_config, $b_user; $title = 'Account Settings / Bulletin'; require('header.php'); -if (!empty($_POST['changepass'])) { +if (!empty($_POST['oldpass'])) { if ($b_user['password'] != hash('sha512', $_POST['oldpass'])) dash_fatal('The password you entered does not match your current password.'); - if ($_POST['newpass1'] != $_POST['newpass2']) dash_fatal('Your new passwords do not match.'); - $db->query('UPDATE users SET password = \''.hash('sha512', $_POST['newpass1']).'\' WHERE id = '.$b_user['id']) or dash_fatal($db->error); - if ($db->affected_rows < 1) dash_fatal('No user with your ID is in the database'); - dash_fatal('Password changed successfully.'); -} else if (!empty($_POST['changetype'])) { - if ($b_user['password'] != hash('sha512', $_POST['curpass'])) dash_fatal('The password you entered does not match your current password.'); + if (!empty($_POST['newpass1'])) { + if ($_POST['newpass1'] != $_POST['newpass2']) dash_fatal('Your new passwords do not match.'); + $db->query('UPDATE users SET password = \''.hash('sha512', $_POST['newpass1']).'\' WHERE id = '.$b_user['id']) or dash_fatal($db->error); + if ($db->affected_rows < 1) dash_fatal('Your password could not be changed.'); + } + + $type = $b_user['type']; + if ($_POST['newtype'] == 0) $type = 'EMPLOYEE'; + else if ($_POST['newtype'] == 1) $type = 'EMPLOYER'; + if ($type != $b_user['type']) { + $db->query('UPDATE users SET type = \''.$type.'\' WHERE id = '.$b_user['id']) or dash_fatal($db->error); + if ($db->affected_rows < 1) dash_fatal('Your account type could not be changed.'); + } + dash_fatal('Account settings successfully updated.'); } ?>
@@ -19,31 +28,31 @@ if (!empty($_POST['changepass'])) {

Account Settings

Adjusting for

-
-

Current Password

-

Your current password is needed to change your account settings.

-

-
-
-
-

Change Password

-

-

-

-
-
-

Change Account Type

-

- -

-

-
-
+
+
+

Current Password

+

Your current password is needed to change your account settings.

+

+
+
+
+

Change Password

+

+

+
+
+

Change Account Type

+

+ +

+
+

+
+
free(); require('footer.php'); ?> diff --git a/inc/config.php b/inc/config.php index 76783c3..b7d21a4 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1,11 +1,11 @@ 'https://www.bulletinalpha.tk/', + 'base_url' => 'http://www.bulletin.com/', 'c_name' => 'bulletin', 'c_expire' => 31536000, - 'c_dom' => '.bulletinalpha.tk', + 'c_dom' => '.bulletin.com', 'c_path' => '/', - 'c_sec' => true, + 'c_sec' => false, 'c_http' => true, 'db_host' => 'localhost', 'db_name' => 'bulletin', diff --git a/inc/config.sample.php b/inc/config.sample.php new file mode 100644 index 0000000..1be5151 --- /dev/null +++ b/inc/config.sample.php @@ -0,0 +1,32 @@ + 'https://www.bulletinalpha.tk/', + + // Cookies Information + 'c_name' => 'bulletin', // Cookie name + 'c_expire' => 31536000, // Expiration time (seconds, default: 1 year) + 'c_dom' => '.bulletinalpha.tk', // Domain + 'c_path' => '/', // Path + 'c_sec' => true, // Serve cookies only over https + 'c_http' => true, // Don't serve cookies to javascript + + // Database Information + 'db_host' => 'localhost', + 'db_name' => '', + 'db_user' => '', + 'db_pass' => '', + + // Send emails from this address + 'mail_from' => 'Bulletin ', + + // Mobile site configuration + 'mobile_base' => 'https://m.bulletinalpha.tk/', + 'moblie_host' => 'm.bulletinalpha.tk', + + // Number of ads per page in the employee dashboard + 'ads_per_page' => 10, + +); +?> diff --git a/inc/dash_fatal.tpl b/inc/dash_fatal.tpl index 31106a2..db7d7fa 100644 --- a/inc/dash_fatal.tpl +++ b/inc/dash_fatal.tpl @@ -1,6 +1,5 @@