| 103 |
- |
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 defines all settings controller functions
|
|
|
24 |
class SettingsController extends Controller{
|
|
|
25 |
|
|
|
26 |
var $layout = 'ajax';
|
|
|
27 |
|
|
|
28 |
# function to show system settings
|
|
|
29 |
function showSystemSettings($category='system') {
|
|
|
30 |
$category = addslashes($category);
|
|
|
31 |
$this->set('list', $this->__getAllSettings(true, 1, $category));
|
|
|
32 |
|
|
|
33 |
if ($category == 'system') {
|
|
|
34 |
$langCtrler = New LanguageController();
|
|
|
35 |
$langList = $langCtrler->__getAllLanguages(" where translated=1");
|
|
|
36 |
$this->set('langList', $langList);
|
|
|
37 |
|
|
|
38 |
$timezoneCtrler = New TimeZoneController();
|
|
|
39 |
$timezoneList = $timezoneCtrler->__getAllTimezones();
|
|
|
40 |
$this->set('timezoneList', $timezoneList);
|
|
|
41 |
|
|
|
42 |
$currencyCtrler = new CurrencyController();
|
|
|
43 |
$this->set('currencyList', $currencyCtrler->__getAllCurrency(" and paypal=1 and status=1 and name!=''"));
|
|
|
44 |
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
$this->set('category', $category);
|
|
|
48 |
|
|
|
49 |
// if report settings page
|
|
|
50 |
if ($category == 'report') {
|
|
|
51 |
|
|
|
52 |
$spTextReport = $this->getLanguageTexts('report', $_SESSION['lang_code']);
|
|
|
53 |
$this->set('spTextReport', $spTextReport);
|
|
|
54 |
$scheduleList = array(
|
|
|
55 |
1 => $_SESSION['text']['label']['Daily'],
|
|
|
56 |
2 => $spTextReport['2 Days'],
|
|
|
57 |
7 => $_SESSION['text']['label']['Weekly'],
|
|
|
58 |
30 => $_SESSION['text']['label']['Monthly'],
|
|
|
59 |
);
|
|
|
60 |
$this->set('scheduleList', $scheduleList);
|
|
|
61 |
$this->render('settings/showreportsettings');
|
|
|
62 |
|
|
|
63 |
} else if ($category == 'proxy') {
|
|
|
64 |
|
|
|
65 |
$spTextProxy = $this->getLanguageTexts('proxy', $_SESSION['lang_code']);
|
|
|
66 |
$this->set('spTextProxy', $spTextProxy);
|
|
|
67 |
$this->render('settings/showproxysettings');
|
|
|
68 |
} else {
|
|
|
69 |
|
|
|
70 |
$spTextPanel = $this->getLanguageTexts('panel', $_SESSION['lang_code']);
|
|
|
71 |
|
|
|
72 |
// switch through category
|
|
|
73 |
switch ($category) {
|
|
|
74 |
|
|
|
75 |
case "api":
|
|
|
76 |
$this->set('headLabel', $spTextPanel['API Settings']);
|
|
|
77 |
break;
|
|
|
78 |
|
|
|
79 |
case "moz":
|
|
|
80 |
$this->set('headLabel', $spTextPanel['MOZ Settings']);
|
|
|
81 |
break;
|
|
|
82 |
|
|
|
83 |
case "google":
|
|
|
84 |
$this->set('headLabel', $spTextPanel['Google Settings']);
|
|
|
85 |
break;
|
|
|
86 |
|
|
|
87 |
case "mail":
|
|
|
88 |
$this->set('headLabel', $spTextPanel['Mail Settings']);
|
|
|
89 |
break;
|
|
|
90 |
|
|
|
91 |
default:
|
|
|
92 |
break;
|
|
|
93 |
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
$this->render('settings/showsettings');
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
function updateSystemSettings($postInfo) {
|
|
|
101 |
|
|
|
102 |
$setList = $this->__getAllSettings(true, 1, $postInfo['category']);
|
|
|
103 |
foreach($setList as $setInfo){
|
|
|
104 |
|
|
|
105 |
switch($setInfo['set_name']){
|
|
|
106 |
|
|
|
107 |
case "SP_PAGINGNO":
|
|
|
108 |
$postInfo[$setInfo['set_name']] = intval($postInfo[$setInfo['set_name']]);
|
|
|
109 |
$postInfo[$setInfo['set_name']] = empty($postInfo[$setInfo['set_name']]) ? SP_PAGINGNO_DEFAULT : $postInfo[$setInfo['set_name']];
|
|
|
110 |
break;
|
|
|
111 |
|
|
|
112 |
case "SP_CRAWL_DELAY":
|
|
|
113 |
case "SP_USER_GEN_REPORT":
|
|
|
114 |
case "SA_CRAWL_DELAY_TIME":
|
|
|
115 |
case "SA_MAX_NO_PAGES":
|
|
|
116 |
case "SP_NUMBER_KEYWORDS_CRON":
|
|
|
117 |
$postInfo[$setInfo['set_name']] = intval($postInfo[$setInfo['set_name']]);
|
|
|
118 |
break;
|
|
|
119 |
|
|
|
120 |
case "SP_SMTP_HOST":
|
|
|
121 |
case "SP_SMTP_USERNAME":
|
|
|
122 |
case "SP_SMTP_PASSWORD":
|
|
|
123 |
// if smtp mail enabled then check all smtp details entered
|
|
|
124 |
if (empty($postInfo[$setInfo['set_name']]) && !empty($postInfo['SP_SMTP_MAIL'])) {
|
|
|
125 |
$this->set('errorMsg', $this->spTextSettings['entersmtpdetails']);
|
|
|
126 |
$this->showSystemSettings($postInfo['category']);
|
|
|
127 |
exit;
|
|
|
128 |
}
|
|
|
129 |
break;
|
|
|
130 |
|
|
|
131 |
case "SP_SYSTEM_REPORT_INTERVAL":
|
|
|
132 |
// update users report schedule if system report schedule is greater than them
|
|
|
133 |
$postInfo[$setInfo['set_name']] = intval($postInfo[$setInfo['set_name']]);
|
|
|
134 |
$sql = "Update reports_settings set report_interval=".$postInfo[$setInfo['set_name']]." where report_interval<".$postInfo[$setInfo['set_name']];
|
|
|
135 |
$userList = $this->db->query($sql);
|
|
|
136 |
break;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
$sql = "update settings set set_val='".addslashes($postInfo[$setInfo['set_name']])."' where set_name='".addslashes($setInfo['set_name'])."'";
|
|
|
140 |
$this->db->query($sql);
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
$this->set('saved', 1);
|
|
|
144 |
$this->showSystemSettings($postInfo['category']);
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
# func to show about us of seo panel
|
|
|
148 |
function showAboutUs($info) {
|
|
|
149 |
|
|
|
150 |
$blogContent = getCustomizerPage('aboutus');
|
|
|
151 |
if (!empty($blogContent['blog_content'])) {
|
|
|
152 |
$this->set('blogContent', $blogContent);
|
|
|
153 |
} else {
|
|
|
154 |
|
|
|
155 |
if ($info['subsec'] != "sponsors") {
|
|
|
156 |
$sql = "select t.*,l.lang_name from translators t,languages l where t.lang_code=l.lang_code";
|
|
|
157 |
$transList = $this->db->select($sql);
|
|
|
158 |
$this->set('transList', $transList);
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
include_once(SP_CTRLPATH."/information.ctrl.php");
|
|
|
162 |
$infoCtrler = new InformationController();
|
|
|
163 |
$this->set('sponsors', $infoCtrler->getSponsors());
|
|
|
164 |
$this->set('subSec', $info['subsec']);
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
$this->render('settings/aboutus');
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
# func to show version of seo panel
|
|
|
171 |
function showVersion() {
|
|
|
172 |
$this->render('settings/version');
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
# function to check version
|
| 155 |
- |
176 |
function checkVersion($return = false) {
|
|
|
177 |
$oldVersion = false;
|
|
|
178 |
|
|
|
179 |
// find latest version of SP
|
|
|
180 |
$content = $this->spider->getContent(SP_VERSION_PAGE);
|
| 103 |
- |
181 |
$content['page'] = str_replace('Version:', '', $content['page']);
|
| 155 |
- |
182 |
$vList = explode(".", $content['page']);
|
|
|
183 |
$latestVersion = sprintf("%02d%02d%02d", $vList[0], $vList[1], $vList[2]);
|
|
|
184 |
|
|
|
185 |
// current version of installation
|
|
|
186 |
$vList = explode(".", SP_VERSION_NUMBER);
|
|
|
187 |
$installVersion = sprintf("%02d%02d%02d", $vList[0], $vList[1], $vList[2]);
|
|
|
188 |
|
|
|
189 |
// verify installation is upto date or not
|
| 103 |
- |
190 |
if ($latestVersion > $installVersion) {
|
| 155 |
- |
191 |
$oldVersion = true;
|
|
|
192 |
$message = $this->spTextSettings['versionnotuptodatemsg']."({$content['page']}) from <a href='".SP_DOWNLOAD_LINK."' target='_blank'>".SP_DOWNLOAD_LINK."</a>";
|
| 103 |
- |
193 |
} else {
|
| 155 |
- |
194 |
$message = $this->spTextSettings["Your Seo Panel installation is up to date"];
|
| 103 |
- |
195 |
}
|
| 155 |
- |
196 |
|
|
|
197 |
// if message needs to be returned
|
|
|
198 |
if ($return) {
|
|
|
199 |
return [$oldVersion, $message];
|
|
|
200 |
} else {
|
|
|
201 |
echo $oldVersion ? showErrorMsg($message, false) : showSuccessMsg($message, false);
|
|
|
202 |
}
|
|
|
203 |
|
| 103 |
- |
204 |
}
|
|
|
205 |
|
|
|
206 |
// show google api settings notification
|
|
|
207 |
public static function showCheckCategorySettings($category, $printMsg = false) {
|
|
|
208 |
$ctrler = new SettingsController();
|
|
|
209 |
$spTextSettings = $ctrler->getLanguageTexts('settings', $_SESSION['lang_code']);
|
|
|
210 |
$showMsg = '';
|
|
|
211 |
$notSet = false;
|
|
|
212 |
|
|
|
213 |
// if category is google
|
|
|
214 |
if ($category == 'google') {
|
|
|
215 |
$settingInfo = $ctrler->__getSettingInfo('SP_GOOGLE_API_KEY');
|
|
|
216 |
|
|
|
217 |
if (empty($settingInfo['set_val'])) {
|
|
|
218 |
$notSet = true;
|
|
|
219 |
$msgStr = $spTextSettings['Please update google settings to get the results'];
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
} else if ($category == 'moz') {
|
|
|
223 |
|
|
|
224 |
$accessInfo = $ctrler->__getSettingInfo('SP_MOZ_API_ACCESS_ID');
|
|
|
225 |
$secretInfo = $ctrler->__getSettingInfo('SP_MOZ_API_SECRET');
|
|
|
226 |
|
|
|
227 |
if (empty($accessInfo['set_val']) || empty($secretInfo['set_val'])) {
|
|
|
228 |
$notSet = true;
|
|
|
229 |
$msgStr = $spTextSettings['Please update MOZ settings to get complete results'];
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
// check whether settings is empty
|
|
|
235 |
if ($notSet) {
|
|
|
236 |
$settingUrl = isAdmin() ? SP_WEBPATH . "/admin-panel.php?menu_selected=settings&start_script=settings&category=$category" : "#";
|
|
|
237 |
$showMsg = '
|
|
|
238 |
<div id="topnewsbox">
|
|
|
239 |
<a class="bold_link" href="' . $settingUrl . '">'. $msgStr .' >>
|
|
|
240 |
</a>
|
|
|
241 |
</div>';
|
|
|
242 |
|
|
|
243 |
// if print message is enabled
|
|
|
244 |
if ($printMsg) {
|
|
|
245 |
echo $showMsg;
|
|
|
246 |
exit;
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
return $showMsg;
|
|
|
252 |
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
// function to get settings info
|
|
|
256 |
function __getSettingInfo($setName) {
|
|
|
257 |
$setInfo = $this->dbHelper->getRow('settings', "set_name='".addslashes($setName)."'");
|
|
|
258 |
return $setInfo;
|
|
|
259 |
}
|
|
|
260 |
|
|
|
261 |
// function to show test email
|
|
|
262 |
function showTestEmailSettings() {
|
|
|
263 |
$this->render('settings/show_test_email');
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
// fucntion to send test email
|
|
|
267 |
function sendTestEmail($info) {
|
|
|
268 |
$errMsg = formatErrorMsg($this->validate->checkEmail($info['test_email']));
|
|
|
269 |
|
|
|
270 |
if(!$this->validate->flagErr){
|
|
|
271 |
|
|
|
272 |
$userController = New UserController();
|
|
|
273 |
$adminInfo = $userController->__getAdminInfo();
|
|
|
274 |
$adminName = $adminInfo['first_name']."-".$adminInfo['last_name'];
|
|
|
275 |
$this->set('adminName', $adminName);
|
|
|
276 |
$content = $this->getViewContent('email/test_email');
|
|
|
277 |
|
|
|
278 |
if (!sendMail($adminInfo['email'], $adminName, $info['test_email'], "Test email from " . SP_COMPANY_NAME, $content)) {
|
|
|
279 |
showErrorMsg('An internal error occured while sending mail!');
|
|
|
280 |
} else {
|
|
|
281 |
showSuccessMsg("Email send successfully to " . $info['test_email']);
|
|
|
282 |
}
|
|
|
283 |
|
|
|
284 |
} else {
|
|
|
285 |
showErrorMsg($errMsg);
|
|
|
286 |
}
|
|
|
287 |
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
}
|
|
|
291 |
?>
|