Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.83 KB | None | 0 0
  1. <?php ini_set('max_execution_time', 1000);
  2. if (isset($_POST)) {
  3.     $host = $_POST["host"];
  4.     $dbuser = $_POST["dbuser"];
  5.     $dbpassword = $_POST["dbpassword"];
  6.     $dbname = $_POST["dbname"];
  7.     $fullname = $_POST["fullname"];
  8.     $email = $_POST["email"];
  9.     $login_password = $_POST["password"] ? $_POST["password"] : "";
  10.     $timezone = $_POST["timezone"];
  11.     $purchase_code = $_POST["purchase_code"];
  12.     if (!($host && $dbuser && $dbname && $fullname && $email && $login_password && $purchase_code && $timezone)) {
  13.         echo json_encode(["success" => false, "message" => "Please input all fields."]);
  14.         exit();
  15.     }
  16.     if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  17.         echo json_encode(["success" => false, "message" => "Please input a valid email."]);
  18.         exit();
  19.     }
  20.     $verification = verify_purchase_code($purchase_code);
  21.     if (!empty($verification) && $verification->status != "success") {
  22.         echo json_encode(["success" => false, "message" => $verification->message]);
  23.         exit();
  24.     }
  25.     $mysqli = @new mysqli($host, $dbuser, $dbpassword, $dbname);
  26.     if (mysqli_connect_errno()) {
  27.         echo json_encode(["success" => false, "message" => $mysqli->connect_error]);
  28.         exit();
  29.     }
  30.     if (!is_file('database.sql')) {
  31.         echo json_encode(["success" => false, "message" => "The database.sql file could not found in install folder!"]);
  32.         exit();
  33.     }
  34.     $config_file_path = "../app/config.php";
  35.     $encryption_key = substr(md5(rand()), 0, 15);
  36.     $config_file = file_get_contents($config_file_path);
  37.     $is_installed = strpos($config_file, "enter_db_host");
  38.     if (!$is_installed) {
  39.         echo json_encode(["success" => false, "message" => "Seems this app is already installed! You can't reinstall it again. Make sure you not edit file config.php and index.php"]);
  40.         exit();
  41.     }
  42.     $sql = file_get_contents("database.sql");
  43.     $now = date("Y-m-d H:i:s");
  44.     $sql = str_replace('admin_fullname', $fullname, $sql);
  45.     $sql = str_replace('admin_email', $email, $sql);
  46.     $sql = str_replace('admin_password', md5($login_password), $sql);
  47.     $sql = str_replace('admin_timezone', $timezone, $sql);
  48.     $sql = str_replace('ITEM-PURCHASE-CODE', $purchase_code, $sql);
  49.     $mysqli->multi_query($sql);
  50.     do {
  51.     } while (mysqli_more_results($mysqli) && mysqli_next_result($mysqli));
  52.     $mysqli->close();
  53.     $config_file = str_replace('enter_encryption_key', $encryption_key, $config_file);
  54.     $config_file = str_replace('enter_db_host', $host, $config_file);
  55.     $config_file = str_replace('enter_db_username', $dbuser, $config_file);
  56.     $config_file = str_replace('enter_db_password', $dbpassword, $config_file);
  57.     $config_file = str_replace('enter_db_name', $dbname, $config_file);
  58.     file_put_contents($config_file_path, $config_file);
  59.     $index_file_path = "../index.php";
  60.     $index_file = file_get_contents($index_file_path);
  61.     $index_file = preg_replace('/installation/', 'production', $index_file, 1);
  62.     file_put_contents($index_file_path, $index_file);
  63.     echo json_encode(["success" => true, "message" => "Installation successfull."]);
  64.     exit();
  65. }
  66. function verify_purchase_code($code)
  67. {
  68.     $code = urlencode($code);
  69.     $website = str_replace("install/", "", $_SERVER['HTTP_REFERER']);
  70.     $url = "http://vtcreators.com/license/verify?purchase_code=" . $code . "&domain=" . $_SERVER['HTTP_HOST'] . "&website=" . $website . "&app=tigerpost";
  71.     $data = file_get_contents($url);
  72.     $ch = curl_init();
  73.     curl_setopt($ch, CURLOPT_HEADER, 0);
  74.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  75.     curl_setopt($ch, CURLOPT_URL, $url);
  76.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  77.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  78.     $data = curl_exec($ch);
  79.     curl_close($ch);
  80.  
  81.     return json_decode($data);
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement