-
Notifications
You must be signed in to change notification settings - Fork 0
/
news.php
107 lines (91 loc) · 4.59 KB
/
news.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* @version news.php 2009-07-16 $
* @copyright Copyright (C) ircs.net. All rights reserved.
*
* @author Amol Divalkar
* @Modified By
* @version 1.0
* @desc This is main file (new) which is used to render show all the news on one page.
*/
//Includes config file
include("includes/config.inc.php");
//Includes global class file
include(DIR_CLASSES."/clsGlobal.php");
//Checks if session is set for admin login or not
if($_SESSION["UID"] == "" && $_SESSION["UNAME"] == ""){
$strRedirect = SITE_NAME."login.htm";
header("Location:$strRedirect");
}
//Creates object for global class file
$hldGlobal = new clsGlobal($hdlDb);
$intUCheck = $hldGlobal->fnUserCheckTemp($_SESSION["UID"]);
if($intUCheck){
$hldGlobal->fnInActiveUser($_SESSION["UID"]);
$strLogOut = SITE_NAME."log/1/login.htm";
header("Location:$strLogOut");
}
//Creates the object for sigma template.
$hdlTpl =& new HTML_Template_Sigma( DIR_TEMPLATE , DIR_TEMPLATE."/prepared");
//Loads index template file
$hdlTpl->loadTemplateFile("news.htm",TRUE,TRUE);
$hldGlobal->fnTrackUser("News",$_SESSION["MaInId"]);
$strHeader = $hldGlobal->fnGetHeader();//Fetches header template
$strMetatag = $hldGlobal->fnMetaTag();//Fetches Metatag template
$strFooter = $hldGlobal->fnGetFooter();//Fetches footer template
$strLmenu = $hldGlobal->fnMenu("",$arrMpage);//Fetches left menu
$hdlTpl->setVariable("metatag",$strMetatag);//Assigns Metatag
$hdlTpl->setVariable("header",$strHeader);//Assigns header
$hdlTpl->setVariable("footer",$strFooter);//Assigns footer
$hdlTpl->setVariable("menu",$strLmenu);//Assigns left menu
$arrRecordSet = $hldGlobal->fnFetchNewsLeft();
if(is_array($arrRecordSet) && count($arrRecordSet) > 0){
for($i=0;$i<count($arrRecordSet);$i++){
$hdlTpl->setVariable("site_name",SITE_NAME);
$hdlTpl->setVariable("left_link",$arrRecordSet[$i]["datecreate"]);//Assigns left link
$arrNewsResult = $hldGlobal->fnGetLeftMonth($arrRecordSet[$i]["datecreate"]);
if(is_array($arrNewsResult) && count($arrNewsResult)){
$strMonth = "";
for($j=0;$j<count($arrNewsResult);$j++){
$hdlTpl->setVariable("site_name",SITE_NAME);//Assigns left link
$hdlTpl->setVariable("intMonthId",$arrNewsResult[$j]["intMonthId"]);//Assigns left link
$hdlTpl->setVariable("intYear",$arrNewsResult[$j]["intYear"]);//Assigns left link
$hdlTpl->setVariable("mon",$arrNewsResult[$j]["mon"]);//Assigns left link
$hdlTpl->setVariable("totcnt",$arrNewsResult[$j]["totcnt"]);//Assigns left link
$hdlTpl->parse("MON_LINK");
}
}
$hdlTpl->parse("YEAR_LINK");
}
}
if($_GET["mon"] && $_GET["year"]){
$arrRecordSet = $hldGlobal->fnFetchNewsMonYear($_GET["mon"],$_GET["year"]);
} else {
$arrRecordSet = $hldGlobal->fnFetchNews(0,$_GET["char"]);
}
$arrNewsSet = $hldGlobal->fnGetData($arrRecordSet,$_GET["char"],REC_PER_PAGE);
if(is_array($arrNewsSet) && count($arrNewsSet) > 0){
for($i=0;$i<(count($arrNewsSet)-1);$i++){
$arrKeys = array_keys($arrNewsSet);
$strNews = stripslashes(substr( strip_tags($arrNewsSet[$arrKeys[$i]]["content"]),0,200))."...";
$strnewstitle = stripslashes($arrNewsSet[$i]["newstitle"]);
$strurl = ereg_replace(" ","_",$strnewstitle);
$hdlTpl->setVariable("date",$arrNewsSet[$arrKeys[$i]]["datecreated"]);//Assigns date
$hdlTpl->setVariable("title",$strnewstitle);//Assigns news title
$hdlTpl->setVariable("news_url",$strurl);//Assigns news title
$hdlTpl->setVariable("site_url",SITE_NAME);//Assigns news title
$hdlTpl->setVariable("news_desc",$strNews);//Assigns news description
$hdlTpl->setVariable("id",$arrNewsSet[$arrKeys[$i]]["id"]);//Assigns id
$hdlTpl->setVariable("paging",$arrNewsSet["paging"]);//Assigns news description
$hdlTpl->parse("NEWS");
}
} else {
$hdlTpl->setVariable("no_news","No news added");//Assigns no news
$hdlTpl->parse("NO_NEWS");
}
$hdlTpl->setVariable("site_name",SITE_NAME);//Assigns news title
$hdlTpl->setVariable("space"," ");
$hdlTpl->parse("INNER_PAGE");
$hdlTpl->parse("INDEX_PAGE");
echo $hdlTpl->get();
?>