| 155 |
- |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/***************************************************************************
|
|
|
4 |
* Copyright (C) 2009-2011 by Geo Varghese(www.seopanel.in) *
|
|
|
5 |
* sendtogeo@gmail.com *
|
|
|
6 |
* *
|
|
|
7 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
8 |
* it under the terms of the GNU General Public License as published by *
|
|
|
9 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
10 |
* (at your option) any later version. *
|
|
|
11 |
* *
|
|
|
12 |
* This program is distributed in the hope that it will be useful, *
|
|
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
15 |
* GNU General Public License for more details. *
|
|
|
16 |
* *
|
|
|
17 |
* You should have received a copy of the GNU General Public License *
|
|
|
18 |
* along with this program; if not, write to the *
|
|
|
19 |
* Free Software Foundation, Inc., *
|
|
|
20 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
21 |
***************************************************************************/
|
|
|
22 |
|
|
|
23 |
class Install {
|
|
|
24 |
|
|
|
25 |
# func to check requirements
|
|
|
26 |
function checkRequirements($error=false) {
|
|
|
27 |
|
|
|
28 |
$phpClass = "red";
|
|
|
29 |
$phpSupport = "No";
|
|
|
30 |
$phpVersion = phpversion();
|
|
|
31 |
if (intval($phpVersion) >= 5) {
|
|
|
32 |
$phpClass = "green";
|
|
|
33 |
$phpSupport = "Yes";
|
|
|
34 |
}
|
|
|
35 |
$phpSupport .= " ( PHP $phpVersion )";
|
|
|
36 |
|
|
|
37 |
$mysqlClass = "red";
|
|
|
38 |
$mysqlSupport = "No";
|
|
|
39 |
if(function_exists('mysql_query') || function_exists('mysqli_query')){
|
|
|
40 |
$mysqlSupport = "Yes";
|
|
|
41 |
$mysqlClass = "green";
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
$curlClass = "red";
|
|
|
45 |
$curlSupport = "No";
|
|
|
46 |
if(function_exists('curl_version')){
|
|
|
47 |
$version = curl_version();
|
|
|
48 |
$curlSupport = "Yes ( CURL {$version['version']} )";
|
|
|
49 |
$curlClass = "green";
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/*$shorttagClass = "red";
|
|
|
53 |
$shorttagSupport = "Disabled";
|
|
|
54 |
if(ini_get('short_open_tag')){
|
|
|
55 |
$shorttagSupport = "Enabled";
|
|
|
56 |
$shorttagClass = "green";
|
|
|
57 |
}*/
|
|
|
58 |
|
|
|
59 |
$gdClass = "red";
|
|
|
60 |
$gdSupport = "No";
|
|
|
61 |
if(function_exists('gd_info')){
|
|
|
62 |
$version = gd_info();
|
|
|
63 |
$gdSupport = "Yes ( GD {$version['GD Version']} )";
|
|
|
64 |
$gdClass = "green";
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
$configClass = "red";
|
|
|
68 |
$configSupport = "Not found";
|
|
|
69 |
$configFile = SP_INSTALL_CONFIG_FILE;
|
|
|
70 |
if(file_exists($configFile)){
|
|
|
71 |
|
|
|
72 |
include_once(SP_INSTALL_CONFIG_FILE);
|
|
|
73 |
if(defined('SP_INSTALLED')){
|
|
|
74 |
die("<p style='color:red'>Seo Panel version ".SP_INSTALLED." is already installed in your system!</p>");
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
$configSupport = "Found, Unwritable<br><p class='note'><b>Command:</b> chmod 666 config/sp-config.php</p>";
|
|
|
78 |
if(is_writable($configFile)){
|
|
|
79 |
$configSupport = "Found, Writable";
|
|
|
80 |
$configClass = "green";
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
$tmpClass = "red";
|
|
|
86 |
$tmpSupport = "Not found";
|
|
|
87 |
$tmpFile = SP_INSTALL_DIR.'/../tmp';
|
|
|
88 |
if(file_exists($tmpFile)){
|
|
|
89 |
$tmpSupport = "Found, Unwritable<br><p class='note'><b>Command:</b> chmod -R 777 tmp/</p>";
|
|
|
90 |
if(is_writable($tmpFile)){
|
|
|
91 |
$tmpSupport = "Found, Writable";
|
|
|
92 |
$tmpClass = "green";
|
|
|
93 |
}
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
$errMsg = "";
|
|
|
97 |
if($error){
|
|
|
98 |
if( ($phpClass == 'red') || ($mysqlClass == 'red') || ($curlClass == 'red') || ($shorttagClass == 'red') || ($configClass == 'red') ){
|
|
|
99 |
$errMsg = "Please fix the following errors to proceed to next step!";
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
?>
|
|
|
104 |
<h1 class="BlockHeader">Welcome to Seo panel Installation</h1>
|
|
|
105 |
<form method="post">
|
|
|
106 |
<table width="100%" cellspacing="8px" cellpadding="0px" class="formtab">
|
|
|
107 |
<tr><th colspan="2" class="header">Installation compatibility</th></tr>
|
|
|
108 |
<tr><td colspan="2" class="error"><?php echo $errMsg;?></td></tr>
|
|
|
109 |
<tr>
|
|
|
110 |
<th>PHP version >= 5.4.0</th>
|
|
|
111 |
<td class="<?php echo $phpClass;?>"><?php echo $phpSupport;?></td>
|
|
|
112 |
</tr>
|
|
|
113 |
<tr>
|
|
|
114 |
<th>MySQL Support</th>
|
|
|
115 |
<td class="<?php echo $mysqlClass;?>"><?php echo $mysqlSupport;?></td>
|
|
|
116 |
</tr>
|
|
|
117 |
<tr>
|
|
|
118 |
<th>CURL Support</th>
|
|
|
119 |
<td class="<?php echo $curlClass;?>"><?php echo $curlSupport; ?></td>
|
|
|
120 |
</tr>
|
|
|
121 |
<?php /* ?>
|
|
|
122 |
<tr>
|
|
|
123 |
<th>PHP short_open_tag</th>
|
|
|
124 |
<td class="<?php echo $shorttagClass;?>"><?php echo $shorttagSupport; ?></td>
|
|
|
125 |
</tr>
|
|
|
126 |
<?php */ ?>
|
|
|
127 |
<tr>
|
|
|
128 |
<th>GD graphics support</th>
|
|
|
129 |
<td class="<?php echo $gdClass;?>"><?php echo $gdSupport; ?></td>
|
|
|
130 |
</tr>
|
|
|
131 |
<tr>
|
|
|
132 |
<th>/config/sp-config.php</th>
|
|
|
133 |
<td class="<?php echo $configClass;?>"><?php echo $configSupport; ?></td>
|
|
|
134 |
</tr>
|
|
|
135 |
<tr>
|
|
|
136 |
<th>/tmp</th>
|
|
|
137 |
<td class="<?php echo $tmpClass;?>"><?php echo $tmpSupport; ?></td>
|
|
|
138 |
</tr>
|
|
|
139 |
</table>
|
|
|
140 |
<input type="hidden" value="<?php echo $phpClass;?>" name="php_support">
|
|
|
141 |
<input type="hidden" value="<?php echo $mysqlClass;?>" name="mysql_support">
|
|
|
142 |
<input type="hidden" value="<?php echo $curlClass;?>" name="curl_support">
|
|
|
143 |
<?php /* ?><input type="hidden" value="<?php echo $shorttagClass;?>" name="short_open_tag"><?php */ ?>
|
|
|
144 |
<input type="hidden" value="<?php echo $configClass;?>" name="config">
|
|
|
145 |
<input type="hidden" value="startinstall" name="sec">
|
|
|
146 |
<input type="submit" value="Proceed to next step >>" name="submit" class="button">
|
|
|
147 |
</form>
|
|
|
148 |
<?php
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
# func to start installation
|
|
|
152 |
function startInstallation($info='', $errMsg='') {
|
|
|
153 |
if( ($info['php_support'] == 'red') || ($info['mysql_support'] == 'red') || ($info['curl_support'] == 'red')
|
|
|
154 |
|| ($info['config'] == 'red') ){
|
|
|
155 |
$this->checkRequirements(true);
|
|
|
156 |
return;
|
|
|
157 |
}
|
|
|
158 |
?>
|
|
|
159 |
<h1 class="BlockHeader">Database Settings</h1>
|
|
|
160 |
<form method="post">
|
|
|
161 |
<table width="100%" cellspacing="8px" cellpadding="0px" class="formtab">
|
|
|
162 |
<tr><th colspan="2" class="header">Database configuration</th></tr>
|
|
|
163 |
<tr><td colspan="2" class="error"><?php echo $errMsg;?></td></tr>
|
|
|
164 |
<tr>
|
|
|
165 |
<th>Database type:</th>
|
|
|
166 |
<td>
|
|
|
167 |
<select name="db_engine">
|
|
|
168 |
<option value="mysql">MySQL</option>
|
|
|
169 |
</select>
|
|
|
170 |
</td>
|
|
|
171 |
</tr>
|
|
|
172 |
<tr>
|
|
|
173 |
<th>Database server hostname:</th>
|
|
|
174 |
<td><input type="text" name="db_host" value="<?php echo empty($info['db_host']) ? "localhost" : $info['db_host'];?>"></td>
|
|
|
175 |
</tr>
|
|
|
176 |
<tr>
|
|
|
177 |
<th>Database name:</th>
|
|
|
178 |
<td><input type="text" name="db_name" value="<?php echo $info['db_name'];?>"></td>
|
|
|
179 |
</tr>
|
|
|
180 |
<tr>
|
|
|
181 |
<th>Database username:</th>
|
|
|
182 |
<td><input type="text" name="db_user" value="<?php echo $info['db_user'];?>"></td>
|
|
|
183 |
</tr>
|
|
|
184 |
<tr>
|
|
|
185 |
<th>Database password:</th>
|
|
|
186 |
<td><input type="text" name="db_pass" value="<?php echo $info['db_pass'];?>"></td>
|
|
|
187 |
</tr>
|
|
|
188 |
<tr>
|
|
|
189 |
<th>Admin email address:</th>
|
|
|
190 |
<td><input type="text" name="email" value="<?php echo $info['email'];?>"></td>
|
|
|
191 |
</tr>
|
|
|
192 |
</table>
|
|
|
193 |
<input type="hidden" value="proceedinstall" name="sec">
|
|
|
194 |
<input type="submit" value="Proceed to next step >>" name="submit" class="button">
|
|
|
195 |
</form>
|
|
|
196 |
<?php
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
# func to write to config file
|
|
|
200 |
function writeConfigFile($info) {
|
|
|
201 |
|
|
|
202 |
$handle = fopen(SP_INSTALL_CONFIG_SAMPLE, "r");
|
|
|
203 |
$cfgData = fread($handle, filesize(SP_INSTALL_CONFIG_SAMPLE));
|
|
|
204 |
fclose($handle);
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
$search = array('[SP_WEBPATH]', '[DB_NAME]', '[DB_USER]', '[DB_PASSWORD]', '[DB_HOST]', '[DB_ENGINE]');
|
|
|
208 |
$replace = array($info['web_path'], $info['db_name'], $info['db_user'], $info['db_pass'], $info['db_host'], $info['db_engine'] );
|
|
|
209 |
$cfgData = str_replace($search, $replace, $cfgData);
|
|
|
210 |
|
|
|
211 |
$handle = fopen(SP_INSTALL_CONFIG_FILE, "w");
|
|
|
212 |
fwrite($handle, $cfgData);
|
|
|
213 |
fclose($handle);
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
function getWebPath(){
|
|
|
217 |
|
|
|
218 |
// to fix the issue with IIS
|
|
|
219 |
if (!isset($_SERVER['REQUEST_URI'])) {
|
|
|
220 |
$_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1 );
|
|
|
221 |
if (isset($_SERVER['QUERY_STRING'])) {
|
|
|
222 |
$_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING'];
|
|
|
223 |
}
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
$reqUrl = $_SERVER['REQUEST_URI'];
|
|
|
227 |
$count = 0;
|
|
|
228 |
$reqUrl = preg_replace('/\/install\/$/i', '', $reqUrl, 1, $count);
|
|
|
229 |
if(empty($count)){
|
|
|
230 |
$reqUrl = preg_replace('/\/install\/index.php$/i', '', $reqUrl, 1, $count);
|
|
|
231 |
if(empty($count)){
|
|
|
232 |
$reqUrl = preg_replace('/\/install$/i', '', $reqUrl, 1, $count);
|
|
|
233 |
if(empty($count)) return false;
|
|
|
234 |
}
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
// find protocol of the server to get seo panel installation url
|
|
|
238 |
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
|
|
|
239 |
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
|
|
|
240 |
$protocol = 'https://';
|
|
|
241 |
} else {
|
|
|
242 |
$protocol = 'http://';
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
$port = empty($_SERVER['SERVER_PORT']) ? "" : (int) $_SERVER['SERVER_PORT'];
|
|
|
246 |
$host = strtolower($_SERVER['HTTP_HOST']);
|
|
|
247 |
if(!empty($port) && ($port <> 443) && ($port <> 80)){
|
|
|
248 |
if(strpos($host, ':') === false){ $host .= ':' . $port; }
|
|
|
249 |
}
|
|
|
250 |
$webPath = $protocol.$host.$reqUrl;
|
|
|
251 |
return $webPath;
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
# func to proceed installation
|
|
|
255 |
function proceedInstallation($info) {
|
|
|
256 |
|
|
|
257 |
// if mysqli function exists
|
|
|
258 |
$db = function_exists('mysqli_query') ? New DBI() : New DB();
|
|
|
259 |
|
|
|
260 |
# checking db settings
|
|
|
261 |
$errMsg = $db->connectDatabase($info['db_host'], $info['db_user'], $info['db_pass'], $info['db_name']);
|
|
|
262 |
if($db->error ){
|
|
|
263 |
$this->startInstallation($info, $errMsg);
|
|
|
264 |
return;
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
# checking config file settings
|
|
|
268 |
if(!is_writable(SP_INSTALL_CONFIG_FILE)){
|
|
|
269 |
$this->checkRequirements(true);
|
|
|
270 |
return;
|
|
|
271 |
}
|
|
|
272 |
|
|
|
273 |
# checking seo panel web path
|
|
|
274 |
$info['web_path'] = $this->getWebPath();
|
|
|
275 |
if(empty($info['web_path'])){
|
|
|
276 |
$errMsg = "Error occured while parsing installation url. Please <a href='https://www.seopanel.org/contact/' target='_blank'>contact</a> Seo Panel team.<br> or <br> Try manual installation by steps specified in <a href='http://www.seopanel.org/install/manual/' target='_blank'>http://www.seopanel.org/install/manual/</a>";
|
|
|
277 |
$this->startInstallation($info, $errMsg);
|
|
|
278 |
return;
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
# importing data to db
|
|
|
282 |
$errMsg = $db->importDatabaseFile(SP_INSTALL_DB_FILE);
|
|
|
283 |
if($db->error ){
|
|
|
284 |
$errMsg = "Error occured while importing data: ". $errMsg;
|
|
|
285 |
$this->startInstallation($info, $errMsg);
|
|
|
286 |
return;
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
# importing text file
|
|
|
290 |
$errMsg = $db->importDatabaseFile(SP_INSTALL_DB_LANG_FILE);
|
|
|
291 |
if($db->error ){
|
|
|
292 |
$errMsg = "Error occured while importing data: ". $errMsg;
|
|
|
293 |
$this->startInstallation($info, $errMsg);
|
|
|
294 |
return;
|
|
|
295 |
}
|
|
|
296 |
|
|
|
297 |
# write to config file
|
|
|
298 |
$this->writeConfigFile($info);
|
|
|
299 |
|
|
|
300 |
# create API Key if not exists
|
|
|
301 |
$this->createSeoPanelAPIKey($db);
|
|
|
302 |
|
|
|
303 |
if(gethostbynamel('seopanel.in')){
|
|
|
304 |
include_once SP_INSTALL_DIR.'/../libs/spider.class.php';
|
|
|
305 |
include_once(SP_INSTALL_CONFIG_FILE);
|
|
|
306 |
$installUpdateUrl = "https://www.seopanel.org/installupdate.php?url=".urlencode($info['web_path'])."&ip=".$_SERVER['SERVER_ADDR']."&email=".urlencode($info['email']);
|
|
|
307 |
$installUpdateUrl .= "&version=".SP_INSTALLED;
|
|
|
308 |
$spider = New Spider();
|
|
|
309 |
$spider->getContent($installUpdateUrl, false, false);
|
|
|
310 |
}
|
|
|
311 |
|
|
|
312 |
$db = function_exists('mysqli_query') ? New DBI() : New DB();
|
|
|
313 |
$db->connectDatabase($info['db_host'], $info['db_user'], $info['db_pass'], $info['db_name']);
|
|
|
314 |
|
|
|
315 |
// update email for admin
|
|
|
316 |
$sql = "update users set email='".addslashes($info['email'])."' where id=1";
|
|
|
317 |
$db->query($sql);
|
|
|
318 |
|
|
|
319 |
// select languages list
|
|
|
320 |
$sql = "select * from languages where translated=1";
|
|
|
321 |
$langList = $db->select($sql);
|
|
|
322 |
|
|
|
323 |
// select timezones
|
|
|
324 |
$sql = "select * from timezone order by id";
|
|
|
325 |
$timezoneList = $db->select($sql);
|
|
|
326 |
?>
|
|
|
327 |
<form method="post" action="<?php echo $info['web_path']."/login.php"; ?>">
|
|
|
328 |
<h1 class="BlockHeader">Seo Panel Installation Success</h1>
|
|
|
329 |
<table width="100%" cellspacing="8px" cellpadding="0px" class="formtab">
|
|
|
330 |
<tr><th colspan="2" class="headersuccess">Seo Panel installed successfully!</th></tr>
|
|
|
331 |
<tr>
|
|
|
332 |
<td class="warning" colspan="2">Warning!</td>
|
|
|
333 |
</tr>
|
|
|
334 |
<tr>
|
|
|
335 |
<td style="border: none;" colspan="2">
|
|
|
336 |
<ul class="list">
|
|
|
337 |
<li> Please change permission of config file <b><?php echo SP_CONFIG_FILE;?></b> to avoid security issues.</li>
|
|
|
338 |
<li>Please remove installation directory <b>install</b> to avoid security issues.</li>
|
|
|
339 |
</ul>
|
|
|
340 |
</td>
|
|
|
341 |
</tr>
|
|
|
342 |
<tr>
|
|
|
343 |
<td class="warning" style="color:black;" colspan="2">Admin Login</td>
|
|
|
344 |
</tr>
|
|
|
345 |
<tr>
|
|
|
346 |
<td style="border-left: none;">Default Language:</td>
|
|
|
347 |
<td>
|
|
|
348 |
<select name="lang_code">
|
|
|
349 |
<?php
|
|
|
350 |
foreach ($langList as $langInfo) {
|
|
|
351 |
$selected = ($langInfo['lang_code'] == 'en') ? "selected" : "";
|
|
|
352 |
?>
|
|
|
353 |
<option value="<?php echo $langInfo['lang_code']?>" <?php echo $selected?>><?php echo $langInfo['lang_name']?></option>
|
|
|
354 |
<?php
|
|
|
355 |
}
|
|
|
356 |
?>
|
|
|
357 |
</select>
|
|
|
358 |
</td>
|
|
|
359 |
</tr>
|
|
|
360 |
<tr>
|
|
|
361 |
<td style="border-left: none;">Default Time Zone:</td>
|
|
|
362 |
<td>
|
|
|
363 |
<select name="time_zone" style="width: 260px;">
|
|
|
364 |
<?php
|
|
|
365 |
$listInfo['set_val'] = ini_get('date.timezone');
|
|
|
366 |
foreach ($timezoneList as $timezoneInfo) {
|
|
|
367 |
$selected = (trim($timezoneInfo['timezone_name']) == $listInfo['set_val']) ? 'selected="selected"' : "";
|
|
|
368 |
?>
|
|
|
369 |
<option value="<?php echo $timezoneInfo['timezone_name']?>" <?php echo $selected?> ><?php echo $timezoneInfo['timezone_label']?></option>
|
|
|
370 |
<?php
|
|
|
371 |
}
|
|
|
372 |
?>
|
|
|
373 |
</select>
|
|
|
374 |
</td>
|
|
|
375 |
</tr>
|
|
|
376 |
<tr>
|
|
|
377 |
<td style="border: none;font-weight: normal;font-size: 13px;" colspan="2">
|
|
|
378 |
<b>Username:</b> <?php echo SP_ADMIN_USER?><br>
|
|
|
379 |
<b>Password:</b> <?php echo SP_ADMIN_PASS?><br><br>
|
|
|
380 |
<b>Note:</b> Please change password of admin after first login.
|
|
|
381 |
</td>
|
|
|
382 |
</tr>
|
|
|
383 |
</table>
|
|
|
384 |
<input type="hidden" name="sec" value="login">
|
|
|
385 |
<input type="hidden" name="userName" value="spadmin">
|
|
|
386 |
<input type="hidden" name="password" value="spadmin">
|
|
|
387 |
<input type="submit" value="Proceed to admin login >>" name="submit" class="button">
|
|
|
388 |
</form>
|
|
|
389 |
<?php
|
|
|
390 |
}
|
|
|
391 |
|
|
|
392 |
|
|
|
393 |
# func to check upgrade requirements
|
|
|
394 |
function checkUpgradeRequirements($error=false, $errorMsg='') {
|
|
|
395 |
|
|
|
396 |
$phpClass = "red";
|
|
|
397 |
$phpSupport = "No";
|
|
|
398 |
$phpVersion = phpversion();
|
|
|
399 |
if (intval($phpVersion) >= 5) {
|
|
|
400 |
$phpClass = "green";
|
|
|
401 |
$phpSupport = "Yes";
|
|
|
402 |
}
|
|
|
403 |
$phpSupport .= " ( PHP $phpVersion )";
|
|
|
404 |
|
|
|
405 |
$mysqlClass = "red";
|
|
|
406 |
$mysqlSupport = "No";
|
|
|
407 |
if(function_exists('mysql_query')|| function_exists('mysqli_query')){
|
|
|
408 |
$mysqlSupport = "Yes";
|
|
|
409 |
$mysqlClass = "green";
|
|
|
410 |
}
|
|
|
411 |
|
|
|
412 |
$curlClass = "red";
|
|
|
413 |
$curlSupport = "No";
|
|
|
414 |
if(function_exists('curl_version')){
|
|
|
415 |
$version = curl_version();
|
|
|
416 |
$curlSupport = "Yes ( CURL {$version['version']} )";
|
|
|
417 |
$curlClass = "green";
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
/*
|
|
|
421 |
$shorttagClass = "red";
|
|
|
422 |
$shorttagSupport = "Disabled";
|
|
|
423 |
if(ini_get('short_open_tag')){
|
|
|
424 |
$shorttagSupport = "Enabled";
|
|
|
425 |
$shorttagClass = "green";
|
|
|
426 |
}*/
|
|
|
427 |
|
|
|
428 |
$gdClass = "red";
|
|
|
429 |
$gdSupport = "No";
|
|
|
430 |
if(function_exists('gd_info')){
|
|
|
431 |
$version = gd_info();
|
|
|
432 |
$gdSupport = "Yes ( GD {$version['GD Version']} )";
|
|
|
433 |
$gdClass = "green";
|
|
|
434 |
}
|
|
|
435 |
|
|
|
436 |
$tmpClass = "red";
|
|
|
437 |
$tmpSupport = "Not found";
|
|
|
438 |
$tmpFile = SP_INSTALL_DIR.'/../tmp';
|
|
|
439 |
if(file_exists($tmpFile)){
|
|
|
440 |
$tmpSupport = "Found, Unwritable<br><p class='note'><b>Command:</b> chmod -R 777 tmp/</p>";
|
|
|
441 |
if(is_writable($tmpFile)){
|
|
|
442 |
$tmpSupport = "Found, Writable";
|
|
|
443 |
$tmpClass = "green";
|
|
|
444 |
}
|
|
|
445 |
}
|
|
|
446 |
|
|
|
447 |
$configClass = "red";
|
|
|
448 |
$configSupport = "Not found";
|
|
|
449 |
$configFile = SP_INSTALL_CONFIG_FILE;
|
|
|
450 |
if(file_exists($configFile)){
|
|
|
451 |
$configSupport = "Found";
|
|
|
452 |
$configClass = "green";
|
|
|
453 |
}
|
|
|
454 |
|
|
|
455 |
$dbClass = "red";
|
|
|
456 |
$dbSupport = "Database config variables not defined";
|
|
|
457 |
include_once(SP_INSTALL_CONFIG_FILE);
|
|
|
458 |
if(defined('DB_HOST') && defined('DB_NAME') && defined('DB_USER') && defined('DB_PASSWORD') && defined('DB_ENGINE')){
|
|
|
459 |
$db = function_exists('mysqli_query') ? New DBI() : New DB();
|
|
|
460 |
|
|
|
461 |
$errMsg = $db->connectDatabase(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
|
|
462 |
if($db->error ){
|
|
|
463 |
$dbSupport = $errMsg;
|
|
|
464 |
}else{
|
|
|
465 |
$dbSupport = "Connected to database successfully";
|
|
|
466 |
$dbClass = "green";
|
|
|
467 |
}
|
|
|
468 |
}
|
|
|
469 |
|
|
|
470 |
$errMsg = "";
|
|
|
471 |
if($error){
|
|
|
472 |
if(empty($errorMsg)){
|
|
|
473 |
if( ($phpClass == 'red') || ($mysqlClass == 'red') || ($curlClass == 'red')
|
|
|
474 |
|| ($configClass == 'red') || ($dbClass == 'red') ){
|
|
|
475 |
$errMsg = "Please fix the following errors to proceed to next step!";
|
|
|
476 |
}
|
|
|
477 |
}else{
|
|
|
478 |
$errMsg = $errorMsg;
|
|
|
479 |
}
|
|
|
480 |
}
|
|
|
481 |
|
|
|
482 |
?>
|
|
|
483 |
<h1 class="BlockHeader">Welcome to Seo panel Upgrade</h1>
|
|
|
484 |
<form method="post">
|
|
|
485 |
<table width="100%" cellspacing="8px" cellpadding="0px" class="formtab">
|
|
|
486 |
<tr><th colspan="2" class="header">Upgrade compatibility</th></tr>
|
|
|
487 |
<tr><td colspan="2" class="error"><?php echo $errMsg;?></td></tr>
|
|
|
488 |
<tr>
|
|
|
489 |
<th>PHP version >= 5.4.0</th>
|
|
|
490 |
<td class="<?php echo $phpClass;?>"><?php echo $phpSupport;?></td>
|
|
|
491 |
</tr>
|
|
|
492 |
<tr>
|
|
|
493 |
<th>MySQL Support</th>
|
|
|
494 |
<td class="<?php echo $mysqlClass;?>"><?php echo $mysqlSupport;?></td>
|
|
|
495 |
</tr>
|
|
|
496 |
<tr>
|
|
|
497 |
<th>CURL Support</th>
|
|
|
498 |
<td class="<?php echo $curlClass;?>"><?php echo $curlSupport; ?></td>
|
|
|
499 |
</tr>
|
|
|
500 |
<?php /*?>
|
|
|
501 |
<tr>
|
|
|
502 |
<th>PHP short_open_tag</th>
|
|
|
503 |
<td class="<?php echo $shorttagClass;?>"><?php echo $shorttagSupport; ?></td>
|
|
|
504 |
</tr>
|
|
|
505 |
<?php */ ?>
|
|
|
506 |
<tr>
|
|
|
507 |
<th>GD graphics support</th>
|
|
|
508 |
<td class="<?php echo $gdClass;?>"><?php echo $gdSupport; ?></td>
|
|
|
509 |
</tr>
|
|
|
510 |
<tr>
|
|
|
511 |
<th>/config/sp-config.php</th>
|
|
|
512 |
<td class="<?php echo $configClass;?>"><?php echo $configSupport; ?></td>
|
|
|
513 |
</tr>
|
|
|
514 |
<tr>
|
|
|
515 |
<th>Database</th>
|
|
|
516 |
<td class="<?php echo $dbClass;?>"><?php echo $dbSupport; ?></td>
|
|
|
517 |
</tr>
|
|
|
518 |
<tr>
|
|
|
519 |
<th>/tmp</th>
|
|
|
520 |
<td class="<?php echo $tmpClass;?>"><?php echo $tmpSupport; ?></td>
|
|
|
521 |
</tr>
|
|
|
522 |
</table>
|
|
|
523 |
<input type="hidden" value="<?php echo $phpClass;?>" name="php_support">
|
|
|
524 |
<input type="hidden" value="<?php echo $mysqlClass;?>" name="mysql_support">
|
|
|
525 |
<input type="hidden" value="<?php echo $curlClass;?>" name="curl_support">
|
|
|
526 |
<?php /* ?><input type="hidden" value="<?php echo $shorttagClass;?>" name="short_open_tag"><?php */ ?>
|
|
|
527 |
<input type="hidden" value="<?php echo $configClass;?>" name="config">
|
|
|
528 |
<input type="hidden" value="<?php echo $dbClass;?>" name="db_support">
|
|
|
529 |
<input type="hidden" value="proceedupgrade" name="sec">
|
|
|
530 |
<?php $submitLabel = defined('SP_INSTALLED') ? "Upgrade to Seo Panel v.".SP_INSTALLED : "Upgrade Seo Panel"; ?>
|
|
|
531 |
<input type="submit" value="<?php echo $submitLabel?> >>" name="submit" class="button">
|
|
|
532 |
</form>
|
|
|
533 |
<?php
|
|
|
534 |
}
|
|
|
535 |
|
|
|
536 |
function getUpgradeDBFiles($db) {
|
|
|
537 |
|
|
|
538 |
$upgradeFileList = array();
|
|
|
539 |
$spVersionList = array(
|
|
|
540 |
'3.8.0',
|
|
|
541 |
'3.9.0',
|
|
|
542 |
'3.10.0',
|
|
|
543 |
'3.11.0',
|
|
|
544 |
'3.12.0',
|
|
|
545 |
'3.13.0',
|
|
|
546 |
'3.14.0',
|
|
|
547 |
'3.15.0',
|
|
|
548 |
'3.16.0',
|
|
|
549 |
'3.17.0',
|
|
|
550 |
'3.18.0',
|
|
|
551 |
'4.0.0',
|
|
|
552 |
'4.1.0',
|
|
|
553 |
'4.2.0',
|
|
|
554 |
'4.3.0',
|
|
|
555 |
'4.4.0',
|
|
|
556 |
);
|
|
|
557 |
|
|
|
558 |
// get current version number
|
|
|
559 |
$sql = "Select set_val from settings where set_name='SP_VERSION_NUMBER'";
|
|
|
560 |
$versionInfo = $db->select($sql, true);
|
|
|
561 |
$currentVersion = !empty($versionInfo['set_val']) ? $versionInfo['set_val'] : '3.8.0';
|
|
|
562 |
|
|
|
563 |
// if current version is set
|
|
|
564 |
if ($currentVersion) {
|
|
|
565 |
|
|
|
566 |
$index = array_search($currentVersion, $spVersionList);
|
|
|
567 |
$lastIndex = count($spVersionList) - 1;
|
|
|
568 |
|
|
|
569 |
// if it is not last index value
|
|
|
570 |
if ($index != $lastIndex) {
|
|
|
571 |
$prevIndex = $index;
|
|
|
572 |
|
|
|
573 |
// loop through the versions
|
|
|
574 |
for ($i = $index + 1; $i <= $lastIndex; $i++) {
|
|
|
575 |
$upgradeFileList[] = SP_INSTALL_DIR . "/data/upgrade_v$spVersionList[$prevIndex]_v$spVersionList[$i].sql";
|
|
|
576 |
$prevIndex = $i;
|
|
|
577 |
}
|
|
|
578 |
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
}
|
|
|
582 |
|
|
|
583 |
$upgradeFileList[] = SP_UPGRADE_DB_FILE;
|
|
|
584 |
return $upgradeFileList;
|
|
|
585 |
|
|
|
586 |
}
|
|
|
587 |
|
|
|
588 |
function proceedUpgrade($info=''){
|
|
|
589 |
if( ($info['php_support'] == 'red') || ($info['mysql_support'] == 'red') || ($info['curl_support'] == 'red')
|
|
|
590 |
|| ($info['config'] == 'red') || ($info['db_support'] == 'red')){
|
|
|
591 |
$this->checkUpgradeRequirements(true);
|
|
|
592 |
return;
|
|
|
593 |
}
|
|
|
594 |
|
|
|
595 |
include_once(SP_INSTALL_CONFIG_FILE);
|
|
|
596 |
$db = function_exists('mysqli_query') ? New DBI() : New DB();
|
|
|
597 |
|
|
|
598 |
// check database connection
|
|
|
599 |
$errMsg = $db->connectDatabase(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
|
|
|
600 |
if($db->error){
|
|
|
601 |
$this->checkUpgradeRequirements(true, $errMsg);
|
|
|
602 |
return;
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
// loop through upgrade files and import data to db
|
|
|
606 |
$upgradeFileList = $this->getUpgradeDBFiles($db);
|
|
|
607 |
foreach ($upgradeFileList as $dbFile) {
|
|
|
608 |
$errMsg = $db->importDatabaseFile($dbFile, false);
|
|
|
609 |
}
|
|
|
610 |
|
|
|
611 |
// importing text file
|
|
|
612 |
$errMsg = $db->importDatabaseFile(SP_UPGRADE_DB_LANG_FILE, false);
|
|
|
613 |
$_SESSION['text'] = "";
|
|
|
614 |
|
|
|
615 |
# create API Key if not exists
|
|
|
616 |
$this->createSeoPanelAPIKey($db);
|
|
|
617 |
|
|
|
618 |
?>
|
|
|
619 |
<form method="post" action="<?php echo SP_WEBPATH."/login.php"; ?>">
|
|
|
620 |
<h1 class="BlockHeader">Success Seo Panel v.<?php echo SP_INSTALLED;?> Upgrade</h1>
|
|
|
621 |
<table width="100%" cellspacing="8px" cellpadding="0px" class="formtab">
|
|
|
622 |
<tr><th colspan="2" class="headersuccess">Seo Panel upgraded successfully!</th></tr>
|
|
|
623 |
<tr>
|
|
|
624 |
<td class="warning">Warning!</td>
|
|
|
625 |
</tr>
|
|
|
626 |
<tr>
|
|
|
627 |
<td style="border: none;">
|
|
|
628 |
<ul class="list">
|
|
|
629 |
<li>Please remove installation directory <b>install</b> to avoid security issues.</li>
|
|
|
630 |
</ul>
|
|
|
631 |
</td>
|
|
|
632 |
</tr>
|
|
|
633 |
</table>
|
|
|
634 |
<input type="submit" value="Proceed to admin login >>" name="submit" class="button">
|
|
|
635 |
</form>
|
|
|
636 |
<?php
|
|
|
637 |
}
|
|
|
638 |
|
|
|
639 |
|
|
|
640 |
# func to show default install header
|
|
|
641 |
function showDefaultHeader() {
|
|
|
642 |
?>
|
|
|
643 |
<html>
|
|
|
644 |
<head>
|
|
|
645 |
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
|
|
|
646 |
<link rel="shortcut icon" href="../images/favicon.ico" />
|
|
|
647 |
<title>Seo Panel installation interface</title>
|
|
|
648 |
<meta name="description" content="Seo Panel installation Steps to install seo control panel for managing seo of your sites.">
|
|
|
649 |
<link rel="stylesheet" type="text/css" href="install.css" media="all" />
|
|
|
650 |
</head>
|
|
|
651 |
<body>
|
|
|
652 |
<div class="installdiv">
|
|
|
653 |
<?php
|
|
|
654 |
}
|
|
|
655 |
|
|
|
656 |
# func to show default install footer
|
|
|
657 |
function showDefaultFooter($content='') {
|
|
|
658 |
?>
|
|
|
659 |
</div>
|
|
|
660 |
</body>
|
|
|
661 |
</html>
|
|
|
662 |
<?php
|
|
|
663 |
}
|
|
|
664 |
|
|
|
665 |
# function to create seo panel API Key
|
|
|
666 |
function createSeoPanelAPIKey($db) {
|
|
|
667 |
$sql = "Select id, set_val from settings where set_name='SP_API_KEY'";
|
|
|
668 |
$apiInfo = $db->select($sql, true);
|
|
|
669 |
|
|
|
670 |
if (empty($apiInfo['set_val'])) {
|
|
|
671 |
$apiKey = rand(10000000, 100000000);
|
|
|
672 |
$apiKey .= rand(10000000, 100000000);
|
|
|
673 |
$apiKey .= rand(10000000, 100000000);
|
|
|
674 |
$apiKey = md5($apiKey);
|
|
|
675 |
|
|
|
676 |
if (empty($apiInfo['id'])) {
|
|
|
677 |
$sql = "Insert into settings(set_label,set_name,set_val,set_type) values('Seo Panel API Key', 'SP_API_KEY', '$apiKey', 'large')";
|
|
|
678 |
} else {
|
|
|
679 |
$sql = "update settings set set_val='$apiKey' where set_name='SP_API_KEY'";
|
|
|
680 |
}
|
|
|
681 |
$apiInfo = $db->query($sql);
|
|
|
682 |
}
|
|
|
683 |
}
|
|
|
684 |
}
|
|
|
685 |
?>
|