Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.38 KB | None | 0 0
  1. <?php
  2. session_start();
  3. header('Content-Type: text/html; charset=utf-8');
  4. ini_set("magic_quotes_gpc", "0");
  5. ini_set("display_errors", "1");
  6. error_reporting(E_ALL ^ E_NOTICE);
  7. define('__DIR__', pathinfo(__FILE__, PATHINFO_DIRNAME));
  8. define('__BASEDIR__', substr(pathinfo(__FILE__, PATHINFO_DIRNAME), 0 , -6));
  9.  
  10. require(__BASEDIR__."/includes/classes/class.parser.php");
  11. $Parser = new TemplateParser();
  12.  
  13. if(file_exists(__DIR__."/setup.lock")){
  14.     header("Location: /index.php");
  15. }
  16.  
  17. if(isset($_POST['install'])){
  18.     if(!@mysqli_connect("".$_POST['dbhost']."", "".$_POST['dbuser']."", "".$_POST['dbpass']."", "".$_POST['dbname']."")){
  19.         $error = "<tr><td class=\"red\">Error! Could not connect to the database!</td></tr>";
  20.     }
  21.     if(empty($error)){
  22.    
  23.         require(__BASEDIR__."/includes/classes/class.db.php");
  24.         $DB = new db_driver($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']);
  25.         $DB->table_prefix = "syrup";
  26.         $DB->development_mode = TRUE;
  27.        
  28.         //write the config file
  29.         $file = fopen(__BASEDIR__."/includes/config.php", "w");
  30.         $string = '<?php
  31. $mysql_host = "'.$_POST['dbhost'].'"; //Mysql host...
  32. $mysql_user = "'.$_POST['dbuser'].'"; //Mysql user...
  33. $mysql_password = "'.$_POST['dbpass'].'"; //Mysql password
  34. $mysql_database = "'.$_POST['dbname'].'"; //Mysql database...
  35. $mysql_tableprefix = "syrup"; //Table prefix...
  36. ?>';
  37.         fwrite($file, $string);
  38.         fclose($file);
  39.    
  40.         //create the database tables
  41.         $DB->query("CREATE TABLE `syrup_bcomments` (
  42.                     `id` int(11) NOT NULL AUTO_INCREMENT,
  43.                     `bid` int(11) NOT NULL,
  44.                     `author_id` int(11) unsigned NOT NULL,
  45.                     `feedback` int(1) NOT NULL,
  46.                     `date` varchar(32) NOT NULL,
  47.                     `comment` text NOT NULL,
  48.                     PRIMARY KEY (`id`)
  49.                     ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  50.         $DB->query("CREATE TABLE `syrup_ecomments` (
  51.                     `id` int(11) NOT NULL AUTO_INCREMENT,
  52.                     `eid` int(11) NOT NULL,
  53.                     PRIMARY KEY (`id`)
  54.                     ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  55.         $DB->query("CREATE TABLE `syrup_events` (
  56.                     `id` int(11) NOT NULL AUTO_INCREMENT,
  57.                     `title` varchar(50) NOT NULL,
  58.                     `author` varchar(16) NOT NULL,
  59.                     `date` varchar(32) NOT NULL,
  60.                     `type` varchar(32) NOT NULL,
  61.                     `status` int(1) unsigned NOT NULL,
  62.                     `content` text NOT NULL,
  63.                     `views` int(11) NOT NULL DEFAULT '0',
  64.                     PRIMARY KEY (`id`)
  65.                     ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  66.         $DB->query("CREATE TABLE `syrup_news` (
  67.                     `id` int(11) NOT NULL AUTO_INCREMENT,
  68.                     `title` varchar(50) NOT NULL,
  69.                     `author` varchar(16) NOT NULL,
  70.                     `date` varchar(32) NOT NULL,
  71.                     `type` varchar(32) NOT NULL,
  72.                     `content` text NOT NULL,
  73.                     `views` int(11) NOT NULL DEFAULT '0',
  74.                     PRIMARY KEY (`id`)
  75.                     ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  76.         $DB->query("CREATE TABLE `syrup_gmblog` (
  77.                     `id` int(11) NOT NULL AUTO_INCREMENT,
  78.                     `title` varchar(50) NOT NULL,
  79.                     `author` varchar(16) NOT NULL,
  80.                     `date` varchar(32) NOT NULL,
  81.                     `content` text NOT NULL,
  82.                     `views` int(11) NOT NULL DEFAULT '0',
  83.                     PRIMARY KEY (`id`)
  84.                     ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  85.         $DB->query("CREATE TABLE `syrup_gdcache` (
  86.                     `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  87.                     `hash` varchar(32) NOT NULL,
  88.                     `name` varchar(20) NOT NULL,
  89.                     PRIMARY KEY (`id`)
  90.                     ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  91.         $DB->query("CREATE TABLE `syrup_profiles` (
  92.                     `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  93.                     `aid` int(11) unsigned NOT NULL,
  94.                     `profile_name` varchar(30) NOT NULL,
  95.                     `mainchar_id` int(11) unsigned DEFAULT NULL,
  96.                     `gender` tinyint(1) DEFAULT NULL,
  97.                     `about_me` text,
  98.                     `country` varchar(50) DEFAULT NULL,
  99.                     `private` tinyint(1) DEFAULT NULL,
  100.                     PRIMARY KEY (`id`)
  101.                     ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  102.                     `login_port` varchar(4) DEFAULT NULL,
  103.                     `server_name` varchar(30) DEFAULT NULL,
  104.                     `slogan` varchar(50) DEFAULT NULL,
  105.                     `gmlvl_for_mod` int(11) unsigned NOT NULL,
  106.                     `gmlvl_for_admin` int(11) unsigned NOT NULL,
  107.                     `gmlvl_for_gmstyle` int(11) unsigned NOT NULL,
  108.                     `template` varchar(30) DEFAULT NULL,
  109.                     `voteurl` varchar(100) DEFAULT NULL,
  110.                     `votebanner` varchar(30) DEFAULT NULL,
  111.                     `launcherurl` varchar(100) DEFAULT NULL,
  112.                     `launchername` varchar(30) DEFAULT NULL,
  113.                     `installerurl` varchar(100) DEFAULT NULL,
  114.                     `nxtimespan` int(11) unsigned NOT NULL,
  115.                     PRIMARY KEY (`id`)
  116.                     ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC", 0);
  117.         $DB->query("CREATE TABLE `syrup_votes` (
  118.                     `id` int(11) NOT NULL AUTO_INCREMENT,
  119.                     `aid` int(11) NOT NULL,
  120.                     `lastvote` int(11) NOT NULL,
  121.                     PRIMARY KEY (`id`)
  122.                     ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1", 0);
  123.         $DB->query("INSERT INTO `syrup_settings` (`id`,`server_version`,`exp_rate`,`meso_rate`,`drop_rate`,`bossdrop_rate`,`max_players`,`date_format`,`date_pfix`,`date_sfix`,`server_ip`,`login_port`,`server_name`,`slogan`,`gmlvl_for_mod`,`gmlvl_for_admin`,`gmlvl_for_gmstyle`,`template`,`voteurl`,`votebanner`,`launcherurl`,`launchername`,`installerurl`,`installername`,`charclasses`,`nxammount`,`nxtimespan`) VALUES (1,'0.62',1,1,1,1,500,'d.m.y','[',']','127.0.0.1','8484','YourServer','Because my server is tasty!!! XD',0,0,0,'default','#','vote.png','#','','#','',1,0,0)", 0);
  124.        
  125.         $DB->query("SELECT `id`, `name` FROM `accounts`", 1);
  126.         while($field = $DB->get_field_data(1)){
  127.             $DB->query("INSERT INTO syrup_profiles (`aid`, `profile_name`) VALUES (".$field['id'].", '".$field['name']."')", 0);
  128.         }
  129.         $file = fopen(__DIR__."/setup.lock", "w");
  130.         fclose($file);
  131.         $succes = 1;
  132.     }
  133. }
  134. if($succes == 1){
  135.     $content = "Congratulations! You have installed MapleSyrup succesfully! Click <a href=\"/index.php\">here</a> to go to the homepage. Then log in with your account and go to Configuration in the menu to configure MapleSyrup.";
  136. } else {
  137.     $Parser->loadfile(__BASEDIR__."/templates/default/installform.html");
  138.     $Parser->assignvars(array('{currentpage}', '{installerror}'),array($_SERVER['PHP_SELF'], $error));
  139.     $content = $Parser->output();
  140. }
  141.  
  142. $Parser->loadfile(__BASEDIR__."/templates/default/maininstall.html");
  143. $Parser->assignblock(array('[content]'), array($content));
  144. echo($Parser->output());
  145. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement