public function changePassword($username, $newPassword)
 {
     if ($username && $newPassword) {
         $this->connection->query("UPDATE " . table("account") . " SET " . column("account", "password") . " = ?, " . column("account", "sessionkey") . " = '', " . column("account", "v") . " = '', " . column("account", "s") . " = '' WHERE " . column("account", "username") . " = ?", array($newPassword, $username));
     } else {
         return false;
     }
 }
 private function canClaim($id)
 {
     /*
     Returns:
     0 : user doesn't exist
     1 : available
     2 : already claimed
     3 : time < required
     4 : not referal (shouldn't happen)
     */
     if (!$this->external_account_model->userExists($id)) {
         return 0;
     }
     $auth = $this->external_account_model->getConnection();
     $query = $auth->query("SELECT * FROM " . table("account") . " WHERE " . column("account", "id") . " = " . $id . " AND recruiter = " . $this->user->getId());
     if ($query->num_rows() > 0) {
         $query = $this->db->query("SELECT * FROM recruit_a_friend_claimed WHERE recruiter = " . $this->user->getId() . " AND referral = " . $id);
         if ($query->num_rows() > 0) {
             return 2;
         } else {
             if ($this->config->item('recruit_realm_id') == 0) {
                 $totaltime = 0;
                 $realms = $this->realms->getRealms();
                 foreach ($realms as $realm) {
                     $characterDb = $realm->getCharacters()->getConnection();
                     $id = $characterDb->escape($id);
                     $query = $characterDb->query("SELECT sum(totaltime) as time FROM " . table("characters") . " WHERE " . column("characters", "account") . " = " . $id);
                     $row = $query->row();
                     if ($row->time) {
                         $totaltime += $row->time;
                     }
                 }
                 if ($totaltime >= $this->config->item('recruit_min_time')) {
                     return 1;
                 } else {
                     return 3;
                 }
             } else {
                 $realm = $this->realms->getRealm($this->config->item('recruit_realm_id'));
                 $characterDb = $realm->getCharacters()->getConnection();
                 $id = $characterDb->escape($id);
                 $query = $characterDb->query("SELECT sum(totaltime) as time FROM " . table("characters") . " WHERE " . column("characters", "account") . " = " . $id);
                 $row = $query->row();
                 if ($row->time && $row->time >= $this->config->item('recruit_min_time')) {
                     return 1;
                 } else {
                     return 3;
                 }
             }
         }
     } else {
         return 4;
     }
 }
Esempio n. 3
0
/**
 * Get the columns and format them
 * @param String $table
 * @param Array $columns
 * @return String
 */
function columns($table, $columns, $realm = false)
{
    foreach ($columns as $column) {
        if (!isset($out)) {
            $out = column($table, $column, false, $realm) . " AS " . $column;
        } else {
            $out .= "," . column($table, $column, false, $realm) . " AS " . $column;
        }
    }
    return $out;
}
 public function setCharacterAccount($guid, $account, $realmId)
 {
     $db = $this->realms->getRealm($realmId)->getCharacters()->getConnection();
     $Table = table("characters", $realmId);
     $ColumnAccount = column("characters", "account", false, $realmId);
     $ColumnGUID = column("characters", "guid", false, $realmId);
     $query = $db->query("UPDATE " . $Table . " SET " . $ColumnAccount . " = ? WHERE " . $ColumnGUID . " = ? LIMIT 1;", array($account, $guid));
     if ($query) {
         return true;
     }
     return false;
 }
Esempio n. 5
0
 public function findCharacter($searchString = "", $realmId = 1)
 {
     //Connect to the character database
     $character_database = $this->realms->getRealm($realmId)->getCharacters();
     $character_database->connect();
     //Get the connection and run a query
     $query = $character_database->getConnection()->query("SELECT " . columns("characters", array("guid", "name", "race", "gender", "class", "level"), $realmId) . " FROM " . table("characters", $realmId) . " WHERE UPPER(" . column("characters", "name", false, $realmId) . ") LIKE ? ORDER BY " . column("characters", "level", false, $realmId) . " DESC", array('%' . strtoupper($searchString) . '%'));
     if ($query->num_rows() > 0) {
         $row = $query->result_array();
         return $row;
     } else {
         return false;
     }
 }
Esempio n. 6
0
 public function getTopKillChars($count, $realm)
 {
     // Initialize the connection
     $realm->getCharacters()->connect();
     $this->connection = $realm->getCharacters()->getConnection();
     if (column('characters', 'totalKills', $realm->getId())) {
         // Select character data
         $query = $this->connection->query("SELECT " . columns("characters", array('guid', 'race', 'class', 'gender', 'level', 'name', 'totalKills'), $realm->getId()) . " FROM " . table('characters', $realm->getId()) . " WHERE " . column('characters', 'totalKills') . " > 0 ORDER BY " . column('characters', 'totalKills', false, $realm->getId()) . " DESC LIMIT " . $count);
     } else {
         $query = $this->connection->query(query('pvp_character', $realm->getId()) . $count);
     }
     if ($this->connection->_error_message()) {
         die($this->connection->_error_message());
     }
     if ($query->num_rows() > 0) {
         return $query->result_array();
     } else {
         return false;
     }
 }
Esempio n. 7
0
 public function save($id, $external_account_data, $external_account_access_data, $internal_data)
 {
     if (column("account", "v") && column("account", "s") && column("account", "sessionkey")) {
         $external_account_data[column("account", "v")] = "";
         $external_account_data[column("account", "s")] = "";
         $external_account_data[column("account", "sessionkey")] = "";
     }
     $this->connection->where(column('account', 'id'), $id);
     $this->connection->update(table('account'), $external_account_data);
     if ($this->getAccessId($id)) {
         // Update external access
         $this->connection->where(column('account_access', 'id'), $id);
         $this->connection->update(table('account_access'), $external_account_access_data);
     } else {
         // Update external access
         $external_account_access_data[column('account_access', 'id')] = $id;
         $this->connection->insert(table('account_access'), $external_account_access_data);
     }
     // Update internal
     $this->db->where('id', $id);
     $this->db->update('account_data', $internal_data);
     $this->logger->createLog("Edited account", $this->user->getUsername($id) . " (" . $id . ")");
 }
Esempio n. 8
0
 public function close($realmId = false, $id = false)
 {
     requirePermission("answer");
     if (!$realmId || !$id || !is_numeric($id) || !is_numeric($realmId)) {
         die(lang("invalid", "gm"));
     }
     //Get the realm
     $realm = $this->realms->getRealm($realmId);
     //Get the ticket
     $ticket = $this->gm_model->getTicket($realm, $id);
     if (column("gm_tickets", "completed")) {
         //A row exists, update it
         $this->gm_model->setTicketCompleted($realm->getCharacters()->getConnection(), $id, $realm->getId());
         die('1');
     } else {
         //Remove it
         $this->gm_model->deleteTicket($realm->getCharacters()->getConnection(), $id, $realm->getId());
         die('1');
     }
     $this->plugins->onClose($realmId, $id);
 }
Esempio n. 9
0
 /**
  * Set the gold of a character
  * @param Int $account
  * @param Int $guid
  * @param Int $newGold
  * @return Boolean
  */
 public function setGold($account, $guid, $newGold)
 {
     $query = $this->db->query("UPDATE " . table("characters", $this->realmId) . " SET " . column("characters", "money", false, $this->realmId) . " = ? WHERE " . column("characters", "account", false, $this->realmId) . " = ? AND " . column("characters", "guid", false, $this->realmId) . " = ?", array($newGold, $account, $guid));
     if ($query) {
         return true;
     } else {
         return false;
     }
 }
 public function getGuildName($id)
 {
     if (!$id) {
         return '';
     } else {
         $this->connect();
         $query = $this->connection->query("SELECT " . column("guild", "name", true, $this->realmId) . " FROM " . table("guild", $this->realmId) . " WHERE " . column("guild", "guildid", false, $this->realmId) . "= ?", array($id));
         if ($query && $query->num_rows() > 0) {
             $row = $query->result_array();
             return $row[0]['name'];
         } else {
             return false;
         }
     }
 }
Esempio n. 11
0
    $SUBS['ID'] = $row[0];
    $SUBS['TITLE'] = column($row[1]);
    $SUBS['AKTUALNO'] .= fileParse('_index_kino.htmlt');
}
//usa
$query = "SELECT\t{$tbl_1d_films}.ID,\n\t\t\t{$tbl_1d_films}.OriginalTitle,\n\t\t\t{$tbl_1d_films}.tsUsaPremiere\n\t\t\t\n\t\tFROM {$tbl_1d_films}\n\t\t\n\t\tWHERE \t{$tbl_1d_films}.tsUsaPremiere <= (" . week() . "+604799)\n\t\t\t\tAND {$tbl_1d_films}.OriginalTitle != ''\n\t\t\t\tAND {$tbl_1d_films}.tsUSaPremiere != ''\n\t\t\n\t\tORDER BY\t({$tbl_1d_films}.tsUsaPremiere >= " . week() . ") DESC,\n\t\t\t{$tbl_1d_films}.tsUsaPremiere DESC,\n\t\t\t{$tbl_1d_films}.OriginalTitle ";
$result = runQuery($query, 'index.php()', 'GET_USA');
$SUBS['CMD'] = 'film';
$mark = 0;
while ($row = db_fetch_row($result)) {
    //usa zaglaviya
    if ($mark == 0) {
        $mark = $row[2];
    }
    if (week($mark) != week($row[2])) {
        break;
    }
    $SUBS['ID'] = $row[0];
    $SUBS['TITLE'] = column($row[1]);
    $SUBS['USA'] .= fileParse('_index_kino.htmlt');
}
//charts
$query = "SELECT\t{$tbl_1d_charts}.ID,\n\t\t\t{$tbl_1d_charts}.Title\n\t\t\t\n\t\tFROM {$tbl_1d_charts}\n\t\tLEFT JOIN {$tbl_1d_kino_charts}\n\t\t\tON {$tbl_1d_kino_charts}.ChartID = {$tbl_1d_charts}.ID\n\t\t\t\tAND {$tbl_1d_charts}.Type = 'kino'\n\t\tLEFT JOIN {$tbl_1d_videodvd_charts}\n\t\t\tON {$tbl_1d_videodvd_charts}.ChartID = {$tbl_1d_charts}.ID\n\t\t\t\tAND {$tbl_1d_charts}.Type = 'videodvd'\n\t\t\n\t\tWHERE ({$tbl_1d_kino_charts}.ID IS NOT NULL)\n\t\t\tOR ({$tbl_1d_videodvd_charts}.ID IS NOT NULL)\n\t\t\n\t\tGROUP BY {$tbl_1d_charts}.ID\n\t\tORDER BY\t{$tbl_1d_charts}.Type ";
$result = runQuery($query, 'index.php()', 'GET_CHARTS');
$SUBS['CMD'] = 'klasacia';
while ($row = db_fetch_row($result)) {
    //imenata na klasaciite
    $SUBS['ID'] = $row[0];
    $SUBS['TITLE'] = column($row[1]);
    $SUBS['CHARTS'] .= fileParse('_index_kino.htmlt');
}
<?php

if (version_compare(PHP_VERSION, '5.5.0') <= 0) {
    die('This example requires at least PHP version 5.5.0' . PHP_EOL . '    but you are only running version ' . PHP_VERSION . PHP_EOL);
}
include __DIR__ . '/classes/Bootstrap.php';
include __DIR__ . '/functions/map.php';
include __DIR__ . '/functions/column.php';
// Create our initial Generator to read the gpx file
$gpxFilename = __DIR__ . '/data/Roman_2015-11-23.gpx';
$gpxReader = new GpxReader\GpxHandler($gpxFilename);
// Set the mapper to calculate the distance between a trackpoint and the previous trackpoint
$distanceCalculator = new GpxReader\Helpers\DistanceCalculator();
// Iterate over the trackpoint set from the gpx file, mapping the distance and extracting only that property to display
foreach (column(map([$distanceCalculator, 'setDistance'], $gpxReader->getElements('trkpt')), 'distance') as $key => $value) {
    printf('%d => %5.2f' . PHP_EOL, $key, $value);
}
Esempio n. 13
0
 public function loadMember($realmId, $memberId)
 {
     $realm = $this->realms->getRealm($realmId);
     $data = $realm->getCharacters()->getCharacters(columns("characters", array("guid", "name", "race", "class", "gender", "level"), $realmId), array(column("characters", "guid", false, $realmId) => $memberId));
     return $data[0];
 }
Esempio n. 14
0
 public function save($id = false)
 {
     if (!hasPermission("editAccounts")) {
         die("UI.alert('You do not have permission to edit accounts')");
     }
     if (!$id || !is_numeric($id)) {
         die;
     }
     $external_account_data[column("account", "expansion")] = $this->input->post("expansion");
     $external_account_data[column("account", "email")] = $this->input->post("email");
     if (hasPermission("editPermissions")) {
         $this->acl_model->removePermissionsFromUser($id);
         foreach ($_POST as $k => $v) {
             if ($v !== '' && !in_array($k, array("vp", "dp", "nickname", "email", "group", "expansion", "password", "gm_level"))) {
                 $permissionParts = explode("-", $k);
                 // UserID, permissionName, moduleName
                 $this->acl_model->assignPermissionToUser($id, $permissionParts[1], $permissionParts[0], $v);
             }
         }
     }
     // Make sure to check if we got something filled in here.
     if ($this->input->post("password")) {
         $external_account_data[column("account", "password")] = $this->realms->getEmulator()->encrypt($this->user->getUsername($id), $this->input->post("password"));
     }
     $external_account_access_data[column("account_access", "gmlevel")] = $this->input->post("gm_level");
     $internal_account_data["vp"] = $this->input->post("vp");
     $internal_account_data["dp"] = $this->input->post("dp");
     $internal_account_data["nickname"] = $this->input->post("nickname");
     if (!$external_account_data[column("account", "email")] || !$internal_account_data["nickname"]) {
         die("UI.alert('The following fields can\\'t be empty: [email]')");
     }
     $this->accounts_model->save($id, $external_account_data, $external_account_access_data, $internal_account_data);
     die('UI.alert("The account has been saved")');
 }
Esempio n. 15
0
echo GENERATE_STYLE;
echo '<table cellspacing="0">
<tr>';
$column = 0;
$row = 0;
for ($i = $_POST['from']; $i < $_POST['from'] + 44; $i++) {
    $i = trim($i);
    if (!ctype_digit($i) or empty($i) or strlen($i) > 8) {
        continue;
    }
    validate::KOD($i);
    while (true) {
        if (!$_POST['no_' . $row . '_' . $column]) {
            break;
        } else {
            echo '<td></td>';
            column($column, $row);
            continue;
        }
    }
    $kod = str_pad($i, 8, '0', STR_PAD_LEFT);
    echo '<td style="padding-left: ' . margin($column % 4) . 'mm;">
<img src="data:image/gif;base64,' . base64_encode(kod($kod)) . '" alt=""><br>' . $kod . '
</td>
';
    column($column, $row);
}
while (true) {
    column($column, $row);
}
echo GENERATE_END;
Esempio n. 16
0
 public function setLocation($x, $y, $z, $o, $mapId, $characterGuid, $realmConnection)
 {
     $realmConnection->query("UPDATE " . table("characters") . " SET " . column("characters", "position_x") . " = ?, " . column("characters", "position_y") . " = ?, " . column("characters", "position_z") . " = ?, " . column("characters", "orientation") . " = ?, " . column("characters", "map") . " = ? WHERE " . column("characters", "guid") . " = ?", array($x, $y, $z, $o, $mapId, $characterGuid));
 }
Esempio n. 17
0
 public function getEmail($id = false)
 {
     if ($id == false) {
         return $this->email;
     } else {
         // Check if it has been loaded already
         if (array_key_exists($id, $this->account_cache)) {
             return $this->account_cache[$id]['email'];
         } else {
             $this->connect();
             $this->connection->select(column("account", "username", true) . ',' . column("account", "email") . ',' . column("account", "joindate"))->from(table("account"))->where(array(column("account", "id") => $id));
             $query = $this->connection->get();
             if ($query->num_rows() > 0) {
                 $result = $query->result_array();
                 $this->account_cache[$id] = $result[0];
                 return $result[0]["email"];
             } else {
                 $this->account_cache[$id]["email"] = false;
                 return false;
             }
         }
     }
 }
Esempio n. 18
0
 public function save($id = false)
 {
     if (!hasPermission("editAccounts")) {
         die("UI.alert('شما دسترسی برای ویرایش اکانت ا ندارید')");
     }
     if (!$id || !is_numeric($id)) {
         die;
     }
     $external_account_data[column("account", "expansion")] = $this->input->post("expansion");
     $external_account_data[column("account", "email")] = $this->input->post("email");
     if (hasPermission("editPermissions")) {
         $this->acl_model->removePermissionsFromUser($id);
         foreach ($_POST as $k => $v) {
             if ($v !== '' && !in_array($k, array("vp", "dp", "nickname", "email", "group", "expansion", "password", "gm_level"))) {
                 $permissionParts = explode("-", $k);
                 // UserID, permissionName, moduleName
                 $this->acl_model->assignPermissionToUser($id, $permissionParts[1], $permissionParts[0], $v);
             }
         }
     }
     // Make sure to check if we got something filled in here.
     if ($this->input->post("password")) {
         $external_account_data[column("account", "password")] = $this->realms->getEmulator()->encrypt($this->user->getUsername($id), $this->input->post("password"));
     }
     $external_account_access_data[column("account_access", "gmlevel")] = $this->input->post("gm_level");
     $internal_account_data["vp"] = $this->input->post("vp");
     $internal_account_data["dp"] = $this->input->post("dp");
     $internal_account_data["nickname"] = $this->input->post("nickname");
     if (!$external_account_data[column("account", "email")] || !$internal_account_data["nickname"]) {
         die("UI.alert('هیچ جایی نباید خالی بماند')");
     }
     $this->accounts_model->save($id, $external_account_data, $external_account_access_data, $internal_account_data);
     die('UI.alert("اکانت با موفقیت ذخیره شد")');
 }
Esempio n. 19
0
 public function updateBan($realmdConnection, $accountId, $bannedBy, $banReason, $banTimeInDays)
 {
     if ($realmdConnection && $accountId && $bannedBy && $banReason) {
         if (column("account_banned", "banreason") && column("account_banned", "bandate")) {
             //Check if it go the banreason and bandate
             $realmdConnection->query("UPDATE " . table("account_banned") . " SET " . column("account_banned", "bandate") . " = ?, " . column("account_banned", "unbandate") . " = ?, " . column("account_banned", "bannedby") . " = ?, " . column("account_banned", "banreason") . " = ?, " . column("account_banned", "active") . " = 1 WHERE " . column("account_banned", "id") . " = ?", array(time(), time() + $banTimeInDays, $bannedBy, $banReason, $accountId));
         } else {
             if (column("account_banned", "banreason") && !column("account_banned", "bandate")) {
                 //Check if it got only banreason
                 $realmdConnection->query("UPDATE " . table("account_banned") . " SET " . column("account_banned", "banreason") . " = ?, " . column("account_banned", "active") . " = 1 WHERE " . column("account_banned", "id") . " = ?", array(time(), time() + $banTimeInDays, $bannedBy, $banReason, $accountId));
             } else {
                 //Else it doesnt got the banreason and bandate
                 $realmdConnection->query("UPDATE " . table("account_banned") . " SET " . column("account_banned", "active") . " = 1 WHERE " . column("account_banned", "id") . " = ?", array(time(), time() + $banTimeInDays, $bannedBy, $banReason, $accountId));
             }
         }
     } else {
         return false;
     }
 }
Esempio n. 20
0
 function section_heading_row($what, $class = null)
 {
     return row(column(section_heading($what)), $class);
 }
Esempio n. 21
0
    <head>
        <title>Functions</title>
    </head>
    <body>
        <h1>functions</h1>
        <?php 
function column()
{
    ?>
            <td>column</td>
        <?php 
}
?>
        <?php 
for ($i = 0; $i < 10; $i++) {
    column();
}
?>
        
    </body>
</html>

<?php 
// nested function
function before($str_b4)
{
    echo "1 {$str_b4} ";
    function after($str_af)
    {
        echo "3 {$str_b4} ";
        echo "4 {$str_af} ";