示例#1
0
 public function createGuild($name, $character)
 {
     $ots = POT::getInstance();
     $ots->connect(POT::DB_MYSQL, connection());
     $player = new OTS_Player();
     $player->load($character);
     $new_guild = new OTS_Guild();
     $new_guild->setCreationData(time());
     $new_guild->setName($name);
     $new_guild->setOwner($player);
     $new_guild->save();
     $new_guild->setCustomField('motd', 'New guild. Leader must edit this text :)');
     $new_guild->setCustomField('creationdata', time());
     $new_guild->setCustomField('world_id', $player->getWorld());
     $ranks = $new_guild->getGuildRanksList();
     $ranks->orderBy('level', POT::ORDER_DESC);
     foreach ($ranks as $rank) {
         if ($rank->getLevel() == 3) {
             $player->setRank($rank);
             $player->save();
         }
     }
     $ide = new IDE();
     $ide->redirect(WEBSITE . "/index.php/guilds/view/" . $new_guild->getId());
     success("{$name} has been created.");
 }
示例#2
0
 function create()
 {
     $ide = new IDE();
     if ($ide->isLogged()) {
         $ide->redirect('../account');
     }
     $this->load->helper('form');
     if ($_POST) {
         $this->load->library('form_validation');
         $this->form_validation->set_rules('name', 'Account Name', 'required|min_length[4]|max_length[32]|callback__account_exists|alpha');
         $this->form_validation->set_rules('password', 'Password', 'required|matches[repeat]|min_length[4]|max_length[255]');
         $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
         if ($this->form_validation->run() == TRUE) {
             require APPPATH . 'config/ide_default.php';
             $ots = POT::getInstance();
             $ots->connect(POT::DB_MYSQL, connection());
             $account = new OTS_Account();
             $name = $account->createNamed($_POST['name']);
             $account->setPassword($_POST['password']);
             $account->setEmail($_POST['email']);
             $account->setCustomField('premdays', PREMDAYS);
             try {
                 $account->save();
                 $_SESSION['logged'] = 1;
                 $_SESSION['name'] = $_POST['name'];
                 $ide->redirect('../account');
             } catch (Exception $e) {
                 error($e->getMessage());
             }
         }
     }
     #Load view of creating account
     $this->load->view('create');
 }
示例#3
0
 public function join($guild_name, $player_name)
 {
     $guild_name = (int) $guild_name;
     $player_name = (int) $player_name;
     $ide = new IDE();
     if (empty($guild_name) or empty($player_name)) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     $ots = POT::getInstance();
     $ots->connect(POT::DB_MYSQL, connection());
     $guild = $ots->createObject('Guild');
     $guild->load($guild_name);
     if (!$guild->isLoaded()) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     $player = new OTS_Player();
     $player->load($player_name);
     if (!$player->isLoaded()) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     if ($player->getAccount()->getId() != $_SESSION['account_id']) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     require_once 'system/application/libraries/POT/InvitesDriver.php';
     new InvitesDriver($guild);
     $invited_list = $guild->listInvites();
     if (!in_array($player->getId(), $invited_list)) {
         $ide->redirect(WEBSITE . "/index.php/guilds");
     }
     $guild->acceptInvite($player);
     $ide->redirect(WEBSITE . "/index.php/guilds/view/" . $guild->getId() . "/1");
 }
示例#4
0
 /**
  * Returns string representation of object.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method.
  * </p>
  * 
  * @version 0.2.0+SVN
  * @since 0.2.0b+SVN
  * @return string String representation of object.
  */
 public function __toString()
 {
     // checks if display driver is loaded
     if (POT::isDisplayDriverLoaded()) {
         return POT::getDisplayDriver()->displayAuctionsList($this);
     }
     return (string) $this->count();
 }
示例#5
0
 /**
  * Returns string representation of object.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method.
  * </p>
  * 
  * @version 0.1.3
  * @since 0.1.0
  * @return string String representation of object.
  */
 public function __toString()
 {
     $ots = POT::getInstance();
     // checks if display driver is loaded
     if ($ots->isDisplayDriverLoaded()) {
         return $ots->getDisplayDriver()->displayAccountsList($this);
     }
     return (string) $this->count();
 }
 public function __construct(OTS_Guild $guild)
 {
     $this->guild = $guild;
     $this->db = POT::getInstance()->getDBHandle();
     $this->guild->invitesDriver = $this;
 }
 /**
  * Magic PHP5 method.
  * 
  * <p>
  * Allows object unserialisation.
  * </p>
  */
 public function __wakeup()
 {
     $this->db = POT::getInstance()->getDBHandle();
 }
示例#8
0
 /**
  * Returns string representation for WHERE clause.
  * 
  * <p>
  * Returned string can be easily inserted into SQL query.
  * </p>
  * 
  * @version 0.1.0
  * @since 0.1.0
  * @return string String WHERE clause.
  */
 public function __toString()
 {
     // database handle
     $db = POT::getInstance()->getDBHandle();
     // basic name
     $name = $db->fieldName($this->name);
     // prepends table name
     if (!empty($this->table)) {
         $name = $db->tableName($this->table) . '.' . $name;
     }
     return $name;
 }
示例#9
0
 /**
  * Returns string representation of XML.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method. Otherwise just returns monster XML content.
  * </p>
  * 
  * @version 0.1.3
  * @since 0.1.0
  * @return string String representation of object.
  */
 public function __toString()
 {
     $ots = POT::getInstance();
     // checks if display driver is loaded
     if ($ots->isDataDisplayDriverLoaded()) {
         return $ots->getDataDisplayDriver()->displayMonster($this);
     }
     return $this->saveXML();
 }
示例#10
0
 public function view($name = null)
 {
     $ide = new IDE();
     if (!empty($name)) {
         $data['character'] = $name;
         $ots = POT::getInstance();
         $ots->connect(POT::DB_MYSQL, connection());
         $player = $ots->createObject('Player');
         $player->find($name);
         if (!$player->isLoaded()) {
             $ide->redirect("../../character/view/");
         } else {
             $data['player'] = $player;
             $data['account'] = $player->getAccount();
         }
         $this->load->view('view_character.php', $data);
     } else {
         $this->load->helper("form");
         if ($_POST) {
             $name = $_POST['name'];
             $ots = POT::getInstance();
             $ots->connect(POT::DB_MYSQL, connection());
             $player = new OTS_Player();
             $player->find($name);
             if ($player->isLoaded()) {
                 $ide->redirect("../character/view/{$name}");
             } else {
                 error("{$name} could not be found.");
             }
         }
         $this->load->view('character_search.php');
     }
 }
示例#11
0
class RequestsDriver implements IOTS_GuildAction
{
}
/*
    Standard binary format cache.
*/
class FileCache implements IOTS_FileCache
{
}
/*
    Items cache driver.
*/
class ItemsCache implements IOTS_ItemsCache
{
}
/*
    Database objects display driver.
*/
class DisplayDriver implements IOTS_Display
{
}
/*
    Display driver for data/ directory resources.
*/
class DataDisplayDriver implements IOTS_DataDisplay
{
}
// sets display drivers for current enviroment
POT::setDisplayDriver(new DisplayDriver());
POT::setDataDisplayDriver(new DataDisplayDriver());
示例#12
0
 /**
  * Returns string representation of XML.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method. Otherwise just returns monster XML content.
  * </p>
  * 
  * @version 0.2.0+SVN
  * @since 0.1.0
  * @return string String representation of object.
  */
 public function __toString()
 {
     // checks if display driver is loaded
     if (POT::isDataDisplayDriverLoaded()) {
         return POT::getDataDisplayDriver()->displayMonster($this);
     }
     return $this->saveXML();
 }
示例#13
0
if (isset($server_config['mysqlHost'])) {
    //new (0.2.6+) ots config.lua file
    $mysqlhost = $server_config['mysqlHost'];
    $mysqluser = $server_config['mysqlUser'];
    $mysqlpass = $server_config['mysqlPass'];
    $mysqldatabase = $server_config['mysqlDatabase'];
    $sqlitefile = $server_config['sqliteDatabase'];
} elseif (isset($server_config['sqlHost'])) {
    //old (0.2.4) ots config.lua file
    $mysqlhost = $server_config['sqlHost'];
    $mysqluser = $server_config['sqlUser'];
    $mysqlpass = $server_config['sqlPass'];
    $mysqldatabase = $server_config['sqlDatabase'];
    $sqlitefile = $server_config['sqliteDatabase'];
}
// loads #####POT mainfile#####
include '../pot/OTS.php';
// PDO and POT connects to database
$ots = POT::getInstance();
if ($server_config['sqlType'] == "mysql") {
    $ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase));
} elseif ($server_config['sqlType'] == "sqlite") {
    $ots->connect(POT::DB_SQLITE, array('database' => $config_ini['server_path'] . $sqlitefile));
}
$name_db = new OTS_Player();
$name_db->find($name);
if ($name_db->isLoaded()) {
    echo '<font color="red"><b>Já existe um personagem com esse nome.</b></font>';
} else {
    echo '<font color="green">O seu nome será: "<b>' . ucwords($name) . '</b>"</font>';
}
示例#14
0
 /**
  * Returns string representation of XML.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method. Otherwise just returns spell XML format.
  * </p>
  * 
  * @version 0.1.3
  * @since 0.1.0
  * @return string String representation of object.
  */
 public function __toString()
 {
     $ots = POT::getInstance();
     // checks if display driver is loaded
     if ($ots->isDataDisplayDriverLoaded()) {
         return $ots->getDataDisplayDriver()->displaySpell($this);
     }
     return $this->element->ownerDocument->saveXML($this->element);
 }
示例#15
0
<?php

// this is the way you should work with POT if you moved main OTS.php file outside POT's directory
include 'path/to/OTS.php';
// dont use 'new POT()'!!!
// dont use POT::getInstance() anymore
POT::setPOTPath('classes');
/*
    here comes your stuff...
*/
示例#16
0
文件: multidb.php 项目: Tobbebror/POT
<?php

// includes POT main file
include_once 'classes/OTS.php';
// define database ids
define(DB_OTSERV1, 100);
define(DB_OTSERV2, 101);
// Config of first database
$config_db1 = array('driver' => POT::DB_MYSQL, 'prefix' => '', 'host' => 'localhost', 'user' => 'wrzasq', 'password' => '', 'database' => 'otserv1');
// Config of second database
$config_db2 = array('driver' => POT::DB_MYSQL, 'prefix' => '', 'host' => 'localhost', 'user' => 'wrzasq', 'password' => '', 'database' => 'otserv2');
// Catch PDO Exceptions!
try {
    // Set the database we want to use
    POT::setCurrentDB(DB_OTSERV1);
    POT::connect(null, $config_db1);
    // Change to another ID to connect
    POT::setCurrentDB(DB_OTSERV2);
    POT::connect(null, $config_db2);
} catch (Exception $e) {
    var_dump($e->getMessage());
}
// To use a database you must set it with POT::setCurrentDB(DB_ID)
POT::setCurrentDB(DB_OTSERV1);
// Then you can get the DB Handle
$ot_db = POT::getDBHandle();
// ... and use it!
示例#17
0
文件: OTS.php 项目: Tobbebror/POT
 /**
  * Sets display driver for non-database resources.
  * 
  * <p>
  * Note: Since 0.2.0+SVN this method is static.
  * </p>
  * 
  * @version 0.2.0+SVN
  * @since 0.1.3
  * @param IOTS_DataDisplay $dataDisplay Display driver.
  */
 public static function setDataDisplayDriver(IOTS_DataDisplay $dataDisplay)
 {
     self::$dataDisplay = $dataDisplay;
 }
示例#18
0
 /**
  * Returns string representation of object.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method. Else it returns group name.
  * </p>
  * 
  * @version 0.1.3
  * @since 0.1.0
  * @return string String representation of object.
  */
 public function __toString()
 {
     $ots = POT::getInstance();
     // checks if display driver is loaded
     if ($ots->isDisplayDriverLoaded()) {
         return $ots->getDisplayDriver()->displayGroup($this);
     }
     return $this->getName();
 }
示例#19
0
<?php

// includes POT main file
include_once 'classes/OTS.php';
// database configuration - can be simply moved to external file, eg. config.php
$config = array('driver' => POT::DB_MYSQL, 'host' => 'localhost', 'user' => 'wrzasq', 'database' => 'otserv');
// creates POT instance (or get existing one)
// dont use POT::getInstance() anymore
POT::connect(null, $config);
// could be: POT::connect(POT::DB_MYSQL, $config);
示例#20
0
文件: items.php 项目: Tobbebror/POT
<?php

// to not repeat all that stuff
include 'quickstart.php';
// loads item typing information
// dont use POT::getInstance() anymore
POT::loadItems('/path/to/your/ots/data/items');
// creates new player object
$player = new OTS_Player();
$player->find('Wrzasq');
/*
    Items loading example.
*/
// loading item from ammunition slot
$item = $player->getSlot(POT::SLOT_AMMO);
echo $player->getName(), ' has item with id ', $item->getId(), ' in his/her ammo slot.', "\n";
// checks if item is a container
if ($item instanceof OTS_Container) {
    // list backpack content
    foreach ($item as $inside) {
        echo 'Container contains item with id ', $inside->getId(), '.', "\n";
    }
}
/*
    Items tree composing example.
*/
// creates container - here it would be a depot locker (we pass ID of item to create)
$container = new OTS_Container(2590);
// now let's create depot chest
$chest = new OTS_Container(2594);
// let's put chest inside locker
示例#21
0
 /**
  * Returns string representation of object.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method. Else it returns group name.
  * </p>
  * 
  * @version 0.2.0+SVN
  * @since 0.1.0
  * @return string String representation of object.
  */
 public function __toString()
 {
     // checks if display driver is loaded
     if (POT::isDisplayDriverLoaded()) {
         return POT::getDisplayDriver()->displayGroup($this);
     }
     return $this->getName();
 }
示例#22
0
文件: install.php 项目: s3kk/Gesior
             echo 'Database error - can\'t connect to MySQL database. Possible reasons:<br>1. MySQL server is not running on host.<br>2. MySQL user, password, database or host isn\'t configured in: <b>' . $config['site']['server_path'] . 'config.lua</b> .<br>3. MySQL user, password, database or host is wrong.';
             exit;
         }
     } elseif (strtolower($config['server']['sqlType']) == "sqlite") {
         $link_to_sqlitedatabase = $config['site']['server_path'] . $sqlitefile;
         try {
             $ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
         } catch (PDOException $error) {
             echo 'Database error - can\'t open SQLite database. Possible reasons:<br><b>' . $link_to_sqlitedatabase . '</b> - file isn\'t valid SQLite database.<br><b>' . $link_to_sqlitedatabase . '</b> - doesn\'t exist.';
             exit;
         }
     } else {
         echo 'Database error. Unknown database type in <b>' . $config['site']['server_path'] . 'config.lua</b> . Must be equal to: "<b>mysql</b>" or "<b>sqlite</b>". Now is: "<b>' . strtolower($config['server']['sqlType']) . '"</b>';
         exit;
     }
     $SQL = POT::getInstance()->getDBHandle();
     $config['site']['install'] = 3;
     saveconfig_ini($config['site']);
 }
 if ($step == '3') {
     echo '<h1>STEP ' . $step . '</h1>Add tables and columns to DB<br>';
     echo 'Installer try to add new tables and columns to database.<br>';
     $config['server'] = parse_ini_file($config['site']['server_path'] . 'config.lua');
     if ($config['server']['sqlType'] == "sqlite") {
         try {
             $SQL->query('ALTER TABLE accounts ADD "key" VARCHAR(255) NOT NULL DEFAULT "";');
         } catch (PDOException $error) {
         }
         try {
             $SQL->query('ALTER TABLE accounts ADD "page_lastday" INTEGER(11) NOT NULL DEFAULT 0;');
         } catch (PDOException $error) {
示例#23
0
 /**
  * Returns type of item.
  * 
  * @version 0.1.0
  * @since 0.1.0
  * @return OTS_ItemType Returns item type of item (null if not exists).
  * @throws E_OTS_NotLoaded If global items list wasn't loaded.
  */
 public function getItemType()
 {
     return POT::getInstance()->getItemsList()->getItemType($this->id);
 }
示例#24
0
文件: schema.php 项目: Tobbebror/POT
<?php

// to not repeat all that stuff
include 'quickstart.php';
// fetches schema info
$info = POT::getSchemaInfo();
// displays database version
echo 'Your database structure version is: ', $info['version'];
示例#25
0
 /**
  * Returns string representation of object.
  * 
  * <p>
  * If any display driver is currently loaded then it uses it's method. Otherwise just returns item ID.
  * </p>
  * 
  * @version 0.2.0+SVN
  * @since 0.1.3
  * @return string String representation of object.
  */
 public function __toString()
 {
     // checks if display driver is loaded
     if (POT::isDataDisplayDriverLoaded()) {
         return POT::getDataDisplayDriver()->displayItemType($this);
     }
     return $this->getId();
 }
示例#26
0
 /**
  * @ignore
  */
 function __autoload($class)
 {
     POT::getInstance()->loadClass($class);
 }
示例#27
0
 /**
  * Fetch an item color from cache or OTB.
  *
  * @param $itemid
  * @return false|array RGB
  */
 public static function itemColor($itemid)
 {
     if (!isset(self::$items[$itemid])) {
         if (!\POT::areItemsLoaded()) {
             \POT::loadItems(public_path() . '/xml');
         }
         $list = \POT::getItemsList();
         if ($list->hasItemTypeId($itemid)) {
             $item = $list->getItemType($itemid);
             if ($item->hasAttribute('minimapColor')) {
                 self::$items[$itemid] = self::$rgbs[$item->getAttribute('minimapColor')];
             }
         }
         if (!isset(self::$items[$itemid])) {
             self::$items[$itemid] = false;
         }
     }
     return self::$items[$itemid];
 }