-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
192 lines (169 loc) · 8.08 KB
/
install.php
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
require_once('runtime.php');
require_once(ROOT_DIR.'/lib/core/config.class.php');
require_once(ROOT_DIR.'/lib/core/install.class.php');
require_once(ROOT_DIR.'/lib/core/crawling.class.php');
require_once(ROOT_DIR.'/lib/extern/Zend/Mail.php');
require_once(ROOT_DIR.'/lib/extern/Zend/Mail/Transport/Smtp.php');
require_once(ROOT_DIR.'/lib/core/Chipset.class.php');
if ($GLOBALS['installed']) {
$message[] = array("Die Intallation wurde gesperrt.", 2);
Message::setMessage($message);
$smarty->assign('message', Message::getMessage());
$smarty->display("header.tpl.html");
$smarty->display("login.tpl.html");
$smarty->display("footer.tpl.html");
} elseif (!isset($_GET['section'])) {
$smarty->assign('netmon_version', $GLOBALS['netmon_version']);
if (strnatcmp(phpversion(),'5.3') >= 0) $smarty->assign('php_version', true);
else $smarty->assign('php_version', false);
$smarty->assign('openssl_loaded', extension_loaded('openssl'));
$smarty->assign('pdo_loaded', extension_loaded('pdo'));
$smarty->assign('pdo_mysql_loaded', extension_loaded('pdo_mysql'));
$smarty->assign('json_loaded', extension_loaded('json'));
$smarty->assign('curl_loaded', extension_loaded('curl'));
$smarty->assign('gd_loaded', extension_loaded('gd'));
$smarty->assign('gmp_loaded', extension_loaded('gmp'));
$smarty->assign('exec', function_exists('exec'));
$smarty->assign('iconv_loaded', function_exists('iconv'));
exec('rrdtool', $rrdToolCheckOutput, $rrdToolCheckReturn);
$smarty->assign('rrdtool_installed', ($rrdToolCheckReturn == 127) ? false : true);
if (mail("[email protected]", "Netmon Mailtest", "This is a Mail that was send by netmon Mailtest", "From: [email protected]")) {
$smarty->assign('mail', true);
$_SESSION['mail'] = "php_mail";
} else {
$smarty->assign('mail', false);
$_SESSION['mail'] = "smtp";
}
$smarty->display("header.tpl.html");
$smarty->display("install_info.tpl.html");
$smarty->display("footer.tpl.html");
} elseif ($_GET['section']=="db") {
$smarty->assign('message', Message::getMessage());
$smarty->display("header.tpl.html");
$smarty->display("install_db_data.tpl.html");
$smarty->display("footer.tpl.html");
} elseif ($_GET['section']=="check_connection") {
try {
new PDO("mysql:host=".$_POST['mysql_host'].";dbname=".$_POST['mysql_db'], $_POST['mysql_user'], $_POST['mysql_password']);
}
catch(PDOException $e) {
$exception = $e->getMessage();
}
if($exception) {
$message[] = array($exception, 2);
Message::setMessage($message);
header('Location: ./install.php?section=db');
} else {
$config_path = "./config/config.local.inc.php";
$file = Install::getFileLineByLine($config_path);
$configs[0] = '$GLOBALS[\'mysql_host\'] = "'.$_POST['mysql_host'].'";';
$configs[1] = '$GLOBALS[\'mysql_db\'] = "'.$_POST['mysql_db'].'";';
$configs[2] = '$GLOBALS[\'mysql_user\'] = "'.$_POST['mysql_user'].'";';
$configs[3] = '$GLOBALS[\'mysql_password\'] = "'.$_POST['mysql_password'].'";';
$file = Install::changeConfigSection('//MYSQL', $file, $configs);
Install::writeEmptyFileLineByLine($config_path, $file);
header('Location: ./install.php?section=db_insert_method');
}
} elseif ($_GET['section']=="db_insert_method") {
if(Install::checkIfDbIsEmpty()) {
header('Location: ./install.php?section=db_insert');
} else {
$smarty->display("header.tpl.html");
$smarty->display("install_db_insert_method.tpl.html");
$smarty->display("footer.tpl.html");
}
} elseif ($_GET['section']=="db_insert") {
try {
$sql = file_get_contents('./netmon.sql');
DB::getInstance()->exec($sql);
} catch(PDOException $e) {
$exception = $e->getMessage();
}
if($exception) {
$message[] = array($exception, 2);
Message::setMessage($message);
header('Location: ./install.php?section=db');
} else {
header('Location: ./install.php?section=messages');
}
} elseif ($_GET['section']=="messages") {
$smarty->assign('mail_sending_type', $_SESSION['mail']);
$smarty->assign('url_to_netmon', "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']));
$smarty->assign('enable_network_policy', false);
$smarty->assign('message', Message::getMessage());
$smarty->display("header.tpl.html");
$smarty->display("install_messages.tpl.html");
$smarty->display("footer.tpl.html");
} elseif ($_GET['section']=="messages_insert") {
//test mail
if ($_POST['mail_sending_type']=='smtp') {
$config = array('username' => $_POST['mail_smtp_username'],
'password' => $_POST['mail_smtp_password']);
if(!empty($_POST['mail_smtp_ssl'])) $config['ssl'] = $_POST['mail_smtp_ssl'];
if(!empty($_POST['mail_smtp_login_auth'])) $config['auth'] = $_POST['mail_smtp_login_auth'];
$transport = new Zend_Mail_Transport_Smtp($_POST['mail_smtp_server'], $config);
}
$mail = new Zend_Mail();
$mail->setFrom($_POST['mail_sender_adress'], $_POST['mail_sender_name']);
$mail->addTo($_POST['mail_sender_adress']);
$mail->setSubject("Testmail");
$mail->setBodyText("This is a testmail from Netmon");
try {
$mail->send($transport);
} catch(Exception $e) {
$exception = $e->getMessage();
print_r($exception);
}
if($exception) {
$message[] = array("Das Senden der Testmail an ".$_POST['mail_sender_adress']." ist fehlgeschlagen.", 2);
$message[] = array($exception, 2);
Message::setMessage($message);
header('Location: ./install.php?section=messages');
} else {
$message[] = array("Das Senden der Testmail an ".$_POST['mail_sender_adress']." war erfolgreich.", 2);
Config::writeConfigLine('url_to_netmon', $_POST['url_to_netmon']);
Config::writeConfigLine('community_name', "Freifunk Deinestadt");
Config::writeConfigLine('community_slogan', "Die freie WLAN-Community aus deiner Stadt • Freie Netze für alle!");
Config::writeConfigLine('community_location_longitude', '8.2284163781917');
Config::writeConfigLine('community_location_latitude', '53.14416891433');
Config::writeConfigLine('community_location_zoom', '11');
Config::writeConfigLine('mail_sender_adress', $_POST['mail_sender_adress']);
Config::writeConfigLine('mail_sender_name', $_POST['mail_sender_name']);
Config::writeConfigLine('mail_sending_type', $_POST['mail_sending_type']);
Config::writeConfigLine('mail_smtp_server', $_POST['mail_smtp_server']);
Config::writeConfigLine('mail_smtp_username', $_POST['mail_smtp_username']);
Config::writeConfigLine('mail_smtp_password', $_POST['mail_smtp_password']);
Config::writeConfigLine('mail_smtp_login_auth', $_POST['mail_smtp_login_auth']);
Config::writeConfigLine('mail_smtp_ssl', $_POST['mail_smtp_ssl']);
Config::writeConfigLine('twitter_consumer_key', "dRWT5eeIn9UiHJgcjgpPQ");
Config::writeConfigLine('twitter_consumer_secret', "QxcnltPX2sTH8E7eZlxyZeqTIVoIoRjlrmUfkCzGSA");
Config::writeConfigLine('enable_network_policy', 'false');
Config::writeConfigLine('network_policy_url', 'http://picopeer.net/PPA-de.html');
Config::writeConfigLine('template', "freifunk_oldenburg");
Config::writeConfigLine('hours_to_keep_mysql_crawl_data', 5);
Config::writeConfigLine('hours_to_keep_history_table', 72);
Config::writeConfigLine('crawl_cycle_length_in_minutes', 10);
Config::writeConfigLine('event_notification_router_offline_crawl_cycles', 6);
Config::writeConfigLine('community_essid', 'deinestadt.freifunk.net');
//create a default chipset
$default_chipset = new Chipset(false, "", "Unbekannt");
$default_chipset->store();
//create an initial crawl cycle
$crawl_cycle_id = Crawling::newCrawlCycle(10);
//require_once(ROOT_DIR.'/cronjobs.php');
header('Location: ./install.php?section=finish');
}
} elseif ($_GET['section']=="finish") {
$config_path = "./config/config.local.inc.php";
$file = Install::getFileLineByLine($config_path);
$configs[0] = '$GLOBALS[\'installed\'] = true;';
$file = Install::changeConfigSection('//INSTALLED', $file, $configs);
Install::writeEmptyFileLineByLine($config_path, $file);
$message[] = array('Netmon wurde erfolgreich installiert.', 1);
$message[] = array('Die Installationsroutine wurde für weitere Zugriffe gesperrt.', 1);
$message[] = array('Bitte registrieren Sie sich, der erste registrierte Benutzer bekommt automatisch volle Root-Rechte!', 1);
Message::setMessage($message);
header('Location: ./register.php');
}
?>