Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 seo tools controller functions
24
class SeoToolsController extends Controller{
25
	var $layout = 'ajax';
26
 
27
	# index function
28
	function index($info=''){
29
		$this->layout = "default";
30
		if(isAdmin()){
31
			$sql = "select * from seotools where status=1";
32
		}else{
33
			$sql = "select * from seotools where status=1 and user_access=1";
34
		}
35
		$sql .= " order by priority, id";
36
 
37
		$menuList = array();
38
		$toolList = $this->db->select($sql);
39
		$userTypeCtrler = new UserTypeController();
40
 
41
		// if not admin, check tool access set for user,
42
		if (!isAdmin()) {
43
			$userSessInfo = Session::readSession('userInfo');
44
			$toolAccessList = $userTypeCtrler->getSeoToolAccessSettings($userSessInfo['userTypeId']);
45
 
46
			// loop through plugin list
47
			foreach ($toolList as $toolInfo) {
48
 
49
				// if access is set for plugin
50
				if (isset($toolAccessList[$toolInfo['id']]['value'])) {
51
 
52
					// access is on
53
					if (!empty($toolAccessList[$toolInfo['id']]['value'])) {
54
						$menuList[] = $toolInfo;
55
					}
56
 
57
				} else {
58
					$menuList[] = $toolInfo;
59
				}
60
 
61
			}
62
 
63
		} else {
64
			$menuList = $toolList;
65
		}
66
 
67
		if(count($menuList) <= 0){
68
			$this->set('msg', $_SESSION['text']['common']['noactivetools']);
69
			$this->render('common/notfound');
70
			exit;
71
		}
72
 
73
		$this->set('menuList', $menuList);
74
		$defaultArgs = empty($info['default_args']) ? "" : urldecode($info['default_args']);
75
		switch($info['menu_sec']){
76
 
77
			case "sitemap-generator":
78
				$defaultScript = "sitemap.php";
79
				break;
80
 
81
		    case "site-auditor":
82
				$defaultScript = "siteauditor.php";
83
				break;
84
 
85
			case "rank-checker":
86
				$defaultScript = "rank.php";
87
				break;
88
 
89
			case "backlink-checker":
90
				$defaultScript = "backlinks.php";
91
				break;
92
 
93
			case "directory-submission":
94
				$defaultScript = "directories.php";
95
				break;
96
 
97
			case "saturation-checker":
98
				$defaultScript = "saturationchecker.php";
99
				break;
100
 
101
			case "pagespeed":
102
				$defaultScript = "pagespeed.php";
103
				break;
104
 
105
			case "webmaster-tools":
106
				$defaultScript = "webmaster-tools.php";
107
				break;
108
 
109
			case "sm-checker":
110
				$defaultScript = "social_media.php";
111
				break;
112
 
113
			case "review-manager":
114
				$defaultScript = "review.php";
115
				break;
116
 
117
			case "web-analytics":
118
			    $defaultScript = "analytics.php";
119
			    break;
120
 
121
			default:
122
				$seoToolInfo = $this->__getSeoToolInfo('keyword-position-checker', 'url_section');
123
				if($seoToolInfo['status'] == 1){
124
					$info['menu_sec'] = 'keyword-position-checker';
125
					$defaultScript = "reports.php";
126
					$defaultArgs = empty($defaultArgs) ? "sec=reportsum" : $defaultArgs;
127
				}
128
		}
129
 
130
		$this->set('menuSelected', $info['menu_sec']);
131
		$this->set('defaultScript', $defaultScript);
132
		$this->set('defaultArgs', $defaultArgs);
133
		$this->render('seotools/index');
134
	}
135
 
136
	# func to get all seo tools
137
	function __getAllSeoTools($whereCond = "1=1"){
138
		$sql = "select * from seotools where $whereCond order by id";
139
		$seoToolList = $this->db->select($sql);
140
		return $seoToolList;
141
	}
142
 
143
	# func to get seo tool info
144
	function __getSeoToolInfo($val, $col='id'){
145
		$sql = "select * from seotools where $col='$val'";
146
		$seoToolInfo = $this->db->select($sql, true);
147
		return $seoToolInfo;
148
	}
149
 
150
	# func to list seo tools
151
	function listSeoTools() {
152
		$seoToolList = $this->__getAllSeoTools();
153
		$this->set('list', $seoToolList);
154
		$this->render('seotools/listseotools');
155
	}
156
 
157
	#function to change status of seo tools
158
	function changeStatus($seoToolId, $status, $col='status'){
159
 
160
		$seoToolId = intval($seoToolId);
161
		$sql = "update seotools set $col=$status where id=$seoToolId";
162
		$this->db->query($sql);
163
	}
164
 
165
	# func to edit seo tool
166
	function editSeoTool($info, $error=false){
167
 
168
		if($error){
169
			$this->set('post', $info);
170
		}else{
171
			$info['pid'] = intval($info['pid']);
172
			$this->set('post', $this->__getSeoToolInfo($info['pid']));
173
		}
174
 
175
		$this->render('seotools/editseotool');
176
	}
177
 
178
	function updateSeoTool($listInfo){
179
 
180
		$listInfo['id'] = intval($listInfo['id']);
181
		$this->set('post', $listInfo);
182
		$errMsg['priority'] = formatErrorMsg($this->validate->checkNumber($listInfo['priority']));
183
		if(!$this->validate->flagErr){
184
			$sql = "update seotools set	priority='".intval($listInfo['priority'])."' where id={$listInfo['id']}";
185
			$this->db->query($sql);
186
			$this->listSeoTools();
187
		}else{
188
			$this->set('errMsg', $errMsg);
189
			$this->editSeoTool($listInfo, true);
190
		}
191
	}
192
 
193
}
194
?>