Ir para conteúdo
  • Cadastre-se

Gesior AAC Como criar um site para seu servidor!


Posts Recomendados

Daai o gesior-aac-0.6.3

ta bugadoo . posta ele dinovo ae plix . :hum: xega no final dps que copia a pasta do gesior-aac-0.6.3 dali pra frente nao da mais olha so oq dar

quem poder mim ajudar olha so >>> Warning: include(pot/OTS.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\upload\install\install.php on line 86

Warning: include() [function.include]: Failed opening 'pot/OTS.php' for inclusion (include_path='.;C:\xampp\php\pear\:../libs') in C:\xampp\htdocs\upload\install\install.php on line86

Fatal error: Class 'POT' not found in C:\xampp\htdocs\upload\install\install.php on line 88

xammp 1.7.3

Matheus

o meu só da assim nem sei mais oq eu faço

Can't connect to MySQL database.

reveja seu config. lua pra ver se a senha e o nome da DB ta certa


Regras Gerais 

 

"Califórnia Brasileira :cool: "

Link para o post
Compartilhar em outros sites
  • Respostas 357
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Mano Meu Mysql Desliga Po sozinho aparece umas coisa ele desliga sozinho , e o Apache fika aparecendo umas coisa tbm So que Nao Desliga Tipo desse daki \/ Php Startup> Mcrypt Unable To Initi

Bom, o tutorial está bom, mais creio que você limitou o xampp, pode ser qualquer versão, é só saber corrigir os erros no php.ini. Alguns erros cometidos, como FileZilla, porque você irá ativar e dei

Bacana Matheus. O audio dessa vez não ficou tão bom quanto o do vídeo anterior,mas mesmo assim ta bom! Reputado. Abraços.

Posted Images

afff da esse erro quando termino de estala o xampp >> Não foi possivel localizar o ponto de entrada do procedimento php_end_ob_buffers na biblioteca de vínculo dinâmico php5ts.dll ,,, sera q alguem poderia me ajuda por favor dou REP+

Editado por schulz2012 (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • 2 weeks later...

Matheus, mano eu fiz isso tudo certinho pegou o site, mas tem o porem, ele nao funcionou no meu ip só ?

tem algum video tutorial mais completão ai com site esse q vc fez pra glr e como abrir o otserv sem erros?

agradeço ai mano :D

Link para o post
Compartilhar em outros sites

Fala galerinha, sei que muitos não sabem criar um website para seu servidor e usam o Account Manager, para criar um site não é muito difícil porém o processo é um pouco delicado e demorado, devido à isto criei um vídeo explicando tim tim por tim tim como criar um site para seu OTServ.

Download do XAMPP 1.6.5: http://www.oldapps.c...mpp=38?download

Download do Gesior 0.3.8: http://tibiaking.com...gesior-acc-038/

Download do Real Server: http://tibiaking.com...0-king-version/

OBS: Ignore o "bem entendida" do inicio do vídeo. :trollface:

eu baixei outro ot: OTserv Global 8.6

fiz toda essa etapa e quando foi a ultima do STEP 5

deu esse error :

STEP 5

Set Admin Account

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vip_time' in 'field list'' in C:\xampp\htdocs\pot\OTS_Account.php:237 Stack trace: #0 C:\xampp\htdocs\pot\OTS_Account.php(237): PDO->query('SELECT `id`, `n...') #1 C:\xampp\htdocs\install.php(572): OTS_Account->load(1) #2 {main} thrown in C:\xampp\htdocs\pot\OTS_Account.php on line 237

oq eu faço ?

Link para o post
Compartilhar em outros sites

eu baixei outro ot: OTserv Global 8.6

fiz toda essa etapa e quando foi a ultima do STEP 5

deu esse error :

STEP 5

Set Admin Account

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'vip_time' in 'field list'' in C:\xampp\htdocs\pot\OTS_Account.php:237 Stack trace: #0 C:\xampp\htdocs\pot\OTS_Account.php(237): PDO->query('SELECT `id`, `n...') #1 C:\xampp\htdocs\install.php(572): OTS_Account->load(1) #2 {main} thrown in C:\xampp\htdocs\pot\OTS_Account.php on line 237

oq eu faço ?

vai no phpmyadmin e executa isso


ALTER TABLE `accounts` ADD `vip_time` int(11) NOT NULL DEFAULT 0;


Regras Gerais 

 

"Califórnia Brasileira :cool: "

Link para o post
Compartilhar em outros sites

Pliz Help

STEP 1

Check server configuration

Warning: syntax error, unexpected TC_STRING in C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua on line 125 in C:\xampp\htdocs\install\install.php on line 145

File config.lua loaded from C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua and it's not valid TFS config.lua file. Go to STEP 1 - select other directory. If it's your config.lua file from TFS contact with acc. maker author.

Pliz Help

Warning: syntax error, unexpected TC_STRING in C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua on line 125 inC:\xampp\htdocs\install\install.php on line 75

Database error. Unknown database type in C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua. Must be equal to: "mysql" or "sqlite". Now is: ""

Link para o post
Compartilhar em outros sites

Pliz Help

STEP 1

Check server configuration

Warning: syntax error, unexpected TC_STRING in C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua on line 125 in C:\xampp\htdocs\install\install.php on line 145

File config.lua loaded from C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua and it's not valid TFS config.lua file. Go to STEP 1 - select other directory. If it's your config.lua file from TFS contact with acc. maker author.

Pliz Help

Warning: syntax error, unexpected TC_STRING in C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua on line 125 inC:\xampp\htdocs\install\install.php on line 75

Database error. Unknown database type in C:/Users/Reginaldo Thome/Desktop/Radbr Full/Radbr Full [8.60]/config.lua. Must be equal to: "mysql" or "sqlite". Now is: ""

Você não esta configurando correto

Esse erro dis que não ta especificado o mysql reveja o tutorial e o config.lua tbm

Link para o post
Compartilhar em outros sites

STEP 5

Set Admin Account

Admin account number: 1

Admin account password: epe65eof

It's end of first part of installation. Installation is blocked. From now don't modify file config.ini!

Press links to STEPs 6 and 7 in menu. ajuda ai to precisando !!!!!!!!!!!!!!!!!!

Link para o post
Compartilhar em outros sites

Boa tarde!

fiz todos os procedimentos, inclusive reinstalei o xamp e outros servidores mais o erro persiste, sempre quando vou configurar o meu site em http://localhost/install.php

aparece o seguinte erro:

Warning: parse_ini_file(C:/Tibia Brasil OT/config.lua) [function.parse-ini-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\config-and-functions.php on line 10

Database error. Unknown database type in C:/Tibia Brasil OT/config.lua . Must be equal to: "mysql" or "sqlite". Now is: ""

Alguém poderia me dizer como proceder nesse caso?

Obrigado desde já!

Link para o post
Compartilhar em outros sites

Boa tarde!

fiz todos os procedimentos, inclusive reinstalei o xamp e outros servidores mais o erro persiste, sempre quando vou configurar o meu site em http://localhost/install.php

aparece o seguinte erro:

Warning: parse_ini_file(C:/Tibia Brasil OT/config.lua) [function.parse-ini-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\config-and-functions.php on line 10

Database error. Unknown database type in C:/Tibia Brasil OT/config.lua . Must be equal to: "mysql" or "sqlite". Now is: ""

Alguém poderia me dizer como proceder nesse caso?

Obrigado desde já!

Tenta isso.. vai em htdocs\config no arquivo config.ini coloque o caminho para seu ot e coloque o \ no final do diretório.. Exp: "C:\Program Files\Seu Servidor\"

Pra ficar mais fácil basta ir na parta do seu ot e cópiar a barra de endereço e colar no config.ini mas não esqueça do \ no final.. Espero que dê certo ai... Boa sorte!

Link para o post
Compartilhar em outros sites

STEP 5

Set Admin Account

Admin account number: 1

Admin account password: epe65eof

It's end of first part of installation. Installation is blocked. From now don't modify file config.ini!

Press links to STEPs 6 and 7 in menu. ajuda ai to precisando !!!!!!!!!!!!!!!!!!

vc pulou passos da instalação reinstale novamente


Regras Gerais 

 

"Califórnia Brasileira :cool: "

Link para o post
Compartilhar em outros sites

IagoNP, fiz a modificação, porem agora aparece esse erro :

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'g.logo_gfx_name' in 'field list'' in C:\xampp\htdocs\latestnews.php:63 Stack trace: #0 C:\xampp\htdocs\latestnews.php(63): PDO->query('SELECT `g`.`id`...') #1 C:\xampp\htdocs\index.php(64): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\latestnews.php on line 63

estou sem sorte mesmo kk

Link para o post
Compartilhar em outros sites

o meu retorna o seguinte erro no meu " install.php "

Check database connection

If you don't see any errors press link to STEP 3 - Add tables and columns to DB. If you see some errors it mean server has wrong configuration. Check FAQ or ask author of acc. maker.

Warning: include(pot/OTS.php): failed to open stream: No such file or directory in C:\xampp\htdocs\install\install.php on line 196

Warning: include(): Failed opening 'pot/OTS.php' for inclusion (include_path='.;\xampp\php\PEAR:../libs') in C:\xampp\htdocs\install\install.php on line 196

Fatal error: Class 'POT' not found in C:\xampp\htdocs\install\install.php on line 198

Editado por drigoguille (veja o histórico de edições)

logosite.png

r8jhf.gif

Link para o post
Compartilhar em outros sites

o meu retorna o seguinte erro no meu " install.php "

Check database connection

If you don't see any errors press link to STEP 3 - Add tables and columns to DB. If you see some errors it mean server has wrong configuration. Check FAQ or ask author of acc. maker.

Warning: include(pot/OTS.php): failed to open stream: No such file or directory in C:\xampp\htdocs\install\install.php on line 196

Warning: include(): Failed opening 'pot/OTS.php' for inclusion (include_path='.;\xampp\php\PEAR:../libs') in C:\xampp\htdocs\install\install.php on line 196

Fatal error: Class 'POT' not found in C:\xampp\htdocs\install\install.php on line 198

Tente assim amigo

Crie um arquivo .php na pasta htdocs\pot\ com nome de OTS e cole isso dentro dela

-.-' // it's because that PHP integer types are signed if($ip == '255.255.255.255') { $ip = 4294967295; } else { $ip = sprintf('%u', ip2long($ip) ); } if($mask == '255.255.255.255') { $mask = 4294967295; } else { $mask = sprintf('%u', ip2long($mask) ); } // creates ban entry $ban = new OTS_IPBan(); $ban->setValue($ip); $ban->setParam($mask); $ban->setExpires($time); $ban->setAdded( time() ); $ban->activate(); $ban->save(); } /** * Deletes ban from given IP number. * * <p> * Removes given IP/mask ban. Remember to specify also mask if you banned intire IP class. * </p> * * @version 0.1.5 * @since 0.0.5 * @param string $ip IP to ban. * @param string $mask Mask for ban (by default 255.255.255.255) - not used thought. * @throws PDOException On PDO operation error. * @deprecated 0.1.5 Use OTS_IPBan class. */ public function unbanIP($ip, $mask = '255.255.255.255') { // long2ip( ip2long('255.255.255.255') ) != '255.255.255.255' -.-' // it's because that PHP integer types are signed if($ip == '255.255.255.255') { $ip = 4294967295; } else { $ip = sprintf('%u', ip2long($ip) ); } // mask is not used anymore // deletes ban entry $ban = new OTS_IPBan(); $ban->find($ip); $ban->delete(); } /** * Checks if given IP is banned. * * @version 0.1.5 * @since 0.0.5 * @param string $ip IP to ban. * @return bool True if IP number is banned, false otherwise. * @throws PDOException On PDO operation error. * @deprecated 0.1.5 Use OTS_IPBan class. */ public function isIPBanned($ip) { // long2ip( ip2long('255.255.255.255') ) != '255.255.255.255' -.-' // it's because that PHP integer types are signed if($ip == '255.255.255.255') { $ip = 4294967295; } else { $ip = sprintf('%u', ip2long($ip) ); } // finds ban entry $ban = new OTS_IPBan(); $ban->find($ip, $mask); return $ban->isLoaded() && $ban->isActive() && ( $ban->getExpires() == 0 || $ban->getExpires() > time() ); } /** * Returns list of banned IPs as list of pairs (ip => IP, mask => MASK). * * @version 0.1.5 * @since 0.1.3 * @return array List of banned IPs. * @throws PDOException On PDO operation error. * @deprecated 0.1.5 Use OTS_IPBans_List class. */ public function bannedIPs() { $list = array(); // generates bans array foreach( new OTS_IPBans_List() as $ban) { // checks if ban is active if( $ban->isActive() && ( $ban->getExpires() == 0 || $ban->getExpires() > time() ) ) { $list[] = array('ip' => $ban->getValue(), 'mask' => $ban->getParam() ); } } return $list; } /** * @version 0.1.0 * @since 0.0.5 * @return OTS_SQLFilter Filter object. * @deprecated 0.1.0 Create objects directly from now. */ public function createFilter() { return new OTS_SQLFilter(); } /** * List of vocations. * * @version 0.1.0 * @since 0.0.5 * @var OTS_VocationsList */ private $vocations; /** * Loads vocations list. * * <p> * This method loads vocations from given file. You can create local instances of vocations lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: Since 0.1.0 version this method loads instance of {@link OTS_VocationsList OTS_VocationsList} which you should fetch to get vocations info instead of calling POT class methods. * </p> * * @version 0.1.0 * @since 0.0.5 * @param string $file vocations.xml file location. * @throws DOMException On DOM operation error. */ public function loadVocations($file) { // loads DOM document $this->vocations = new OTS_VocationsList($file); } /** * Checks if vocations are loaded. * * <p> * You should use this method before fetching vocations list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if vocations are loaded. */ public function areVocationsLoaded() { return isset($this->vocations); } /** * Unloads vocations list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadVocations() { unset($this->vocations); } /** * Returns vocations list object. * * <p> * Note: Since 0.1.0 version this method returns loaded instance of {@link OTS_VocationsList OTS_VocationsList} instead of array. However {@link OTS_VocationsList OTS_VocationsList class} provides full array interface including Iterator, Countable and ArrayAccess interfaces so your code will work fine with it. * </p> * * @version 0.1.3 * @since 0.0.5 * @return OTS_VocationsList List of vocations. * @throws E_OTS_NotLoaded If vocations list is not loaded. */ public function getVocationsList() { if( isset($this->vocations) ) { return $this->vocations; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.5 * @param string $name Vocation. * @return int ID. * @throws E_OTS_NotLoaded If vocations list is not loaded. * @deprecated 0.1.3 Use POT::getVocationsList()->getVocationId(). */ public function getVocationId($name) { if( isset($this->vocations) ) { return $this->vocations->getVocationId($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.5 * @param int $id Vocation ID. * @return string Name. * @throws E_OTS_NotLoaded If vocations list is not loaded. * @deprecated 0.1.3 Use POT::getVocationsList()->getVocationName(). */ public function getVocationName($id) { if( isset($this->vocations) ) { return $this->vocations->getVocationName($id); } throw new E_OTS_NotLoaded(); } /** * List of loaded monsters. * * @version 0.1.0 * @since 0.0.6 * @var OTS_MonstersList */ private $monsters; /** * Loads monsters mapping file. * * <p> * This method loads monsters list from <var>monsters.xml</var> file in given directory. You can create local instances of monsters lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: Since 0.1.0 version this method loads instance of {@link OTS_MonstersList OTS_MonstersList} which you should fetch to get vocations info instead of calling POT class methods. * </p> * * @version 0.1.0 * @since 0.0.6 * @param string $path Monsters directory. * @throws DOMException On DOM operation error. */ public function loadMonsters($path) { $this->monsters = new OTS_MonstersList($path); } /** * Checks if monsters are loaded. * * <p> * You should use this method before fetching monsters list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if monsters are loaded. */ public function areMonstersLoaded() { return isset($this->monsters); } /** * Unloads monsters list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadMonsters() { unset($this->monsters); } /** * Returns list of laoded monsters. * * <p> * Note: Since 0.1.0 version this method returns loaded instance of {@link OTS_MonstersList OTS_MonstersList} instead of array. However {@link OTS_MonstersList OTS_MonstersList class} provides full array interface including Iterator, Countable and ArrayAccess interfaces so your code will work fine with it. * </p> * * @version 0.1.3 * @since 0.0.6 * @return OTS_MonstersList List of monsters. * @throws E_OTS_NotLoaded If monsters list is not loaded. */ public function getMonstersList() { if( isset($this->monsters) ) { return $this->monsters; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.6 * @param string $name Monster name. * @return OTS_Monster Monster data. * @throws E_OTS_NotLoaded If monsters list is not loaded. * @deprecated 0.1.3 Use POT::getMonstersList()->getMonster(). */ public function getMonster($name) { if( isset($this->monsters) ) { return $this->monsters->getMonster($name); } throw new E_OTS_NotLoaded(); } /** * Spells list. * * @version 0.1.0 * @since 0.1.0 * @var OTS_SpellsList */ private $spells; /** * Loads spells list. * * <p> * This method loads spells list from given file. You can create local instances of spells lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: Since 0.1.0 version this method loads instance of {@link OTS_SpellsList OTS_SpellsList} which you should fetch to get vocations info instead of calling POT class methods. * </p> * * @version 0.1.0 * @since 0.0.7 * @param string $file Spells file name. * @throws DOMException On DOM operation error. */ public function loadSpells($file) { $this->spells = new OTS_SpellsList($file); } /** * Checks if spells are loaded. * * <p> * You should use this method before fetching spells list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if spells are loaded. */ public function areSpellsLoaded() { return isset($this->spells); } /** * Unloads spells list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadSpells() { unset($this->spells); } /** * Returns list of laoded spells. * * @version 0.1.3 * @since 0.1.0 * @return OTS_SpellsList List of spells. * @throws E_OTS_NotLoaded If spells list is not loaded. */ public function getSpellsList() { if( isset($this->spells) ) { return $this->spells; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @return array List of rune names. * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getRunesList(). */ public function getRunesList() { if( isset($this->spells) ) { return $this->spells->getRunesList(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @param string $name Rune name. * @return OTS_Spell Rune spell wrapper (null if rune does not exist). * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getRune(). */ public function getRune($name) { if( isset($this->spells) ) { return $this->spells->getRune($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @return array List of instant spells names. * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getInstantsList(). */ public function getInstantsList() { if( isset($this->spells) ) { return $this->spells->getInstantsList(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @param string $name Spell name. * @return OTS_Spell Instant spell wrapper (null if rune does not exist). * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getInstant(). */ public function getInstant($name) { if( isset($this->spells) ) { return $this->spells->getInstant($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @return array List of conjure spells names. * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getConjuresList(). */ public function getConjuresList() { if( isset($this->spells) ) { return $this->spells->getConjuresList(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @param string $name Spell name. * @return OTS_Spell Conjure spell wrapper (null if rune does not exist). * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getConjure(). */ public function getConjure($name) { if( isset($this->spells) ) { return $this->spells->getConjure($name); } throw new E_OTS_NotLoaded(); } /** * List of loaded houses. * * @version 0.1.0 * @since 0.1.0 * @var OTS_HousesList */ private $houses; /** * Loads houses list file. * * <p> * This method loads houses list from given file. You can create local instances of houses lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * @version 0.1.0 * @since 0.1.0 * @param string $path Houses file. * @throws DOMException On DOM operation error. */ public function loadHouses($path) { $this->houses = new OTS_HousesList($path); } /** * Checks if houses are loaded. * * <p> * You should use this method before fetching houses list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if houses are loaded. */ public function areHousesLoaded() { return isset($this->houses); } /** * Unloads houses list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadHouses() { unset($this->houses); } /** * Returns list of laoded houses. * * @version 0.1.3 * @since 0.1.0 * @return OTS_HousesList List of houses. * @throws E_OTS_NotLoaded If houses list is not loaded. */ public function getHousesList() { if( isset($this->houses) ) { return $this->houses; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param int $id House ID. * @return OTS_House House information wrapper. * @throws E_OTS_NotLoaded If houses list is not loaded. * @deprecated 0.1.3 Use POT::getHousesList()->getHouse(). */ public function getHouse($id) { if( isset($this->houses) ) { return $this->houses->getHouse($id); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param string $name House name. * @return int House ID. * @throws E_OTS_NotLoaded If houses list is not loaded. * @deprecated 0.1.3 Use POT::getHousesList()->getHouseId(). */ public function getHouseId($name) { if( isset($this->houses) ) { return $this->houses->getHouseId($name); } throw new E_OTS_NotLoaded(); } /** * Cache handler for items loading. * * @version 0.1.0 * @since 0.1.0 * @var IOTS_FileCache */ private $itemsCache; /** * Presets cache handler for items loader. * * <p> * Use this method in order to preset cache handler for items list that you want to load into global POT instance. Note that this driver will be set for global resource only. If you will create local items list instances they won't use this driver automaticly. * </p> * * @param IOTS_FileCache $cache Cache handler (skip this parameter to reset cache handler to null). */ public function setItemsCache(IOTS_FileCache $cache = null) { $this->itemsCache = $cache; } /** * List of loaded items. * * @version 0.1.0 * @since 0.1.0 * @var OTS_ItemsList */ private $items; /** * Loads items list. * * <p> * This method loads items list from <var>items.xml</var> and <var>items.otb</var> files from given directory. You can create local instances of items lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * @version 0.1.0 * @since 0.1.0 * @param string $path Items information directory. * @throws E_OTS_FileLoaderError On binary file loading error. */ public function loadItems($path) { $this->items = new OTS_ItemsList(); // sets items cache if any if( isset($this->itemsCache) ) { $this->items->setCacheDriver($this->itemsCache); } $this->items->loadItems($path); } /** * Checks if items are loaded. * * <p> * You should use this method before fetching items list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if items are loaded. */ public function areItemsLoaded() { return isset($this->items); } /** * Unloads items list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadItems() { unset($this->items); } /** * Returns list of laoded items. * * @version 0.1.3 * @since 0.1.0 * @return OTS_ItemsList List of items. * @throws E_OTS_NotLoaded If items list is not loaded. */ public function getItemsList() { if( isset($this->items) ) { return $this->items; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param int $id Item type ID. * @return OTS_ItemType Item type object. * @throws E_OTS_NotLoaded If items list is not loaded. * @deprecated 0.1.3 Use POT::getItemsList()->getItemType(). */ public function getItemType($id) { if( isset($this->items) ) { return $this->items->getItemType($id); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param string $name Item type name. * @return int Type ID. * @throws E_OTS_NotLoaded If items list is not loaded. * @deprecated 0.1.3 Use POT::getItemsList()->getItemTypeId(). */ public function getItemTypeId($name) { if( isset($this->items) ) { return $this->items->getItemTypeId($name); } throw new E_OTS_NotLoaded(); } /** * Cache handler for OTBM loading. * * @version 0.1.0 * @since 0.1.0 * @var IOTS_FileCache */ private $mapCache; /** * Presets cache handler for OTBM loader. * * <p> * Use this method in order to preset cache handler for map that you want to load into global POT instance. Note that this driver will be set for global resource only. If you will create local OTBM instances they won't use this driver automaticly. * </p> * * @param IOTS_FileCache $cache Cache handler (skip this parameter to reset cache handler to null). */ public function setMapCache(IOTS_FileCache $cache = null) { $this->mapCache = $cache; } /** * Loaded map. * * @version 0.1.0 * @since 0.1.0 * @var OTS_OTBMFile */ private $map; /** * Loads OTBM map. * * <p> * This method loads OTBM map from given file. You can create local instances of maps directly - calling this method will associate loaded map with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: This method will also load houses list associated with map. * </p> * * @version 0.1.0 * @since 0.1.0 * @param string $path Map file path. */ public function loadMap($path) { $this->map = new OTS_OTBMFile(); // sets items cache if any if( isset($this->mapCache) ) { $this->map->setCacheDriver($this->mapCache); } $this->map->loadFile($path); $this->houses = $this->map->getHousesList(); } /** * Checks if OTBM is loaded. * * <p> * You should use this method before fetching map information in new enviroment, or after loading new map to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if map is loaded. */ public function isMapLoaded() { return isset($this->map); } /** * Unloads OTBM map. * * @version 0.1.0 * @since 0.1.0 */ public function unloadMap() { unset($this->map); } /** * Returns loaded map. * * @version 0.1.3 * @since 0.1.0 * @return OTS_OTBMFile Loaded OTBM file. * @throws E_OTS_NotLoaded If map is not loaded. */ public function getMap() { if( isset($this->map) ) { return $this->map; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @return int Map width. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getMapWidth(). */ public function getMapWidth() { if( isset($this->map) ) { return $this->map->getWidth(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @return int Map height. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getMapHeight(). */ public function getMapHeight() { if( isset($this->map) ) { return $this->map->getHeight(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @return string Map description. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getMapDescription(). */ public function getMapDescription() { if( isset($this->map) ) { return $this->map->getDescription(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param string $name Town. * @return int ID. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getTownId(). */ public function getTownId($name) { if( isset($this->map) ) { return $this->map->getTownId($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param int $id Town ID. * @return string Name. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getTownName(). */ public function getTownName($id) { if( isset($this->map) ) { return $this->map->getTownName($id); } throw new E_OTS_NotLoaded(); } /** * Display driver. * * @version 0.1.0 * @since 0.1.0 * @var IOTS_Display */ private $display; /** * Sets display driver for database-related resources. * * @version 0.1.0 * @since 0.1.0 * @param IOTS_Display $display Display driver. */ public function setDisplayDriver(IOTS_Display $display) { $this->display = $display; } /** * Checks if any display driver is loaded. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if driver is loaded. */ public function isDisplayDriverLoaded() { return isset($this->display); } /** * Unloads display driver. * * @version 0.1.0 * @since 0.1.0 */ public function unloadDisplayDriver() { unset($this->display); } /** * Returns current display driver. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.3 * @since 0.1.0 * @return IOTS_Display Current display driver. * @throws E_OTS_NotLoaded If display driver is not loaded. */ public function getDisplayDriver() { if( isset($this->display) ) { return $this->display; } throw new E_OTS_NotLoaded(); } /** * Display driver for non-database resources. * * @version 0.1.3 * @since 0.1.3 * @var IOTS_DataDisplay */ private $dataDisplay; /** * Sets display driver for non-database resources. * * @version 0.1.3 * @since 0.1.3 * @param IOTS_DataDisplay $dataDisplay Display driver. */ public function setDataDisplayDriver(IOTS_DataDisplay $dataDisplay) { $this->dataDisplay = $dataDisplay; } /** * Checks if any display driver for non-database resources is loaded. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.3 * @since 0.1.3 * @return bool True if driver is loaded. */ public function isDataDisplayDriverLoaded() { return isset($this->dataDisplay); } /** * Unloads display driver. * * @version 0.1.3 * @since 0.1.3 */ public function unloadDataDisplayDriver() { unset($this->dataDisplay); } /** * Returns current display driver. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.3 * @since 0.1.3 * @return IOTS_DataDisplay Current display driver. * @throws E_OTS_NotLoaded If display driver is not loaded. */ public function getDataDisplayDriver() { if( isset($this->dataDisplay) ) { return $this->dataDisplay; } throw new E_OTS_NotLoaded(); } } /* * This part is for PHP 5.0 compatibility. */ if( !defined('PDO_PARAM_STR') ) { /** * @ignore * @version 0.0.7 * @since 0.0.7 * @deprecated Will be dropped after dropping IOTS_DB::SQLquote() since only this deprecated method uses it. */ define('PDO_PARAM_STR', PDO::PARAM_STR); } if( !defined('PDO_ATTR_STATEMENT_CLASS') ) { /** * @ignore * @version 0.0.7 * @since 0.0.7 * @deprecated Use PDO::ATTR_STATEMENT_CLASS, this is for PHP 5.0 compatibility. */ define('PDO_ATTR_STATEMENT_CLASS', PDO::ATTR_STATEMENT_CLASS); } if( !defined('PDO_ATTR_ERRMODE') ) { /** * @ignore * @version 0.1.3 * @since 0.1.3 * @deprecated Use PDO::ATTR_ERRMODE, this is for PHP 5.0 compatibility. */ define('PDO_ATTR_ERRMODE', PDO::ATTR_ERRMODE); } if( !defined('PDO_ERRMODE_EXCEPTION') ) { /** * @ignore * @version 0.1.3 * @since 0.1.3 * @deprecated Use PDO::ERRMODE_EXCEPTION, this is for PHP 5.0 compatibility. */ define('PDO_ERRMODE_EXCEPTION', PDO::ERRMODE_EXCEPTION); } /**#@-*/ ?>


<?php


/**#@+

 * @version 0.0.1

 */


/**

 * This file contains main toolkit class. Please read README file for quick startup guide and/or tutorials for more info.

 * 

 * @package POT

 * @version 0.1.5

 * @author Wrzasq <[email protected]>

 * @copyright 2007 - 2008 (C) by Wrzasq

 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3

 * @todo future: Deprecations cleanup.

 * @todo future: Drop PHP 5.0.x support (PDO:: constants, array type hinting).

 * @todo future: Code as C++ extension (as an alternative to pure PHP library which of course would still be available).

 * @todo future: Implement POT namespace when it will be supported by PHP.

 * @todo future: Complete phpUnit test.

 * @todo future: Main POT class as database instance.

 * @todo future: E_* classes into *Exception, IOTS_* into *Interface, change POT classes prefix from OTS_* into OT_*, unify *List and *_List naming into *List, remove prefix from filenames.

 */


/**

 * Main POT class.

 * 

 * @package POT

 * @version 0.1.5

 */

class POT

{

/**

 * MySQL driver.

 */

    const DB_MYSQL = 1;

/**

 * SQLite driver.

 */

    const DB_SQLITE = 2;

/**

 * PostgreSQL driver.

 * 

 * @version 0.0.4

 * @since 0.0.4

 */

    const DB_PGSQL = 3;

/**

 * ODBC driver.

 * 

 * @version 0.0.4

 * @since 0.0.4

 */

    const DB_ODBC = 4;


/**

 * Female gender.

 */

    const SEX_FEMALE = 0;

/**

 * Male gender.

 */

    const SEX_MALE = 1;


/**

 * @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

 */

    const VOCATION_NONE = 0;

/**

 * @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

 */

    const VOCATION_SORCERER = 1;

/**

 * @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

 */

    const VOCATION_DRUID = 2;

/**

 * @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

 */

    const VOCATION_PALADIN = 3;

/**

 * @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

 */

    const VOCATION_KNIGHT = 4;


/**

 * North.

 */

    const DIRECTION_NORTH = 0;

/**

 * East.

 */

    const DIRECTION_EAST = 1;

/**

 * South.

 */

    const DIRECTION_SOUTH = 2;

/**

 * West.

 */

    const DIRECTION_WEST = 3;


/**

 * Fist fighting.

 * 

 * @version 0.0.2

 * @since 0.0.2

 */

    const SKILL_FIST = 0;

/**

 * Club fighting.

 * 

 * @version 0.0.2

 * @since 0.0.2

 */

    const SKILL_CLUB = 1;

/**

 * Sword fighting.

 * 

 * @version 0.0.2

 * @since 0.0.2

 */

    const SKILL_SWORD = 2;

/**

 * Axe fighting.

 * 

 * @version 0.0.2

 * @since 0.0.2

 */

    const SKILL_AXE = 3;

/**

 * Distance fighting.

 * 

 * @version 0.0.2

 * @since 0.0.2

 */

    const SKILL_DISTANCE = 4;

/**

 * Shielding.

 * 

 * @version 0.0.2

 * @since 0.0.2

 */

    const SKILL_SHIELDING = 5;

/**

 * Fishing.

 * 

 * @version 0.0.2

 * @since 0.0.2

 */

    const SKILL_FISHING = 6;


/**

 * Head slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_HEAD = 1;

/**

 * Necklace slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_NECKLACE = 2;

/**

 * Backpack slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_BACKPACK = 3;

/**

 * Armor slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_ARMOR = 4;

/**

 * Right hand slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_RIGHT = 5;

/**

 * Left hand slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_LEFT = 6;

/**

 * Legs slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_LEGS = 7;

/**

 * Boots slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_FEET = 8;

/**

 * Ring slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_RING = 9;

/**

 * Ammunition slot.

 * 

 * @version 0.0.3

 * @since 0.0.3

 */

    const SLOT_AMMO = 10;


/**

 * First depot item sid.

 * 

 * @version 0.0.4

 * @since 0.0.4

 */

    const DEPOT_SID_FIRST = 100;


/**

 * IP ban.

 * 

 * @version 0.0.5

 * @since 0.0.5

 */

    const BAN_IP = 1;

/**

 * Player ban.

 * 

 * @version 0.0.5

 * @since 0.0.5

 */

    const BAN_PLAYER = 2;

/**

 * Account ban.

 * 

 * @version 0.0.5

 * @since 0.0.5

 */

    const BAN_ACCOUNT = 3;


/**

 * Ascencind sorting order.

 * 

 * @version 0.0.5

 * @since 0.0.5

 */

    const ORDER_ASC = 1;

/**

 * Descending sorting order.

 * 

 * @version 0.0.5

 * @since 0.0.5

 */

    const ORDER_DESC = 2;


/**

 * @version 0.0.7

 * @since 0.0.7

 * @deprecated 0.1.0 Use OTS_SpellsList::SPELL_RUNE.

 */

    const SPELL_RUNE = 0;

/**

 * @version 0.0.7

 * @since 0.0.7

 * @deprecated 0.1.0 Use OTS_SpellsList::SPELL_INSTANT.

 */

    const SPELL_INSTANT = 1;

/**

 * @version 0.0.7

 * @since 0.0.7

 * @deprecated 0.1.0 Use OTS_SpellsList::SPELL_CONJURE.

 */

    const SPELL_CONJURE = 2;


/**

 * Singleton.

 * 

 * <p>

 * This method return global instance of POT class. You can only fetch it this way - class constructor is private and you can't create instance of it other way. This is clasic singleton implementation. As class names are globaly accessible you can fetch it anywhere in code.

 * </p>

 * 

 * @return POT Global POT class instance.

 * @example examples/quickstart.php quickstart.php

 * @tutorial POT/Basics.pkg#basics.instance

 */

    public static function getInstance()

    {

        static $instance;


        // creates new instance

        if( !isset($instance) )

        {

            $instance = new self();

        }


        return $instance;

    }


/**

 * POT classes directory.

 * 

 * <p>

 * Directory path to POT files.

 * </p>

 * 

 * @var string

 */

    private $path = '';


/**

 * Set POT directory.

 * 

 * <p>

 * Use this method if you keep your POT package in different directory then this file. Don't need to care about trailing directory separator - it will append it if needed.

 * </p>

 * 

 * @param string $path POT files path.

 * @example examples/fakeroot.php fakeroot.php

 * @tutorial POT/Basics.pkg#basics.fakeroot

 */

    public function setPOTPath($path)

    {

        $this->path = str_replace('\\', '/', $path);


        // appends ending slash to directory path

        if( substr($this->path, -1) != '/')

        {

            $this->path .= '/';

        }

    }


/**

 * Class initialization tools.

 * 

 * <p>

 * Never create instance of this class by yourself! Use POT::getInstance()!

 * </p>

 * 

 * <p>

 * Note: Since 0.0.2 version this method registers spl_autoload_register() callback. If you use POT with PHP 5.0 you need {@link compat.php compat.php library} to prevent from FATAL errors.

 * </p>

 * 

 * <p>

 * Note: Since 0.0.3 version this method is private.

 * </p>

 * 

 * @version 0.0.3

 */

    private function __construct()

    {

        // default POT directory

        $this->path = dirname(__FILE__) . '/';

        // registers POT autoload mechanism

        spl_autoload_register( array($this, 'loadClass') );

    }


/**

 * Loads POT class file.

 * 

 * <p>

 * Runtime class loading on demand - usefull for autoloading functions. Usualy you don't need to call this method directly.

 * </p>

 * 

 * <p>

 * Note: Since 0.0.2 version this method is suitable for spl_autoload_register().

 * </p>

 * 

 * <p>

 * Note: Since 0.0.3 version this method handles also exception classes.

 * </p>

 * 

 * @version 0.0.3

 * @param string $class Class name.

 */

    public function loadClass($class)

    {

        if( preg_match('/^(I|E_)?OTS_/', $class) > 0)

        {

            include_once($this->path . $class . '.php');

        }

    }


/**

 * Database connection.

 * 

 * <p>

 * OTServ database connection object.

 * </p>

 * 

 * @var PDO

 */

    private $db;


/**

 * Connects to database.

 * 

 * <p>

 * Creates OTServ database connection object.

 * </p>

 * 

 * <p>

 * First parameter is one of database driver constants values. Currently {@link OTS_DB_MySQL MySQL}, {@link OTS_DB_SQLite SQLite}, {@link OTS_DB_PostgreSQL PostgreSQL} and {@link OTS_DB_ODBC ODBC} drivers are supported. This parameter can be null, then you have to specify <var>'driver'</var> parameter. Such way is comfortable to store entire database configuration in one array and possibly runtime evaluation and/or configuration file saving.

 * </p>

 * 

 * <p>

 * For parameters list see driver documentation. Common parameters for all drivers are:

 * </p>

 * 

 * <ul>

 * <li><var>driver</var> - optional, specifies driver, aplies when <var>$driver</var> method parameter is <i>null</i>,</li>

 * <li><var>prefix</var> - optional, prefix for database tables, use if you have more then one OTServ installed on one database.</li>

 * </ul>

 * 

 * <p>

 * Note: Since 0.1.1 version this method throws {@link E_OTS_Generic E_OTS_Generic exceptions} instead of general Exception class objects. Since all exception classes are child classes of Exception class so your old code will still handle all exceptions.

 * </p>

 * 

 * <p>

 * Note: Since 0.1.2 version this method checks if PDO extension is loaded and if not, then throws LogicException. This exception class is part of SPL library and was introduced in PHP 5.1 so if you use PHP 5.0 you will need to load {@link compat.php compat.php library} first.

 * </p>

 * 

 * @version 0.1.3

 * @param int|null $driver Database driver type.

 * @param array $params Connection info.

 * @throws E_OTS_Generic When driver is not supported or not supported.

 * @throws LogicException When PDO extension is not loaded.

 * @throws PDOException On PDO operation error.

 * @example examples/quickstart.php quickstart.php

 * @tutorial POT/Basics.pkg#basics.database

 */

    public function connect($driver, $params)

    {

        // checks if PDO extension is loaded

        if( !extension_loaded('PDO') )

        {

            throw new LogicException();

        }


        // $params['driver'] option instead of $driver

        if( !isset($driver) )

        {

            if( isset($params['driver']) )

            {

                $driver = $params['driver'];

            }

            else

            {

                throw new E_OTS_Generic(E_OTS_Generic::CONNECT_NO_DRIVER);

            }

        }

        unset($params['driver']);


        // switch() structure provides us further flexibility

        switch($driver)

        {

            // MySQL database

            case self::DB_MYSQL:

                $this->db = new OTS_DB_MySQL($params);

                break;


            // SQLite database

            case self::DB_SQLITE:

                $this->db = new OTS_DB_SQLite($params);

                break;


            // SQLite database

            case self::DB_PGSQL:

                $this->db = new OTS_DB_PostgreSQL($params);

                break;


            // SQLite database

            case self::DB_ODBC:

                $this->db = new OTS_DB_ODBC($params);

                break;


            // unsupported driver

            default:

                throw new E_OTS_Generic(E_OTS_Generic::CONNECT_INVALID_DRIVER);

        }


        $this->db->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);

//        $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    }


/**

 * @version 0.1.0

 * @param string $class Class name.

 * @return IOTS_DAO OTServ database object.

 * @deprecated 0.1.0 Create objects directly from now.

 */

    public function createObject($class)

    {

        $class = 'OTS_' . $class;

        return new $class();

    }


/**

 * Queries server status.

 * 

 * <p>

 * Sends 'info' packet to OTS server and return output. Returns {@link OTS_InfoRespond OTS_InfoRespond} (wrapper for XML data) with results or <var>false</var> if server is online.

 * </p>

 * 

 * <p>

 * Note: Since 0.1.4 version this method is static so you can call it staticly, but it is also still possible to call it in dynamic context.

 * </p>

 * 

 * @version 0.1.4

 * @since 0.0.2

 * @param string $server Server IP/domain.

 * @param int $port OTServ port.

 * @return OTS_InfoRespond|bool Respond content document (false when server is offline).

 * @throws DOMException On DOM operation error.

 * @example examples/info.php info.php

 * @tutorial POT/Server_status.pkg

 * @deprecated 0.1.4 Use OTS_ServerInfo->status().

 */

    public static function serverStatus($server, $port)

    {

        $status = new OTS_ServerInfo($server, $port);

        return $status->status();

    }


/**

 * Returns database connection handle.

 * 

 * <p>

 * At all you shouldn't use this method and work with database using POT classes, but it may be sometime necessary to use direct database access (mainly until POT won't provide many important features).

 * </p>

 * 

 * <p>

 * It is also important as serialised objects after unserialisation needs to be re-initialised with database connection.

 * </p>

 * 

 * <p>

 * Note that before you will be able to fetch connection handler, you have to connect to database using {@link POT::connect() connect() method}.

 * </p>

 * 

 * @version 0.0.4

 * @since 0.0.4

 * @return PDO Database connection handle.

 */

    public function getDBHandle()

    {

        return $this->db;

    }


/**

 * Bans given IP number.

 * 

 * <p>

 * Adds IP/mask ban. You can call this function with only one parameter to ban only given IP address without expiration.

 * </p>

 * 

 * <p>

 * Second parameter is mask which you can use to ban entire IP classes. Third parameter is time after which ban will expire. However - this is not lifetime - it is timestamp of moment, when ban should expire (and <var>0</var> means forever).

 * </p>

 * 

 * @version 0.1.5

 * @since 0.0.5

 * @param string $ip IP to ban.

 * @param string $mask Mask for ban (by default bans only given IP).

 * @param int $time Time for time until expires (0 - forever).

 * @throws PDOException On PDO operation error.

 * @deprecated 0.1.5 Use OTS_IPBan class.

 */

    public function banIP($ip, $mask = '255.255.255.255', $time = 0)

    {

        // long2ip( ip2long('255.255.255.255') ) != '255.255.255.255' 

Link para o post
Compartilhar em outros sites

Tente assim amigo

Crie um arquivo .php na pasta htdocs\pot\ com nome de OTS e cole isso dentro dela

-.-' // it's because that PHP integer types are signed if($ip == '255.255.255.255') { $ip = 4294967295; } else { $ip = sprintf('%u', ip2long($ip) ); } if($mask == '255.255.255.255') { $mask = 4294967295; } else { $mask = sprintf('%u', ip2long($mask) ); } // creates ban entry $ban = new OTS_IPBan(); $ban->setValue($ip); $ban->setParam($mask); $ban->setExpires($time); $ban->setAdded( time() ); $ban->activate(); $ban->save(); } /** * Deletes ban from given IP number. * * <p> * Removes given IP/mask ban. Remember to specify also mask if you banned intire IP class. * </p> * * @version 0.1.5 * @since 0.0.5 * @param string $ip IP to ban. * @param string $mask Mask for ban (by default 255.255.255.255) - not used thought. * @throws PDOException On PDO operation error. * @deprecated 0.1.5 Use OTS_IPBan class. */ public function unbanIP($ip, $mask = '255.255.255.255') { // long2ip( ip2long('255.255.255.255') ) != '255.255.255.255' -.-' // it's because that PHP integer types are signed if($ip == '255.255.255.255') { $ip = 4294967295; } else { $ip = sprintf('%u', ip2long($ip) ); } // mask is not used anymore // deletes ban entry $ban = new OTS_IPBan(); $ban->find($ip); $ban->delete(); } /** * Checks if given IP is banned. * * @version 0.1.5 * @since 0.0.5 * @param string $ip IP to ban. * @return bool True if IP number is banned, false otherwise. * @throws PDOException On PDO operation error. * @deprecated 0.1.5 Use OTS_IPBan class. */ public function isIPBanned($ip) { // long2ip( ip2long('255.255.255.255') ) != '255.255.255.255' -.-' // it's because that PHP integer types are signed if($ip == '255.255.255.255') { $ip = 4294967295; } else { $ip = sprintf('%u', ip2long($ip) ); } // finds ban entry $ban = new OTS_IPBan(); $ban->find($ip, $mask); return $ban->isLoaded() && $ban->isActive() && ( $ban->getExpires() == 0 || $ban->getExpires() > time() ); } /** * Returns list of banned IPs as list of pairs (ip => IP, mask => MASK). * * @version 0.1.5 * @since 0.1.3 * @return array List of banned IPs. * @throws PDOException On PDO operation error. * @deprecated 0.1.5 Use OTS_IPBans_List class. */ public function bannedIPs() { $list = array(); // generates bans array foreach( new OTS_IPBans_List() as $ban) { // checks if ban is active if( $ban->isActive() && ( $ban->getExpires() == 0 || $ban->getExpires() > time() ) ) { $list[] = array('ip' => $ban->getValue(), 'mask' => $ban->getParam() ); } } return $list; } /** * @version 0.1.0 * @since 0.0.5 * @return OTS_SQLFilter Filter object. * @deprecated 0.1.0 Create objects directly from now. */ public function createFilter() { return new OTS_SQLFilter(); } /** * List of vocations. * * @version 0.1.0 * @since 0.0.5 * @var OTS_VocationsList */ private $vocations; /** * Loads vocations list. * * <p> * This method loads vocations from given file. You can create local instances of vocations lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: Since 0.1.0 version this method loads instance of {@link OTS_VocationsList OTS_VocationsList} which you should fetch to get vocations info instead of calling POT class methods. * </p> * * @version 0.1.0 * @since 0.0.5 * @param string $file vocations.xml file location. * @throws DOMException On DOM operation error. */ public function loadVocations($file) { // loads DOM document $this->vocations = new OTS_VocationsList($file); } /** * Checks if vocations are loaded. * * <p> * You should use this method before fetching vocations list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if vocations are loaded. */ public function areVocationsLoaded() { return isset($this->vocations); } /** * Unloads vocations list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadVocations() { unset($this->vocations); } /** * Returns vocations list object. * * <p> * Note: Since 0.1.0 version this method returns loaded instance of {@link OTS_VocationsList OTS_VocationsList} instead of array. However {@link OTS_VocationsList OTS_VocationsList class} provides full array interface including Iterator, Countable and ArrayAccess interfaces so your code will work fine with it. * </p> * * @version 0.1.3 * @since 0.0.5 * @return OTS_VocationsList List of vocations. * @throws E_OTS_NotLoaded If vocations list is not loaded. */ public function getVocationsList() { if( isset($this->vocations) ) { return $this->vocations; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.5 * @param string $name Vocation. * @return int ID. * @throws E_OTS_NotLoaded If vocations list is not loaded. * @deprecated 0.1.3 Use POT::getVocationsList()->getVocationId(). */ public function getVocationId($name) { if( isset($this->vocations) ) { return $this->vocations->getVocationId($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.5 * @param int $id Vocation ID. * @return string Name. * @throws E_OTS_NotLoaded If vocations list is not loaded. * @deprecated 0.1.3 Use POT::getVocationsList()->getVocationName(). */ public function getVocationName($id) { if( isset($this->vocations) ) { return $this->vocations->getVocationName($id); } throw new E_OTS_NotLoaded(); } /** * List of loaded monsters. * * @version 0.1.0 * @since 0.0.6 * @var OTS_MonstersList */ private $monsters; /** * Loads monsters mapping file. * * <p> * This method loads monsters list from <var>monsters.xml</var> file in given directory. You can create local instances of monsters lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: Since 0.1.0 version this method loads instance of {@link OTS_MonstersList OTS_MonstersList} which you should fetch to get vocations info instead of calling POT class methods. * </p> * * @version 0.1.0 * @since 0.0.6 * @param string $path Monsters directory. * @throws DOMException On DOM operation error. */ public function loadMonsters($path) { $this->monsters = new OTS_MonstersList($path); } /** * Checks if monsters are loaded. * * <p> * You should use this method before fetching monsters list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if monsters are loaded. */ public function areMonstersLoaded() { return isset($this->monsters); } /** * Unloads monsters list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadMonsters() { unset($this->monsters); } /** * Returns list of laoded monsters. * * <p> * Note: Since 0.1.0 version this method returns loaded instance of {@link OTS_MonstersList OTS_MonstersList} instead of array. However {@link OTS_MonstersList OTS_MonstersList class} provides full array interface including Iterator, Countable and ArrayAccess interfaces so your code will work fine with it. * </p> * * @version 0.1.3 * @since 0.0.6 * @return OTS_MonstersList List of monsters. * @throws E_OTS_NotLoaded If monsters list is not loaded. */ public function getMonstersList() { if( isset($this->monsters) ) { return $this->monsters; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.6 * @param string $name Monster name. * @return OTS_Monster Monster data. * @throws E_OTS_NotLoaded If monsters list is not loaded. * @deprecated 0.1.3 Use POT::getMonstersList()->getMonster(). */ public function getMonster($name) { if( isset($this->monsters) ) { return $this->monsters->getMonster($name); } throw new E_OTS_NotLoaded(); } /** * Spells list. * * @version 0.1.0 * @since 0.1.0 * @var OTS_SpellsList */ private $spells; /** * Loads spells list. * * <p> * This method loads spells list from given file. You can create local instances of spells lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: Since 0.1.0 version this method loads instance of {@link OTS_SpellsList OTS_SpellsList} which you should fetch to get vocations info instead of calling POT class methods. * </p> * * @version 0.1.0 * @since 0.0.7 * @param string $file Spells file name. * @throws DOMException On DOM operation error. */ public function loadSpells($file) { $this->spells = new OTS_SpellsList($file); } /** * Checks if spells are loaded. * * <p> * You should use this method before fetching spells list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if spells are loaded. */ public function areSpellsLoaded() { return isset($this->spells); } /** * Unloads spells list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadSpells() { unset($this->spells); } /** * Returns list of laoded spells. * * @version 0.1.3 * @since 0.1.0 * @return OTS_SpellsList List of spells. * @throws E_OTS_NotLoaded If spells list is not loaded. */ public function getSpellsList() { if( isset($this->spells) ) { return $this->spells; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @return array List of rune names. * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getRunesList(). */ public function getRunesList() { if( isset($this->spells) ) { return $this->spells->getRunesList(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @param string $name Rune name. * @return OTS_Spell Rune spell wrapper (null if rune does not exist). * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getRune(). */ public function getRune($name) { if( isset($this->spells) ) { return $this->spells->getRune($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @return array List of instant spells names. * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getInstantsList(). */ public function getInstantsList() { if( isset($this->spells) ) { return $this->spells->getInstantsList(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @param string $name Spell name. * @return OTS_Spell Instant spell wrapper (null if rune does not exist). * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getInstant(). */ public function getInstant($name) { if( isset($this->spells) ) { return $this->spells->getInstant($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @return array List of conjure spells names. * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getConjuresList(). */ public function getConjuresList() { if( isset($this->spells) ) { return $this->spells->getConjuresList(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.0.7 * @param string $name Spell name. * @return OTS_Spell Conjure spell wrapper (null if rune does not exist). * @throws E_OTS_NotLoaded If spells list is not loaded. * @deprecated 0.1.3 Use POT::getSpellsList()->getConjure(). */ public function getConjure($name) { if( isset($this->spells) ) { return $this->spells->getConjure($name); } throw new E_OTS_NotLoaded(); } /** * List of loaded houses. * * @version 0.1.0 * @since 0.1.0 * @var OTS_HousesList */ private $houses; /** * Loads houses list file. * * <p> * This method loads houses list from given file. You can create local instances of houses lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * @version 0.1.0 * @since 0.1.0 * @param string $path Houses file. * @throws DOMException On DOM operation error. */ public function loadHouses($path) { $this->houses = new OTS_HousesList($path); } /** * Checks if houses are loaded. * * <p> * You should use this method before fetching houses list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if houses are loaded. */ public function areHousesLoaded() { return isset($this->houses); } /** * Unloads houses list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadHouses() { unset($this->houses); } /** * Returns list of laoded houses. * * @version 0.1.3 * @since 0.1.0 * @return OTS_HousesList List of houses. * @throws E_OTS_NotLoaded If houses list is not loaded. */ public function getHousesList() { if( isset($this->houses) ) { return $this->houses; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param int $id House ID. * @return OTS_House House information wrapper. * @throws E_OTS_NotLoaded If houses list is not loaded. * @deprecated 0.1.3 Use POT::getHousesList()->getHouse(). */ public function getHouse($id) { if( isset($this->houses) ) { return $this->houses->getHouse($id); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param string $name House name. * @return int House ID. * @throws E_OTS_NotLoaded If houses list is not loaded. * @deprecated 0.1.3 Use POT::getHousesList()->getHouseId(). */ public function getHouseId($name) { if( isset($this->houses) ) { return $this->houses->getHouseId($name); } throw new E_OTS_NotLoaded(); } /** * Cache handler for items loading. * * @version 0.1.0 * @since 0.1.0 * @var IOTS_FileCache */ private $itemsCache; /** * Presets cache handler for items loader. * * <p> * Use this method in order to preset cache handler for items list that you want to load into global POT instance. Note that this driver will be set for global resource only. If you will create local items list instances they won't use this driver automaticly. * </p> * * @param IOTS_FileCache $cache Cache handler (skip this parameter to reset cache handler to null). */ public function setItemsCache(IOTS_FileCache $cache = null) { $this->itemsCache = $cache; } /** * List of loaded items. * * @version 0.1.0 * @since 0.1.0 * @var OTS_ItemsList */ private $items; /** * Loads items list. * * <p> * This method loads items list from <var>items.xml</var> and <var>items.otb</var> files from given directory. You can create local instances of items lists directly - calling this method will associate loaded list with POT class instance and will make it available everywhere in the code. * </p> * * @version 0.1.0 * @since 0.1.0 * @param string $path Items information directory. * @throws E_OTS_FileLoaderError On binary file loading error. */ public function loadItems($path) { $this->items = new OTS_ItemsList(); // sets items cache if any if( isset($this->itemsCache) ) { $this->items->setCacheDriver($this->itemsCache); } $this->items->loadItems($path); } /** * Checks if items are loaded. * * <p> * You should use this method before fetching items list in new enviroment, or after loading new list to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if items are loaded. */ public function areItemsLoaded() { return isset($this->items); } /** * Unloads items list. * * @version 0.1.0 * @since 0.1.0 */ public function unloadItems() { unset($this->items); } /** * Returns list of laoded items. * * @version 0.1.3 * @since 0.1.0 * @return OTS_ItemsList List of items. * @throws E_OTS_NotLoaded If items list is not loaded. */ public function getItemsList() { if( isset($this->items) ) { return $this->items; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param int $id Item type ID. * @return OTS_ItemType Item type object. * @throws E_OTS_NotLoaded If items list is not loaded. * @deprecated 0.1.3 Use POT::getItemsList()->getItemType(). */ public function getItemType($id) { if( isset($this->items) ) { return $this->items->getItemType($id); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param string $name Item type name. * @return int Type ID. * @throws E_OTS_NotLoaded If items list is not loaded. * @deprecated 0.1.3 Use POT::getItemsList()->getItemTypeId(). */ public function getItemTypeId($name) { if( isset($this->items) ) { return $this->items->getItemTypeId($name); } throw new E_OTS_NotLoaded(); } /** * Cache handler for OTBM loading. * * @version 0.1.0 * @since 0.1.0 * @var IOTS_FileCache */ private $mapCache; /** * Presets cache handler for OTBM loader. * * <p> * Use this method in order to preset cache handler for map that you want to load into global POT instance. Note that this driver will be set for global resource only. If you will create local OTBM instances they won't use this driver automaticly. * </p> * * @param IOTS_FileCache $cache Cache handler (skip this parameter to reset cache handler to null). */ public function setMapCache(IOTS_FileCache $cache = null) { $this->mapCache = $cache; } /** * Loaded map. * * @version 0.1.0 * @since 0.1.0 * @var OTS_OTBMFile */ private $map; /** * Loads OTBM map. * * <p> * This method loads OTBM map from given file. You can create local instances of maps directly - calling this method will associate loaded map with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: This method will also load houses list associated with map. * </p> * * @version 0.1.0 * @since 0.1.0 * @param string $path Map file path. */ public function loadMap($path) { $this->map = new OTS_OTBMFile(); // sets items cache if any if( isset($this->mapCache) ) { $this->map->setCacheDriver($this->mapCache); } $this->map->loadFile($path); $this->houses = $this->map->getHousesList(); } /** * Checks if OTBM is loaded. * * <p> * You should use this method before fetching map information in new enviroment, or after loading new map to make sure it is loaded. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if map is loaded. */ public function isMapLoaded() { return isset($this->map); } /** * Unloads OTBM map. * * @version 0.1.0 * @since 0.1.0 */ public function unloadMap() { unset($this->map); } /** * Returns loaded map. * * @version 0.1.3 * @since 0.1.0 * @return OTS_OTBMFile Loaded OTBM file. * @throws E_OTS_NotLoaded If map is not loaded. */ public function getMap() { if( isset($this->map) ) { return $this->map; } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @return int Map width. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getMapWidth(). */ public function getMapWidth() { if( isset($this->map) ) { return $this->map->getWidth(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @return int Map height. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getMapHeight(). */ public function getMapHeight() { if( isset($this->map) ) { return $this->map->getHeight(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @return string Map description. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getMapDescription(). */ public function getMapDescription() { if( isset($this->map) ) { return $this->map->getDescription(); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param string $name Town. * @return int ID. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getTownId(). */ public function getTownId($name) { if( isset($this->map) ) { return $this->map->getTownId($name); } throw new E_OTS_NotLoaded(); } /** * @version 0.1.3 * @since 0.1.0 * @param int $id Town ID. * @return string Name. * @throws E_OTS_NotLoaded If map is not loaded. * @deprecated 0.1.3 Use POT::getMap()->getTownName(). */ public function getTownName($id) { if( isset($this->map) ) { return $this->map->getTownName($id); } throw new E_OTS_NotLoaded(); } /** * Display driver. * * @version 0.1.0 * @since 0.1.0 * @var IOTS_Display */ private $display; /** * Sets display driver for database-related resources. * * @version 0.1.0 * @since 0.1.0 * @param IOTS_Display $display Display driver. */ public function setDisplayDriver(IOTS_Display $display) { $this->display = $display; } /** * Checks if any display driver is loaded. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.0 * @since 0.1.0 * @return bool True if driver is loaded. */ public function isDisplayDriverLoaded() { return isset($this->display); } /** * Unloads display driver. * * @version 0.1.0 * @since 0.1.0 */ public function unloadDisplayDriver() { unset($this->display); } /** * Returns current display driver. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.3 * @since 0.1.0 * @return IOTS_Display Current display driver. * @throws E_OTS_NotLoaded If display driver is not loaded. */ public function getDisplayDriver() { if( isset($this->display) ) { return $this->display; } throw new E_OTS_NotLoaded(); } /** * Display driver for non-database resources. * * @version 0.1.3 * @since 0.1.3 * @var IOTS_DataDisplay */ private $dataDisplay; /** * Sets display driver for non-database resources. * * @version 0.1.3 * @since 0.1.3 * @param IOTS_DataDisplay $dataDisplay Display driver. */ public function setDataDisplayDriver(IOTS_DataDisplay $dataDisplay) { $this->dataDisplay = $dataDisplay; } /** * Checks if any display driver for non-database resources is loaded. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.3 * @since 0.1.3 * @return bool True if driver is loaded. */ public function isDataDisplayDriverLoaded() { return isset($this->dataDisplay); } /** * Unloads display driver. * * @version 0.1.3 * @since 0.1.3 */ public function unloadDataDisplayDriver() { unset($this->dataDisplay); } /** * Returns current display driver. * * <p> * This method is mostly used internaly by POT classes. * </p> * * @version 0.1.3 * @since 0.1.3 * @return IOTS_DataDisplay Current display driver. * @throws E_OTS_NotLoaded If display driver is not loaded. */ public function getDataDisplayDriver() { if( isset($this->dataDisplay) ) { return $this->dataDisplay; } throw new E_OTS_NotLoaded(); } } /* * This part is for PHP 5.0 compatibility. */ if( !defined('PDO_PARAM_STR') ) { /** * @ignore * @version 0.0.7 * @since 0.0.7 * @deprecated Will be dropped after dropping IOTS_DB::SQLquote() since only this deprecated method uses it. */ define('PDO_PARAM_STR', PDO::PARAM_STR); } if( !defined('PDO_ATTR_STATEMENT_CLASS') ) { /** * @ignore * @version 0.0.7 * @since 0.0.7 * @deprecated Use PDO::ATTR_STATEMENT_CLASS, this is for PHP 5.0 compatibility. */ define('PDO_ATTR_STATEMENT_CLASS', PDO::ATTR_STATEMENT_CLASS); } if( !defined('PDO_ATTR_ERRMODE') ) { /** * @ignore * @version 0.1.3 * @since 0.1.3 * @deprecated Use PDO::ATTR_ERRMODE, this is for PHP 5.0 compatibility. */ define('PDO_ATTR_ERRMODE', PDO::ATTR_ERRMODE); } if( !defined('PDO_ERRMODE_EXCEPTION') ) { /** * @ignore * @version 0.1.3 * @since 0.1.3 * @deprecated Use PDO::ERRMODE_EXCEPTION, this is for PHP 5.0 compatibility. */ define('PDO_ERRMODE_EXCEPTION', PDO::ERRMODE_EXCEPTION); } /**#@-*/ ?>


<?php


/**#@+

* @version 0.0.1

*/


/**

* This file contains main toolkit class. Please read README file for quick startup guide and/or tutorials for more info.

*

* @package POT

* @version 0.1.5

* @author Wrzasq <[email protected]>

* @copyright 2007 - 2008 (C) by Wrzasq

* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3

* @todo future: Deprecations cleanup.

* @todo future: Drop PHP 5.0.x support (PDO:: constants, array type hinting).

* @todo future: Code as C++ extension (as an alternative to pure PHP library which of course would still be available).

* @todo future: Implement POT namespace when it will be supported by PHP.

* @todo future: Complete phpUnit test.

* @todo future: Main POT class as database instance.

* @todo future: E_* classes into *Exception, IOTS_* into *Interface, change POT classes prefix from OTS_* into OT_*, unify *List and *_List naming into *List, remove prefix from filenames.

*/


/**

* Main POT class.

*

* @package POT

* @version 0.1.5

*/

class POT

{

/**

* MySQL driver.

*/

const DB_MYSQL = 1;

/**

* SQLite driver.

*/

const DB_SQLITE = 2;

/**

* PostgreSQL driver.

*

* @version 0.0.4

* @since 0.0.4

*/

const DB_PGSQL = 3;

/**

* ODBC driver.

*

* @version 0.0.4

* @since 0.0.4

*/

const DB_ODBC = 4;


/**

* Female gender.

*/

const SEX_FEMALE = 0;

/**

* Male gender.

*/

const SEX_MALE = 1;


/**

* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

*/

const VOCATION_NONE = 0;

/**

* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

*/

const VOCATION_SORCERER = 1;

/**

* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

*/

const VOCATION_DRUID = 2;

/**

* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

*/

const VOCATION_PALADIN = 3;

/**

* @deprecated 0.0.5 Vocations are now loaded dynamicly from vocations.xml file.

*/

const VOCATION_KNIGHT = 4;


/**

* North.

*/

const DIRECTION_NORTH = 0;

/**

* East.

*/

const DIRECTION_EAST = 1;

/**

* South.

*/

const DIRECTION_SOUTH = 2;

/**

* West.

*/

const DIRECTION_WEST = 3;


/**

* Fist fighting.

*

* @version 0.0.2

* @since 0.0.2

*/

const SKILL_FIST = 0;

/**

* Club fighting.

*

* @version 0.0.2

* @since 0.0.2

*/

const SKILL_CLUB = 1;

/**

* Sword fighting.

*

* @version 0.0.2

* @since 0.0.2

*/

const SKILL_SWORD = 2;

/**

* Axe fighting.

*

* @version 0.0.2

* @since 0.0.2

*/

const SKILL_AXE = 3;

/**

* Distance fighting.

*

* @version 0.0.2

* @since 0.0.2

*/

const SKILL_DISTANCE = 4;

/**

* Shielding.

*

* @version 0.0.2

* @since 0.0.2

*/

const SKILL_SHIELDING = 5;

/**

* Fishing.

*

* @version 0.0.2

* @since 0.0.2

*/

const SKILL_FISHING = 6;


/**

* Head slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_HEAD = 1;

/**

* Necklace slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_NECKLACE = 2;

/**

* Backpack slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_BACKPACK = 3;

/**

* Armor slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_ARMOR = 4;

/**

* Right hand slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_RIGHT = 5;

/**

* Left hand slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_LEFT = 6;

/**

* Legs slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_LEGS = 7;

/**

* Boots slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_FEET = 8;

/**

* Ring slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_RING = 9;

/**

* Ammunition slot.

*

* @version 0.0.3

* @since 0.0.3

*/

const SLOT_AMMO = 10;


/**

* First depot item sid.

*

* @version 0.0.4

* @since 0.0.4

*/

const DEPOT_SID_FIRST = 100;


/**

* IP ban.

*

* @version 0.0.5

* @since 0.0.5

*/

const BAN_IP = 1;

/**

* Player ban.

*

* @version 0.0.5

* @since 0.0.5

*/

const BAN_PLAYER = 2;

/**

* Account ban.

*

* @version 0.0.5

* @since 0.0.5

*/

const BAN_ACCOUNT = 3;


/**

* Ascencind sorting order.

*

* @version 0.0.5

* @since 0.0.5

*/

const ORDER_ASC = 1;

/**

* Descending sorting order.

*

* @version 0.0.5

* @since 0.0.5

*/

const ORDER_DESC = 2;


/**

* @version 0.0.7

* @since 0.0.7

* @deprecated 0.1.0 Use OTS_SpellsList::SPELL_RUNE.

*/

const SPELL_RUNE = 0;

/**

* @version 0.0.7

* @since 0.0.7

* @deprecated 0.1.0 Use OTS_SpellsList::SPELL_INSTANT.

*/

const SPELL_INSTANT = 1;

/**

* @version 0.0.7

* @since 0.0.7

* @deprecated 0.1.0 Use OTS_SpellsList::SPELL_CONJURE.

*/

const SPELL_CONJURE = 2;


/**

* Singleton.

*

* <p>

* This method return global instance of POT class. You can only fetch it this way - class constructor is private and you can't create instance of it other way. This is clasic singleton implementation. As class names are globaly accessible you can fetch it anywhere in code.

* </p>

*

* @return POT Global POT class instance.

* @example examples/quickstart.php quickstart.php

* @tutorial POT/Basics.pkg#basics.instance

*/

public static function getInstance()

{

static $instance;


// creates new instance

if( !isset($instance) )

{

$instance = new self();

}


return $instance;

}


/**

* POT classes directory.

*

* <p>

* Directory path to POT files.

* </p>

*

* @var string

*/

private $path = '';


/**

* Set POT directory.

*

* <p>

* Use this method if you keep your POT package in different directory then this file. Don't need to care about trailing directory separator - it will append it if needed.

* </p>

*

* @param string $path POT files path.

* @example examples/fakeroot.php fakeroot.php

* @tutorial POT/Basics.pkg#basics.fakeroot

*/

public function setPOTPath($path)

{

$this->path = str_replace('\\', '/', $path);


// appends ending slash to directory path

if( substr($this->path, -1) != '/')

{

$this->path .= '/';

}

}


/**

* Class initialization tools.

*

* <p>

* Never create instance of this class by yourself! Use POT::getInstance()!

* </p>

*

* <p>

* Note: Since 0.0.2 version this method registers spl_autoload_register() callback. If you use POT with PHP 5.0 you need {@link compat.php compat.php library} to prevent from FATAL errors.

* </p>

*

* <p>

* Note: Since 0.0.3 version this method is private.

* </p>

*

* @version 0.0.3

*/

private function __construct()

{

// default POT directory

$this->path = dirname(__FILE__) . '/';

// registers POT autoload mechanism

spl_autoload_register( array($this, 'loadClass') );

}


/**

* Loads POT class file.

*

* <p>

* Runtime class loading on demand - usefull for autoloading functions. Usualy you don't need to call this method directly.

* </p>

*

* <p>

* Note: Since 0.0.2 version this method is suitable for spl_autoload_register().

* </p>

*

* <p>

* Note: Since 0.0.3 version this method handles also exception classes.

* </p>

*

* @version 0.0.3

* @param string $class Class name.

*/

public function loadClass($class)

{

if( preg_match('/^(I|E_)?OTS_/', $class) > 0)

{

include_once($this->path . $class . '.php');

}

}


/**

* Database connection.

*

* <p>

* OTServ database connection object.

* </p>

*

* @var PDO

*/

private $db;


/**

* Connects to database.

*

* <p>

* Creates OTServ database connection object.

* </p>

*

* <p>

* First parameter is one of database driver constants values. Currently {@link OTS_DB_MySQL MySQL}, {@link OTS_DB_SQLite SQLite}, {@link OTS_DB_PostgreSQL PostgreSQL} and {@link OTS_DB_ODBC ODBC} drivers are supported. This parameter can be null, then you have to specify <var>'driver'</var> parameter. Such way is comfortable to store entire database configuration in one array and possibly runtime evaluation and/or configuration file saving.

* </p>

*

* <p>

* For parameters list see driver documentation. Common parameters for all drivers are:

* </p>

*

* <ul>

* <li><var>driver</var> - optional, specifies driver, aplies when <var>$driver</var> method parameter is <i>null</i>,</li>

* <li><var>prefix</var> - optional, prefix for database tables, use if you have more then one OTServ installed on one database.</li>

* </ul>

*

* <p>

* Note: Since 0.1.1 version this method throws {@link E_OTS_Generic E_OTS_Generic exceptions} instead of general Exception class objects. Since all exception classes are child classes of Exception class so your old code will still handle all exceptions.

* </p>

*

* <p>

* Note: Since 0.1.2 version this method checks if PDO extension is loaded and if not, then throws LogicException. This exception class is part of SPL library and was introduced in PHP 5.1 so if you use PHP 5.0 you will need to load {@link compat.php compat.php library} first.

* </p>

*

* @version 0.1.3

* @param int|null $driver Database driver type.

* @param array $params Connection info.

* @throws E_OTS_Generic When driver is not supported or not supported.

* @throws LogicException When PDO extension is not loaded.

* @throws PDOException On PDO operation error.

* @example examples/quickstart.php quickstart.php

* @tutorial POT/Basics.pkg#basics.database

*/

public function connect($driver, $params)

{

// checks if PDO extension is loaded

if( !extension_loaded('PDO') )

{

throw new LogicException();

}


// $params['driver'] option instead of $driver

if( !isset($driver) )

{

if( isset($params['driver']) )

{

$driver = $params['driver'];

}

else

{

throw new E_OTS_Generic(E_OTS_Generic::CONNECT_NO_DRIVER);

}

}

unset($params['driver']);


// switch() structure provides us further flexibility

switch($driver)

{

// MySQL database

case self::DB_MYSQL:

$this->db = new OTS_DB_MySQL($params);

break;


// SQLite database

case self::DB_SQLITE:

$this->db = new OTS_DB_SQLite($params);

break;


// SQLite database

case self::DB_PGSQL:

$this->db = new OTS_DB_PostgreSQL($params);

break;


// SQLite database

case self::DB_ODBC:

$this->db = new OTS_DB_ODBC($params);

break;


// unsupported driver

default:

throw new E_OTS_Generic(E_OTS_Generic::CONNECT_INVALID_DRIVER);

}


$this->db->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);

// $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

}


/**

* @version 0.1.0

* @param string $class Class name.

* @return IOTS_DAO OTServ database object.

* @deprecated 0.1.0 Create objects directly from now.

*/

public function createObject($class)

{

$class = 'OTS_' . $class;

return new $class();

}


/**

* Queries server status.

*

* <p>

* Sends 'info' packet to OTS server and return output. Returns {@link OTS_InfoRespond OTS_InfoRespond} (wrapper for XML data) with results or <var>false</var> if server is online.

* </p>

*

* <p>

* Note: Since 0.1.4 version this method is static so you can call it staticly, but it is also still possible to call it in dynamic context.

* </p>

*

* @version 0.1.4

* @since 0.0.2

* @param string $server Server IP/domain.

* @param int $port OTServ port.

* @return OTS_InfoRespond|bool Respond content document (false when server is offline).

* @throws DOMException On DOM operation error.

* @example examples/info.php info.php

* @tutorial POT/Server_status.pkg

* @deprecated 0.1.4 Use OTS_ServerInfo->status().

*/

public static function serverStatus($server, $port)

{

$status = new OTS_ServerInfo($server, $port);

return $status->status();

}


/**

* Returns database connection handle.

*

* <p>

* At all you shouldn't use this method and work with database using POT classes, but it may be sometime necessary to use direct database access (mainly until POT won't provide many important features).

* </p>

*

* <p>

* It is also important as serialised objects after unserialisation needs to be re-initialised with database connection.

* </p>

*

* <p>

* Note that before you will be able to fetch connection handler, you have to connect to database using {@link POT::connect() connect() method}.

* </p>

*

* @version 0.0.4

* @since 0.0.4

* @return PDO Database connection handle.

*/

public function getDBHandle()

{

return $this->db;

}


/**

* Bans given IP number.

*

* <p>

* Adds IP/mask ban. You can call this function with only one parameter to ban only given IP address without expiration.

* </p>

*

* <p>

* Second parameter is mask which you can use to ban entire IP classes. Third parameter is time after which ban will expire. However - this is not lifetime - it is timestamp of moment, when ban should expire (and <var>0</var> means forever).

* </p>

*

* @version 0.1.5

* @since 0.0.5

* @param string $ip IP to ban.

* @param string $mask Mask for ban (by default bans only given IP).

* @param int $time Time for time until expires (0 - forever).

* @throws PDOException On PDO operation error.

* @deprecated 0.1.5 Use OTS_IPBan class.

*/

public function banIP($ip, $mask = '255.255.255.255', $time = 0)

{

// long2ip( ip2long('255.255.255.255') ) != '255.255.255.255' 

obrigado pela luz, era so colocar a pasta pot que esta em libs dentro da pasta install. a instalação concluiu com exito mas agora tenho erro para fazer login, criar conta.

os erros que dão são:

manager account

Fatal error: Uncaught exception 'E_OTS_NotLoaded' in C:\xampp\htdocs\pot\OTS_Account.php:403 Stack trace: #0 C:\xampp\htdocs\accountmanagement.php(25): OTS_Account->getCreated() #1 C:\xampp\htdocs\index.php(159): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\pot\OTS_Account.php on line 403

Creat account

Warning: require_once(recaptchalib.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\createaccount.php on line 178

Fatal error: require_once() [function.require]: Failed opening required 'recaptchalib.php' (include_path='.;\xampp\php\PEAR:./libs') in C:\xampp\htdocs\createaccount.php on line 178

Efetuar login so site:

você coloca a conta e senh, clica em submite e nada acontece apenas da um refresh a pagina e volta pedir login e senha.

Editado por drigoguille (veja o histórico de edições)

logosite.png

r8jhf.gif

Link para o post
Compartilhar em outros sites

mee ajudaaaaa da esse erro quando vou entra no site Warning: parse_ini_file(C:/Tibia Brasil OT/config.lua) [function.parse-ini-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\config-and-functions.php on line 10

Database error. Unknown database type in C:/Tibia Brasil OT/config.lua . Must be equal to: "mysql" or "sqlite". Now is: ""

Link para o post
Compartilhar em outros sites

mee ajudaaaaa da esse erro quando vou entra no site Warning: parse_ini_file(C:/Tibia Brasil OT/config.lua) [function.parse-ini-file]: failed to open stream: No such file or directory in C:\xampp\htdocs\config-and-functions.php on line 10

Database error. Unknown database type in C:/Tibia Brasil OT/config.lua . Must be equal to: "mysql" or "sqlite". Now is: ""

Use este.

config-and-functions.php

Atenciosamente,Mozark.



 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Conteúdo Similar

    • Por Qwizer
      MercadoPago Checkout Transparente (CC)
       
      Abaixo Segue código PHP de pagamento via cartão de credito pelo mercado pago com retorno automático para quem quiser adaptar em seus sites ter uma direção de onde ir 
      testado em Znote e MyAcc.
       

       
       
      https://mega.nz/folder/m4QkWBLS#PIvJ_scVm7w8-5FLlStTHg  
    • Por Underewar
      Tutorial: Criando um Sistema de Enviar efeito com OTClient.


       
      Neste tutorial, vamos criar um sistema simples de Enviar efeito no OTClient.
      Este sistema permitirá que os jogadores ativem um efeito especial e vejam uma janela ao clicar em um botão específico.
      Pré-requisitos:
      Ambiente de Desenvolvimento:
      Certifique-se de ter um ambiente de desenvolvimento configurado com OTClient Edubart. Conhecimento Básico em Lua:
      Familiaridade com a linguagem de script Lua.
       
      Passo 1: Estrutura do projeto
       
      Organize seu projeto conforme abaixo:

      OTC / MODS



      Passo 2: Criando a Interface Gráfica (OTUI)

      game_pass.otui
      Repare que em nossa interface nossos botões de ação entram no caminho do module e iniciam uma função que esta disponivel em nosso game_pass.lua (Client-Side)

       



      Passo 3: Criando funções Client-Side

      Agora com as funções criada podemos chamar elas de acordo com a necessidade em nosso arquivo de interface.
      Por exemplo a função effect() que foi chamada em nosso arquivo de interface.otui agora é criada aqui para mostrar o efeito ao jogador.

      game_pass.lua
       
       
      Passo 4: Registrando o novo Mod

      Agora podemos registrar e iniciar nosso modulo usando o arquivo de configuração

      game_pass.otmod
       

      Feito isso ja podemos ver nosso module no client e enviar opcodes através do gameprotocol e também receber o buffer para manipular os dados podemos utilizar :
      protocolGame:sendExtendedOpcode(14, "1")
      Basicamente oque estamos fazendo é armazenando o valor 1 na variaval 14 do ExtendedOpcode e futuramente podemos recuperar esse valor.

      Recuperamos esse valor em nosso server side data/creatuerscript/otc/game_pass.lua

      Verificando se o opcode é 14 se for 14 então fazemos x ação.

      Show, tendo isso em mente para que o nosso client-side consiga receber com sucesso o efeito enviado ao jogador então utilizamos 

      Passo 5: Criando o Server-side responsavel por enviar o efeito correto ao jogador dependendo do opcode selecionado no nosso cliente.

      data/creaturescripts/otc/game_pass.lua
       
      Passo 6: Registrando o evento para evitar erros futuros!
      Para que tudo funcione corretamente sem erros é  necessário registrar o evento no creaturescript.xml / login.lua

      creaturescript.xml
      <event type="extendedopcode" name="GamePass" script="otc/game_pass.lua" />
      login.lua
          player:registerEvent("GamePass")  


      Ótimo agora ao selecionar o menu recompensa o jogador recebera um efeito.

      Espero que tenha ficado claro como usar Opcodes/ExetendedOpcodes.

      Arquivos usados no tutorrial:
      OTC MODULE
      game_pass.rar
      Creaturescript
      game_pass.lua

      Vi muitos tutoriais desatualizado então resolvi trazer esse!
      Reparem que nesse caso passamos creature como parametro do buffer isso porque precisamos enviar um efeito no player.

      Melhorando a formatação com JSON Encoder

       
       
    • Por Argona2509
      Boa tarde venho por aqui pedir ajuda estou com um problema no gesior para criar conta nao aparece vocacao e o nome Nadega Sample
       
       
    • Por Magato
      Galera, boa tarde a todos.
       
      Estou iniciando um servidor com o mapa Pbot e estou com dificuldades em encontrar um website para ele.
       
      Procurei na internet toda e não achei um link que me levasse ao download do Gesior Onix para pbot exclusivo (o link estava quebrado)
       
      Tentei utilizar o Gesior 2012 mas o layout do site e todas as funcionalidades estão bugadas.
       
      Gostaria que alguém pudesse me ajudar e postasse aqui algum link de gesior para PBOT. A versão do meu servidor é 8.60.
       
      Agradeço a quem puder.
       
       
    • Por Andersontatuador
      .Qual servidor ou website você utiliza como base? 
      Global Full 8.60 + Zao
      Qual o motivo deste tópico? 
      O site não esta adicionando os pontos na conta dos plays.
       
      Está surgindo algum erro? Se sim coloque-o aqui. 
       
      Você tem o código disponível? Se tiver publique-o aqui: 
         
      Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 
       






×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo