-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
223 lines (191 loc) · 8.41 KB
/
Copy pathindex.php
File metadata and controls
223 lines (191 loc) · 8.41 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
header('Content-type: text/html; charset=utf-8');
setlocale(LC_ALL, 'ru_RU.UTF-8');
mb_internal_encoding('UTF-8');
ini_set('display_errors',1);
error_reporting(7);
date_default_timezone_set('Europe/Moscow');
//error_reporting(E_ALL);
//echo "Сайт временно не работает. Техническое обслуживание.";
//exit();
/*---------------время генерации страницы--------------------*/
// считываем текущее время
$start_time = microtime();
// разделяем секунды и миллисекунды (становятся значениями начальных ключей массива-списка)
$start_array = explode(" ",$start_time);
// это и есть стартовое время
$start_time = $start_array[1] + $start_array[0];
/*---------------время генерации страницы--------------------*/
require('./fmake/FController.php');
require('./fmake/libs/function_xajax.php');
require('./fmake/libs/login.php');
$modulObj = new fmakeAdminController();
$admin = $modulObj->getUserObj();
$admin->load();
if ($configs->site_on_off == '1' ){
switch ($request->action){
case 'feedback':
$fmakeFeedback = new fmakeFeedback();
$error = false;
if(!trim($request ->email) || !ereg("^([-a-zA-Z0-9._]+@[-a-zA-Z0-9.]+(\.[-a-zA-Z0-9]+)+)*$", $request ->email)) $error['email'] = "Некорректный Email";
if($fmakeFeedback->isEmail(trim($request ->email))) $error['duble'] = "Данный email уже записан";
if(!$error){
$fmakeFeedback->addParam("email",$request->email);
$fmakeFeedback->newItem();
$message = "Ты узнаешь первым!";
$globalTemplateParam->set('message',$message);
}else {
$globalTemplateParam->set('errors',$error);
}
break;
}
if(!$admin->isLogined()){
$modul->template = "zagluwka/main.tpl";
$template = $twig->loadTemplate($modul->template);
$template->display($globalTemplateParam->get());
exit();
}
}
/*---------курс валют----------*/
$cache = new cacheValue();
if (!$cache->isCache("usd_valuta")) {
$date = date("d/m/Y",time());
$xmlParser = new xmlParser();
$array = $xmlParser->fileXmlToArray("http://www.cbr.ru/scripts/XML_daily.asp?date_req={$date}");
if ($array['Valute'])foreach($array['Valute'] as $key=>$item) {
if ($item['CharCode'] == 'USD') {
$ar = explode(",",$item['Value']);
$usd_valuta = $cache->addCache("usd_valuta",$ar[0].".".substr($ar[1],0,2));
}
if ($item['CharCode'] == 'EUR') {
$ar = explode(",",$item['Value']);
$eur_valuta = $cache->addCache("eur_valuta",$ar[0].".".substr($ar[1],0,2));
}
}
} else {
$usd_valuta = $cache->getCacheValue("usd_valuta");
$eur_valuta = $cache->getCacheValue("eur_valuta");
}
if (!$cache->isCache("weather")) {
$xmlParser = new xmlParser();
$array_weather = $xmlParser->fileXmlToArray("http://informer.gismeteo.ru/xml/34175_1.xml");
$array_weather = $array_weather['REPORT']['TOWN']['FORECAST'][0]['TEMPERATURE']['@attributes'];
$max_weather = intval($array_weather['max']);
$min_weather = intval($array_weather['min']);
$temperature = round(($max_weather+$min_weather)/2);
if($temperature>0) $temperature = "+".$temperature;
$weather = $cache->addCache("weather",$temperature);
} else {
$weather = $cache->getCacheValue("weather");
}
$globalTemplateParam->set('usd_valuta',$usd_valuta);
$globalTemplateParam->set('eur_valuta',$eur_valuta);
$globalTemplateParam->set('weather',$weather);
/*---------курс валют----------*/
$fmakeBanerContent = new fmakeBanerContent();
$globalTemplateParam->set('baner_obj',$fmakeBanerContent);
$array_baner = $fmakeBanerContent->getBanersShow(true);
if ($array_baner) foreach ($array_baner as $key=>$item) {
$globalTemplateParam->set('baner'.$item['id_type'],$item);
}
$modul = new fmakeSiteModule();
$globalTemplateParam->set('site_obj',$modul);
$url = $request -> getEscape('url') ? $request -> getEscape('url') : $request -> getEscape('modul');
$url = explode('/', $url);
$url = $url[0];
//printAr($_REQUEST);
//echo $request -> getEscape('modul');
$modul->getPage($request -> getEscape('modul') , $twig, $url);
//добавляем каталог к основным модулям
$menu = $modul->getAllForMenuSite(0, true,$q=true,$flag=true,true);
#проставляем статус у левого меню новостей
$new_modul = new fmakeNews;
$new_modul->setRedir($request->modul);
$lenta_cat = $new_modul->getCatForMenu(2 ,true);
$all_new_modul = $new_modul->getInfo();
$parent_new_modul = $new_modul->getParents($all_new_modul['id']);
if($parent_new_modul)foreach ($parent_new_modul as $key => $value) {
if($lenta_cat)foreach ($lenta_cat as $key2 => $value2) {
if($lenta_cat[$key2]['id'] == $parent_new_modul[$key]['id']){
$lenta_cat[$key2]['status'] = 1;
}
}
}
#проставляем статус у левого меню новостей, конец
$globalTemplateParam->set('lenta_cat',$lenta_cat);
$request_uri = $_SERVER['REQUEST_URI'];
/*--------правый блок с последними новостями--------*/
$fmakeComments = new fmakeComments();
/*новости по теме*/
if ($modul->id == 2) {
$news_theme = new fmakeNews();
$news_theme->setRedir($request->modul);
$item_news_theme_cat = $news_theme->getInfo();
if ($item_news_theme_cat['id'] == $modul->id) {
$cat_theme = "";
} elseif ($item_news_theme_cat['file'] == 'item_news') {
$parent = $item_news_theme_cat['parent'];
$cat_theme = "a.parent in ({$parent}) AND ";
} else {
//$parents = $news_theme->getCats($item_news_theme_cat['id']);
$cat_theme = "";
}
} else {
$cat_theme = "";
}
/*новости по теме*/
$limit_news_right = 7;
$tmp_order = $modul->order;
$modul->order = "b.date DESC, a.id";
$news_right_block = $modul->getByPageAdmin(2, $limit_news_right,1," {$cat_theme} a.`file` = 'item_news'",true);
if ($news_right_block) foreach ($news_right_block as $key=>$item) {
$news_right_block[$key]['comment'] = $fmakeComments->getByPageCount($item[$modul->idField],true);
}
$modul->order = $tmp_order;
$globalTemplateParam->set('news_right_block',$news_right_block);
//if($_GET['debug']==1){
//$static = new fmakeCount();
//$short_news = $static->getShortNameNews(7);
//printAr($short_news);
//printAr($modul->id);
//echo($request->modul);
//}
/*--------правый блок с последними новостями--------*/
/*--------меню с самыми посещяемыми новостями--------*/
$static = new fmakeCount();
$short_news = $static->getShortNameNews(4);
$globalTemplateParam->set('short_news',$short_news);
/*--------меню с самыми посещяемыми новостями--------*/
//$time_new = date('d',time())." ".$modul->getMounth(date("m",time()))." ".date('Y',time())." ".date('H:i',time());
$time_new = '<span>Сегодня <b>'.date('d',time()).' '.$modul->getMounth(date("m",time())).'</b></span><img src="/images/icons/time_header.png" alt="Время"/><span class="time">'.date('H:i',time()).'</span>';
$globalTemplateParam->set('time_new',$time_new);
$globalTemplateParam->set('request_uri',$request_uri);
$globalTemplateParam->set('menu',$menu);
$globalTemplateParam->set('url',$url);
$modul->template = "base/main.tpl";
$globalTemplateParam->set('modul',$modul);
if($modul->file){
include($modul->file.".php");
}
//PrintAr($request_uri);
//echo 'qq';
/*---------------время генерации страницы--------------------*/
// делаем то же, что и в start.php, только используем другие переменные
$end_time = microtime();
$end_array = explode(" ",$end_time);
$end_time = $end_array[1] + $end_array[0];
// вычитаем из конечного времени начальное
$time = $end_time - $start_time;
$time = round($time,2);
// выводим в выходной поток (броузер) время генерации страницы
$generate_page_time = "Страница сгенерирована за {$time} секунд";
$globalTemplateParam->set('generate_page',$generate_page_time);
/*---------------время генерации страницы--------------------*/
/*-- вывод id страницы --*/
$modul->setRedir($request->modul);
$page_id = $modul->getInfo();
$page_id = "{$page_id['id']}";
$globalTemplateParam->set('id_page',$page_id);
/*-- конец вывода id страницы--*/
$template = $twig->loadTemplate($modul->template);
$template->display($globalTemplateParam->get());