diff --git a/config/Db.class.php b/config/Db.class.php new file mode 100644 index 0000000..896ab3e --- /dev/null +++ b/config/Db.class.php @@ -0,0 +1,312 @@ +log = new Log(); + $this->Connect(); + $this->parameters = array(); + } + + /** + * This method makes connection to the database. + * + * 1. Reads the database settings from a ini file. + * 2. Puts the ini content into the settings array. + * 3. Tries to connect to the database. + * 4. If connection failed, exception is displayed and a log file gets created. + */ + private function Connect() + { + $this->settings = parse_ini_file("settings.ini.php"); + $dsn = 'mysql:dbname=' . $this->settings["dbname"] . ';host=' . $this->settings["host"] . ''; + try { + # Read settings from INI file, set UTF8 + $this->pdo = new PDO($dsn, $this->settings["user"], $this->settings["password"], array( + PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" + )); + + # We can now log any exceptions on Fatal error. + $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + # Disable emulation of prepared statements, use REAL prepared statements instead. + $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); + + # Connection succeeded, set the boolean to true. + $this->bConnected = true; + } + catch (PDOException $e) { + # Write into log + echo $this->ExceptionLog($e->getMessage()); + die(); + } + } + /* + * You can use this little method if you want to close the PDO connection + * + */ + public function CloseConnection() + { + # Set the PDO object to null to close the connection + # http://www.php.net/manual/en/pdo.connections.php + $this->pdo = null; + } + + /** + * Every method which needs to execute a SQL query uses this method. + * + * 1. If not connected, connect to the database. + * 2. Prepare Query. + * 3. Parameterize Query. + * 4. Execute Query. + * 5. On exception : Write Exception into the log + SQL query. + * 6. Reset the Parameters. + */ + private function Init($query, $parameters = "") + { + # Connect to database + if (!$this->bConnected) { + $this->Connect(); + } + try { + # Prepare query + $this->sQuery = $this->pdo->prepare($query); + + # Add parameters to the parameter array + $this->bindMore($parameters); + + # Bind parameters + if (!empty($this->parameters)) { + foreach ($this->parameters as $param => $value) { + if(is_int($value[1])) { + $type = PDO::PARAM_INT; + } else if(is_bool($value[1])) { + $type = PDO::PARAM_BOOL; + } else if(is_null($value[1])) { + $type = PDO::PARAM_NULL; + } else { + $type = PDO::PARAM_STR; + } + // Add type when binding the values to the column + $this->sQuery->bindValue($value[0], $value[1], $type); + } + } + + # Execute SQL + $this->sQuery->execute(); + } + catch (PDOException $e) { + # Write into log and display Exception + echo $this->ExceptionLog($e->getMessage(), $query); + die(); + } + + # Reset the parameters + $this->parameters = array(); + } + + /** + * @void + * + * Add the parameter to the parameter array + * @param string $para + * @param string $value + */ + public function bind($para, $value) + { + $this->parameters[sizeof($this->parameters)] = [":" . $para , $value]; + } + /** + * @void + * + * Add more parameters to the parameter array + * @param array $parray + */ + public function bindMore($parray) + { + if (empty($this->parameters) && is_array($parray)) { + $columns = array_keys($parray); + foreach ($columns as $i => &$column) { + $this->bind($column, $parray[$column]); + } + } + } + /** + * If the SQL query contains a SELECT or SHOW statement it returns an array containing all of the result set row + * If the SQL statement is a DELETE, INSERT, or UPDATE statement it returns the number of affected rows + * + * @param string $query + * @param array $params + * @param int $fetchmode + * @return mixed + */ + public function query($query, $params = null, $fetch = true, $fetchmode = PDO::FETCH_ASSOC) + { + $query = trim(str_replace("\r", " ", $query)); + + $this->Init($query, $params); + + $rawStatement = explode(" ", preg_replace("/\s+|\t+|\n+/", " ", $query)); + + # Which SQL statement is used + $statement = strtolower($rawStatement[0]); + + if ($statement === 'select' || $statement === 'show') { + if ($fetch == true) { + return $this->sQuery->fetchAll($fetchmode); + }else { + return $this->sQuery->fetch($fetchmode); + } + + } elseif ($statement === 'insert' || $statement === 'update' || $statement === 'delete') { + // return $this->sQuery->rowCount(); + return true; + } else { + return NULL; + } + } + + /** + * Returns the last inserted id. + * @return string + */ + public function lastInsertId() + { + return $this->pdo->lastInsertId(); + } + + /** + * Starts the transaction + * @return boolean, true on success or false on failure + */ + public function beginTransaction() + { + return $this->pdo->beginTransaction(); + } + + /** + * Execute Transaction + * @return boolean, true on success or false on failure + */ + public function executeTransaction() + { + return $this->pdo->commit(); + } + + /** + * Rollback of Transaction + * @return boolean, true on success or false on failure + */ + public function rollBack() + { + return $this->pdo->rollBack(); + } + + /** + * Returns an array which represents a column from the result set + * + * @param string $query + * @param array $params + * @return array + */ + public function column($query, $params = null) + { + $this->Init($query, $params); + $Columns = $this->sQuery->fetchAll(PDO::FETCH_NUM); + + $column = null; + + foreach ($Columns as $cells) { + $column[] = $cells[0]; + } + + return $column; + + } + /** + * Returns an array which represents a row from the result set + * + * @param string $query + * @param array $params + * @param int $fetchmode + * @return array + */ + public function row($query, $params = null, $fetchmode = PDO::FETCH_ASSOC) + { + $this->Init($query, $params); + $result = $this->sQuery->fetch($fetchmode); + $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued, + return $result; + } + /** + * Returns the value of one single field/column + * + * @param string $query + * @param array $params + * @return string + */ + public function single($query, $params = null) + { + $this->Init($query, $params); + $result = $this->sQuery->fetchColumn(); + $this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued + return $result; + } + /** + * Writes the log and returns the exception + * + * @param string $message + * @param string $sql + * @return string + */ + private function ExceptionLog($message, $sql = "") + { + $exception = 'Unhandled Exception.
'; + $exception .= $message; + $exception .= "
You can find the error back in the log."; + + if (!empty($sql)) { + # Add the Raw SQL to the Log + $message .= "\r\nRaw SQL : " . $sql; + } + # Write into log + $this->log->write($message); + + return $exception; + } +} +?> diff --git a/config/Log.class.php b/config/Log.class.php new file mode 100644 index 0000000..46c294f --- /dev/null +++ b/config/Log.class.php @@ -0,0 +1,70 @@ +path = dirname(__FILE__) . $this->path; + } + + /** + * @void + * Creates the log + * + * @param string $message the message which is written into the log. + * @description: + * 1. Checks if directory exists, if not, create one and call this method again. + * 2. Checks if log already exists. + * 3. If not, new log gets created. Log is written into the logs folder. + * 4. Logname is current date(Year - Month - Day). + * 5. If log exists, edit method called. + * 6. Edit method modifies the current log. + */ + public function write($message) { + $date = new DateTime(); + $log = $this->path . $date->format('Y-m-d').".txt"; + + if(is_dir($this->path)) { + if(!file_exists($log)) { + $fh = fopen($log, 'a+') or die("Fatal Error !"); + $logcontent = "Time : " . $date->format('H:i:s')."\r\n" . $message ."\r\n"; + fwrite($fh, $logcontent); + fclose($fh); + } + else { + $this->edit($log,$date, $message); + } + } + else { + if(mkdir($this->path,0777) === true) + { + $this->write($message); + } + } + } + + /** + * @void + * Gets called if log exists. + * Modifies current log and adds the message to the log. + * + * @param string $log + * @param DateTimeObject $date + * @param string $message + */ + private function edit($log,$date,$message) { + $logcontent = "Time : " . $date->format('H:i:s')."\r\n" . $message ."\r\n\r\n"; + $logcontent = $logcontent . file_get_contents($log); + file_put_contents($log, $logcontent); + } + } +?> diff --git a/config/logs/2022-01-02.txt b/config/logs/2022-01-02.txt new file mode 100644 index 0000000..602244e --- /dev/null +++ b/config/logs/2022-01-02.txt @@ -0,0 +1,7 @@ +Time : 11:58:45 +SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'aircraft_id' at row 1 +Raw SQL : INSERT INTO schedules (aircraft_id, engineer_id, task) VALUES (:aircraft_id, :engineer_id, :task) + +Time : 07:40:33 +SQLSTATE[42S22]: Column not found: 1054 Unknown column 'type' in 'field list' +Raw SQL : INSERT INTO aircraft (company, number, type, age, year, running_hours) VALUES (:company, :number, :type, :age, :year, :running_hours) diff --git a/config/settings.ini.php b/config/settings.ini.php new file mode 100644 index 0000000..bb8d886 --- /dev/null +++ b/config/settings.ini.php @@ -0,0 +1,6 @@ +; +[SQL] +host = 127.0.0.1 +user = root +password = psalm294u +dbname = abc_air diff --git a/controllers/account.php b/controllers/account.php new file mode 100644 index 0000000..26353c1 --- /dev/null +++ b/controllers/account.php @@ -0,0 +1,199 @@ + request::secureTxt($email) + ); + + $account = $db->query("SELECT * FROM engineers WHERE email = :email", $param, false); + + if (!$account) { + respond::alert('warning', '', 'Invalid email address or password'); + return false; + } + $account_pwd = $account['password']; + + $pwd = crypt($password, $account_pwd); + + if ($account_pwd != $pwd) { + respond::alert('warning', '', 'Invalid email address or password'); + return false; + } + + + $_SESSION['user'] = $email; + + header('location: /aircraft'); + return true; + + }// LOGIN METHOD + + public static function fetch($email) { + global $db; + + return $db->query("SELECT * FROM engineers WHERE email = :email", array('email' => $email), false); + + } + + public static function checkAdminAuth($email) { + global $db; + + $param = array( + 'email' => request::secureTxt($email) + ); + + $account = $db->query("SELECT * FROM engineers WHERE email = :email", $param, false); + + if ($account['admin']) { + return true; + } + + return false; + + } + + public static function forgot_password($email) { + global $db; + + if (self::check_email($email)) { + + respond::alert('warning', '', 'Email Address does not exist'); + + }else { + + $reset_code = request::randomString(); + + $param = array( + 'email' => request::secureTxt($email), + 'password_reset' => $reset_code + ); + $statement = "UPDATE accounts SET password_reset = :password_reset WHERE email = :email"; + + if ($db->query($statement, $param)) { + + $email = self::fetch_username($email); + + $from = config::email(); + $subject = "Password Reset"; + $sender = config::name(); + $url = config::base().'reset-password/'.$reset_code; + + $msg = '

+ Someone requested that the password be reset for the following account: +

+

+ Username: '.$email.' +

+

+ If this was a mistake, just ignore this email and nothing will happen. +

+

+ To reset your password, visit the following address: +

+

+ '.$url.' +

+

+ For any requests, please contact '.$from.' +

'; + + mail::send($from, $sender, $email, $subject, $msg); + + respond::alert('success', 'Password reset link sent!', 'A password reset mail has been successfully sent to '.$email); + }else { + respond::alert('warning', '', 'Unable to send a password reset mail'); + } + + } + + }// ACCOUNT FORGOT PASSWORD + + public static function change_password($email, $new_password, $repeat_password) { + global $db; + + $pwd = request::secureTxt($new_password); + $repeat_pwd = request::secureTxt($repeat_password); + + if ($pwd != $repeat_pwd) { + respond::alert('warning', 'Update Error!', "Repeated password doesn't match new password"); + }else{ + $password = request::securePwd($new_password); + + $statement = "UPDATE accounts SET password = :password WHERE username = :username"; + $param = array( + 'password' => $password, + 'username' => $email + ); + + if ($db->query($statement, $param)) { + respond::alert('success', 'Update Success!', 'Password successfully changed'); + }else{ + respond::alert('danger', 'Update Error!', 'Unable to change password'); + } + + } + + } + // CHANGE PASSWORD + + static function check_password($password, $confirm_password) { + if ($password == $confirm_password) { + return true; + }else { + return false; + } + }// CONFIRM PASSWORD + + + public static function update($email, $name, $phone, $photo = array()) { + global $db; + + if ($photo['size'] > 0) { + + $file = $db->single("SELECT photo FROM accounts WHERE username = :username", array('username' => $email)); + + if ($file != 'avatar.png') { + upload::remove($file, config::baseUploadUrl()); + } + + $upload = upload::add($photo, config::baseUploadUrl(), true); + $photo = $upload['file']; + + $db->query("UPDATE accounts SET photo = :photo WHERE username = :username", array('photo' => $photo, 'username' => $email)); + + $photo = config::baseUploadUrl().$photo; + + ?> + + + query("UPDATE accounts SET fname = :name, phone = :phone WHERE username = :username", array( + 'name' => $name, + 'phone' => $phone, + 'username' => $email + ))) { + respond::alert('success', 'Update Success!', 'Profile successfully updated'); + }else { + respond::alert('danger', 'Update Error!', 'Unable to update profile'); + } + + } + + public static function getDetails($email) { + global $db; + return $db->query("SELECT * FROM engineers WHERE email = :email", array('email' => $email), false); + } + +} \ No newline at end of file diff --git a/controllers/aircraft.php b/controllers/aircraft.php new file mode 100644 index 0000000..d383301 --- /dev/null +++ b/controllers/aircraft.php @@ -0,0 +1,165 @@ + request::secureTxt($company), + 'number' => request::secureTxt($number), + 'type' => request::secureTxt($type), + 'age' => request::secureTxt($age), + 'year' => request::secureTxt($year), + 'running_hours' => request::secureTxt($running_hours), + ); + + $insert = $db->query("INSERT INTO aircraft (company, number, aircraft_type, age, year, running_hours) VALUES (:company, :number, :type, :age, :year, :running_hours)", $param); + + if ($insert) { + respond::alert('success', '', 'Aircraft successfully added'); + return false; + } + + respond::alert('danger', '', 'Unable to add aircraft at the moment'); + return false; + + } + + static function check($company, $number) { + global $db; + + $param = array( + 'company' => request::secureTxt($company), + 'number' => request::secureTxt($number) + ); + + $check = $db->query("SELECT * FROM aircraft WHERE company = :company AND number = :number", $param); + + if ($check) { + return true; + } + + return false; + } + + public static function edit($id, $company, $number, $type, $age, $year, $running_hours) { + global $db; + + $update = $db->query("UPDATE aircraft SET company = :company, number = :number, aircraft_type = :type, age = :age, year = :year, running_hours = :running_hours WHERE id = :id", array( + 'id' => $id, + 'company' => $company, + 'number' => $number, + 'type' => $type, + 'age' => $age, + 'year' => $year, + 'running_hours' => $running_hours + )); + + if ($update) { + respond::alert('success', '', 'Aircraft successfully updated'); + return true; + } + + respond::alert('danger', '', 'Unable to update aircraft at the moment'); + return false; + + } + + public static function all() { + global $db; + + $aircraft = $db->query("SELECT * FROM aircraft ORDER BY id DESC"); + + if (count($aircraft) > 0) { + return $aircraft; + } + + return false; + + } + + public static function single($id) { + global $db; + + return $db->query("SELECT * FROM aircraft WHERE id = :id", array( + 'id' => $id + ), false); + + } + + public static function unscheduledAircraft() { + + $unscheduledAircraft = []; + + $aircraft = self::all(); + + foreach ($aircraft as $aircraft_) { + $id = $aircraft_['id']; + $check = self::checkSchedule($id); + if (!$check) { + array_push($unscheduledAircraft, self::single($id)); + } + } + + if (count($unscheduledAircraft) > 0) { + return $unscheduledAircraft; + } + + return false; + + } + + public static function checkSchedule($aircraft_id) { + global $db; + + $param = array( + 'aircraft_id' => request::secureTxt($aircraft_id) + ); + + $check = $db->query("SELECT * FROM schedules WHERE aircraft_id = :aircraft_id", $param); + + if ($check) { + return true; + } + + return false; + } + + public static function remove($id) { + global $db; + + $remove = $db->query("DELETE FROM aircraft WHERE id = :id", array('id' => $id)); + + if ($remove) { + $db->query("DELETE FROM schedules WHERE aircraft_id = :id", array('id' => $id)); + respond::alert('success', '', 'Aircraft successfully removed'); + return true; + } + + respond::alert('danger', '', 'Unable to remove this aircraft at the moment'); + return false; + + } + + public static function removeSchedule($aircraft_id) { + global $db; + + $remove = $db->query("DELETE FROM schedules WHERE aircraft_id = :aircraft_id", array('aircraft_id' => $aircraft_id)); + + if ($remove) { + respond::alert('success', '', 'Aircraft schedule successfully removed'); + return true; + } + + respond::alert('danger', '', 'Unable to remove this aircraft schedule at the moment'); + return false; + + } + +} \ No newline at end of file diff --git a/controllers/engineer.php b/controllers/engineer.php new file mode 100644 index 0000000..daaa9db --- /dev/null +++ b/controllers/engineer.php @@ -0,0 +1,186 @@ + request::secureTxt($name), + 'category' => request::secureTxt($category), + 'email' => request::secureTxt($email), + 'password' => request::securePwd($password) + ); + + $insert = $db->query("INSERT INTO engineers (name, category, email, password) VALUES (:name, :category, :email, :password)", $param); + + if ($insert) { + respond::alert('success', '', 'Engineer successfully added'); + return false; + } + + respond::alert('danger', '', 'Unable to add engineer at the moment'); + return false; + + } + + static function check($email) { + global $db; + + $param = array( + 'email' => request::secureTxt($email) + ); + + $check = $db->query("SELECT * FROM engineers WHERE email = :email", $param); + + if ($check) { + return true; + } + + return false; + } + + public static function checkSchedule($engineer_id) { + global $db; + + $param = array( + 'engineer_id' => request::secureTxt($engineer_id) + ); + + $check = $db->query("SELECT * FROM schedules WHERE engineer_id = :engineer_id", $param); + + if ($check) { + return true; + } + + return false; + } + + public static function unscheduledEngineers() { + + $unscheduledEngineers = []; + + $engineers = self::all(); + + foreach ($engineers as $engineer) { + $id = $engineer['id']; + $check = self::checkSchedule($id); + if (!$check) { + array_push($unscheduledEngineers, self::single($id)); + } + } + + if (count($unscheduledEngineers) > 0) { + return $unscheduledEngineers; + } + + return false; + + } + + public static function edit($id, $name, $category, $email) { + global $db; + + $param = array( + 'email' => request::secureTxt($email), + 'id' => $id + ); + + $check = $db->query("SELECT * FROM engineers WHERE email = :email AND id != :id", $param); + + if ($check) { + respond::alert('danger', '', 'Engineer with the same email address already exist'); + } + + $update = $db->query("UPDATE engineers SET name = :name, category = :category, email = :email WHERE id = :id", array( + 'id' => $id, + 'name' => $name, + 'category' => $category, + 'email' => $email + )); + + if ($update) { + respond::alert('success', '', 'Engineer successfully updated'); + return true; + } + + respond::alert('danger', '', 'Unable to update engineer at the moment'); + return false; + + } + + public static function all() { + global $db; + + $engineers = $db->query("SELECT * FROM engineers WHERE admin = 0 ORDER BY id DESC"); + + if (count($engineers) > 0) { + return $engineers; + } + + return false; + + } + + public static function single($id) { + global $db; + + return $db->query("SELECT * FROM engineers WHERE id = :id", array( + 'id' => $id + ), false); + + } + + public static function remove($id) { + global $db; + + $remove = $db->query("DELETE FROM engineers WHERE id = :id", array('id' => $id)); + + if ($remove) { + $db->query("DELETE FROM schedules WHERE engineer_id = :id", array('id' => $id)); + respond::alert('success', '', 'Engineer successfully removed'); + return true; + } + + respond::alert('danger', '', 'Unable to remove this engineer at the moment'); + return false; + + } + + public static function schedules($engineer_id) { + global $db; + + $param = array( + 'engineer_id' => request::secureTxt($engineer_id) + ); + + $schedules = $db->query("SELECT schedules.*, company, number, name, category, aircraft_type FROM schedules LEFT JOIN aircraft a on a.id = schedules.aircraft_id LEFT JOIN engineers e on schedules.engineer_id = e.id WHERE engineer_id = :engineer_id ORDER BY id DESC", $param); + + if (count($schedules) > 0) { + return $schedules; + } + + return false; + } + + public static function removeSchedule($engineer_id) { + global $db; + + $remove = $db->query("DELETE FROM schedules WHERE engineer_id = :engineer_id", array('engineer_id' => $engineer_id)); + + if ($remove) { + respond::alert('success', '', 'Task successfully removed from engineer'); + return true; + } + + respond::alert('danger', '', 'Unable to remove task from engineer at the moment'); + return false; + + } + +} \ No newline at end of file diff --git a/controllers/schedule.php b/controllers/schedule.php new file mode 100644 index 0000000..0ad5242 --- /dev/null +++ b/controllers/schedule.php @@ -0,0 +1,74 @@ +query("SELECT schedules.*, company, number, name, category, aircraft_type FROM schedules LEFT JOIN aircraft a on a.id = schedules.aircraft_id LEFT JOIN engineers e on schedules.engineer_id = e.id ORDER BY id DESC"); + + if (count($schedules) > 0) { + return $schedules; + } + + return false; + } + + public static function add($aircraft_id, $engineer_id, $task, $engineer = false) { + global $db; + + if (self::check($aircraft_id)) { + respond::alert('warning', '', 'Aircraft is already scheduled'); + return false; + } + + $param = array( + 'aircraft_id' => request::secureTxt($aircraft_id), + 'engineer_id' => request::secureTxt($engineer_id), + 'task' => request::secureTxt($task) + ); + + $insert = $db->query("INSERT INTO schedules (aircraft_id, engineer_id, task) VALUES (:aircraft_id, :engineer_id, :task)", $param); + + if ($insert) { + $engineer ? respond::alert('success', '', 'Task successfully assigned to engineer') : respond::alert('success', '', 'Aircraft successfully scheduled'); + return false; + } + + $engineer ? respond::alert('danger', '', 'Unable to assign task to engineer at the moment') : respond::alert('danger', '', 'Unable to schedule aircraft at the moment'); + return false; + + } + + static function check($aircraft_id) { + global $db; + + $param = array( + 'aircraft_id' => request::secureTxt($aircraft_id) + ); + + $check = $db->query("SELECT * FROM schedules WHERE aircraft_id = :aircraft_id", $param); + + if ($check) { + return true; + } + + return false; + } + + public static function remove($id, $engineer = false) { + global $db; + + $remove = $db->query("DELETE FROM schedules WHERE id = :id", array('id' => $id)); + + if ($remove) { + $engineer ? respond::alert('success', '', 'Task successfully removed from engineer') : respond::alert('success', '', 'Aircraft schedule successfully removed'); + return true; + } + + $engineer ? respond::alert('danger', '', 'Unable to remove task from engineer at the moment') : respond::alert('danger', '', 'Unable to remove this aircraft schedule at the moment'); + return false; + + } + +} \ No newline at end of file diff --git a/helpers/config.php b/helpers/config.php new file mode 100644 index 0000000..547b99d --- /dev/null +++ b/helpers/config.php @@ -0,0 +1,121 @@ +Akwa Ibom, Nigeria"; + } + + public static function accountDetails() { + return "Bank: Suntrust bank
Account Name: Janelle Apparels
Account Number: 0001148001"; + } + + public static function phone() { + return "+234 708 022 7501"; + } + + public static function url() { + return self::$url; + } + + public static function logo() { + return 'assets/images/logo.svg'; + } + + public static function favicon() { + return 'assets/images/favicon.png'; + } + + public static function baseUploadProductUrl() { + return 'assets/images/products/'; + } + + public static function baseUploadSliderUrl() { + return 'assets/images/sliders/'; + } + + public static function baseUploadProfileUrl() { + return 'assets/images/users/'; + } + + public static function baseUploadPromoUrl() { + return 'assets/images/promo/'; + } + + public static function baseUploadProductGalleryUrl() { + return 'assets/images/products/gallery/'; + } + + public static function baseUploadCategoryUrl() { + return 'assets/images/categories/'; + } + + + + public static function baseUploadLookbookCoverUrl() { + return 'assets/images/lookbook/cover/'; + } + + public static function baseUploadLookbookUrl() { + return 'assets/images/lookbook/'; + } + + + public static function meta() { + ?> + + + + + + + + + + + + + + + + + + + + + + + + $value) { + $d = array($key => self::secureTxt($value)); + $data += $d; + } + $request = array("method" => $method, "request" => $data); + return $request; + } + + public static function parameters($data, $required) { + + $isOkay = true; + foreach ($required as $key => $value) { + + if (!array_key_exists($value, $data)) { + $isOkay = false; + } + } + + if ($isOkay) { + return true; + }else { + + return false; + + } + + } + + public static function compress($source, $destination, $quality = 40) { + + $info = getimagesize($source); + + if ($info['mime'] == 'image/jpeg') + $image = imagecreatefromjpeg($source); + + elseif ($info['mime'] == 'image/gif') + $image = imagecreatefromgif($source); + + elseif ($info['mime'] == 'image/png') + $image = imagecreatefrompng($source); + + if (imagejpeg($image, $destination, $quality)) { + return true; + }else { + return false; + } + + } + + public static function pre($object) { + ?> +
+                
+            
+ is_valid_address(array('address' => $address)))['data']['is_valid']; + return $status; + + } + + +} + diff --git a/helpers/respond.php b/helpers/respond.php new file mode 100644 index 0000000..95b3874 --- /dev/null +++ b/helpers/respond.php @@ -0,0 +1,152 @@ + +
+ + +

+ +

+ +
+ $status, + 'status_message' => $status_message, + 'data' => $data + ); + echo json_encode($response); + } + +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..42efb4d --- /dev/null +++ b/index.php @@ -0,0 +1,113 @@ + +
+
+
+

Account login

+
+ +
+ +
+ Login with email address and password +
+ +
+
+ + + autocomplete="off" placeholder="Input email address" name="email"/> +
+
+ + +
+
+ +
+ + +
+
+ \ No newline at end of file