My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
//////////////////////////////
// The Hosting Tool
// Install Script
// By Jonny H and Kevin M
// Released under the GNU-GPL
//////////////////////////////

/*
* This is a pretty bad attempt at being secure. If you're having
* problems with it, feel free to comment it out. But it was
* better than what we had before and should work.
*/

/*
* __FILE__ is an absolute path and we need to make it relative to
* the document root. This file must be called directly and
* directly only.
*/
if(strtoupper(substr(PHP_OS, 0, 3)) === "WIN") {
$file = str_replace("\\", "/", __FILE__);
$prepend = "/";
}
else {
$file = __FILE__;
$prepend = "";
}
$compare = explode($_SERVER["DOCUMENT_ROOT"], $file);
if($prepend . $compare[1] !== $_SERVER["PHP_SELF"]) {
die("You can only run the install from the <em>".__FILE__."</em> file.");
}


/*
* Quick little function made to make generating a default site URL
* easy. Hopefully this will assist alot of support topics regarding
* bad site URLs, as the automatically generated ones should be correct.
*/
function generateSiteUrl() {
$url = "";
if(!empty($_SERVER["HTTPS"])) {
$url .= "https://";
}
else {
$url .= "http://";
}
$exploded = explode($_SERVER["DOCUMENT_ROOT"], realpath("../"));
$url .= $_SERVER["HTTP_HOST"] . $exploded[1] . "/";
return $url;
}

//INSTALL GLOBALS
define("CVER", "1.2.1");
define("NVER", "1.2.2");

define("LINK", "../includes/"); # Set link
include(LINK."compiler.php"); # Get compiler

function writeconfig($host, $user, $pass, $db, $pre, $true) {
global $style;
$array['HOST'] = $host;
$array['USER'] = $user;
$array['PASS'] = $pass;
$array['DB'] = $db;
$array['PRE'] = $pre;
$array['TRUE'] = $true;
$tpl = $style->replaceVar("tpl/install/conftemp.tpl", $array);
$link = LINK."conf.inc.php";
if(is_writable($link)) {
file_put_contents($link, $tpl);
return true;
}
else {
return false;
}
}

define("THEME", "Reloaded2"); # Set the theme
define("URL", "../"); # Set url to blank

define("NAME", "THT");
define("PAGE", "Install");
define("SUB", "Choose Method");

$array['VERSION'] = NVER;
$array['ANYTHING'] = "";
$link = LINK."conf.inc.php";
$disable = false;
if(INSTALL == 1) {
include(LINK."conf.inc.php");
if(!writeconfig($sql['host'], $sql['user'], $sql['pass'], $sql['db'], $sql['pre'], "false")) {
$array['ANYTHING'] = "Your $link isn't writeable or does not exist! Please CHMOD it to 666 and make sure it exists!!";
$disable = true;
}
else {
$array['ANYTHING'] = "Since you've already ran the install your config has been re-written to not installed. If you are upgrading, this is fine!";
}
}
if(!file_exists($link)) {
$array["ANYTHING"] = "Your $link file doesn't exist! Please create it!";
$disable = true;
}
elseif(!is_writable($link)) {
$array['ANYTHING'] = "Your $link isn't writeable! Please CHMOD it to 666!";
$disable = true;
}
echo $style->get("header.tpl");
if($disable) {
echo '<script type="text/javascript">$(function(){$(".twobutton").attr("disabled", "true");$("#method").attr("disabled", "true");});</script>';
}
$array["GENERATED_URL"] = generateSiteUrl();
echo $style->replaceVar("tpl/install/install.tpl", $array);
echo $style->get("footer.tpl");

include(LINK."output.php"); #Output it

?>

Change log

r46 by kmark937 on Jun 18, 2010   Diff
Added the release tag snapshot for v1.2.2.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 3370 bytes, 117 lines
Powered by Google Project Hosting