Advertisement
Guest User

Untitled

a guest
May 13th, 2017
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 28.24 KB | None | 0 0
  1. <?PHP
  2. $config['site'] = parse_ini_file('config/config.ini');
  3. session_start();
  4. //save config in ini file
  5. function saveconfig_ini($config) {
  6. $file = fopen("config/config.ini", "w");
  7. foreach($config as $param => $data) {
  8. $file_data .= $param.' = "'.str_replace('"', '', $data).'"
  9. ';
  10. }
  11. rewind($file);
  12. fwrite($file, $file_data);
  13. fclose($file);
  14. }
  15.  
  16. function check_password($pass)
  17. {
  18.   $temp = strspn("$pass", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890");
  19.   if ($temp != strlen($pass)) {
  20.   return false;
  21.   }
  22.   else
  23.   {
  24.   $ok = "/[a-zA-Z0-9]{1,40}/";
  25.   return (preg_match($ok, $pass))? true: false;
  26.   }
  27. }
  28.  
  29. function password_ency($password) {
  30. $ency = $GLOBALS['passwordency'];
  31. if($ency == 'sha1') {
  32. return sha1($password);
  33. }
  34. if($ency == 'md5') {
  35. return md5($password);
  36. }
  37. if($ency == '') {
  38. return $password;
  39. }
  40. }
  41.  
  42. if($_REQUEST['page'] == '' && !isset($_REQUEST['step'])) {
  43. echo '<html>
  44. <head>
  45.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  46.     <title>Installation of account maker</title>
  47. </head>
  48. <frameset cols="230,*">
  49.     <frame name="menu" src="install.php?page=menu" />
  50.     <frame name="step" src="install.php?page=step&step=0" />
  51.     <noframes><body>Frames don\'t work. Install Firefox :P</body></noframes>
  52. </frameset>
  53. </html>';
  54. }
  55. if($_REQUEST['page'] == 'menu') {
  56. echo '<h2>MENU</h2><br>
  57. <b>IF NOT INSTALLED:</b><br>
  58. <a href="install.php?page=step&step=start" target="step">0. Informations</a><br>
  59. <a href="install.php?page=step&step=1" target="step">1. Set server path</a><br>
  60. <a href="install.php?page=step&step=2" target="step">2. Check DataBase connection</a><br>
  61. <a href="install.php?page=step&step=3&server_conf=yes" target="step">3. Add tables and columns to DB</a><br>
  62. <a href="install.php?page=step&step=4&server_conf=yes" target="step">4. Add samples to DB</a><br>
  63. <a href="install.php?page=step&step=5&server_conf=yes" target="step">5. Set Admin Account</a><br>
  64. <b>FOR ADMINS:</b><br>
  65. <a href="index.php?subtopic=adminpanel&action=install_monsters" target="step">6. Load Monsters from OTS</a><br>
  66. <a href="index.php?subtopic=adminpanel&action=install_spells" target="step">7. Load Spells from OTS</a><br>
  67. <a href="index.php?subtopic=adminpanel&action=install_vocations" target="step" onClick="alert(\'Here you can configure vocations to page >Create Character<. Remember: ALWAYS check >Add to create character list?< near vocations that you want to be available when user open >Create Character< page! \');">8. Configure vocations</a><br>
  68. <a href="index.php?subtopic=adminpanel&action=editaccountmanager" target="step" onClick="alert(\'>accept new e-mail time< can be like 0.001 or 0.05 it mean player can accept new e-mail after >0.001 day<, day = 86400 seconds, 86400*0.001 = 86.4 seconds\');">Configure <b>Account Manager</b></a><br>
  69. <a href="index.php?subtopic=adminpanel&action=editcreateaccount" target="step">Configure <b>Create Account</b></a><br>
  70. <a href="index.php?subtopic=adminpanel&action=editmainconfig" target="step">Configure <b>SITE options</b></a><br>';
  71.  
  72. }
  73. if($_REQUEST['page'] == 'step') {
  74. if($config['site']['install'] != "no") {
  75. if($_REQUEST['server_conf'] == 'yes' || ($_REQUEST['step'] > 2 && $_REQUEST['step'] < 6)) {
  76. //load server config
  77. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  78. if(isset($config['server']['mysqlHost'])) {
  79. //new (0.2.6+) ots config.lua file
  80. $mysqlhost = $config['server']['mysqlHost'];
  81. $mysqluser = $config['server']['mysqlUser'];
  82. $mysqlpass = $config['server']['mysqlPass'];
  83. $mysqldatabase = $config['server']['mysqlDatabase'];
  84. }
  85. elseif(isset($config['server']['sqlHost'])) {
  86. //old (0.2.4) ots config.lua file
  87. $mysqlhost = $config['server']['sqlHost'];
  88. $mysqluser = $config['server']['sqlUser'];
  89. $mysqlpass = $config['server']['sqlPass'];
  90. $mysqldatabase = $config['server']['sqlDatabase'];
  91. }
  92. $sqlitefile = $config['server']['sqliteDatabase'];
  93. $passwordency = '';
  94. if(strtolower($config['server']['useMD5Passwords']) == 'yes' || strtolower($config['server']['passwordType']) == 'md5') {
  95.     $passwordency = 'md5';
  96. }
  97. if(strtolower($config['server']['passwordType']) == 'sha1') {
  98.     $passwordency = 'sha1';
  99. }
  100. // loads #####POT mainfile#####
  101. include('pot/OTS.php');
  102. // PDO and POT connects to database
  103. $ots = POT::getInstance();
  104. if(strtolower($config['server']['sqlType']) == "mysql")
  105. {
  106.     //connect to MySQL database
  107.     try
  108.     {
  109.         $ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
  110.     }
  111.     catch(PDOException $error)
  112.     {
  113.         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.';
  114.         exit;
  115.     }
  116. }
  117. elseif(strtolower($config['server']['sqlType']) == "sqlite")
  118. {
  119.     //connect to SQLite database
  120.     $link_to_sqlitedatabase = $config['site']['server_path'].$sqlitefile;
  121.     try
  122.     {
  123.         $ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
  124.     }
  125.     catch(PDOException $error)
  126.     {
  127.         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.';
  128.         exit;
  129.     }
  130. }
  131. else
  132. {
  133.     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>';
  134.     exit;
  135. }
  136. $SQL = POT::getInstance()->getDBHandle();
  137. }
  138. $step = $_REQUEST['step'];
  139. if(empty($step)) {
  140. $step = $config['site']['install'];
  141. }
  142. if($step == 'start') {
  143. echo '<h1>STEP '.$step.'</h1>Informations<br>';
  144. echo 'Welcome to Gesior Account Maker installer. <b>First do steps 1-5 one by one, later (when you will be logged on admin account) press on links to steps 6-11 to load configuration from OTS.</b>';
  145. }
  146. if($step == '1') {
  147. if(isset($_REQUEST['server_path'])) {
  148.     echo '<h1>STEP '.$step.'</h1>Check server configuration<br>';
  149.     $config['site']['server_path'] = $_REQUEST['server_path'];
  150.     $config['site']['server_path'] = trim($config['site']['server_path'])."\\";
  151.     $config['site']['server_path'] = str_replace("\\\\", "/", $config['site']['server_path']);
  152.     $config['site']['server_path'] = str_replace("\\", "/", $config['site']['server_path']);
  153.     $config['site']['server_path'] = str_replace("//", "/", $config['site']['server_path']);
  154.     saveconfig_ini($config['site']);
  155.     if(file_exists($config['site']['server_path'].'config.lua')) {
  156.         $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  157.         if(isset($config['server']['sqlType'])) {
  158.             $config['site']['install'] = 2;
  159.             saveconfig_ini($config['site']);
  160.             echo 'File <b>config.lua</b> loaded from <font color="red"><i>'.$config['site']['server_path'].'config.lua</i></font> and looks like fine server config file. Now you can check database('.$config['server']['sqlType'].') connection: <a href="install.php?page=step&step=2">STEP 2 - check database connection</a>';
  161.         }
  162.         else
  163.         {
  164.             echo 'File <b>config.lua</b> loaded from <font color="red"><i>'.$config['site']['server_path'].'config.lua</i></font> and it\'s not valid TFS config.lua file. <a href="install.php?page=step&step=1">Go to STEP 1 - select other directory.</a> If it\'s your config.lua file from TFS contact with acc. maker author.';
  165.         }
  166.     }
  167.     else
  168.     {
  169.         echo 'Can\'t load file <b>config.lua</b> from <font color="red"><i>'.$config['site']['server_path'].'config.lua</i></font> File doesn\'t exist in selected directory. <a href="install.php?page=step&step=1">Go to STEP 1 - select other directory.</a>';
  170.     }
  171. }
  172. else
  173. {
  174. echo 'Please write you TFS directory below. Like: <i>C:\Documents and Settings\Gesior\Desktop\TFS 0.2.9\</i><form action="install.php">
  175. <input type="text" name="server_path" size="90" value="'.$config['site']['server_path'].'" /><input type="hidden" name="page" value="step" /><input type="hidden" name="step" value="1" /><input type="submit" value="Set server path" />
  176. </form>';
  177. }
  178. }
  179. if($step == '2') {
  180. echo '<h1>STEP '.$step.'</h1>Check database connection<br>';
  181. echo 'If you don\'t see any errors press <a href="install.php?page=step&step=3&server_conf=yes">link to STEP 3 - Add tables and columns to DB</a>. If you see some errors it mean server has wrong configuration. Check FAQ or ask author of acc. maker.';
  182. //load server config
  183. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  184. if(isset($config['server']['mysqlHost'])) {
  185. //new (0.2.6+) ots config.lua file
  186. $mysqlhost = $config['server']['mysqlHost'];
  187. $mysqluser = $config['server']['mysqlUser'];
  188. $mysqlpass = $config['server']['mysqlPass'];
  189. $mysqldatabase = $config['server']['mysqlDatabase'];
  190. }
  191. elseif(isset($config['server']['sqlHost'])) {
  192. //old (0.2.4) ots config.lua file
  193. $mysqlhost = $config['server']['sqlHost'];
  194. $mysqluser = $config['server']['sqlUser'];
  195. $mysqlpass = $config['server']['sqlPass'];
  196. $mysqldatabase = $config['server']['sqlDatabase'];
  197. }
  198. $sqlitefile = $config['server']['sqliteDatabase'];
  199. $passwordency = '';
  200. if(strtolower($config['server']['useMD5Passwords']) == 'yes' || strtolower($config['server']['passwordType']) == 'md5') {
  201.     $passwordency = 'md5';
  202. }
  203. if(strtolower($config['server']['passwordType']) == 'sha1') {
  204.     $passwordency = 'sha1';
  205. }
  206. // loads #####POT mainfile#####
  207. include('pot/OTS.php');
  208. // PDO and POT connects to database
  209. $ots = POT::getInstance();
  210. if(strtolower($config['server']['sqlType']) == "mysql")
  211. {
  212.     //connect to MySQL database
  213.     try
  214.     {
  215.         $ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
  216.     }
  217.     catch(PDOException $error)
  218.     {
  219.         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.';
  220.         exit;
  221.     }
  222. }
  223. elseif(strtolower($config['server']['sqlType']) == "sqlite")
  224. {
  225.     //connect to SQLite database
  226.     $link_to_sqlitedatabase = $config['site']['server_path'].$sqlitefile;
  227.     try
  228.     {
  229.         $ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
  230.     }
  231.     catch(PDOException $error)
  232.     {
  233.         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.';
  234.         exit;
  235.     }
  236. }
  237. else
  238. {
  239.     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>';
  240.     exit;
  241. }
  242. $SQL = POT::getInstance()->getDBHandle();
  243. $config['site']['install'] = 3;
  244. saveconfig_ini($config['site']);
  245. }
  246. if($step == '3') {
  247. echo '<h1>STEP '.$step.'</h1>Add tables and columns to DB<br>';
  248. echo 'Installer try to add new tables and columns to database.<br>';
  249.         $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  250.         if($config['server']['sqlType'] == "sqlite") {
  251.             //if sqlite
  252.             try { $SQL->query('ALTER TABLE accounts ADD "key" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  253.             try { $SQL->query('ALTER TABLE accounts ADD "page_lastday" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  254.             try { $SQL->query('ALTER TABLE accounts ADD "email_new" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  255.             try { $SQL->query('ALTER TABLE accounts ADD "email_new_time" INTEGER(15) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  256.             try { $SQL->query('ALTER TABLE accounts ADD "created" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  257.             try { $SQL->query('ALTER TABLE accounts ADD "rlname" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  258.             try { $SQL->query('ALTER TABLE accounts ADD "location" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  259.             try { $SQL->query('ALTER TABLE accounts ADD "page_access" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  260.             try { $SQL->query('ALTER TABLE accounts ADD "email_code" VARCHAR(255) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  261.             try { $SQL->query('ALTER TABLE accounts ADD "next_email" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  262.             try { $SQL->query('ALTER TABLE accounts ADD "premium_points" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  263.             echo "Added columns to table <b>accounts</b>.<br/>";
  264.             try { $SQL->query('ALTER TABLE guilds ADD "description" TEXT NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  265.             try { $SQL->query('ALTER TABLE guilds ADD "logo_gfx_name" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  266.             echo "Added columns to table <b>guilds</b>.<br/>";
  267.             try { $SQL->query('ALTER TABLE players ADD "online" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  268.             try { $SQL->query('ALTER TABLE players ADD "created" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  269.             try { $SQL->query('ALTER TABLE players ADD "nick_verify" VARCHAR(5) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  270.             try { $SQL->query('ALTER TABLE players ADD "hide_char" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  271.             try { $SQL->query('ALTER TABLE players ADD "comment" TEXT NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  272.             echo "Added columns to table <b>players</b>.<br/>";
  273.             try { $SQL->query('CREATE TABLE "z_news_big" (
  274.                         "hide_news" INTEGER NOT NULL DEFAULT 0,
  275.                         "date" INTEGER NOT NULL,
  276.                         "author" VARCHAR(255) NOT NULL,
  277.                         "author_id" INTEGER NOT NULL,
  278.                         "image_id" INTEGER NOT NULL DEFAULT 0,
  279.                         "topic" VARCHAR(255) NOT NULL,
  280.                         "text" TEXT NOT NULL);'); } catch(PDOException $error) {}
  281.             echo "Added table <b>z_news_big</b> (news).<br/>";
  282.             try { $SQL->query('CREATE TABLE "z_news_tickers" (
  283.                         "date" INTEGER NOT NULL,
  284.                         "author" INTEGER NOT NULL,
  285.                         "image_id" INTEGER NOT NULL DEFAULT 0,
  286.                         "text" TEXT NOT NULL,
  287.                         "hide_ticker" INTEGER NOT NULL DEFAULT 0);'); } catch(PDOException $error) {}
  288.             echo "Added table <b>z_news_tickers</b> (tickers).<br/>";
  289.             try { $SQL->query('CREATE TABLE "z_spells" (
  290.                         "name" VARCHAR(255) NOT NULL,
  291.                         "spell" VARCHAR(255) NOT NULL,
  292.                         "spell_type" VARCHAR(255) NOT NULL,
  293.                         "mana" INTEGER NOT NULL DEFAULT 0,
  294.                         "lvl" INTEGER NOT NULL DEFAULT 0,
  295.                         "mlvl" INTEGER NOT NULL DEFAULT 0,
  296.                         "soul" INTEGER NOT NULL DEFAULT 0,
  297.                         "pacc" VARCHAR(255) NOT NULL,
  298.                         "vocations" VARCHAR(255) NOT NULL,
  299.                         "conj_count" INTEGER NOT NULL DEFAULT 0,
  300.                         "hide_spell" INTEGER NOT NULL DEFAULT 0);'); } catch(PDOException $error) {}
  301.             echo "Added table <b>z_spells</b> (spells list).<br/>";
  302.             try { $SQL->query('CREATE TABLE "z_monsters" (
  303.               "hide_creature" INTEGER NOT NULL DEFAULT 0,
  304.               "name" VARCHAR(255) NOT NULL,
  305.               "mana" INTEGER NOT NULL,
  306.               "exp" INTEGER NOT NULL,
  307.               "health" INTEGER NOT NULL,
  308.               "speed_lvl" INTEGER NOT NULL DEFAULT 1,
  309.               "use_haste" INTEGER NOT NULL,
  310.               "voices" text NOT NULL,
  311.               "immunities" VARCHAR(255) NOT NULL,
  312.               "summonable" INTEGER NOT NULL,
  313.               "convinceable" INTEGER NOT NULL,
  314.               "race" VARCHAR(255) NOT NULL,
  315.               "gfx_name" VARCHAR(255) NOT NULL)'); } catch(PDOException $error) {}
  316.             echo 'Added table <b>z_monsters</b> (monsters list).<br/>';
  317.         }
  318.         elseif($config['server']['sqlType'] == "mysql")
  319.         {
  320.             //if mysql
  321.             try { $SQL->query("ALTER TABLE `accounts` ADD `key` VARCHAR( 20 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
  322.             try { $SQL->query("ALTER TABLE `accounts` ADD `page_lastday` INT( 11 ) NOT NULL;"); } catch(PDOException $error) {}
  323.             try { $SQL->query("ALTER TABLE `accounts` ADD `email_new` VARCHAR( 255 ) NOT NULL;"); } catch(PDOException $error) {}
  324.             try { $SQL->query("ALTER TABLE `accounts` ADD `email_new_time` INT( 15 ) NOT NULL;"); } catch(PDOException $error) {}
  325.             try { $SQL->query("ALTER TABLE `accounts` ADD `created` INT( 11 ) NOT NULL;"); } catch(PDOException $error) {}
  326.             try { $SQL->query("ALTER TABLE `accounts` ADD `rlname` VARCHAR( 255 ) NOT NULL;"); } catch(PDOException $error) {}
  327.             try { $SQL->query("ALTER TABLE `accounts` ADD `location` VARCHAR( 255 ) NOT NULL;"); } catch(PDOException $error) {}
  328.             try { $SQL->query("ALTER TABLE `accounts` ADD `page_access` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
  329.             try { $SQL->query("ALTER TABLE `accounts` ADD `email_code` VARCHAR( 255 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
  330.             try { $SQL->query("ALTER TABLE `accounts` ADD `next_email` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
  331.             try { $SQL->query("ALTER TABLE `accounts` ADD `premium_points` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
  332.             echo "Added columns to table <b>accounts</b><br/>";
  333.             try { $SQL->query('ALTER TABLE `guilds` ADD `description` TEXT NOT NULL;'); } catch(PDOException $error) {}
  334.             try { $SQL->query('ALTER TABLE `guilds` ADD `logo_gfx_name` VARCHAR( 255 ) NOT NULL;'); } catch(PDOException $error) {}
  335.             echo "Added columns to table <b>guilds</b>.<br/>";
  336.             try { $SQL->query("ALTER TABLE `players` ADD `online` INT( 11 ) NOT NULL;"); } catch(PDOException $error) {}
  337.             try { $SQL->query("ALTER TABLE `players` ADD `created` INT( 11 ) NOT NULL;"); } catch(PDOException $error) {}
  338.             try { $SQL->query("ALTER TABLE `players` ADD `nick_verify` VARCHAR( 5 ) NOT NULL;"); } catch(PDOException $error) {}
  339.             try { $SQL->query("ALTER TABLE `players` ADD `hide_char` INT( 11 ) NOT NULL DEFAULT '0';"); } catch(PDOException $error) {}
  340.             try { $SQL->query("ALTER TABLE `players` ADD `comment` TEXT NOT NULL;"); } catch(PDOException $error) {}
  341.             echo "Added columns to table <b>players</b><br/>";
  342.             try { $SQL->query("CREATE TABLE `z_news_big` (
  343.                         `hide_news` tinyint(1) NOT NULL DEFAULT '0',
  344.                         `date` int(11) NOT NULL DEFAULT '0',
  345.                         `author` varchar(255) NOT NULL,
  346.                         `author_id` int(11) NOT NULL,
  347.                         `image_id` int(3) NOT NULL DEFAULT '0',
  348.                         `topic` varchar(255) NOT NULL,
  349.                         `text` text NOT NULL
  350.                         ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); } catch(PDOException $error) {}
  351.             echo "Added table <b>z_news_big</b> (news).<br/>";
  352.             try { $SQL->query("CREATE TABLE `z_news_tickers` (
  353.                         `date` int(11) NOT NULL default '1',
  354.                         `author` int(11) NOT NULL,
  355.                         `image_id` int(3) NOT NULL default '0',
  356.                         `text` text NOT NULL,
  357.                         `hide_ticker` tinyint(1) NOT NULL
  358.                         ) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
  359.             echo "Added table <b>z_news_tickers</b> (tickers).<br/>"; } catch(PDOException $error) {}
  360.             try { $SQL->query('CREATE TABLE `z_spells` (
  361.                         `name` VARCHAR(255) NOT NULL,
  362.                         `spell` VARCHAR(255) NOT NULL,
  363.                         `spell_type` VARCHAR(255) NOT NULL,
  364.                         `mana` INTEGER NOT NULL DEFAULT 0,
  365.                         `lvl` INTEGER NOT NULL DEFAULT 0,
  366.                         `mlvl` INTEGER NOT NULL DEFAULT 0,
  367.                         `soul` INTEGER NOT NULL DEFAULT 0,
  368.                         `pacc` VARCHAR(255) NOT NULL,
  369.                         `vocations` VARCHAR(255) NOT NULL,
  370.                         `conj_count` INTEGER NOT NULL DEFAULT 0,
  371.                         `hide_spell` INTEGER NOT NULL DEFAULT 0);'); } catch(PDOException $error) {}
  372.             echo 'Added table <b>z_spells</b> (spells list).<br/>';
  373.             try { $SQL->query('CREATE TABLE `z_monsters` (
  374.               `hide_creature` tinyint(1) NOT NULL default \'0\',
  375.               `name` varchar(255) NOT NULL,
  376.               `mana` int(11) NOT NULL,
  377.               `exp` int(11) NOT NULL,
  378.               `health` int(11) NOT NULL,
  379.               `speed_lvl` int(11) NOT NULL default \'1\',
  380.               `use_haste` tinyint(1) NOT NULL,
  381.               `voices` text NOT NULL,
  382.               `immunities` varchar(255) NOT NULL,
  383.               `summonable` tinyint(1) NOT NULL,
  384.               `convinceable` tinyint(1) NOT NULL,
  385.               `race` varchar(255) NOT NULL,
  386.               `gfx_name` varchar(255) NOT NULL
  387.             ) ENGINE=MyISAM DEFAULT CHARSET=latin1;'); } catch(PDOException $error) {}
  388.             echo 'Added table <b>z_monsters</b> (monsters list).<br/>';
  389.         }
  390.         $config['site']['install'] = 4;
  391.         saveconfig_ini($config['site']);
  392.     echo 'All tables and columns added to database.<br>Go to <a href="install.php?page=step&step=4&server_conf=yes">STEP 4 - Add samples</a>';
  393. }
  394. if($step == '4') {
  395. echo '<h1>STEP '.$step.'</h1>Add samples to DB:<br>';
  396. $check_news_ticker = $SQL->query('SELECT * FROM z_news_tickers WHERE image_id = 1 AND author = 1 AND hide_ticker = 0 LIMIT 1 OFFSET 0')->fetch();
  397. if(!isset($check_news_ticker['author'])) {
  398. $SQL->query('INSERT INTO z_news_tickers (date, author, image_id, text, hide_ticker) VALUES ('.time().', 1, 1, "Hello! Gesior account manager 0.31 installed. Report bugs to gesiorjr@poczta.fm", 0)');
  399. echo "Added first news ticker.<br/>";
  400. } else {
  401. echo "News ticker sample is already in database. New sample is not needed.<br/>";
  402. }
  403. $check_news = $SQL->query('SELECT * FROM z_news_big WHERE author = "Gesior" LIMIT 1 OFFSET 0')->fetch();
  404. if(!isset($check_news['author'])) {
  405. $SQL->query('INSERT INTO z_news_big (hide_news, date, author, author_id, image_id, topic, text) VALUES (0, '.time().', "Gesior", 1, 0, "New account manager!", "Gesior account manager 0.31 installed. All options should work fine. Report bugs in acc. maker thread");');
  406. echo "Added first news.<br/>";
  407. } else {
  408. echo "News sample is already in database. New sample is not needed.<br/>";
  409. }
  410. $check_voc_0 = $SQL->query('SELECT * FROM players WHERE name = "Rook Sample" LIMIT 1 OFFSET 0')->fetch();
  411. if(!isset($check_voc_0['name'])) {
  412. $SQL->query('INSERT INTO players (name, group_id, account_id, sex, vocation, experience, level, maglevel, health, healthmax, mana, manamax, manaspent, soul, direction, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, posx, posy, posz, cap, lastlogin, lastip, save, conditions, redskulltime, redskull, guildnick, rank_id, town_id, loss_experience, loss_mana, loss_skills, lastlogout, blessings, premend, online, comment, created, hide_char, nick_verify) VALUES ("Rook Sample", 1, 1, 1, 0, 0, 1, 0, 185, 185, 35, 35, 0, 100,"", 44, 44, 44, 44, 128, 0, 0, 0, 0, 420, "", "", 1,"","","","","","1","","","","","","","","",'.time().',1,1)');
  413. echo "Added 'Rook Sample' character.<br/>";
  414. } else {
  415. echo "Character 'Rook Sample' already in database.<br/>";
  416. }
  417. $check_voc_1 = $SQL->query('SELECT * FROM players WHERE name = "Sorcerer Sample" LIMIT 1 OFFSET 0')->fetch();
  418. if(!isset($check_voc_1['name'])) {
  419. $SQL->query('INSERT INTO players (name, group_id, account_id, sex, vocation, experience, level, maglevel, health, healthmax, mana, manamax, manaspent, soul, direction, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, posx, posy, posz, cap, lastlogin, lastip, save, conditions, redskulltime, redskull, guildnick, rank_id, town_id, loss_experience, loss_mana, loss_skills, lastlogout, blessings, premend, online, comment, created, hide_char, nick_verify) VALUES ("Sorcerer Sample", 1, 1, 1, 1, 0, 1, 0, 185, 185, 35, 35, 0, 100,"", 44, 44, 44, 44, 128, 0, 0, 0, 0, 420, "", "", 1,"","","","","","1","","","","","","","","",'.time().',1,1)');
  420. echo "Added 'Sorcerer Sample' character.<br/>";
  421. } else {
  422. echo "Character 'Sorcerer Sample' already in database.<br/>";
  423. }
  424. $check_voc_2 = $SQL->query('SELECT * FROM players WHERE name = "Druid Sample" LIMIT 1 OFFSET 0')->fetch();
  425. if(!isset($check_voc_2['name'])) {
  426. $SQL->query('INSERT INTO players (name, group_id, account_id, sex, vocation, experience, level, maglevel, health, healthmax, mana, manamax, manaspent, soul, direction, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, posx, posy, posz, cap, lastlogin, lastip, save, conditions, redskulltime, redskull, guildnick, rank_id, town_id, loss_experience, loss_mana, loss_skills, lastlogout, blessings, premend, online, comment, created, hide_char, nick_verify) VALUES ("Druid Sample", 1, 1, 1, 2, 0, 1, 0, 185, 185, 35, 35, 0, 100,"", 44, 44, 44, 44, 128, 0, 0, 0, 0, 420, "", "", 1,"","","","","","1","","","","","","","","",'.time().',1,1)');
  427. echo "Added 'Druid Sample' character.<br/>";
  428. } else {
  429. echo "Character 'Druid Sample' already in database.<br/>";
  430. }
  431. $check_voc_3 = $SQL->query('SELECT * FROM players WHERE name = "Paladin Sample" LIMIT 1 OFFSET 0')->fetch();
  432. if(!isset($check_voc_3['name'])) {
  433. $SQL->query('INSERT INTO players (name, group_id, account_id, sex, vocation, experience, level, maglevel, health, healthmax, mana, manamax, manaspent, soul, direction, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, posx, posy, posz, cap, lastlogin, lastip, save, conditions, redskulltime, redskull, guildnick, rank_id, town_id, loss_experience, loss_mana, loss_skills, lastlogout, blessings, premend, online, comment, created, hide_char, nick_verify) VALUES ("Paladin Sample", 1, 1, 1, 3, 0, 1, 0, 185, 185, 35, 35, 0, 100,"", 44, 44, 44, 44, 128, 0, 0, 0, 0, 420, "", "", 1,"","","","","","1","","","","","","","","",'.time().',1,1)');
  434. echo "Added 'Paladin Sample' character.<br/>";
  435. } else {
  436. echo "Character 'Paladin Sample' already in database.<br/>";
  437. }
  438. $check_voc_4 = $SQL->query('SELECT * FROM players WHERE name = "Knight Sample" LIMIT 1 OFFSET 0')->fetch();
  439. if(!isset($check_voc_4['name'])) {
  440. $SQL->query('INSERT INTO players (name, group_id, account_id, sex, vocation, experience, level, maglevel, health, healthmax, mana, manamax, manaspent, soul, direction, lookbody, lookfeet, lookhead, looklegs, looktype, lookaddons, posx, posy, posz, cap, lastlogin, lastip, save, conditions, redskulltime, redskull, guildnick, rank_id, town_id, loss_experience, loss_mana, loss_skills, lastlogout, blessings, premend, online, comment, created, hide_char, nick_verify) VALUES ("Knight Sample", 1, 1, 1, 4, 0, 1, 0, 185, 185, 35, 35, 0, 100,"", 44, 44, 44, 44, 128, 0, 0, 0, 0, 420, "", "", 1,"","","","","","1","","","","","","","","",'.time().',1,1)');
  441. echo "Added 'Knight Sample' character.<br/>";
  442. } else {
  443. echo "Character 'Knight Sample' already in database.<br/>";
  444. $config['site']['install'] = 5;
  445. saveconfig_ini($config['site']);
  446. echo 'All samples added to database. Now you can go to <a href="install.php?page=step&step=5&server_conf=yes">STEP 5 - Set Admin Account</a><br/>';
  447. }
  448. }
  449. if($step == '5') {
  450. echo '<h1>STEP '.$step.'</h1>Set Admin Account<br>';
  451. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  452. if(empty($_REQUEST['saveaccpassword'])) {
  453.     echo 'Admin account number is: <b>1</b><br/>Set new password to this account.<br>';
  454.     echo 'New password: <form action="install.php" method=POST><input type="text" name="newpass" size="35">(Don\'t give it password to anyone!)';
  455.     echo '<input type="hidden" name="saveaccpassword" value="yes"><input type="hidden" name="page" value="step"><input type="hidden" name="step" value="5"><input type="submit" value="SET"></form><br>If account with number 1 doesn\'t exist installator will create it and set your password.';
  456.     } else {
  457.    
  458.     $newpass = $_POST['newpass'];
  459.     if(!check_password($newpass)) {
  460.     echo 'Password contains illegal characters. Please use only a-Z and 0-9. <a href="install.php?page=step&step=5&server_conf=yes">GO BACK</a> and write other password.';
  461.     }
  462.     else
  463.     {
  464.     $newpass_to_db = password_ency($newpass);
  465.     //ustawienie/stworzenie konta admina
  466.     $account = new OTS_Account();
  467.     $account->load(1);
  468.     if($account->isLoaded()) {
  469.     //set password
  470.     $account->setPassword($newpass_to_db);
  471.     $account->save();
  472.     $account->setCustomField("page_access", 3);
  473.     }
  474.     else
  475.     {
  476.     //create account
  477.     $number = $account->create(1,1);
  478.     $account->setPassword($newpass_to_db);
  479.     $account->unblock();
  480.     $account->save();
  481.     $account->setCustomField("created", time());
  482.     $account->setCustomField("page_access", 3);
  483.     }
  484.     $_SESSION['account'] = 1;
  485.     $_SESSION['password'] = $newpass;
  486.     $logged = TRUE;
  487.     $account->setCustomField("page_lastday", time());
  488.     echo '<h1>Admin account number: 1<br>Admin account password: '.$_POST['newpass'].'</h1><br/><h3>It\'s end of first part of installation. Installation is blocked. From now don\'t modify file config.ini!<br>Press links to STEPs 6-9 in menu.</h3>';
  489.     $config['site']['install'] = 'no';
  490.     saveconfig_ini($config['site']);
  491.     }
  492.     }
  493. }
  494. }
  495. else
  496. {
  497. echo "Account maker is already installed! To reinstall open file 'config.ini' in directory 'config' and change:<br/><b>install = \"no\"</b><br/>to:</br><b>install = \"start\"</b><br/>and enter this site again.";
  498. }
  499. }
  500. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement