diff --git a/README.md b/README.md index c387482..72f433b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A simple Content Management System for Reseller of MyOwnFreeHost - [x] Change language -### member module +### ClientArea module - [x] Account registration - [x] Account verification diff --git a/assets/css/clientarea.css b/assets/css/clientarea.css new file mode 100644 index 0000000..dc2b193 --- /dev/null +++ b/assets/css/clientarea.css @@ -0,0 +1,13 @@ +.mx-auto { + margin-left: auto !important; + margin-right: auto !important; + float: none; +} + +#imageUpload { + display: none; +} + +.img-avatar { + max-height: 200px; +} \ No newline at end of file diff --git a/assets/js/clientarea.js b/assets/js/clientarea.js new file mode 100644 index 0000000..289b621 --- /dev/null +++ b/assets/js/clientarea.js @@ -0,0 +1,5 @@ +$("#uploadNewImage").click(function () { + $("#imageBox").hide(); + $("#imageUpload").show(); + +}); diff --git a/clientarea.php b/clientarea.php new file mode 100644 index 0000000..cbd6e16 --- /dev/null +++ b/clientarea.php @@ -0,0 +1,30 @@ +prepare( + "UPDATE users SET is_active = 0 WHERE id = ?" + ); + $stmt->bind_param("i", $user->id); + if ($stmt->execute()) { + setMsg("msg_notify", "Your account has been deactivated successfully. Request support to activate your account."); + unset($_SESSION["user"]); + redirect("clientarea", "login"); + } + } +} else { + redirect("clientarea", "details"); +} diff --git a/clientarea/controllers/account_verify.php b/clientarea/controllers/account_verify.php new file mode 100644 index 0000000..f05ae21 --- /dev/null +++ b/clientarea/controllers/account_verify.php @@ -0,0 +1,22 @@ + 20 || strlen($old_password) < 5) { + $errors["old_password_err"] = "Old Password min limit is 5 & max is 20 characters"; + } elseif (!password_verify($old_password, $user->password)) { + $errors["old_password_err"] = "Old password incorrect please enter valid password"; + } + + if (strlen($password) > 20 || strlen($password) < 5) { + $errors["password_err"] = "Password min limit is 5 & max is 20 characters"; + } + + if ($password != $confirm_password || empty($confirm_password)) { + $errors["confirm_password_err"] = "Password does not match or empty"; + } + + if (!count($errors)) { + $stmt = $objDB->prepare("UPDATE users SET password = ? WHERE id = ?"); + $stmt->bind_param("si", password_hash($password, PASSWORD_DEFAULT), $user->id); + + if ($stmt->execute()) { + setMsg("msg_notify", "Your account password has been updated successfully."); + unset($_SESSION["user"]); + redirect("clientarea", "login"); + exit(); + } + } else { + $data = [ + "old_password" => $old_password, + "password" => $password, + "confirm_password" => $confirm_password, + ]; + setMsg("form_data", $data); + setMsg("errors", $errors); + } +} diff --git a/clientarea/controllers/details.php b/clientarea/controllers/details.php new file mode 100644 index 0000000..1d03d53 --- /dev/null +++ b/clientarea/controllers/details.php @@ -0,0 +1,18 @@ +image)) ? '/clientarea/images/' . $user->image : "http://via.placeholder.com/150x150"; +$userRegDate = cTime($user->created_at); diff --git a/clientarea/controllers/edit_details.php b/clientarea/controllers/edit_details.php new file mode 100644 index 0000000..1dbc9f6 --- /dev/null +++ b/clientarea/controllers/edit_details.php @@ -0,0 +1,82 @@ +image)) ? '/clientarea/images/' . $user->image : "http://via.placeholder.com/150x150"; + +if (isset($_POST["edit"])) { + + $errors = array(); + + $name = filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING); + $username = filter_input(INPUT_POST, "username", FILTER_SANITIZE_STRING); + $email = filter_input(INPUT_POST, "email", FILTER_SANITIZE_EMAIL); + $website = filter_input(INPUT_POST, "website", FILTER_SANITIZE_URL); + $image = isset($_FILES["image"]) ? $_FILES["image"] : ""; + + $user = $_SESSION["user"]; + + if (strlen($name) > 50 || strlen($name) < 6) { + $errors["name_err"] = "Name min limit is 6 & max is 50 characters"; + } + + if (strlen($username) > 15 || strlen($username) < 5) { + $errors["username_err"] = "Username min limit is 5 & max is 15 characters"; + } + + if (!isemail($email)) { + $errors["email_err"] = "The email address is invalid."; + } + + if (empty($website)) { + $errors["website_err"] = "Invalid entry"; + } + + if ($image["error"] != 4) { + if (!is_dir(APPROOT . "/images")) { + mkdir(APPROOT . "/images"); + } + + if ($image["error"] == 4) { + $errors["image_err"] = "Please, upload file"; + } elseif ($image["type"] != "image/png" && $image["type"] != "image/jpeg") { + $errors["image_err"] = "Only, png/jpeg image is allowed"; + } + + $image_info = pathinfo($image["name"]); + extract($image_info); + $image_convention = $filename . time() . ".$extension"; + + move_uploaded_file($image["tmp_name"], APPROOT . "/images/" . $image_convention); + } else { + $image_convention = $user->image; + } + + if (!count($errors)) { + $stmt = $objDB->prepare( + "UPDATE users SET name = ?, email = ?, username=?, website=?, image=? WHERE id=?" + ); + $stmt->bind_param("sssssi", $name, $email, $username, $website, $image_convention, $user->id); + + if ($stmt->execute()) { + setMsg("msg_notify", "Your account has been updated successfully."); + } + + $_SESSION["user"] = getUserById($user->id); + redirect("clientarea", "details"); + } else { + setMsg("errors", $errors); + redirect("clientarea", "edit_details"); + } +} diff --git a/clientarea/controllers/emails.php b/clientarea/controllers/emails.php new file mode 100644 index 0000000..2bcab20 --- /dev/null +++ b/clientarea/controllers/emails.php @@ -0,0 +1,33 @@ + 12, + "pages" => 4, + "page" => 1, + "list" => [ + [ + "id" => "3453822", + "date" => "Saturday, August 11th, 2018 (04:50)", + "subject" => "Invoice Payment Confirmation" + ], + [ + "id" => "3453821", + "date" => "Friday, August 10th, 2018 (12:00)", + "subject" => "Customer Invoice" + ], + [ + "id" => "3453820", + "date" => "Tuesday, April 3rd, 2018 (00:51)", + "subject" => "Your password has been reset" + ] + ] +]; diff --git a/clientarea/controllers/forget_password.php b/clientarea/controllers/forget_password.php new file mode 100644 index 0000000..a510cb2 --- /dev/null +++ b/clientarea/controllers/forget_password.php @@ -0,0 +1,53 @@ + $email, + ]; + setMsg("form_data", $data); + setMsg("errors", $errors); + redirect("clientarea", "forget_password"); + } else { + $code = md5(crypt(rand(), "aa")); + $stmt = $objDB->prepare( + "UPDATE users SET is_active = 0, reset_code=? WHERE email=?" + ); + $stmt->bind_param("ss", $code, $email); + if ($stmt->execute()) { + setMsg("msg_notify", "You made a password request, please check email to reset your password.", "success"); + $message = "Hi! You requested password reset, . You need to click here to reset your password."; + echo $message; + send_mail([ + "to" => $email, + "message" => $message, + "subject" => "Reset Password Requested" + ]); + } else { + setMsg("msg_notify", "reset password request, Please try again later.", "warning"); + } + } +} diff --git a/clientarea/controllers/index.php b/clientarea/controllers/index.php new file mode 100644 index 0000000..a3de1d1 --- /dev/null +++ b/clientarea/controllers/index.php @@ -0,0 +1,2 @@ + 15 || strlen($username) < 5) { + $errors["username_err"] = "Username min limit is 5 & max is 15 characters"; + } elseif (!checkUserByUsername($username)) { + $errors["username_err"] = "Username not exists"; + } elseif (!checkUserActivation($username)) { + $errors["username_err"] = 'Your account is not verified, click here to verify.'; + } + + if (strlen($password) > 20 || strlen($password) < 5) { + $errors["password_err"] = "Password min limit is 5 & max is 20 characters"; + } + if (!count($errors)) { + $stmt = $objDB->prepare("SELECT * FROM users WHERE username=?"); + $stmt->bind_param("s", $username); + $stmt->execute(); + $result = $stmt->get_result(); + $user = $result->fetch_object(); + if ($result->num_rows == 1) { + if (password_verify($password, $user->password)) { + if ($remember == "Yes") { + setcookie("user", serialize($user), time() + (86400 * 30), "/"); + } else { + $_SESSION["user"] = $user; + } + redirect("clientarea", "details"); + } else { + setMsg("msg_notify", "Account not found, please enter correct credentials", "warning"); + } + } + } else { + $data = [ + "username" => $username, + "password" => $password, + ]; + setMsg("form_data", $data); + setMsg("errors", $errors); + redirect("clientarea", "login"); + } +} diff --git a/clientarea/controllers/logout.php b/clientarea/controllers/logout.php new file mode 100644 index 0000000..25eccc4 --- /dev/null +++ b/clientarea/controllers/logout.php @@ -0,0 +1,23 @@ + 50 || strlen($name) < 6) { + $errors["name_err"] = "Name min limit is 6 & max is 50 characters"; + } + + if (strlen($username) > 15 || strlen($username) < 5) { + $errors["username_err"] = "Username min limit is 5 & max is 15 characters"; + } elseif (checkUserByUsername($username)) { + $errors["username_err"] = "Username already exists"; + } + + if (!isemail($email)) { + $errors["email_err"] = "The email address is invalid."; + } elseif (checkUserByEmail($email)) { + $errors["email_err"] = "The email address already exists in system."; + } + + if (empty($website)) { + $errors["website_err"] = "Invalid entry"; + } + + if (strlen($password) > 20 || strlen($password) < 5) { + $errors["password_err"] = "Password min limit is 5 & max is 20 characters"; + } + + if ($password != $confirm_password || empty($confirm_password)) { + $errors["confirm_password_err"] = "Password does not match or empty"; + } + + if (!count($errors)) { + $password = password_hash($password, PASSWORD_DEFAULT); + $code = md5(crypt(rand(), "aa")); + $stmt = $objDB->prepare( + "INSERT INTO users(name, email, username, password, website, created_at, reset_code) + VALUES(?, ?, ?, ?, ?, ?, ?)" + ); + $stmt->bind_param("sssssis", $name, $email, $username, $password, $website, time(), $code); + if ($stmt->execute()) { + setMsg("msg_notify", "Your account has been created successfully.Please, check your email to verify.", "warning"); + $message = "Hi! You requested an account on our website, in order to use this account. You need to click here to Verify it."; + send_mail([ + "to" => $email, + "message" => $message, + "subject" => "Account Verficiation" + ]); + redirect("clientarea", "login"); + } + } else { + $data = [ + "name" => $name, + "username" => $username, + "email" => $email, + "website" => $website, + "password" => $password, + "confirm_password" => $confirm_password, + ]; + setMsg("form_data", $data); + setMsg("errors", $errors); + redirect("clientarea", "register"); + } +} diff --git a/clientarea/controllers/request-account-activate.php b/clientarea/controllers/request-account-activate.php new file mode 100644 index 0000000..cc1c9f7 --- /dev/null +++ b/clientarea/controllers/request-account-activate.php @@ -0,0 +1,43 @@ +prepare( + "UPDATE users SET reset_code=? WHERE email=?" + ); + $stmt->bind_param("ss", $code, $email); + if ($stmt->execute()) { + setMsg("msg_notify", "Please check your email to verify your account", "warning"); + $message = "Hi! You requested account verification. You need to click here to activate your account."; + send_mail([ + "to" => $email, + "message" => $message, + "subject" => "Account Verification Request", + ]); + } + } else { + $data = [ + "email" => $email, + ]; + setMsg("form_data", $data); + setMsg("errors", $errors); + } +} diff --git a/clientarea/controllers/reset_password.php b/clientarea/controllers/reset_password.php new file mode 100644 index 0000000..e935f62 --- /dev/null +++ b/clientarea/controllers/reset_password.php @@ -0,0 +1,63 @@ + 20 || strlen($password) < 5) { + $errors["password_err"] = "Password min limit is 5 & max is 20 characters"; + } + if (empty($confirm_password)) { + $errors["confirm_password_err"] = "The password is empty."; + } elseif ($password != $confirm_password) { + $errors["confirm_password_err"] = "The password does not match."; + } + if (!count($errors)) { + $password = password_hash($password, PASSWORD_DEFAULT); + $stmt = $objDB->prepare( + "UPDATE users SET reset_code= '', is_active=1, password=? WHERE reset_code=?" + ); + $stmt->bind_param("ss", $password, $reset_code); + if ($stmt->execute()) { + setMsg("msg_notify", "Your account password has been reset, you can login now."); + redirect("clientarea", "login"); + } + } else { + $data = [ + "password" => $password, + "confirm_password" => $confirm_password, + ]; + setMsg("form_data", $data); + setMsg("errors", $errors); + redirect("clientarea", "reset_password", ["reset_code" => $reset_code]); + } +} diff --git a/clientarea/controllers/tickets.php b/clientarea/controllers/tickets.php new file mode 100644 index 0000000..0ba42b0 --- /dev/null +++ b/clientarea/controllers/tickets.php @@ -0,0 +1,39 @@ + 10, + "pages" => 4, + "page" => 1, + "list" => [ + [ + "date" => "Saturday, August 11th, 2018 (04:50)", + "department" => "Saturday, August 11th, 2018 (04:50)", + "subject" => "Invoice Payment Confirmation", + "status" => "", + "lastupdated" => "" + ], + [ + "date" => "Friday, August 10th, 2018 (12:00)", + "department" => "Friday, August 10th, 2018 (12:00)", + "subject" => "Customer Invoice", + "status" => "", + "lastupdated" => "" + ], + [ + "date" => "Tuesday, April 3rd, 2018 (00:51)", + "department" => "Tuesday, April 3rd, 2018 (00:51)", + "subject" => "Your password has been reset", + "status" => "", + "lastupdated" => "" + ] + ] +]; diff --git a/clientarea/data/config.php b/clientarea/data/config.php new file mode 100644 index 0000000..85460d6 --- /dev/null +++ b/clientarea/data/config.php @@ -0,0 +1,26 @@ +debug = false; + $this->smtp_port = $smtp_port; + $this->relay_host = $relay_host; + $this->time_out = 30; // is used in fsockopen() + $this->auth = $auth; // auth + $this->user = $user; + $this->pass = $pass; + $this->host_name = "localhost"; //is used in HELO command + $this->log_file = ""; + $this->sock = false; + } + + public function sendmail($to, $totitle = "", $from, $fromtitle = "", $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "") + { + $mail_from = $this->get_address($this->strip_comment($from)); + $body = preg_replace("/(^|(\r\n))(\.)/", "\1.\3", $body); + $header = "MIME-Version:1.0\r\n"; + if ($mailtype == "HTML") { + $header .= 'Content-Type: text/html; charset="utf-8"' . "\r\n"; + } + if (!empty($totitle)) { + $header .= "To: =?utf-8?B?" . base64_encode($totitle) . "?= <{$to}>\r\n"; + } else { + $header .= "To: {$to} <{$to}>\r\n"; + } + if (!empty($cc)) { + $header .= "Cc: {$cc}\r\n"; + } + if (!empty($fromtitle)) { + $header .= "From: =?utf-8?B?" . base64_encode($fromtitle) . "?= <{$from}>\r\n"; + } else { + $header .= "From: {$from} <{$from}>\r\n"; + } + $header .= "Subject: =?utf-8?B?" . base64_encode($subject) . "?=\r\n"; + $header .= $additional_headers; + $header .= "Date: " . date("r") . "\r\n"; + $header .= "X-Mailer: By UIISC (PHP/" . phpversion() . ")\r\n"; + list($msec, $sec) = explode(" ", microtime()); + $header .= "Message-ID: <" . date("YmdHis", $sec) . "." . ($msec * 1000000) . "." . $mail_from . ">\r\n"; + $TO = explode(",", $this->strip_comment($to)); + if ($cc != "") { + $TO = array_merge($TO, explode(",", $this->strip_comment($cc))); + } + if ($bcc != "") { + $TO = array_merge($TO, explode(",", $this->strip_comment($bcc))); + } + $sent = true; + foreach ($TO as $rcpt_to) { + $rcpt_to = $this->get_address($rcpt_to); + if (!$this->smtp_sockopen($rcpt_to)) { + $this->log_write("Error: Cannot send email to " . $rcpt_to . "\n"); + $sent = false; + continue; + } + if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) { + $this->log_write("E-mail has been sent to <" . $rcpt_to . ">\n"); + } else { + $this->log_write("Error: Cannot send email to <" . $rcpt_to . ">\n"); + $sent = false; + } + fclose($this->sock); + $this->log_write("Disconnected from remote host\n"); + } + return $sent; + } + + /* Private Functions */ + public function smtp_send($helo, $from, $to, $header, $body = "") + { + if (!$this->smtp_putcmd("HELO", $helo)) { + return $this->smtp_error("sending HELO command"); + } + if ($this->auth) { + if (!$this->smtp_putcmd("AUTH LOGIN", base64_encode($this->user))) { + return $this->smtp_error("sending HELO command"); + } + if (!$this->smtp_putcmd("", base64_encode($this->pass))) { + return $this->smtp_error("sending HELO command"); + } + } + if (!$this->smtp_putcmd("MAIL", "FROM:<" . $from . ">")) { + return $this->smtp_error("sending MAIL FROM command"); + } + if (!$this->smtp_putcmd("RCPT", "TO:<" . $to . ">")) { + return $this->smtp_error("sending RCPT TO command"); + } + if (!$this->smtp_putcmd("DATA")) { + return $this->smtp_error("sending DATA command"); + } + if (!$this->smtp_message($header, $body)) { + return $this->smtp_error("sending message"); + } + if (!$this->smtp_eom()) { + return $this->smtp_error("sending . [EOM]"); + } + if (!$this->smtp_putcmd("QUIT")) { + return $this->smtp_error("sending QUIT command"); + } + return true; + } + + public function smtp_sockopen($address) + { + if ($this->relay_host == "") { + return $this->smtp_sockopen_mx($address); + } else { + return $this->smtp_sockopen_relay(); + } + } + + public function smtp_sockopen_relay() + { + $this->log_write("Trying to " . $this->relay_host . ":" . $this->smtp_port . "\n"); + $this->sock = @fsockopen($this->relay_host, $this->smtp_port, $errno, $errstr, $this->time_out); + if (!($this->sock && $this->smtp_ok())) { + $this->log_write("Error: Cannot connenct to relay host " . $this->relay_host . "\n"); + $this->log_write("Error: " . $errstr . " (" . $errno . ")\n"); + return false; + } + $this->log_write("Connected to relay host " . $this->relay_host . "\n"); + return true; + } + + public function smtp_sockopen_mx($address) + { + $domain = ereg_replace("^.+@([^@]+)$", "\1", $address); + if (!@getmxrr($domain, $MXHOSTS)) { + $this->log_write("Error: Cannot resolve MX \"" . $domain . "\"\n"); + return false; + } + foreach ($MXHOSTS as $host) { + $this->log_write("Trying to " . $host . ":" . $this->smtp_port . "\n"); + $this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out); + if (!($this->sock && $this->smtp_ok())) { + $this->log_write("Warning: Cannot connect to mx host " . $host . "\n"); + $this->log_write("Error: " . $errstr . " (" . $errno . ")\n"); + continue; + } + $this->log_write("Connected to mx host " . $host . "\n"); + return true; + } + $this->log_write("Error: Cannot connect to any mx hosts (" . implode(", ", $MXHOSTS) . ")\n"); + return false; + } + + public function smtp_message($header, $body) + { + fputs($this->sock, $header . "\r\n" . $body); + $this->smtp_debug("> " . str_replace("\r\n", "\n" . "> ", $header . "\n> " . $body . "\n> ")); + return true; + } + + public function smtp_eom() + { + fputs($this->sock, "\r\n.\r\n"); + $this->smtp_debug(". [EOM]\n"); + return $this->smtp_ok(); + } + + public function smtp_ok() + { + $response = str_replace("\r\n", "", fgets($this->sock, 512)); + $this->smtp_debug($response . "\n"); + if (!preg_match("/^[23]/", $response)) { + fputs($this->sock, "QUIT\r\n"); + fgets($this->sock, 512); + $this->log_write("Error: Remote host returned \"" . $response . "\"\n"); + return false; + } + return true; + } + + public function smtp_putcmd($cmd, $arg = "") + { + if ($arg != "") { + if ($cmd == "") { + $cmd = $arg; + } else { + $cmd = $cmd . " " . $arg; + } + } + fputs($this->sock, $cmd . "\r\n"); + $this->smtp_debug("> " . $cmd . "\n"); + return $this->smtp_ok(); + } + + public function smtp_error($string) + { + $this->log_write("Error: Error occurred while " . $string . ".\n"); + return false; + } + + public function log_write($message) + { + $this->smtp_debug($message); + if ($this->log_file == "") { + return true; + } + $message = date("M d H:i:s ") . get_current_user() . "[" . getmypid() . "]: " . $message; + if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) { + $this->smtp_debug("Warning: Cannot open log file \"" . $this->log_file . "\"\n"); + return false; + } + flock($fp, LOCK_EX); + fputs($fp, $message); + fclose($fp); + return true; + } + + public function strip_comment($address) + { + $comment = "/\([^()]*\)/"; + while (preg_match($comment, $address)) { + $address = ereg_replace($comment, "", $address); + } + return $address; + } + + public function get_address($address) + { + $address = preg_replace("/([ \t\r\n])+/", "", $address); + $address = preg_replace("/^.*<(.+)>.*$/", "\1", $address); + return $address; + } + + public function smtp_debug($message) + { + if ($this->debug) { + echo $message; + } + } +} diff --git a/clientarea/library/functions.php b/clientarea/library/functions.php new file mode 100644 index 0000000..b1abbf3 --- /dev/null +++ b/clientarea/library/functions.php @@ -0,0 +1,217 @@ +connect_error) { + die("Connection not established"); + } + return $objDB; +} + +function upload_image($image) +{ + + if (!is_dir(APPROOT . "/images")) { + mkdir(APPROOT . "/images"); + } + + if ($image["error"] == 4) { + die("image file not uploaded"); + } + + if ($image["type"] != "image/png") { + die("Only, png image files are allowed"); + } + + $image_info = pathinfo($image["name"]); + extract($image_info); + $image_convention = $filename . time() . ".$extension"; + + if (move_uploaded_file($image["tmp_name"], APPROOT . "/images/" . $imageConvention)) { + return $image_convention; + } else { + return false; + } +} + +function cTime($timestamp) +{ + return date("Y-m-d H:i:s", $timestamp); +} + +function checkUserByEmail($email) +{ + + $objDB = objDB(); + $stmt = $objDB->prepare( + "SELECT * FROM users WHERE email=?" + ); + + $stmt->bind_param("s", $email); + $stmt->execute(); + $stmt->store_result(); + return $stmt->num_rows; +} + +function checkUserByUsername($username) +{ + + $objDB = objDB(); + $stmt = $objDB->prepare( + "SELECT * FROM users WHERE username=?" + ); + $stmt->bind_param("s", $username); + $stmt->execute(); + $stmt->store_result(); + return $stmt->num_rows; +} + +function checkUserActivation($username) +{ + + $objDB = objDB(); + $stmt = $objDB->prepare( + "SELECT * FROM users WHERE username=? AND is_active=1" + ); + $stmt->bind_param("s", $username); + $stmt->execute(); + $stmt->store_result(); + return $stmt->num_rows; +} + +function setMsg($name, $value, $class = "success") +{ + if (is_array($value)) { + $_SESSION[$name] = $value; + } else { + $_SESSION[$name] = "
$value
"; + } +} + +function getMsg($name) +{ + if (isset($_SESSION[$name])) { + $session = $_SESSION[$name]; + unset($_SESSION[$name]); + return $session; + } +} + +function getUserById($user_id) +{ + + $objDB = objDB(); + $stmt = $objDB->prepare( + "SELECT * FROM users WHERE id=?" + ); + $stmt->bind_param("i", $user_id); + $stmt->execute(); + $result = $stmt->get_result(); + return $result->fetch_object(); +} + +function verifyUserAccount($code) +{ + + $objDB = objDB(); + $stmt = $objDB->prepare( + "UPDATE users SET is_active = 1 , reset_code = '' WHERE reset_code = ?" + ); + $stmt->bind_param("s", $code); + $stmt->execute(); + $stmt->store_result(); + return $stmt->affected_rows; +} + +function checkUserByCode($code) +{ + $objDB = objDB(); + $stmt = $objDB->prepare( + "SELECT * FROM users WHERE reset_code = ?" + ); + $stmt->bind_param("s", $code); + $stmt->execute(); + $stmt->store_result(); + return $stmt->num_rows; +} + +function isUserLoggedIn() +{ + if (isset($_SESSION["user"]) || isset($_COOKIE["user"])) { + return true; + } else { + return false; + } +} + +function get_userinfo() +{ + return isUserLoggedIn() ? isset($_COOKIE["user"]) ? unserialize($_COOKIE["user"]) : $_SESSION["user"] : ""; +} + +function send_mail($detail = array()) +{ + if (!empty($detail["to"]) && !empty($detail["message"]) && !empty($detail["subject"])) { + $to = $detail["to"]; + $totitle = isset($detail["totitle"]) ? $detail["totitle"] : ""; + $from = SMTP_MAILADDR; + $fromtitle = isset($detail["fromtitle"]) ? $detail["fromtitle"] : ""; + $subject = $detail["subject"]; + $body = $detail["message"]; + $mailtype = "HTML"; // HTML/TXT + + $smtp = new MailSMTP(SMTP_SERVER, SMTP_PORT, true, SMTP_USERNAME, SMTP_PASSWORD); + $smtp->debug = false; + $res = $smtp->sendmail($to, $totitle, $from, $fromtitle, $subject, $body, $mailtype); + if (!$res) { + return false; + } else { + return true; + } + } else { + die("Your Mail Handler requires four main paramters"); + } +} + +/** + * redirect to functions URL + */ +function redirect($module, $section = "", $param = []) +{ + $url = $param ? setRouter($module, $section) . "&" . http_build_query($param) : setRouter($module, $section); + // $param = $param ? http_build_query($param) : ""; + // $url = $section ? setRouter($module, $section) . "&" . $param : setRouter($module) . "?" . $param; + header("Location: {$url}"); + exit; +} + +/** make router URL + * @param mixed $module + * @param mixed $section + * @return string + */ +function setRouter($module, $section = "") +{ + return empty($section) ? "{$module}.php" : "{$module}.php?s=$section"; +} + +/** make a full path http URL + * @param mixed $module + * @param mixed $section + * @return string + */ +function setURL($module, $section = "") +{ + return empty($section) ? URLROOT . "/{$module}.php" : URLROOT . "/{$module}.php?s=$section"; +} + +/** Determine if a variable is an email address + * + * @param string $email + * @return bool + */ +function isemail($email = "") +{ + return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $email); +} diff --git a/clientarea/views/account_deactivation.php b/clientarea/views/account_deactivation.php new file mode 100644 index 0000000..3dc498a --- /dev/null +++ b/clientarea/views/account_deactivation.php @@ -0,0 +1,25 @@ + + +
+
+
+
+
+

Account Deactivation

+
+
+ +
+ +
+
+
+
diff --git a/clientarea/views/account_verify.php b/clientarea/views/account_verify.php new file mode 100644 index 0000000..537da15 --- /dev/null +++ b/clientarea/views/account_verify.php @@ -0,0 +1,25 @@ + + +
+
+
+
+
+

Account Verify

+
+
+ +
+ +
+
+
+
diff --git a/clientarea/views/change_password.php b/clientarea/views/change_password.php new file mode 100644 index 0000000..04cf67f --- /dev/null +++ b/clientarea/views/change_password.php @@ -0,0 +1,46 @@ + + +
+
+
+ +
+
+

Change Password

+
+
+

Please fill in credentials to Change Password.

+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/clientarea/views/details.php b/clientarea/views/details.php new file mode 100644 index 0000000..e9fb257 --- /dev/null +++ b/clientarea/views/details.php @@ -0,0 +1,71 @@ + + +
+
+
+ +
+
+

Account Details

+
+
+
+ +
+
+
+ + name); ?> +
+
+ + email); ?> +
+
+ + username); ?> +
+
+ + website); ?> +
+
+
+ + +
+
+ +
+
+
+
+ + diff --git a/clientarea/views/edit_details.php b/clientarea/views/edit_details.php new file mode 100644 index 0000000..d2c4d14 --- /dev/null +++ b/clientarea/views/edit_details.php @@ -0,0 +1,60 @@ + + +
+
+
+ +
+
+

Edit Account Details

+
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+ +
+ + + +
+
+ +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/clientarea/views/emails.php b/clientarea/views/emails.php new file mode 100644 index 0000000..7c7ee97 --- /dev/null +++ b/clientarea/views/emails.php @@ -0,0 +1,55 @@ + + +
+
+
+ +
+
+

Email History

+
+
+
+ + + + + + + + + + + $value) { ?> + + + + + + + + + + + + +
IDDate SentMessage SubjectOperate
+ +
No Records Found
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/clientarea/views/footer.php b/clientarea/views/footer.php new file mode 100644 index 0000000..1381d23 --- /dev/null +++ b/clientarea/views/footer.php @@ -0,0 +1,32 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/clientarea/views/forget_password.php b/clientarea/views/forget_password.php new file mode 100644 index 0000000..387f2b1 --- /dev/null +++ b/clientarea/views/forget_password.php @@ -0,0 +1,37 @@ + + +
+
+
+ +
+
+

Forget Password

+
+
+

If you have forgotten your password, you can reset it here. When you fill in your registered email address, you will be sent instructions on how to reset your password.

+

Please fill in credentials to get a link to reset password.

+
+
+ + + +
+
+ +
+
+
+ +
+
+
+
diff --git a/clientarea/views/header.php b/clientarea/views/header.php new file mode 100644 index 0000000..a877645 --- /dev/null +++ b/clientarea/views/header.php @@ -0,0 +1,29 @@ + + + + + + + + + + + Client Area + + + + + + + + + diff --git a/clientarea/views/index.php b/clientarea/views/index.php new file mode 100644 index 0000000..a3de1d1 --- /dev/null +++ b/clientarea/views/index.php @@ -0,0 +1,2 @@ + + +
+
+
+ +
+
+

Login

+
+
+

Please fill in credentials to log in.

+
+
+ + + +
+
+ + + +
+
+ + +
+
+
+ +
+
+
+
diff --git a/clientarea/views/logout.php b/clientarea/views/logout.php new file mode 100644 index 0000000..f1e0183 --- /dev/null +++ b/clientarea/views/logout.php @@ -0,0 +1,26 @@ + +
+
+
+ +
+
+

Logout

+
+
+

What do you want to do.

+

+ Login + Register +

+
+
+
+
+
\ No newline at end of file diff --git a/clientarea/views/main.php b/clientarea/views/main.php new file mode 100644 index 0000000..0428063 --- /dev/null +++ b/clientarea/views/main.php @@ -0,0 +1,52 @@ + + +
+

Client Area

+
+
+ +
+
+

Client Area

+
+
+

Please fill in credentials to log in.

+
+ +
+
+
+
+ +
+
+

Project Client Area Features

+

Create the complete login and register form

+
+
+
+ +
+
+ +
+
+
\ No newline at end of file diff --git a/clientarea/views/navbar.php b/clientarea/views/navbar.php new file mode 100644 index 0000000..6409737 --- /dev/null +++ b/clientarea/views/navbar.php @@ -0,0 +1,75 @@ + + + \ No newline at end of file diff --git a/clientarea/views/register.php b/clientarea/views/register.php new file mode 100644 index 0000000..97ef9c6 --- /dev/null +++ b/clientarea/views/register.php @@ -0,0 +1,61 @@ + + +
+
+
+ +
+
+

Account Register

+
+
+

Please fill in credentials to Sign Up.

+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+ +
+
+
+
diff --git a/clientarea/views/request-account-activate.php b/clientarea/views/request-account-activate.php new file mode 100644 index 0000000..e4c6b04 --- /dev/null +++ b/clientarea/views/request-account-activate.php @@ -0,0 +1,35 @@ + + +
+
+
+ +
+
+

Activate Account Request

+
+
+
+
+ + + +
+
+ +
+
+
+ +
+
+
+
diff --git a/clientarea/views/reset_password.php b/clientarea/views/reset_password.php new file mode 100644 index 0000000..b975374 --- /dev/null +++ b/clientarea/views/reset_password.php @@ -0,0 +1,43 @@ + + +
+
+
+ +
+
+

Reset Password

+
+
+

Please fill in credentials to Reset Password.

+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+
+
+
diff --git a/clientarea/views/tickets.php b/clientarea/views/tickets.php new file mode 100644 index 0000000..b26a4be --- /dev/null +++ b/clientarea/views/tickets.php @@ -0,0 +1,56 @@ + + +
+
+
+ +
+
+ Support Tickets + New Ticket +
+
+
+ + + + + + + + + + + + $value) { ?> + + + + + + + + + + + + + +
DateDepartmentSubjectStatusLast Updated
No Records Found
+
+
+ +
+
+
+
\ No newline at end of file