Example #1
1
    function talk($id_npc)
    {
        //данный метод не должен принимать параметров, но для примера мы его передаем
        $player = new player();
        //этот код до следующего комента мусорный, но нужен для работы в примере
        $target_npc = $id_npc;
        /*   ТАКИМ ОБРАЗОМ ПОЛУЧАЕМ ID NPC
         		$npc = new NPC;
        		$target_npc = $npc->get_npc_id();
        		*/
        if ($target_npc == $this->IVAN) {
            if ($this->COND == 0) {
                if ($player->get_lvl() >= 50) {
                    echo '<strong>ИВАН</strong> Твой уровень подходит, ты можешь взять квест - даем ссылку на евент event(start); 
					"Этот евент должен запускать игрок, тут я его сам запускаю, типа мы согласились выполнять квест"<br><hr>';
                    $this->event('start');
                    return;
                } else {
                    echo '<strong>ИВАН</strong> Твой уровень не подходит, ты не можешь взять этот квест<br>';
                    return;
                }
            }
            if ($this->COND == 1) {
                echo '<strong>ИВАН</strong> я тебе уже дал это задание, иди выполняй его!<br>';
                return;
            }
        }
        if ($target_npc == $this->LENA) {
            if ($this->COND == 1) {
                echo '<strong>ЕЛЕНА</strong> О ты принес мою коробку! - даем ссылку на евент event(finish)<br><hr>';
                $this->event('finish');
                return;
            }
        }
    }
 private function update(player $player)
 {
     $db = db::obtain();
     $data = array('account_id' => player::convert_id($player->get('steamid')));
     $data = array_merge($data, $player->get_data_array());
     $db->update_pdo(db::real_tablename('users'), $data, array('steamid' => $player->get('steamid')));
 }
Example #3
0
function getOpponentScores($init, $data)
{
    $player = new player($init->settings, $init->repository->get_data("player"));
    $scores = $player->getOpponentScores($init->repository->get_data("tempo"));
    foreach ($scores as $key => $opponentData) {
        $opponent = new player($settings, $opponentData["TegenstanderId"]);
        $opponent->getDetails();
        $scores[$key]["name"] = $opponent->name;
    }
    echo json_encode($scores);
}
Example #4
0
 public function updatePlayer($id)
 {
     Flight::auth()->check();
     $response = Flight::util()->validate('player', Flight::request()->data);
     if (is_array($response)) {
         Flight::util()->render('editPlayer', array('player' => Flight::players()->getPlayerWithId($id), 'teams' => Flight::teams()->getAllTeams(), 'error' => $response));
         return;
     }
     $player = new player(Flight::request()->data);
     $player->update();
     Flight::redirect('/player/' . $id);
 }
 public function load()
 {
     $db = db::obtain();
     $players = array();
     $result = $db->fetch_array_pdo('SELECT * FROM users WHERE steamid IN (' . $this->get_ids_string() . ')', array());
     foreach ($result as $r) {
         $player = new player();
         $player->set_array((array) $r);
         $players[$player->get('steamid')] = $player;
     }
     return $players;
 }
Example #6
0
 /**
  * Utfør kriminalitet
  */
 public function utfor($id)
 {
     $this->options_load();
     if (!isset($this->options[$id])) {
         throw new HSException("Fant ikke ønsket alternativ.");
     }
     $krim = $this->options[$id];
     $ret = array("success" => false);
     // treffer vi med sannsynligheten?
     if (rand(0, 100) <= $krim['prob'] * 100) {
         // vellykket
         $ret['success'] = true;
         // gi penger til spilleren
         $cash = rand($krim['cash_min'], $krim['cash_max']);
         \Kofradia\DB::get()->exec("UPDATE users_players SET up_cash = up_cash + {$cash} WHERE up_id = {$this->up->id}");
         $ret['cash'] = $cash;
         // trigger
         $this->up->update_money($cash, true, false);
         // gi rank til spilleren
         $ret['rank_change'] = $this->up->increase_rank($krim['points']);
         $ret['rank'] = $krim['points'];
     }
     // wanted nivå
     $ret['wanted_change'] = $this->up->fengsel_rank($krim['points'], $ret['success']);
     // oppdater kriminalitet-status
     $s = $ret['success'] ? 2 : 1;
     \Kofradia\DB::get()->exec("\n\t\t\tINSERT INTO kriminalitet_status\n\t\t\tSET krimid = {$id}, ks_up_id = {$this->up->id}, count = 1, success = " . ($ret['success'] ? 1 : 0) . ", last = " . time() . ", ks_strength = ks_strength + {$s}\n\t\t\tON DUPLICATE KEY\n\t\t\tUPDATE count = count + 1, success = success + VALUES(success), last = VALUES(last), ks_strength = VALUES(ks_strength)");
     // oppdater kriminalitet
     \Kofradia\DB::get()->exec("\n\t\t\tUPDATE kriminalitet\n\t\t\tSET k_strength = k_strength + {$s}\n\t\t\tWHERE id = {$id}");
     // trigger
     $this->up->trigger("kriminalitet", array("option" => $krim, "success" => $ret['success']));
     // sett ned energien til spilleren
     $this->up->energy_use(self::ENERGY_KRIM);
     return $ret;
 }
Example #7
0
 /**
  * Senk deler av en dusør (ved skadet angrep)
  * @param player $up spilleren det gjelder
  * @param player $attacker spilleren som angrep
  * @param float $health_f for hvor mye helse spilleren mistet (i forhold til maksverdien til spilleren)
  */
 public static function player_hurt(player $up, player $attacker, $health_f)
 {
     \Kofradia\DB::get()->beginTransaction();
     // hent informasjon om spilleren
     $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT SUM(hl_amount_valid) AS sum_hl_amount_valid\n\t\t\tFROM (\n\t\t\t\tSELECT hl_amount_valid\n\t\t\t\tFROM hitlist\n\t\t\t\tWHERE hl_up_id = {$up->id}\n\t\t\t\tFOR UPDATE\n\t\t\t) ref");
     $hl = $result->fetch();
     if (!$hl || $hl['sum_hl_amount_valid'] <= 0) {
         \Kofradia\DB::get()->commit();
         return 0;
     }
     $sum = $hl['sum_hl_amount_valid'];
     // hvor mye vi får
     $amount = bcmul($sum, $health_f);
     if ($amount <= 0) {
         \Kofradia\DB::get()->commit();
         return 0;
     }
     // trekk pengene fra hitlist
     \Kofradia\DB::get()->exec("SET @t := {$amount}");
     \Kofradia\DB::get()->exec("\n\t\t\tUPDATE hitlist h, (\n\t\t\t\tSELECT\n\t\t\t\t\thl_id,\n\t\t\t\t\tGREATEST(0, LEAST(@t, hl_amount_valid)) AS to_remove,\n\t\t\t\t\t@t := GREATEST(0, @t - hl_amount_valid)\n\t\t\t\tFROM hitlist\n\t\t\t\tWHERE hl_up_id = {$up->id} AND @t > 0\n\t\t\t\tORDER BY hl_time\n\t\t\t) r\n\t\t\tSET h.hl_amount_valid = h.hl_amount_valid - to_remove\n\t\t\tWHERE h.hl_id = r.hl_id");
     \Kofradia\DB::get()->exec("DELETE FROM hitlist WHERE hl_amount_valid = 0");
     // gi pengene til spilleren
     \Kofradia\DB::get()->exec("UPDATE users_players SET up_cash = up_cash + {$amount} WHERE up_id = {$attacker->id}");
     $attacker->data['up_cash'] = bcadd($attacker->data['up_cash'], $amount);
     // hendelse om at man mottok penger fra hitlist for angrepet
     $attacker->add_log("etterlyst_receive", $up->id . ":1:1", $amount);
     \Kofradia\DB::get()->commit();
     return $amount;
 }
 public function setUp()
 {
     $mapperWeb = new PlayersMapperWeb();
     $mapperWeb->addId(player::convertId($this->playerId));
     $d = $mapperWeb->load();
     $this->player = array_pop($d);
 }
Example #9
0
 /**
  * Hent beste ranker siste 24 timer
  */
 public function action_bestranker()
 {
     $stats = new \Kofradia\Users\Stats();
     $players = $stats->getBestRankers();
     if (count($players) == 0) {
         return \Kofradia\View::forgeTwig('users/login/helpers/best_ranker', array("player" => null));
     }
     $player = reset($players);
     return \Kofradia\View::forgeTwig('users/login/helpers/best_ranker', array("player" => $player, "img" => \player::get_profile_image_static($player['up_profile_image_url']), "rank" => new \Kofradia\Game\Player\Rank($player['up_points'], $player['upr_rank_pos'], $player['up_access_level']), "profile_link" => \game::profile_link($player['up_id'], $player['up_name'], $player['up_access_level'])));
 }
Example #10
0
function addPlayer()
{
    include_once "./model/player.php";
    $player = new Player();
    //upload picture here
    $picture = uploadPicture("./images/players", "player_picture");
    $name = $_REQUEST['name'];
    $birth = $_REQUEST['birth'];
    $division = $_REQUEST['division'];
    $position = $_REQUEST['position'];
    $about = $_REQUEST['about'];
    $signed = $_REQUEST['signed'];
    include "../../model/player.php";
    $player = new player();
    if (!$player->add_player($name, $birth, $division, $position, $about, $signed, $picture)) {
        echo 'problem adding player, try again later';
        return;
    }
    echo '' . $name . ' has been added successfully';
}
Example #11
0
 /**
  * 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;
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
<?php

require "../../base.php";
global $_whatpulse, $_base;
// sørg for at whatpulse-innstillingene lastes inn
class_exists("whatpulse");
// brukes kun for autoloader
access::no_guest();
$_base->page->add_title("WhatPulse");
$wpFelt = $_whatpulse['fields_text'];
$player = login::$user->player;
// skal vi laste inn siden for noen andre spillere?
if (isset($_GET['up_id']) && access::has("mod")) {
    $player = player::get(intval(getval('up_id')));
    if (!$player or $player->id == login::$user->player->id) {
        redirect::handle();
    }
    ess::$b->page->add_message('Du viser nå WhatPulse-informasjonen til <user id="' . $player->id . '" />');
    redirect::store("?up_id={$player->id}");
}
// sjekk om vi har WhatPulse registrert
$result = \Kofradia\DB::get()->query("SELECT sw_userid, sw_time_update, sw_xml, sw_params FROM stats_whatpulse WHERE sw_up_id = " . $player->id . " FOR UPDATE");
if ($result->rowCount() == 0) {
    echo '
<h1>WhatPulse</h1>
<div style="width: 300px" class="center">
	<div class="section">
		<h3>Informasjon</h3>
		<p>
			Du er ikke registrert med WhatPulse informasjon. For å koble WhatPulse informasjonen til din profil fyll ut formen nedenfor. Se på <a href="http://whatpulse.org/" target="_blank">whatpulse.org</a> for informasjon om WhatPulse.
		</p>
Example #14
0
<?php

//WEBSITE STARTUP
include_once '../../includes/class.init.php';
include_once '../../includes/class.player.php';
$init = new init(1, 0, 0);
$settings = new settings();
$member = new player($settings, $init->repository->get_data("memberId"));
if ($init->repository->get_data("memberAction") == 1) {
    $member->setDetails($init->repository->get_data("memberKNSB"), $init->repository->get_data("memberInitials"), $init->repository->get_data("memberFirstname"), $init->repository->get_data("memberMiddlename"), $init->repository->get_data("memberSurname"));
}
$member->getDetails();
include_once '../../includes/header.beheer.php';
?>
<body class="container">

    <?php 
include "../../includes/menu.beheer.php";
?>
       


    <div class="row hidden-print">
        <div class="col-md-12">
            <h1 class="hidden-print">Leden bewerken</h1>
            <form class="form-horizontal" method="post">
                <input type="hidden" name="memberId" value=<?php 
echo $init->repository->get_data("memberId");
?>
>
                <input type="hidden" name="memberAction" value=1>
Example #15
0
function getMatchResults($match_id)
{
    if (isset($_GET['match_id'])) {
        $match_id = intval($_GET['match_id']);
    }
    $match_mapper_web = new match_mapper_web($match_id);
    $match = $match_mapper_web->load();
    if (is_null($match)) {
        die('<p>Match does not exists.</p>');
    }
    $players_mapper_web = new players_mapper_web();
    foreach ($match->get_all_slots() as $slot) {
        if ($slot->get('account_id') != player::ANONYMOUS) {
            $players_mapper_web->add_id(player::convert_id($slot->get('account_id')));
        }
    }
    $players = $players_mapper_web->load();
    $slots = $match->get_all_slots_divided();
    $results = array();
    if ($match->get('radiant_win')) {
        $results['winners'] = getMatchTeamPlayers($slots, $players, 'radiant');
        $results['losers'] = getMatchTeamPlayers($slots, $players, 'dire');
    } else {
        $results['winners'] = getMatchTeamPlayers($slots, $players, 'dire');
        $results['losers'] = getMatchTeamPlayers($slots, $players, 'radiant');
    }
    return $results;
}
Example #16
0
<?php

define("FORCE_HTTPS", true);
define("ALLOW_GUEST", true);
require "base.php";
global $__server;
ess::$b->page->theme_file = "guest_simple";
// logget inn og har vervelenke?
if (login::$logged_in && isset($_GET['r'])) {
    // finn spilleren og redirect dit om mulig
    if ($player = player::get($_GET['r'])) {
        return $player->redirect_to();
    }
}
access::no_user();
ess::$b->page->add_css('
.registrer_felt {
	background: rgb(30, 30, 30);
	background: rgba(150, 150, 150, 0.05);
	border: 7px solid rgb(25, 25, 25);
	border: 7px solid rgba(31, 31, 31, 0.7);
	width: 300px;
	margin: 1em auto;
	padding: 1px 1em;
}
/*.registrer_felt input.styled {
	background: #111;
	color: #FFF;
	border: 1px solid #1F1F1F;
	padding: 1px;
	font-size: 12px;
Example #17
0
<?php

include "./slotFunctions.php";
include "./unitClass.php";
echo 'This is a battle that is waiting to take place';
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
// Load list of units that the player controls
$playerObj = new player($pGameID, $unitFile, 400);
$unitList = array_filter(unpack("i*", readSlotData($slotFile, $playerObj->get('unitSlot'), 40)));
$matchedSide = 0;
// Look for units that the player controls to determine which side they are on
$sideA = new itemSlot($unitDat[15], $slotFile, 40);
$sideB = new itemSlot($unitDat[16], $slotFile, 40);
fclose($slotFile);
for ($i = 1; $i <= sizeof($unitList->slotData); $i++) {
    if (array_search($unitList->slotData[$i], $sideA->slotData)) {
        $matchedSide = 1;
    } else {
        if (array_search($unitList->slotData[$i], $sideB->slotData)) {
            $matchedSide = 2;
        }
    }
}
// Get information on the wars
for ($i = 0; $i <= 5; $i++) {
    fseek($unitFile, $unitDat[17 + $i] * $defaultBlockSize);
    $warDat = unpack('i*', fread($unitFile, 200));
    echo 'War #' . $unitDat[17 + $i] . '<br>';
}
echo '<div style="position:absolute; bottom:0; left:0;" onclick="scrMod(1094,' . $unitID . ');">Battle Detail</div>';
<?php

global $files;
// kjør session for å unngå feil når player::get lastes
session_start();
// eksporter databasen med exportscriptet
require "export_to_devdb.php";
// initialiser crewfiles systemet med SYSTEM-brukeren
crewfiles::init(player::get(SYSTEM_USER_ID), true);
// hvilke filer i crewfiles som skal oppdateres
$data = array(array(190, $files[0], "main"));
// oppdaterer filene i crewfiles
foreach ($data as $r) {
    // hent filobjekt i crewfiles
    $file = crewfiles::get_file($r[0]);
    if (!$file) {
        echo "Fant ikke filen med ID {$r[0]}\n";
        continue;
    }
    echo "Kjører {$r[1]} gjennom gzip.\n";
    shell_exec("gzip -9 " . escapeshellarg($r[1]));
    $r[1] .= ".gz";
    echo "Laster opp {$r[1]} til crewfiles...\n";
    $revision = $file->upload($r[1], "Automatisk eksportert", "application/x-gzip-compressed", $r[1], true);
    $path = ess::$s['spath'] . '/crewstuff/f/rev/' . $revision->id . '-' . urlencode(crewfiles::generate_tagname($revision->info['cfr_title']));
    putlog("CREWCHAN", "Dev-database {$r[2]}: {$path}");
    echo "Lastet opp!\n";
    // slett filen
    unlink($r[1]);
}
    public function prepare()
    {
        global $db, $user, $settings;
        // auth check
        $auth = $db->query_first("SELECT mp.type FROM  tf2stats_map_to_player mp LEFT JOIN tf2_maps m ON m.id = mp.map_id\r\n\t\t\t\t\t\tWHERE mp.player_id = %s AND m.name = %s", array($user->id(), $this->request[0]));
        if (!in_array($auth['type'], array('M', 'A', 'C'))) {
            page::error("Little man", "You are no match for me!");
        }
        // handle file removals
        if ($this->request[1] == 'delimg') {
            $db->query("DELETE FROM tf2stats_map_images WHERE image = %s", array($this->request[2]));
            $this->params['success'] = "Deleted " . $this->request[2];
        }
        // update
        if ($_REQUEST['update']) {
            if ($_REQUEST['filesize'] && !is_numeric($_REQUEST['filesize'])) {
                $this->params['error'] = 'Filesize must be numeric. Do not append "MB".';
            } elseif ($_REQUEST['url'] && !filter_var($_REQUEST['url'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {
                $this->params['error'] = 'Download URL is not valid.';
            } else {
                $i = $db->query_first("SELECT m.id, m.official FROM tf2_maps m WHERE m.name = %s", array($this->request[0]));
                if (IsUserAdmin()) {
                    $Official = (int) (isset($_REQUEST['official']) && $_REQUEST['official'] == 'official');
                    cache::log("Changing official status for " . $i['id'] . " - old: " . $i['official'] . " - new: " . $Official);
                    if ($i['official'] != $Official) {
                        $db->query("UPDATE tf2_maps SET official = %s WHERE id = %s", array($Official, $i['id']));
                    }
                }
                $db->query("INSERT INTO tf2stats_managed_maps (player_id, map_id, edit_time, description, file_size, download_url) VALUES(%s, %s, %s, %s, %s, %s)\r\n\t\t\t\t\t\t\tON DUPLICATE KEY UPDATE edit_time=%s, description=%s, file_size=%s, download_url = %s", array($user->id(), $i['id'], time(), $_REQUEST['description'], $_REQUEST['filesize'], $_REQUEST['url'], time(), $_REQUEST['description'], $_REQUEST['filesize'], $_REQUEST['url']));
            }
        }
        // map info
        $map_info = $db->query_first("SELECT m.name, m.id, m.official, mp.description, mp.file_size, mp.download_url, mp.edit_time, p.name as player_name FROM  tf2stats_managed_maps mp \r\n\t\t\t\t\t\tLEFT JOIN tf2_maps m ON m.id = mp.map_id\r\n\t\t\t\t\t\tLEFT JOIN tf2_players p on mp.player_id = p.id\r\n\t\t\t\t\t\tWHERE m.name = %s\r\n\t\t\t\t\t\tORDER BY edit_time DESC\r\n\t\t\t\t\t\tLIMIT 1", array($this->request[0]));
        if ($map_info) {
            $this->params['old'] = true;
        } else {
            $map_info = $db->query_first("SELECT m.name,  m.id FROM tf2_maps m WHERE m.name = %s", array($this->request[0]));
        }
        $this->params['map_info'] = $map_info;
        // handle adding authors.
        if ($this->request[1] == 'addauthor') {
            if ($this->request['search']) {
                $player_id = $this->request['search'];
                if (!is_id64($player_id)) {
                    $player_id = get_id64($this->request['search']);
                }
                $player = new player($player_id);
                if ($player->id()) {
                    $db->query("INSERT INTO tf2stats_map_to_player(player_id, map_id, type) VALUES(%s, %s, %s)", array($player->id(), $map_info['id'], 'A'));
                    $this->params['success'] = $player_id . ' has been added to the author list.';
                } else {
                    $this->params['error'] = "Could not find a player by '" . $_REQUEST['search'] . "'. Please refine your search.";
                }
            } else {
                $this->template = "manage_map_author";
                $this->title = sprintf("Adding author for %s", htmlspecialchars($map_info['name']));
                return;
            }
        }
        if ($this->request[1] == 'delauthor') {
            $id = $this->request[2];
            $db->query("DELETE FROM tf2stats_map_to_player WHERE player_id=%s AND map_id = %s", array($id, $map_info['id']));
            $this->params['success'] = "Deleted author";
        }
        // handle file uploads.
        if ($this->request[1] == 'upload') {
            $this->template = "manage_map_upload";
            $this->title = sprintf("Upload image for %s", htmlspecialchars($map_info['name']));
            $this->params['allowed_images'] = implode(', ', $settings['upload']['allowed_images']);
            if ($_FILES['image']) {
                if (!$_FILES['image']['tmp_name']) {
                    $this->params['error'] = 'Upload failed. (This usually happens when you try to upload a file larger than 1MB!)';
                    return;
                }
                // check extension.
                $ext = end(explode(".", strtolower($_FILES['image']['name'])));
                if (!in_array($ext, $settings['upload']['allowed_images'])) {
                    $this->params['error'] = 'Unsupported file extension ' . $ext . '. Please convert your image to one of these formats: ' . implode(', ', $settings['upload']['allowed_images']);
                    return;
                }
                // rename if already exists
                $filename = sprintf("%s_%s", $map_info['id'], str_replace(array('(', ')', ' '), '_', basename($_FILES['image']['name'])));
                $target_path = $settings['upload']['folder']['maps'] . $filename;
                while (file_exists($target_path)) {
                    $filename = md5(time() . rand()) . '.' . $ext;
                    $target_path = $settings['upload']['folder']['maps'] . $filename;
                }
                //var_dump($target_path);
                if (filesize($_FILES['image']['tmp_name']) > 2097152) {
                    $this->params['error'] = 'Uploaded file cannot exceed 1MB.';
                    return;
                }
                if (move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
                    $db->query("INSERT INTO tf2stats_map_images (map_id, player_id, image) VALUES(%s, %s, %s)", array($map_info['id'], $user->id(), $filename));
                    $this->params['success'] = basename($_FILES['image']['name']) . ' uploaded successfully.';
                } else {
                    echo $_FILES['image']['tmp_name'];
                    echo $target_path;
                    $this->params['error'] = 'Unknown error. Please nag FireSlash until he fixes it.';
                }
            }
            return;
        }
        // tinyMCE setup
        $this->head .= '<script type="text/javascript" src="/static/js/tiny_mce/jquery.tinymce.js"></script>
		<script type="text/javascript">
	$().ready(function() {
		$(\'textarea.tinymce\').tinymce({
			// Location of TinyMCE script
			script_url : "/static/js/tiny_mce/tiny_mce.js",

			theme : "advanced",
			mode : "none",
			plugins : "bbcode",
			theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,styleselect,removeformat,cleanup,code",
			theme_advanced_buttons2 : "",
			theme_advanced_buttons3 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle",
			content_css : "css/bbcode.css",
			entity_encoding : "raw",
			add_unload_trigger : false,
			remove_linebreaks : false,
			inline_styles : false,
			convert_fonts_to_spans : false,
			apply_source_formatting : false
			
		});
	});
</script>
		';
        // map info
        $this->template = "manage_map";
        require_once 'classes/map.php';
        $m = new map($this->request[0]);
        $this->params['images'] = $m->get_images('xy165');
        $this->params['has_images'] = $this->params['images'];
        $this->params['can_set_official'] = IsUserAdmin();
        // associated peoples
        $db->query("SELECT p.id, p.name, mp.type from tf2stats_map_to_player mp LEFT JOIN tf2_players p ON mp.player_id = p.id WHERE mp.map_id = %s", array($map_info['id']));
        while ($row = $db->fetch_array()) {
            $row['del_link'] = sprintf('/manage_map/%s/delauthor/%s/', $this->request[0], $row['id']);
            $p[] = $row;
        }
        $this->title = sprintf("Managing %s", htmlspecialchars($this->request[0]));
        $this->params['people'] = $p;
    }
    }
    ?>
	<br>
	<?php 
    //printf("%d insert player %s %s  ", $i, $player_i[0], $player_i[1]);
    $result = player::insert($player_i[0], $player_i[1], $player_i[2]);
    $player_id = $result->player_id;
    $first_name = $result->first_name;
    $last_name = $result->last_name;
    printf("insert Player " . "{$player_id}: " . "{$first_name}" . " and " . "{$last_name}" . " succeeded!");
    if (count($player_i) == 8) {
        ?>
	<br>
	<?php 
        //printf("%d insert Passing player %s %s ", $i, $player_i[6], $player_i[7]);
        $result = player::insert($player_i[6], $player_i[7], $player_i[2]);
        $player_id = $result->player_id;
        $first_name = $result->first_name;
        $last_name = $result->last_name;
        printf("insert Player " . "{$player_id}: " . "{$first_name}" . " and " . "{$last_name}" . " succeeded!");
    }
}
?>
<br>
<?php 
// $exist = $conn->query("select * from Player p where ");
// if($exist){
// 	$next_row = $exist->fetch_assoc();
// 	printf($next_row["first_name"]);
// 	printf(count($next_row));
// }
Example #21
0
                            <th>Bord</th>
                            <th>Speler</th>
                            <th>Rating</th>
                            <th></th>
                            <th>Tegenstander</th>
                            <th>KNSB</th>
                            <th>Rating</th>
                            <th>Uitslag</th>
                        </tr> 
                    </thead>
                    <?php 
$results = array("1" => "1 - 0", "0.5" => "&#189;-&#189;", "0" => "0 - 1");
for ($a = 1; $a < 11; $a++) {
    $game = $data->filter($matchGames, "bord", $a);
    $game = $game[0];
    $speler = new player($settings, $game["spelerId"]);
    $speler->getDetails();
    ?>
                        <tr>
                            <td><?php 
    echo $a;
    ?>
                                <input type="hidden" name="gameId<?php 
    echo $a;
    ?>
" value="<?php 
    echo $game["id"];
    ?>
">
                                <input type="hidden" name="memberId<?php 
    echo $a;
Example #22
0
        $Token1 = @$_GET['Token'];
        $type = @$_GET['ask_method'];
        if ($infoarr['openid'] != "") {
            if ($media_id == "") {
                $Token2 = "";
            } else {
                include "../cache/" . $media_id . ".php";
                $Token2 = $Token['token'];
            }
            if ($Token1 == $Token2 && $Token1 != "" && $Token2 != "") {
                $media_url = "http://weixin.faeries-land.com/uploadfile/" . $media_id . ".mp3";
                $data = array('media_id' => "{$media_id}", 'media_url' => $media_url);
                $code = 0;
                $msg = "success!";
                api_response::api_method($type, $code, $msg, $data);
            } else {
                $code = -1;
                $msg = "error:permission denied!";
                $data = "null";
                api_response::api_method($type, $code, $msg, $data);
            }
        } else {
            $code = -1;
            $msg = "error:You have to use wechat app to open! ";
            $data = "null";
            api_response::api_method($type, $code, $msg, $data);
        }
    }
}
$show = new player();
$show->permission();
Example #23
0
    /**
     * Vis resultat fra angrep
     */
    protected function attack_result_show($result, $bullets)
    {
        echo '
<div class="bg1_c xsmall">
	<h1 class="bg1">' . ($result['drept'] ? 'Spiller drept' : 'Spiller skadet') . '<span class="left2"></span><span class="right2"></span></h1>
	<div class="bg1">';
        // sett opp hva vi fikk
        $got = array();
        $got[] = game::format_num($result['rankpoeng']) . ' poeng' . ($result['drept'] ? '' : ' fra spilleren');
        if (isset($result['penger']) && $result['penger'] > 0) {
            $got[] = game::format_cash($result['penger']) . ' som offeret hadde på hånda';
        }
        if (isset($result['penger_bank']) && $result['penger_bank'] > 0) {
            $got[] = game::format_cash($result['penger_bank']) . ' som deler av det offeret hadde i banken';
        }
        if (isset($result['hitlist']) && $result['hitlist'] > 0) {
            $got[] = game::format_cash($result['hitlist']) . ' fra hitlista';
        }
        $got = sentences_list($got);
        // vellykket?
        if ($result['drept']) {
            $place = bydeler::get_random_place(login::$user->player->bydel['id']);
            echo '
		<p>Du fant ' . $this->up_offer->profile_link() . ' som hadde ranken ' . $this->up_offer->rank['name'] . ' og var plassert som nummer ' . $this->up_offer->data['upr_rank_pos'] . ' på ranklista' . ($place ? ' ved ' . $place : '') . ' og angrep spilleren med ' . $bullets . ' ' . fword("kule", "kuler", $bullets) . '.</p>
		<p>Spilleren døde av angrepet ditt. Du fikk ' . $got . '.' . ($result['penger'] == 0 ? ' Offeret hadde ingen penger på hånda.' : '') . '</p>';
        } else {
            $place = bydeler::get_random_place(login::$user->player->bydel['id']);
            echo '
		<p>Du fant ' . $this->up_offer->profile_link() . ' med ranken ' . $this->up_offer->rank['name'] . ' og plassering nummer ' . $this->up_offer->data['upr_rank_pos'] . ' på ranklista' . ($place ? ' ved ' . $place : '') . ' og angrep spilleren med ' . $bullets . ' ' . fword("kule", "kuler", $bullets) . '.</p>
		<p>Spilleren ble skadet av angrepet men overlevde. Du mottok ' . $got . '.</p>';
        }
        // list opp vitner
        if (count($result['vitner']) == 0) {
            echo '
		<p>Ingen spillere vitnet ' . ($result['drept'] ? 'drapet' : 'drapsforsøket') . '.</p>';
        } else {
            // sett opp liste over navngitte spillere som oppdaget det
            $list = array();
            $count_other = 0;
            foreach ($result['vitner'] as $vitne) {
                if ($vitne['visible']) {
                    $list[] = $vitne['up']->profile_link();
                } else {
                    $count_other++;
                }
            }
            if ($count_other > 0) {
                $list[] = fwords("%d ukjent spiller", "%d ukjente spillere", $count_other);
            }
            echo '
		<p>Du ble oppdaget av ' . sentences_list($list) . ' da ' . ($result['drept'] ? 'drapet' : 'drapsforsøket') . ' ble gjennomført.</p>';
        }
        // fengselendring?
        if (isset($result['fengsel'])) {
            // kom i fengsel?
            if ($result['fengsel'] === false) {
                // fjern meldingen som allerede er lagt inn
                ess::$b->page->message_get("fengsel");
                echo '
		<p>Du kom i fengsel og slipper ut om ' . game::counter(login::$user->player->data['up_fengsel_time'] - time()) . '. Wanted nivået er nå på ' . game::format_num(login::$user->player->data['up_wanted_level'] / 10, 1) . ' %.</p>';
            } else {
                echo '
		<p>Wanted nivået økte med ' . game::format_num($result['fengsel'] / 10, 1) . ' %.</p>';
            }
        }
        echo '
		<p class="c"><a href="angrip">Tilbake</a></p>
	</div>
</div>';
        ess::$b->page->load();
    }
Example #24
0
 /**
  * Slett auksjonen (sett som inaktiv og returner bud)
  */
 public function handle_delete()
 {
     // forsøk å sett som behandlet
     $this->data['a_completed'] = 1;
     $affected = \Kofradia\DB::get()->exec("UPDATE auksjoner SET a_completed = 1 WHERE a_id = {$this->id} AND a_completed = 0");
     // allerede behandlet?
     if ($affected == 0) {
         return;
     }
     // behandle ulike auksjonstyper
     switch ($this->data['a_type']) {
         case self::TYPE_KULER:
             // gi kulene tilbake til personen som startet auksjonen
             $kuler = (int) $this->params->get("bullets");
             if ($kuler && $this->data['a_up_id']) {
                 \Kofradia\DB::get()->exec("UPDATE users_players SET up_weapon_bullets = up_weapon_bullets + {$kuler}, up_weapon_bullets_auksjon = GREATEST(0, up_weapon_bullets_auksjon - {$kuler}) WHERE up_id = {$this->data['a_up_id']}");
             }
             break;
     }
     // hent alle budene som skal settes inaktive
     $result = \Kofradia\DB::get()->query("\n\t\t\tSELECT ab_id, ab_bid, ab_up_id\n\t\t\tFROM auksjoner_bud\n\t\t\tWHERE ab_a_id = {$this->id} AND ab_active != 0");
     while ($row = $result->fetch()) {
         self::set_bud_inactive($row, $this);
     }
     // behandle trigger
     if ($this->data['a_up_id']) {
         $up = player::get($this->data['a_up_id']);
         if ($up) {
             $up->trigger("auksjon_delete", array("auksjon" => $this));
         }
     }
     // oppdater cache
     self::update_cache();
 }
Example #25
0
 /**
  * test creating a player and then deleting it
  **/
 public function testDeleteValidPlayer()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("player");
     // create a new player and insert into mySQL
     $player = new Player(null, $this->VALID_PLAYERAPIID, $this->team->getTeamId(), $this->sport->getSportId(), $this->VALID_PLAYERNAME);
     $player->insert($this->getPDO());
     // delete the player from mySQL
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("player"));
     $player->delete($this->getPDO());
     // grab the data from mySQL and enforce the player does not exist
     $pdoPlayer = player::getPlayerByPlayerId($this->getPDO(), $player->getPlayerId());
     $this->assertNull($pdoPlayer);
     $this->assertEquals($numRows, $this->getConnection()->getRowCount("player"));
 }
Example #26
0
 /**
  * \param N number of players to be created for the tournament
  *
  * \param team_colours Array of string with teams colours eg. ["red", 
  * "blue"]
  *
  * \brief Creates $N players assigned to teams defined with $team_colours
  *
  * Constructor create an instance of team class for each value fo $team_colours
  * and $N players are constructed and randomly assigned to one of the 
  * teams
  */
 public function __construct($N, $team_colours)
 {
     $this->number_of_players = $N;
     foreach ($team_colours as $colour) {
         $this->teams[] = new team($colour);
         $this->number_of_teams++;
     }
     $players = [];
     while (player::getCount() < $N) {
         $players[] = new player();
     }
     $this->assign_players($players);
 }
Example #27
0
 /**
  * Handle failure
  */
 protected function handleFailure()
 {
     // wanted level
     $this->result->wanted = $this->ut->up->fengsel_rank($this->getPoints());
     \Kofradia\DB::get()->prepare("\n\t\t\tUPDATE users_players\n\t\t\tSET up_utpressing_last = ?\n\t\t\tWHERE up_id = ?")->execute(array(time(), $this->ut->up->id));
     $this->ut->up->data['up_utpressing_last'] = time();
     // we can fail totally, which basicly mean
     // we don't find a player at all
     // or we can try find a player and pretend we
     // didn't manage to take the money
     if (rand(1, 100) <= 30) {
         return;
     }
     $cash = $this->getCash();
     $w = $this->getPlayersCriterias($cash);
     // find a matching player
     $result = \Kofradia\DB::get()->prepare("\n\t\t\tSELECT up_id\n\t\t\tFROM (\n\t\t\t\tSELECT up_id\n\t\t\t\tFROM users_players\n\t\t\t\tWHERE {$w[0]}\n\t\t\t\tORDER BY up_last_online DESC\n\t\t\t\tLIMIT 100\n\t\t\t) ref\n\t\t\tORDER BY RAND()\n\t\t\tLIMIT 1");
     $result->execute($w[1]);
     // no players?
     $row = $result->fetch();
     if (!$row) {
         return;
     }
     $this->result->up = \player::get($row['up_id']);
     $this->result->cashLost = $cash;
 }
Example #28
0
File: td_2.php Project: rwruss/ib3
include "./unitClass.php";
date_default_timezone_set('America/Chicago');
if (isset($unitAssign)) {
    if ($unitAssign != 0) {
        echo 'Task type 2 Detail - unit assigned #' . $unitAssign . '<br>';
        //print_r($taskDat);
    }
} else {
    //echo 'Task type 2 Detail';
}
// Get list of workers avaialble to work on this task.
$unitFile = fopen($gamePath . '/unitDat.dat', 'rb');
fseek($unitFile, $pGameID * $defaultBlockSize);
$pDat = unpack('i*', fread($unitFile, 400));
$playerObj = new player($pGameID, $pDat, $unitFile);
//print_R($playerObj);
$slotFile = fopen($gamePath . '/gameSlots.slt', 'rb');
//$unitList = array_filter(unpack("i*", readSlotData($slotFile, $playerObj->unitSlot, 40)));
$unitList = new itemSlot($playerObj->get('unitSlot'), $slotFile, 40);
//echo 'Check unit tslot '.$playerObj->get('unitSlot');
$noUnitsHere = true;
echo '<script>
useDeskTop.newPane("characters");
thisDiv = useDeskTop.getPane("characters");

taskList.newUnit({unitType:"task", unitID:' . $postVals[1] . ', unitName:"Task #' . $postVals[1] . ' on ' . $taskDat[11] . '", actionPoints:' . $taskDat[6] . ', reqPts:' . $taskDat[5] . ', strength:75});
taskList.renderSum(' . $postVals[1] . ', thisDiv)

var thisTask = makeTabMenu("newChars", thisDiv);
var taskDesc = newTab("newChars", 1, "Description");
 /**
  * @return array
  */
 public function load()
 {
     $request = new request(self::player_steam_url, array('steamids' => $this->get_ids_string()));
     $players_info = $request->send();
     if (is_null($players_info)) {
         return null;
     }
     $players = array();
     foreach ($players_info->players[0] as $player_info) {
         $player = new player();
         $player->set_array((array) $player_info);
         $players[$player->get('steamid')] = $player;
     }
     return $players;
 }
Example #30
0
 public function removeFromWaitScreen(player $player)
 {
     if ($player->isWaiting()) {
         //clear the player name from the waiting screen
         $output = "÷\t" . chr(call_method('getPid', $player)) . toEndian(INT2WORD(call_method('getWaitTime', $player))) . "";
         foreach ($this->players as $othPlayer) {
             if (call_method('isOffline', $othPlayer)) {
                 continue;
             }
             call_method('write', $this, call_method('getSocketId', $othPlayer), $output);
         }
     }
 }