· 5 years ago · Oct 14, 2020, 06:18 PM
1<?php
2if (!defined("_VALID_PHP")) { die('Direct access to this location is not allowed.'); }
3
4if (file_exists('install/')) {
5 header('Location: /install/install.php');
6}
7$BASEPATH = str_replace("autoload.php", "", realpath(__FILE__));
8define("BASEPATH", $BASEPATH);
9define("MODULES_DIR", "modules");
10
11//require_once(BASEPATH . "helper.php");
12if (strlen(session_id()) < 1)
13 @session_start();
14
15// Include Config File
16$configFile = BASEPATH . "config.php";
17if (file_exists($configFile)) {
18
19 require_once($configFile);
20}
21
22$values['actual_link'] = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
23
24// Magic Quotes Fix
25if(ini_get('magic_quotes_gpc')){
26 function clean($data)
27 {
28 if (is_array($data)) {
29 foreach ($data as $key => $value) {
30 $data[clean($key)] = clean($value);
31 }
32 } else {
33 $data = stripslashes($data);
34 }
35
36 return $data;
37 }
38
39 $_GET = clean($_GET);
40 $_POST = clean($_POST);
41 $_COOKIE = clean($_COOKIE);
42}
43@require_once('helper.php');
44
45////Shop Class
46//require_once(BASEPATH . API_DIR . CLASSES_DIR . "class.shop.php");
47//// Extend file classes
48//require_once(BASEPATH . API_DIR . CLASSES_DIR . "class.shop_attributes.php");
49//require_once(BASEPATH . API_DIR . CLASSES_DIR . "class.shop_extras.php");
50//$shop = new Shop_Extras();
51
52
53
54//Objects Class
55require_once(BASEPATH . API_DIR . CLASSES_DIR . "class.objects.php");
56// Extend file classes
57require_once(BASEPATH . API_DIR . CLASSES_DIR . "class.objects_extras.php");
58$obj = new Objects_Extras();
59
60//Ads Class
61require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.ads.php");
62$ads = new Ads();
63
64//Blog Class
65//require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.blog.php");
66//$blog = new Blog();
67
68//Payments Class
69//require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.payments.php");
70//$pm = new Payments();
71
72require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.gateways.php");
73$gt = new Gateways();
74
75require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.slider.php");
76$slider = new Slider();
77
78//Comments Class
79require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.comments.php");
80$comments = new Comments();
81
82//Promos Class
83// require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.promos.php");
84
85//
86////Warehouse Class
87// require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.warehouse.php");
88// $wh = new Warehouse();
89
90//Hubspot Class
91require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.hubspot.php");
92$hubspot = new Hubspot();
93//OneSignal Class
94require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.onesignal.php");
95$oneSignal = new OneSignal();
96//currencies
97require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.currencies.php");
98$currencies = new Currencies();
99//forum
100require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.forum.php");
101$forum = new Forum();
102
103//Chat Class
104require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.conversations.php");
105$chat = new Conversations();
106
107
108//Api Class
109require_once(BASEPATH . API_DIR . CLASSES_DIR. "class.api.php");
110$api = new Api();
111
112if(!isset($_SESSION['city'])) {
113 $visitor_ip = $_SERVER['REMOTE_ADDR'];
114 $details = json_decode(file_get_contents("http://ipinfo.io/{$visitor_ip}"));
115 $city_id = $db->getValue("id", "cities", "title_en='".$details->city."'");
116 if(!$city_id) {
117 $city_id = $db->getValue("id", "cities", "id!='0' ORDER BY id DESC");
118 }
119 $_SESSION['city'] = $city_id;
120}
121
122if(post('city_id_filt')) {
123 $_SESSION['city'] = post('city_id_filt');
124}
125
126$values['modules_js'] = array();
127
128$modules = $db->getResults("*", "modules", "status='1'");
129if($modules) {
130 foreach($modules as $row) {
131 if (file_exists(BASEPATH."modules" . "/" . $row['dir'] . "/class/class.".$row['class'].".php")) {
132 require_once(BASEPATH."modules" . "/" . $row['dir'] . "/class/class.".$row['class'].".php");
133 $var = $row['variable'];
134 $class_name = $row['class_name'];
135 ${"$var"} = new $class_name();
136 $values['modules_js'] = $db->getResults("file_name, '".$row['dir']."' AS dir", "modules_js", "module_id='".$row['id']."'");
137 }
138 }
139}
140//$db->pre($values['modules_js']);
141//require_once(BASEPATH . API_DIR . CLASSES_DIR . "class.cart.php");
142//$cart = new Cart();
143
144//$db->pre($lang->lang_as_array());
145
146if(!isset($core->theme)) {
147 $core->theme = "default";
148}
149
150define('SITEURL', $core->site_url);
151define('ADMINURL', $core->site_url . "/admin");
152define('THEMEURL', $core->site_url . '/templates/' . $core->theme);
153define('THEMEPATH', 'templates/' . $core->theme);
154define('UPLOADURL', $core->site_url . "/" . API_DIR . UPLOADS_DIR);
155define('RESIZEURL', $core->site_url."/resize.php");
156
157define('UPLOADS', BASEPATH . API_DIR . UPLOADS_DIR);
158
159//Start Mustache Class
160require_once(BASEPATH . API_DIR . PLUGINS_DIR. "Mustache/Autoloader.php");
161Mustache_Autoloader::register();
162
163//Start Memchached
164//require_once(BASEPATH . API_DIR . PLUGINS_DIR. "Mustache/MustacheCacheMemcached.php");
165//$memcache = new Memcached();
166//$memcache->addServer('127.0.0.1', '11211');
167
168
169$loader_dir_template = dirname(__FILE__).'/templates/' . $core->theme;
170
171//custom footer code
172$values['code'] = htmlspecialchars_decode($db->getValue('code', TABLE_SETTINGS, 'id=1'));
173
174$mustache_options = array(
175 'template_class_prefix' => '_'. $core->theme .'_',
176 // 'cache' => new MustacheCacheMemcached($memcache),
177 //'cache' => dirname(__FILE__).'/tmp/cache/mustache',
178 'cache_file_mode' => 0666, // Please, configure your umask instead of doing this :)
179 'cache_lambda_templates' => true,
180 'loader' => new Mustache_Loader_FilesystemLoader($loader_dir_template, array('extension' => '.tpl')),
181 'partials_loader' => new Mustache_Loader_FilesystemLoader($loader_dir_template, array('extension' => '.tpl')),
182 'helpers' => array(
183 'lang' => $lang->lang_as_array(),
184 'SITEURL' => SITEURL,
185 'THEMEURL' => THEMEURL,
186 'UPLOADURL' => UPLOADURL,
187 'RESIZEURL' => RESIZEURL,
188// 'menu' => $menu->cattree,
189 ),
190 //'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/templates/'.$core->theme.'/partials'),
191 'escape' => function($value) {
192 return @htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
193 },
194);
195//$db->pre($lang->lang_as_array());
196$langs = $lang->lang_as_array();
197$site_menu='';
198if($menu->cattree) {
199 foreach ($menu->cattree as $key => $link) {
200 if ($link['parent_id'] == 0) {
201 $child = $menu->get_child_tree($link['id']);
202 $child_html = '';
203 $class = ' ';
204 $after = '';
205// if ($child) {
206// $class = ' class="awemenu-item"';
207// $child_html .= '<ul style="display:none;">';
208// foreach ($child as $c_li) {
209// $c_slug = '';
210// if(isset($c_li['slug'])) {
211// $c_slug = $c_li['slug'];
212// }
213// $c_title = '';
214// if(isset($c_li['title'])) {
215// $c_title = $c_li['title'];
216// }
217// $child_li = '<li class="sub-menu"><a href="' . $c_slug . '"><i class="' . $c_li["icon"] . '"></i>' . $c_title . '</a></li>';
218// $child_html .= $child_li;
219// }
220// $child_html .= '</ul>';
221// //$after = '<i class="fa fa-angle-down"></i>';
222// }
223 $slug = '';
224 if(isset($link['slug'])) {
225 $slug = $link['slug'];
226 }
227 $title = '';
228 if(isset($link['title'])) {
229 $title = $link['title'];
230 }
231 $li = '<li' . $class . '><a href="' . $slug . '"><div><i class="' . $link["icon"] . '"></i>' . $title . $after . '</div></a>' . $child_html . '</li>';
232 $site_menu .= $li;
233 }
234 }
235}
236
237
238if(isset($_SESSION['aff'])) {
239 $values['affilate_id'] = $_SESSION['aff'];
240}
241
242//zopim
243$zopim = $db->getResults("*", "integrations", "id='1'");
244if($zopim[0]['status'] == 1) {
245 $values['zopim_enabled'] = TRUE;
246 $values['zopim_code'] = htmlspecialchars_decode($zopim[0]['code1']);
247 $values['zopim_title'] = $zopim[0]['title'];
248} else {
249 $values['zopim_enabled'] = FALSE;
250}
251
252//Yotpo
253$yotpo = $db->getResults("*", "integrations", "id='2'");
254if($yotpo[0]['status'] == 1) {
255 $values['yotpo_enabled'] = TRUE;
256 $values['yotpo_code'] = htmlspecialchars_decode($yotpo[0]['code1']);
257 $values['yotpo_title'] = $yotpo[0]['title'];
258} else {
259 $values['zopim_enabled'] = FALSE;
260}
261
262//Hotjar
263$hotjar = $db->getResults("*", "integrations", "id='3'");
264if($hotjar[0]['status'] == 1) {
265 $values['hotjar_enabled'] = TRUE;
266 $values['hotjar_code'] = htmlspecialchars_decode($hotjar[0]['code1']);
267 $values['hotjar_title'] = $hotjar[0]['title'];
268} else {
269 $values['zopim_enabled'] = FALSE;
270}
271
272//google UA
273if(isset($core->google_ua)) {
274 $values['google_ua'] = $core->google_ua;
275}
276
277//Mailchimp
278$mailchimp = $db->getResults("*", "integrations", "id='4'");
279if($mailchimp[0]['status'] == 1) {
280 $values['mailchimp_enabled'] = TRUE;
281 $values['mailchimp_code'] = htmlspecialchars_decode($mailchimp[0]['code1']);
282 $values['mailchimp_title'] = $mailchimp[0]['title'];
283} else {
284 $values['mailchimp_enabled'] = FALSE;
285}
286
287$values['facebook_login'] = $core->facebook_login;
288$values['facebook_appid'] = $core->facebook_appID;
289
290
291$mustache_options['helpers']['menu_html'] = $site_menu;
292$values['site_name'] = $core->site_name;
293
294
295$values['currencies'] = $db->getResults("*", "currencies");
296
297
298//$mustache_options['helpers']['cart'] = $shop->cartrows;
299$mustache_options['helpers']['cart_id'] = $shop->cartrows[0]['id'];
300//$mustache_options['helpers']['cart_item_id'] = $shop->cartrows[0]['cart_item_id'];
301$mustache_options['helpers']['cartnum'] = ($shop->cartrows) ? count($shop->cartrows) : 0;
302$mustache_options['helpers']['cartnum_text'] = ($shop->cartrows != 0 && count($shop->cartrows) == 1) ? 'продукт' : 'продукта';
303//
304//$values['cart'] = $shop->loadCart();
305//if(is_array($values['cart'])){
306// $totalPrice = 0;
307// foreach($values['cart'] as $single){
308// $totalPrice += $single['product_price_total'];
309// }
310// $values['cart_total'] = $totalPrice;
311//}
312
313
314if( $user->logged_in ) {
315 $values['wish_count'] = $db->getValue('COUNT(id)','wishlist','uid='.$user->uid);
316
317// $db->pre($wish_count);
318// $db->pre(count($wish_count));
319}else{
320 $values['wish_count'] = 0;
321}
322
323
324$values['searchCat'] = $db->getResults("c.id, cc.title","shop_categories c left join shop_categories_content cc on c.id = cc.eid");
325
326
327//$db->pre($values['selopt_categories']);
328
329//$db->pre($values['cart']);
330
331//if($user->logged_in) {
332// $userinfo = $user->get_user_info($_SESSION['email']);
333// if($userinfo['pp_data'] == 0 || $userinfo['general_terms'] == 0) {
334// $values['terms_alert_up'] = '<div class="alert alert-danger" role="alert">
335// '._ALERT_CONFIRM_DATA.'
336//</div>';
337// $host = $_SERVER['REQUEST_URI'];
338// if ($host == '/logout.php' || $host == '/index/25-userpage.html?do=profile-settings' || $host == '/user-actions.php') {
339//
340// } else {
341// header("Location: /index/25-userpage.html?do=profile-settings");
342// }
343// } else {
344// $values['terms_alert_up'] = '';
345// }
346//}
347
348$domain = $_SERVER['HTTP_HOST'];
349$values['show_cart'] = $core->show_cart;
350$values['logo'] = '/api/uploads/settings/'.$core->logo;
351$values['favicon'] = '/api/uploads/settings/'.$core->favicon;
352
353$mustache = new Mustache_Engine($mustache_options);
354if($user->userlevel <= 1) {
355 $date_now = date("Y-m-d H:i:s");
356 if ($core->maintance & $core->countdown_date > $date_now) {
357 $host = $_SERVER['REQUEST_URI'];
358 if (strpos($host, '/admin') !== false || $host == '/maintance.php') {
359
360 } else {
361 header("Location: /maintance.php");
362 }
363
364 }
365}
366
367?>