view->fetch(); } public function detail($id = 0) { if ($id > 0) { /*$article = Loader::model('Article')->getRow($id); if (empty($article)) { return exception('数据有误,请检查后再操作'); } //$addarticle = Loader::model('ArticleAddition')->getRow(['aid' => $article['id']]); $category = Loader::model('ArticleCategory')->getRow($article['cid']); if (empty($category)) { return exception('数据有误,请检查后再操作'); } $template = $category['tempdetail']; //$prev_detail = Loader::model('Article')->getRow(['id' => ['gt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'asc']); //$next_detail = Loader::model('Article')->getRow(['id' => ['lt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'desc']); $value = [ 'detail' => $article, //'addarticle' => $addarticle, 'category' => $category, //'prev_detail' => $prev_detail, //'next_detail' => $next_detail, ]; //$topid = Loader::model('ArticleCategory')->getTopParentID($article['cid']); //$value['topid'] = $topid; $arg_where = ['content_id' => $id, 'stat' => 0, 'display' => 1]; $arg_order = ['id' => 'desc']; $arg_field = ['*']; $dataObject = Loader::model('Pinglun')->getPageList($arg_where, $arg_order, $arg_field, 5); //header('content-type:text/html;charset=utf-8;'); $value['list'] = $dataObject->isEmpty() ? null : $dataObject->items(); $value['total'] = $dataObject->total(); $value['seo_title'] = $article['seo_title']? : $article['name'] . '-' . config('website_seo_title'); $value['seo_keyword'] = $article['seo_keyword']? : config('website_seo_keyword'); $value['seo_description'] = $article['seo_description']? : config('website_seo_description'); $this->assign($value); $this->viewcount($id);*/ //return $this->fetch($template); return $this->fetch(); } else { return exception('数据有误,请检查后再操作'); } } protected function viewcount($id) { /*$view = Cookie::get('articleview', 'history'); //print_r($history);exit; if (empty($view) || $view != $id) { Loader::model('Article')->where(['id' => $id])->setInc('viewcount'); Cookie::set('articleview', $id, ['prefix' => 'history', 'expire' => 3600]); }*/ } protected function historyarticle($id) { /*$article = Cookie::get('article', 'history'); //print_r($history);exit; if (isset($article) && !empty($article)) { $article_ids = explode(',', $article); if ($article_ids[0] != $id) { array_unshift($article_ids, $id); $article_ids = array_unique($article_ids); $num = Config::get('history_number') > 0 ? Config::get('history_number') : 10; //$article_ids = array_slice($article_ids, 0, $num); while (count($article_ids) > $num) { array_pop($article_ids); } Cookie::set('article', implode(',', $article_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]); } } else { Cookie::set('article', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]); }*/ } public function create() { $data = $this->request->post(); if (empty($data) || !is_array($data)) return $this->json(403, 'Data error '); if ($data['company'] == '') return $this->json(403-2, 'Company name cannot be empty'); /*if ($data['name'] == '' && $data['last_name']) return $this->json(403-3, 'Your name cannot be empty');*/ if ($data['email'] == '') return $this->json(403-4, 'Email cannot be empty'); /*if ($data['country'] == '') return $this->json(403-5, 'Distribution region cannot be empty');*/ if ($data['business_type'] == '') return $this->json(403-6, 'Business type cannot be empty'); if ($data['enterprise_size'] == '') return $this->json(403-7, 'Enterprise size cannot be empty'); if ($data['phone'] == '') return $this->json(403-8, 'Phone cannot be empty'); // if ($data['buy_source'] == '') // return $this->json(-5, '购买渠道不能为空'); /*if ($data['customer_telephone'] != '' && !preg_match("/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/", $data['customer_telephone'])) return $this->json(-6, 'Phone format error ');*/ if ($data['email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['email'])) return $this->json(403-6, 'Email Address format error'); $referer = isset($data['refer']) ? $data['refer'] : ''; $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $searchFeed = getKeywords($referer); $channel = isset($searchFeed['channel']) ? $searchFeed['channel'] : ''; $keyword = isset($searchFeed['search']) ? $searchFeed['search'] : ''; $fed = visitLog(); $insert_data = [ 'company' => $data['company'], 'uri' => $data['uri'], 'name' => isset($data['name']) ? $data['name'] : '', 'last_name' => isset($data['last_name']) ? $data['last_name'] : '', 'email' => $data['email'], 'phone' => trim($data['phone']), 'country' => isset($data['country']) ? $data['country'] : '', 'message' => isset($data['message']) ? $data['message'] : '', 'interest' => isset($data['interested']) ? $data['interested'] : $data['message'], 'is_inventory' => isset($data['is_inventory']) ? $data['is_inventory'] : '', 'createtime' => date("Y-m-d H:i:s"), 'siteid' => $this->siteid, 'country_code' => $this->country_code, 'refer' => $referer, 'url' => $url, 'channel' => $channel, 'keyword' => $keyword, 'ip' => $fed['ip'], 'state' => $fed['country'], 'province' => $fed['province'], 'city' => $fed['city'], 'drvice' => $fed['drive'], 'user_agent' => $fed['system']." ".$fed['brower'], 'refer' => $referer, 'url' => $url, 'channel' => $channel, 'keyword' => $keyword, 'ip' => $fed['ip'], 'state' => $fed['country'], 'province' => $fed['province'], 'city' => $fed['city'], 'drvice' => $fed['drive'], 'user_agent' => $fed['system']." ".$fed['brower'], ]; $result = model('agents')->insert($insert_data); if (!$result) return $this->json(201, 'Failure to submit'); return $this->json(200, 'ok'); } }