fritids

Untitled

May 8th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 24.77 KB | None | 0 0
  1. <?php
  2. /**
  3.  * $Id: index.php 525 2008-07-23 07:11:52Z jumpin_banana $
  4.  * $HeadURL: https://hlstats.svn.sourceforge.net/svnroot/hlstats/tags/v1.40/web/install/index.php $
  5.  *
  6.  * Original development:
  7.  * +
  8.  * + HLstats - Real-time player and clan rankings and statistics for Half-Life
  9.  * + http://sourceforge.net/projects/hlstats/
  10.  * +
  11.  * + Copyright (C) 2001  Simon Garner
  12.  * +
  13.  *
  14.  * Additional development:
  15.  * +
  16.  * + UA HLstats Team
  17.  * + http://www.unitedadmins.com
  18.  * + 2004 - 2007
  19.  * +
  20.  *
  21.  *
  22.  * Current development:
  23.  * +
  24.  * + Johannes 'Banana' Keßler
  25.  * + http://hlstats.sourceforge.net
  26.  * + 2007 - 2008
  27.  * +
  28.  *
  29.  * This program is free software; you can redistribute it and/or
  30.  * modify it under the terms of the GNU General Public License
  31.  * as published by the Free Software Foundation; either version 2
  32.  * of the License, or (at your option) any later version.
  33.  *
  34.  * This program is distributed in the hope that it will be useful,
  35.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  36.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  37.  * GNU General Public License for more details.
  38.  *
  39.  * You should have received a copy of the GNU General Public License
  40.  * along with this program; if not, write to the Free Software
  41.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  42.  */
  43.  
  44. /**
  45.  * make get vars save
  46.  *
  47.  * @param string $text
  48.  * @return string
  49.  */
  50. function sanitize($text) {
  51.     return htmlentities(strip_tags($text), ENT_QUOTES, "UTF-8");
  52. }
  53.  
  54. // do not report NOTICE warnings
  55. error_reporting(E_ALL ^ E_NOTICE);
  56.  
  57. session_name('hlstatsInstall');
  58. session_set_cookie_params(1800);
  59. session_start();
  60.  
  61.  
  62. //// process the single steps
  63. if(isset($_POST['saveDBSettings'])) {
  64.     // check for required values
  65.     $dbHost = sanitize($_POST['dbHost']);
  66.     $dbName = sanitize($_POST['dbName']);
  67.     $dbUser = sanitize($_POST['dbUser']);
  68.     $dbPass = sanitize($_POST['dbPass']);
  69.     $dbPre = sanitize($_POST['dbPrefix']);
  70.  
  71.     if($dbHost != "" && $dbName != "" && $dbUser != "" && $dbPass != "") {
  72.         // check if the data is valid
  73.         $db_con = @mysql_connect($dbHost,$dbUser,$dbPass);
  74.         $db_sel = @mysql_select_db($dbName,$db_con);
  75.  
  76.         if($db_con && $db_sel) {
  77.             // save the data into $_SESSION
  78.             $_SESSION['db']['dbHost'] = $dbHost;
  79.             $_SESSION['db']['dbName'] = $dbName;
  80.             $_SESSION['db']['dbUser'] = $dbUser;
  81.             $_SESSION['db']['dbPass'] = $dbPass;
  82.             $_SESSION['db']['dbPrefix'] = $dbPre;
  83.             $_SESSION['db']['status'] = true;
  84.  
  85.             $return['db']['success'] = true;
  86.         }
  87.         else {
  88.             $return['db']['error'] = true;
  89.             $return['db']['status'] = "2";
  90.         }
  91.     }
  92.     else {
  93.         $return['db']['error'] = true;
  94.         $return['db']['status'] = "1";
  95.     }
  96. }
  97.  
  98. if(isset($_POST['saveAdminSettings'])) {
  99.     // check for required values
  100.     $aName = sanitize($_POST['adminName']);
  101.     $aPass = sanitize($_POST['adminPass']);
  102.     $aMail = sanitize($_POST['adminMail']);
  103.  
  104.     if($aName != "" && $aPass != "" ) {
  105.         // save the data into $_SESSION
  106.         $_SESSION['admin']['adminName'] = $aName;
  107.         $_SESSION['admin']['adminPass'] = $aPass;
  108.         $_SESSION['admin']['adminMail'] = $aMail;
  109.  
  110.         $return['admin']['success'] = true;
  111.     }
  112.     else {
  113.         $return['admin']['error'] = true;
  114.         $return['admin']['status'] = "1";
  115.     }
  116. }
  117.  
  118. if(isset($_POST['saveSetSettings'])) {
  119.     // check for required values
  120.     $setDays = sanitize($_POST['setDeleteDays']);
  121.  
  122.     if($setDays != "") {
  123.         $_SESSION['set']['setDeleteDays'] = $setDays;
  124.         $_SESSION['set']['setMode'] = $_POST['setMode'];
  125.         $_SESSION['set']['setBots'] = $_POST['setBots'];
  126.  
  127.         if(trim($_POST['setIP']) != "") {
  128.             $_SESSION['set']['setPort'] = $_POST['setPort'];
  129.         }
  130.         else {
  131.             $_SESSION['set']['setPort'] = "27500";
  132.         }
  133.  
  134.         $_SESSION['set']['setIP'] = $_POST['setIP'];
  135.  
  136.         $return['set']['success'] = true;
  137.     }
  138.     else {
  139.         $return['set']['error'] = true;
  140.         $return['set']['status'] = "1";
  141.     }
  142. }
  143.  
  144. // the final process
  145. // create db and settings here.
  146. if(isset($_POST['saveAllSettings'])) {
  147.     // creat db connection
  148.     $db_con = mysql_connect($_SESSION['db']['dbHost'],$_SESSION['db']['dbUser'],$_SESSION['db']['dbPass']) OR die("Unable to connect to DB Server !");
  149.     $db_sel = mysql_select_db($_SESSION['db']['dbName'],$db_con) OR die("Unable to connect to DB Server !");
  150.  
  151.     // read the hlstats.sql file
  152.     $hlSql = file_get_contents("sql_files/hlstats.sql");
  153.     // since we cant run multiple sql commands within mysql_query
  154.     // // we have to split up
  155.     $hlSql = trim($hlSql);
  156.  
  157.     // replace the prefix
  158.     $hlSql = str_replace("#DB_PREFIX#",$_SESSION['db']['dbPrefix'],$hlSql);
  159.  
  160.     $queries = explode(";",$hlSql);
  161.     foreach ($queries as $query) {
  162.         $query = trim($query);
  163.         if($query != "") {
  164.             $run = mysql_query(trim($query));
  165.             if($run != true) {
  166.                 break;
  167.             }
  168.         }
  169.     }
  170.     if($run === true) {
  171.         // continue
  172.         // update admin password
  173.         mysql_query("TRUNCATE ".$_SESSION['db']['dbPrefix']."_Users");
  174.         $query = mysql_query("INSERT INTO ".$_SESSION['db']['dbPrefix']."_Users
  175.                                 SET `username` = '".$_SESSION['admin']['adminName']."',
  176.                                     `password` = '".md5($_SESSION['admin']['adminPass'])."',
  177.                                     `acclevel` = '100',
  178.                                     `playerId` = 0");
  179.         if($query != false) {
  180.             // change hlstats.conf.inc.php file
  181.             $configFile = "conf.sample.php";
  182.             $fh = fopen($configFile,"r");
  183.             $configContent = fread($fh,filesize($configFile));
  184.             fclose($fh);
  185.  
  186.             // replace values
  187.             $sArr = array("#DB_NAME#","#DB_USER#","#DB_PASS#","#DB_HOST#","#DELETE_DAYS#","#MODE#","#HIDE_BOTS#","#DB_PREFIX#");
  188.             $rArr = array($_SESSION['db']['dbName'],$_SESSION['db']['dbUser'],$_SESSION['db']['dbPass'],$_SESSION['db']['dbHost'],
  189.                             $_SESSION['set']['setDeleteDays'],$_SESSION['set']['setMode'],$_SESSION['set']['setBots'],$_SESSION['db']['dbPrefix']);
  190.             $configContent = str_replace($sArr,$rArr,$configContent);
  191.  
  192.             $hlConfigFile = "../hlstatsinc/hlstats.conf.inc.php";
  193.             $fh = fopen($hlConfigFile,"w");
  194.             if($fh != false)  {
  195.                 fputs($fh,$configContent);
  196.  
  197.                 // create the hlstats.conf file
  198.                 $configFile = "conf.sample.pl.php";
  199.                 $fhC = fopen($configFile,"r");
  200.                 $configContent = fread($fhC,filesize($configFile));
  201.                 fclose($fhC);
  202.  
  203.                 // replace values
  204.                 $sArr = array("#DB_NAME#","#DB_USER#","#DB_PASS#","#DB_HOST#","#DELETE_DAYS#","#MODE#","#HLS_PORT#","#HLS_IP#","#DB_PREFIX#","#ADMIN_MAIL#");
  205.                 $rArr = array($_SESSION['db']['dbName'],$_SESSION['db']['dbUser'],$_SESSION['db']['dbPass'],$_SESSION['db']['dbHost'],
  206.                             $_SESSION['set']['setDeleteDays'],$_SESSION['set']['setMode'],$_SESSION['set']['setPort'],$_SESSION['set']['setIP'],$_SESSION['db']['dbPrefix'],
  207.                             $_SESSION['admin']['adminMail']);
  208.                 $configContent = str_replace($sArr,$rArr,$configContent);
  209.  
  210.                 $hlConfigFile = "hlstats.conf";
  211.                 $fhC = fopen($hlConfigFile,"w");
  212.                 if($fhC != false)  {
  213.                     fputs($fhC,$configContent);
  214.  
  215.                     $return['final']['success'] = true;
  216.  
  217.                     // lock the installer !!
  218.                     rename("./htaccess.php","./.htaccess");
  219.                 }
  220.                 else {
  221.                     $return['final']['error'] = true;
  222.                     $return['final']['status'] = "4";
  223.                 }
  224.                 fclose($fhC);
  225.             }
  226.             else {
  227.                 $return['final']['error'] = true;
  228.                 $return['final']['status'] = "3";
  229.             }
  230.             fclose($fh);
  231.         }
  232.         else {
  233.             $return['final']['error'] = true;
  234.             $return['final']['status'] = "2";
  235.         }
  236.     }
  237.     else {
  238.         $return['final']['error'] = true;
  239.         $return['final']['status'] = "1";
  240.     }
  241. }
  242.  
  243.  
  244. header("Content-type: text/html; charset=UTF-8");
  245. ?>
  246. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  247.  
  248. <html>
  249. <head>
  250.     <meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
  251.     <title>HLstats Installer</title>
  252.     <style type="text/css">
  253.         body {
  254.             padding: 0;
  255.             margin: 0;
  256.             color: #666666;
  257.             background-color: #fff;
  258.             font-family: Arial,Verdana,Helvetica,sans-serif;
  259.             font-size: 12px;
  260.         }
  261.         a {
  262.             color: #666666;
  263.             text-decoration: underline;
  264.         }
  265.         a:hover {
  266.             color: #666666;
  267.             text-decoration: none;
  268.         }
  269.  
  270.         td,input,select {
  271.             font-family: Arial,Verdana,Helvetica,sans-serif;
  272.             font-size: 12px;
  273.         }
  274.  
  275.         input,select {
  276.             border: 1px solid #cccccc;
  277.         }
  278.  
  279.         #mainBox {
  280.             margin: 40px auto;
  281.             width: 700px;
  282.             border: 1px solid #cccccc;
  283.         }
  284.         #headBox {
  285.             background-color: #eeeeee;
  286.             height: 20px;
  287.             border-bottom: 1px solid #ccc;
  288.         }
  289.         .headBoxEntry {
  290.             float: left;
  291.             font-size: 14px;
  292.             font-weight: bold;
  293.             padding: 2px;
  294.         }
  295.         .headBoxEntryOver {
  296.             float: left;
  297.             font-size: 14px;
  298.             font-weight: bold;
  299.             padding: 2px;
  300.             background-color: #ccc;
  301.         }
  302.         .headSeperator {
  303.             float: left;
  304.             width: 2px;
  305.             height: 20px;
  306.             background-color: #ccc;
  307.             margin: 0px 2px 0px 2px;
  308.         }
  309.  
  310.         #contentBox {
  311.             padding: 2px 10px 2px 20px;
  312.         }
  313.  
  314.         #footBox {
  315.             background-color: #eeeeee;
  316.             height: 15px;
  317.             border-top: 1px solid #ccc;
  318.             font-size: 10px;
  319.             text-align: center;
  320.         }
  321.  
  322.         .headline {
  323.             font-weight: bold;
  324.             font-size: 16px;
  325.             border-bottom: 1px solid #838382;
  326.             margin: 10px;
  327.         }
  328.  
  329.         .error {
  330.             border: 1px solid red;
  331.             margin: 5px;
  332.             padding: 2px;
  333.         }
  334.         .success {
  335.             border: 1px solid green;
  336.             margin: 5px;
  337.             padding: 5px;
  338.             background-color: #6be16b;
  339.         }
  340.     </style>
  341. </head>
  342. <body>
  343.     <div id="mainBox">
  344.         <div id="headBox">
  345.             <div class="headBoxEntry<?php if($_GET['step'] == "") echo "Over"; ?>">
  346.                 <a href="index.php">Start</a>
  347.             </div>
  348.             <div class="headSeperator">&nbsp;</div>
  349.             <div class="headBoxEntry<?php if($_GET['step'] == "1") echo "Over"; ?>">
  350.                 <a href="index.php?step=1">Step 1</a>
  351.             </div>
  352.             <div class="headSeperator">&nbsp;</div>
  353.             <div class="headBoxEntry<?php if($_GET['step'] == "2") echo "Over"; ?>">
  354.                 <a href="index.php?step=2">Step 2</a>
  355.             </div>
  356.             <div class="headSeperator">&nbsp;</div>
  357.             <div class="headBoxEntry<?php if($_GET['step'] == "3") echo "Over"; ?>">
  358.                 <a href="index.php?step=3">Step 3</a>
  359.             </div>
  360.             <div class="headSeperator">&nbsp;</div>
  361.             <div class="headBoxEntry<?php if($_GET['step'] == "4") echo "Over"; ?>">
  362.                 <a href="index.php?step=4">Step 4</a>
  363.             </div>
  364.             <div class="headSeperator">&nbsp;</div>
  365.             <span style="clear: both;"></span>
  366.         </div>
  367.         <div id="contentBox">
  368.         <?php
  369.             switch ($_GET['step']) {
  370.                 case '1':
  371.                 // set default prefix
  372.                 if($_SESSION['db']['dbPrefix'] == "") {
  373.                     $dbPrefix = "hlstats";
  374.                 }
  375.                 else {
  376.                     $dbPrefix = $_SESSION['db']['dbPrefix'];
  377.                 }
  378.                 ?>
  379.                 <div class="headline">Step 1 Database settings</div>
  380.                 Input your Database settings for your database which you are going to use for
  381.                 hlstats. You should have one already, since this installer can't create one for you.<br />
  382.                 If you don't know your db hostname try localhost. If this is not working ask your webhoster
  383.                 about the database hostname.<br />
  384.                 <br />
  385.                 <?php
  386.                     if($return['db']['error']) {
  387.                         echo "<div class='error'>";
  388.                         if($return['db']['status'] == "1") {
  389.                             echo "Please provide all the input fields !";
  390.                         }
  391.                         else if($return['db']['status'] == "2") {
  392.                             echo "Please review your DB settings. !<br />";
  393.                             echo "No Connection could be made to the db server.";
  394.                         }
  395.                         echo "</div>";
  396.                     }
  397.                     elseif($return['db']['success']) {
  398.                         echo "<div class='success'>";
  399.                         echo "All Data saved and checked. You can continue to the next step.<br /><br />";
  400.                         echo "<a href='index.php?step=2'>Continue with Step 2 &#187;</a>";
  401.                         echo "</div>";
  402.                         $_SESSION['step1'] = "run";
  403.                     }
  404.                 ?>
  405.                 <form method="post" action="">
  406.                 <table cellpadding="2" cellspacing="0" border="0">
  407.                     <tr>
  408.                         <td width="100px">
  409.                             Hostname
  410.                         </td>
  411.                         <td>
  412.                             <input type="text" name="dbHost" value="<?php echo $_SESSION['db']['dbHost']; ?>" />
  413.                         </td>
  414.                     </tr>
  415.                     <tr>
  416.                         <td>Database Name</td>
  417.                         <td>
  418.                             <input type="text" name="dbName" value="<?php echo $_SESSION['db']['dbName']; ?>" />
  419.                         </td>
  420.                     </tr>
  421.                     <tr>
  422.                         <td>Database User</td>
  423.                         <td>
  424.                             <input type="text" name="dbUser" value="<?php echo $_SESSION['db']['dbUser']; ?>" />
  425.                         </td>
  426.                     </tr>
  427.                     <tr>
  428.                         <td>Database Passwort</td>
  429.                         <td>
  430.                             <input type="text" name="dbPass" value="<?php echo $_SESSION['db']['dbPass']; ?>" />
  431.                         </td>
  432.                     </tr>
  433.                     <tr>
  434.                         <td>Database prefix</td>
  435.                         <td>
  436.                             <input type="text" name="dbPrefix" value="<?php echo $dbPrefix; ?>" /> <i>(a underscore will be added automtically)</i>
  437.                         </td>
  438.                     </tr>
  439.                     <tr>
  440.                         <td colspan="2">
  441.                             <input type="submit" name="saveDBSettings" value="Save" />
  442.                         </td>
  443.                     </tr>
  444.                 </table>
  445.                 </form>
  446.                 <?php
  447.                 break;
  448.  
  449.                 case '2':
  450.                     if($_SESSION['step1'] == "run") {
  451.                 ?>
  452.                     <div class="headline">Step 2 Admin User settings</div>
  453.                     Choose your Admin username and password for your HLstats admin area.<br />
  454.                     <br />
  455.                     <?php
  456.                         if($return['admin']['error']) {
  457.                             echo "<div class='error'>";
  458.                             if($return['admin']['status'] == "1") {
  459.                                 echo "Please provide all the input fields !";
  460.                             }
  461.                             echo "</div>";
  462.                         }
  463.                         elseif($return['admin']['success']) {
  464.                             echo "<div class='success'>";
  465.                             echo "All Data saved and checked. You can continue to the next step.<br /><br />";
  466.                             echo "<a href='index.php?step=3'>Continue with Step 3 &#187;</a>";
  467.                             echo "</div>";
  468.                             $_SESSION['step2'] = "run";
  469.                         }
  470.                     ?>
  471.                     <form method="post" action="">
  472.                         <table cellpadding="2" cellspacing="0" border="0">
  473.                             <tr>
  474.                                 <td width="100px">
  475.                                     Username:
  476.                                 </td>
  477.                                 <td>
  478.                                     <input type="text" name="adminName" value="<?php echo $_SESSION['admin']['adminName']; ?>" />
  479.                                 </td>
  480.                             </tr>
  481.                             <tr>
  482.                                 <td>
  483.                                     Password:
  484.                                 </td>
  485.                                 <td>
  486.                                     <input type="text" name="adminPass" value="<?php echo $_SESSION['admin']['adminPass']; ?>" />
  487.                                 </td>
  488.                             </tr>
  489.                             <tr>
  490.                                 <td>
  491.                                     E-Mail:
  492.                                 </td>
  493.                                 <td>
  494.                                     <input type="text" name="adminMail" value="<?php echo $_SESSION['admin']['adminMail']; ?>" />
  495.                                     <i>(sending error messages)</i>
  496.                                 </td>
  497.                             </tr>
  498.                             <tr>
  499.                                 <td colspan="2">
  500.                                     <input type="submit" name="saveAdminSettings" value="Save" />
  501.                                 </td>
  502.                             </tr>
  503.                         </table>
  504.                     </form>
  505.                 <?php
  506.                     }
  507.                     else {
  508.                 ?>
  509.                     <div class="error">
  510.                         Please run Step 1 first !
  511.                     </div>
  512.                 <?php
  513.                     }
  514.                 break;
  515.  
  516.                 case '3':
  517.                     if($_SESSION['step1'] == "run" && $_SESSION['step2'] == "run") {
  518.  
  519.                     if($_SESSION['set']['setDeleteDays'] == "") {
  520.                         $_SESSION['set']['setDeleteDays'] = "5";
  521.                     }
  522.                 ?>
  523.                     <div class="headline">Step 3 HLstats settings</div>
  524.                     Set your HLstats settings right here.<br />
  525.                     <br />
  526.                     <?php
  527.                         if($return['set']['error']) {
  528.                             echo "<div class='error'>";
  529.                             if($return['set']['status'] == "1") {
  530.                                 echo "Please provide all the input fields !";
  531.                             }
  532.                             echo "</div>";
  533.                         }
  534.                         elseif($return['set']['success']) {
  535.                             echo "<div class='success'>";
  536.                             echo "All Data saved and checked. You can continue to the next step.<br /><br />";
  537.                             echo "<a href='index.php?step=4'>Continue with Step 4 &#187;</a>";
  538.                             echo "</div>";
  539.                             $_SESSION['step3'] = "run";
  540.                         }
  541.                     ?>
  542.                     <form method="post" action="">
  543.                         <table cellpadding="2" cellspacing="0" border="0">
  544.                             <tr>
  545.                                 <td width="160px">
  546.                                     HLstats Daemon Port
  547.                                 </td>
  548.                                 <td>
  549.                                     <input type="text" name="setPort" size="6" value="<?php echo $_SESSION['set']['setPort']; ?>" />
  550.                                     The port to which the gameserver sends the log data (default is 27500). <br />
  551.                                     Leave if empty to use the default one.
  552.                                 </td>
  553.                             </tr>
  554.                             <tr>
  555.                                 <td colspan="2">&nbsp;</td>
  556.                             </tr>
  557.                             <tr>
  558.                                 <td>
  559.                                     HLstats Daemon IP
  560.                                 </td>
  561.                                 <td>
  562.                                     <input type="text" name="setIP" value="<?php echo $_SESSION['set']['setIP']; ?>" /><br />
  563.                                     The ip from the box on which the daemon runs.<br />
  564.                                     Leave it empty for automatic. It could be that your provider forces you to use one !
  565.                                 </td>
  566.                             </tr>
  567.                             <tr>
  568.                                 <td colspan="2">&nbsp;</td>
  569.                             </tr>
  570.                             <tr>
  571.                                 <td>
  572.                                     Delete Days:
  573.                                 </td>
  574.                                 <td>
  575.                                     <input type="text" name="setDeleteDays" size="2" value="<?php echo $_SESSION['set']['setDeleteDays']; ?>" />
  576.                                     How long events for each player should be kept in the database.<br />
  577.                                     The value can be 0. Which means the data will be kept forever.
  578.                                 </td>
  579.                             </tr>
  580.                             <tr>
  581.                                 <td colspan="2">&nbsp;</td>
  582.                             </tr>
  583.                             <tr>
  584.                                 <td valign="top">
  585.                                     Mode:
  586.                                 </td>
  587.                                 <td>
  588.                                     <select name="setMode">
  589.                                         <option value="Normal" <?php if($_SESSION['set']['setMode'] == "Normal") echo "selected"; ?>>Normal</option>
  590.                                         <option value="NameTrack" <?php if($_SESSION['set']['setMode'] == "NameTrack") echo "selected"; ?>>NameTrack</option>
  591.                                         <option value="LAN" <?php if($_SESSION['set']['setMode'] == "LAN") echo "selected"; ?>>LAN</option>
  592.                                     </select>
  593.                                     Where does hlstats get its data from ?<br />
  594.                                     Internet = Normal<br />
  595.                                     Local area network = LAN<br />
  596.                                     Tracking by Name = NameTrack
  597.                                 </td>
  598.                             </tr>
  599.                             <tr>
  600.                                 <td colspan="2">&nbsp;</td>
  601.                             </tr>
  602.                             <tr>
  603.                                 <td width="100px">
  604.                                     Hide Bots:
  605.                                 </td>
  606.                                 <td>
  607.                                     <select name="setBots">
  608.                                         <option value="0" <?php if($_SESSION['set']['setBots'] == "0") echo "selected"; ?>>No</option>
  609.                                         <option value="1" <?php if($_SESSION['set']['setBots'] == "1") echo "selected"; ?>>Yes</option>
  610.                                     </select>
  611.                                     Hide Bots from ranking.
  612.                                 </td>
  613.                             </tr>
  614.                             <tr>
  615.                                 <td colspan="2">&nbsp;</td>
  616.                             </tr>
  617.                             <tr>
  618.                                 <td colspan="2">
  619.                                     <input type="submit" name="saveSetSettings" value="Save" />
  620.                                 </td>
  621.                             </tr>
  622.                         </table>
  623.                     </form>
  624.                 <?php
  625.                     }
  626.                     else {
  627.                 ?>
  628.                     <div class="error">
  629.                         Please run Step 1 und Step 2 first !
  630.                     </div>
  631.                 <?php
  632.                     }
  633.                 break;
  634.  
  635.                 case '4':
  636.                     if($_SESSION['step1'] == "run" && $_SESSION['step2'] == "run" && $_SESSION['step3'] == "run") {
  637.                 ?>
  638.                     <div class="headline">Step 4 Settings overview</div>
  639.                     <br />
  640.                     <?php
  641.                         if($return['final']['error']) {
  642.                             echo "<div class='error'>";
  643.                             if($return['final']['status'] == "1") {
  644.                                 echo "Failed to import hlstats.sql file !!!";
  645.                             }
  646.                             elseif($return['final']['status'] == "2") {
  647.                                 echo "Can't create admin user !!";
  648.                             }
  649.                             elseif($return['final']['status'] == "3") {
  650.                                 echo "Can't write to config file !!";
  651.                             }
  652.                             elseif($return['final']['status'] == "4") {
  653.                                 echo "Can't write to daemon config file !!";
  654.                             }
  655.                             echo "</div>";
  656.                         }
  657.                         elseif($return['final']['success']) {
  658.                         ?>
  659.                             <div class='success'>
  660.                                 All Data saved and checked.<br />
  661.                                 The configuration files are saved and ready to use.<br />
  662.                                 <br />
  663.                                 The installer has been locked and have to be renamed if you want to run this installer again.<br />
  664.                                 See docomentation for more details.
  665.                                 <br />
  666.                                 <br />
  667.                                 <b>The configuration file for the daemon has been saved here:</b><br />
  668.                                 -- <?php echo dirname(__FILE__)."/hlstats.conf"; ?> --<br />
  669.                                 <br />
  670.                                 Use this file and move it to the location of your daemon folder and overwrite the
  671.                                 existing configuration file.
  672.                             </div>
  673.                         <?php
  674.                         }
  675.                     ?>
  676.  
  677.                     <form method="post" action="">
  678.                         <table cellpadding="2" cellspacing="0" border="0">
  679.                             <tr>
  680.                                 <td colspan="2">
  681.                                     <b>Database Settings</b>
  682.                                 </td>
  683.                             </tr>
  684.                             <tr>
  685.                                 <td width="100px">
  686.                                     DB Host
  687.                                 </td>
  688.                                 <td>
  689.                                     <?php echo $_SESSION['db']['dbHost']; ?>
  690.                                 </td>
  691.                             </tr>
  692.                             <tr>
  693.                                 <td width="100px">
  694.                                     DB Name
  695.                                 </td>
  696.                                 <td>
  697.                                     <?php echo $_SESSION['db']['dbName']; ?>
  698.                                 </td>
  699.                             </tr>
  700.                             <tr>
  701.                                 <td width="100px">
  702.                                     DB User
  703.                                 </td>
  704.                                 <td>
  705.                                     <?php echo $_SESSION['db']['dbUser']; ?>
  706.                                 </td>
  707.                             </tr>
  708.                             <tr>
  709.                                 <td width="100px">
  710.                                     DB Password
  711.                                 </td>
  712.                                 <td>
  713.                                     <?php echo $_SESSION['db']['dbPass']; ?>
  714.                                 </td>
  715.                             </tr>
  716.                             <tr>
  717.                                 <td>DB prefix</td>
  718.                                 <td>
  719.                                     <?php echo $_SESSION['db']['dbPrefix']; ?>_ <i>(a underscore will be added automatically)</i>
  720.                                 </td>
  721.                             </tr>
  722.                             <tr>
  723.                                 <td colspan="2">
  724.                                     &nbsp;
  725.                                 </td>
  726.                             </tr>
  727.                             <tr>
  728.                                 <td colspan="2">
  729.                                     <b>Admin Access</b>
  730.                                 </td>
  731.                             </tr>
  732.                             <tr>
  733.                                 <td width="100px">
  734.                                     Admin username
  735.                                 </td>
  736.                                 <td>
  737.                                     <?php echo $_SESSION['admin']['adminName']; ?>
  738.                                 </td>
  739.                             </tr>
  740.                             <tr>
  741.                                 <td width="100px">
  742.                                     Admin password
  743.                                 </td>
  744.                                 <td>
  745.                                     <?php echo $_SESSION['admin']['adminPass']; ?>
  746.                                 </td>
  747.                             </tr>
  748.                             <tr>
  749.                                 <td width="100px">
  750.                                     Admin Mail
  751.                                 </td>
  752.                                 <td>
  753.                                     <?php echo $_SESSION['admin']['adminMail']; ?>
  754.                                 </td>
  755.                             </tr>
  756.                             <tr>
  757.                                 <td colspan="2">
  758.                                     &nbsp;
  759.                                 </td>
  760.                             </tr>
  761.                             <tr>
  762.                                 <td colspan="2">
  763.                                     <b>Settings</b>
  764.                                 </td>
  765.                             </tr>
  766.                             <tr>
  767.                                 <td width="100px">
  768.                                     Delete Days
  769.                                 </td>
  770.                                 <td>
  771.                                     <?php echo $_SESSION['set']['setDeleteDays']; ?>
  772.                                 </td>
  773.                             </tr>
  774.                             <tr>
  775.                                 <td width="100px">
  776.                                     Mode
  777.                                 </td>
  778.                                 <td>
  779.                                     <?php echo $_SESSION['set']['setMode']; ?>
  780.                                 </td>
  781.                             </tr>
  782.                             <tr>
  783.                                 <td width="100px">
  784.                                     Hide Bots
  785.                                 </td>
  786.                                 <td>
  787.                                     <?php echo $_SESSION['set']['setBots']; ?>
  788.                                 </td>
  789.                             </tr>
  790.                             <tr>
  791.                                 <td colspan="2">&nbsp;</td>
  792.                             </tr>
  793.                             <tr>
  794.                                 <td colspan="2">
  795.                                     <input type="submit" name="saveAllSettings" value="Save to configuration file and install tables" />
  796.                                 </td>
  797.                             </tr>
  798.                         </table>
  799.                     </form>
  800.                 <?php
  801.                     }
  802.                     else {
  803.                 ?>
  804.                     <div class="error">
  805.                         Please run all the previous steps first !
  806.                     </div>
  807.                 <?php
  808.                     }
  809.                 break;
  810.  
  811.                 default:
  812.                     // unset session
  813.                     session_destroy();
  814.                     $_SESSION = array();
  815.  
  816.                     // check if we have access to the config files.
  817.                     $fhConfSample = is_readable("conf.sample.php");
  818.                     $fhConfDaemon = is_readable("conf.sample.pl.php");
  819.                     $fhConfWeb = is_writeable("../hlstatsinc/hlstats.conf.inc.php");
  820.  
  821.                 ?>
  822.                 <div class="headline">Welcome</div>
  823.                 This installer will guide you through the steps to install your copy of HLstats.<br />
  824.                 <br />
  825.                 This Installer is build to run once. If you repeat the install process all configured data will
  826.                 be lost. AND all the stats.....<br />
  827.                 <br />
  828.                 <div style="background-color: #FFFF88; border: 1px solid #CDEB8B; padding: 3px;">
  829.                     <b>The installer needs access to:</b><br />
  830.                     <ol>
  831.                         <li>
  832.                             Config sample files :<br />
  833.                             <?php
  834.                                 if($fhConfSample) {
  835.                                     echo '<span style="color: green;">conf.sample.php OK</span>';
  836.                                 }
  837.                                 else {
  838.                                     echo '<b>'.dirname(__FILE__).'/conf.sample.php</b> <span style="color: red;">is not readable !</span>';
  839.                                 }
  840.                                 echo "<br />";
  841.                                 if($fhConfDaemon) {
  842.                                     echo '<span style="color: green;">conf.sample.pl.php OK</span>';
  843.                                 }
  844.                                 else {
  845.                                     echo '<b>'.dirname(__FILE__).'/conf.sample.pl.php</b> <span style="color: red;">is not readable !</span>';
  846.                                 }
  847.  
  848.                             ?>
  849.                             </li>
  850.                         <li>
  851.                             Real config file web :<br />
  852.                             <?php
  853.                                 if($fhConfWeb) {
  854.                                     echo '<span style="color: green;">hlstats.conf.inc.php OK</span>';
  855.                                 }
  856.                                 else {
  857.                                     echo '<b>'.str_replace("install/","",dirname(__FILE__)).'/include/hlstats.conf.inc.php</b> <span style="color: red;">is not writeable !</span>';
  858.                                 }
  859.                             ?>
  860.                         </li>
  861.                         <li>
  862.                             The configuration file for the daemon will be generated
  863.                         </li>
  864.                     </ol>
  865.                     If there is <span style="color: red">something red</span> make sure the webserver has read/write permission to those files.<br />
  866.                 </div>
  867.                 <br />
  868.                 Ok lets start:<br />
  869.                 <br />
  870.                 <a href="index.php?step=1">Start &#187;</a>
  871.                 <?php
  872.             }
  873.         ?>
  874.         </div>
  875.         <div id="footBox">
  876.             &copy; 2008 <a href="http://www.hlstats-community.org">HLstats-Community.org</a>
  877.         </div>
  878.     </div>
  879. </body>
  880. </html>
Advertisement
Add Comment
Please, Sign In to add comment