/**
  * Initializes list with player bans filtering.
  * 
  * @version 0.1.5
  * @since 0.1.5
  */
 public function __construct()
 {
     parent::__construct();
     // filters only account bans
     $filter = new OTS_SQLFilter();
     $filter->addFilter(new OTS_SQLField('type', 'bans'), POT::BAN_PLAYER);
     $this->setFilter($filter);
 }
 /**
  * @version 0.1.5
  * @since 0.1.3
  * @return OTS_Accounts_List Filtered list.
  * @deprecated 0.1.5 Use OTS_AccountBans_List.
  */
 public static function bannedAccounts()
 {
     // creates filter
     $filter = new OTS_SQLFilter();
     $filter->addFilter(new OTS_SQLField('type', 'bans'), POT::BAN_ACCOUNT);
     $filter->addFilter(new OTS_SQLField('active', 'bans'), 1);
     $filter->addFilter(new OTS_SQLField('value', 'bans'), new OTS_SQLField('id', 'accounts'));
     // selects only active bans
     $actives = new OTS_SQLFilter();
     $actives->addFilter(new OTS_SQLField('expires', 'bans'), 0);
     $actives->addFilter(new OTS_SQLField('time', 'bans'), time(), OTS_SQLFilter::OPERATOR_GREATER, OTS_SQLFilter::CRITERIUM_OR);
     $filter->addFilter($actives);
     // creates list and aplies filter
     $list = new OTS_Accounts_List();
     $list->setFilter($filter);
     return $list;
 }
 /**
  * Returns generic SQL query that can be adaptated by child classes.
  * 
  * @version 0.1.5
  * @since 0.1.5
  * @param array $fields Fields to be selected.
  * @param bool $count Shows if the SQL should be generated for COUNT() variant.
  * @return string SQL query.
  */
 protected function prepareSQL($fields, $count = false)
 {
     $tables = array();
     // generates tables list for current qeury
     if (isset($this->filter)) {
         $tables = $this->filter->getTables();
     }
     // adds default table
     if (!in_array($this->table, $tables)) {
         $tables[] = $this->table;
     }
     // prepares tables names
     foreach ($tables as &$name) {
         $name = $this->db->tableName($name);
     }
     // WHERE clause
     if (isset($this->filter)) {
         $where = ' WHERE ' . $this->filter->__toString();
     } else {
         $where = '';
     }
     // ORDER BY clause
     if ($count || empty($this->orderBy)) {
         $orderBy = '';
     } else {
         $orderBy = array();
         foreach ($this->orderBy as $criterium) {
             switch ($criterium['order']) {
                 case POT::ORDER_ASC:
                     $orderBy[] = $criterium['field'] . ' ASC';
                     break;
                 case POT::ORDER_DESC:
                     $orderBy[] = $criterium['field'] . ' DESC';
                     break;
             }
         }
         $orderBy = ' ORDER BY ' . implode(', ', $orderBy);
     }
     return 'SELECT ' . implode(', ', $fields) . ' FROM ' . implode(', ', $tables) . $where . $orderBy . $this->db->limit($this->limit, $this->offset);
 }
Example #4
0
<?php

// to not repeat all that stuff
include 'quickstart.php';
// creates new players list object
$players = new OTS_Players_List();
// creates filter
$filter = new OTS_SQLFilter();
// sets filter to choose only players with level 8
$filter->compareField('level', 8);
// sets filter on list
$players->setFilter($filter);
// iterates throught selected players
foreach ($players as $index => $player) {
    echo $player->getName(), "\n";
}
 /**
  * List of characters on account.
  * 
  * <p>
  * In difference to {@link OTS_Account::getPlayers() getPlayers() method} this method returns filtered {@link OTS_Players_List OTS_Players_List} object instead of array of {@link OTS_Player OTS_Player} objects. It is more effective since OTS_Player_List doesn't perform all rows loading at once.
  * </p>
  * 
  * <p>
  * Note: Returned object is only prepared, but not initialised. When using as parameter in foreach loop it doesn't matter since it will return it's iterator, but if you will wan't to execute direct operation on that object you will need to call {@link OTS_Base_List::rewind() rewind() method} first.
  * </p>
  * 
  * @version 0.1.4
  * @since 0.0.5
  * @return OTS_Players_List List of players from current account.
  * @throws E_OTS_NotLoaded If account is not loaded.
  */
 public function getPlayersList()
 {
     if (!isset($this->data['id'])) {
         throw new E_OTS_NotLoaded();
     }
     // creates filter
     $filter = new OTS_SQLFilter();
     $filter->compareField('account_id', (int) $this->data['id']);
     // creates list object
     $list = new OTS_Players_List();
     $list->setFilter($filter);
     return $list;
 }
Example #6
0
    foreach ($config['site']['worlds'] as $id => $world_n) {
        $main_content .= '<OPTION VALUE="' . $id . '">' . $world_n . '</OPTION>';
    }
    $main_content .= '</SELECT> </TD><TD><INPUT TYPE=image NAME="Submit" ALT="Submit" SRC="' . $layout_name . '/images/buttons/sbutton_submit.gif">
        </TD></TR></TABLE></TABLE></FORM></TABLE>';
    foreach ($config['site']['worlds'] as $idd => $world_n) {
        if ($idd == (int) $_REQUEST['world']) {
            $world_id = $idd;
            $world_name = $world_n;
        }
    }
    if (!isset($world_id)) {
        $world_id = 0;
        $world_name = $config['server']['serverName'];
    }
    $filter = new OTS_SQLFilter();
    $filter->compareField('world_id', (int) $world_id);
    $guilds_list = $ots->createObject('Guilds_List');
    $guilds_list->setFilter($filter);
    $guilds_list->orderBy('name');
    $main_content .= '<h2><center><i>World:</i> ' . $world_name . '</center></h2><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
	<TR BGCOLOR=' . $config['site']['vdarkborder'] . '><TD COLSPAN=3 CLASS=white><B>Guilds on ' . $world_name . '</B></TD></TR>
	<TR BGCOLOR=' . $config['site']['darkborder'] . '><TD WIDTH=64><B>Logo</B></TD>
	<TD WIDTH=100%><B>Description</B></TD>
	<TD WIDTH=56><B>&#160;</B></TD></TR>';
    $showed_guilds = 1;
    if (count($guilds_list) > 0) {
        foreach ($guilds_list as $guild) {
            if (is_int($showed_guilds / 2)) {
                $bgcolor = $config['site']['darkborder'];
            } else {
Example #7
0
 /**
  * Returns list of VIPs.
  * 
  * <p>
  * It means list of players which this player have on his/her list.
  * </p>
  * 
  * @version 0.1.3
  * @since 0.1.3
  * @return OTS_Players_List List of VIPs.
  * @throws E_OTS_NotLoaded If player is not loaded.
  * @throws PDOException On PDO operation error.
  */
 public function getVIPsList()
 {
     if (!isset($this->data['id'])) {
         throw new E_OTS_NotLoaded();
     }
     $list = new OTS_Players_List();
     // foreign table fields identifiers
     $field1 = new OTS_SQLField('player_id', 'player_viplist');
     $field2 = new OTS_SQLField('vip_id', 'player_viplist');
     // creates filter
     $filter = new OTS_SQLFilter();
     $filter->addFilter($field1, $this->data['id']);
     $filter->compareField('id', $field2);
     // puts filter onto list
     $list->setFilter($filter);
     return $list;
 }
Example #8
0
<?php

// to not repeat all that stuff
include 'quickstart.php';
// creates new players list object
$players = new OTS_Players_List();
// creates filter
$filter = new OTS_SQLFilter();
// selects player whose rank belongs to guild with ID 5
$filter->addFilter(new OTS_SQLField('rank_id', 'players'), new OTS_SQLField('id', 'ranks'));
$filter->addFilter(new OTS_SQLField('guild_id', 'ranks'), 5);
// sets filter on list
$players->setFilter($filter);
// iterates throught selected players
foreach ($players as $index => $player) {
    echo $player->getName(), "\n";
}
Example #9
0
<?php

// to not repeat all that stuff
include 'quickstart.php';
// creates new players list object
$players = new OTS_Players_List();
// creates filter
$filter = new OTS_SQLFilter();
// sets filter to choose players with capacity equal to hit points
$filter->addFilter(new OTS_SQLField('cap'), new OTS_SQLField('health'));
// another filter
$sub = new OTS_SQLFilter();
// only players with level 8 and higher...
$sub->compareField('level', 8, OTS_SQLFilter::OPERATOR_NLOWER);
// ... OR magic level 5 and higher
$sub->compareField('maglevel', 5, OTS_SQLFilter::OPERATOR_NLOWER, OTS_SQLFilter::CRITERIUM_OR);
// final result is:
// "cap" = "health" AND ("level" = 8 OR "maglevel" = 5)
$filter->addFilter($sub);
// sets filter on list
$players->setFilter($filter);
// iterates throught selected players
foreach ($players as $index => $player) {
    echo $player->getName(), "\n";
}
Example #10
0
 /**
  * Returns list of killers.
  * 
  * @version 0.2.0+SVN
  * @since 0.2.0+SVN
  * @return OTS_Kills_List List of killers.
  * @throws E_OTS_NotLoaded If death is not loaded.
  * @throws PDOException On PDO operation error.
  */
 public function getKillsList()
 {
     if (!isset($this->data['id'])) {
         throw new E_OTS_NotLoaded();
     }
     // creates filter
     $filter = new OTS_SQLFilter();
     $filter->compareField('death_id', (int) $this->data['id']);
     // puts filter onto list
     $list = new OTS_Kills_List();
     $list->setFilter($filter);
     return $list;
 }