| 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 |
/**
|
|
|
24 |
* class defines all information controller functions
|
|
|
25 |
* @author Seo Panel
|
|
|
26 |
*
|
|
|
27 |
*/
|
|
|
28 |
class InformationController extends Controller {
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* function to show news boxes
|
|
|
32 |
*/
|
|
|
33 |
function showNews($secInfo='') {
|
|
|
34 |
|
|
|
35 |
// switch trhough sections
|
|
|
36 |
switch($secInfo['sec_name']){
|
|
|
37 |
|
|
|
38 |
default:
|
|
|
39 |
|
|
|
40 |
// get today's information
|
|
|
41 |
$ret = $this->__getTodayInformation();
|
|
|
42 |
|
|
|
43 |
// if empty fetch directly from website
|
|
|
44 |
if (!isset($ret['page'])) {
|
|
|
45 |
|
|
|
46 |
// get content directly from website
|
|
|
47 |
$ret = $this->spider->getContent(SP_NEWS_PAGE . "?lang=". $_SESSION['lang_code'], true, false);
|
|
|
48 |
|
|
|
49 |
// update in db
|
|
|
50 |
$this->updateTodayInformation($ret['page']);
|
|
|
51 |
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
// check whether it contains required data
|
|
|
55 |
if (!empty($ret['page']) && stristr($ret['page'], "id='news_info'")) {
|
|
|
56 |
$this->set('newsContent', stripslashes($ret['page']));
|
|
|
57 |
$this->render('common/topnewsbox', 'ajax');
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
/**
|
|
|
65 |
* function to get sponsors
|
|
|
66 |
*/
|
|
|
67 |
function getSponsors() {
|
|
|
68 |
|
|
|
69 |
// get today's information
|
|
|
70 |
$ret = $this->__getTodayInformation('sponsors');
|
|
|
71 |
|
|
|
72 |
// if empty fetch directly from website
|
|
|
73 |
if (!isset($ret['page'])) {
|
|
|
74 |
|
|
|
75 |
// get content directly from website
|
|
|
76 |
$ret = $this->spider->getContent(SP_SPONSOR_PAGE . "?lang=". $_SESSION['lang_code'], true, false);
|
|
|
77 |
|
|
|
78 |
// update in db
|
|
|
79 |
$this->updateTodayInformation($ret['page'], 'sponsors');
|
|
|
80 |
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
// check whether it contains required data
|
|
|
84 |
if (!empty($ret['page']) && stristr($ret['page'], 'class="contentmid"')) {
|
|
|
85 |
return $ret['page'];
|
|
|
86 |
} else {
|
|
|
87 |
return false;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* function to update news in database
|
|
|
94 |
*/
|
|
|
95 |
function updateTodayInformation($content, $secName = 'news') {
|
|
|
96 |
|
|
|
97 |
$todayDate = date('Y-m-d');
|
|
|
98 |
$sql = "delete from information_list where info_type='" . addslashes($secName) . "'";
|
|
|
99 |
$this->db->query($sql);
|
|
|
100 |
|
|
|
101 |
$sql = "insert into information_list(info_type, content, update_date)
|
|
|
102 |
values('" . addslashes($secName) . "', '" . addslashes($content) . "', '{$todayDate}')";
|
|
|
103 |
$this->db->query($sql);
|
|
|
104 |
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* function to get todays information
|
|
|
109 |
*/
|
|
|
110 |
function __getTodayInformation($secName = 'news') {
|
|
|
111 |
$sql = "select info_type, content as page from information_list where info_type='" . addslashes($secName) . "'
|
|
|
112 |
and update_date='" . date('Y-m-d') . "'";
|
|
|
113 |
$info = $this->db->select($sql, true);
|
|
|
114 |
return $info;
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
}
|
|
|
118 |
?>
|