/** Hent status for en henvendelse (ajax) */ public static function action_status() { // mangler ID? if (!isset($_POST['su_id'])) { redirect::handle(""); } // finner vi den? $su = support_henvendelse::get($_POST['su_id']); if (!$su || !$su->has_access() || $su->own) { ajax::text("ERROR:404-SUPPORT", ajax::TYPE_404); } // vis status $su->status_ajax(); }
<?php /** * Hent raw data for et forumsvar * * Inndata: * - sid * - topic_id * - reply_id */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); // hent forumtråd $topic = new \Kofradia\Forum\TopicAjax(postval("topic_id")); // hent forumsvaret $reply = $topic->get_reply(postval("reply_id")); // fant ikke forumsvaret? if (!$reply) { ajax::text("ERROR:404-REPLY", ajax::TYPE_INVALID); } // krev tilgang til forumsvaret $reply->require_access(); // send tilbake data ajax::text($reply->info['fr_text']);
/** * Forumsvaret ble lagt til (som nytt forumsvar) */ protected function add_reply_complete($reply_id) { \ajax::text("REDIRECT:" . \ess::$s['relative_path'] . "/forum/topic?id={$this->id}&replyid={$reply_id}"); }
/** * Krev at brukeren ikke har noen aktiv lås * @param boolean $allow_crew tillate crew å vise siden? */ public static function validate_lock($allow_crew = false) { // har vi lås? if (login::check_lock()) { // crew? if ($allow_crew && access::has("crewet")) { return; } // har vi ingen spiller? if (count(login::$user->lock) == 1 && in_array("player", login::$user->lock)) { ajax::text("ERROR:NO-PLAYER", ajax::TYPE_INVALID); } // ikke tillatt ajax::text("ERROR:USER-RESTRICTED", ajax::TYPE_INVALID); } }
/** * Krev en bestemt bruker * @param mixed brukerid/e-post/brukernavn * @param optional mixed brukerid/e-post/brukernavn * @param .. */ public static function need_userid() { global $_base; if (login::$logged_in) { for ($i = 0; $i < func_num_args(); $i++) { $req = func_get_arg($i); if (is_int($req)) { if ($req == login::$user->id) { return; } } else { if ($req == login::$user->data['u_email']) { return; } if ($req == login::$user->player->data['up_name']) { return; } } } } // ajax? if (defined("SCRIPT_AJAX")) { ajax::text("ERROR:NO-ACCESS,DEFINED-USERS-ONLY", ajax::TYPE_INVALID); } echo "<h1>Ikke tilgang</h1><p>Du har ikke tilgang til denne siden!</p><p>Den er forebeholdt bestemte brukere.</p>"; $_base->page->load(); }
<?php require "../../app/ajax.php"; ajax::require_user(); // mangler brukerid? if (!isset($_POST['up_id'])) { $_POST['up_id'] = 1; } global $__server, $_game, $_base; $mod = access::has("mod"); $up_id = intval($_POST['up_id']); // hent spillerdata $result = \Kofradia\DB::get()->query("\n\tSELECT\n\t\tusers_players.*,\n\t\tup_cash + up_bank AS money,\n\t\tu_email, u_online_ip,\n\t\tupr_rank_pos\n\tFROM users_players\n\t\tLEFT JOIN users_players_rank ON upr_up_id = up_id,\n\t\tusers\n\tWHERE up_id = {$up_id} AND up_u_id = u_id\n\tGROUP BY up_id"); if (!($player = $result->fetch())) { ajax::text("ERROR:404-USER", ajax::TYPE_404); } // hent FF $result = \Kofradia\DB::get()->query("\n\tSELECT ffm_priority, ff_id, ff_name, ff_type\n\tFROM ff_members JOIN ff ON ffm_ff_id = ff_id\n\tWHERE ffm_up_id = {$up_id} AND ffm_status = 1 AND ff_inactive = 0\n\tORDER BY ff_name"); $ff = array(); while ($row = $result->fetch()) { $type = ff::$types[$row['ff_type']]; $row['posisjon'] = ucfirst($type['priority'][$row['ffm_priority']]); $ff[] = $row; } // profilbildet $profile_image = player::get_profile_image_static($player['up_profile_image_url']); // ranken $rank = game::rank_info($player['up_points'], $player['upr_rank_pos'], $player['up_access_level']); #$rank_name = $rank['name']; // statusen $status = "";
<?php require "graphs_base.php"; ajax::require_user(); // annen bruker $u_id = login::$user->id; $up_name = login::$user->player->data['up_name']; if (isset($_GET['up_id']) && access::has("mod")) { $up_id = (int) getval("up_id"); $result = \Kofradia\DB::get()->query("SELECT up_u_id, up_id, up_name FROM users_players WHERE up_id = {$up_id}"); if ($result->rowCount() == 0) { ajax::text("ERROR:UP-404", ajax::TYPE_404); } $row = $result->fetch(); $u_id = $row['up_u_id']; $up_name = $row['up_name']; } // sett opp tidspunkt $date = ess::$b->date->get(); $time_end = $date->format("U"); $day_end = $date->format("Y-m-d"); $date->modify("-30 days"); $date->setTime(0, 0, 0); $time_start = $date->format("U"); $stats = array(); while (true) { $day = $date->format("Y-m-d"); $stats[$day] = 0; $date->modify("+1 day"); if ($day == $day_end) { break;
<?php /** * Annonser forumsvar * * Inndata: * - sid * - topic_id * - reply_id */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); // hent forumtråd $topic = new \Kofradia\Forum\TopicAjax(postval("topic_id")); // hent forumsvaret $reply = $topic->get_reply(postval("reply_id")); // fant ikke forumsvaret? if (!$reply) { ajax::text("ERROR:404-REPLY", ajax::TYPE_INVALID); } // ikke et gyldig forum hvor vi kan annonsere forumsvar på nytt? if ($topic->forum->id < 5 || $topic->forum->id > 7) { ajax::text("ERROR:INVALID-ANNOUNCE-FORUM", ajax::TYPE_INVALID); } // annonser svaret $reply->announce(); ajax::text("Forumsvaret ble annonsert på nytt. Du ser også denne oppføringen i hendelser.");
} // kontroller tilgang til forumet $forum = new \Kofradia\Forum\CategoryAjax($topic['ft_fse_id']); $forum->require_access(); // mangler svarliste? if (!isset($_POST['r_id_list'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // hvilket tidspunkt vi skal hente endringer etter if (!isset($_POST['time'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } $time_last = (int) $_POST['time']; // mangler siste id? if (!isset($_POST['r_last_id'])) { ajax::text("ERROR:MISSING"); } // sett opp liste over svar-ID-ene vi har $id_list = array_unique(array_map("intval", explode(",", $_POST['r_id_list']))); // sett opp siste ID $id_last = intval($_POST['r_last_id']); // skal vi hente nye svar etter $id_last ? $get_new = isset($_POST['get_new']); // sjekk om noen av svarene er slettet og vi skal fjerne slettede svar $deleted = array(); if (count($id_list) > 0 && !isset($_POST['no_delete'])) { $result = \Kofradia\DB::get()->query("SELECT fr_id FROM forum_replies WHERE fr_id IN (" . implode(",", $id_list) . ") AND fr_deleted != 0"); while ($row = $result->fetch()) { $deleted[] = $row['fr_id']; unset($id_list[array_search($row['fr_id'], $id_list)]); }
/** Behandle respons */ public function handle_ret($id, $data = NULL) { switch ($id) { case self::RET_INFO_DELETED_OWN: case self::RET_INFO_DELETED: case self::RET_INFO_REPORTED: break; case self::RET_ERROR_404: ajax::text("Fant ikke meldingstråden.", ajax::TYPE_404); break; case self::RET_ERROR_MARK_NO_REL: ajax::text("NO-RELATION", ajax::TYPE_INVALID); break; case self::RET_INFO_MARK_ALREADY: if ($this->data_rel['ir_marked']) { ajax::text("MARK-TRUE"); } else { ajax::text("MARK-FALSE"); } break; case self::RET_INFO_MARK_TRUE: ajax::text("MARK-TRUE"); break; case self::RET_INFO_MARK_FALSE: ajax::text("MARK-FALSE"); break; default: throw new HSException("Ukjent behandler."); } }
/** Ingen endringer ble utført */ protected function edit_error_nochange() { \ajax::text("Ingen endringer ble utført.", \ajax::TYPE_INVALID); }
require "../../app/ajax.php"; ajax::require_user(); // kontroller lås ajax::validate_lock(); // hent alle utfordringer $result = \Kofradia\DB::get()->query("SELECT poker_id, poker_starter_up_id, poker_time_start, poker_starter_cards, poker_cash FROM poker WHERE poker_state = 2 ORDER BY poker_cash"); $i = 0; $data = array(); $html_to_parse = array(); while ($row = $result->fetch()) { $d = array(); $d['self'] = $row['poker_starter_up_id'] == login::$user->player->id; $html_to_parse[$i] = (!$d['self'] ? '<input type="radio" name="id" value="' . $row['poker_id'] . '" />' : '') . '<user id="' . $row['poker_starter_up_id'] . '" />'; $d['cash'] = game::format_cash($row['poker_cash']); $d['reltime'] = poker_round::get_time_text($row['poker_time_start']); if (access::has("admin")) { $cards = new CardsPoker(explode(",", $row['poker_starter_cards'])); $d['cards'] = $cards->solve_text($cards->solve()); } $data[$i++] = $d; } // parse html if (count($html_to_parse) > 0) { $html_to_parse = parse_html_array($html_to_parse); foreach ($html_to_parse as $i => $value) { $data[$i]['player'] = $value; } } ajax::text(js_encode($data), ajax::TYPE_OK);
* - locked [optional forum mod] */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); global $_base, $_game; // mangler forumtråd-id? if (!isset($_POST['topic_id'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // mangler data? if (!isset($_POST['title']) || !isset($_POST['text'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // mangler sist redigert? if (!isset($_POST['last_edit'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // hent forumtråden $topic = new \Kofradia\Forum\TopicAjax($_POST['topic_id']); // kontroller at forumtråden ikke har blitt endret siden sist oppdatert $last_edit = (int) $_POST['last_edit']; if ($topic->info['ft_last_edit'] && $topic->info['ft_last_edit'] > $last_edit) { ajax::text("ERROR:TOPIC-ALREADY-EDITED:{$topic->info['ft_last_edit']}", ajax::TYPE_INVALID); } // forsøk å utfør endringer $type = isset($_POST['type']) && $topic->forum->fmod ? $_POST['type'] : NULL; $locked = isset($_POST['locked']) && $topic->forum->fmod ? $_POST['locked'] : NULL; $section = isset($_POST['section']) ? $_POST['section'] : NULL; $topic->edit($_POST['title'], $_POST['text'], $section, $type, $locked);
/** * Markere/fjerne markering av meldingstråd * @param inbox_thread_ajax $thread */ public static function thread_mark(inbox_thread_ajax $thread) { // kontroller SID ajax::validate_sid(); // kan vi ikke markere denne tråden? if (!$thread->data_rel) { ajax::text("NO-RELATION", ajax::TYPE_INVALID); } // skal vi fjerne eller legge til markering? if (!isset($_POST['mark'])) { ajax::text("MISSING-MARK", ajax::TYPE_INVALID); } $mark = $_POST['mark'] != 0; // forsøk å markere tråden $thread->mark($mark); }
<?php require "../../app/ajax.php"; // mangler tekst? if (!isset($_POST['text'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } global $__server; ajax::essentials(); // logg $name = login::$logged_in ? login::$user->player->data['up_name'] : '*ukjent spiller*'; $ref = isset($_SERVER['HTTP_REFERER']) ? ' - referer: ' . $_SERVER['HTTP_REFERER'] : ' - ingen referer'; putlog("LOG", "%c3%bMIN-STATUS:%b%c %u{$name}%u hentet HTML for BB-kode{$ref}"); // sett opp html $bb = parse_html(game::bb_to_html($_POST['text'])); // send raw html? if (isset($_POST['plain'])) { ajax::text($bb); } // send inni xml element ajax::xml('<content>' . htmlspecialchars($bb) . '</content>');
ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); global $_base, $_game; // mangler forumsvar-id? if (!isset($_POST['reply_id'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // mangler nytt innhold? if (!isset($_POST['text'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // mangler sist redigert? if (!isset($_POST['last_edit'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } // hent forumsvaret $reply = new \Kofradia\Forum\ReplyAjax($_POST['reply_id']); // fant ikke forumsvaret? if (!$reply->info) { ajax::text("ERROR:404-REPLY", ajax::TYPE_INVALID); } // hent forumtråden til forumsvaret $reply->get_topic(); // kontroller at svaret ikke har blitt endret siden sist oppdatert $last_edit = (int) $_POST['last_edit']; if ($reply->info['fr_last_edit'] && $reply->info['fr_last_edit'] > $last_edit) { ajax::text("ERROR:REPLY-ALREADY-EDITED:{$reply->info['fr_last_edit']}", ajax::TYPE_INVALID); } // forsøk å utfør endringer $reply->edit($_POST['text']);
<?php require "../../app/ajax.php"; ajax::require_user(); global $_base; // mangler brukerid? if (!isset($_POST['q'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } $q = $_POST['q']; // limit $limit = intval(min(100, max(1, postval("limit", 10)))); // ekskluder? $exclude = ""; $exclude_ids = array(); if (isset($_POST['exclude'])) { $exclude_ids = array_unique(array_map("intval", explode(",", $_POST['exclude']))); if (count($exclude_ids) > 0) { $exclude = "up_id NOT IN (" . implode(",", $exclude_ids) . ") AND "; } } // ignorere egne deaktiverte spillere? if (isset($_POST['is'])) { $exclude .= "up_u_id != " . login::$user->id . " AND "; } // hent brukere $q2 = \Kofradia\DB::quote(str_replace("_", "\\_", $q)); $result = \Kofradia\DB::get()->query("SELECT SQL_CALC_FOUND_ROWS up_id, up_name, up_access_level FROM users_players WHERE {$exclude}up_name LIKE {$q2} ORDER BY LENGTH(up_name), up_name LIMIT {$limit}"); $result2 = \Kofradia\DB::get()->query("SELECT FOUND_ROWS()"); $num = $result2->fetchColumn(0); // logg
<?php /** * Slett forumsvar * * Inndata: * - sid * - topic_id * - reply_id */ require "../../../app/ajax.php"; ajax::validate_sid(); // kontroller lås ajax::validate_lock(true); // hent forumtråd $topic = new \Kofradia\Forum\TopicAjax(postval("topic_id")); // hent forumsvaret $reply = $topic->get_reply(postval("reply_id")); // fant ikke forumsvaret? if (!$reply) { ajax::text("ERROR:404-REPLY", ajax::TYPE_INVALID); } // forsøk å slette $reply->delete();
<?php require "../../app/ajax.php"; ajax::require_user(); // sjekk handling if (!isset($_POST['a1'])) { ajax::text("ERROR:MISSING", ajax::TYPE_INVALID); } $action = $_POST['a1']; // sjekk action switch ($action) { } ajax::text("Ukjent handling.", ajax::TYPE_INVALID);
/** Forumtråden ble redigert */ protected function add_topic_complete($topic_id) { \ess::$b->page->add_message("Forumtråden ble opprettet."); \ajax::text("REDIRECT:" . \ess::$s['relative_path'] . "/forum/topic?id={$topic_id}"); }