/** * Update settings so the value increases by one for this type * * @param string Name of type (code|other) */ public static function incSetting($name, $inc = 1) { $name = \Kofradia\DB::quote('github_' . $name); $inc = (int) $inc; \Kofradia\DB::get()->exec("\n\t\t\tINSERT INTO settings SET name = {$name}, value = 1\n\t\t\tON DUPLICATE KEY UPDATE value = value + {$inc}"); \Kofradia\Settings::reload(); }
/** * Legg til e-post i køen * @param object email $email * @param array receivers * @param string subject * @param bool sende e-posten med en gang */ public static function add_emails(email $email, $receivers, $subject, $send_now = false) { global $_base; if (!is_array($receivers)) { $receivers = array($receivers); } if (!isset($email->data) || !$email->data) { throw new HSException("Email must be formatted before input."); } // sett opp tag $id = uniqid("", true); $add = array(); foreach ($receivers as $item) { $more = $send_now ? ", " . (time() + self::$timeout) . ", " . \Kofradia\DB::quote($id) : ""; $add[] = "(" . \Kofradia\DB::quote($item) . "," . \Kofradia\DB::quote($subject) . "," . \Kofradia\DB::quote($email->data[0]) . "," . \Kofradia\DB::quote($email->data[1]) . "," . \Kofradia\DB::quote($email->params) . "{$more})"; } // noen vi skal legge til? if (count($add) > 0) { $more = $send_now ? ", m_active_end, m_active_id" : ""; \Kofradia\DB::get()->exec("INSERT INTO mailer (m_receiver, m_subject, m_headers, m_body, m_params{$more}) VALUES " . implode(", ", $add)); } // skal e-postene sendes med en gang? if ($send_now) { return array($add, self::send_tag($id)); } return count($add); }
/** * Oppdater en Hall of Fame (oppnådd) */ protected static function set_data($name, $sub, $data, $extra = null) { $a = \Kofradia\DB::get()->exec("\n\t\t\tINSERT IGNORE INTO hall_of_fame\n\t\t\tSET\n\t\t\t\thof_name = " . \Kofradia\DB::quote($name) . ",\n\t\t\t\thof_sub = " . \Kofradia\DB::quote($sub) . ",\n\t\t\t\thof_time = " . time() . ",\n\t\t\t\thof_data = " . \Kofradia\DB::quote(serialize($data))); $affected = $a > 0; // logg list($subject, $url) = self::get_subject($name, $extra); $text = self::get_text($name, $sub, $data); putlog("INFO", "%bHALL OF FAME:%b %u" . $subject . "%u ble " . $text . " {$url}"); // spillerlogg $up = null; if ($name != "familie" && $name != "familie_rank") { $up = $extra; } if ($name == "ff_owner") { $up = $extra[1]; } if ($up) { $up->add_log("hall_of_fame", $text); } // ff-logg if ($name == "familie") { $extra->add_log("info", 'Broderskapet ble det første broderskap i spillet og havnet på <a href="&rpath;/hall_of_fame">Hall of Fame</a>!'); } elseif ($name == "familie_rank") { $extra->add_log("info", 'Broderskapet har for øyeblikket flest poeng av alle broderskap på spillet i historien og havnet på <a href="&rpath;/hall_of_fame">Hall of Fame</a>!'); } self::cache_load(true); return $affected; }
/** Lagre til logg systemet */ function putlog($area, $msg) { global $_base; static $b = ""; static $c = ""; static $u = ""; static $locations = array("LOG" => array("#SMLogs", "SMAFIA"), "SPAM" => array("#SMLogs", "SMAFIA"), "INFO" => array("#SMLogs", "SMAFIA", "#kofradia", "QuakeNet"), "SPAMLOG" => array("#SMLogs", "SMAFIA"), "ANTIBOT" => array("#SMLogs", "SMAFIA"), "SUPERLOG" => array("#SMLogs", "SMAFIA"), "PROFILVIS" => array("#SMLogs", "SMAFIA"), "CREWCHAN" => array("#SMLogs", "SMAFIA", "#opers", "SMAFIA"), "ANTIBOT_ERROR" => array("#opers", "SMAFIA"), "FF" => array("#SMLogs", "SMAFIA", "#FF", "SMAFIA"), "ABUSE" => array("#SMLogs", "SMAFIA", "#SMAbuse", "SMAFIA"), "ABUSE2" => array("#SMLogs", "SMAFIA", "#SMAbuse", "SMAFIA", "#opers", "SMAFIA"), "NOTICE" => array("#SMLogs", "SMAFIA", "#SMNotice", "SMAFIA"), "DF" => array("#SMDF", "SMAFIA")); // bytt ut juksetegnene med spesialtegn $msg = str_replace(array("%b", "%c", "%u", "\r", "\n"), array($b, $c, $u, "", ""), $msg); $file = $area == "INT" ? LOGFILE_INT : LOGFILE; if ($area == "LOG") { $sid = 0; if (login::$logged_in) { $sid = login::$info['ses_id']; } elseif (isset($_SESSION[$GLOBALS['__server']['session_prefix'] . 'login_info']['ses_id'])) { $sid = $_SESSION[$GLOBALS['__server']['session_prefix'] . 'login_info']['ses_id']; } $msg .= " {$c}15(SID: " . login::$info['ses_id'] . ")"; } // skriv til databasen og if ($area != "INT") { global $_base; if (isset($locations[$area])) { for ($i = 0; $i < count($locations[$area]); $i += 2) { $chan = $locations[$area][$i]; $net = $locations[$area][$i + 1]; \Kofradia\DB::get()->exec("INSERT INTO log_irc SET li_network = " . \Kofradia\DB::quote($net) . ", li_channel = " . \Kofradia\DB::quote($chan) . ", li_time = " . time() . ", li_message = " . \Kofradia\DB::quote($msg)); } } else { $err = "UKJENT({$area}): "; \Kofradia\DB::get()->exec("INSERT INTO log_irc SET li_time = " . time() . ", li_message = " . \Kofradia\DB::quote($err . $msg)); } } // fjern IRC-tegn fra loggmeldingen som legges i tekstloggen $text = str_replace(array($b, $u), array("", "'"), preg_replace("/{$c}(\\d{1,2}(,\\d{1,2})?)?/", "", $msg)); // vis informasjon til konsoll for scheduler bakgrunn-scriptet if (defined("SCHEDULER_REPEATING")) { $t = microtime(true); $m = sprintf("%02d", round(($t - (int) $t) * 100)); echo ess::$b->date->get((int) $t)->format("H:i:s.") . $m . ": " . $text . "\n"; } // finnes ikke loggfilen? if (!file_exists($file)) { $fh = fopen($file, "a"); if (!$fh) { throw new HSException("error (putlog_mf)", sysreport::EXCEPTION_ANONYMOUS); } fwrite($fh, "\r\n" . $_base->date->get()->format("d-m-Y H:i:s ") . "{$area}: {$text}"); fclose($fh); chmod($file, 0777); } else { $fh = fopen($file, "a"); if (!$fh) { throw new HSException("error (putlog_mf)", sysreport::EXCEPTION_ANONYMOUS); } fwrite($fh, "\r\n" . $_base->date->get()->format("d-m-Y H:i:s ") . "{$area}: {$text}"); fclose($fh); } }
/** * Load specific poll * * @param int * @param \user * @return \Kofradia\Polls\Poll */ public static function load($poll_id, \user $user = null) { $poll_id = \Kofradia\DB::quote($poll_id); $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT p_id, p_active, p_ft_id, p_title, p_text, p_time_start, p_time_end" . ($user ? ", pv_po_id, pv_time" : "") . "\n\t\t\tFROM polls" . ($user ? "\n\t\t\t\tLEFT JOIN polls_votes ON pv_up_id = " . $user->player->id . " AND pv_p_id = p_id" : "") . "\n\t\t\tWHERE p_id = {$poll_id}\n\t\t\tGROUP BY p_id"); if ($row = $result->fetch()) { return static::createFromData($row, $user); } }
/** * Sett telleren til bestemt verdi * @param string $name * @param integer $count */ public static function set($name, $value) { global $_base; $value = (int) $value; // forsøk å sett telleren til bestemt verdi $affected = \Kofradia\DB::get()->exec("UPDATE tasks SET t_ant = {$value} WHERE t_name = " . \Kofradia\DB::quote($name)); // oppdater cache self::load(true); return $affected; }
/** * Legg til oppføring */ public static function add_row($html, $time = null) { $time = (int) $time; if (!$time) { $time = time(); } if (empty($html)) { throw new HSException("Mangler HTML."); } // legg til oppføringen \Kofradia\DB::get()->exec("INSERT INTO livefeed SET lf_time = {$time}, lf_html = " . \Kofradia\DB::quote($html)); }
/** * Generate autologin-row for a user * * @param int $u_id * @param int $expire timestamp * @param optional string $redirect * @param optional int $type (1=resets password) * @return string hash */ public static function generate($u_id, $expire, $redirect = null, $type = null) { $u_id = (int) $u_id; $expire = (int) $expire; $type = $type === null ? null : (int) $type; // generer hash $hash = mb_substr(sha1(sha1($u_id . $expire . uniqid()) . ($redirect ? $redirect : "doh")), 0, 16); // opprett $redirect = $redirect ? ", al_redirect = " . \Kofradia\DB::quote($redirect) : ""; \Kofradia\DB::get()->exec("\n\t\t\tINSERT INTO autologin\n\t\t\tSET al_u_id = {$u_id}, al_hash = " . \Kofradia\DB::quote($hash) . ", al_time_created = " . time() . ",\n\t\t\t\tal_time_expire = " . $expire . "{$redirect}, al_type = " . \Kofradia\DB::quote($type)); return $hash; }
/** * Add to database */ public function addToDb() { // already in db? if ($this->id) { return; } Hendelser::incSetting("count_events"); foreach ($this->getDescriptionHTML() as $text) { if ($this->event_name == "push") { Hendelser::incSetting("count_code", $this->getLogCount()); } else { Hendelser::incSetting("count_other", $this->getLogCount()); } } \Kofradia\DB::get()->exec("\n\t\t\tINSERT INTO github_log\n\t\t\tSET gl_time = " . $this->event_time->getTimestamp() . ", gl_event_type = " . \Kofradia\DB::quote($this->event_name) . ",\n\t\t\t gl_contents = " . \Kofradia\DB::quote(serialize($this)) . ", gl_log_count = " . $this->getLogCount()); }
/** * Oppdater data */ public static function update_data() { global $_base; // hent data $data = self::get_changes(); if (!$data) { return false; } // lagre ny data $data_sql = \Kofradia\DB::quote(serialize($data)); \Kofradia\DB::get()->exec("INSERT INTO settings SET name = 'wordpress_data', value = {$data_sql} ON DUPLICATE KEY UPDATE value = {$data_sql}"); // sjekk for ny data self::check_new($data); // last inn settings på nytt require PATH_APP . "/scripts/update_db_settings.php"; }
public function __construct() { ess::$b->page->add_title("Meldinger", "Ny melding"); // maks antall mottakere $this->receivers_limit = access::has("forum_mod") ? 9 : 4; // opprette melding? if (isset($_POST['message'])) { $this->create(); } elseif (isset($_GET['mottaker'])) { $result = \Kofradia\DB::get()->query("\n\t\t\t\tSELECT up_id, up_name, up_access_level\n\t\t\t\tFROM users_players\n\t\t\t\tWHERE up_name = " . \Kofradia\DB::quote($_GET['mottaker']) . "\n\t\t\t\tORDER BY up_access_level = 0, up_last_online DESC\n\t\t\t\tLIMIT 1"); while ($row = $result->fetch()) { $this->receivers[] = $row; } } // vis skjema $this->show(); }
/** * Handle notify URLs from PayPal */ public function action_notify() { file_put_contents(PATH_ROOT . "/paypal.log", print_r($_POST, true), FILE_APPEND); // TODO: remove this when tested on production if (!isset($_POST['receiver_email']) || $_POST['receiver_email'] != '*****@*****.**') { die; } // should really check for duplicates, but we don't // but it must be "completed" if (!isset($_POST['payment_status']) || $_POST['payment_status'] != 'Completed') { die; } // verify it $verify = Donation::verifyPayPalData($_POST); if (!$verify) { die; } // check for user etc $custom = postval("custom"); if (!preg_match('~^(.*):(.*);public=(0|1)$~', $custom, $matches)) { die; } trigger_error("should add"); $player = null; if ($matches[1] != "gjest") { // find this player $result = DB::get()->query("\n\t\t\t\tSELECT up_id\n\t\t\t\tFROM users_players\n\t\t\t\t\tLEFT JOIN users ON up_u_id = u_id\n\t\t\t\t\tLEFT JOIN sessions ON u_id = ses_u_id\n\t\t\t\tWHERE ses_id = " . DB::quote($matches[1]) . " AND up_id = " . DB::quote($matches[2]) . " LIMIT 1"); if ($up_id = $result->fetchColumn(0)) { $player = \player::get($up_id); } } $time = \ess::$b->date->parse(postval("payment_date")); // add it $d = Donation::create(postval("mc_gross"), $time, $matches[3] ? $player->id : null); putlog("CREWCHAN", sprintf("%%uDONASJON:%%u %s %s ble donert av %s", postval("mc_currency"), postval("mc_gross"), $player ? $player->data['up_name'] . ($matches[3] ? ' (synlig)' : ' (som anonym)') : 'anonym gjest')); // no output die; }
$aktive[] = "-"; } } // finnes feltet? if (isset($wpFelt[$name]) && !in_array($name, $aktive)) { $aktive[] = $name; } } // er siste en seperator? if (end($aktive) == "-") { array_pop($aktive); } // lagre $wp->params->update("fields", implode(",", $aktive)); $data = $wp->params->build(); \Kofradia\DB::get()->exec("UPDATE stats_whatpulse SET sw_params = " . \Kofradia\DB::quote($data) . " WHERE sw_up_id = " . $player->id); $_base->page->add_message("WhatPulse informasjonen ble oppdatert. Sjekk profilen din!"); } redirect::handle(); } // javascript $_base->page->add_js(' function wpHentFelt(form) { var elms = []; var op = form.wpAktiveFelt.options; for (var i = 0; i < op.length; i++) { elms.push(op[i].value); }
} $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 putlog("LOG", "%c3%bFINN-SPILLER:%b%c %u" . login::$user->player->data['up_name'] . "%u søkte etter %u{$q}%u!"); // xml $data = '<userlist query="' . htmlspecialchars($q) . '" limit="' . $limit . '" results="' . $num . '">'; while ($row = $result->fetch()) { $data .= '<user up_id="' . $row['up_id'] . '" up_name="' . htmlspecialchars($row['up_name']) . '">' . htmlspecialchars(game::profile_link($row['up_id'], $row['up_name'], $row['up_access_level'])) . '</user>'; } $data .= '</userlist>'; ajax::xml($data);
/** * Generer bilder */ public function generate_images($first = NULL) { // slett gamle bilder \Kofradia\DB::get()->exec("DELETE FROM users_antibot_validate WHERE antibotid = {$this->data['id']}"); // lås anti-boten \Kofradia\DB::get()->beginTransaction(); \Kofradia\DB::get()->query("SELECT id FROM users_antibot WHERE id = {$this->data['id']} FOR UPDATE")->closeCursor(); // har noen bilder nå? $result = \Kofradia\DB::get()->query("SELECT COUNT(*) FROM users_antibot_validate WHERE antibotid = {$this->data['id']}"); if ($result->fetchColumn(0) > 0) { \Kofradia\DB::get()->commit(); return $this->get_images(); } $images = array("data" => array(), "info" => array(), "valid" => 0); // generer bildene $data = antibot_generate::image_create_all(2, 6); $time = time(); // opprett bildene og putt i databasen foreach ($data as $key => $image) { $imgnum = $key + 1; // legg til i databasen $valid = $image['valid'] ? '1' : '0'; \Kofradia\DB::get()->exec("INSERT INTO users_antibot_validate SET antibotid = {$this->data['id']}, imgnum = {$imgnum}, valid = {$valid}, time = {$time}, data = " . \Kofradia\DB::quote($image['data'])); // legg til i $antibot $images['info'][$imgnum] = array("time" => $time, "valid" => $valid); $images['data'][$imgnum] = $image['data']; if ($valid) { $images['valid']++; } } // avslutt lås \Kofradia\DB::get()->commit(); return $images; }
} break; case "text": // ingen endringer break; } $fields[$key] = $value; } } // slett gamle felt \Kofradia\DB::get()->beginTransaction(); \Kofradia\DB::get()->exec("DELETE FROM soknader_applicants_felt WHERE saf_sa_id = {$applicant['sa_id']}"); \Kofradia\DB::get()->exec("UPDATE soknader_applicants SET sa_updated = " . time() . " WHERE sa_id = {$applicant['sa_id']}"); // legg til nye felt foreach ($fields as $key => $value) { \Kofradia\DB::get()->exec("INSERT INTO soknader_applicants_felt SET saf_sa_id = {$applicant['sa_id']}, saf_sf_id = {$key}, saf_value = " . \Kofradia\DB::quote($value)); } // kun lagre? if (isset($_POST['lagre'])) { $_base->page->add_message("Endringene ble lagret."); \Kofradia\DB::get()->commit(); redirect::handle(); } elseif (isset($_POST['preview'])) { $_base->page->add_message("Endringene ble lagret."); \Kofradia\DB::get()->commit(); redirect::handle("soknader_vis?so_id={$soknad['so_id']}&preview"); } else { // feil? if (count($errors) > 0) { $_base->page->add_message("Kan ikke sende inn søknad fordi noen felt ikke er korrekt utfylt. Se feltene. Endringene ble lagret.", "error"); \Kofradia\DB::get()->commit();
/** Lagre params til cellen */ public function commit($free = true) { // ikke låst? if (!$this->locked) { throw new HSException("params_update->commit: Cannot commit unlocked row."); } // ingen endringer? if (!$this->changed_state) { if ($free) { \Kofradia\DB::get()->commit(); $this->locked = false; } return; } // oppdater databasen \Kofradia\DB::get()->exec("UPDATE {$this->link_table} SET {$this->link_column} = " . \Kofradia\DB::quote($this->build()) . " WHERE {$this->link_where} LIMIT 1"); $this->changed_state = false; // frigjøre? if ($free) { \Kofradia\DB::get()->commit(); $this->locked = false; } }
error("Ugyldig ff ID."); } require "../../app/essentials.php"; global $_base; // sørg for at den ikke cacher header("Expires: Mon, 18 Jul 2005 00:00:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 // skal vi vise en gammel logo? if (isset($_GET['log_id'])) { // finn logg info $log_id = \Kofradia\DB::quote($_GET['log_id']); $result = \Kofradia\DB::get()->query("SELECT ffl_extra FROM ff_log WHERE ffl_id = {$log_id} AND ffl_ff_id = {$ff_id} AND ffl_type = 12"); if ($result->rowCount() == 0) { error("Fant ikke logg enheten."); } $data = $result->fetchColumn(0); if (empty($data)) { error("Gammel logo finnes ikke."); } $data = base64_decode($data); // vis logoen header("Content-Type: image/png"); header("X-Script-Time: " . round(microtime(true) - SCRIPT_START, 4)); echo $data; die; }
/** * Lagre status * * @param integer $o_id * @param object params $params */ public function update_status($o_id, $params) { $o_id = (int) $o_id; $data = $params->build(); // oppdater lokalt if (isset($this->oppdrag[$o_id])) { $this->oppdrag[$o_id]['uo_params'] = $data; if (isset($this->params[$o_id])) { $this->params[$o_id]['uo_params'] = $params; } } // oppdater databasen \Kofradia\DB::get()->exec("UPDATE users_oppdrag SET uo_params = " . \Kofradia\DB::quote($data) . " WHERE uo_up_id = {$this->up->id} AND uo_o_id = {$o_id}"); // oppdater triggers $this->link_triggers(); }
/** Hent ut data for brukeren og sørg for at den er oppdatert */ public function update($data = NULL, $force_update = NULL) { global $_base; // hente data lokalt? if ($data === NULL && $this->data) { $data = $this->data['sw_xml']; } // forsøk å lese data $xml = $this->read_xml($data); $update = $force_update !== false; // sjekk om data ikke skal oppdateres if ($xml && $force_update === NULL) { $last_real_update = $_base->date->parse($xml->GeneratedTime)->format("U"); // gått mindre enn en time? if ($last_real_update > time() - 3600) { // ikke oppdater data $update = false; } } // oppdatere data? if ($update) { $data = $this->get_xml(); $xml_update = $this->read_xml($data); // gyldig? if ($xml_update) { $xml = $xml_update; // lagre data \Kofradia\DB::get()->exec("UPDATE stats_whatpulse SET sw_time_update = " . time() . ", sw_xml = " . \Kofradia\DB::quote($data) . " WHERE sw_userid = {$this->user_id}"); } } $this->xml = $xml; return (bool) $xml; }
/** * Redigere en oppføring */ protected function handle_specific_edit($lc, $lc_action, $data) { ess::$b->page->add_title("Redigering av oppføring: {$lc['lc_id']} (" . htmlspecialchars($lc_action[4]) . ")"); // behandle ulike type oppføringer switch (crewlog::$actions_id[$lc['lc_lca_id']]) { // advarsel case "user_warning": $invalidated = !empty($data['invalidated']); if (!$invalidated) { // slette? if (isset($_POST['revoke'])) { // legg til logg $d = array("lc_id" => $lc['lc_id'], "type" => $data['type'], "priority" => $data['priority']); crewlog::log("user_warning_invalidated", $lc['lc_a_up_id'], null, $d); // marker som slettet \Kofradia\DB::get()->exec("\n\t\t\t\t\t\t\tINSERT INTO log_crew_data\n\t\t\t\t\t\t\tSET lcd_lc_id = {$lc['lc_id']}, lcd_lce_id = 5, lcd_lca_id = {$lc['lc_lca_id']}, lcd_data_int = 1\n\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE lcd_data_int = 1"); // har vi en hendelse vi kan slette? if (!empty($data['notified_id'])) { \Kofradia\DB::get()->exec("DELETE FROM users_log WHERE id = {$data['notified_id']}"); } ess::$b->page->add_message("Advarselen ble markert som ugyldig."); redirect::handle("crewlogg?lc_id={$lc['lc_id']}"); } // redigere? if (isset($_POST['edit'])) { $types = crewlog::$user_warning_types; $log = trim(postval("log")); $note = trim(postval("note")); $type = postval("type"); $priority = (int) postval("priority"); if (empty($log) || empty($note)) { ess::$b->page->add_message("Både begrunnelse og intern informasjon må fylles ut.", "error"); } elseif (!isset($types[$type])) { ess::$b->page->add_message("Ugyldig kategori.", "error"); } elseif ($priority < 1 || $priority > 3) { ess::$b->page->add_message("Ugylig alvorlighet.", "error"); } elseif ($priority == $data['priority'] && $log == $lc['lc_log'] && $note == $data['note'] && $types[$type] == $data['type']) { ess::$b->page->add_message("Ingenting ble endret.", "error"); } else { $d = array("lc_id" => $lc['lc_id']); $d['priority_new'] = $priority; if ($priority != $data['priority']) { $d['priority_old'] = $data['priority']; } $d['type_new'] = $types[$type]; if ($types[$type] != $data['type']) { $d['type_old'] = $data['type']; } if ($log != $lc['lc_log']) { $d['log_old'] = $lc['lc_log']; $d['log_new'] = $log; } if ($note != $data['note']) { $d['note_old'] = $data['note']; $d['note_new'] = $note; } // legg til at advarselen er redigert crewlog::log("user_warning_edit", $lc['lc_a_up_id'], null, $d); // oppdater crewloggen \Kofradia\DB::get()->exec("UPDATE log_crew SET lc_log = " . \Kofradia\DB::quote($log) . " WHERE lc_id = {$lc['lc_id']}"); \Kofradia\DB::get()->exec("UPDATE log_crew_data SET lcd_data_int = {$priority} WHERE lcd_lc_id = {$lc['lc_id']} AND lcd_lce_id = 3"); \Kofradia\DB::get()->exec("UPDATE log_crew_data SET lcd_data_text = " . \Kofradia\DB::quote($types[$type]) . " WHERE lcd_lc_id = {$lc['lc_id']} AND lcd_lce_id = 1"); \Kofradia\DB::get()->exec("UPDATE log_crew_data SET lcd_data_text = " . \Kofradia\DB::quote($note) . " WHERE lcd_lc_id = {$lc['lc_id']} AND lcd_lce_id = 2"); // har vi en hendelse vi kan oppdatere? if (!empty($data['notified_id'])) { \Kofradia\DB::get()->exec("UPDATE users_log SET note = " . \Kofradia\DB::quote(urlencode($types[$type]) . ":" . urlencode($log)) . " WHERE id = {$data['notified_id']}"); } ess::$b->page->add_message("Advarselen ble redigert."); redirect::handle("crewlogg?lc_id={$lc['lc_id']}"); } } } echo ' <div class="bg1_c small"> <h1 class="bg1">Rediger advarsel<span class="left2"></span><span class="right2"></span></h1> <p class="h_left"><a href="crewlogg?lc_id=' . $lc['lc_id'] . '">« Tilbake</a></p> <div class="bg1"> <dl class="dd_right"> <dt>Logg ID</dt> <dd>' . $lc['lc_id'] . '</dd> <dt>Handling</dt> <dd>' . htmlspecialchars(crewlog::$actions_groups[$lc_action[1]]) . ': ' . htmlspecialchars($lc_action[4]) . '</dd> <dt>Utført av</dt> <dd><user id="' . $lc['lc_up_id'] . '" /></dd>' . ($lc['lc_a_up_id'] ? ' <dt>Påvirket spiller</dt> <dd><user id="' . $lc['lc_a_up_id'] . '" /></dd>' : '') . ' <dt>Tidspunkt</dt> <dd>' . ess::$b->date->get($lc['lc_time'])->format(date::FORMAT_SEC) . '</dd> </dl> <dl class="dd_right"> <dt>Kategori</dt> <dd>' . $data['type'] . '</dd> <dt>Prioritet</dt> <dd>' . ($data['priority'] == 1 ? 'Lav' : ($data['priority'] == 3 ? 'Høy' : 'Moderator')) . '</dd> <dt>Varslet?</dt> <dd>' . (empty($data['notified']) ? 'Brukeren ble ikke varslet' : 'Brukeren ble varslet med logg') . '</dd>' . ($invalidated ? ' <dt>Ugyldig</dt> <dd><b>Advarselen er trukket tilbake</b></dd>' : '') . ' </dl> <p>Begrunnelse:</p> <div class="crewlog_note">' . game::format_data($lc['lc_log']) . '</div> <p>Intern informasjon:</p> <div class="crewlog_note">' . game::format_data($data['note']) . '</div>'; if ($invalidated) { echo ' <p>Denne advarselen er trukket tilbake og kan ikke redigeres.</p>'; } else { echo ' <form action="" method="post"> <div class="hr"></div> <p><b>Rediger advarsel:</b></p> <dl class="dd_right"> <dt>Kategori</dt> <dd> <select name="type">'; $type = array_search($data['type'], crewlog::$user_warning_types); if (isset($_POST['type']) && isset($types[$_POST['type']])) { $type = (int) $_POST['type']; } if ($type === false) { echo ' <option value="">Velg ..</option>'; } foreach (crewlog::$user_warning_types as $key => $row) { echo ' <option value="' . $key . '"' . ($key === $type ? ' selected="selected"' : '') . '>' . htmlspecialchars($row) . '</option>'; } echo ' </select> </dd> <dt>Alvorlighet/prioritet</dt> <dd> <select name="priority">'; $priority = isset($_POST['priority']) && is_numeric($_POST['priority']) && $_POST['priority'] >= 1 && $_POST['priority'] <= 3 ? $_POST['priority'] : $data['priority']; echo ' <option value="1"' . ($priority == 1 ? ' selected="selected"' : '') . '>Lav</option> <option value="2"' . ($priority == 2 ? ' selected="selected"' : '') . '>Moderat</option> <option value="3"' . ($priority == 3 ? ' selected="selected"' : '') . '>Høy</option> </select> </dd> </dl> <p>Begrunnelse:</p> <p><textarea name="log" rows="10" cols="30" style="width: 98%">' . htmlspecialchars(postval("log", $lc['lc_log'])) . '</textarea></p> <p>Intern informasjon:</p> <p><textarea name="note" rows="10" cols="30" style="width: 98%">' . htmlspecialchars(postval("note", $data['note'])) . '</textarea></p> <p class="c">' . show_sbutton("Oppdater advarsel", 'name="edit"') . '</p> </form> <form action="" method="post"> <p class="c">' . show_sbutton("Trekk tilbake advarsel", 'name="revoke" onclick="return confirm(\'Er du sikker på at du ønsker å trekke tilbake denne advarselen?\')"') . '</p> </form>'; } echo ' </div> </div>'; break; // ukjent // ukjent default: ess::$b->page->add_message("Kan ikke redigere denne oppføringen.", "error"); redirect::handle("crewlogg?lc_id={$lc['lc_id']}"); } ess::$b->page->load(); }
<tr' . (++$i % 2 == 0 ? ' class="color"' : '') . '> <td>' . game::profile_link($row['up_id'], $row['up_name'], $row['up_access_level']) . '</td> <td>' . htmlspecialchars($row['u_email']) . '</td> <td>' . $_base->date->get($row['up_last_online'])->format(date::FORMAT_SEC) . '</td> <td><form action="" method="post"><input type="hidden" name="up_id" value="' . $row['up_id'] . '" />' . show_sbutton("Velg") . '</form></td> </tr>'; } echo ' </tbody> </table>'; } echo box_end(); } if (isset($_POST['user']) && isset($_POST['value'])) { // finn brukeren med dette spillernavnet $result = \Kofradia\DB::get()->query("SELECT up_id, up_name, u_email, up_access_level, up_last_online FROM users, users_players WHERE up_name = " . \Kofradia\DB::quote($_POST['value']) . " AND up_u_id = u_id"); echo box_start("Registrer donasjon - Søk etter spiller", "small") . ' <p>Søk (spiller): ' . htmlspecialchars($_POST['value']) . '</p>'; if ($result->rowCount() == 0) { echo ' <p>Fant ingen spillere.</p>'; } else { echo ' <table class="table tablemb"> <thead> <tr> <th>Bruker</th> <th>E-post</th> <th>Sist pålogget</th> <th> </th> </tr>
function step4() { global $__server, $_game; // er skjemaet sendt inn? if ($_SERVER['REQUEST_METHOD'] == "POST") { // sjekk for gyldig trinn if (!isset($_POST['step']) || $_POST['step'] != 4) { redirect::handle(); } // betingelser, alder, forste_bruker $betingelser = isset($_POST['betingelser']); $alder = isset($_POST['alder']); $forste_bruker = isset($_POST['forste_bruker']); // er ikke betingelsene godtatt? if (!$betingelser) { ess::$b->page->add_message("Hvis du ikke godtar betingelsene kan du dessverre ikke registrere deg her.", "error"); } elseif (!$alder) { ess::$b->page->add_message("Hvis du ikke har fylt 13 år kan du dessverre ikke registrere deg her.", "error"); } elseif (!$forste_bruker) { ess::$b->page->add_message("Hvis du allerede har en bruker fra før så bruk den! Å opprette ny konto gjør det bare dumt for deg selv og kan i værste tilfelle føre til politianmeldelse.", "error"); } else { // finn en tilfeldig bydel $result = \Kofradia\DB::get()->query("SELECT id FROM bydeler WHERE active = 1 ORDER BY RAND()"); $bydel = $result->fetchColumn(0); // sett opp nødvendig info $user = \Kofradia\DB::quote($this->info['user']); $pass = \Kofradia\DB::quote($this->info['pass']); $email = \Kofradia\DB::quote($this->info['email']); $referer = \Kofradia\DB::quote($this->info['referer']); $tos_version = intval(game::$settings['tos_version']['value']); $birth = \Kofradia\DB::quote($this->info['birth']); $recruiter = array("up_id" => 'NULL', "up_u_id" => 'NULL'); global $__server; // er denne brukeren vervet? if (isset($_COOKIE[$__server['cookie_prefix'] . "rid"])) { $rid = $_COOKIE[$__server['cookie_prefix'] . "rid"]; // finnes denne brukeren? $result = \Kofradia\DB::get()->query("SELECT up_id, up_u_id FROM users_players WHERE up_id = " . \Kofradia\DB::quote($rid)); if ($row = $result->fetch()) { $recruiter = $row; } } \Kofradia\DB::get()->beginTransaction(); // deaktiver kontroll av foreign key \Kofradia\DB::get()->exec("SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0"); // opprett bruker $time = time(); \Kofradia\DB::get()->exec("INSERT INTO users SET u_email = {$email}, u_pass = {$pass}, u_birth = {$birth}, u_tos_version = {$tos_version}, u_created_time = {$time}, u_created_ip = " . \Kofradia\DB::quote($_SERVER['REMOTE_ADDR']) . ", u_created_referer = {$referer}, u_recruiter_u_id = {$recruiter['up_u_id']}, u_recruiter_points_last = 0"); $u_id = \Kofradia\DB::get()->lastInsertId(); // opprett spiller og tilknytt brukeren \Kofradia\DB::get()->exec("INSERT INTO users_players SET up_u_id = {$u_id}, up_name = {$user}, up_created_time = {$time}, up_recruiter_up_id = {$recruiter['up_id']}, up_b_id = {$bydel}"); $up_id = \Kofradia\DB::get()->lastInsertId(); \Kofradia\DB::get()->exec("UPDATE users SET u_active_up_id = {$up_id} WHERE u_id = {$u_id}"); // aktiver kontroll av foreign key \Kofradia\DB::get()->exec("SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS"); // sett opp riktig rank plassering #\Kofradia\DB::get()->exec("UPDATE users_players AS main, (SELECT COUNT(users_players.up_id)+1 AS pos, ref.up_id FROM users_players AS ref LEFT JOIN users_players ON users_players.up_points > ref.up_points AND users_players.up_access_level < {$_game['access_noplay']} AND users_players.up_access_level != 0 WHERE ref.up_id = $up_id GROUP BY ref.up_id) AS rp SET main.up_rank_pos = rp.pos WHERE main.up_id = rp.up_id"); \Kofradia\DB::get()->exec("INSERT INTO users_players_rank SET upr_up_id = {$up_id}"); ranklist::update(); // slett registrasjonsoppføringen \Kofradia\DB::get()->exec("DELETE FROM registration WHERE id = {$this->id}"); \Kofradia\DB::get()->commit(); // send e-post $email = new email(); $email->text = 'Hei, Du har registrert deg som ' . $this->info['user'] . ' på Kofradia. Velkommen til spillet! -- www.kofradia.no'; $email->headers['X-SMafia-IP'] = $_SERVER['REMOTE_ADDR']; $email->headers['Reply-To'] = "*****@*****.**"; $email->send($this->info['email'], "Velkommen til Kofradia"); ess::$b->page->add_message('Velkommen til Kofradia!<br /><br />Du er nå registrert som <b>' . $this->info['user'] . '</b> og automatisk logget inn.<br /><br />Sjekk ut menyen til venstre så ser du hva vi har å tilby i dag.<br /><br />Hvis du har noen spørsmål ta en titt under <a href="' . ess::$s['relative_path'] . '/node">hjelp</a> og ta evt. kontakt med <a href="support/">support</a> om du ikke finner svar på det du lurer på!<br /><br />Ikke glem og les gjennom <a href="' . ess::$s['relative_path'] . '/node/6">reglene for forumene</a> før du skriver i forumet. Lykke til i spillet!'); // hent antall medlemmer $result = \Kofradia\DB::get()->query("SELECT COUNT(up_id) FROM users_players WHERE up_access_level < {$_game['access_noplay']} AND up_access_level != 0"); putlog("INFO", "%bNY SPILLER:%b (#{$up_id} - Nummer %b" . $result->fetchColumn(0) . "%b) %u{$this->info['user']}%u registrerte seg! {$__server['absolute_path']}{$__server['relative_path']}/p/" . rawurlencode($this->info['user'])); // logg inn brukeren login::do_login($u_id, $this->info['pass'], LOGIN_TYPE_TIMEOUT, false); // slett registrasjonsoppføringen fra session etc $this->trash(); // sjekk om det er mulig multi $result = \Kofradia\DB::get()->query("\n\t\t\t\t\tSELECT up_name\n\t\t\t\t\tFROM users_players, users\n\t\t\t\t\tWHERE u_online_ip = " . \Kofradia\DB::quote($_SERVER['REMOTE_ADDR']) . "\n\t\t\t\t\t\tAND u_id != {$u_id}\n\t\t\t\t\t\tAND u_active_up_id = up_id AND up_access_level != 0\n\t\t\t\t\t\tAND up_last_online > " . (time() - 86400 * 30) . "\n\t\t\t\t\tLIMIT 10"); if ($result->rowCount() > 0) { $names = array(); while ($row = $result->fetch()) { $names[] = $row['up_name']; } putlog("CREWCHAN", "%b%c4NY REGISTERT, MULIG MULTI:%c%b (#{$up_id}) %u{$this->info['user']}%u registrerte seg. Andre spillere på IP-en: " . implode(", ", $names) . ". {$__server['path']}/admin/brukere/finn?ip=" . rawurlencode($_SERVER['REMOTE_ADDR'])); } // videresend til hovedsiden redirect::handle("", redirect::ROOT); } } echo ' <form action="registrer" method="post"> <input type="hidden" name="abort" /> <h1>Bekreftelse av betingelsene</h1> <p class="h_right">' . show_sbutton("Avbryt registrering", 'onclick="return confirm(\'Er du sikker på at du vil AVBRYTE?\')"') . '</p> </form> <p> På denne siden finner du en oversikt over betingelsene. Betingelsene er ikke lange og er kjapt å lese igjennom. Det er viktig at du er klar over innholdet i disse betingelsene og at du følger dem. Følger du ikke disse betingelsene vil brukeren din bli deaktivert. For å kunne opprette må du godta betingelsene. </p> <boxes /> <form action="registrer" method="post"> <input type="hidden" name="step" value="4" /> <p> Betingelser:<br /> <div id="betingelser_content">' . game::$settings['tos']['value'] . '</div> </p> <p> <input type="checkbox" name="betingelser" id="betingelser" /><label for="betingelser"> Jeg har lest gjennom og aksepterer betingelsene</label> </p> <p> <input type="checkbox" name="alder" id="alder" /><label for="alder"> Jeg har fylt 13 år</label> </p> <p> <input type="checkbox" name="forste_bruker" id="forste_bruker" /><label for="forste_bruker"> Jeg har ingen bruker som er aktivert fra før av</label> <span class="dark">(Hvis du allerede har en bruker, må du deaktivere den <u>før</u> du registrerer deg på nytt.)</span> </p> <p> ' . show_sbutton("Opprett bruker") . ' </p> </form> <form action="registrer" method="post"> <input type="hidden" name="abort" /> <p> ' . show_sbutton("Avbryt registrering", 'onclick="return confirm(\'Er du sikker på at du vil AVBRYTE?\')"') . ' </p> </form>'; }
/** * Opprett auksjon for FF */ public static function create_auksjon_ff(ff $ff, $start = null, $end = null) { $time = time(); if (!$start) { $start = $time; } else { $start = (int) $start; } if (!$end) { // varighet er til 21:00 med minimum 12 timer $date = ess::$b->date->get(); $date->setTime(21, 0, 0); $min_time = 3600 * 12; if ($date->format("U") < $time + $min_time) { $date->modify("+1 day"); } $expire = $date->format("U"); } else { $expire = (int) $end; } // sett opp params for ff_id $params = new params(); $params->update("ff_id", $ff->id); // opprett auksjonen \Kofradia\DB::get()->exec("INSERT INTO auksjoner SET a_type = " . self::TYPE_FIRMA . ", a_title = " . \Kofradia\DB::quote($ff->data['ff_name']) . ", a_start = {$start}, a_end = {$expire}, a_bid_start = 1000000, a_bid_jump = 500000, a_active = 1, a_params = " . \Kofradia\DB::quote($params->build())); $a_id = \Kofradia\DB::get()->lastInsertId(); // logg putlog("INFO", "%bAUKSJON:%b Auksjon for %u" . $ff->data['ff_name'] . "%u ble opprettet " . ess::$s['spath'] . "/auksjoner?a_id={$a_id}"); // live-feed livefeed::add_row('<a href="' . ess::$s['rpath'] . '/auksjoner?a_id=' . $a_id . '">Auksjon</a> for <a href="' . ess::$s['rpath'] . '/ff/?ff_id=' . $ff->id . '">' . htmlspecialchars($ff->data['ff_name']) . '</a> ble opprettet.'); self::update_cache(); }
/** * Behandle nytt passord */ protected function solve_pass() { // lagre passord if (isset($_POST['save_pass'])) { // kontroller alle feltene $pass_new = trim(postval("pass_new")); $pass_repeat = trim(postval("pass_repeat")); // kontroller at alle feltene er fylt ut if ($pass_new == "" || $pass_repeat == "") { ess::$b->page->add_message("Alle feltene må fylles ut.", "error"); } elseif ($pass_new != $pass_repeat) { ess::$b->page->add_message("De nye passordene var ikke like.", "error"); } elseif (mb_strlen($pass_new) < 6) { ess::$b->page->add_message("Det nye passordet må inneholde minimum 6 tegn.", "error"); } elseif (password::validate($pass_new, password::LEVEL_LOGIN) != 0) { ess::$b->page->add_message("Du må velge et vanskeligere passord.", "error"); } elseif (password::verify_hash($pass_new, login::$user->data['u_bank_auth'], 'bank_auth')) { ess::$b->page->add_message("Velg et annet passord enn du har i banken."); } else { \Kofradia\DB::get()->exec("UPDATE users SET u_pass = "******", u_pass_change = NULL WHERE u_id = " . login::$user->id); // melding ess::$b->page->add_message("Du har nå lagret et nytt passord for brukeren din."); putlog("NOTICE", "%bPASSORD%b: %u" . login::$user->player->data['up_name'] . "%u lagret nytt passord på sin bruker (var nullstilt). " . ess::$s['path'] . "/min_side?u_id=" . login::$user->id); // send ut e-post for å informere $email = new email(); $email->text = 'Hei, Det er nå blitt opprettet et nytt passord fra ' . $_SERVER['REMOTE_ADDR'] . ' (' . $_SERVER['HTTP_USER_AGENT'] . '). Bruker ID: ' . login::$user->data['u_id'] . ' E-post: ' . login::$user->data['u_email'] . ' Vi sender selvfølgelig ikke ditt nye passord på e-post. Det skal du kunne selv! -- www.kofradia.no'; $email->send(login::$user->data['u_email'], "Nytt passord"); // logg ut alle andre brukere \Kofradia\DB::get()->exec("UPDATE sessions SET ses_active = 0, ses_logout_time = " . time() . " WHERE ses_active = 1 AND ses_u_id = " . login::$user->id . " AND ses_id != " . login::$info['ses_id']); redirect::handle(); } } ess::$b->page->add_js_domready('$("lockpass").focus();'); echo ' <div class="bg1_c small"> <h1 class="bg1">Lagre nytt passord<span class="left"></span><span class="right"></span></h1> <p class="h_left"><a href="' . htmlspecialchars($this->url) . '">Tilbake</a></p> <div class="bg1"> <p>Ditt passord har blitt nullstilt. Du vil ikke kunne logge inn uten å måtte benytte <i>glemt passord</i> funksjonen før du har opprettet et nytt passord.</p> <form action="" method="post" autocomplete="off"> <dl class="dd_right dl_2x center" style="width: 80%"> <dt>Nytt passord</dt> <dd><input type="password" class="styled w100" name="pass_new" id="lockpass" /></dd> <dt>Gjenta nytt passord</dt> <dd><input type="password" class="styled w100" name="pass_repeat" /></dd> </dl> <p class="c">' . show_sbutton("Lagre passordet", 'name="save_pass"') . '</p> </form> </div> </div>'; }
if (isset($_GET['sa_id'])) { // hent søknaden $sa_id = intval(getval("sa_id")); $result = \Kofradia\DB::get()->query("SELECT sa_id, sa_up_id, sa_added, sa_status, IF(sa_updated=0, sa_added, sa_updated) AS sa_updated, sa_comment, sa_weight, sa_verified, sa_verified_up_id FROM soknader_applicants WHERE sa_id = {$sa_id} AND sa_so_id = {$soknad['so_id']}"); $applicant = $result->fetch(); if (!$applicant) { $_base->page->add_message("Fant ikke søknaden.", "error"); redirect::handle(); } redirect::store("soknader?admin&so_id={$soknad['so_id']}&sa_id={$applicant['sa_id']}"); $_base->page->add_title("Søknad #{$applicant['sa_id']}"); // lagre rating og kommentar? if (isset($_POST['rating']) && isset($_POST['comment'])) { $rating = intval(postval("rating")); $comment = trim(postval("comment")); \Kofradia\DB::get()->exec("UPDATE soknader_applicants SET sa_weight = {$rating}, sa_comment = " . \Kofradia\DB::quote($comment) . ", sa_verified = " . time() . ", sa_verified_up_id = " . login::$user->player->id . " WHERE sa_id = {$applicant['sa_id']}"); $_base->page->add_message("Informasjonen ble lagret."); redirect::handle(); } $result = \Kofradia\DB::get()->query("SELECT saf_sf_id, saf_value FROM soknader_applicants_felt WHERE saf_sa_id = {$applicant['sa_id']}"); $applicant_felt = array(); while ($row = $result->fetch()) { $applicant_felt[$row['saf_sf_id']] = $row['saf_value']; } echo ' <h2 class="bg1" style="margin-top: 20px" id="scroll_here">Søknad #' . $applicant['sa_id'] . '<span class="left2"></span><span class="right2"></span></h2> <p class="h_left"><a href="soknader?admin&so_id=' . $soknad['so_id'] . '">« Tilbake</a></p> <div class="bg1"> <boxes />'; if ($applicant['sa_status'] == 0) { echo '
/** * Internt: Legg til en rapportering * @param int $up_id * @param int $type * @param int $type_id * @param string $message * @return int r_id */ private static function add($up_id, $type, $type_id, $message) { global $__server; // sørg for at brukeren er logget inn if (!login::$logged_in) { throw new HSException("Brukeren er ikke logget inn."); } // samle sammen data $source_up_id = intval(login::$user->player->id); $up_id = intval($up_id); $type = intval($type); $type_id = intval($type_id); $message = \Kofradia\DB::quote($message); // legg til \Kofradia\DB::get()->exec("INSERT INTO rapportering SET r_source_up_id = {$source_up_id}, r_up_id = {$up_id}, r_type = {$type}, r_type_id = {$type_id}, r_time = " . time() . ", r_note = {$message}"); $id = \Kofradia\DB::get()->lastInsertId(); // melding på IRC putlog("CREWCHAN", "%bNY RAPPORTERING:%b {$__server['path']}/crew/rapportering"); // øk rapporteringstelleren tasks::increment("rapporteringer"); // returner iden return $id; }
function handle_data($cid, $line) { global $_base; $this->debug($cid, "Handling data: {$line}"); if (!isset($this->sockets[$cid])) { $this->debug($cid, "Socket not found. Aborting data check."); return; } #$this->debug($cid, "Data received: " . $line); $matches = false; if (preg_match('/^:([^ ]+)\\s+(.+?)\\s+(.+?)(?:\\s+:(.+?))?\\r?$/s', $line, $matches)) { $from = $matches[1]; $type = $matches[2]; $arg = $matches[3]; $content = isset($matches[4]) ? $matches[4] : ''; $user = $this->nickinfo($from); switch ($type) { // nick i bruk case "433": $this->handle_error($cid, "Nick is in use.."); return; // motd innhold // motd innhold case "372": $this->debug($cid, "MOTD: " . $content); break; // motd mangler // motd mangler case "422": #$this->debug($cid, "MOTD mangler"); #$this->debug($cid, "MOTD mangler"); case "376": $this->debug($cid, "MOTD avsluttet"); // sette som den aktive? if (!$this->connected_cid) { $this->connected_cid = $cid; } // join kanaler foreach ($this->settings['channels'] as $chan) { $args = isset($chan[1]) ? " :" . $chan[1] : ""; $this->send_data($cid, "JOIN {$chan[0]}{$args}\n"); } // oper if ($this->settings['name'] == "SMAFIA" || $this->settings['name'] == "SMAFIA_BETA") { $this->send_data($cid, "OPER SMAFIA StreetzMafiaBoten\n"); } // merk som klar for timers $this->connected = true; break; // invitasjon // invitasjon case "INVITE": $chan = explode(" ", $arg); if ($chan != "#StreetzMafia" && $chan != "#kofradia") { break; } $this->send_data($cid, "JOIN {$chan[1]}\n"); break; // meldinger // meldinger case "PRIVMSG": case "NOTICE": if (($this->settings['name'] == "SMAFIA" || $this->settings['name'] == "SMAFIA_BETA") && $this->irc_info || $this->settings['name'] == "QuakeNet" && $user["nick"] == "henrist" && $user["ident"] == "henrik" && $user["host"] == "hsw.no") { $match = false; $log = true; $break = false; if (substr($content, 0, 3) == ".r ") { $this->send_data($cid, "NOTICE {$user['nick']} :Sending raw data..\n"); $this->send_data($cid, substr($content, 3) . "\n"); $break = true; } elseif ($content == ".vars") { $this->msg($cid, $arg, "Kofradia Announcer - Loglimit: {$this->loglimit} - Skiptime: " . game::format_number($this->select_delay / 1000, 1) . " ms - Log delay: " . game::format_number($this->timers["CHECKLOG"][1] * 1000) . " ms"); } elseif ($content == ".queue") { $w = $this->settings['name'] == "SMAFIA_BETA" ? '1' : " li_network = " . \Kofradia\DB::quote($this->settings['name']); $result = \Kofradia\DB::get()->query("SELECT COUNT(*) FROM log_irc WHERE {$w}"); $ant = $result->fetchColumn(0); unset($result); $this->msg($cid, $arg, "Message queue: " . game::format_number($ant)); } elseif (preg_match("/^\\.loglimit\\s(\\d+)\$/", $content, $match)) { $num = intval($match[1]); if ($num <= 0) { $msg = "Must be more than 0."; } elseif ($num > 1500) { $msg = "Must be less than or equal to 1500."; } else { $this->loglimit = $num; $msg = "Log limit set to {$num}."; } $this->msg($cid, $arg, $msg); } elseif (preg_match("/^\\.logdelay\\s(\\d+)\$/", $content, $match)) { $num = intval($match[1]); if ($num < 100) { $msg = "Must be more than or equal 100."; } else { $this->timers["CHECKLOG"][1] = $num / 1000; $msg = "Log delay set to " . game::format_number($num / 1000, 1) . " sec."; } $this->msg($cid, $arg, $msg); } elseif ($content == ".logtimer") { $this->timers["CHECKLOG"][2] = 0; $this->next = 0; $msg = "Timer reset."; $this->msg($cid, $arg, $msg); } elseif (preg_match("/^\\.skiptime\\s(\\d+)\$/", $content, $match)) { $num = intval($match[1]); if ($num < 5) { $msg = "Must be more than or equal to 5."; } elseif ($num > 60000) { $msg = "Must be less than or equal to 60000."; } else { $this->select_delay = $num * 1000; $msg = "Skiptime set to {$num}."; } $this->msg($cid, $arg, $msg); } elseif (preg_match("/^\\.s(\\s|\$)/", $content) && ($arg[0] != "#" || $this->connected_cid == $cid)) { if (strstr($content, " ") == " disconnect") { $this->connect = false; $this->msg($cid, $arg, "State set to disconnect."); } else { $this->connect = true; $this->msg($cid, $arg, "State set to connect."); } } elseif (preg_match("/^\\.addbot\\s(.+)\$/", $content, $match) && ($arg[0] != "#" || $this->connected_cid == $cid)) { $info = explode(" ", $match[1], 4); if (count($info) == 4) { $this->clients[] = array("nick" => $info[1], "user" => $info[2], "name" => $info[3], "bind" => $info[0], "tmp" => ""); end($this->clients); $key = key($this->clients); $this->msg($cid, $arg, "New bot added to list. (#{$key})"); } else { $this->msg($cid, $arg, "Wrong parameter count."); } } elseif (preg_match("/^\\.disconnect (\\d+)\$/", $content, $match)) { if ($cid == $match[1]) { $this->msg($cid, $arg, ":("); $this->debug($cid, "Disconnect command applied."); $this->disconnect($cid); $break = true; } } elseif (preg_match("/^\\.disconnect\$/", $content)) { $this->debug($cid, "Disconnect command applied."); $this->disconnect($cid); $break = true; } elseif (preg_match("/^\\.die\$/", $content)) { $this->debug($cid, "Die!!!"); unset($this->clients[$cid]); $this->msg($cid, $arg, "Bye, bye.."); $this->disconnect($cid, "Killed in action!"); $break = true; } elseif (preg_match("/^\\.die (\\d+)\$/", $content, $match)) { if (isset($this->clients[$match[1]])) { if ($cid != $match[1]) { $this->msg($cid, $arg, "Lets kill! heaheaha"); } else { $this->msg($cid, $arg, "Bye, bye.. :("); } $this->debug($match[1], "Die!!!"); unset($this->clients[$match[1]]); if (isset($this->sockets[$match[1]])) { $this->disconnect($match[1], "Killed in action!"); } if ($cid == $match[1]) { $break = true; } } else { #$this->msg($cid, $arg, "I don't know that person....?"); } } elseif (substr($content, 0, 5) == ".sql " && ($arg[0] != "#" || $this->connected_cid == $cid)) { $query = substr($content, 5); if (strpos($query, ";") !== false || substr($query, 0, 7) != "SELECT ") { $this->send_data($cid, "PRIVMSG {$arg} :Invalid query..\n"); } else { //$arg = "mysql --user="******" --pass="******" ".escapeshellarg(DBNAME)." --execute=".escapeshellarg($query); //$val = shell_exec($arg); $this->send_data($cid, "PRIVMSG {$arg} :Executing query..\n"); $ok = true; try { $result = \Kofradia\DB::get()->query($query); } catch (Exception $e) { $ok = false; } if (!$ok) { $this->send_data($cid, "PRIVMSG {$arg} :Query failed: " . \Kofradia\DB::get()->errorInfo()[2] . "\n"); } else { if ($result->rowCount() == 0) { $this->send_data($cid, "PRIVMSG {$arg} :No data in result.\n"); } else { // list opp feltene $row = $result->fetch(); $fields = array_keys($row); $this->send_data($cid, "PRIVMSG {$arg} :Fields: " . implode(", ", $fields) . "\n"); // vis hver rad $i = 1; do { $data = array(); foreach ($row as $value) { $data[] = preg_replace("/[\r\n]/", "", $value); } $this->send_data($cid, "PRIVMSG {$arg} :Row {$i}: " . implode(", ", $data) . "\n"); $i++; } while ($row = $result->fetch()); } $this->send_data($cid, "PRIVMSG {$arg} :Query completed..\n"); } } $break = true; } else { $log = false; } if ($log) { // logg forespørselen file_put_contents("irclog-" . $this->settings['name'] . ".log", date("r") . " {$user['nick']}!{$user['ident']}@{$user['host']} {$type} {$arg} {$content}\n", FILE_APPEND); } if ($break) { break; } } // ikke kanal melding if (substr($arg, 0, 1) != "#") { if ($user['ident'] != "" && $type == "PRIVMSG") { $this->send_data($cid, "NOTICE {$user['nick']} :Doh?\n"); } } else { // aktiv cid? if ($this->connected_cid == $cid) { $info = preg_split("/\\s+/", $content, 2); if (!isset($info[1])) { $info[1] = NULL; } switch ($info[0]) { case "!status": $time = intval($info[1]); if ($time == 0 || $time < 0) { $time = 300; } $last = time() - $time; $result = \Kofradia\DB::get()->query("SELECT COUNT(up_id) FROM users_players WHERE up_last_online >= {$last}"); $ant = game::format_number($result->fetchColumn(0)); unset($result); $time = game::timespan($time, game::TIME_FULL | game::TIME_NOBOLD); $this->msg($cid, $arg, "%bAntall pålogget siste {$time}%b: %u{$ant}%u"); break; case "!info": if ($this->irc_info) { $this->irc_info->end_node = $arg; $this->irc_info->parse_request($info[1]); } break; case "!search": $this->node_search($cid, $arg, $info[1]); break; } } } break; default: $this->debug($cid, "UNKNOWN USER DATA: {$line}"); } return; } $info = explode(" ", $line, 2); switch ($info[0]) { case "PING": $this->debug($cid, "PING PONG"); $this->send_data($cid, "PONG {$info[1]}"); break; case "ERROR": $this->debug($cid, $line); $this->handle_error($cid, "Error occured.."); // koble til på nytt #$this->connect($cid); break; default: $this->debug($cid, "UNKNOWN DATA: {$line}"); } }
/** Rediger revisjonsinformasjon */ public function edit($title, $description, $mime) { global $_base; // sørg for at tittelen (filename) ikke inneholder noen ugyldige tegn $title = crewfiles::filter_filename($title); // lagre endringer \Kofradia\DB::get()->exec("UPDATE crewfiles_revisions SET cfr_title = " . \Kofradia\DB::quote($title) . ", cfr_description = " . \Kofradia\DB::quote($description) . ", cfr_mime = " . \Kofradia\DB::quote($mime) . " WHERE cfr_id = {$this->id}"); $this->info['cfr_title'] = $title; $this->info['cfr_description'] = $description; $this->info['cfr_mime'] = $mime; }
/** * Deaktiver brukeren */ public function deactivate($reason, $note, player $by_up = null) { global $_game, $__server; if (!$by_up) { $by_up = $this->player; } // er ikke aktivert? if ($this->data['u_access_level'] == 0) { return false; } // deaktivere spilleren? if ($this->player->active) { $this->player->deactivate($reason, $note, $by_up); } $this->data['u_access_level'] = 0; $this->data['u_deactivated_time'] = time(); $this->data['u_deactivated_up_id'] = $by_up->id; $this->data['u_deactivated_reason'] = empty($reason) ? NULL : $reason; $this->data['u_deactivated_note'] = empty($note) ? NULL : $note; // deaktiver brukeren $a = \Kofradia\DB::get()->exec("UPDATE users SET u_access_level = 0, u_deactivated_time = {$this->data['u_deactivated_time']}, u_deactivated_up_id = {$by_up->id}, u_deactivated_reason = " . \Kofradia\DB::quote($reason) . ", u_deactivated_note = " . \Kofradia\DB::quote($note) . " WHERE u_id = {$this->id} AND u_access_level != 0"); if ($a == 0) { return false; } // logg ut alle øktene \Kofradia\DB::get()->exec("UPDATE sessions SET ses_active = 0, ses_logout_time = " . time() . " WHERE ses_u_id = {$this->id} AND ses_active = 1"); if ($by_up->id == $this->player->id) { $info = 'deaktiverte seg selv'; } else { $info = 'ble deaktivert'; if (login::$logged_in) { $info .= ' av ' . login::$user->player->data['up_name']; } } putlog("CREWCHAN", "%bDeaktivering%b: Brukeren {$this->data['u_email']} ({$this->player->data['up_name']}) {$info} {$__server['path']}/min_side?u_id={$this->id}"); return true; }