function authorization($login, $password) { $password = md5($password); $db = new \core\system\DB(); $table = "userLogin"; $what = ""; $where = ["login" => $login, "password" => $password]; $orderColumn = "login"; $desc = "ASC"; $limit = [0, 30]; $result = $db->select($table, $what, $where, $orderColumn, $desc, $limit); if (count($result) > 0) { $_SESSION['auth'] = "true"; $_SESSION['login'] = $login; $token = md5($login . "login"); $_SESSION['token'] = $token; if (isset($_POST["memory"])) { setcookie("auth", "true", 1, "/"); setcookie("login", $login, 1, "/"); setcookie("token", "", 1, "/"); } else { setcookie("auth", "true", time() + 3600, "/"); //куки на час setcookie("login", $login, time() + 3600, "/"); setcookie("token", $token, time() + 3600, "/"); } return true; } else { $_SESSION['auth'] = "false"; $_SESSION['login'] = ""; return false; } }
function updateOne() { $db = new \core\system\DB(); $table = "userData"; if ($_GET['wt_idUser']) { $what["idUser"] = $_GET['wt_idUser']; } if ($_GET['wt_lastName']) { $what["lastName"] = $_GET['wt_lastName']; } if ($_GET['wt_firstName']) { $what["firstName"] = $_GET['wt_firstName']; } if ($_GET['wt_gender']) { $what["gender"] = $_GET['wt_gender']; } if ($_GET['wr_idUser']) { $where["idUser"] = $_GET['wr_idUser']; } if ($_GET['wr_lastName']) { $where["lastName"] = $_GET['wr_lastName']; } if ($_GET['wr_firstName']) { $where["firstName"] = $_GET['wr_firstName']; } if ($_GET['wr_gender']) { $where["gender"] = $_GET['wr_gender']; } if ($db->update($table, $what, $where)) { return true; } else { return false; } }