Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 40.83 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. {
  31. $ency = $GLOBALS['passwordency'];
  32. if($ency == 'sha1')
  33. return sha1($password);
  34. elseif($ency == 'md5')
  35. return md5($password);
  36. elseif($ency == '')
  37. return $password;
  38. }
  39.  
  40. if($_GET['page'] == '' && !isset($_GET['step'])){
  41. echo '<html>
  42. <head>
  43. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  44. <title>Installation of account maker</title>
  45. </head>
  46. <frameset cols="230,*">
  47. <frame name="menu" src="install.php?page=menu" />
  48. <frame name="step" src="install.php?page=step&step=0" />
  49. <noframes><body>Frames don\'t work. Install Firefox :P</body></noframes>
  50. </frameset>
  51. </html>';}
  52. if($_GET['page'] == 'menu'){
  53. echo '<h2>MENU</h2><br><b>IF NOT INSTALLED:</b><br>
  54. <a href="install.php?page=step&step=start" target="step">0. Informations</a><br>
  55. <a href="install.php?page=step&step=1" target="step">1. Set server path</a><br>
  56. <a href="install.php?page=step&step=2" target="step">2. Check DataBase connection</a><br>
  57. <a href="install.php?page=step&step=3&server_conf=yes" target="step">3. Add tables and columns to DB</a><br>
  58. <a href="install.php?page=step&step=4&server_conf=yes" target="step">4. Add samples to DB</a><br>
  59. <a href="install.php?page=step&step=5&server_conf=yes" target="step">5. Set Admin Account</a><br>
  60. <b>FOR ADMINS:</b><br>
  61. <a href="index.php?subtopic=adminpanel&action=install_monsters" target="step">6. Load Monsters from OTS</a><br>
  62. <a href="index.php?subtopic=adminpanel&action=install_spells" target="step">7. Load Spells from OTS</a><br>';}
  63. if($_GET['page'] == 'step') {
  64. if($config['site']['install'] != "no") {
  65. if($_REQUEST['server_conf'] == 'yes' || ($_REQUEST['step'] > 2 && $_REQUEST['step'] < 6)) {
  66. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  67. if(isset($config['server']['mysqlHost'])) {
  68. $mysqlhost = $config['server']['mysqlHost'];
  69. $mysqluser = $config['server']['mysqlUser'];
  70. $mysqlpass = $config['server']['mysqlPass'];
  71. $mysqldatabase = $config['server']['mysqlDatabase'];
  72. }
  73. elseif(isset($config['server']['sqlHost'])) {
  74. $mysqlhost = $config['server']['sqlHost'];
  75. $mysqluser = $config['server']['sqlUser'];
  76. $mysqlpass = $config['server']['sqlPass'];
  77. $mysqldatabase = $config['server']['sqlDatabase'];
  78. }
  79. $sqlitefile = $config['server']['sqliteDatabase'];
  80. $passwordency = '';
  81. if(strtolower($config['server']['useMD5Passwords']) == 'yes' || strtolower($config['server']['passwordType']) == 'md5')
  82. $passwordency = 'md5';
  83. if(strtolower($config['server']['passwordType']) == 'sha1')
  84. $passwordency = 'sha1';
  85. // loads #####POT mainfile#####
  86. include('pot/OTS.php');
  87. // PDO and POT connects to database
  88. $ots = POT::getInstance();
  89. if(strtolower($config['server']['sqlType']) == "mysql") {
  90. try {
  91. $ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
  92. }
  93. catch(PDOException $error) {
  94. 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.';
  95. exit;
  96. }
  97. }
  98. elseif(strtolower($config['server']['sqlType']) == "sqlite") {
  99. $link_to_sqlitedatabase = $config['site']['server_path'].$sqlitefile;
  100. try {
  101. $ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
  102. }
  103. catch(PDOException $error) {
  104. 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.';
  105. exit;
  106. }
  107. } else {
  108. 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>';
  109. exit;
  110. }
  111. $SQL = POT::getInstance()->getDBHandle();
  112. }
  113. $step = $_REQUEST['step'];
  114. if(empty($step))
  115. $step = $config['site']['install'];
  116. if($step == 'start') {
  117. echo '<h1>STEP '.$step.'</h1>Informations<br>';
  118. 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-8 to load configuration from OTS.</b>';
  119. }
  120. if($step == '1') {
  121. if(isset($_REQUEST['server_path'])) {
  122. echo '<h1>STEP '.$step.'</h1>Check server configuration<br>';
  123. $config['site']['server_path'] = $_REQUEST['server_path'];
  124. $config['site']['server_path'] = trim($config['site']['server_path'])."\\";
  125. $config['site']['server_path'] = str_replace("\\\\", "/", $config['site']['server_path']);
  126. $config['site']['server_path'] = str_replace("\\", "/", $config['site']['server_path']);
  127. $config['site']['server_path'] = str_replace("//", "/", $config['site']['server_path']);
  128. saveconfig_ini($config['site']);
  129. if(file_exists($config['site']['server_path'].'config.lua')) {
  130. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  131. if(isset($config['server']['sqlType'])) {
  132. $config['site']['install'] = 2;
  133. saveconfig_ini($config['site']);
  134. 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>';
  135. }
  136. else
  137. {
  138. 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.';
  139. }
  140. }
  141. else
  142. {
  143. 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>';
  144. }
  145. }
  146. else
  147. {
  148. echo 'Please write you TFS directory below. Like: <i>C:\Documents and Settings\Gesior\Desktop\TFS 0.2.9\</i><form action="install.php">
  149. <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" /></form>';
  150. }
  151. }
  152. if($step == '2') {
  153. echo '<h1>STEP '.$step.'</h1>Check database connection<br>';
  154. 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.';
  155. //load server config
  156. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  157. if(isset($config['server']['mysqlHost'])) {
  158. //new (0.2.6+) ots config.lua file
  159. $mysqlhost = $config['server']['mysqlHost'];
  160. $mysqluser = $config['server']['mysqlUser'];
  161. $mysqlpass = $config['server']['mysqlPass'];
  162. $mysqldatabase = $config['server']['mysqlDatabase'];
  163. }
  164. elseif(isset($config['server']['sqlHost'])) {
  165. //old (0.2.4) ots config.lua file
  166. $mysqlhost = $config['server']['sqlHost'];
  167. $mysqluser = $config['server']['sqlUser'];
  168. $mysqlpass = $config['server']['sqlPass'];
  169. $mysqldatabase = $config['server']['sqlDatabase'];
  170. }
  171. $sqlitefile = $config['server']['sqliteDatabase'];
  172. $passwordency = '';
  173. if(strtolower($config['server']['useMD5Passwords']) == 'yes' || strtolower($config['server']['passwordType']) == 'md5')
  174. $passwordency = 'md5';
  175. if(strtolower($config['server']['passwordType']) == 'sha1')
  176. $passwordency = 'sha1';
  177. // loads #####POT mainfile#####
  178. include('pot/OTS.php');
  179. $ots = POT::getInstance();
  180. if(strtolower($config['server']['sqlType']) == "mysql") {
  181. try {
  182. $ots->connect(POT::DB_MYSQL, array('host' => $mysqlhost, 'user' => $mysqluser, 'password' => $mysqlpass, 'database' => $mysqldatabase) );
  183. }
  184. catch(PDOException $error) {
  185. 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.';
  186. exit;
  187. }
  188. }
  189. elseif(strtolower($config['server']['sqlType']) == "sqlite") {
  190. $link_to_sqlitedatabase = $config['site']['server_path'].$sqlitefile;
  191. try {
  192. $ots->connect(POT::DB_SQLITE, array('database' => $link_to_sqlitedatabase));
  193. }
  194. catch(PDOException $error) {
  195. 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.';
  196. exit;
  197. }
  198. }
  199. else
  200. {
  201. 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>';
  202. exit;
  203. }
  204. $SQL = POT::getInstance()->getDBHandle();
  205. $config['site']['install'] = 3;
  206. saveconfig_ini($config['site']);
  207. }
  208. if($step == '3') {
  209. echo '<h1>STEP '.$step.'</h1>Add tables and columns to DB<br>';
  210. echo 'Installer try to add new tables and columns to database.<br>';
  211. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  212. if($config['server']['sqlType'] == "sqlite") {
  213. try { $SQL->query('ALTER TABLE accounts ADD "key" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  214. try { $SQL->query('ALTER TABLE accounts ADD "page_lastday" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  215. try { $SQL->query('ALTER TABLE accounts ADD "email_new" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  216. try { $SQL->query('ALTER TABLE accounts ADD "email_new_time" INTEGER(15) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  217. try { $SQL->query('ALTER TABLE accounts ADD "created" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  218. try { $SQL->query('ALTER TABLE accounts ADD "rlname" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  219. try { $SQL->query('ALTER TABLE accounts ADD "location" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  220. try { $SQL->query('ALTER TABLE accounts ADD "page_access" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  221. try { $SQL->query('ALTER TABLE accounts ADD "email_code" VARCHAR(255) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  222. try { $SQL->query('ALTER TABLE accounts ADD "next_email" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  223. try { $SQL->query('ALTER TABLE accounts ADD "premium_points" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  224. echo "Added columns to table <b>accounts</b>.<br/>";
  225. try { $SQL->query('ALTER TABLE guilds ADD "description" TEXT NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  226. try { $SQL->query('ALTER TABLE guilds ADD "logo_gfx_name" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  227. echo "Added columns to table <b>guilds</b>.<br/>";
  228. try { $SQL->query('ALTER TABLE players ADD "online" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  229. try { $SQL->query('ALTER TABLE players ADD "created" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  230. try { $SQL->query('ALTER TABLE players ADD "nick_verify" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  231. try { $SQL->query('ALTER TABLE players ADD "old_name" VARCHAR(255) NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  232. try { $SQL->query('ALTER TABLE players ADD "hide_char" INTEGER(11) NOT NULL DEFAULT 0;'); } catch(PDOException $error) {}
  233. try { $SQL->query('ALTER TABLE players ADD "comment" TEXT NOT NULL DEFAULT "";'); } catch(PDOException $error) {}
  234. echo "Added columns to table <b>players</b>.<br/>";
  235. try { $SQL->query('CREATE TABLE "z_news_tickers" (
  236. "date" INTEGER NOT NULL,
  237. "author" INTEGER NOT NULL,
  238. "image_id" INTEGER NOT NULL DEFAULT 0,
  239. "text" TEXT NOT NULL,
  240. "hide_ticker" INTEGER NOT NULL DEFAULT 0);'); } catch(PDOException $error) {}
  241. echo "Added table <b>z_news_tickers</b> (tickers).<br/>";
  242. try { $SQL->query('CREATE TABLE "z_spells" (
  243. "name" VARCHAR(255) NOT NULL,
  244. "spell" VARCHAR(255) NOT NULL,
  245. "spell_type" VARCHAR(255) NOT NULL,
  246. "mana" INTEGER NOT NULL DEFAULT 0,
  247. "lvl" INTEGER NOT NULL DEFAULT 0,
  248. "mlvl" INTEGER NOT NULL DEFAULT 0,
  249. "soul" INTEGER NOT NULL DEFAULT 0,
  250. "pacc" VARCHAR(255) NOT NULL,
  251. "vocations" VARCHAR(255) NOT NULL,
  252. "conj_count" INTEGER NOT NULL DEFAULT 0,
  253. "hide_spell" INTEGER NOT NULL DEFAULT 0);'); } catch(PDOException $error) {}
  254. echo "Added table <b>z_spells</b> (spells list).<br/>";
  255. try { $SQL->query('CREATE TABLE "z_monsters" (
  256. "hide_creature" INTEGER NOT NULL DEFAULT 0,
  257. "name" VARCHAR(255) NOT NULL,
  258. "mana" INTEGER NOT NULL,
  259. "exp" INTEGER NOT NULL,
  260. "health" INTEGER NOT NULL,
  261. "speed_lvl" INTEGER NOT NULL DEFAULT 1,
  262. "use_haste" INTEGER NOT NULL,
  263. "voices" text NOT NULL,
  264. "immunities" VARCHAR(255) NOT NULL,
  265. "summonable" INTEGER NOT NULL,
  266. "convinceable" INTEGER NOT NULL,
  267. "race" VARCHAR(255) NOT NULL,
  268. "gfx_name" VARCHAR(255) NOT NULL)'); } catch(PDOException $error) {}
  269. echo "Added table <b>z_monsters</b> (monsters list).<br/>";
  270. }
  271. elseif($config['server']['sqlType'] == "mysql") {
  272. echo "<h3>Add columns to table <b>accounts</b></h3>";
  273. try { $SQL->query("ALTER TABLE `accounts` ADD `key` VARCHAR( 20 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>key</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>key</b> to table <b>accounts</b>, already exist?<br/>";}
  274. try { $SQL->query("ALTER TABLE `accounts` ADD `page_lastday` INT( 11 ) NOT NULL;"); echo "<font color=\"green\">Added column</font> <b>page_lastday</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>page_lastday</b> to table <b>accounts</b>, already exist?<br/>";}
  275. try { $SQL->query("ALTER TABLE `accounts` ADD `email_new` VARCHAR( 255 ) NOT NULL;"); echo "<font color=\"green\">Added column</font> <b>email_new</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>email_new</b> to table <b>accounts</b>, already exist?<br/>";}
  276. try { $SQL->query("ALTER TABLE `accounts` ADD `email_new_time` INT( 15 ) NOT NULL;"); echo "<font color=\"green\">Added column</font> <b>email_new_time</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>email_new_time</b> to table <b>accounts</b>, already exist?<br/>";}
  277. try { $SQL->query("ALTER TABLE `accounts` ADD `created` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>created</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>created</b> to table <b>accounts</b>, already exist?<br/>";}
  278. try { $SQL->query("ALTER TABLE `accounts` ADD `rlname` VARCHAR( 255 ) NOT NULL DEFAULT '';"); echo "<font color=\"green\">Added column</font> <b>rlname</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>rlname</b> to table <b>accounts</b>, already exist?<br/>";}
  279. try { $SQL->query("ALTER TABLE `accounts` ADD `location` VARCHAR( 255 ) NOT NULL DEFAULT '';"); echo "<font color=\"green\">Added column</font> <b>location</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>location</b> to table <b>accounts</b>, already exist?<br/>";}
  280. try { $SQL->query("ALTER TABLE `accounts` ADD `page_access` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>page_access</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>page_access</b> to table <b>accounts</b>, already exist?<br/>";}
  281. try { $SQL->query("ALTER TABLE `accounts` ADD `email_code` VARCHAR( 255 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>email_code</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>email_code</b> to table <b>accounts</b>, already exist?<br/>";}
  282. try { $SQL->query("ALTER TABLE `accounts` ADD `next_email` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>next_email</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>next_email</b> to table <b>accounts</b>, already exist?<br/>";}
  283. try { $SQL->query("ALTER TABLE `accounts` ADD `premium_points` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>premium_points</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>premium_points</b> to table <b>accounts</b>, already exist?<br/>";}
  284. try { $SQL->query("ALTER TABLE `accounts` ADD `vote` INT( 11 ) NOT NULL;"); echo "<font color=\"green\">Added column</font> <b>vote</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>vote</b> to table <b>players</b>, already exist?<br/>";}
  285. try { $SQL->query("ALTER TABLE `accounts` ADD `last_post` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>last post</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>last posts</b> to table <b>accounts</b>, already exist?<br/>";}
  286. try { $SQL->query("ALTER TABLE `accounts` ADD `flag` VARCHAR( 255 ) NOT NULL;"); echo "<font color=\"green\">Added column</font> <b>flag</b> to table <b>accounts</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>flag</b> to table <b>accounts</b>, already exist?<br/>";}
  287. echo "<h3>Add columns to table <b>guilds</b></h3>";
  288. try { $SQL->query('ALTER TABLE `guilds` ADD `description` TEXT NOT NULL DEFAULT "";'); echo "<font color=\"green\">Added column</font> <b>description</b> to table <b>guilds</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>description</b> to table <b>guilds</b>, already exist?<br/>";}
  289. try { $SQL->query('ALTER TABLE `guilds` ADD `logo_gfx_name` VARCHAR( 255 ) NOT NULL DEFAULT "";'); echo "<font color=\"green\">Added column</font> <b>logo_gfx_name</b> to table <b>guilds</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>logo_gfx_name</b> to table <b>guilds</b>, already exist?<br/>";}
  290. echo "<h3>Add columns to table <b>players</b></h3>";
  291. try { $SQL->query("ALTER TABLE `players` ADD `online` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>online</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>online</b> to table <b>players</b>, already exist?<br/>";}
  292. try { $SQL->query("ALTER TABLE `players` ADD `created` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>created</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>created</b> to table <b>players</b>, already exist?<br/>";}
  293. try { $SQL->query("ALTER TABLE `players` ADD `nick_verify` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>nick_verify</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>nick_verify</b> to table <b>players</b>, already exist?<br/>";}
  294. try { $SQL->query("ALTER TABLE `players` ADD `old_name` VARCHAR( 255 ) NOT NULL DEFAULT '';"); echo "<font color=\"green\">Added column</font> <b>old_name</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>old_name</b> to table <b>players</b>, already exist?<br/>";}
  295. try { $SQL->query("ALTER TABLE `players` ADD `hide_char` INT( 11 ) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>hide_char</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>hide_char</b> to table <b>players</b>, already exist?<br/>";}
  296. try { $SQL->query("ALTER TABLE `players` ADD `worldtransfer` int(11) NOT NULL DEFAULT '0';"); echo "<font color=\"green\">Added column</font> <b>worldtransfer</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>worldtransfer</b> to table <b>players</b>, already exist?<br/>";}
  297. try { $SQL->query("ALTER TABLE `players` ADD `comment` TEXT NOT NULL;"); echo "<font color=\"green\">Added column</font> <b>comment</b> to table <b>players</b><br />";} catch(PDOException $error) { echo "<font color=\"red\">Can't add column</font> <b>comment</b> to table <b>players</b>, already exist?<br/>";}
  298. echo "<h3>Add new tables to database</h3>";
  299. try { $SQL->query("CREATE TABLE `z_news_tickers` (
  300. `date` int(11) NOT NULL default '1',
  301. `author` int(11) NOT NULL,
  302. `image_id` int(3) NOT NULL default '0',
  303. `text` text NOT NULL,
  304. `hide_ticker` tinyint(1) NOT NULL
  305. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
  306. echo '<font color=\"green\">Added table <b>z_news_tickers</b></font><br/>';
  307. } catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_news_tickers</b> not added.</font> Already exist?<br/>";}
  308. try { $SQL->query('CREATE TABLE `z_spells` (
  309. `name` VARCHAR(255) NOT NULL,
  310. `spell` VARCHAR(255) NOT NULL,
  311. `spell_type` VARCHAR(255) NOT NULL,
  312. `mana` INTEGER NOT NULL DEFAULT 0,
  313. `lvl` INTEGER NOT NULL DEFAULT 0,
  314. `mlvl` INTEGER NOT NULL DEFAULT 0,
  315. `soul` INTEGER NOT NULL DEFAULT 0,
  316. `pacc` VARCHAR(255) NOT NULL,
  317. `vocations` VARCHAR(255) NOT NULL,
  318. `conj_count` INTEGER NOT NULL DEFAULT 0,
  319. `hide_spell` INTEGER NOT NULL DEFAULT 0);');
  320. echo '<font color=\"green\">Added table <b>z_spells</b></font><br/>';
  321. } catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_spells</b> not added.</font> Already exist?<br/>";}
  322. try { $SQL->query('CREATE TABLE `z_monsters` (
  323. `hide_creature` tinyint(1) NOT NULL default \'0\',
  324. `name` varchar(255) NOT NULL,
  325. `mana` int(11) NOT NULL,
  326. `exp` int(11) NOT NULL,
  327. `health` int(11) NOT NULL,
  328. `speed_lvl` int(11) NOT NULL default \'1\',
  329. `use_haste` tinyint(1) NOT NULL,
  330. `voices` text NOT NULL,
  331. `immunities` varchar(255) NOT NULL,
  332. `summonable` tinyint(1) NOT NULL,
  333. `convinceable` tinyint(1) NOT NULL,
  334. `race` varchar(255) NOT NULL,
  335. `gfx_name` varchar(255) NOT NULL
  336. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;');
  337. echo"<font color=\"green\">Added table <b>z_monsters</b></font><br/>";
  338. } catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_monsters</b> not added.</font> Already exist?<br/>";}
  339. try { $SQL->query("CREATE TABLE `z_ots_comunication` (
  340. `id` int(11) NOT NULL auto_increment,
  341. `name` varchar(255) NOT NULL,
  342. `type` varchar(255) NOT NULL,
  343. `action` varchar(255) NOT NULL,
  344. `param1` varchar(255) NOT NULL,
  345. `param2` varchar(255) NOT NULL,
  346. `param3` varchar(255) NOT NULL,
  347. `param4` varchar(255) NOT NULL,
  348. `param5` varchar(255) NOT NULL,
  349. `param6` varchar(255) NOT NULL,
  350. `param7` varchar(255) NOT NULL,
  351. `delete_it` int(2) NOT NULL default '1',
  352. PRIMARY KEY (`id`)
  353. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
  354. echo "<font color=\"green\">Added table <b>z_ots_comunication</b> (shopsystem).<br/></font>";
  355. }
  356. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_ots_comunication</b> not added.</font> Already exist?<br/>";}
  357. try { $SQL->query("CREATE TABLE `z_shop_offer` (
  358. `id` int(11) NOT NULL auto_increment,
  359. `points` int(11) NOT NULL default '0',
  360. `itemid1` int(11) NOT NULL default '0',
  361. `count1` int(11) NOT NULL default '0',
  362. `itemid2` int(11) NOT NULL default '0',
  363. `count2` int(11) NOT NULL default '0',
  364. `offer_type` varchar(255) default NULL,
  365. `offer_description` text NOT NULL,
  366. `offer_name` varchar(255) NOT NULL,
  367. `pid` INT(11) NOT NULL DEFAULT '0',
  368. PRIMARY KEY (`id`)
  369. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
  370. echo "<font color=\"green\">Added table <b>z_shop_offer</b> (shopsystem).<br/></font>";
  371. }
  372. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_shop_offer</b> not added.</font> Already exist?<br/>";}
  373. try { $SQL->query("CREATE TABLE `z_shop_history_item` (
  374. `id` int(11) NOT NULL auto_increment,
  375. `to_name` varchar(255) NOT NULL default '0',
  376. `to_account` int(11) NOT NULL default '0',
  377. `from_nick` varchar(255) NOT NULL,
  378. `from_account` int(11) NOT NULL default '0',
  379. `price` int(11) NOT NULL default '0',
  380. `offer_id` int(11) NOT NULL default '0',
  381. `trans_state` varchar(255) NOT NULL,
  382. `trans_start` int(11) NOT NULL default '0',
  383. `trans_real` int(11) NOT NULL default '0',
  384. PRIMARY KEY (`id`)
  385. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
  386. echo "<font color=\"green\">Added table <b>z_shop_history_item</b> (shopsystem).<br/></font>";
  387. }
  388. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_shop_history_item</b> not added.</font> Already exist?<br/>";}
  389. try { $SQL->query("CREATE TABLE `z_shop_history_pacc` (
  390. `id` int(11) NOT NULL auto_increment,
  391. `to_name` varchar(255) NOT NULL default '0',
  392. `to_account` int(11) NOT NULL default '0',
  393. `from_nick` varchar(255) NOT NULL,
  394. `from_account` int(11) NOT NULL default '0',
  395. `price` int(11) NOT NULL default '0',
  396. `pacc_days` int(11) NOT NULL default '0',
  397. `trans_state` varchar(255) NOT NULL,
  398. `trans_start` int(11) NOT NULL default '0',
  399. `trans_real` int(11) NOT NULL default '0',
  400. PRIMARY KEY (`id`)
  401. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
  402. echo "<font color=\"green\">Added table <b>z_shop_history_pacc</b> (shopsystem).<br/></font>";
  403. }
  404. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_shop_history_pacc</b> not added.</font> Already exist?<br/>";}
  405. try { $SQL->query("CREATE TABLE IF NOT EXISTS `z_changelog` (
  406. `id` int(11) NOT NULL auto_increment,
  407. `type` varchar(255) NOT NULL default '',
  408. `where` varchar(255) NOT NULL default '',
  409. `date` int(11) NOT NULL default '0',
  410. `description` varchar(255) NOT NULL,
  411. PRIMARY KEY (`id`)
  412. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;");
  413. echo "<font color=\"green\">Added table <b>z_changelog</b> (changelog).<br/></font>";
  414. }
  415. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_changelog</b> not added.</font> Already exist?<br/>";}
  416. try { $SQL->query("CREATE TABLE `z_polls` (
  417. `id` int(11) NOT NULL auto_increment,
  418. `question` varchar(255) NOT NULL,
  419. `end` int(11) NOT NULL,
  420. `start` int(11) NOT NULL,
  421. `answers` int(11) NOT NULL,
  422. `votes_all` int(11) NOT NULL,
  423. PRIMARY KEY (`id`)
  424. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;");
  425. echo "<font color=\"green\">Added table <b>z_polls</b> (poll-system).<br/></font>";
  426. }
  427. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_polls</b> not added.</font> Already exist?<br/>";}
  428. try { $SQL->query("CREATE TABLE `z_polls_answers` (
  429. `poll_id` int(11) NOT NULL,
  430. `answer_id` int(11) NOT NULL,
  431. `answer` varchar(255) NOT NULL,
  432. `votes` int(11) NOT NULL
  433. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
  434. echo "<font color=\"green\">Added table <b>z_polls_answers</b> (poll-system).<br/></font>";
  435. }
  436. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_polls_answers</b> not added.</font> Already exist?<br/>";}
  437. try { $SQL->query("CREATE TABLE IF NOT EXISTS `z_forum` (
  438. `id` int(11) NOT NULL auto_increment,
  439. `sticky` tinyint(1) NOT NULL DEFAULT '0',
  440. `closed` tinyint(1) NOT NULL DEFAULT '0',
  441. `first_post` int(11) NOT NULL default '0',
  442. `last_post` int(11) NOT NULL default '0',
  443. `section` int(3) NOT NULL default '0',
  444. `replies` int(20) NOT NULL default '0',
  445. `views` int(20) NOT NULL default '0',
  446. `author_aid` int(20) NOT NULL default '0',
  447. `author_guid` int(20) NOT NULL default '0',
  448. `post_text` text NOT NULL,
  449. `post_topic` varchar(255) NOT NULL,
  450. `post_smile` tinyint(1) NOT NULL default '0',
  451. `post_date` int(20) NOT NULL default '0',
  452. `last_edit_aid` int(20) NOT NULL default '0',
  453. `edit_date` int(20) NOT NULL default '0',
  454. `post_ip` varchar(32) NOT NULL default '0.0.0.0',
  455. PRIMARY KEY (`id`),
  456. KEY `section` (`section`)
  457. ) ENGINE=MyISAM AUTO_INCREMENT=1 ;");
  458. echo "<font color=\"green\">Added table <b>z_forum</b>.<br/></font>";
  459. }
  460. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_forum/b> not added.</font> Already exist?<br/>";}
  461. try { $SQL->query("CREATE TABLE `zaypay_payment` (
  462.  
  463. `payID` bigint(30) NOT NULL,
  464.  
  465. `account_id` int(20) NOT NULL,
  466.  
  467. `status` varchar(255) NOT NULL,
  468.  
  469. PRIMARY KEY (`payID`)
  470.  
  471. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  472. ");
  473. echo "<font color=\"green\">Added table <b>zaypay_payment</b>.<br/></font>";
  474. }
  475. catch(PDOException $error) { echo "<font color=\"red\">Table <b>zaypay_payment</b> not added.</font> Already exist?<br/>";}
  476. try { $SQL->query("CREATE TABLE `z_bug_tracker` (
  477. `account` varchar(255) NOT NULL,
  478. `type` int(11) NOT NULL,
  479. `status` int(11) NOT NULL,
  480. `text` text NOT NULL,
  481. `id` int(11) NOT NULL,
  482. `subject` varchar(255) NOT NULL,
  483. `reply` int(11) NOT NULL,
  484. `who` int(11) NOT NULL,
  485. `uid` int(11) NOT NULL auto_increment,
  486. `tag` int(11) NOT NULL,
  487. PRIMARY KEY (`uid`)
  488. ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;");
  489. echo "<font color=\"green\">Added table <b>z_bug_tracker</b> (bug tracker).<br/></font>";
  490. }
  491. catch(PDOException $error) { echo "<font color=\"red\">Table <b>z_bug_tracker</b> not added.</font> Already exist?<br/>";}
  492. }
  493. $config['site']['install'] = 4;
  494. saveconfig_ini($config['site']);
  495. echo '<br>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>';
  496. }
  497. if($step == '4') {
  498. echo '<h1>STEP '.$step.'</h1>Add samples to DB:<br>';
  499. $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();
  500. if(!isset($check_news_ticker['author'])) {
  501. $SQL->query('INSERT INTO z_news_tickers (date, author, image_id, text, hide_ticker) VALUES ('.time().', 1, 1, "Hello! Gesior account manager 0.3.6 installed. Report bugs Otland.Net Thread. Thanks to widnet and Norix.", 0)');
  502. echo "Added first news ticker.<br/>";
  503. } else {
  504. echo "News ticker sample is already in database. New sample is not needed.<br/>";
  505. }
  506. $check_voc_0 = $SQL->query('SELECT * FROM players WHERE name = "Rook Sample" LIMIT 1 OFFSET 0')->fetch();
  507. if(!isset($check_voc_0['name'])) {
  508. $SQL->query('INSERT INTO `players` (`id`, `name`, `world_id`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `skull`, `skulltime`, `rank_id`, `guildnick`, `lastlogout`, `blessings`, `balance`, `stamina`, `direction`, `loss_experience`, `loss_mana`, `loss_skills`, `loss_containers`, `loss_items`, `premend`, `online`, `marriage`, `promotion`, `deleted`, `description`, `created`, `nick_verify`, `old_name`, `hide_char`, `comment`) VALUES
  509. (NULL, "Rook Sample", 0, 1, 1, 1, 0, 150, 150, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, 50, 50, 7, "", 400, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 201660000, 0, 100, 100, 100, 100, 100, 0, 0, 0, 0, 0, "", 0, 0, "", 0, "")');
  510. echo "Added 'Rook Sample' character.<br/>";
  511. } else {
  512. echo "Character 'Rook Sample' already in database.<br/>";
  513. }
  514. $check_voc_1 = $SQL->query('SELECT * FROM players WHERE name = "Sorcerer Sample" LIMIT 1 OFFSET 0')->fetch();
  515. if(!isset($check_voc_1['name'])) {
  516. $SQL->query('INSERT INTO `players` (`id`, `name`, `world_id`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `skull`, `skulltime`, `rank_id`, `guildnick`, `lastlogout`, `blessings`, `balance`, `stamina`, `direction`, `loss_experience`, `loss_mana`, `loss_skills`, `loss_containers`, `loss_items`, `premend`, `online`, `marriage`, `promotion`, `deleted`, `description`, `created`, `nick_verify`, `old_name`, `hide_char`, `comment`) VALUES
  517. (NULL, "Sorcerer Sample", 0, 1, 1, 1, 1, 150, 150, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, 50, 50, 7, "", 400, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 201660000, 0, 100, 100, 100, 100, 100, 0, 0, 0, 0, 0, "", 0, 0, "", 0, "")');
  518. echo "Added 'Sorcerer Sample' character.<br/>";
  519. } else {
  520. echo "Character 'Sorcerer Sample' already in database.<br/>";
  521. }
  522. $check_voc_2 = $SQL->query('SELECT * FROM players WHERE name = "Druid Sample" LIMIT 1 OFFSET 0')->fetch();
  523. if(!isset($check_voc_2['name'])) {
  524. $SQL->query('INSERT INTO `players` (`id`, `name`, `world_id`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `skull`, `skulltime`, `rank_id`, `guildnick`, `lastlogout`, `blessings`, `balance`, `stamina`, `direction`, `loss_experience`, `loss_mana`, `loss_skills`, `loss_containers`, `loss_items`, `premend`, `online`, `marriage`, `promotion`, `deleted`, `description`, `created`, `nick_verify`, `old_name`, `hide_char`, `comment`) VALUES
  525. (NULL, "Druid Sample", 0, 1, 1, 1, 2, 150, 150, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, 50, 50, 7, "", 400, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 201660000, 0, 100, 100, 100, 100, 100, 0, 0, 0, 0, 0, "", 0, 0, "", 0, "")');
  526. echo "Added 'Druid Sample' character.<br/>";
  527. } else {
  528. echo "Character 'Druid Sample' already in database.<br/>";
  529. }
  530. $check_voc_3 = $SQL->query('SELECT * FROM players WHERE name = "Paladin Sample" LIMIT 1 OFFSET 0')->fetch();
  531. if(!isset($check_voc_3['name'])) {
  532. $SQL->query('INSERT INTO `players` (`id`, `name`, `world_id`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `skull`, `skulltime`, `rank_id`, `guildnick`, `lastlogout`, `blessings`, `balance`, `stamina`, `direction`, `loss_experience`, `loss_mana`, `loss_skills`, `loss_containers`, `loss_items`, `premend`, `online`, `marriage`, `promotion`, `deleted`, `description`, `created`, `nick_verify`, `old_name`, `hide_char`, `comment`) VALUES
  533. (NULL, "Paladin Sample", 0, 1, 1, 1, 3, 150, 150, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, 50, 50, 7, "", 400, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 201660000, 0, 100, 100, 100, 100, 100, 0, 0, 0, 0, 0, "", 0, 0, "", 0, "")');
  534. echo "Added 'Paladin Sample' character.<br/>";
  535. } else {
  536. echo "Character 'Paladin Sample' already in database.<br/>";
  537. }
  538. $check_voc_4 = $SQL->query('SELECT * FROM players WHERE name = "Knight Sample" LIMIT 1 OFFSET 0')->fetch();
  539. if(!isset($check_voc_4['name'])) {
  540. $SQL->query('INSERT INTO `players` (`id`, `name`, `world_id`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `lookaddons`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `skull`, `skulltime`, `rank_id`, `guildnick`, `lastlogout`, `blessings`, `balance`, `stamina`, `direction`, `loss_experience`, `loss_mana`, `loss_skills`, `loss_containers`, `loss_items`, `premend`, `online`, `marriage`, `promotion`, `deleted`, `description`, `created`, `nick_verify`, `old_name`, `hide_char`, `comment`) VALUES
  541. (NULL, "Knight Sample", 0, 1, 1, 1, 4, 150, 150, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, 50, 50, 7, "", 400, 0, 0, 0, 0, 0, 0, 0, "", 0, 0, 0, 201660000, 0, 100, 100, 100, 100, 100, 0, 0, 0, 0, 0, "", 0, 0, "", 0, "")');
  542. echo "Added 'Knight Sample' character.<br/>";
  543. } else {
  544. echo "Character 'Knight Sample' already in database.<br/>";
  545. $config['site']['install'] = 5;
  546. saveconfig_ini($config['site']);
  547. 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/>';
  548. }
  549. }
  550. if($step == '5') {
  551. echo '<h1>STEP '.$step.'</h1>Set Admin Account<br>';
  552. $config['server'] = parse_ini_file($config['site']['server_path'].'config.lua');
  553. if(empty($_REQUEST['saveaccpassword'])) {
  554. echo 'Admin account number is: <b>1</b><br/>Set new password to this account.<br>';
  555. echo 'New password: <form action="install.php" method=POST><input type="text" name="newpass" size="35">(Don\'t give it password to anyone!)';
  556. 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.';
  557. } else {
  558. $newpass = $_POST['newpass'];
  559. if(!check_password($newpass))
  560. 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.';
  561. else
  562. {
  563. $newpass_to_db = password_ency($newpass);
  564. $account = new OTS_Account();
  565. $account->load(1);
  566. if($account->isLoaded()) {
  567. $account->setPassword($newpass_to_db);
  568. $account->save();
  569. $account->setCustomField("page_access", 3);
  570. } else {
  571. $number = $account->create(1,1,1);
  572. $account->setPassword($newpass_to_db);
  573. $account->unblock();
  574. $account->save();
  575. $account->setCustomField("page_access", 3);
  576. }
  577. $_SESSION['account'] = 1;
  578. $_SESSION['password'] = $newpass;
  579. $logged = TRUE;
  580. $account->setCustomField("page_lastday", time());
  581. 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 and 7 in menu.</h3>';
  582. $config['site']['install'] = 'no';
  583. saveconfig_ini($config['site']);
  584. }
  585. }
  586. }
  587. }
  588. else
  589. 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.";
  590. }
  591. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement