/* session,cache,configure,webroot register */ Session::Init(); $INI = ZSystem::GetINI(); /* end */ /* date_zone */ if (function_exists('date_default_timezone_set')) { date_default_timezone_set($INI['system']['timezone']); } /* end date_zone */ /* biz logic */ $currency = $INI['system']['currency']; $login_user_id = ZLogin::GetLoginId(); $login_user = Table::Fetch('user', $login_user_id); $hotcities = option_hotcategory('city', false, true); $allcities = option_category('city', false, true); $city = cookie_city(null); if (!isset($_COOKIE['referer'])) { setcookie('referer', $_SERVER['HTTP_REFERER']); } /* not allow access app.php */ if ($_SERVER['SCRIPT_FILENAME'] == __FILE__) { redirect(WEB_ROOT . '/index.php'); } /* end */ $AJAX = 'XMLHttpRequest' == @$_SERVER['HTTP_X_REQUESTED_WITH']; if (false == $AJAX) { header('Content-Type: text/html; charset=UTF-8'); run_cron(); } else { header("Cache-Control: no-store, no-cache, must-revalidate"); }
* The City List * ---------------------------------------------------------------------------- * This is not free software * ---------------------------------------------------------------------------- * @author abei <*****@*****.**> * @version 1.0 * @link http://www.qiang8.cn */ require_once(dirname(dirname(__FILE__)) . '/app.php'); $ename = strval($_GET['n']); $currefer = null; if ($ename&&$ename!='none') { $city = Table::Fetch('category', $ename, 'ename'); if ($city) { cookie_city($city); $currefer = udecode($currefer); if ($currefer) { redirect($currefer); } else if ( $_SERVER['HTTP_REFERER'] ) { if (!preg_match('#'.$_SERVER['HTTP_HOST'].'#', $_SERVER['HTTP_REFERER'])) { redirect( 'index.php'); } if (preg_match('#/city#', $_SERVER['HTTP_REFERER'])) { redirect( 'index.php'); } redirect($_SERVER['HTTP_REFERER']); } redirect('index.php'); } }
function cookie_city($city) { global $INI; if ($city) { cookieset('city', $city['id']); return $city; } $city_id = cookieget('city'); if (!$city_id) { $city = get_city(); if (!$city) { $city = Table::Fetch('category', $INI['hotcity'][0]); } if ($city) { cookie_city($city); } return $city; } else { if (in_array($city_id, $INI['hotcity'])) { return Table::Fetch('category', $city_id); } $INI['hotcity'] = array_diff($INI['hotcity'], array(0, NULL)); $city = Table::Fetch('category', $INI['hotcity'][0]); } return $city; }
<?php require_once dirname(__FILE__) . '/app.php'; $tip = strval($_GET['tip']); if ($_POST) { if (!Utility::ValidEmail($_POST['email'], true)) { Session::Set('error', 'Email is not a valid email address'); Utility::Redirect(WEB_ROOT . '/subscribe.php'); } if ($_POST['city_id']) { ZSubscribe::Create($_POST['email'], $_POST['city_id']); if ($city['id'] != $_POST['city_id']) { $updatecity = Table::Fetch('category', $_POST['city_id']); cookie_city($updatecity); $city = $updatecity; } } else { ZSubscribe::Create($_POST['email'], $city['id']); } die(include template('subscribe_success')); } include template('subscribe');
<?php require_once dirname(__FILE__) . '/app.php'; $tip = strval($_GET['tip']); if ($_POST) { $city_id = abs(intval($_POST['city_id'])); ZSubscribe::Create($_POST['email'], $city_id); cookie_city($city = Table::Fetch('category', $city_id)); die(include template('subscribe_success')); } include template('subscribe');
function cookie_city($city) { global $hotcities; if ($city) { cookieset('city', $city['id']); return $city; } $city_id = cookieget('city'); $city = Table::Fetch('category', $city_id); if (!$city) { $city = get_city(); } if (!$city) { $city = array_shift($hotcities); } if ($city) { return cookie_city($city); } return $city; }
function cookie_city($city) { if ($city) { $city_v = uencode("{$city['id']}|{$city['ename']}|{$city['name']}"); $expire = time() + 365 * 86400; cookieset('city', $city_v); } else { if (!cookieget('city')) { $city = get_city(); if (!$city) { return array(); } return cookie_city($city); } else { $v = explode('|', udecode(cookieget('city'))); return array('id' => $v[0], 'ename' => $v[1], 'name' => $v[2]); } } return $city; }