public static function login($login, $password, $session = true) { if (empty($login)) { raptor_warning("Trying to login player with no login"); } if (empty($password)) { raptor_warning("Trying to login player with no password"); } $data = Database::GetOne("config", array("mod" => "auth"))['authType']; $check = Database::GetOne("players", array($data => $login, "password" => md5($password))); if (empty($check['login'])) { return false; } else { if ($session === true) { $_SESSION['id'] = $check['_id']->__toString(); } Database::Edit("players", array("_id" => $check['_id']), array("last_ip" => $_SERVER['REMOTE_ADDR'], "last_date" => raptor_date())); return $check['_id']; } call_user_func("onPlayerLogin", $_POST['name']); }
function makeReport($name, $text, $date) { $date = !empty($date) ? $date : raptor_date(); Database::Insert("reports", array("author" => $name, "date" => $date, "message" => $text)); }
<h2>Новости</h2> <br> <form method="POST"><p><button name="new" type="submit" value="1" class="btn btn-xs btn-default">Создать новость</button></p></form> <hr> <?php if (isset($_POST['title'])) { $_POST['_id'] = toId($_GET['edit']); Database::Edit("news", array("_id" => toId($_GET['edit'])), $_POST); echo '<div class="alert alert-success">Новость успешно отредактирована</div>'; } if (isset($_POST['new'])) { $id = new MongoId(); Database::Insert("news", array("_id" => $id, "short" => '', "title" => '', "full" => '', "date" => raptor_date(), "public" => '1')); die("<script>location.href = '/admin/news?edit=" . $id . "';</script>"); } if (isset($_GET['edit'])) { $array = Database::GetOne("news", array("_id" => toId($_GET['edit']))); echo "<form action='' method='POST'>\n\t\t<input class='form-control' name='title' value='" . $array['title'] . "' placeholder='Заголовок'>\n\t\t<textarea rows=15 cols=105 placeholder='Анонс (краткое описание)' name='short'>" . $array['short'] . "</textarea> <br>\n <textarea rows=15 cols=105 placeholder='Полный текст' name='full'>" . $array['full'] . "</textarea> <br>\n <button type='submit' class='btn btn-default'>Сохранить</button>\n </form>\n <hr>"; } ?> <div class="table-responsive"> <table class="table table-bordered table-hover table-striped"> <thead> <tr> <td>Заголовок</td> <td></td> </tr> </thead> <tbody>
public static function makereport($array) { if (!isset($_POST['text'])) { $answer = json_encode(array('error' => 'Cant read text')); } if (!isset($_SESSION['cid'])) { $answer = json_encode(array('error' => 'Not logged in')); } $text = trim($_POST['text']); $text = htmlspecialchars($_POST['text']); $text = strip_tags($_POST['text']); Database::Insert("reports", array("author" => char()->name, "message" => $text, "date" => raptor_date())); $answer = json_encode(array('message' => 'Report sent')); return $answer; }