| 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 website controller functions
|
|
|
24 |
class WebsiteController extends Controller{
|
|
|
25 |
|
|
|
26 |
# func to show websites
|
|
|
27 |
function listWebsites($info=''){
|
|
|
28 |
|
|
|
29 |
$userId = isLoggedIn();
|
|
|
30 |
$info['pageno'] = intval($info['pageno']);
|
|
|
31 |
$pageScriptPath = 'websites.php?stscheck=';
|
|
|
32 |
$pageScriptPath .= isset($info['stscheck']) ? $info['stscheck'] : "select";
|
|
|
33 |
|
|
|
34 |
// if admin add user filter
|
|
|
35 |
if(isAdmin()){
|
|
|
36 |
$sql = "select w.*,u.username from websites w,users u where u.id=w.user_id";
|
|
|
37 |
$this->set('isAdmin', 1);
|
|
|
38 |
|
|
|
39 |
// if user id is not empty
|
|
|
40 |
if (!empty($info['userid'])) {
|
|
|
41 |
$sql .= " and w.user_id=".intval($info['userid']);
|
|
|
42 |
$pageScriptPath .= "&userid=" . intval($info['userid']);
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
$userCtrler = New UserController();
|
|
|
46 |
$userList = $userCtrler->__getAllUsers();
|
|
|
47 |
$this->set('userList', $userList);
|
|
|
48 |
|
|
|
49 |
}else{
|
|
|
50 |
$sql = "select * from websites w where user_id=$userId";
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
// search for user name
|
|
|
54 |
if (!empty($info['search_name'])) {
|
|
|
55 |
$sql .= " and (w.name like '%".addslashes($info['search_name'])."%'
|
|
|
56 |
or w.url like '%".addslashes($info['search_name'])."%')";
|
|
|
57 |
$pageScriptPath .= "&search_name=" . $info['search_name'];
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
// if status set
|
|
|
61 |
if (isset($info['stscheck']) && $info['stscheck'] != 'select') {
|
|
|
62 |
$info['stscheck'] = intval($info['stscheck']);
|
|
|
63 |
$sql .= " and w.status='{$info['stscheck']}'";
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
$sql .= " order by w.name";
|
|
|
67 |
$this->set('userId', empty($info['userid']) ? 0 : $info['userid']);
|
|
|
68 |
|
|
|
69 |
# pagination setup
|
|
|
70 |
$this->db->query($sql, true);
|
|
|
71 |
$this->paging->setDivClass('pagingdiv');
|
|
|
72 |
$this->paging->loadPaging($this->db->noRows, SP_PAGINGNO);
|
|
|
73 |
$pagingDiv = $this->paging->printPages($pageScriptPath);
|
|
|
74 |
$this->set('pagingDiv', $pagingDiv);
|
|
|
75 |
$sql .= " limit ".$this->paging->start .",". $this->paging->per_page;
|
|
|
76 |
|
|
|
77 |
$statusList = array(
|
|
|
78 |
$_SESSION['text']['common']['Active'] => 1,
|
|
|
79 |
$_SESSION['text']['common']['Inactive'] => 0,
|
|
|
80 |
);
|
|
|
81 |
|
|
|
82 |
$this->set('statusList', $statusList);
|
|
|
83 |
$this->set('info', $info);
|
|
|
84 |
|
|
|
85 |
$websiteList = $this->db->select($sql);
|
|
|
86 |
$this->set('pageNo', $info['pageno']);
|
|
|
87 |
$this->set('list', $websiteList);
|
|
|
88 |
$this->render('website/list');
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
# func to get all Websites
|
|
|
92 |
function __getAllWebsites($userId = '', $isAdminCheck = false, $searchName = '') {
|
|
|
93 |
$sql = "select * from websites where status=1";
|
|
|
94 |
if(!$isAdminCheck || !isAdmin() ) {
|
|
|
95 |
if(!empty($userId)) {
|
|
|
96 |
$sql .= $this->getWebsiteUserAccessCondition($userId, "id", "user_id");
|
|
|
97 |
}
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
// if search string is not empty
|
|
|
101 |
if (!empty($searchName)) {
|
|
|
102 |
$sql .= " and (name like '%".addslashes($searchName)."%' or url like '%".addslashes($searchName)."%')";
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
$sql .= " order by name";
|
|
|
106 |
$websiteList = $this->db->select($sql);
|
|
|
107 |
return $websiteList;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
function __getUserWebsites($userId, $searchInfo=[]) {
|
|
|
111 |
$cond = "user_id=".intval($userId);
|
|
|
112 |
$cond .= isset($searchInfo['status']) ? " and status=".intval($searchInfo['status']) : "";
|
|
|
113 |
$cond .= isset($searchInfo['search']) ? " and url like '%".addslashes($searchInfo['search'])."%'" : "";
|
|
|
114 |
return $this->dbHelper->getAllRows('websites', $cond);
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
# func to get all Websites
|
|
|
118 |
function __getCountAllWebsites($userId='', $statusCheck = true, $statusVal = 1){
|
|
|
119 |
|
|
|
120 |
$sql = "select count(*) count from websites where 1=1";
|
|
|
121 |
$sql .= $statusCheck ? " and status=" . $statusVal : "";
|
|
|
122 |
|
|
|
123 |
if (!empty($userId)) {
|
|
|
124 |
$sql .= " and user_id=" . intval($userId);
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
$countInfo = $this->db->select($sql, true);
|
|
|
128 |
$count = empty($countInfo['count']) ? 0 : $countInfo['count'];
|
|
|
129 |
return $count;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
# func to get all Websites having active keywords
|
|
|
133 |
function __getAllWebsitesWithActiveKeywords($userId='', $isAdminCheck=false){
|
|
|
134 |
$sql = "select w.* from websites w,keywords k where w.id=k.website_id and w.status=1 and k.status=1";
|
|
|
135 |
if(!$isAdminCheck || !isAdmin() ){
|
|
|
136 |
if(!empty($userId)) {
|
|
|
137 |
$sql .= $this->getWebsiteUserAccessCondition($userId);
|
|
|
138 |
}
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
$sql .= " group by w.id order by w.name";
|
|
|
142 |
$websiteList = $this->db->select($sql);
|
|
|
143 |
return $websiteList;
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
function getWebsiteUserAccessCondition($userId, $col="w.id", $userCol = "w.user_id") {
|
|
|
147 |
if (SP_CUSTOM_DEV) {
|
|
|
148 |
$userCtrl = new UserController();
|
|
|
149 |
$webAccessList = $userCtrl->getUserWebsiteAccessList($userId);
|
|
|
150 |
$webIdList = array_keys($webAccessList);
|
|
|
151 |
$webIdList = !empty($webIdList) ? $webIdList : array(0);
|
|
|
152 |
$cond = " and ($userCol=" . intval($userId) . " or $col in (".implode($webIdList, ',')."))";
|
|
|
153 |
} else {
|
|
|
154 |
$cond = " and $userCol=" . intval($userId);
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
return $cond;
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
# func to change status
|
|
|
161 |
function __changeStatus($websiteId, $status){
|
|
|
162 |
|
|
|
163 |
$websiteId = intval($websiteId);
|
|
|
164 |
$sql = "update websites set status=$status where id=$websiteId";
|
|
|
165 |
$this->db->query($sql);
|
|
|
166 |
|
|
|
167 |
$sql = "update keywords set status=$status where website_id=$websiteId";
|
|
|
168 |
$this->db->query($sql);
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
# func to delete website
|
|
|
172 |
function __deleteWebsite($websiteId){
|
|
|
173 |
|
|
|
174 |
$websiteId = intval($websiteId);
|
|
|
175 |
$sql = "delete from websites where id=$websiteId";
|
|
|
176 |
$this->db->query($sql);
|
|
|
177 |
|
|
|
178 |
# delete all keywords under this website
|
|
|
179 |
$sql = "select id from keywords where website_id=$websiteId";
|
|
|
180 |
$keywordList = $this->db->select($sql);
|
|
|
181 |
$keywordCtrler = New KeywordController();
|
|
|
182 |
foreach($keywordList as $keywordInfo){
|
|
|
183 |
$keywordCtrler->__deleteKeyword($keywordInfo['id']);
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
# remove rank results
|
|
|
187 |
$sql = "delete from rankresults where website_id=$websiteId";
|
|
|
188 |
$this->db->query($sql);
|
|
|
189 |
|
|
|
190 |
# remove backlink results
|
|
|
191 |
$sql = "delete from backlinkresults where website_id=$websiteId";
|
|
|
192 |
$this->db->query($sql);
|
|
|
193 |
|
|
|
194 |
# remove saturation results
|
|
|
195 |
$sql = "delete from saturationresults where website_id=$websiteId";
|
|
|
196 |
$this->db->query($sql);
|
|
|
197 |
|
|
|
198 |
# remove site auditor results
|
|
|
199 |
$sql = "select id from auditorprojects where website_id=$websiteId";
|
|
|
200 |
$info = $this->db->select($sql, true);
|
|
|
201 |
if (!empty($info['id'])) {
|
|
|
202 |
$auditorObj = $this->createController('SiteAuditor');
|
|
|
203 |
$auditorObj->__deleteProject($info['id']);
|
|
|
204 |
}
|
|
|
205 |
|
|
|
206 |
#remove directory results
|
|
|
207 |
$sql = "delete from dirsubmitinfo where website_id=$websiteId";
|
|
|
208 |
$this->db->query($sql);
|
|
|
209 |
$sql = "delete from skipdirectories where website_id=$websiteId";
|
|
|
210 |
$this->db->query($sql);
|
|
|
211 |
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
function newWebsite($info=''){
|
|
|
215 |
|
|
|
216 |
$userId = isLoggedIn();
|
|
|
217 |
if(!empty($info['check']) && !$this->__getCountAllWebsites($userId)){
|
|
|
218 |
$this->set('msg', $this->spTextWeb['plscrtwebsite'].'<br>Please <a href="javascript:void(0);" onclick="scriptDoLoad(\'websites.php\', \'content\')">'.strtolower($_SESSION['text']['common']['Activate']).'</a> '.$this->spTextWeb['yourwebalreday']);
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
# Validate website count
|
|
|
222 |
if (!$this->validateWebsiteCount($userId)) {
|
|
|
223 |
$this->set('validationMsg', $this->spTextWeb['Your website count already reached the limit']);
|
|
|
224 |
}
|
|
|
225 |
|
|
|
226 |
# get all users
|
|
|
227 |
if(isAdmin()){
|
|
|
228 |
$userCtrler = New UserController();
|
|
|
229 |
$userList = $userCtrler->__getAllUsers();
|
|
|
230 |
$this->set('userList', $userList);
|
|
|
231 |
$this->set('userSelected', empty($info['userid']) ? $userId : $info['userid']);
|
|
|
232 |
$this->set('isAdmin', 1);
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
$this->render('website/new');
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
function __checkName($name, $userId){
|
|
|
239 |
|
|
|
240 |
$sql = "select id from websites where name='".addslashes($name)."' and user_id=$userId";
|
|
|
241 |
$listInfo = $this->db->select($sql, true);
|
|
|
242 |
return empty($listInfo['id']) ? false : $listInfo['id'];
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
function __checkWebsiteUrl($url, $websiteId=0){
|
|
|
246 |
$sql = "select id from websites where url='".addslashes($url)."'";
|
|
|
247 |
$sql .= $websiteId ? " and id!=$websiteId" : "";
|
|
|
248 |
$listInfo = $this->db->select($sql, true);
|
|
|
249 |
return empty($listInfo['id']) ? false : $listInfo['id'];
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
function createWebsite($listInfo, $apiCall = false){
|
|
|
253 |
|
|
|
254 |
// add user id when using as admin or calling api
|
|
|
255 |
if (isAdmin() || $apiCall) {
|
|
|
256 |
$userId = empty($listInfo['userid']) ? isLoggedIn() : intval($listInfo['userid']);
|
|
|
257 |
} else {
|
|
|
258 |
$userId = isLoggedIn();
|
|
|
259 |
}
|
|
|
260 |
|
|
|
261 |
$errMsg = [];
|
|
|
262 |
$listInfo['name'] = strip_tags($listInfo['name']);
|
|
|
263 |
$this->set('post', $listInfo);
|
|
|
264 |
$errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name']));
|
|
|
265 |
$errMsg['url'] = formatErrorMsg($this->validate->checkBlank($listInfo['url']));
|
|
|
266 |
$listInfo['url'] = addHttpToUrl($listInfo['url']);
|
|
|
267 |
$statusVal = isset($listInfo['status']) ? intval($listInfo['status']) : 1;
|
|
|
268 |
|
|
|
269 |
// verify the limit for the user
|
|
|
270 |
if (!$this->validateWebsiteCount($userId)) {
|
|
|
271 |
$this->set('validationMsg', $this->spTextWeb["Your website count already reached the limit"]);
|
|
|
272 |
$this->validate->flagErr = true;
|
|
|
273 |
$errMsg['limit_error'] = $this->spTextWeb["Your website count already reached the limit"];
|
|
|
274 |
}
|
|
|
275 |
|
|
|
276 |
// validate website creation
|
|
|
277 |
if(!$this->validate->flagErr){
|
|
|
278 |
if (!$this->__checkName($listInfo['name'], $userId)) {
|
|
|
279 |
if (!$this->__checkWebsiteUrl($listInfo['url'])) {
|
| 155 |
- |
280 |
$listInfo['title'] = substr($listInfo['title'], 0, 100);
|
|
|
281 |
$listInfo['description'] = substr($listInfo['description'], 0, 500);
|
|
|
282 |
$listInfo['keywords'] = substr($listInfo['keywords'], 0, 500);
|
| 103 |
- |
283 |
$sql = "insert into websites(name,url,title,description,analytics_view_id,keywords,user_id,status)
|
|
|
284 |
values('".addslashes($listInfo['name'])."','".addslashes($listInfo['url'])."','".
|
|
|
285 |
addslashes($listInfo['title'])."','".addslashes($listInfo['description'])."', '".addslashes($listInfo['analytics_view_id'])."', '".
|
|
|
286 |
addslashes($listInfo['keywords'])."', $userId, $statusVal)";
|
|
|
287 |
$this->db->query($sql);
|
|
|
288 |
|
|
|
289 |
// if api call
|
|
|
290 |
if ($apiCall) {
|
|
|
291 |
return array('success', 'Successfully created website');
|
|
|
292 |
} else {
|
|
|
293 |
$this->listWebsites();
|
|
|
294 |
exit;
|
|
|
295 |
}
|
|
|
296 |
|
|
|
297 |
} else {
|
|
|
298 |
$errMsg['url'] = formatErrorMsg($this->spTextWeb['Website already exist']);
|
|
|
299 |
}
|
|
|
300 |
}else{
|
|
|
301 |
$errMsg['name'] = formatErrorMsg($this->spTextWeb['Website already exist']);
|
|
|
302 |
}
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
// if api call
|
|
|
306 |
if ($apiCall) {
|
|
|
307 |
return array('error', $errMsg);
|
|
|
308 |
} else {
|
|
|
309 |
$this->set('errMsg', $errMsg);
|
|
|
310 |
$this->newWebsite($listInfo);
|
|
|
311 |
}
|
|
|
312 |
}
|
|
|
313 |
|
|
|
314 |
function __getWebsiteInfo($websiteId){
|
|
|
315 |
$websiteId = intval($websiteId);
|
|
|
316 |
$sql = "select * from websites where id=$websiteId";
|
|
|
317 |
$listInfo = $this->db->select($sql, true);
|
|
|
318 |
return empty($listInfo['id']) ? false : $listInfo;
|
|
|
319 |
}
|
|
|
320 |
|
|
|
321 |
function editWebsite($websiteId, $listInfo=''){
|
|
|
322 |
|
|
|
323 |
$websiteId = intval($websiteId);
|
|
|
324 |
if(!empty($websiteId)){
|
|
|
325 |
if(empty($listInfo)){
|
|
|
326 |
$listInfo = $this->__getWebsiteInfo($websiteId);
|
|
|
327 |
$listInfo['oldName'] = $listInfo['name'];
|
|
|
328 |
}
|
|
|
329 |
$listInfo['title'] = stripslashes($listInfo['title']);
|
|
|
330 |
$listInfo['description'] = stripslashes($listInfo['description']);
|
|
|
331 |
$listInfo['keywords'] = stripslashes($listInfo['keywords']);
|
|
|
332 |
$this->set('post', $listInfo);
|
|
|
333 |
|
|
|
334 |
# get all users
|
|
|
335 |
if(isAdmin()){
|
|
|
336 |
$userCtrler = New UserController();
|
|
|
337 |
$userList = $userCtrler->__getAllUsers();
|
|
|
338 |
$this->set('userList', $userList);
|
|
|
339 |
$this->set('isAdmin', 1);
|
|
|
340 |
}
|
|
|
341 |
|
|
|
342 |
$this->render('website/edit');
|
|
|
343 |
exit;
|
|
|
344 |
}
|
|
|
345 |
$this->listWebsites();
|
|
|
346 |
}
|
|
|
347 |
|
|
|
348 |
function updateWebsite($listInfo, $apiCall = false){
|
|
|
349 |
|
|
|
350 |
// check whether admin or api calll
|
|
|
351 |
if (isAdmin() || $apiCall) {
|
|
|
352 |
$userId = empty($listInfo['user_id']) ? isLoggedIn() : $listInfo['user_id'];
|
|
|
353 |
} else {
|
|
|
354 |
$userId = isLoggedIn();
|
|
|
355 |
}
|
|
|
356 |
|
|
|
357 |
$listInfo['id'] = intval($listInfo['id']);
|
|
|
358 |
$listInfo['name'] = strip_tags($listInfo['name']);
|
|
|
359 |
$this->set('post', $listInfo);
|
|
|
360 |
$errMsg['name'] = formatErrorMsg($this->validate->checkBlank($listInfo['name']));
|
|
|
361 |
$errMsg['url'] = formatErrorMsg($this->validate->checkBlank($listInfo['url']));
|
|
|
362 |
$listInfo['url'] = addHttpToUrl($listInfo['url']);
|
|
|
363 |
$statusVal = isset($listInfo['status']) ? "status = " . intval($listInfo['status']) ."," : "";
|
|
|
364 |
|
|
|
365 |
// check limit
|
|
|
366 |
if(!$this->validate->flagErr && !empty($listInfo['user_id'])){
|
|
|
367 |
$websiteInfo = $this->__getWebsiteInfo($listInfo['id']);
|
|
|
368 |
|
|
|
369 |
// if user is changed for editing
|
|
|
370 |
if ($websiteInfo['user_id'] != $listInfo['user_id']) {
|
|
|
371 |
|
|
|
372 |
// verify the limit for the user
|
|
|
373 |
if (!$this->validateWebsiteCount($listInfo['user_id'])) {
|
|
|
374 |
$this->set('validationMsg', $this->spTextWeb["Your website count already reached the limit"]);
|
|
|
375 |
$this->validate->flagErr = true;
|
|
|
376 |
$errMsg['limit_error'] = $this->spTextWeb["Your website count already reached the limit"];
|
|
|
377 |
}
|
|
|
378 |
}
|
|
|
379 |
}
|
|
|
380 |
|
|
|
381 |
// verify the form
|
|
|
382 |
if(!$this->validate->flagErr){
|
|
|
383 |
|
|
|
384 |
if($listInfo['name'] != $listInfo['oldName']){
|
|
|
385 |
if ($this->__checkName($listInfo['name'], $userId)) {
|
|
|
386 |
$errMsg['name'] = formatErrorMsg($this->spTextWeb['Website already exist']);
|
|
|
387 |
$this->validate->flagErr = true;
|
|
|
388 |
}
|
|
|
389 |
}
|
|
|
390 |
|
|
|
391 |
if ($this->__checkWebsiteUrl($listInfo['url'], $listInfo['id'])) {
|
|
|
392 |
$errMsg['url'] = formatErrorMsg($this->spTextWeb['Website already exist']);
|
|
|
393 |
$this->validate->flagErr = true;
|
|
|
394 |
}
|
|
|
395 |
|
|
|
396 |
if (!$this->validate->flagErr) {
|
| 155 |
- |
397 |
$listInfo['title'] = substr($listInfo['title'], 0, 100);
|
|
|
398 |
$listInfo['description'] = substr($listInfo['description'], 0, 500);
|
|
|
399 |
$listInfo['keywords'] = substr($listInfo['keywords'], 0, 500);
|
| 103 |
- |
400 |
$sql = "update websites set
|
|
|
401 |
name = '".addslashes($listInfo['name'])."',
|
|
|
402 |
url = '".addslashes($listInfo['url'])."',
|
|
|
403 |
user_id = $userId,
|
|
|
404 |
title = '".addslashes($listInfo['title'])."',
|
|
|
405 |
description = '".addslashes($listInfo['description'])."',
|
|
|
406 |
analytics_view_id = '".addslashes($listInfo['analytics_view_id'])."',
|
|
|
407 |
$statusVal
|
|
|
408 |
keywords = '".addslashes($listInfo['keywords'])."'
|
|
|
409 |
where id={$listInfo['id']}";
|
|
|
410 |
$this->db->query($sql);
|
|
|
411 |
|
|
|
412 |
// if api call
|
|
|
413 |
if ($apiCall) {
|
|
|
414 |
return array('success', 'Successfully updated website');
|
|
|
415 |
} else {
|
|
|
416 |
$this->listWebsites();
|
|
|
417 |
exit;
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
}
|
|
|
421 |
}
|
|
|
422 |
|
|
|
423 |
// if api call
|
|
|
424 |
if ($apiCall) {
|
|
|
425 |
return array('error', $errMsg);
|
|
|
426 |
} else {
|
|
|
427 |
$this->set('errMsg', $errMsg);
|
|
|
428 |
$this->editWebsite($listInfo['id'], $listInfo);
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
}
|
|
|
432 |
|
|
|
433 |
# func to crawl meta data of a website
|
|
|
434 |
public static function crawlMetaData($websiteUrl, $keyInput='', $pageContent='', $returVal=false) {
|
|
|
435 |
if (empty($pageContent)) {
|
|
|
436 |
if(!preg_match('/\w+/', $websiteUrl)) return;
|
|
|
437 |
$websiteUrl = addHttpToUrl($websiteUrl);
|
|
|
438 |
$spider = New Spider();
|
|
|
439 |
$ret = $spider->getContent($websiteUrl);
|
|
|
440 |
} else {
|
|
|
441 |
$ret['page'] = $pageContent;
|
|
|
442 |
$metaInfo = array();
|
|
|
443 |
}
|
|
|
444 |
if(!empty($ret['page'])){
|
|
|
445 |
|
|
|
446 |
if (empty($keyInput)) {
|
|
|
447 |
|
|
|
448 |
# meta title
|
|
|
449 |
preg_match('/<TITLE>(.*?)<\/TITLE>/si', $ret['page'], $matches);
|
|
|
450 |
if(!empty($matches[1])){
|
|
|
451 |
if ($returVal) {
|
|
|
452 |
$metaInfo['page_title'] = $matches[1];
|
|
|
453 |
} else {
|
|
|
454 |
WebsiteController::addInputValue($matches[1], 'webtitle');
|
|
|
455 |
}
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
# meta description
|
|
|
459 |
preg_match('/<META.*?name="description".*?content="(.*?)"/si', $ret['page'], $matches);
|
|
|
460 |
if(empty($matches[1])){
|
|
|
461 |
preg_match("/<META.*?name='description'.*?content='(.*?)'/si", $ret['page'], $matches);
|
|
|
462 |
}
|
|
|
463 |
if(empty($matches[1])){
|
|
|
464 |
preg_match('/<META content="(.*?)" name="description"/si', $ret['page'], $matches);
|
|
|
465 |
}
|
|
|
466 |
if(!empty($matches[1])){
|
|
|
467 |
if ($returVal) {
|
|
|
468 |
$metaInfo['page_description'] = $matches[1];
|
|
|
469 |
} else {
|
|
|
470 |
WebsiteController::addInputValue($matches[1], 'webdescription');
|
|
|
471 |
}
|
|
|
472 |
}
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
# meta keywords
|
|
|
476 |
preg_match('/<META.*?name="keywords".*?content="(.*?)"/si', $ret['page'], $matches);
|
|
|
477 |
if(empty($matches[1])){
|
|
|
478 |
preg_match("/<META.*?name='keywords'.*?content='(.*?)'/si", $ret['page'], $matches);
|
|
|
479 |
}
|
|
|
480 |
if(empty($matches[1])){
|
|
|
481 |
preg_match('/<META content="(.*?)" name="keywords"/si', $ret['page'], $matches);
|
|
|
482 |
}
|
|
|
483 |
|
|
|
484 |
if(!empty($matches[1])){
|
|
|
485 |
if ($returVal) {
|
|
|
486 |
$metaInfo['page_keywords'] = $matches[1];
|
|
|
487 |
} else {
|
|
|
488 |
WebsiteController::addInputValue($matches[1], 'webkeywords');
|
|
|
489 |
}
|
|
|
490 |
}
|
|
|
491 |
}
|
|
|
492 |
return $metaInfo;
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
public static function addInputValue($value, $col) {
|
|
|
496 |
|
|
|
497 |
$value = removeNewLines($value);
|
|
|
498 |
?>
|
|
|
499 |
<script type="text/javascript">
|
|
|
500 |
document.getElementById('<?php echo $col;?>').value = '<?php echo str_replace("'", "\'", $value);?>';
|
|
|
501 |
</script>
|
|
|
502 |
<?php
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
function showImportWebsites() {
|
|
|
506 |
|
|
|
507 |
$userId = isLoggedIn();
|
|
|
508 |
|
|
|
509 |
# get all users
|
|
|
510 |
if(isAdmin()){
|
|
|
511 |
$userCtrler = New UserController();
|
|
|
512 |
$userList = $userCtrler->__getAllUsers();
|
|
|
513 |
$this->set('userList', $userList);
|
|
|
514 |
$this->set('userSelected', empty($info['userid']) ? $userId : $info['userid']);
|
|
|
515 |
$this->set('isAdmin', 1);
|
|
|
516 |
}
|
|
|
517 |
|
|
|
518 |
// Check the user website count for validation
|
|
|
519 |
if (!isAdmin()) {
|
|
|
520 |
$this->setValidationMessageForLimit($userId);
|
|
|
521 |
}
|
|
|
522 |
|
|
|
523 |
$this->set('delimiter', ',');
|
|
|
524 |
$this->set('enclosure', '"');
|
|
|
525 |
$this->set('escape', '\\');
|
|
|
526 |
$this->render('website/importwebsites');
|
|
|
527 |
}
|
|
|
528 |
|
|
|
529 |
# function to set validation message for the limit
|
|
|
530 |
function setValidationMessageForLimit($userId) {
|
|
|
531 |
|
|
|
532 |
// Check the user website count for validation
|
|
|
533 |
$userTypeCtrlr = new UserTypeController();
|
|
|
534 |
$userWebsiteCount = $this->__getCountAllWebsites($userId, false);
|
|
|
535 |
$userTypeDetails = $userTypeCtrlr->getUserTypeSpecByUser($userId);
|
|
|
536 |
$validCount = $userTypeDetails['websitecount'] - $userWebsiteCount;
|
|
|
537 |
$validCount = $validCount > 0 ? $validCount : 0;
|
|
|
538 |
$validationMsg = str_replace("[websitecount]", "<b>$validCount</b>", $this->spTextWeb['You can add only websitecount websites more']);
|
|
|
539 |
$this->set('validationMsg', $validationMsg);
|
|
|
540 |
return $validationMsg;
|
|
|
541 |
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
function importWebsiteFromCsv($info) {
|
|
|
545 |
|
|
|
546 |
// if csv file is not uploaded
|
|
|
547 |
if (empty($_FILES['website_csv_file']['name'])) {
|
|
|
548 |
print "<script>alert('".$this->spTextWeb['Please enter CSV file']."')</script>";
|
|
|
549 |
return False;
|
|
|
550 |
}
|
|
|
551 |
|
|
|
552 |
$userId = isAdmin() ? intval($info['userid']) : isLoggedIn();
|
|
|
553 |
|
|
|
554 |
$resultInfo = array(
|
|
|
555 |
'total' => 0,
|
|
|
556 |
'valid' => 0,
|
|
|
557 |
'invalid' => 0,
|
|
|
558 |
);
|
|
|
559 |
$count = 0;
|
|
|
560 |
|
|
|
561 |
// process file upload option
|
|
|
562 |
$fileInfo = $_FILES['website_csv_file'];
|
|
|
563 |
if (!empty($fileInfo['name']) && !empty($userId)) {
|
|
|
564 |
if ($fileInfo["type"] == "text/csv" || $fileInfo["type"] == "application/vnd.ms-excel") {
|
|
|
565 |
$targetFile = SP_TMPPATH . "/".$fileInfo['name'];
|
|
|
566 |
if(move_uploaded_file($fileInfo['tmp_name'], $targetFile)) {
|
|
|
567 |
|
|
|
568 |
$delimiterChar = empty($info['delimiter']) ? ',' : $info['delimiter'];
|
|
|
569 |
$enclosureChar = empty($info['enclosure']) ? '"' : $info['enclosure'];
|
|
|
570 |
$escapeChar = empty($info['escape']) ? '\\' : $info['escape'];
|
|
|
571 |
|
|
|
572 |
// open file read through csv file
|
|
|
573 |
if (($handle = fopen($targetFile, "r")) !== FALSE) {
|
|
|
574 |
|
|
|
575 |
// loop through the data row
|
|
|
576 |
while (($websiteInfo = fgetcsv($handle, 4096, $delimiterChar, $enclosureChar, $escapeChar)) !== FALSE) {
|
|
|
577 |
if (empty($websiteInfo[0])) continue;
|
|
|
578 |
$count++;
|
|
|
579 |
}
|
|
|
580 |
|
|
|
581 |
fclose($handle);
|
|
|
582 |
}
|
|
|
583 |
|
|
|
584 |
// Check the user website count for validation
|
|
|
585 |
if (!$this->validateWebsiteCount($userId, $count)) {
|
|
|
586 |
$validationMag = strip_tags($this->setValidationMessageForLimit($userId));
|
|
|
587 |
print "<script>alert('$validationMag')</script>";
|
|
|
588 |
return False;
|
|
|
589 |
}
|
|
|
590 |
|
|
|
591 |
// open file read through csv file
|
|
|
592 |
if (($handle = fopen($targetFile, "r")) !== FALSE) {
|
|
|
593 |
|
|
|
594 |
// loop through the data row
|
|
|
595 |
while (($websiteInfo = fgetcsv($handle, 4096, $delimiterChar, $enclosureChar, $escapeChar)) !== FALSE) {
|
|
|
596 |
if (empty($websiteInfo[0])) continue;
|
|
|
597 |
$status = $this->importWebsite($websiteInfo, $userId);
|
|
|
598 |
$resultInfo[$status] += 1;
|
|
|
599 |
$resultInfo['total'] += 1;
|
|
|
600 |
}
|
|
|
601 |
|
|
|
602 |
fclose($handle);
|
|
|
603 |
}
|
|
|
604 |
}
|
|
|
605 |
}
|
|
|
606 |
}
|
|
|
607 |
|
|
|
608 |
|
|
|
609 |
$text = "<p class=\'note\' id=\'note\'><b>Website import process started. It will take some time depends on the number of websites needs to be imported!</b></p><div id=\'subcontmed\'></div>";
|
|
|
610 |
print "<script type='text/javascript'>parent.document.getElementById('import_website_div').innerHTML = '$text';</script>";
|
|
|
611 |
print "<script>parent.showLoadingIcon('subcontmed', 0)</script>";
|
|
|
612 |
$spText = $_SESSION['text'];
|
|
|
613 |
$resText = '<table width="40%" border="0" cellspacing="0" cellpadding="0px" class="summary_tab" align="center">'.
|
|
|
614 |
'<tr><td class="topheader" colspan="10">Import Summary</td></tr>'.
|
|
|
615 |
'<tr><th class="leftcell">'.$spText['common']['Total'].':</th><td>'.$resultInfo['total'].'</td><th>Valid:</th><td>'.$resultInfo['valid'].'</td></tr>'.
|
|
|
616 |
'<tr><th>Invalid:</th><td>'.$resultInfo['invalid'].'</td><th> </th><td> </td></tr>'.
|
|
|
617 |
'</table>';
|
|
|
618 |
echo "<script type='text/javascript'>parent.document.getElementById('subcontmed').innerHTML = '$resText'</script>";
|
|
|
619 |
echo "<script type='text/javascript'>parent.document.getElementById('note').style.display='none';</script>";
|
|
|
620 |
}
|
|
|
621 |
|
|
|
622 |
function importWebsite($wInfo, $userId) {
|
|
|
623 |
$status = 'invalid';
|
|
|
624 |
|
|
|
625 |
if (!empty($wInfo[0]) && !empty($wInfo[1])) {
|
|
|
626 |
$listInfo = [];
|
|
|
627 |
$listInfo['name'] = trim($wInfo[0]);
|
|
|
628 |
$listInfo['url'] = trim($wInfo[1]);
|
|
|
629 |
$listInfo['title'] = $wInfo[2] ? trim($wInfo[2]) : "";
|
|
|
630 |
$listInfo['description'] = $wInfo[3] ? trim($wInfo[3]) : "";
|
|
|
631 |
$listInfo['keywords'] = $wInfo[4] ? trim($wInfo[4]) : "";
|
|
|
632 |
$listInfo['status'] = intval($wInfo[5]);
|
|
|
633 |
$listInfo['analytics_view_id'] = $wInfo[6] ? trim($wInfo[6]) : "";
|
|
|
634 |
$listInfo['userid'] = $userId;
|
|
|
635 |
$return = $this->createWebsite($listInfo, true);
|
|
|
636 |
|
|
|
637 |
if ($return[0] == 'success') {
|
|
|
638 |
$status = "valid";
|
|
|
639 |
}
|
|
|
640 |
}
|
|
|
641 |
|
|
|
642 |
return $status;
|
|
|
643 |
}
|
|
|
644 |
|
|
|
645 |
// Function to check / validate the user type website count
|
|
|
646 |
function validateWebsiteCount($userId, $newCount = 1) {
|
|
|
647 |
$userCtrler = new UserController();
|
|
|
648 |
|
|
|
649 |
// if admin user id return true
|
|
|
650 |
if ($userCtrler->isAdminUserId($userId)) {
|
|
|
651 |
return true;
|
|
|
652 |
}
|
|
|
653 |
|
|
|
654 |
$userTypeCtrlr = new UserTypeController();
|
|
|
655 |
$userWebsiteCount = $this->__getCountAllWebsites($userId, false);
|
|
|
656 |
$userWebsiteCount += $newCount;
|
|
|
657 |
$userTypeDetails = $userTypeCtrlr->getUserTypeSpecByUser($userId);
|
|
|
658 |
|
|
|
659 |
// if limit is set and not -1
|
|
|
660 |
if (isset($userTypeDetails['websitecount']) && $userTypeDetails['websitecount'] >= 0) {
|
|
|
661 |
|
|
|
662 |
// check whether count greater than limit
|
|
|
663 |
if ($userWebsiteCount <= $userTypeDetails['websitecount']) {
|
|
|
664 |
return true;
|
|
|
665 |
} else {
|
|
|
666 |
return false;
|
|
|
667 |
}
|
|
|
668 |
|
|
|
669 |
} else {
|
|
|
670 |
return true;
|
|
|
671 |
}
|
|
|
672 |
|
|
|
673 |
}
|
|
|
674 |
|
|
|
675 |
function showimportWebmasterToolsWebsites() {
|
|
|
676 |
|
|
|
677 |
$userId = isLoggedIn();
|
|
|
678 |
$this->set('spTextTools', $this->getLanguageTexts('seotools', $_SESSION['lang_code']));
|
|
|
679 |
$userCtrler = New UserController();
|
|
|
680 |
|
|
|
681 |
// get all users
|
|
|
682 |
if(isAdmin()){
|
|
|
683 |
$userList = $userCtrler->__getAllUsers();
|
|
|
684 |
$this->set('userList', $userList);
|
|
|
685 |
$this->set('userSelected', empty($info['userid']) ? $userId : $info['userid']);
|
|
|
686 |
$this->set('isAdmin', 1);
|
|
|
687 |
} else {
|
|
|
688 |
$userInfo = $userCtrler->__getUserInfo($userId);
|
|
|
689 |
$this->set('userName', $userInfo['username']);
|
|
|
690 |
}
|
|
|
691 |
|
|
|
692 |
// Check the user website count for validation
|
|
|
693 |
if (!isAdmin()) {
|
|
|
694 |
$this->setValidationMessageForLimit($userId);
|
|
|
695 |
}
|
|
|
696 |
|
|
|
697 |
$this->render('website/import_webmaster_tools_websites');
|
|
|
698 |
}
|
|
|
699 |
|
|
|
700 |
function importWebmasterToolsWebsites($info) {
|
|
|
701 |
$userId = isAdmin() ? intval($info['userid']) : isLoggedIn();
|
|
|
702 |
$limitReached = false;
|
|
|
703 |
$importList = array();
|
|
|
704 |
|
|
|
705 |
// verify the limit for the user
|
|
|
706 |
if (!$this->validateWebsiteCount($userId)) {
|
|
|
707 |
showErrorMsg($this->spTextWeb["Your website count already reached the limit"]);
|
|
|
708 |
}
|
|
|
709 |
|
|
|
710 |
$gapiCtrler = new WebMasterController();
|
|
|
711 |
$result = $gapiCtrler->getAllSites($userId);
|
|
|
712 |
|
|
|
713 |
// check whether error occured while api call
|
|
|
714 |
if (!$result['status']) {
|
|
|
715 |
showErrorMsg($result['msg']);
|
|
|
716 |
}
|
|
|
717 |
|
|
|
718 |
// loop through website list
|
|
|
719 |
foreach ($result['resultList'] as $websiteInfo) {
|
|
|
720 |
|
|
|
721 |
if ($websiteInfo->permissionLevel != 'siteOwner') continue;
|
|
|
722 |
|
|
|
723 |
// chekc whether website existing or not
|
|
|
724 |
if (!$this->__checkWebsiteUrl($websiteInfo->siteUrl) && !$this->__checkWebsiteUrl(Spider::removeTrailingSlash($websiteInfo->siteUrl))) {
|
|
|
725 |
$websiteName = formatUrl($websiteInfo->siteUrl, false);
|
|
|
726 |
$websiteName = Spider::removeTrailingSlash($websiteName);
|
|
|
727 |
$listInfo['name'] = $websiteName;
|
|
|
728 |
$listInfo['url'] = $websiteInfo->siteUrl;
|
|
|
729 |
$listInfo['title'] = $websiteName;
|
|
|
730 |
$listInfo['description'] = $websiteName;
|
|
|
731 |
$listInfo['keywords'] = $websiteName;
|
|
|
732 |
$listInfo['status'] = 1;
|
|
|
733 |
$listInfo['userid'] = $userId;
|
|
|
734 |
$return = $this->createWebsite($listInfo, true);
|
|
|
735 |
|
|
|
736 |
// if success, check of number of websites can be added
|
|
|
737 |
if ($return[0] == 'success') {
|
|
|
738 |
$importList[] = $websiteInfo->siteUrl;
|
|
|
739 |
|
|
|
740 |
// if reached website add limit
|
|
|
741 |
if (!$this->validateWebsiteCount($userId)) {
|
|
|
742 |
$limitReached = true;
|
|
|
743 |
break;
|
|
|
744 |
}
|
|
|
745 |
|
|
|
746 |
}
|
|
|
747 |
|
|
|
748 |
}
|
|
|
749 |
|
|
|
750 |
}
|
|
|
751 |
|
|
|
752 |
// show results
|
|
|
753 |
showSuccessMsg("<b>".$this->spTextWeb["Successfully imported following websites"]."</b>:", false);
|
|
|
754 |
foreach ($importList as $url) showSuccessMsg($url, false);
|
|
|
755 |
|
|
|
756 |
// if website add limit reached
|
|
|
757 |
if ($limitReached) {
|
|
|
758 |
showErrorMsg($this->spTextWeb["Your website count already reached the limit"]);
|
|
|
759 |
}
|
|
|
760 |
|
|
|
761 |
}
|
|
|
762 |
|
|
|
763 |
function addToWebmasterTools($websiteId) {
|
|
|
764 |
$webisteInfo = $this->__getWebsiteInfo($websiteId);
|
|
|
765 |
$gapiCtrler = new WebMasterController();
|
|
|
766 |
$result = $gapiCtrler->addWebsite($webisteInfo['url'], $webisteInfo['user_id']);
|
|
|
767 |
|
|
|
768 |
// chekc whether error occured while api call
|
|
|
769 |
if ($result['status']) {
|
|
|
770 |
$activateUrl = "https://www.google.com/webmasters/verification/verification?tid=alternate&siteUrl=" . $webisteInfo['url'];
|
|
|
771 |
$successMsg = $this->spTextWeb["Website successfully added to webmaster tools"] . ": " . $webisteInfo['url'] . "<br><br>";
|
|
|
772 |
$successMsg .= "<a href='$activateUrl' target='_blank'>Click Here</a> to activate the website in webmaster tools.";
|
|
|
773 |
showSuccessMsg($successMsg, false);
|
|
|
774 |
} else {
|
|
|
775 |
showErrorMsg($result['msg'], false);
|
|
|
776 |
}
|
|
|
777 |
|
|
|
778 |
}
|
|
|
779 |
|
|
|
780 |
// func to list sitemaps
|
|
|
781 |
function listSitemap($info, $summaryPage = false, $cronUserId=false) {
|
|
|
782 |
$userId = !empty($cronUserId) ? $cronUserId : isLoggedIn();
|
|
|
783 |
$this->set('spTextTools', $this->getLanguageTexts('seotools', $_SESSION['lang_code']));
|
|
|
784 |
$this->set('spTextSitemap', $this->getLanguageTexts('sitemap', $_SESSION['lang_code']));
|
|
|
785 |
$this->set('spTextHome', $this->getLanguageTexts('home', $_SESSION['lang_code']));
|
|
|
786 |
$this->set('spTextDirectory', $this->getLanguageTexts('directory', $_SESSION['lang_code']));
|
|
|
787 |
|
|
|
788 |
$websiteList = $this->__getAllWebsites($userId, true);
|
|
|
789 |
$this->set('websiteList', $websiteList);
|
|
|
790 |
$websiteId = isset($info['website_id']) ? intval($info['website_id']) : $websiteList[0]['id'];
|
|
|
791 |
$this->set('websiteId', $websiteId);
|
|
|
792 |
|
|
|
793 |
$whereCond = "status=1";
|
|
|
794 |
|
| 155 |
- |
795 |
// check for wbsite id
|
|
|
796 |
if (empty($websiteId)) {
|
|
|
797 |
$wIdList = [0];
|
| 103 |
- |
798 |
foreach ($websiteList as $websiteInfo) $wIdList[] = $websiteInfo['id'];
|
|
|
799 |
$whereCond .= " and website_id in (".implode(',', $wIdList).")";
|
|
|
800 |
} else {
|
| 155 |
- |
801 |
$whereCond .= " and website_id=$websiteId";
|
| 103 |
- |
802 |
}
|
|
|
803 |
|
|
|
804 |
$sitemapList = $this->dbHelper->getAllRows("webmaster_sitemaps", $whereCond);
|
|
|
805 |
|
|
|
806 |
$this->set('list', $sitemapList);
|
|
|
807 |
$this->set('summaryPage', $summaryPage);
|
|
|
808 |
|
|
|
809 |
// if pdf export
|
|
|
810 |
if ($summaryPage) {
|
|
|
811 |
return $this->getViewContent('sitemap/list_webmaster_sitemap_list');
|
|
|
812 |
} else {
|
|
|
813 |
$this->render('sitemap/list_webmaster_sitemap_list');
|
|
|
814 |
}
|
|
|
815 |
|
|
|
816 |
}
|
|
|
817 |
|
|
|
818 |
// func to import webmaster tools sitemaps
|
|
|
819 |
function importWebmasterToolsSitemaps($websiteId, $cronJob = false) {
|
|
|
820 |
$websiteId = intval($websiteId);
|
|
|
821 |
$webisteInfo = $this->__getWebsiteInfo($websiteId);
|
|
|
822 |
|
|
|
823 |
// call webmaster api
|
|
|
824 |
$gapiCtrler = new WebMasterController();
|
|
|
825 |
$result = $gapiCtrler->getAllSitemap($webisteInfo['url'], $webisteInfo['user_id']);
|
|
|
826 |
|
|
|
827 |
// check whether error occured while api call
|
|
|
828 |
if ($result['status']) {
|
|
|
829 |
|
|
|
830 |
// change status of all sitemaps
|
|
|
831 |
$dataList = array('status' => 0);
|
|
|
832 |
$this->dbHelper->updateRow("webmaster_sitemaps", $dataList, " website_id=$websiteId");
|
|
|
833 |
|
|
|
834 |
// loop through webmaster tools list
|
|
|
835 |
foreach ($result['resultList'] as $sitemapInfo) {
|
|
|
836 |
|
|
|
837 |
$dataList = array(
|
|
|
838 |
'last_submitted' => date('Y-m-d H:i:s', strtotime($sitemapInfo->lastSubmitted)),
|
|
|
839 |
'last_downloaded' => date('Y-m-d H:i:s', strtotime($sitemapInfo->lastDownloaded)),
|
|
|
840 |
'is_pending|int' => $sitemapInfo->isPending,
|
|
|
841 |
'warnings|int' => $sitemapInfo->warnings,
|
|
|
842 |
'errors|int' => $sitemapInfo->errors,
|
|
|
843 |
'submitted|int' => $sitemapInfo->contents[0]['submitted'],
|
|
|
844 |
'indexed|int' => $sitemapInfo->contents[0]['indexed'],
|
|
|
845 |
'status' => 1,
|
|
|
846 |
);
|
|
|
847 |
|
|
|
848 |
$rowInfo = $this->dbHelper->getRow("webmaster_sitemaps", " website_id=$websiteId and path='$sitemapInfo->path'");
|
|
|
849 |
if (!empty($rowInfo['id'])) {
|
|
|
850 |
$this->dbHelper->updateRow("webmaster_sitemaps", $dataList, " id=" . $rowInfo['id']);
|
|
|
851 |
} else {
|
|
|
852 |
$dataList['website_id|int'] = $websiteId;
|
|
|
853 |
$dataList['path'] = $sitemapInfo->path;
|
|
|
854 |
$this->dbHelper->insertRow("webmaster_sitemaps", $dataList);
|
|
|
855 |
}
|
|
|
856 |
|
|
|
857 |
}
|
|
|
858 |
|
|
|
859 |
if ($cronJob) {
|
|
|
860 |
echo $this->spTextWeb["Successfully sync sitemaps from webmaster tools"] . "<br>\n";
|
|
|
861 |
} else {
|
|
|
862 |
showSuccessMsg($this->spTextWeb["Successfully sync sitemaps from webmaster tools"], false);
|
|
|
863 |
}
|
|
|
864 |
|
|
|
865 |
} else {
|
|
|
866 |
showErrorMsg($result['msg'], false);
|
|
|
867 |
}
|
|
|
868 |
|
|
|
869 |
}
|
|
|
870 |
|
|
|
871 |
// func to show submit sitemap form
|
|
|
872 |
function showSubmitSitemap($info) {
|
|
|
873 |
$userId = isLoggedIn();
|
|
|
874 |
$this->set('websiteList', $this->__getAllWebsites($userId, true));
|
|
|
875 |
$this->set('websiteId', intval($info['website_id']));
|
|
|
876 |
$this->set('spTextTools', $this->getLanguageTexts('seotools', $_SESSION['lang_code']));
|
|
|
877 |
$this->render('sitemap/submit_sitemap');
|
|
|
878 |
}
|
|
|
879 |
|
|
|
880 |
// func to submit sitemap
|
|
|
881 |
function submitSitemap($info) {
|
|
|
882 |
$webisteInfo = $this->__getWebsiteInfo($info['website_id']);
|
|
|
883 |
$spTextWebproxy = $this->getLanguageTexts('QuickWebProxy', $_SESSION['lang_code']);
|
|
|
884 |
|
|
|
885 |
if (empty($info['sitemap_url'])) {
|
|
|
886 |
showErrorMsg($spTextWebproxy["Please enter a valid url"]);
|
|
|
887 |
}
|
|
|
888 |
|
|
|
889 |
$info['sitemap_url'] = addHttpToUrl($info['sitemap_url']);
|
|
|
890 |
|
|
|
891 |
// if website url not correct
|
|
|
892 |
if (!preg_match("/". preg_quote($webisteInfo['url'], '/') ."/i", $info['sitemap_url'])) {
|
|
|
893 |
showErrorMsg($spTextWebproxy["Please enter a valid url"]);
|
|
|
894 |
}
|
|
|
895 |
|
|
|
896 |
// call webmaster api
|
|
|
897 |
$gapiCtrler = new WebMasterController();
|
|
|
898 |
$result = $gapiCtrler->submitSitemap($webisteInfo['url'], $info['sitemap_url'], $webisteInfo['user_id']);
|
|
|
899 |
|
|
|
900 |
// check whether error occured while api call
|
|
|
901 |
if ($result['status']) {
|
|
|
902 |
showSuccessMsg($this->spTextWeb["Sitemap successfully added to webmaster tools"] . ": " . $info['sitemap_url'], false);
|
|
|
903 |
|
|
|
904 |
// update seo panel webmaster tool sitemaps
|
|
|
905 |
$this->importWebmasterToolsSitemaps($webisteInfo['id']);
|
|
|
906 |
|
|
|
907 |
} else {
|
|
|
908 |
showErrorMsg($result['msg'], false);
|
|
|
909 |
}
|
|
|
910 |
|
|
|
911 |
}
|
|
|
912 |
|
|
|
913 |
function deleteWebmasterToolSitemap($sitemapId) {
|
|
|
914 |
$sitemapId = intval($sitemapId);
|
|
|
915 |
$sitemapInfo = $this->dbHelper->getRow("webmaster_sitemaps", "id=$sitemapId");
|
|
|
916 |
|
|
|
917 |
if (empty($sitemapInfo['id'])) {
|
|
|
918 |
showErrorMsg("Please provide a valid sitemap id");
|
|
|
919 |
}
|
|
|
920 |
|
|
|
921 |
$webisteInfo = $this->__getWebsiteInfo($sitemapInfo['website_id']);
|
|
|
922 |
$gapiCtrler = new WebMasterController();
|
|
|
923 |
$result = $gapiCtrler->deleteWebsiteSitemap($webisteInfo['url'], $sitemapInfo['path'], $webisteInfo['user_id']);
|
|
|
924 |
|
|
|
925 |
// check whether error occured while api call
|
|
|
926 |
if ($result['status']) {
|
|
|
927 |
$this->dbHelper->updateRow("webmaster_sitemaps", array('status' => 0), "id=$sitemapId");
|
|
|
928 |
showSuccessMsg($this->spTextWeb["Successfully deleted sitemap from webmaster tools"], false);
|
|
|
929 |
} else {
|
|
|
930 |
showErrorMsg($result['msg'], false);
|
|
|
931 |
}
|
|
|
932 |
|
|
|
933 |
$this->listSitemap(array('website_id' => $sitemapInfo['website_id']));
|
|
|
934 |
|
|
|
935 |
}
|
|
|
936 |
|
|
|
937 |
|
|
|
938 |
}
|
|
|
939 |
?>
|