johnburn

install.php

Apr 19th, 2011
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.86 KB | None | 0 0
  1. <?php
  2. function display_install_page($post, $error = "") {
  3.     global $_GLOBAL_TEXT;
  4.     $source = "<html> <head> <title>.: egBusiness Installation :.</title> <link href=\"images/css/style.css\" rel=\"stylesheet\" type=\"text/css\"> </head> <body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" bgcolor=\"#CCCCFF\"> <div align=\"center\"> <table border=\"0\" bordercolorlight=\"#808080\" cellspacing=\"0\" cellpadding=\"0\" class=\"globalbox\"> <tr> <td> <div align=\"center\"> <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFFF\"> <tr> <td valign=\"top\" height=\"93\"> <img border=\"0\" src=\"../images/egbusiness_01.jpg\" width=\"780\" height=\"113\"></td> </tr> <tr> <td valign=\"top\"> <table border=\"0\" width=\"100%\"> <tr> <td> <img border=\"0\" src=\"../images/ar_or.gif\" width=\"10\" height=\"10\"> <font color=\"#808080\"><b>egBusiness Installation</b></font></td> </tr> </table> </td> </tr> <tr> <td valign=\"top\" align=\"center\"> <form method=\"POST\"> <table border=\"0\" cellspacing=\"4\" cellpadding=\"3\"> <tr> <td style=\"text-align: center\" colspan=\"2\" valign=\"top\"> <font color=\"#FF0000\">{\$error}</font><p><u> <b>Root URL</b></u></p> </td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>Root URL :</b></td> <td> <input type=\"text\" name=\"rooturl\" size=\"25\" value=\"{\$post.rooturl}\"><br> <small>Note: Root url of the script<br> Do not place a trailing slash ( / ) at the end! <br> Please note that url must match your license</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td style=\"text-align: center\" valign=\"top\" colspan=\"2\"> <u><b>MySQL Configuration</b></u></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>Mysql Host :</b></td> <td> <input type=\"text\" name=\"dbhost\" size=\"25\" value=\"{\$post.dbhost}\"><br> <small>Note: Usually is &#39;localhost&#39;.<br> If your web hosting use different mysql host<br> you can ask your hosting provider for the correct mysql host address<br>&nbsp;</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>MySQL Database :</b></td> <td> <input type=\"text\" name=\"dbname\" size=\"25\" value=\"{\$post.dbname}\"><br> <small>Note: Setup does not create the database for you.<br> Use the default database created by your host or<br> create a new database, for example &#39;egbusiness_&#39; on Web Control Panel<br>&nbsp;</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>MySQL Username :</b></td> <td> <input type=\"text\" name=\"dbusername\" size=\"25\" value=\"{\$post.dbusername}\"><br> <small>Note: Mysql username which you had created on Web Control Panel<br>&nbsp;</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>MySQL Password :</b></td> <td> <input type=\"text\" name=\"dbpassword\" size=\"25\" value=\"{\$post.dbpassword}\"><br> <small>Note: Mysql password which you had created on Web Control Panel<br>&nbsp;</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>MySQL Tables Prefix :</b></td> <td> <input type=\"text\" name=\"dbprefix\" size=\"25\" value=\"{\$post.dbprefix}\"><br> <small>Note: Additional identity for tables name<br> If you are not sure, use the default value &#39;egbusiness_&#39;<br>&nbsp;</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td style=\"text-align: center\" colspan=\"2\" valign=\"top\"> <u><b>Language Configuration</b></u></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>Default Language :</b> </td> <td><select size=\"1\" name=\"language\">{\$languages} </select><br> <small>Note: Default language which is used by the script and Admin<br> You can change this value later in Admin Control Panel</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td style=\"text-align: center\" colspan=\"2\" valign=\"top\"> <u><b>Admin Information</b></u></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>Admin Name :</b></td> <td> <input type=\"text\" name=\"adminname\" size=\"25\" value=\"{\$post.adminname}\"><br> <small>Note: Admin&#39;s name<br> You can change this value later in Admin Control Panel<br>&nbsp;</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>Email :</b><small><br>&nbsp;</small></td> <td> <input type=\"text\" name=\"adminemail\" size=\"25\" value=\"{\$post.adminemail}\"><br> <small>Note: The address that alerts and other email should be sent to<br> You can change this value later in Admin Control Panel<br>&nbsp;</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>Username :</b></td> <td> <input type=\"text\" name=\"adminusername\" size=\"25\" value=\"{\$post.adminusername}\"><br> <small>Note: Username for login to the Admin control panel<br> You can change this value later in Admin Control Panel</small><br>&nbsp;</td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\"> <b>Password :</b></td> <td> <input type=\"text\" name=\"adminpassword\" size=\"25\" value=\"{\$post.adminpassword}\"><br> <small>Note:&nbsp; Password for login to the Admin control panel<br> You can change this value later in Admin Control Panel</small></td> </tr> <tr> <td style=\"text-align: right\" valign=\"top\">&nbsp;</td> <td>&nbsp;<input type=\"submit\" value=\" Install ยป \" name=\"submit\"></td> </tr> </table> </form> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p><small>Copyright 2007-2010 <a href=\"http://script4profit.com\">EGN</a> </small></p> </td> </tr> </table> </div> </td> </tr> </table> </div> </body> </html>";
  5.     $langs = array();
  6.     load_install_languages();
  7.     if (is_array($GLOBALS['_lang'])) {
  8.         foreach($GLOBALS['_lang'] as $k => $v) {
  9.             $langs[$k] = $v['title'];
  10.         }
  11.     }
  12.     $_GLOBAL_TEXT = $source;
  13.     $t = new_smarty_text();
  14.     $t->assign(array("languages" => get_select($langs, $post['language']), "error" => $error != "" ? "ERROR: " . $error : "", "post" => $post, "http_host" => $_SERVER['HTTP_HOST']));
  15.     echo $t->fetch("text:text");
  16.     exit();
  17. }
  18. function display_install_done($msg = "") {
  19.     global $_GLOBAL_TEXT;
  20.     $source = "<html> <head> <title>.: egBusiness Installation :.</title> <link href=\"images/css/style.css\" rel=\"stylesheet\" type=\"text/css\"> </head> <body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" bgcolor=\"#CCCCFF\"> <div align=\"center\"> <table border=\"0\" bordercolorlight=\"#808080\" cellspacing=\"0\" cellpadding=\"0\" class=globalbox> <tr> <td> <div align=\"center\"> <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#FFFFFF\"> <tr> <td valign=\"top\" height=\"93\"> <img border=\"0\" src=\"images/egbusiness_01.jpg\" width=\"780\" height=\"113\"></td> </tr> <tr> <td valign=\"top\"> <table border=\"0\" width=\"100%\"> <tr> <td> <img border=\"0\" src=\"images/ar_or.gif\" width=\"10\" height=\"10\"> <font color=\"#808080\"><b>egBusiness Installation Success</b></font></td> </tr> </table> </td> </tr> <tr> <td valign=\"top\" align=\"center\"> <form method=\"POST\"> <table border=\"0\" cellspacing=\"4\" cellpadding=\"3\"> <tr> <td style=\"text-align: center\" valign=\"top\"> <font color=\"#FF0000\"><b>{\$msg}</b></font><p> <b>Thank you for choosing egBusiness</b><br>&nbsp;</p> <p>You have finished creating your admin account and installing the software.<br> Now you must set up all of the variables and settings in <b><a href=\"admin/\">Admin Control Panel</a></b></p> <p>You can find the egBusiness user&#39;s guide <a target=\"_blank\" href=\"http://script4profit.com/customers/\">here</a>.<br> Feel free to <a target=\"_blank\" href=\"http://script4profit.com/support/\">contact EGN Support</a> any time if you have any issues or need any customization of the script.</p> <p>&nbsp;</p> <p>Good Luck with Your Business!</p> </td> </tr> </table> </form> <p>&nbsp;</p> <p><small>Copyright 2007-2010 <a href=\"http://script4profit.com\">EGN</a> </small></p> </td> </tr> </table> </div> </td> </tr> </table> </div> </body> </html>";
  21.     $_GLOBAL_TEXT = $source;
  22.     $t = new_smarty_text();
  23.     $t->assign(array("msg" => $msg));
  24.     echo $t->fetch("text:text");
  25.     exit();
  26. }
  27. function install_error($msg) {
  28.     global $post;
  29.     display_install_page($_POST, $msg);
  30. }
  31. function get_root_dir() {
  32.     $d = dirname(__FILE__);
  33.     display_install_page($post, $msg);
  34. }
  35. define("_VALID_MOS_", 1);
  36. define("DOCSPATH", dirname(__FILE__) . "/");
  37. require_once (DOCSPATH . "includes/" . "smarty/Smarty.class.php");
  38. require_once (DOCSPATH . "includes/" . "smarty/SmartyNoWrite.class.php");
  39. require_once (DOCSPATH . "includes/" . "eg_general.php");
  40. require_once (DOCSPATH . "includes/" . "eg_functions.php");
  41. require_once (DOCSPATH . "includes/" . "eg_filter.php");
  42. error_reporting(E_ALL ^ E_NOTICE);
  43. if ($_POST) {
  44.     $post = $_POST;
  45.     unset($post['dbpassword']);
  46.     foreach($post as $k => $v) {
  47.         if (!strlen($v)) {
  48.             install_error("Please fill in all required fields!");
  49.         }
  50.     }
  51.     if (!function_exists("mysql_connect")) {
  52.         install_error("PHP on your webhosting has been compiled without MySQL support.<br>Please contact your hosting support to fix this problem.");
  53.     }
  54.     if (!($conn = @mysql_connect(@$post['dbhost'], @$post['dbusername'], @$_POST['dbpassword']))) {
  55.         install_error("Cannot connect to mysql (" . mysql_error() . ")");
  56.     }
  57.     if (!($db = @mysql_select_db(@$post['dbname'], @$conn))) {
  58.         install_error("Cannot select database '" . savedbstring($post['dbname']) . "' (" . mysql_error() . ")");
  59.     }
  60.     $root_dir = DOCSPATH;
  61.     $cf = $root_dir . "config_inc.php";
  62.     if (file_exists($cf) && !is_writeable($cf)) {
  63.         install_error("Config file '{$cf}' is not writeable. Please set to writeable");
  64.     }
  65.     $post['dbpassword'] = $_POST['dbpassword'];
  66.     if (!write_config_file($post, $root_dir)) {
  67.         install_error("Unable to save config file ({$cf})");
  68.     }
  69.     if (!is_writeable($d = $root_dir . "files/")) {
  70.         install_error("Directory '{$d}' is not writeable. Please set to writeable");
  71.     }
  72.     if (!is_writeable($d = $root_dir . "pictures/")) {
  73.         install_error("Directory '{$d}' is not writeable. Please set to writeable");
  74.     }
  75.     if (!file_exists($sql = $root_dir . "egbusiness.sql")) {
  76.         install_error("Sql file '{$sql}' is not exists!");
  77.     }
  78.     $mqr = @get_magic_quotes_runtime();
  79.     @set_magic_quotes_runtime(0);
  80.     $query = fread(fopen($sql, "r"), filesize($sql));
  81.     $query = str_replace("@DB_PREFIX@", $post['dbprefix'], $query);
  82.     @set_magic_quotes_runtime(@$mqr);
  83.     $Var_3816 = split_sql($query);
  84.     if ($pieces) {
  85.         $i = 0;
  86.         while ($i < count($pieces)) {
  87.             $pieces[$i] = trim($pieces[$i]);
  88.             if (!empty($pieces[$i]) && $pieces[$i] != "#") {
  89.                 if (!mysql_query($pieces[$i])) {
  90.                 }
  91.             }
  92.             ++$i;
  93.         }
  94.     }
  95.     install_error("Sql file '{$sql}' is broken!");
  96.     $rooturl = sanitize_url($post['rooturl']);
  97.     $dbprefix = safe_string($post['dbprefix']);
  98.     if (!mysql_query("REPLACE " . $dbprefix . "config" . " SET value ='{$rooturl}', name='root_url', global='1'")) {
  99.     }
  100.     if (!mysql_query("REPLACE INTO " . $dbprefix . "admin" . " SET userid = '" . safe_string($post['adminusername']) . "' , password = '" . set_pass_db($_POST['adminpassword']) . "' , lastip = '" . savedbstring($_SERVER['REMOTE_ADDR']) . "' , name = '" . uc_words($post['adminname']) . "', email = '" . strtolower(savedbstring($post['adminemail'])) . "', Super_Admin = '1', admin_default = '1'")) {
  101.     }
  102.     $msg = "";
  103.     $u = "";
  104.     if (@!unlink(@$sql)) {
  105.         $msg.= "Cannot delete Sql file ({$sql}) Please delete this file immediately!";
  106.     }
  107.     $thisfile = $root_dir . "install.php";
  108.     if (@!unlink(@$thisfile)) {
  109.         $msg.= "<br>Cannot delete Install file ({$thisfile}) Please delete this file immediately!";
  110.     }
  111.     if (function_exists("curl_init")) {
  112.         $postString = "cmd=_notify-install&ip=" . urlencode(savedbstring($_SERVER['REMOTE_ADDR'])) . "&";
  113.         $postString.= "host=" . urlencode(savedbstring($_SERVER['HTTP_HOST'])) . "&hostip=" . urlencode(savedbstring($_SERVER['SERVER_ADDR'])) . "&";
  114.         $postString.= "server=" . urlencode(savedbstring($_SERVER['SERVER_SOFTWARE'])) . "&uid=" . urlencode(savedbstring($lic_userid)) . "&";
  115.         $postString.= "pas=98184fce3e4f7ee5f7d49864e8d77bc6&time=" . time() . "";
  116.         $postString.= "&script=egbusiness";
  117.         $ch = @curl_init();
  118.         @curl_setopt(@$ch, @CURLOPT_URL, "http://script4profit.com/notify-install.php");
  119.         @curl_setopt(@$ch, @CURLOPT_POST, 1);
  120.         @curl_setopt(@$ch, @CURLOPT_POSTFIELDS, @$postString);
  121.         @curl_exec(@$ch);
  122.     }
  123.     display_install_done($msg);
  124. }
  125. $post['rooturl'] = "http://" . $_SERVER['SERVER_NAME'];
  126. $post['dbprefix'] = "egbusiness_";
  127. $post['dbhost'] = "localhost";
  128. display_install_page($post);
  129. ?>
Advertisement
Add Comment
Please, Sign In to add comment