コード例 #1
0
ファイル: Date.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     $tmp = explode('-', $var);
     if (count($tmp) != 3) {
         return FALSE;
     }
     if (!is_numeric($tmp[0]) || !is_numeric($tmp[1]) || !is_numeric($tmp[2])) {
         return FALSE;
     }
     if ($tmp[0] < 1900) {
         return false;
     }
     if ($tmp[1] < 1 || $tmp[1] > 12) {
         return false;
     }
     if ($tmp[2] < 1 || $tmp[2] > 31) {
         return false;
     }
     return TRUE;
 }
コード例 #2
0
ファイル: Cookie.php プロジェクト: kevinwan/xf
 /**
  * 读取内容
  * @return mixed
  */
 public function read()
 {
     if (isset($_COOKIE[$this->_namespace])) {
         return XF_Functions::authCode($_COOKIE[$this->_namespace], 'DECODE');
     }
     return null;
 }
コード例 #3
0
ファイル: Meta.php プロジェクト: kevinwan/xf
 /**
  * 获取实例
  * @access public
  * @return XF_View_Helper_Header_Meta
  */
 public static function getInstance($meta = null)
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     if (XF_Functions::isEmpty($meta) === false) {
         self::$_instance->appendMeta($meta);
     }
     return self::$_instance;
 }
コード例 #4
0
ファイル: Script.php プロジェクト: kevinwan/xf
 /**
  * 获取实例
  * @access public
  * @return XF_View_Helper_Header_Script
  */
 public static function getInstance($script = null)
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     if (XF_Functions::isEmpty($script) === false) {
         self::$_instance->appendFile($script);
     }
     return self::$_instance;
 }
コード例 #5
0
ファイル: Title.php プロジェクト: kevinwan/xf
 /**
  * 获取实例
  * @access public
  * @return XF_View_Helper_Header_Title
  */
 public static function getInstance($title = '')
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     if (XF_Functions::isEmpty($title) === false) {
         self::$_instance->appendTitle($title);
     }
     return self::$_instance;
 }
コード例 #6
0
ファイル: Link.php プロジェクト: kevinwan/xf
 /**
  * 获取实例
  * @access public
  * @return XF_View_Helper_Header_Link
  */
 public static function getInstance($link = null)
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     if (XF_Functions::isEmpty($link) === false) {
         self::$_instance->appendLink($link);
     }
     return self::$_instance;
 }
コード例 #7
0
ファイル: Rewrite.php プロジェクト: kevinwan/xf
 /**
  * 分析匹配结果
  * @param string $uri 请求的URI
  * @param string $regex 具体规则
  * @param array $tmp 匹配后的结果数组
  * @param int $regexIndex 当前是第几个规则【是指同一个名称里的规则,不是全局】
  * @return void
  */
 private function _matchAnalysis($uri, $regex, $tmp, $regexIndex)
 {
     //是否匹配成功
     if (is_array($tmp) && XF_Functions::isEmpty($tmp) === FALSE || $regex == '/' && $uri == '/') {
         //记录匹配到的规则方便调式用
         if (XF_Config::getInstance()->getSaveDebug()) {
             XF_DataPool::getInstance()->addHash('DEBUG', 'Match_Rewrite', $regex);
         }
         $this->_match_status = TRUE;
         $request = XF_Controller_Request_Http::getInstance();
         $request->setModule($this->_ma_array['module'])->setController($this->_ma_array['controller'])->setAction($this->_ma_array['action']);
         //是否存在自定义的附加参数
         if (isset($this->_ma_array['params']) && is_array($this->_ma_array['params'])) {
             foreach ($this->_ma_array['params'] as $k => $val) {
                 $request->setParam($k, $val);
             }
         }
         //设置匹配到的参数
         if (is_array($this->_params_array)) {
             foreach ($this->_params_array as $key => $val) {
                 //指定的参数是否只匹配指定位置的规则
                 $keyTmp = explode(':', $key);
                 if (!isset($keyTmp[1])) {
                     if (isset($tmp[$keyTmp[0]])) {
                         $request->setParam($val, urldecode($tmp[$keyTmp[0]]));
                     }
                 } else {
                     if ($keyTmp[0] == $regexIndex && isset($tmp[$keyTmp[1]])) {
                         //规则位置从0开始
                         $request->setParam($val, urldecode($tmp[$keyTmp[1]]));
                     }
                 }
             }
         }
         //////重写URL后,尝试获取设置的参数
         $uri = str_replace($tmp[0], '', $uri);
         $tep = explode('/', $uri);
         if (is_array($tep) && count($tep) >= 2) {
             if ($tep[0] == '') {
                 unset($tep[0]);
             }
             $tep = array_values($tep);
             foreach ($tep as $key => $val) {
                 if (isset($tep[$key + 1]) && $tep[$key + 1] != '') {
                     $request->setParam($val, urldecode($tep[$key + 1]));
                 } else {
                     break;
                 }
             }
         }
     }
 }
コード例 #8
0
ファイル: Card.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     if (!ereg("\\d{15}|\\d{18}", $var)) {
         return FALSE;
     }
     return TRUE;
 }
コード例 #9
0
ファイル: Email.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     if (!preg_match("/^([a-zA-Z0-9]+[_|\\_|\\.|\\-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\\_|\\.|\\-]?)*[a-zA-Z0-9]+\\.[a-zA-Z]{2,3}\$/", $var)) {
         return FALSE;
     }
     return TRUE;
 }
コード例 #10
0
ファイル: Phone.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     if (!preg_match("/\\d{3}-\\d{8}|\\d{4}-\\d{7}/", $var)) {
         return FALSE;
     }
     return TRUE;
 }
コード例 #11
0
ファイル: Ip.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     if (!preg_match("/\\A((([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\\.){3}(([0-9]?[0-9])|(1[0-9]{2})|(2[0-4][0-9])|(25[0-5]))\\Z/", $var)) {
         return FALSE;
     }
     return TRUE;
 }
コード例 #12
0
ファイル: ZipCode.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     if (!preg_match("/[1-9]\\d{5}(?!\\d)/", $var)) {
         return FALSE;
     }
     return TRUE;
 }
コード例 #13
0
 /**
  * 获取品牌关键词
  */
 public function brandKeywordsAction()
 {
     $b = new Auto_Model_Brand();
     $keywords = $b->getBrandKeywords();
     if (!XF_Functions::isEmpty($keywords)) {
         $tmp = array();
         foreach ($keywords as $r) {
             $tmp[] = array('keywords' => $r->keywords, 'slug' => $r->slug, 'brand_name' => $r->brand_name, 'parent' => $r->parent, 'name' => $r->name);
         }
         $this->responseOK($tmp);
     }
     $this->responseOK();
 }
コード例 #14
0
ファイル: Chinese.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     if (preg_match("/[-�]/", $var)) {
         return TRUE;
     }
     return FALSE;
 }
コード例 #15
0
ファイル: Main.php プロジェクト: kevinwan/gongpingjiaPHP
 /**
  * 检测二级域名
  */
 protected function initCheckDomain()
 {
     $cookie = new XF_Cookie('local');
     $tmp = explode('.', $_SERVER['HTTP_HOST']);
     //是否为地区二级域名
     if (isset($this->_cityDomains->{$tmp[0]})) {
         $this->_nowCityDomain = (object) $this->_cityDomains->{$tmp[0]};
         $this->_nowCityDomain->pinyin = $tmp[0];
         //记录当前浏览的地区id
         $cookie->write($this->_nowCityDomain->id, 604800, '/', '.' . $this->_config->getDomain());
     } else {
         //记录当前浏览的地区id
         $cookie->write(1, 604800, '/', '.' . $this->_config->getDomain());
         XF_Functions::go('http://beijing.' . $this->_config->getDomain());
     }
 }
コード例 #16
0
ファイル: Mobile.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (!is_numeric($var)) {
         return FALSE;
     }
     if (strlen($var) > 11) {
         return FALSE;
     }
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     if (!preg_match("/^1(3|4|5|8|7|)\\d{10}/", $var)) {
         return FALSE;
     }
     return TRUE;
 }
コード例 #17
0
ファイル: Bootstrap.php プロジェクト: kevinwan/xf
 /**
  * 运行启动器
  * @access public
  * @return void
  */
 public function run()
 {
     $st = microtime(true);
     $this->checkDomain();
     $this->runStartup();
     XF_DataPool::getInstance()->addList('Bootstrap_Inits', 'runStartup ' . sprintf('%.5fs', microtime(true) - $st));
     if (!empty($_GET['xsessid'])) {
         $session_id = XF_Functions::authCode(urlencode($_GET['xsessid']), 'DECODE');
         if ($session_id != '') {
             session_id($session_id);
         }
     }
     $stt = microtime(true);
     session_start();
     XF_DataPool::getInstance()->addList('Bootstrap_Inits', 'session_start ' . sprintf('%.5fs', microtime(true) - $stt));
     header("Content-type:text/html;charset=utf-8");
     $this->_loadInit();
     XF_DataPool::getInstance()->add('RunBootstrap', sprintf("%.6f", microtime(true) - $st));
     XF_Controller_Front::getInstance()->init()->dispatch();
 }
コード例 #18
0
ファイル: Front.php プロジェクト: kevinwan/gongpingjiaPHP
 public function routeShutdown(XF_Controller_Request_Abstract $request)
 {
     //检测访问权限
     $m = $request->getModule();
     $c = $request->getController();
     if ($m == 'user' && $c != 'front') {
         $auth = new XF_Auth_Storage_Session();
         if ($auth->isEmpty()) {
             XF_Functions::go('/login/?redirect_url=' . urlencode($request->getRequestUrl()));
         }
     }
     //如果存在强制清除缓存命令
     $auth = new XF_Auth_Storage_Session();
     if ($auth->isEmpty() == false && $auth->read()->role_id != '0') {
         if ($request->getParam('clear') == 'cache') {
             XF_DataPool::getInstance()->add('clearCache', TRUE);
         }
         if ($request->getParam('clear') == 'action') {
             XF_DataPool::getInstance()->add('clearActionCache', TRUE);
         }
     }
 }
コード例 #19
0
 protected function __cacheSign($action_name)
 {
     switch ($action_name) {
         case 'index':
             //是否存在跳转url
             if ($val = $this->getParam('redirect_url')) {
                 //二手车随便看看
                 if (strpos($val, '/used/index/index') !== false) {
                     XF_Functions::go('/used/index/index');
                 } elseif (preg_match_all("/\\/sellreport\\/(\\d+)\\/(.*?)\\/(\\d+)\\/(\\d+)\\/(\\d+)\\//", $this->getParam('redirect_url'), $matchs)) {
                     XF_Functions::go('/sellreport/' . $matchs[1][0] . '/');
                 } elseif (preg_match_all("/\\/buyreport\\/(\\d+)\\/(.*?)\\/(\\d+)\\/(\\d+)\\/(\\d+)\\//", $this->getParam('redirect_url'), $matchs)) {
                     XF_Functions::go('/buyreport/' . $matchs[1][0] . '/');
                 } else {
                     XF_Functions::go($val);
                 }
             }
             if (is_object($this->nowCity)) {
                 return $this->nowCity->id . '_indexhome';
             }
             break;
     }
     return '';
 }
コード例 #20
0
ファイル: Time.php プロジェクト: kevinwan/xf
 public static function validate($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return FALSE;
     }
     if (!is_scalar($var)) {
         return FALSE;
     }
     $tmp = explode(' ', $var);
     if (count($tmp) != 2) {
         return false;
     }
     if (XF_String_Validate_Date::validate($tmp[0]) == false) {
         return false;
     }
     $tmp = explode(':', $tmp[1]);
     if (count($tmp) != 3) {
         return false;
     }
     if ($tmp[0] > 23 || $tmp[0] < 0 || $tmp[1] > 59 || $tmp[1] < 0 || $tmp[2] > 59 || $tmp[2] < 0) {
         return false;
     }
     return TRUE;
 }
コード例 #21
0
ファイル: Validate.php プロジェクト: kevinwan/xf
 /**
  * 验证表单 分析规则 Validate
  * @access private
  * @param array $data 将要验证的数组资料
  * @param string $key	当前需要验证的字段[key]
  * @param string $rules_name	规则名称
  * @param mixed $rules_value	规则值
  * @param array	 $message	自定义错误信息
  * @param XF_Db_Table_Abstract $db_table 主要支持unique的验证,默认为null
  * @param bool $is_insert 是否为添加数据操作?如果不是,则不强制执行required
  * @return bool
  */
 private function _switchValidateFormData($data, $key, $rules_name, $rules_value, $message, XF_Db_Table_Abstract $db_table = NULL, $is_insert = TRUE)
 {
     $this->_validate_count++;
     //判断规则,分析结果
     $validateOk = true;
     switch ($rules_name) {
         //验证 必填
         case 'required':
             if ($rules_value == 'true') {
                 if (isset($data[$key])) {
                     if (XF_Functions::isEmpty($data[$key])) {
                         $validateOk = false;
                     }
                 } elseif ($is_insert == true) {
                     $validateOk = false;
                 }
             }
             break;
             //验证 数字
         //验证 数字
         case 'number':
             if (isset($data[$key])) {
                 if ($rules_value == 'true') {
                     if (!is_numeric($data[$key])) {
                         $validateOk = false;
                     }
                 }
             }
             break;
             //数字小于
         //数字小于
         case 'lt':
             if (isset($data[$key])) {
                 if (!is_numeric($data[$key]) || !is_numeric($rules_value)) {
                     $validateOk = false;
                 } elseif ($data[$key] >= $rules_value) {
                     $validateOk = false;
                 }
             }
             break;
             //数字大于
         //数字大于
         case 'gt':
             if (isset($data[$key])) {
                 if (!is_numeric($data[$key]) || !is_numeric($rules_value)) {
                     $validateOk = false;
                 } elseif ($data[$key] <= $rules_value) {
                     $validateOk = false;
                 }
             }
             break;
             //等于
         //等于
         case 'equal':
             if (isset($data[$key])) {
                 if ($data[$key] !== $rules_value) {
                     $validateOk = false;
                 }
             }
             break;
             //不等于
         //不等于
         case 'unequal':
             if (isset($data[$key])) {
                 if ($data[$key] === $rules_value) {
                     $validateOk = false;
                 }
             }
             break;
             //验证 是否为正确的email
         //验证 是否为正确的email
         case 'email':
             if (!empty($data[$key]) && $rules_value == 'true') {
                 $validateOk = XF_String_Validate_Email::validate($data[$key]);
             }
             break;
             //验证 是否为正确的电话号码
         //验证 是否为正确的电话号码
         case 'tel':
             if (!empty($data[$key]) && $rules_value == 'true') {
                 $validateOk = XF_String_Validate_Phone::validate($data[$key]);
             }
             break;
             //验证 是否为正确的手机号码
         //验证 是否为正确的手机号码
         case 'mobile':
             if (!empty($data[$key]) && $rules_value == 'true') {
                 $validateOk = XF_String_Validate_Mobile::validate($data[$key]);
             }
             break;
             //验证 是否为正确的身份证号码
         //验证 是否为正确的身份证号码
         case 'card':
             if (!empty($data[$key]) && $rules_value == 'true') {
                 $validateOk = XF_String_Validate_Card::validate($data[$key]);
             }
             break;
             //验证 是否为正确邮政编码
         //验证 是否为正确邮政编码
         case 'zip':
             if (!empty($data[$key]) && $rules_value == 'true') {
                 $validateOk = XF_String_Validate_ZipCode::validate($data[$key]);
             }
             break;
             //验证 最小长度
         //验证 最小长度
         case 'minlen':
             if (!empty($data[$key])) {
                 if (mb_strlen($data[$key], 'utf8') < $rules_value) {
                     $validateOk = false;
                 }
             }
             break;
             //验证 最大长度
         //验证 最大长度
         case 'maxlen':
             if (!empty($data[$key])) {
                 if (mb_strlen($data[$key], 'utf8') > $rules_value) {
                     $validateOk = false;
                 }
             }
             break;
             //验证 ip地址
         //验证 ip地址
         case 'ip':
             if (!empty($data[$key]) && $rules_value == 'true') {
                 $validateOk = XF_String_Validate_Ip::validate($data[$key]);
             }
             break;
             /**
              *  验证 取值范围在列表中
              *  例如:in:2|23|9|0
              *
              */
         /**
          *  验证 取值范围在列表中
          *  例如:in:2|23|9|0
          *
          */
         case 'in':
             if (XF_Functions::isEmpty($data[$key]) == FALSE) {
                 if (!in_array($data[$key], explode('|', $rules_value))) {
                     $validateOk = false;
                 }
             }
             break;
             /**
              *  验证 取值范围必需不在列表中
              *  例如:not_in:2|23|9|0
              *
              */
         /**
          *  验证 取值范围必需不在列表中
          *  例如:not_in:2|23|9|0
          *
          */
         case 'not_in':
             if (XF_Functions::isEmpty($data[$key]) == FALSE) {
                 if (!in_array($data[$key], explode('|', $rules_value))) {
                     $validateOk = false;
                 }
             }
             break;
             //验证与指定的字段值是否相同
         //验证与指定的字段值是否相同
         case 'confirm':
             if (isset($data[$key])) {
                 if ($data[$key] != $data[$rules_value]) {
                     $validateOk = false;
                 }
             }
             break;
         case 'date':
             if (isset($data[$key]) && $rules_value == 'true') {
                 if (!XF_String_Validate_Date::validate($data[$key])) {
                     $validateOk = false;
                 }
             }
             break;
         case 'time':
             if (isset($data[$key]) && $rules_value == 'true') {
                 if (!XF_String_Validate_Time::validate($data[$key])) {
                     $validateOk = false;
                 }
             }
             break;
         case 'unique':
             if (isset($data[$key]) && $rules_value == 'true') {
                 if ($db_table == NULL) {
                     $validateOk = false;
                 } elseif (!XF_Db_Table_Validate_Unique::validate($data[$key], $key, $db_table, $is_insert)) {
                     $validateOk = false;
                 }
             }
             break;
     }
     //字段值为 '$NULL' 时直接通过验证 2014-09-3
     if (isset($data[$key]) && $data[$key] == '$NULL') {
         $validateOk = true;
     }
     //没有错误
     if ($validateOk) {
         $this->_validate_success_count++;
         return true;
     } else {
         //记录错误
         $errorMessage = $key . '=>' . $rules_name . ':' . $rules_value;
         if (isset($message[$key]) && is_array($message[$key]) && isset($message[$key][$rules_name])) {
             $errorMessage = $message[$key][$rules_name];
         } elseif (isset($message[$key])) {
             $errorMessage = (string) $message[$key];
         }
         XF_DataPool::getInstance()->replace('TableFieldDataValidateError', $errorMessage);
         return false;
     }
 }
コード例 #22
0
ファイル: Front.php プロジェクト: kevinwan/xf
 /**
  * 转发控制器
  * @param XF_Controller_Request_Abstract $request
  * @param bool $runRouter 重新运行路由解析 默认为true
  * @throws XF_Controller_Exception
  */
 private function _dispatch(XF_Controller_Request_Abstract $request = null, $runRouter = true)
 {
     $this->_dispath_count++;
     if ($request != null) {
         $this->_request = $request;
     }
     if ($this->_dispath_count == 1) {
         $this->_plugin_manage->routeStartup($this->_request);
         $this->_router->run();
         $this->_plugin_manage->routeShutdown($this->_request);
     } elseif ($this->_dispath_count >= 5) {
         XF_Functions::writeErrLog('URI:' . $this->_request->getRequestUrl() . ' - loop forever dispatch controller');
         throw new XF_Exception('loop forever dispatch controller');
     } else {
         if ($runRouter == true) {
             $this->_router->run();
         }
     }
     //没有找到正确的模块
     if ($this->_request->getModule() == 'unknown') {
         throw new XF_Exception('404 Not found!', 404);
     }
     //加载控制器
     $this->getModuleDir();
     $controllerName = NULL;
     if (strtolower($this->_request->getModule()) != 'default') {
         $controllerName = ucfirst($this->_request->getModule()) . '_';
     }
     $this->_controller_dir = $this->_module_dir . '/controllers';
     $controllerFile = $this->_controller_dir . '/' . ucfirst($this->_request->getController()) . 'Controller.php';
     if (is_file($controllerFile)) {
         require_once $controllerFile;
         $controllerName .= ucfirst($this->_request->getController()) . 'Controller';
         if (class_exists($controllerName, FALSE)) {
             $this->_plugin_manage->preDispatch($this->_request);
             $this->_controller_instance = new $controllerName();
             $this->_plugin_manage->postDispatch($this->_request);
         }
     }
     if ($this->_controller_instance == null) {
         throw new XF_Exception('404 Not found!', 404);
     } elseif ($this->_controller_instance instanceof XF_Controller_Interface) {
         $this->_controller_instance->doAction();
     } else {
         throw new XF_Exception('404 Not found!', 404);
     }
 }
コード例 #23
0
 public function buyReportAction()
 {
     $serialId = $this->getParam('serialId');
     $cityid = $this->getParam('city');
     $year = $this->getParam('year');
     $typeId = $this->getParam('typeId');
     $mileage = $this->getParam('mileage');
     if (!isset($serialId) || XF_Functions::isEmpty($serialId)) {
         throw new XF_Exception('车系参数不正确');
     }
     // 当前地区名称
     $name = $this->nowCity->name;
     $this->_view->serialId = $serialId;
     // 获取车型列表
     $mod = new Auto_Model_Type();
     $types = $mod->getsBySerialId($serialId);
     // print_r($types);
     $this->_view->types = $types;
     if ((!isset($serialId) || XF_Functions::isEmpty($typeId)) && !XF_Functions::isEmpty($types)) {
         $typeId = $types[0][1][0]->id;
         $type = $mod->getsByTypeId($typeId);
     } else {
         $type = $mod->getsByTypeId($typeId);
     }
     //        获得session,存车型id
     $gpj_session = new XF_Session("gpj_session");
     $sessionAry = array();
     $sessionAry["modelId"] = $typeId;
     $sessionAry["detail_model"] = $type->detail_model;
     $sessionAry["detail_price"] = $type->price_bn;
     $this->_view->type = $type;
     //        获取评估报告投票
     $vote = new Report_Model_Vote();
     $reportVote = $vote->getVoteByTypeId($typeId);
     if ($reportVote) {
         $this->_view->goodNum = $reportVote->right_vote;
         $this->_view->noGoodNum = $reportVote->noright_vote;
         $this->_view->totalNum = $reportVote->right_vote + $reportVote->noright_vote;
     } else {
         $this->_view->goodNum = 0;
         $this->_view->noGoodNum = 0;
         $this->_view->totalNum = 0;
     }
     $cityModel = new Application_Model_City();
     $cities = $cityModel->getsByCity($this->nowCity->id);
     if (!isset($cityid) || XF_Functions::isEmpty($cityid) || !is_numeric($cityid) || $cityid <= 0) {
         $cityid = $this->nowCity->id;
     }
     $cityObj = $cityModel->get($cityid);
     $this->_view->cities = $cities;
     $this->_view->cityName = $cityObj->name;
     $this->_view->cityId = $cityid;
     $this->_view->cityPinYin = $cityObj->pinyin;
     $sessionAry["province"] = $cityid;
     $d_model = $type->id;
     $year = $year > 0 ? $year : $type->listed_year;
     $mile = floatval($mileage) > 0 ? floatval($mileage) : date("Y") - $type->listed_year;
     $intent = 'buy';
     $this->_view->mileage = $mile;
     $this->_view->year = $year;
     $mod = new Report_Model_Valuation();
     $V = $mod->getValuation($cityid, $d_model, $year, '', $mile, $intent);
     $this->_view->V = $V;
     $sessionAry["detail_year"] = $year;
     $sessionAry["detail_mile"] = $mile;
     $sessionAry["serialId"] = $serialId;
     $gpj_session->write($sessionAry);
     // 随机抽取6辆车型
     $carTypeModel = new Auto_Model_Type();
     $serialCars = $carTypeModel->getsByCityAndSerialId($cityid, $typeId);
     foreach ($serialCars as $key => $val) {
         $val->mile = round($val->mile);
         if (!XF_Functions::isEmpty($val->year)) {
             $val->car_age = date("Y") - $val->year;
         }
         if (!XF_Functions::isEmpty($val->source_type)) {
             $val->source_val = $this->source_type[$val->source_type];
         }
         if (!XF_Functions::isEmpty($val->thumbnail)) {
             $val->thumbnail = $val->thumbnail . "?imageView2/1/w/296/h/193";
         } else {
         }
     }
     $this->_view->serialCars = $serialCars;
     $this->setLayout(new Layout_Default());
     $this->_view->headTitle("买二手车价格评估-买二手车估价-买二手车技巧流程-公平价");
     $this->_view->headMeta("买二手车车评估,买二手车估价,买二手车流程,买二手车技巧");
     $this->_view->headMeta("公平价-买车评估频道为您提供:二手车买车估值、二手车买车估价、二手车买车估价计算器,给您所选爱车一个精准、公平、公道的价格。二手车买车服务就上公平价!");
     // 设置页面资源
     $this->_view->headStylesheet('/css/report/report.css');
     $this->_view->headStylesheet('/css/valid.css');
     $this->_view->headScript('/js/pagejs/buyreport.js');
 }
コード例 #24
0
 public function goodinfoAction()
 {
     $submit_statue = $this->getParam('statue');
     $gpj_session = new XF_Session("gpj_session");
     $session_ary = $gpj_session->read();
     if (!$gpj_session->hasContent("userId")) {
         throw new XF_Exception('补充商品信息:用户没有登录');
     }
     if (isset($submit_statue) && !XF_Functions::isEmpty($submit_statue)) {
         if ($submit_statue == "submit") {
             $car_parts = $this->getParam("car_parts");
             $car_color = $this->getParam("car_color");
             $period_insurance = $this->getParam("period_insurance");
             $car_maintain = $this->getParam("car_maintain");
             $max_cost = $this->getParam("max_cost");
             $transfer_num = $this->getParam("transfer_num");
             $sellObj = new Sell_Model_Sellinfo();
             $last_id = $sellObj->addSellInfo($session_ary["userId"], $session_ary["modelId"], $session_ary["changeId"], $session_ary["dataFrom"], $session_ary["infoId"], implode(",", $car_parts), $car_color, $period_insurance, $car_maintain, $max_cost, $transfer_num, $this->nowCity->id);
             if ($last_id) {
                 $session_ary["sellInfoId"] = $last_id;
                 $gpj_session->write($session_ary);
                 XF_Functions::go("/sell/index/upload/");
             }
         }
     } else {
         $submit_statue = "submit";
     }
     $this->setLayout(new Layout_Default());
     $this->_view->headStylesheet('/css/sell/goodinfo.css');
     $this->_view->headStylesheet('/css/common.css');
     $this->_view->headScript('/js/pagejs/goodinfo.js');
     XF_View::getInstance()->assign('statue', $submit_statue);
     $this->_view->detailModel = $session_ary["detail_model"];
     $this->_view->detailYear = $session_ary["detail_year"];
     $this->_view->detailMile = $session_ary["detail_mile"];
     $this->_view->detailPrice = $session_ary["detail_price"];
 }
コード例 #25
0
ファイル: Abstract.php プロジェクト: kevinwan/xf
 /**
  * 查询关联的数据
  * @access public
  * @param string $name 自定义关联名称
  * @param mixed $size 关联数量。默认为20,如果为false将关联所有数据[该设置仅在关联类型(oneToMany)为一对多时有效]
  * @param mixed $where 关联额外的字段查询条件。默认为NULL,可以是字符串或数组。
  * @param mixed $order 关联的数据的排序设置,默认为NULL,或例如:'id DESC'
  * @param string $field 关联的数据要查询的字段,默认为“*”,或例如:'id,name'
  * @return mixed
  */
 public function selectAssociated($name, $size = 20, $where = null, $order = null, $field = '*')
 {
     if (empty($this->_field_associateds[$name])) {
         return false;
     }
     ///////////兼容额外的设置 /////////////////
     if ($where == null && isset($this->_field_associateds[$name]['where'])) {
         $where = $this->_field_associateds[$name]['where'];
         //还原设置
         unset($this->_field_associateds[$name]['where']);
     }
     if ($order == null && isset($this->_field_associateds[$name]['order'])) {
         $order = $this->_field_associateds[$name]['order'];
         //还原设置
         unset($this->_field_associateds[$name]['order']);
     }
     if (isset($this->_field_associateds[$name]['size'])) {
         $size = $this->_field_associateds[$name]['size'];
         //还原设置
         unset($this->_field_associateds[$name]['size']);
     }
     if (isset($this->_field_associateds[$name]['_field'])) {
         $field = $this->_field_associateds[$name]['_field'];
         //还原设置
         unset($this->_field_associateds[$name]['_field']);
     }
     $tableName = $this->_field_associateds[$name]['table'];
     $table = new $tableName();
     /////检测是否需要设置当前关联对象自己的关联状态
     //if (is_array($this->_field_associateds) && count($this->_field_associateds) > 0)
     //{
     foreach ($this->_field_associateds as $_k => $_val) {
         if (isset($this->_field_associate_object_asssetting[$_k])) {
             $matchAssting = $this->_field_associate_object_asssetting[$_k];
             foreach ($matchAssting as $mk => $mval) {
                 if (get_class($table) == $mval['assObjectName']) {
                     if ($mval['autoAssociated'] == true) {
                         if (!empty($mval['where'])) {
                             $table->setAssociatedAuto($mk, $mval['size'], $mval['where'], $mval['order'], $mval['_field']);
                         } else {
                             $table->setAssociatedAutoOnly($mk, $mval['size'], $mval['_field']);
                         }
                     } elseif (!empty($mval['where'])) {
                         $table->setAssociatedManual($mk, $mval['size'], $mval['where'], $mval['order'], $mval['_field']);
                     } else {
                         $table->setAssociatedManualOnly($mk, $mval['size'], $mval['_field']);
                     }
                 }
             }
         }
     }
     //}
     /////2013-4-9 是否设置了当前关联对象自动执行方法
     $methods = $this->getInitAutoExecuteMethodFromAssociate($name);
     if (is_array($methods)) {
         foreach ($methods as $m) {
             if ($m['params'] !== NULL) {
                 array_unshift($m['params'], $m['method'], NULL);
                 call_user_func_array(array($table, 'addInitAutoExecuteMethod'), $m['params']);
             } else {
                 $table->addInitAutoExecuteMethod($m['method']);
             }
         }
     }
     //2013-1-9 实现一条关联可以设置多个字段,例如同时关联省份和城市,我们一般省份和城市记录都是在一个表里,结构都一样
     $fieldValues = null;
     $fieldNames = explode(',', $this->_field_associateds[$name]['field']);
     foreach ($fieldNames as $fieldName) {
         if (strpos($fieldName, ':') === 0) {
             $fieldName = substr($fieldName, 1);
         }
         $value = $this->{$fieldName};
         if (XF_Functions::isEmpty($value)) {
             continue;
         }
         $value = explode(',', $value);
         foreach ($value as $v) {
             if ($v != '' || $v == '0') {
                 $fieldValues[$v] = $v;
             }
         }
     }
     if (!is_array($fieldValues)) {
         return false;
     }
     $fieldValues = array_values($fieldValues);
     $select = $table->getTableSelect()->setFindField($field)->setWhereIn($this->_field_associateds[$name]['associateField'], $fieldValues);
     $select->appendWhere($where)->setOrder($order);
     //如果是一对多的查询
     if ($this->_field_associateds[$name]['oneToMany'] === true) {
         return $select->setLimit($size)->fetchAll();
     } elseif (count($fieldNames) > 1) {
         return $select->setLimit(count($fieldNames))->fetchAll();
     }
     return $select->fetchRow();
 }
コード例 #26
0
ファイル: Router.php プロジェクト: kevinwan/xf
 /**
  * 通过URL分析模块、控制器、动作名及参数列表
  * @access private
  * @return void
  */
 private function _start()
 {
     if ($this->_final_uri != '' && $this->_final_uri != '/' && $this->_final_uri != '/index.php') {
         $tmp = explode('/', $this->_final_uri);
         XF_Functions::arrayDeleteEmptyValue($tmp, TRUE);
         $count = count($tmp);
         $isDefaultModule = FALSE;
         $setController = false;
         $binds = $this->getAllBindModuleName();
         $domainModuleName = null;
         if (key_exists($this->_request_http_host, $this->_bin_domain)) {
             $domainModuleName = $this->_bin_domain[$this->_request_http_host];
         }
         if ($domainModuleName != null) {
             $isDefaultModule = TRUE;
             $this->_request->setModule($domainModuleName);
             //2013-10-17
             if ($count >= 1 && is_array($this->_bin_domain_allow_modules) && isset($this->_bin_domain_allow_modules[$domainModuleName]) && in_array($tmp[0], $this->_bin_domain_allow_modules[$domainModuleName])) {
                 //是否为自身当前绑定应用的控制器
                 if (!file_exists(APPLICATION_PATH . '/modules/' . $domainModuleName . '/' . ucfirst($tmp[0]) . 'Controller.php')) {
                     if (is_dir(APPLICATION_PATH . '/modules/' . $tmp[0])) {
                         $isDefaultModule = FALSE;
                         $this->_request->setModule($tmp[0]);
                     }
                 }
             }
         } elseif ($count == 1) {
             if (strtolower($tmp[0]) == 'index') {
                 throw new XF_Exception('Access denied', 404);
             }
             //是否为默认module中的控制器
             if (is_file(APPLICATION_PATH . '/controllers/' . ucfirst($tmp[0]) . 'Controller.php')) {
                 $setController = $isDefaultModule = TRUE;
                 $this->_request->setModule('default')->setController($tmp[0]);
             } elseif (is_dir(APPLICATION_PATH . '/modules/' . $tmp[0] . '/controllers/') && !in_array($tmp[0], $binds)) {
                 $this->_request->setModule($tmp[0]);
             } else {
                 $this->_request->setModule('unknown');
             }
             return;
         } else {
             //是否存在此Module
             if (isset($tmp[1]) && is_file(APPLICATION_PATH . '/modules/' . $tmp[0] . '/controllers/' . ucfirst($tmp[1]) . 'Controller.php') && !in_array($tmp[0], $binds)) {
                 $this->_request->setModule($tmp[0]);
             } else {
                 //是否为默module中的控制器(controller)
                 if (is_file(APPLICATION_PATH . '/controllers/' . ucfirst($tmp[0]) . 'Controller.php')) {
                     $setController = $isDefaultModule = TRUE;
                     $this->_request->setModule('default')->setController($tmp[0]);
                 } else {
                     $this->_request->setModule('unknown');
                 }
             }
         }
         $index = 0;
         if (!$isDefaultModule) {
             $index++;
         }
         if ($setController == false) {
             $this->_request->setController(isset($tmp[$index]) ? $tmp[$index] : 'index');
         }
         $this->_request->setAction(isset($tmp[$index + 1]) ? $tmp[$index + 1] : 'index');
         //分析参数列表
         if (isset($tmp[$index + 2])) {
             $params = array_slice($tmp, $index + 2);
             if ($this->_save_uri_value === true) {
                 for ($i = 0; $i < count($params); $i++) {
                     $this->_request->setParam('$' . ($i + 1), urldecode($params[$i]));
                 }
             } else {
                 for ($i = 0; $i <= count($params); $i += 2) {
                     if (isset($params[$i]) && !is_numeric($params[$i])) {
                         $this->_request->setParam($params[$i], isset($params[$i + 1]) ? urldecode($params[$i + 1]) : '');
                     }
                 }
             }
         }
     } else {
         $this->_setDefault();
     }
 }
コード例 #27
0
ファイル: fourshop.php プロジェクト: kevinwan/gongpingjiaPHP
?>
万公里</span>|<span>上牌城市:<?php 
echo $this->nowCity->name;
?>
</span></p>
                <p>新车指导价:<?php 
echo $this->detailPrice;
?>
万</p>
            </div>
		</div>

	</div>
	<div class="content">
        <?php 
if (!XF_Functions::isEmpty($this->changeModel)) {
    ?>
		<div class="selcar">已选择新车 “<?php 
    echo $this->changeModel;
    ?>
”</div>
        <?php 
}
?>
		<div class="boxtitle">请选择 4S店</div>
		<div class="fourshops clearfix">
            <?php 
$isClose = false;
foreach ($this->fourshop as $key => $dealer) {
    if ($key == "4") {
        $isClose = true;
コード例 #28
0
ファイル: Tool.php プロジェクト: kevinwan/xf
 /**
  * 查询指定的字段格式化
  * @access public
  * @param mixed $var 字符串或数组 
  * @return string
  */
 public static function findFormat($var)
 {
     if (XF_Functions::isEmpty($var)) {
         return '*';
     }
     if (!is_array($var)) {
         return $var;
     } else {
         $string = '';
         for ($i = 0; $i < count($var); $i++) {
             if ($i == 0) {
                 $string = '`' . $var[$i] . '`';
             } else {
                 $string .= ',`' . $var[$i] . '`';
             }
         }
         return $string;
     }
 }
コード例 #29
0
ファイル: Mysql.php プロジェクト: kevinwan/xf
 /**
  * 设置分组
  * @access public
  * @param unknown_type $var
  * @return XF_Db_Table_Select_Mysql
  */
 public function setGroup($var)
 {
     if (XF_Functions::isEmpty($var) == false) {
         //是否存在排序
         if (XF_Functions::isEmpty($this->_adv_order) == false) {
             $this->_adv_group = ' #GROUP BY ' . $var;
         } else {
             $this->_adv_group = ' GROUP BY ' . $var;
         }
     }
     return $this;
 }
コード例 #30
0
ファイル: DbTableSimple.php プロジェクト: kevinwan/xf
 /**
  * 认证
  * @return XF_Auth_Result
  */
 public function authenticate()
 {
     if ($this->_dbTable == NULL || !$this->_dbTable instanceof XF_Db_Table_Abstract) {
         throw new XF_Auth_Adapter_Exception('Lack of effective XF_Db_Table_Abstract authentication adapter !');
     }
     if (XF_Functions::isEmpty($this->_identity_column)) {
         throw new XF_Auth_Adapter_Exception('Certified identity column name and credential column name can not be empty!');
     }
     if (XF_Functions::isEmpty($this->_identity)) {
         return new XF_Auth_Result(-1, NULL);
     }
     $row = $this->_dbTable->getTableSelect()->setWhere(array($this->_identity_column => $this->_identity))->fetchRow();
     if ($row instanceof XF_Db_Table_Abstract) {
         $tmp = array();
         $array = $row->toArray();
         foreach ($array as $key => $val) {
             if (is_array($this->_storage_column)) {
                 if (in_array($key, $this->_storage_column)) {
                     $tmp[$key] = $val;
                 }
             } else {
                 $tmp[$key] = $val;
             }
         }
         return new XF_Auth_Result(9, (object) $tmp);
     }
     return new XF_Auth_Result(-1, NULL);
 }