Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- if (!isset($_POST["main_domain"])) {
- header("Location: setup.html");
- exit;
- }
- $domain = parse_url_all($_POST["main_domain"]);
- $domain = $domain["host"];
- $mainDomain = preg_replace("#^www\\.(.+\\.)#i", "\$1", $domain);
- if ($mainDomain == NULL) {
- print_r("<b>ERROR:</b> Domain Error. Check domain and try again.");
- print_r("<br><br>");
- print_r("Following are the correct domain formats:");
- print_r("<ul><li>mydomain.com</li><li>myapp.mydomain.com</li></ul>");
- exit;
- }
- print_r("Your main domain is set: <b>" . $mainDomain . "</b>");
- $mainDomain = "https://" . $mainDomain;
- $toReplace = "http://foodomaamain.com";
- $jsFiles = glob("static/js/*");
- foreach ($jsFiles as $file) {
- if (preg_match("/\\bmain\\b/", $file)) {
- $fileContents = file_get_contents($file);
- if (strpos($fileContents, $toReplace) !== false) {
- $replaced = str_replace("http://foodomaamain.com", $mainDomain, $fileContents);
- file_put_contents($file, $replaced);
- }
- }
- }
- unlink("setup.html");
- unlink("store_config.php");
- print_r("<br> <b>Done. </b>");
- function parse_url_all($url)
- {
- $url = substr($url, 0, 4) == "http" ? $url : "http://" . $url;
- $d = parse_url($url);
- $tmp = explode(".", $d["host"]);
- $n = count($tmp);
- if (2 <= $n) {
- if ($n == 4 || $n == 3 && strlen($tmp[$n - 2]) <= 3) {
- $d["domain"] = $tmp[$n - 3] . "." . $tmp[$n - 2] . "." . $tmp[$n - 1];
- $d["domainX"] = $tmp[$n - 3];
- } else {
- $d["domain"] = $tmp[$n - 2] . "." . $tmp[$n - 1];
- $d["domainX"] = $tmp[$n - 2];
- }
- }
- return $d;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement