This commit is contained in:
2024-10-29 14:04:59 +08:00
commit 48bf3e6f33
2839 changed files with 762707 additions and 0 deletions

186
app/index/controller/Ad.php Executable file
View File

@@ -0,0 +1,186 @@
<?php
namespace app\index\controller;
use think\Lang;
use think\Loader;
use think\Config;
use app\common\controller\BaseController;
class Ad extends BaseController {
private $country_code = 'ZH';
public function tags($tags = '', $num = 1) {
if ($tags) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adzh-' . md5($tags);
$htmlbody = $nocache ? '' : $this->cacheGet($cacheTag);
if (empty($htmlbody)) {
$list = Loader::model('Ad')->getList(['stat' => 0, 'tags' => $tags, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'desc'], ['id', 'typeid', 'name', 'sort', 'tags', 'timeset', 'starttime', 'endtime', 'normbody', 'expbody'], $num);
if (empty($list)) {
$this->cacheTag('adTagZh')->set($cacheTag, "<!--\r\ndocument.write(\"<!--403-->\");\r\n-->\r\n");
exit;
}
$htmlbody = '';
$expire = 3600;
foreach ($list as $row) {
$adbody = '';
if ($row['timeset'] == 0) {
$adbody = $row['normbody'];
$exp = 0;
} else {
$ntime = time();
if ($ntime > $row['endtime'] || $ntime < $row['starttime']) {
$adbody = $row['expbody'];
$exp = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0;
} else {
$adbody = $row['normbody'];
$exp = $row['endtime'] - $ntime;
}
}
$expire = $exp > 0 && $exp < $expire ? $exp : $expire;
$adbody = str_replace('"', '\"', $adbody);
$adbody = str_replace("\r", "\\r", $adbody);
$adbody = str_replace("\n", "\\n", $adbody);
$htmlbody .= "<!--\r\ndocument.write(\"{$adbody}\");\r\n-->\r\n";
//print_r($htmlbody);exit;
}
$this->cacheTag('adTagZh')->set($cacheTag, $htmlbody, $expire);
}
echo $htmlbody;
exit;
}
exit(' Error! ');
}
public function tagsli($tags = '', $num = 1) {
if ($tags) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adzh-' . md5($tags);
$htmlbody = $nocache == false ? '' : $this->cacheGet($cacheTag);
if (empty($htmlbody)) {
$list = Loader::model('Ad')->getList(['stat' => 0, 'tags' => $tags, 'typeid' => 5, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'desc'], ['id', 'typeid', 'name', 'sort', 'tags', 'timeset', 'starttime', 'endtime', 'normbody', 'expbody'], $num);
if (empty($list)) {
$this->cacheTag('adTagZh')->set($cacheTag, "<!--\r\ndocument.write(\"<!--405-->\");\r\n-->\r\n");
exit;
}
$htmlbody = '';
$expire = 3600;
foreach ($list as $k => $row) {
$adbody = '';
if ($row['timeset'] == 0) {
$adbody = $row['normbody'];
$exp = 0;
} else {
$ntime = time();
if ($ntime > $row['endtime'] || $ntime < $row['starttime']) {
$adbody = $row['expbody'];
$exp = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0;
} else {
$adbody = $row['normbody'];
$exp = $row['endtime'] - $ntime;
}
}
$expire = $exp > 0 && $exp < $expire ? $exp : $expire;
$adbody = str_replace('"', '\"', $adbody);
$adbody = str_replace("\r", "\\r", $adbody);
$adbody = str_replace("\n", "\\n", $adbody);
$htmlbody .= "<!--\r\ndocument.write(\"<li class=\\\"li" . ($k + 2) . "\\\">{$adbody}</li>\");\r\n-->\r\n";
}
$this->cacheTag('adTagZh')->set($cacheTag, $htmlbody, $expire);
}
echo $htmlbody;
exit;
}
exit(' Error! ');
}
public function index($id = 0) {
if ($id > 0) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adzh-' . $id;
$adbody = $nocache ? '' : $this->cacheGet($cacheTag);
if (empty($adbody)) {
$row = Loader::model('Ad')->where(['stat' => ['eq', 0], 'id' => $id, 'country_code' => $this->country_code])->find();
if (empty($row)) {
$this->cacheTag('adTagZh')->set($cacheTag, "<!--\r\ndocument.write(\"<!--406-->\");\r\n-->\r\n");
exit;
}
$adbody = '';
if ($row['timeset'] == 0) {
$adbody = $row['normbody'];
$expire = 0;
} else {
$ntime = time();
if ($ntime > $row['endtime'] || $ntime < $row['starttime']) {
$adbody = $row['expbody'];
$expire = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0;
} else {
$adbody = $row['normbody'];
$expire = $row['endtime'] - $ntime;
}
}
$adbody = str_replace('"', '\"', $adbody);
$adbody = str_replace("\r", "\\r", $adbody);
$adbody = str_replace("\n", "\\n", $adbody);
$adbody = "<!--\r\ndocument.write(\"{$adbody}\");\r\n-->\r\n";
$this->cacheTag('adTagZh')->set($cacheTag, $adbody, $expire);
}
echo $adbody;
exit;
}
exit(' Error! ');
}
public function cat($id = '', $num = 1) {
if ($id) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adzh-' . $id;
$htmlbody = $nocache ? '' : $this->cacheGet($cacheTag);
if (empty($htmlbody)) {
$list = Loader::model('Ad')->getList(['stat' => ['eq', 0], 'typeid' => $id, 'country_code'], ['sort' => 'asc', 'id' => 'desc'], ['id', 'typeid', 'name', 'sort', 'tags', 'timeset', 'starttime', 'endtime', 'normbody', 'expbody'], $num);
if (empty($list)) {
$this->cacheTag('adTagZh')->set($cacheTag, "<!--\r\ndocument.write(\"<!--407-->\");\r\n-->\r\n");
exit;
}
$htmlbody = '';
$expire = 3600;
foreach ($list as $row) {
$adbody = '';
if ($row['timeset'] == 0) {
$adbody = $row['normbody'];
$exp = 0;
} else {
$ntime = time();
if ($ntime > $row['endtime'] || $ntime < $row['starttime']) {
$adbody = $row['expbody'];
$exp = $ntime < $row['starttime'] ? $row['starttime'] - $ntime : 0;
} else {
$adbody = $row['normbody'];
$exp = $row['endtime'] - $ntime;
}
}
$expire = $exp > 0 && $exp < $expire ? $exp : $expire;
$adbody = str_replace('"', '\"', $adbody);
$adbody = str_replace("\r", "\\r", $adbody);
$adbody = str_replace("\n", "\\n", $adbody);
$htmlbody .= "<!--\r\ndocument.write(\"{$adbody}\");\r\n-->\r\n";
}
$this->cacheTag('adTagZh')->set($cacheTag, $htmlbody, $expire);
}
echo $htmlbody;
exit;
}
exit(' Error! ');
}
public function previewjs($id) {
$id = intval($id);
if ($id > 0) {
echo '<script src="' . url('index/ad/index', ['id' => $id]) . '?nocache=1" language="javascript"></script>';
}
exit();
}
}

137
app/index/controller/Antifake.php Executable file
View File

@@ -0,0 +1,137 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-07-23
* Time: 15:40
*/
namespace app\index\controller;
use think\Loader;
class Antifake extends BaseController
{
public function index()
{
$this->redirect("https://anti-fake-checking.com/index");
return $this->view->fetch();
}
public function sn_result()
{
if ($_POST) {
$post = $this->request->post();
//$this->verify_check($post['captcha'], 'authcode') || $this->error('验证码有误', url('antifake/index'));
$snnum = $post['sn'];
$snnum = str_replace('-','',$snnum);
$ssd = Loader::model('Ssd');
$where = ['sn' => $post['sn']];
$arr = $ssd->where($where)->find();
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$this->assign('data', $data);
} else {
$postdata = ['sn'=>$snnum];
$postdata = http_build_query($postdata);
$sn = CurlRequest('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $postdata);
$sn = json_decode($sn, true);
if ($sn['result'] == 1) {
$data['sn'] = $post['sn'];
$data['fake'] = '';
$data['specifications_and_models'] = $sn['specifications_and_models'];
$data['69_code'] = $sn['69_code'];
$data['production_date'] = $sn['production_date'];
$data['Customer_name'] = $sn['Customer_name'];
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
}
//$data['department'] = $sn['B2B_B2C'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
//$time = strtotime($data['delivery_time']);
// $data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
//if($data['department']=='B2B'){
//$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+1 month",strtotime($data['mendtime'])));
//}
$data['material_ID'] = $sn['material_ID'];
$where = ['sku'=>$data['specifications_and_models']];
$productid = Loader::model('ProductSku')->where($where)->find();
$img = Loader::model('product_two_img')->where(['product_id'=>$productid['product_id']])->find();
$img = $img['image_url'];
$data['img']=$img;
$add = $ssd->save($data);
$data['result'] = $sn['result'];
$this->assign('data',$data);
} else {
$data['sn']=$snnum;
$data['result'] = $sn['result'];
$this->assign('data',$data);
}
}
}
return $this->fetch();
}
public function anti_fake_result()
{
if ($_POST) {
$post = $this->request->post();
//$verify = $this->verify_check($post['captcha'], 'authcode'); || $this->error('验证码有误', url('antifake/index'));
$fake = $post['fake'];
$ssd = Loader::model('Ssd');
$where = ['fake' => $fake];
$arr = $ssd->where($where)->find();
//echo "<pre>=="; print_r($post); die;
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$this->assign('data', $data);
} else {
$postdata = ['fwm'=>$fake];
$postdata = http_build_query($postdata);
$sn = CurlRequest('http://mes.orico.com.cn:8081/content/mes/web/api/fwm.aspx', $postdata);
$sn = json_decode($sn, true);
if ($sn['result'] == 1) {
$data['sn'] = $sn['serial_number'];
$data['fake'] = $fake;
$data['specifications_and_models'] = $sn['specifications_and_models'];
$data['69_code'] = $sn['69_code'];
$data['production_date'] = $sn['production_date'];
$data['Customer_name'] = $sn['Customer_name'];
$data['delivery_time'] = $sn['delivery_time'];
//$data['department'] = $sn['B2B_B2C'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
$data['chicktime'] = date("Y-m-d H:i:s");
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
//if($data['department']=='B2B'){
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+1 month",strtotime($data['mendtime'])));
// }
$data['material_ID'] = $sn['material_ID'];
$where = ['sku'=>$data['specifications_and_models']];
$productid = Loader::model('product_sku')->where($where)->find();
$img = Loader::model('product_two_img')->where(['product_id'=>$productid['product_id']])->find();
$img = $img['image_url'];
$data['img']=$img;
$add = $ssd->save($data);
$data['result'] = $sn['result'];
$this->assign('data',$data);
} else {
$data['fake']=$fake;
$data['result'] = $sn['result'];
$this->assign('data',$data);
}
}
}
return $this->fetch();
}
}

222
app/index/controller/Article.php Executable file
View File

@@ -0,0 +1,222 @@
<?php
namespace app\index\controller;
use think\Loader;
use think\Cookie;
use think\Config;
class Article extends BaseController {
public function lists() {
$arg_where = ['a.siteid' => $this->siteid, 'country_code' => $this->country_code];
$arg_order = ['a.id' => 'desc'];
$search = array();
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
if ($skeyword != '') {
$search['skeyword'] = $skeyword;
$arg_where['a.name'] =['like', '%' . $search['skeyword'] . '%'];
$search['name'] = $search['skeyword'];
}
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.jump_link', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.writer', 'a.source', 'a.viewcount', 'a.zancount', 'a.commentcount', 'a.description', 'a.picture', 'a.tags', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = Loader::model('Article')->getCateArticleLists($arg_where, $arg_order, $arg_field, 12);
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
'category' => ['id' => 0, 'name' => '新闻资讯'],
];
$cate_list = model('article_category')->where(['country_code' => $this->country_code, 'pid' => 0, 'isshow' => 1, 'stat' => 0])->order(['sort' => 'asc'])->select();
$value['cate_list'] = $cate_list;
$value['seo_title'] = config('article_seo_title')? : config('website_seo_title');
$value['seo_keyword'] = config('article_seo_keyword')? : config('website_seo_keyword');
$value['seo_description'] = config('article_seo_description')? : config('website_seo_description');
$this->assign($value);
$this->assign('search',$search);
return $this->fetch();
}
public function catelists($id = 0) {
if ($id > 0) {
$category = Loader::model('ArticleCategory')->getRow($id);
}
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$arg_where = ['cid' => $id, 'a.country_code' => $this->country_code];
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
if ($skeyword != '') {
$skeyword = trim($skeyword);
$search['skeyword'] = $skeyword;
$arg_where['a.name'] = ['like', '%' . $search['skeyword'] . '%'];
Config::set('paginate.query', ['skeyword' => $skeyword]); //分页参数
$value['search'] = $search;
}
switch ($category['classtype']) {
case 2:
$template = $category['templist'];
$arg_order = ['a.createtime' => 'desc'];
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.jump_link', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.writer', 'a.source', 'a.viewcount', 'a.zancount', 'a.commentcount', 'a.description', 'a.picture', 'a.tags', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = Loader::model('Article')->getCateArticleLists($arg_where, $arg_order, $arg_field, 12);
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
];
break;
case 3:
header('location:' . $category['url']);
exit;
break;
default:
$template = $category['tempindex'];
break;
}
$cate_list = model('article_category')->where(['country_code' => $this->country_code, 'pid' => 0, 'isshow' => 1, 'stat' => 0])->order(['sort' => 'asc'])->select();
$value['cate_list'] = $cate_list;
$value['category'] = $category;
$value['seo_title'] = $category['seo_title']? : config('website_seo_title');
$value['seo_keyword'] = $category['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $category['seo_description']? : config('website_seo_description');
$this->assign($value);
return $this->fetch($template);
}
public function detail($id = 0) {
if ($id > 0) {
//$jssdk=new \JsSdk\JsSdk('wx0d4ac6d59abca442','8103022bb6ed902eb5c685800a78fd51');
//$signPackage = $jssdk->getSignPackage();
//$this->assign('singpackage',$signPackage);
$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 = ['createtime' => '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);
} else {
return exception('数据有误,请检查后再操作');
}
}
public function zan($id = 0) {
$id = intval($id);
if ($id > 0) {
$article = Loader::model('Article')->getRow(['id' => $id], ['id', 'zancount']);
if (empty($article)) {
return $this->error('Error');
}
$article['zancount'] = $article['zancount'] + 1;
$result = $article->save();
if ($result) {
return $this->success('Zan', null, $article['zancount']);
} else {
return $this->error('Zan Error');
}
}
return $this->error('Error');
}
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]);
}
}
//添加留言 2024-03-01 Martin
public function addcomment()
{
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(403, 'Data error ');
if (trim($data['name']) == '')
return $this->json(403-2, 'Name cannot be empty');
if (trim($data['email']) == '')
return $this->json(403-4, 'Email cannot be empty');
if (trim($data['comment']) == '')
return $this->json(403-5, 'Comment 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');
$insert_data = [
'article_id' => trim($data['article_id']),
'name' => trim($data['name']),
'email' => trim($data['email']),
'content' => trim($data['comment']),
'add_time' => date("Y-m-d H:i:s",time()),
'siteid' => $this->siteid,
'country_code' => $this->country_code,
];
$result = model('article_comment')->insert($insert_data);
if (!$result)
return $this->json(201, 'Failure to submit');
return $this->json(200, 'ok');
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace app\index\controller;
use think\Lang;
use think\Loader;
use think\Config;
use app\common\controller\BaseController;
class Authcode extends BaseController {
public function index($id = "") {
$verify = new \verify\Verify((array) Config::get('captcha'));
return $verify->entry($id);
}
/**
* 验证码
*/
public function check($code, $id = '') {
return $this->verify_check($code, $id);
}
/**
* 验证码
*/
public function verify($id = '') {
return $this->verify_build($id);
}
}

View File

@@ -0,0 +1,332 @@
<?php
namespace app\index\controller;
use think\Lang;
use think\Loader;
use think\Config;
use think\Session;
use think\Cookie;
use app\common\controller\BaseController as Controller;
//<!--#include file="([0-9a-zA-Z/._-]+?)\.html" -->
class BaseController extends Controller {
//当前用户
protected $customer_id = 0;
# 当前国家编码
protected $country_code = 'ZH';
public function __construct() {
parent::__construct();
}
// 初始化
protected function _initialize() {
parent::_initialize();
if ($this->check_true_login())
{
$customer_info = json_decode(Cookie::get('c'), true);
$this->view->assign('customer_info', $customer_info);
$this->customer_id = $customer_info['id'];
$this->customer_info = $customer_info;
}
else
{
$this->_logout();
}
$this->view->assign('seo_title', (string) Config::get('website_seo_title'));
$this->view->assign('seo_keyword', (string) Config::get('website_seo_keyword'));
$this->view->assign('seo_description', (string) Config::get('website_seo_description'));
// $this->categoryList = $this->cacheGet('productCategoryList');
if (empty($this->productCategory)) {
$this->categoryList = Loader::model('ProductCategory')->getList(['stat' => 0, 'siteid' => $this->siteid,'isshow'=>1, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'asc'], ['id', 'pid', 'haschild', 'name', 'shortname', 'sort', 'description', 'isshow', 'recommend', 'picture', 'icon', 'image', 'm_icon', 'unique_id']);
$this->cacheTag('ProductCategoryTag')->set('productCategoryList', $this->categoryList);
}
$this->productCategory = $this->list_to_tree($this->categoryList);
// tiaoshi($this->productCategory[0]['child'][0]['child']);die;
if ($this->cacheHas('country_list')) {
$this->country_list = $this->cacheGet('country_list');
} else {
$this->country_list = model('country')->where(['stat' => 0])->order(['sort' => 'asc'])->select();
$this->cacheSet('country_list', $this->country_list, 3600);
}
//搜索推荐产品
$search_views = Loader::model('Product')->where(['stat' => 0, 'siteid' => $this->siteid,'is_show'=>0, 'country_code' => $this->country_code])->limit(3)->order(['sort' => 'asc'])->select();
$this->view->assign('popular_list', $search_views);
//$historyList = getBannerList(79, 5);
$historyList = Loader::model('banner')->getList(['typeid'=>100,'stat' => 0, 'country_code' => COUNTRY_CODE], ['sort' => 'asc', 'id' => 'desc'], array('*'), 3);
$this->view->assign('historyList', $historyList);
$website_email = (string) Config::get('website_email');
$this->view->assign('website_email', $website_email);
$website_phone = (string) Config::get('website_phone');
$this->view->assign('website_phone', $website_phone);
//导航
$navigation =self::navInit();
$this->nav_header = $navigation['header'];
$this->nav_footer = $navigation['footer'];
$this->assign('nav_header', $this->nav_header);
$this->assign('nav_footer', $this->nav_footer);
$product_country_code = "products_".strtolower($this->country_code)."_color";
$productColor = config($product_country_code);
$this->view->assign('productColor', $productColor);
//echo $product_country_code."<pre>=="; print_r($productColor);die;
$this->view->assign('country_list', $this->country_list);
$this->view->assign('productCategory', $this->productCategory);
$this->view->assign('allCategoryList', $this->categoryList);
}
protected function buildTree($data, $pid = 0)
{
$tree = [];
foreach ($data as $val) {
if ($val['pid'] == $pid) {
$children = $this->buildTree($data, $val['id']);
if (!empty($children)) {
$val['items'] = $children;
}
$tree[] = $val;
}
}
return $tree;
}
/**
* nasNavigation 获取并组装nas专题页的top导航和footer
*/
protected function nasNavigation()
{
$navs = Loader::model('Navigation')->field([
'id',
'pid',
'name',
'url',
'value',
'data_type',
'is_new_window_open',
])
->where('stat', '=', 0)
->where('nav_type', '=', 'tops_nas_header')
->where('country_code', '=', $this->country_code)
->order('sort')
->select();
$navs_array = collection($navs)->toArray();
$header = $this->NavDataDealWith($navs_array);
$this->assign('nav_header', $this->buildTree($header));
}
//导航初始化
private function navInit(){
// 读取缓存数据
//$header = $this->cacheGet('cache_common_nav_header_key');
//$footer = $this->cacheGet('cache_common_nav_footer_key');
// 导航模型
$field = array('id', 'pid', 'name', 'url', 'value', 'data_type', 'is_new_window_open');
// 缓存没数据则从数据库重新读取,顶部菜单
//if(empty($header))
//{
$headerData = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'header', 'stat'=>0, 'pid'=>0, 'country_code' => $this->country_code))->order('sort')->select();
$header = self::navDataDealWith($headerData);
if(!empty($header))
{
foreach($header as &$v)
{
$childData = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'header', 'stat'=>0, 'pid'=>$v['id'], 'country_code' => $this->country_code))->order('sort')->select();
$v['items'] = self::navDataDealWith($childData);
}
}
//$this->cacheSet('cache_common_nav_header_key', $header, 3600);
//}
// 底部导航
//if(empty($footer))
//{
$footerdata = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'footer', 'stat'=>0, 'pid'=>0, 'country_code' => $this->country_code))->order('sort')->select();
$footer = self::navDataDealWith($footerdata);
if(!empty($footer))
{
foreach($footer as &$v)
{
$childData = Loader::model('Navigation')->field($field)->where(array('nav_type'=>'footer', 'stat'=>0, 'pid'=>$v['id'], 'country_code' => $this->country_code))->order('sort')->select();
$v['items'] = self::navDataDealWith($childData);
}
}
//$this->cacheSet('cache_common_nav_footer_key', $footer, 3600);
//}
return [
'header' => $header,
'footer' => $footer,
];
}
/**
* [NavDataDealWith 导航数据处理]
* @author martin
* @version 0.0.1
* @datetime 2023-11-23T21:36:46+0800
* @param [array] $data [需要处理的数据]
* @return [array] [处理好的数据]
*/
public function NavDataDealWith($data)
{
if(!empty($data) && is_array($data))
{
foreach($data as $k=>&$v)
{
// url处理
switch($v['data_type'])
{
// 文章分类
case 'article':
$v['url'] = 'article/detail/'.$v['value'].'.html';
break;
// 博客
case 'blog':
$v['url'] = 'index/blog/detail/id/'.$v['value'].'.html';
break;
// 商品分类
case 'goods_category':
$category = Loader::model('ProductCategory')->getRow(['stat' => 0, 'id' => $v['value'], 'country_code' => $this->country_code], null, ['id' => 'asc']);
//echo $category['pid']."<pre>=="; print_r($category);
if($category['pid'] == 0) {
$v['url'] = 'product/catelists/'.$v['value'].'.html';
}
else{
$v['url'] = 'product/subcategory/'.$v['value'].'.html';
}
break;
}
$data[$k] = $v;
}
}
return $data;
}
/**
* 节点遍历
* @param $list
* @param string $pk
* @param string $pid
* @param string $child
* @param int $root
* return array
*/
protected function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = 'child', $root = 0) {
//header('content-type:text/html;charset=utf-8;');
// 创建Tree
$tree = [];
if (is_array($list)) {
// 创建基于主键的数组引用
$refer = [];
foreach ($list as $key => $data) {
$list[$key] = $data->toArray();
$refer[$data[$pk]] = & $list[$key];
}
foreach ($list as $key => $data) {
// 判断是否存在parent
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[] = & $list[$key];
} else {
if (isset($refer[$parentId])) {
$parent = & $refer[$parentId];
$parent[$child][] = & $list[$key];
}
}
}
}
return $tree;
}
private function check_login_token($customer_id, $curr_time, $p)
{
$expire = 86400 * 30;
if (time() - $curr_time > $expire)
return false;
$temp_p = $this->make_pwd($customer_id, $curr_time);
if ($temp_p !== $p)
{
return false;
}
return true;
}
protected function set_login_token($customer_info)
{
$curr_time = time();
$p = $this->make_pwd($customer_info['id'], $curr_time);
$customer_info['telephone'] = $customer_info['telephone'] != '' ? substr_replace($customer_info['telephone'], '****', 3, 4) : '';
$customer_info['email'] = $customer_info['email'] != '' ? substr_replace($customer_info['email'], '****', 2, 6) : '';
$customer_info['have_pwd'] = $customer_info['password'] != '' ? 1 : 0;
unset($customer_info['password']);
$customer_info['ct'] = $curr_time;
$customer_info['p'] = $p;
$expire = 86400 * 30;
Cookie::init(['expire' => $expire]);
Cookie::set('c', $customer_info);
}
private function make_pwd($customer_id, $curr_time)
{
$salt = 'Orico2019.';
$p = md5(md5($customer_id . $curr_time . $salt));
return $p;
}
private function check_login()
{
return Cookie::has('c');
}
protected function check_true_login()
{
// 校验用户是否登录,且校验cookie合法性
if (!$this->check_login())
{
return false;
}
$customer_info = json_decode(Cookie::get('c'), true);
$ct = isset($customer_info['ct']) ? $customer_info['ct'] : '';
$p = isset($customer_info['p']) ? $customer_info['p'] : '';
return $this->check_login_token($customer_info['id'], $ct, $p);
}
protected function _logout()
{
if (Cookie::has('c'))
Cookie::delete('c');
$this->customer_id = 0;
}
}

View File

@@ -0,0 +1,168 @@
<?php
namespace app\index\controller;
use think\Lang;
use think\Loader;
use think\Config;
use think\Session;
use think\Cookie;
use app\common\controller\BaseController as Controller;
//<!--#include file="([0-9a-zA-Z/._-]+?)\.html" -->
class BaseController extends Controller {
//当前用户
protected $customer_id = 0;
# 当前国家编码
protected $country_code = 'ZH';
public function __construct() {
parent::__construct();
}
// 初始化
protected function _initialize() {
parent::_initialize();
if ($this->check_true_login())
{
$customer_info = json_decode(Cookie::get('c'), true);
$this->view->assign('customer_info', $customer_info);
$this->customer_id = $customer_info['id'];
$this->customer_info = $customer_info;
}
else
{
$this->_logout();
}
$this->view->assign('seo_title', (string) Config::get('website_seo_title'));
$this->view->assign('seo_keyword', (string) Config::get('website_seo_keyword'));
$this->view->assign('seo_description', (string) Config::get('website_seo_description'));
// $this->categoryList = $this->cacheGet('productCategoryList');
if (empty($this->productCategory)) {
$this->categoryList = Loader::model('ProductCategory')->getList(['stat' => 0, 'siteid' => $this->siteid,'isshow'=>1, 'country_code' => $this->country_code], ['sort' => 'asc', 'id' => 'asc'], ['id', 'pid', 'haschild', 'name', 'shortname', 'sort', 'description', 'isshow', 'recommend', 'picture', 'icon', 'image', 'unique_id']);
$this->cacheTag('ProductCategoryTag')->set('productCategoryList', $this->categoryList);
}
$this->productCategory = $this->list_to_tree($this->categoryList);
if ($this->cacheHas('country_list')) {
$this->country_list = $this->cacheGet('country_list');
} else {
$this->country_list = model('country')->where(['stat' => 0])->order(['sort' => 'asc'])->select();
$this->cacheSet('country_list', $this->country_list, 3600);
}
$this->view->assign('country_list', $this->country_list);
$this->view->assign('productCategory', $this->productCategory);
$this->view->assign('allCategoryList', $this->categoryList);
}
/**
* 节点遍历
* @param $list
* @param string $pk
* @param string $pid
* @param string $child
* @param int $root
* return array
*/
protected function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = 'child', $root = 0) {
//header('content-type:text/html;charset=utf-8;');
// 创建Tree
$tree = [];
if (is_array($list)) {
// 创建基于主键的数组引用
$refer = [];
foreach ($list as $key => $data) {
$list[$key] = $data->toArray();
$refer[$data[$pk]] = & $list[$key];
}
foreach ($list as $key => $data) {
// 判断是否存在parent
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[] = & $list[$key];
} else {
if (isset($refer[$parentId])) {
$parent = & $refer[$parentId];
$parent[$child][] = & $list[$key];
}
}
}
}
return $tree;
}
private function check_login_token($customer_id, $curr_time, $p)
{
// 校验登录的合法性
$tmp_p = $this->make_pwd($customer_id, $curr_time);
if ($tmp_p !== $p)
{
return false;
}
return true;
}
protected function set_login_token($customer_info)
{
$curr_time = time();
$p = $this->make_pwd($customer_info['id'], $curr_time);
$expire = 86400 * 30;
Cookie::init(['expire' => $expire]);
Cookie::set('p', $p);
Cookie::set('c', $customer_info);
Cookie::set('ct', $curr_time);
return;
}
private function make_pwd($customer_id, $curr_time)
{
$salt = 'Orico2019.';
$p = md5(md5($customer_id . $curr_time . $salt));
return $p;
}
private function check_login()
{
// 有cookie默认为已登录, 不校验cookie的合法性
return Cookie::has('p') && Cookie::has('c') && Cookie::has('ct');
}
protected function check_true_login()
{
// 校验用户是否登录,且校验cookie合法性
if (!$this->check_login())
{
$this->_logout();
return false;
}
$customer_info = json_decode(Cookie::get('c'), true);
$curr_time = Cookie::get('ct');
$p = Cookie::get('p');
return $this->check_login_token($customer_info['id'], $curr_time, $p);
}
protected function _logout()
{
if (Cookie::has('p'))
Cookie::delete('p');
if (Cookie::has('c'))
Cookie::delete('c');
if (Cookie::has('ct'))
Cookie::delete('ct');
$this->customer_id = 0;
return;
}
}

221
app/index/controller/Blog.php Executable file
View File

@@ -0,0 +1,221 @@
<?php
namespace app\index\controller;
use think\Loader;
use think\Cookie;
use think\Config;
use think\Db;
class Blog extends BaseController {
public function index() {
$data = $this->request->param();
$arg_where = ['siteid' => $this->siteid,'stat' => 1, 'country_code' => $this->country_code,'public_time'=>['<=',date("Y-m-d")]];
$search = array();
if (isset($data['name']) && $data['name'] != ''){
$arg_where['title'] = ['like', "%$data[name]%"];
$search['name'] = $data['name'];
}
$arg_order = ['is_top'=>'desc','id' => 'desc'];
$arg_field = ['*'];
$dataObject = Loader::model('blog')->getBlogLists($arg_where, $arg_order, $arg_field, 12);
//echo Loader::model('blog')->getLastsql();
//echo "<pre>====22222222======"; print_r($dataObject);die;
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
];
$value['seo_title'] = config('article_seo_title')? : config('website_seo_title_us');
$value['seo_keyword'] = config('article_seo_keyword')? : config('website_seo_keyword');
$value['seo_description'] = config('article_seo_description')? : config('website_seo_description');
$this->assign($value);
$this->assign('search',$search);
return $this->fetch();
}
public function blog() {
$data = $this->request->param();
$arg_where = ['siteid' => $this->siteid,'stat' => 1, 'country_code' => $this->country_code,'public_time'=>['<=',date("Y-m-d")]];
$search = array();
if (isset($data['name']) && $data['name'] != ''){
$arg_where['title'] = ['like', "%$data[name]%"];
$search['name'] = $data['name'];
}
$arg_order = ['is_top'=>'desc','id' => 'desc'];
$arg_field = ['*'];
$dataObject = Loader::model('blog')->getBlogLists($arg_where, $arg_order, $arg_field, 12);
//echo Loader::model('blog')->getLastsql();
//echo "<pre>====22222222======"; print_r($dataObject);die;
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
];
$value['seo_title'] = config('article_seo_title')? : config('website_seo_title_us');
$value['seo_keyword'] = config('article_seo_keyword')? : config('website_seo_keyword');
$value['seo_description'] = config('article_seo_description')? : config('website_seo_description');
$this->assign($value);
$this->assign('search',$search);
return $this->fetch();
}
public function detail($id = 0) {
if ($id > 0) {
$blog = Loader::model('Blog')->getRow($id);
if (empty($blog)) {
return exception('数据有误,请检查后再操作');
}
//echo "<pre>====6666======".$id; print_r($blog); die;
$arg_where = ['blog_remark.b_id' => $id, 'blog_remark.stat' => 1];
$arg_order = ['blog_remark.id' => 'desc'];
$arg_field = ['blog_remark.*'];
$dataObject = Loader::model('blog')->getRemarkList($arg_where, $arg_order, $arg_field, 10);
$value['list'] = $dataObject->isEmpty() ? null : $dataObject->items();
$value['total'] = $dataObject->total();
$value['page'] = $dataObject->render();
$value['seo_title'] = $blog['seo_title']? : $blog['title'] . '-' . config('website_seo_title');
$value['seo_keyword'] = $blog['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $blog['seo_description']? : config('website_seo_description');
$this->assign($value);
$this->assign('blog', $blog);
$this->viewcount($id);
//return $this->fetch($template);
$disCount = $dataObject->isEmpty() ? null : count($dataObject->items());
if($disCount) {
$counts = get_rand_number(1,10,$disCount);
$this->assign('counts', $counts);
}
$curUrl = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$this->assign('curUrl', $curUrl);
return $this->fetch();
} else {
return exception('数据有误,请检查后再操作');
}
}
public function details($id = 0) {
if ($id > 0) {
$blog = Loader::model('Blog')->getRow($id);
if (empty($blog)) {
return exception('数据有误,请检查后再操作');
}
$jssdk=new \JsSdk\JsSdk('wx0d4ac6d59abca442','c482b3f5d1354533e9e14ad294016551');
//$jssdk=new \JsSdk\JsSdk('wxe44444f1f65fe4a6','a8c6a5a40572829da61a9c945ae6a0cd'); //测试账户
$signPackage = $jssdk->getSignPackage();
$this->assign('singpackage',$signPackage);
$arg_where = ['blog_remark.b_id' => $id, 'blog_remark.stat' => 1];
$arg_order = ['blog_remark.id' => 'desc'];
$arg_field = ['blog_remark.*'];
$dataObject = Loader::model('blog')->getRemarkList($arg_where, $arg_order, $arg_field, 10);
$value['list'] = $dataObject->isEmpty() ? null : $dataObject->items();
$value['total'] = $dataObject->total();
$value['page'] = $dataObject->render();
$value['seo_title'] = $blog['seo_title']? : $blog['title'] . '-' . config('website_seo_title');
$value['seo_keyword'] = $blog['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $blog['seo_description']? : config('website_seo_description');
$this->assign($value);
$this->assign('blog', $blog);
$this->viewcount($id);
//return $this->fetch($template);
$disCount = $dataObject->isEmpty() ? null : count($dataObject->items());
if($disCount) {
$counts = get_rand_number(1,10,$disCount);
$this->assign('counts', $counts);
}
$curUrl = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$this->assign('curUrl', $curUrl);
return $this->fetch();
} else {
return exception('数据有误,请检查后再操作');
}
}
protected function viewcount($id) {
$view = Cookie::get('blogview', 'history'); //print_r($history);exit;
if (empty($view) || $view != $id) {
Loader::model('blog')->where(['id' => $id])->setInc('visit_count');
Cookie::set('blogview', $id, ['prefix' => 'history', 'expire' => 3600]);
}
}
//添加评论 2021-06-01 Martin
public function addcomment()
{
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(403, 'Data error ');
if (trim($data['name']) == '')
return $this->json(403-2, 'Name cannot be empty');
if (trim($data['email']) == '')
return $this->json(403-4, 'Email cannot be empty');
if (trim($data['comment']) == '')
return $this->json(403-5, 'Comment 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');
$insert_data = [
'b_id' => trim($data['b_id']),
'name' => trim($data['name']),
'email' => trim($data['email']),
'content' => trim($data['comment']),
'add_time' => date("Y-m-d H:i:s",time()),
'siteid' => $this->siteid,
'country_code' => $this->country_code,
];
$result = model('blog_remark')->insert($insert_data);
if (!$result)
return $this->json(201, 'Failure to submit');
return $this->json(200, 'ok');
}
}

259
app/index/controller/Bulk.php Executable file
View File

@@ -0,0 +1,259 @@
<?php
namespace app\index\controller;
use think\Loader;
use think\Cookie;
use think\Config;
use think\Session;
class Bulk extends BaseController {
public function Bulk() {
return $this->view->fetch();
}
public function detail($id = 0) {
if ($id > 0) {
return $this->fetch();
} else {
return exception('数据有误,请检查后再操作');
}
}
/**
* 联系我们留言
* @author: Martin
* @email 1541350712@qq.com
* @version 1.0.0
* @date 2024-02-01
* @desc description
* @param [array] $params [输入参数]
*/
public function create()
{
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(403, 'Data error ');
if ($data['username'] == '')
return $this->json(403-3, 'Your name cannot be empty');
if ($data['email'] == '')
return $this->json(403-4, 'Email cannot be empty');
$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 = [
'first_name' => $data['username'],
'email' => $data['email'],
'message' => $data['message'],
'ip' => get_ip(),
'refer_url' => $_SERVER["HTTP_REFERER"],
'createtime' => date("Y-m-d H:i:s"),
'siteid' => $this->siteid,
'country_code' => $this->country_code,
'refer' => $referer,
'url' => $url,
'channels' => $channel,
'keyword' => $keyword,
'state' => $fed['country'],
'province' => $fed['province'],
'city' => $fed['city'],
'drvice' => $fed['drive'],
'user_agent' => $fed['system']." ".$fed['brower'],
];
$result = model('Bulk')->insert($insert_data);
if (!$result)
return $this->json(201, 'Failure to submit');
return $this->json(200, 'ok');
}
/**
* 商务订单 - 批量采购
* @author: Martin
* @email 1541350712@qq.com
* @version 1.0.0
* @date 2024-02-01
* @desc description
* @param [array] $params [输入参数]
*/
public function inquiry()
{
$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['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($data['url']) ? $data['url'] : '';
$searchFeed = getKeywords($referer);
$channel = isset($searchFeed['channel']) ? $searchFeed['channel'] : '';
$keyword = isset($searchFeed['search']) ? $searchFeed['search'] : '';
$fed = visitLog();
$insert_data = [
'company' => $data['company'],
'first_name' => $data['name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'phone' => trim($data['phone']),
'interest' => $data['interested'],
'message' => $data['message'],
'url' => $data['url'],
'ip' => get_ip(),
'refer_url' => $_SERVER["HTTP_REFERER"],
'createtime' => date("Y-m-d H:i:s"),
'siteid' => $this->siteid,
'country_code' => $this->country_code,
'refer' => $referer,
'uri' => $url,
'channel' => $channel,
'keyword' => $keyword,
'ip' => $fed['ip'],
'state' => isset($fed['country']) ? $fed['country'] : '',
'province' => isset($fed['province']) ? $fed['province'] : '',
'city' => isset($fed['city']) ? $fed['city'] : '',
'drvice' => isset($fed['drive']) ? $fed['drive'] : '',
'user_agent' => $fed['system']." ".$fed['brower'],
];
$result = model('bulk_inquiry')->insert($insert_data);
if (!$result)
return $this->json(201, 'Failure to submit');
return $this->json(200, 'ok');
}
/**
* 代理商申请 Distributor
* @author: Martin
* @email 1541350712@qq.com
* @version 1.0.0
* @date 2024-02-01
* @desc description
* @param [array] $params [输入参数]
*/
public function agents()
{
$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'],
'email' => $data['email'],
'phone' => trim($data['phone']),
'address' => isset($data['address']) ? $data['address'] : '',
'message' => isset($data['message']) ? $data['message'] : '',
'enterprise_size' => isset($data['interested']) ? $data['interested'] : $data['message'],
'business_type' => isset($data['business_type']) ? $data['business_type'] : '',
'createtime' => date("Y-m-d H:i:s"),
'siteid' => $this->siteid,
'country_code' => $this->country_code,
'message' => isset($data['message']) ? $data['message'] : '',
'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');
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-12-10
* Time: 13:48
*/
namespace app\index\controller;
use think\Controller;
use think\Session;
class ClickSum extends Controller {
public function add_click() {
$data = $this->request->post();
// tiaoshi($data);die;
if (empty($data) || !is_array($data)) {
return $this->json(-1, '数据错误');
}
$insert_data = [
'content_id' => $data['content_id'],
'type' => $data['type'],
'customer_id' => $data['customer_id'],
'country_code' => $data['country_code'],
'url' => $data['url'],
'click_ip' => get_ip(),
'create_time' => date('Y-m-d H:i:s')
];
model('click_sum')->insert($insert_data);
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace app\index\controller;
class Collection extends BaseController {
public function add_collection()
{
$data = $this->request->post();
if ($this->customer_id <= 0)
{
$param = [];
if (isset($data['curr_url']))
{
$param['url'] = $data['curr_url'];
}
return $this->json(-1000, '请先登录', $param);
}
if (empty($data) || !is_array($data))
{
return $this->json(-1, '数据格式错误');
}
$where = [
'customer_id' => $this->customer_id,
'type' => $data['type'],
'coll_id' => $data['coll_id'],
'stat' => 0
];
$is_collection = model('collection')->where($where)->find();
if (!empty($is_collection))
{
return $this->json(200, '已经收藏过啦');
}
$insert_data = [
'customer_id' => $this->customer_id,
'type' => $data['type'],
'coll_id' => $data['coll_id'],
'create_time' => time(),
'stat' => 0
];
$result = model('collection')->insert($insert_data);
if (!$result)
{
return $this->json(-2, '收藏失败,请稍后再试');
}
return $this->json(200, '收藏成功');
}
public function cancel_collection()
{
$data = $this->request->post();
if ($this->customer_id <= 0)
{
$param = [];
if (isset($data['curr_url']))
{
$param['url'] = $data['curr_url'];
}
return $this->json(-1000, '请先登录', $param);
}
if (empty($data) || !is_array($data))
{
return $this->json(-1, '数据格式错误');
}
$where = [
'customer_id' => $this->customer_id,
'type' => $data['type'],
];
if (!is_array($data['coll_id']))
{
$where['coll_id'] = $data['coll_id'];
}
else
{
$where['coll_id'] = ['in', $data['coll_id']];
}
$result = model('collection')->where($where)->update(['stat' => 1]);
if (!$result)
{
return $this->json(-2, '取消失败,请稍后再试');
}
return $this->json(200, '取消成功');
}
}

1021
app/index/controller/Customer.php Executable file

File diff suppressed because it is too large Load Diff

352
app/index/controller/Download.php Executable file
View File

@@ -0,0 +1,352 @@
<?php
namespace app\index\controller;
use think\Config;
use think\Cookie;
use think\Loader;
class Download extends BaseController
{
public function get_filter() {
$dl_name = model('download')->field('name')->where(['stat' => 0, 'country_code' => $this->country_code])->select();
$data = [
'dl_name' => $dl_name,
];
return $this->json(200, 'ok', $data);
}
public function catelists()
{
$arg_where = [
'a.siteid' => $this->siteid,
'c.id' => 1,
];
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
if ($skeyword != '') {
$skeyword = trim($skeyword);
$search['skeyword'] = $skeyword;
$arg_where['a.name|a.app_model'] = ['like', '%' . $search['skeyword'] . '%'];
Config::set('paginate.query', ['skeyword' => $skeyword]); //分页参数
$value['search'] = $search;
}
$arg_order = ['a.id' => 'desc'];
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.app_model', 'a.support_os', 'a.format', 'a.viewcount', 'a.downloadcount', 'a.description', 'a.picture', 'a.tags', 'a.downloadpath', 'a.downloadpath64', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = Loader::model('Download')->getCateDownloadLists($arg_where, $arg_order, $arg_field, 12);
// echo \think\Db::table('download')->getLastSql(), '<hr>';
// tiaoshi($dataObject->items());die;
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(),
'page' => $dataObject->render(),
];
if ($this->request->isAjax()) {
return $this->result($value, true, '下载列表');
}
$downloadCategory = Loader::model('DownloadCategory')->getList(['siteid' => $this->siteid, 'stat' => 0, 'pid' => 2], ['sort', 'id']);
// tiaoshi($downloadCategory);die;
$value['downloadCategory'] = $downloadCategory;
$value['skeyword'] = '';
$this->assign($value);
return $this->fetch();
}
public function detail($id = 0)
{
if ($id > 0) {
$detail = Loader::model('Download')->getRow($id);
if (empty($detail)) {
return exception('数据有误,请检查后再操作');
}
//$adddownload = Loader::model('DownloadAddition')->getRowAddition(['aid' => $detail['id']]);
$category = Loader::model('DownloadCategory')->getRow($detail['cid']);
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$prev_detail = Loader::model('Download')->getRow(['id' => ['gt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'asc']);
$next_detail = Loader::model('Download')->getRow(['id' => ['lt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'desc']);
$value = [
'detail' => $detail,
//'adddownload' => $adddownload,
'category' => $category,
'prev_detail' => $prev_detail,
'next_detail' => $next_detail,
];
$value['seo_title'] = $detail['seo_title'] ?: $detail['name'] . '-' . config('website_seo_title');
$value['seo_keyword'] = $detail['seo_keyword'] ?: config('website_seo_keyword');
$value['seo_description'] = $detail['seo_description'] ?: config('website_seo_description');
$this->assign($value);
$this->viewcount($id);
return $this->fetch();
} else {
return exception('数据有误,请检查后再操作');
}
}
public function download($id = 0, $bit = 0)
{
$id = intval($id);
$bit = intval($bit);
if ($id > 0) {
$detail = Loader::model('Download')->getRow($id);
if (empty($detail)) {
return exception('数据有误,请检查后再操作');
}
$docDir = request()->server('DOCUMENT_ROOT');
$rootDir = request()->root();
$directory = $docDir . $rootDir;
$downloadpath = explode(',', $detail['downloadpath']);
//$downloadpath64 = explode(',', $detail['downloadpath64']);
if (empty($downloadpath[$bit])) {
return exception('数据有误,请检查后再操作');
}
$fileinfo = pathinfo($downloadpath[$bit]);
$download = $directory . $downloadpath[$bit]; // 文件要下载的地址
Loader::model('Download')->updateRow(['downloadcount' => \think\Db::raw('`downloadcount`+1')], ['id' => $id]);
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileinfo['basename']);
header('Content-Length: ' . filesize($download));
ob_clean();
flush();
readfile($download);
exit();
} else {
return exception('数据有误,请检查后再操作');
}
}
public function dlcount($id = 0)
{
$id = intval($id);
if ($id > 0) {
$download = Loader::model('Download')->getRow(['id' => $id], ['id', 'downloadcount']);
if (empty($download)) {
return $this->error('Error');
}
$download['downloadcount'] = $download['downloadcount'] + 1;
$result = $download->save();
if ($result) {
return $this->success('Download', null, $download['downloadcount']);
} else {
return $this->error('Download Error');
}
}
return $this->error('Error');
}
public function prodownload($id = 0)
{
if ($id > 0) {
$detail = Loader::model('ProductDl')->getRow($id);
if (empty($detail)) {
return exception('数据有误,请检查后再操作');
}
$docDir = request()->server('DOCUMENT_ROOT');
$rootDir = request()->root();
$directory = $docDir . $rootDir;
$fileinfo = pathinfo($detail['dl_url']);
$file = $directory . $detail['dl_url']; // 文件要下载的地址
//在session里面存ip和id 查这个上次访问时间
$ip = $this->get_real_ip();
$name = 'ip_' . $ip . '_' . $id;
$time = time();
$dl = session($name);
//如果没有则创建session
if ($dl == '') {
$dl = session($name, $time);
}
$a = 180 - (time() - $dl);
if ($dl && time() - $dl < 180) {
return $this->error('操作过于频繁,请' . $a . '秒后再试');
}
// echo $file, '<hr>';
// var_dump(file_exists($file));echo '<hr>';
// echo filesize($file), '<hr>';
// echo 'Content-type: application/octet-stream', '<hr>';
// echo 'Content-Disposition: attachment; filename=' . $fileinfo['basename'], '<hr>';
// echo 'Content-Length: ' . filesize($file), '<hr>';
// die;
ini_set('memory_limit', '500M');
set_time_limit(0);
$dl = session($name, $time);
Loader::model('ProductDl')->updateRow(['dl_count' => \think\Db::raw('`dl_count`+1')], ['id' => $id]);
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileinfo['basename']);
header('Content-Length: ' . filesize($file));
readfile($file);
exit();
} else {
return exception('数据有误,请检查后再操作');
}
}
protected function viewcount($id)
{
$view = Cookie::get('downloadview', 'history'); //print_r($history);exit;
if (empty($view) || $view != $id) {
Loader::model('Download')->where(['id' => $id])->setInc('viewcount');
Cookie::set('downloadview', $id, ['prefix' => 'history', 'expire' => 3600]);
}
}
protected function historydownload($id)
{
$download = Cookie::get('download', 'history'); //print_r($history);exit;
if (isset($download) && !empty($download)) {
$download_ids = explode(',', $download);
if ($download_ids[0] != $id) {
array_unshift($download_ids, $id);
$download_ids = array_unique($download_ids);
$num = Config::get('history_number') > 0 ? Config::get('history_number') : 10;
//$download_ids = array_slice($download_ids, 0, $num);
while (count($download_ids) > $num) {
array_pop($download_ids);
}
Cookie::set('download', implode(',', $download_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
} else {
Cookie::set('download', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
}
public function catelists_down($id = 0)
{
//dump($id);die;
$arg_where = ['a.siteid' => $this->siteid];
if ($id > 0) {
$arg_where['cid'] = $id;
$category = Loader::model('DownloadCategory')->getRow($id);
}
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
if ($skeyword != '') {
$skeyword = trim($skeyword);
$search['skeyword'] = $skeyword;
$arg_where['a.name|a.app_model'] = ['like', '%' . $search['skeyword'] . '%'];
Config::set('paginate.query', ['skeyword' => $skeyword]); //分页参数
$value['search'] = $search;
}
switch ($category['classtype']) {
case 2:
$template = $category['templist'];
$arg_order = ['a.id' => 'desc'];
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.app_model', 'a.support_os', 'a.format', 'a.viewcount', 'a.downloadcount', 'a.description', 'a.picture', 'a.tags', 'a.downloadpath', 'a.downloadpath64', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = Loader::model('Download')->getCateDownloadLists($arg_where, $arg_order, $arg_field, 12);
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
];
if ($this->request->isAjax()) {
return $this->result($value, true, '下载列表');
}
$downloadCategory = Loader::model('DownloadCategory')->getList(['siteid' => $this->siteid, 'stat' => 0, 'pid' => 2], ['sort', 'id']);
$value['downloadCategory'] = $downloadCategory;
break;
case 3:
header('location:' . $category['url']);
exit;
break;
default:
$template = $category['tempindex'];
break;
}
$value['skeyword'] = '';
$value['category'] = $category;
$value['seo_title'] = $category['seo_title'] ?: config('website_seo_title');
$value['seo_keyword'] = $category['seo_keyword'] ?: config('website_seo_keyword');
$value['seo_description'] = $category['seo_description'] ?: config('website_seo_description');
$this->assign($value);
return $this->fetch($template);
}
public function index($id = 0)
{
$arg_where = ['a.siteid' => $this->siteid];
if ($id > 0) {
$arg_where['cid'] = $id;
$category = Loader::model('DownloadCategory')->getRow($id);
}
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
switch ($category['classtype']) {
case 2:
$template = $category['templist'];
$arg_order = ['a.id' => 'desc'];
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.app_model', 'a.support_os', 'a.format', 'a.viewcount', 'a.downloadcount', 'a.description', 'a.picture', 'a.tags', 'a.downloadpath', 'a.downloadpath64', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = Loader::model('Download')->getCateDownloadLists($arg_where, $arg_order, $arg_field, 12);
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
];
if ($this->request->isAjax()) {
return $this->result($value, true, '下载列表');
}
$downloadCategory = Loader::model('DownloadCategory')->getList(['siteid' => $this->siteid, 'stat' => 0, 'pid' => 2], ['sort', 'id']);
$value['downloadCategory'] = $downloadCategory;
break;
case 3:
header('location:' . $category['url']);
exit;
break;
default:
$template = $category['tempindex'];
break;
}
$value['skeyword'] = '';
$value['category'] = $category;
$value['seo_title'] = $category['seo_title'] ?: config('website_seo_title');
$value['seo_keyword'] = $category['seo_keyword'] ?: config('website_seo_keyword');
$value['seo_description'] = $category['seo_description'] ?: config('website_seo_description');
$this->assign($value);
return $this->fetch($template);
}
function get_real_ip()
{
$ip = false;
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode(', ', $_SERVER['HTTP_X_FORWARDED_FOR']);
if ($ip) {
array_unshift($ips, $ip);
$ip = FALSE;
}
for ($i = 0; $i < count($ips); $i++) {
if (!eregi('^(10│172.16│192.168).', $ips[$i])) {
$ip = $ips[$i];
break;
}
}
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
public function dlsearch($id)
{
$where = ['id' => $id];
$view = Loader::model('Download')->where($where)->find();
$category = Loader::model('DownloadCategory')->getRow();
$this->assign('view',$view);
$this->assign('category',$category);
return $this->fetch();
}
}

536
app/index/controller/Group.php Executable file
View File

@@ -0,0 +1,536 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-09-21
* Time: 17:36
*/
namespace app\index\controller;
use think\Loader;
class Group extends BaseController
{
public function index()
{
return $this->view->fetch();
}
public function odm()
{
return $this->view->fetch();
}
public function special()
{
return $this->view->fetch();
}
public function policy()
{
return $this->view->fetch();
}
public function culture()
{
return $this->view->fetch();
}
public function backup_treasure()
{
return $this->view->fetch();
}
public function pssd()
{
return $this->view->fetch();
}
public function question()
{
$data = $this->request->param();
$where = [
'a.stat' => 0,
'a.country_code' => $this->country_code,
];
$cid = isset($data['cid']) ? $data['cid'] : 0;
if ($cid)
$where['a.cid'] = $cid;
$search['keyword'] = '';
if (isset($data['keyword']) && $data['keyword'] != '')
{
$where['a.title'] = ['like', '%' . $data['keyword'] . '%'];
$search['keyword'] = $data['keyword'];
}
$order = [
'a.sort' => 'asc',
'a.id' => 'desc'
];
$field = ['a.*', 'b.name' => 'cate_name'];
$question_list = model('question')->alias('a')->join('question_category b', 'a.cid = b.id', 'LEFT')->where($where)->order($order)->field($field)->paginate(4);
// echo model('question')->getLastSql();die;
// tiaoshi($question_list->items());die;
$question_catelist = model('question_category')->where(['stat' => 0])->select();
$value = [
'question_list' => $question_list->isEmpty() ? null : $question_list->items(),
'page' => $question_list->render(),
'cid' => $cid,
'search' => $search,
'question_catelist' => $question_catelist
];
$this->assign($value);
return view();
}
public function honor()
{
return $this->view->fetch();
}
public function industry()
{
return $this->view->fetch();
}
public function weare()
{
return $this->view->fetch();
}
public function responsibility()
{
return $this->view->fetch();
}
public function wewill()
{
return $this->view->fetch();
}
public function oricoindex()
{
return $this->view->fetch();
}
public function vision()
{
return $this->view->fetch();
}
public function rdcenter()
{
return $this->view->fetch();
}
public function search()
{
return $this->view->fetch();
}
public function transparent()
{
return $this->view->fetch();
}
public function headset()
{
return $this->view->fetch();
}
public function socket()
{
return $this->view->fetch();
}
public function charger()
{
return $this->view->fetch();
}
public function fan()
{
return $this->view->fetch();
}
public function sitemap()
{
return $this->view->fetch();
}
public function ufo()
{
return $this->view->fetch();
}
public function h_speed()
{
return $this->view->fetch();
}
public function decennial()
{
return $this->view->fetch();
}
public function ssd()
{
return $this->view->fetch();
}
public function series_95()
{
return $this->view->fetch();
}
public function series_35()
{
return $this->view->fetch();
}
public function stripe()
{
return $this->view->fetch();
}
public function thunderbolt_3 ()
{
return $this->view->fetch();
}
public function customized ()
{
return $this->view->fetch();
}
/********20230720 顶部导航栏目************/
public function blog2023(){
return $this->view->fetch();
}
public function brand2023(){
return $this->view->fetch();
}
public function brand(){
return $this->view->fetch();
}
public function Contact2023(){
return $this->view->fetch();
}
public function product2023(){
return $this->view->fetch();
}
public function catelists2023(){
return $this->view->fetch();
}
public function download(){
return $this->view->fetch();
}
public function achievement(){
return $this->view->fetch();
}
public function business2023(){
return $this->view->fetch();
}
public function distributor2023(){
return $this->view->fetch();
}
public function introduction2023(){
return $this->view->fetch();
}
public function faq(){
$where = ['stat' => 0];
$order = [
'sort' => 'asc',
'id' => 'desc'
];
$fq_list = model('fq')->where($where)->order($order)->paginate(6);
// echo model('question')->getLastSql();die;
// tiaoshi($question_list->items());die;
$value = [
'fq_list' => $fq_list->isEmpty() ? null : $fq_list->items(),
'page' => $fq_list->render(),
];
$this->assign($value);
return $this->view->fetch();
}
public function mileage(){
$arg_where = ['a.siteid' => $this->siteid, 'a.country_code' => $this->country_code];
$arg_order = ['a.id' => 'desc'];
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.writer', 'a.source', 'a.viewcount', 'a.zancount', 'a.commentcount', 'a.description', 'a.picture', 'a.tags', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = model('Article')->getCateArticleLists($arg_where, $arg_order, $arg_field, 12);
$category = model('ArticleCategory')->getRow(1);
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
'category' => $category,
];
//echo "<pre>=="; print_r($category);
$this->assign($value);
return $this->view->fetch();
}
public function guide(){
return $this->view->fetch();
}
public function query(){
return $this->view->fetch();
}
public function contact(){
$banners = Loader::model("Banner")->alias('b')->field([
'b.id',
'b.typeid',
'bt.name' => 'typename',
'bt.description' => 'typedesc',
'b.name',
'b.categoryid',
'b.url',
'b.picture',
'b.alt',
'b.style',
'b.description' => 'desc',
'b.descolor',
'b.btncolor',
'b.videourl',
])
->join('banner_type bt', 'bt.stat= 0 and bt.id=b.typeid')
->where('b.stat', '=', 0)
->where('b.typeid', '=', 122)
->order(['sort' => 'asc', 'id' => 'asc'])
->select();
$data = [];
foreach ($banners as $val) {
$link = $val['url'];
if (empty($val['url']) && !empty($val['categoryid'])) {
$link = url_rewrite('productsub', ['id' => $val['categoryid']]);
}
$data[] = [
'id' => $val['id'],
'name' => $val['name'],
'link' => $link,
'picture' => $val['picture'],
'alt' => $val['alt'],
'style' => $val['style'],
'desc' => $val['desc'],
'desc_color' => $val['descolor'],
'btn_color' => $val['btncolor'],
'video_url' => $val['videourl'],
];
}
$this->assign('data', $data);
return $this->view->fetch();
}
public function tutorial(){
return $this->view->fetch();
}
public function distributor(){
return $this->view->fetch();
}
public function business(){
return $this->view->fetch();
}
public function introduction(){
return $this->view->fetch();
}
public function test ()
{
$field = ['a.*', 'b.name', 'b.shortname', 'b.brand_id', 'b.url_tm', 'b.url_jd'];
$special_product_list = db('special_product_relation')->alias('a')->join('product b', 'a.product_id=b.id', 'LEFT')->where(['a.special_id' => 3, 'a.stat' => 0, 'b.stat' => 0])->field($field)->limit(8)->select();
$normal_product = [];
$special_product = [];
foreach ($special_product_list as $key => $value) {
$product_two_img = model('product_two_img')->where(['stat' => 0, 'product_id' => $value['product_id']])->find();
$value['img'] = $product_two_img['image_url'];
if ($value['type'] == 0)
array_push($normal_product, $value);
else if ($value['type'] == 1)
array_push($special_product, $value);
}
// tiaoshi($normal_product);
// tiaoshi($special_product);die;
$this->assign('normal_product', $normal_product);
$this->assign('special_product', $special_product);
return $this->view->fetch();
}
public function report()
{
if ($this->customer_id <= 0)
$this->redirect('/login.html');
return $this->view->fetch();
}
public function create_report()
{
if ($this->customer_id <= 0)
return $this->json(-100, '请先登录');
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(-1, '数据错误');
if ($data['product_name'] == '')
return $this->json(-2, '产品名称不能为空');
if ($data['product_model'] == '')
return $this->json(-3, '产品型号不能为空');
if ($data['product_manufacturer'] == '')
return $this->json(-4, '厂商不能为空');
// 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, '手机格式错误');
if ($data['customer_email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['customer_email']))
return $this->json(-7, '邮箱格式错误');
$insert_data = [
'customer_id' => $this->customer_id,
'product_name' => $data['product_name'],
'product_model' => $data['product_model'],
'product_manufacturer' => $data['product_manufacturer'],
'buy_source' => $data['buy_source'],
'product_price' => floatval($data['product_price']),
'customer_name' => $data['customer_name'],
'customer_email' => $data['customer_email'],
'customer_telephone' => $data['customer_telephone'],
'description' => $data['description'],
'create_time' => time(),
];
$result = model('report')->insert($insert_data);
if (!$result)
return $this->json(-8, '提交失败');
return $this->json(200, 'ok');
}
public function job()
{
$sql = "SELECT * FROM cod_job
WHERE stat=0
AND NOW() >= publish_time
AND NOW() <= end_time
";
$job_list = \think\Db::query($sql);
// tiaoshi($job_list);die;
$this->assign('job_list', $job_list);
return $this->view->fetch();
}
public function Fake()
{
$data = $this->request->post();
//$this->verify_check($data['captcha'], 'authcode') || $this->error('验证码有误', url('group/test'));
$sn = $data['sn'];//dump($sn);die;
$sn = $this->https_request('http://mes.orico.com.cn:8084/api/values/',$sn);dump($sn);die;
}
//CURL POST请求
function https_request($url, $data = null) {
$apiUrl = "$url$data";//print_r($apiUrl);die;
$oCurl = curl_init();
if(stripos($apiUrl,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($oCurl,CURLOPT_TIMEOUT,5);
curl_setopt ($oCurl, CURLOPT_HEADER, 0);
curl_setopt($oCurl, CURLOPT_HTTPHEADER, []);
curl_setopt($oCurl, CURLOPT_URL, $apiUrl);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, 3);
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}
//可以发送get和post的请求方式
function curl_request($url,$method='get',$data=null,$https=true){
//1.初识化curl
$ch = curl_init($url);
//2.根据实际请求需求进行参数封装
//返回数据不直接输出
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//如果是https请求
if($https === true){
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
}
//如果是post请求
if($method === 'post'){
//开启发送post请求选项
curl_setopt($ch,CURLOPT_POST,true);
//发送post的数据
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
}
//3.发送请求
$result = curl_exec($ch);dump($result);die;
//4.返回返回值,关闭连接
curl_close($ch);
return $result;
}
/**
* post
* post方式请求资源
* @param string $url 基于的baseUrl
* @param array $keysArr 请求的参数列表
* @param int $flag 标志位
* @return string 返回的资源内容
*/
public function post($url, $keysArr, $flag = 0){
$ch = curl_init();
if(! $flag) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $keysArr);
curl_setopt($ch, CURLOPT_URL, $url);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
}

342
app/index/controller/Group1.php Executable file
View File

@@ -0,0 +1,342 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-09-21
* Time: 17:36
*/
namespace app\index\controller;
class Group extends BaseController
{
public function index()
{
return $this->view->fetch();
}
public function odm()
{
return $this->view->fetch();
}
public function special()
{
return $this->view->fetch();
}
public function policy()
{
return $this->view->fetch();
}
public function culture()
{
return $this->view->fetch();
}
public function Contact()
{
return $this->view->fetch();
}
public function fq()
{
$where = ['stat' => 0];
$order = [
'sort' => 'asc',
'id' => 'desc'
];
$fq_list = model('fq')->getList($where, $order, null, 6);
$data['fq_list'] = $fq_list;
$this->assign($data);
return $this->view->fetch();
}
public function question()
{
$data = $this->request->param();
$where = [
'a.stat' => 0,
'a.country_code' => $this->country_code,
];
$cid = isset($data['cid']) ? $data['cid'] : 0;
if ($cid)
$where['a.cid'] = $cid;
$search['keyword'] = '';
if (isset($data['keyword']) && $data['keyword'] != '')
{
$where['a.title'] = ['like', '%' . $data['keyword'] . '%'];
$search['keyword'] = $data['keyword'];
}
$order = [
'a.sort' => 'asc',
'a.id' => 'desc'
];
$field = ['a.*', 'b.name' => 'cate_name'];
$question_list = model('question')->alias('a')->join('question_category b', 'a.cid = b.id', 'LEFT')->where($where)->order($order)->field($field)->paginate(4);
// echo model('question')->getLastSql();die;
// tiaoshi($question_list->items());die;
$question_catelist = model('question_category')->where(['stat' => 0])->select();
$value = [
'question_list' => $question_list->isEmpty() ? null : $question_list->items(),
'page' => $question_list->render(),
'cid' => $cid,
'search' => $search,
'question_catelist' => $question_catelist
];
$this->assign($value);
return view();
}
public function honor()
{
return $this->view->fetch();
}
public function industry()
{
return $this->view->fetch();
}
public function weare()
{
return $this->view->fetch();
}
public function wewill()
{
return $this->view->fetch();
}
public function vision()
{
return $this->view->fetch();
}
public function rdcenter()
{
return $this->view->fetch();
}
public function brand()
{
return $this->view->fetch();
}
public function search()
{
return $this->view->fetch();
}
public function transparent()
{
return $this->view->fetch();
}
public function distributor()
{
return $this->view->fetch();
}
public function headset()
{
return $this->view->fetch();
}
public function socket()
{
return $this->view->fetch();
}
public function charger()
{
return $this->view->fetch();
}
public function fan()
{
return $this->view->fetch();
}
public function sitemap()
{
return $this->view->fetch();
}
public function ufo()
{
return $this->view->fetch();
}
public function h_speed()
{
return $this->view->fetch();
}
public function decennial()
{
return $this->view->fetch();
}
public function ssd()
{
return $this->view->fetch();
}
public function thunderbolt_3 ()
{
return $this->view->fetch();
}
public function report()
{
if ($this->customer_id <= 0)
$this->redirect('/login.html');
return $this->view->fetch();
}
public function create_report()
{
if ($this->customer_id <= 0)
return $this->json(-100, '请先登录');
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(-1, '数据错误');
if ($data['product_name'] == '')
return $this->json(-2, '产品名称不能为空');
if ($data['product_model'] == '')
return $this->json(-3, '产品型号不能为空');
if ($data['product_manufacturer'] == '')
return $this->json(-4, '厂商不能为空');
// 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, '手机格式错误');
if ($data['customer_email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['customer_email']))
return $this->json(-7, '邮箱格式错误');
$insert_data = [
'customer_id' => $this->customer_id,
'product_name' => $data['product_name'],
'product_model' => $data['product_model'],
'product_manufacturer' => $data['product_manufacturer'],
'buy_source' => $data['buy_source'],
'product_price' => floatval($data['product_price']),
'customer_name' => $data['customer_name'],
'customer_email' => $data['customer_email'],
'customer_telephone' => $data['customer_telephone'],
'description' => $data['description'],
'create_time' => time(),
];
$result = model('report')->insert($insert_data);
if (!$result)
return $this->json(-8, '提交失败');
return $this->json(200, 'ok');
}
public function job()
{
$sql = "SELECT * FROM cod_job
WHERE stat=0
AND NOW() >= publish_time
AND NOW() <= end_time
";
$job_list = \think\Db::query($sql);
// tiaoshi($job_list);die;
$this->assign('job_list', $job_list);
return $this->view->fetch();
}
public function Fake()
{
$data = $this->request->post();
//$this->verify_check($data['captcha'], 'authcode') || $this->error('验证码有误', url('group/test'));
$sn = $data['sn'];//dump($sn);die;
$sn = $this->https_request('http://mes.orico.com.cn:8084/api/values/',$sn);dump($sn);die;
}
//CURL POST请求
function https_request($url, $data = null) {
$apiUrl = "$url$data";//print_r($apiUrl);die;
$oCurl = curl_init();
if(stripos($apiUrl,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($oCurl,CURLOPT_TIMEOUT,5);
curl_setopt ($oCurl, CURLOPT_HEADER, 0);
curl_setopt($oCurl, CURLOPT_HTTPHEADER, []);
curl_setopt($oCurl, CURLOPT_URL, $apiUrl);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, 3);
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}
//可以发送get和post的请求方式
function curl_request($url,$method='get',$data=null,$https=true){
//1.初识化curl
$ch = curl_init($url);
//2.根据实际请求需求进行参数封装
//返回数据不直接输出
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//如果是https请求
if($https === true){
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
}
//如果是post请求
if($method === 'post'){
//开启发送post请求选项
curl_setopt($ch,CURLOPT_POST,true);
//发送post的数据
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
}
//3.发送请求
$result = curl_exec($ch);dump($result);die;
//4.返回返回值,关闭连接
curl_close($ch);
return $result;
}
/**
* post
* post方式请求资源
* @param string $url 基于的baseUrl
* @param array $keysArr 请求的参数列表
* @param int $flag 标志位
* @return string 返回的资源内容
*/
public function post($url, $keysArr, $flag = 0){
$ch = curl_init();
if(! $flag) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $keysArr);
curl_setopt($ch, CURLOPT_URL, $url);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
}

View File

@@ -0,0 +1,372 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-09-21
* Time: 17:36
*/
namespace app\index\controller;
class Group extends BaseController
{
public function index()
{
return $this->view->fetch();
}
public function odm()
{
return $this->view->fetch();
}
public function special()
{
return $this->view->fetch();
}
public function policy()
{
return $this->view->fetch();
}
public function culture()
{
return $this->view->fetch();
}
public function Contact()
{
return $this->view->fetch();
}
public function fq()
{
$where = ['stat' => 0];
$order = [
'sort' => 'asc',
'id' => 'desc'
];
$fq_list = model('fq')->getList($where, $order, null, 6);
$data['fq_list'] = $fq_list;
$this->assign($data);
return $this->view->fetch();
}
public function question()
{
$data = $this->request->param();
$where = [
'a.stat' => 0,
'a.country_code' => $this->country_code,
];
$cid = isset($data['cid']) ? $data['cid'] : 0;
if ($cid)
$where['a.cid'] = $cid;
$search['keyword'] = '';
if (isset($data['keyword']) && $data['keyword'] != '')
{
$where['a.title'] = ['like', '%' . $data['keyword'] . '%'];
$search['keyword'] = $data['keyword'];
}
$order = [
'a.sort' => 'asc',
'a.id' => 'desc'
];
$field = ['a.*', 'b.name' => 'cate_name'];
$question_list = model('question')->alias('a')->join('question_category b', 'a.cid = b.id', 'LEFT')->where($where)->order($order)->field($field)->paginate(4);
// echo model('question')->getLastSql();die;
// tiaoshi($question_list->items());die;
$question_catelist = model('question_category')->where(['stat' => 0])->select();
$value = [
'question_list' => $question_list->isEmpty() ? null : $question_list->items(),
'page' => $question_list->render(),
'cid' => $cid,
'search' => $search,
'question_catelist' => $question_catelist
];
$this->assign($value);
return view();
}
public function honor()
{
return $this->view->fetch();
}
public function industry()
{
return $this->view->fetch();
}
public function weare()
{
return $this->view->fetch();
}
public function wewill()
{
return $this->view->fetch();
}
public function vision()
{
return $this->view->fetch();
}
public function rdcenter()
{
return $this->view->fetch();
}
public function brand()
{
return $this->view->fetch();
}
public function search()
{
return $this->view->fetch();
}
public function transparent()
{
return $this->view->fetch();
}
public function distributor()
{
return $this->view->fetch();
}
public function headset()
{
return $this->view->fetch();
}
public function socket()
{
return $this->view->fetch();
}
public function charger()
{
return $this->view->fetch();
}
public function fan()
{
return $this->view->fetch();
}
public function sitemap()
{
return $this->view->fetch();
}
public function ufo()
{
return $this->view->fetch();
}
public function h_speed()
{
return $this->view->fetch();
}
public function decennial()
{
return $this->view->fetch();
}
public function ssd()
{
return $this->view->fetch();
}
public function series_95()
{
return $this->view->fetch();
}
public function stripe()
{
return $this->view->fetch();
}
public function thunderbolt_3 ()
{
return $this->view->fetch();
}
public function test ()
{
$field = ['a.*', 'b.name', 'b.shortname', 'b.brand_id', 'b.url_tm', 'b.url_jd'];
$special_product_list = db('special_product_relation')->alias('a')->join('product b', 'a.product_id=b.id', 'LEFT')->where(['a.special_id' => 3, 'a.stat' => 0, 'b.stat' => 0])->field($field)->limit(8)->select();
$normal_product = [];
$special_product = [];
foreach ($special_product_list as $key => $value) {
$product_two_img = model('product_two_img')->where(['stat' => 0, 'product_id' => $value['product_id']])->find();
$value['img'] = $product_two_img['image_url'];
if ($value['type'] == 0)
array_push($normal_product, $value);
else if ($value['type'] == 1)
array_push($special_product, $value);
}
// tiaoshi($normal_product);
// tiaoshi($special_product);die;
$this->assign('normal_product', $normal_product);
$this->assign('special_product', $special_product);
return $this->view->fetch();
}
public function report()
{
if ($this->customer_id <= 0)
$this->redirect('/login.html');
return $this->view->fetch();
}
public function create_report()
{
if ($this->customer_id <= 0)
return $this->json(-100, '请先登录');
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(-1, '数据错误');
if ($data['product_name'] == '')
return $this->json(-2, '产品名称不能为空');
if ($data['product_model'] == '')
return $this->json(-3, '产品型号不能为空');
if ($data['product_manufacturer'] == '')
return $this->json(-4, '厂商不能为空');
// 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, '手机格式错误');
if ($data['customer_email'] != '' && !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['customer_email']))
return $this->json(-7, '邮箱格式错误');
$insert_data = [
'customer_id' => $this->customer_id,
'product_name' => $data['product_name'],
'product_model' => $data['product_model'],
'product_manufacturer' => $data['product_manufacturer'],
'buy_source' => $data['buy_source'],
'product_price' => floatval($data['product_price']),
'customer_name' => $data['customer_name'],
'customer_email' => $data['customer_email'],
'customer_telephone' => $data['customer_telephone'],
'description' => $data['description'],
'create_time' => time(),
];
$result = model('report')->insert($insert_data);
if (!$result)
return $this->json(-8, '提交失败');
return $this->json(200, 'ok');
}
public function job()
{
$sql = "SELECT * FROM cod_job
WHERE stat=0
AND NOW() >= publish_time
AND NOW() <= end_time
";
$job_list = \think\Db::query($sql);
// tiaoshi($job_list);die;
$this->assign('job_list', $job_list);
return $this->view->fetch();
}
public function Fake()
{
$data = $this->request->post();
//$this->verify_check($data['captcha'], 'authcode') || $this->error('验证码有误', url('group/test'));
$sn = $data['sn'];//dump($sn);die;
$sn = $this->https_request('http://mes.orico.com.cn:8084/api/values/',$sn);dump($sn);die;
}
//CURL POST请求
function https_request($url, $data = null) {
$apiUrl = "$url$data";//print_r($apiUrl);die;
$oCurl = curl_init();
if(stripos($apiUrl,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($oCurl,CURLOPT_TIMEOUT,5);
curl_setopt ($oCurl, CURLOPT_HEADER, 0);
curl_setopt($oCurl, CURLOPT_HTTPHEADER, []);
curl_setopt($oCurl, CURLOPT_URL, $apiUrl);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, 3);
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}
//可以发送get和post的请求方式
function curl_request($url,$method='get',$data=null,$https=true){
//1.初识化curl
$ch = curl_init($url);
//2.根据实际请求需求进行参数封装
//返回数据不直接输出
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
//如果是https请求
if($https === true){
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
}
//如果是post请求
if($method === 'post'){
//开启发送post请求选项
curl_setopt($ch,CURLOPT_POST,true);
//发送post的数据
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
}
//3.发送请求
$result = curl_exec($ch);dump($result);die;
//4.返回返回值,关闭连接
curl_close($ch);
return $result;
}
/**
* post
* post方式请求资源
* @param string $url 基于的baseUrl
* @param array $keysArr 请求的参数列表
* @param int $flag 标志位
* @return string 返回的资源内容
*/
public function post($url, $keysArr, $flag = 0){
$ch = curl_init();
if(! $flag) curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $keysArr);
curl_setopt($ch, CURLOPT_URL, $url);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}
}

132
app/index/controller/Index.php Executable file
View File

@@ -0,0 +1,132 @@
<?php
namespace app\index\controller;
use think\Lang;
use think\Loader;
use think\Config;
use think\TransDb;
class Index extends BaseController {
public function index() {
// 如果是手机端进官网
if (isMobile()) {
if ($_SERVER['HTTP_HOST']=="www.orico.cc" || $_SERVER['HTTP_HOST']=="orico.cc") {
return $this->redirect("http://www.orico.cc/usmobile");
} else {
return $this->redirect('http://www.orico.com.cn/mobile');
}
}
else{
if ($_SERVER['HTTP_HOST']=="www.orico.cc" || $_SERVER['HTTP_HOST']=="orico.cc") {
//验证上级来源页
$domainUrl = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
/*if (!isset($_SERVER['HTTP_REFERER'])) {
if ($domainUrl== 'www.orico.cc/' || $domainUrl == 'orico.cc/') {
return $this->redirect("http://www.orico.cc/us/Group/oricoindex");
}
}*/
return $this->redirect("http://www.orico.cc/us");
}
//验证上级来源页
/* if (!isset($_SERVER['HTTP_REFERER'])) {
$domainUrl = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
//echo $domainUrl; die;
if ($domainUrl== 'www.orico.com.cn/' || $domainUrl == 'orico.com.cn/') {
return $this->redirect("http://orico.com.cn/index/Group/oricoindex");
}
} */
}
$lebel_list = getDifferentProduct("recommend",12);
$this->assign('recomment_items',$lebel_list);
$blog_list = getArticleList();
$this->assign('blog_list',$blog_list);
$faqData = getFaqList();
$this->assign('faqData',$faqData);
//echo "<pre>=="; print_r($blog_list); die;
return $this->fetch('/index');
}
public function info(){
echo "\nstart: ".date("Y-m-d H:i:s")."\n";
$TransDb = new TransDb();
$TransDb->selectAllStruct("ProductCategory");
//$getDb = $TransDb->getkv();
echo "\nend :".date("Y-m-d H:i:s")."\n";
dump($TransDb);
// phpinfo();
}
public function feedback() {
if ($this->request->isPost()) {
$data = $this->request->post();
if (empty($data) || !is_array($data)) {
return $this->error('未知错误');
}
$this->verify_check($data['authcode'], 'authcode') || $this->error('验证码不正确');
$validaterule = [
'name' => 'require',
'subject' => 'require',
'contact' => 'require',
'content' => 'require',
];
$validatemsg = [
'name.require' => '名称不能为空',
'subject.require' => '主题不能为空',
'contact.require' => '联系方式不能为空',
'content.require' => '内容不能为空',
];
if (empty($data['way'])) {
return $this->error('请选择正确的联系方式');
} else {
if ($data['way'] == 'E-mail') {
$validaterule['contact'] = 'email';
$validatemsg['contact.email'] = '联系方式格式不正确';
}
if ($data['way'] == 'tel') {
$validaterule['contact'] = ['regex' => '^1[345789]\d{9}$|^([0-9]{3,4}-?)?[0-9]{7,8}$'];
$validatemsg['contact.regex'] = '联系方式格式不正确';
}
}
$valid_result = $this->validate($data, $validaterule, $validatemsg);
if (true !== $valid_result) {
// 验证失败 输出错误信息
return $this->error($valid_result);
}
$set = [
'feedback_type' => isset($data['feedback_type']) ? $data['feedback_type'] : '',
'name' => isset($data['name']) ? $data['name'] : 'Name',
'subject' => isset($data['subject']) ? $data['subject'] : '',
'content' => isset($data['content']) ? $data['content'] : '',
'way' => isset($data['way']) ? $data['way'] : '',
'contact' => isset($data['contact']) ? $data['contact'] : '',
'addtime' => date('Y-m-d H:i:s'),
];
$model = Loader::model('Msgform')->insertRow($set);
if ($model && $model->getData('id')) {
return $this->success('成功!成功!等待管理员查看', url('/'));
} else {
return $this->error('操作失败');
}
}
return $this->result(['code' => false, 'msg' => '未知错误'], false, '未知错误');
}
}

View File

@@ -0,0 +1,96 @@
<?php
namespace app\index\controller;
use think\Loader;
use think\Cookie;
use think\Config;
class Pinglun extends BaseController {
public function lists($type = '', $cid = 0) {
$arg_where = ['stat' => 0, 'display' => 1];
if ($type) {
$arg_where['typeid'] = $type;
}
if ($cid) {
$arg_where['content_id'] = $cid;
}
$arg_order = ['id' => 'desc'];
$arg_field = ['*'];
$dataObject = Loader::model('Pinglun')->getPageList($arg_where, $arg_order, $arg_field, 12);
//header('content-type:text/html;charset=utf-8;');
$value['list'] = $dataObject->isEmpty() ? null : $dataObject->items();
$value['page'] = $dataObject->render();
$value['total'] = $dataObject->total();
if ($this->request->isAjax()) {
return $this->result($value, 'pinglun', true);
}
$value['cid'] = $cid;
$value['type'] = ucfirst($type);
$value['seo_title'] = config('article_seo_title')? : config('website_seo_title');
$value['seo_keyword'] = config('article_seo_keyword')? : config('website_seo_keyword');
$value['seo_description'] = config('article_seo_description')? : config('website_seo_description');
$this->assign($value);
return $this->fetch('pinglun');
}
public function add() {
if (!$this->customer_id) {
return $this->result(['code' => false, 'msg' => '请登录后再进行评论'], false, '请登录后再进行评论');
}
if ($this->request->isPost()) {
$row = Loader::model('Pinglun')->getRow(['customer_id' => $this->customer_id, 'stat' => 0], null, ['createtime' => 'desc']);
if ($row && $row['id']) {
$createtime = strtotime($row['createtime']);
if (time() - $createtime < 60) {
return $this->result(['code' => false, 'msg' => '您已评论过了请不要重复评论'], false, '您已评论过了请不要重复评论');
}
}
$data = $this->request->post();
if (empty($data) || !is_array($data)) {
return $this->error('未知错误');
}
$validaterule = [
'pid' => 'require',
'cid' => 'require',
'typeid' => 'require',
'content' => 'require',
];
$validatemsg = [
'pid.require' => 'p不能为空',
'cid.require' => 'c内容为空',
'typeid.require' => 'type不能为空',
'content.require' => '内容不能为空',
];
$valid_result = $this->validate($data, $validaterule, $validatemsg);
if (true !== $valid_result) {
// 验证失败 输出错误信息
return $this->error($valid_result);
}
$addtime = date('Y-m-d H:i:s');
$txarr = [1, 2, 3, 4, 5];
shuffle($txarr);
$set = [
'customer_id' => $this->customer_id,
'cname' => session('customer_auth.firstname'),
'typeid' => isset($data['typeid']) ? $data['typeid'] : 'Article',
'pid' => isset($data['pid']) ? $data['pid'] : 0,
'content_id' => isset($data['cid']) ? $data['cid'] : 0,
'content' => $data['content'],
'tx' => $txarr[0],
'createtime' => $addtime,
'lasttime' => $addtime,
];
$model = Loader::model('Pinglun')->insertRow($set);
if ($model && $model->getData('id')) {
isset($data['cid']) ? Loader::model('Article')->where(['id' => $data['cid']])->setInc('commentcount') : '';
return $this->success('成功!成功!等待管理员的审核后,方可显示', url('/'));
} else {
return $this->error('操作失败');
}
}
return $this->result(['code' => false, 'msg' => '未知错误'], false, '未知错误');
}
}

500
app/index/controller/Product.php Executable file
View File

@@ -0,0 +1,500 @@
<?php
namespace app\index\controller;
use think\Collection;
use think\Db;
use think\Loader;
use think\Cookie;
use think\Config;
class Product extends BaseController {
public function get_filter() {
if ($this->cacheHas('product_filter_index'))
{
$product_filter_index = $this->cacheGet('product_filter_index');
}
else
{
$product_filter_index = model('product')->field('name, brand_id, keyword')->where(['stat' => 0, 'is_show' => 0, 'country_code' => $this->country_code])->select();
$this->cacheSet('product_filter_index', $product_filter_index, 86400);
}
$data = [
'product_name' => $product_filter_index,
];
return $this->json(200, 'ok', $data);
}
public function lists($id = 0) {
$category = Loader::model('ProductCategory')->getRow(['stat' => 0, 'pid' => 0, 'country_code' => $this->country_code], null, ['id' => 'asc']);
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$value = [
'category' => $category,
];
$value['seo_title'] = config('product_seo_title')? : config('website_seo_title');
$value['seo_keyword'] = config('product_seo_keyword')? : config('website_seo_keyword');
$value['seo_description'] = config('product_seo_description')? : config('website_seo_description');
$this->assign($value);
return $this->fetch('catelists');
}
public function catelists($id = 0) {
$arg_where = ['a.siteid' => $this->siteid, 'country_code' => $this->country_code];
if ($id > 0) {
$arg_where['cid'] = $id;
$category = Loader::model('ProductCategory')->getRow($id);
}
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
switch ($category['classtype']) {
case 2:
$template = $category['templist'];
break;
case 3:
header('location:' . $category['url']);
exit;
break;
default:
$template = $category['tempindex'];
break;
}
$value['category'] = $category;
$value['seo_title'] = $category['seo_title']? : config('website_seo_title');
$value['seo_keyword'] = $category['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $category['seo_description']? : config('website_seo_description');
$this->assign($value);
return $this->fetch($template);
}
public function subcatelists($id = 0) {
$arg_where = ['a.siteid' => $this->siteid, 'country_code' => $this->country_code];
if ($id > 0) {
$arg_where['cid'] = $id;
$category = Loader::model('ProductCategory')->getRow($id);
}
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
switch ($category['classtype']) {
case 2:
$template = $category['templist'];
$subproductCategory = $this->list_to_tree($this->categoryList, 'id', 'pid', 'child', $id);
$value = ['subproductCategory' => $subproductCategory];
break;
case 3:
header('location:' . $category['url']);
exit;
break;
default:
$template = $category['tempindex'];
break;
}
$result = model('ProductCategory')->where(['pid' => $category['id']])->find();
$last_cate = empty($result) ? 1 : 0;
$value['last_cate'] = $last_cate;
$value['pid'] = $id;
$value['category'] = $category;
$value['seo_title'] = $category['seo_title']? : config('website_seo_title');
$value['seo_keyword'] = $category['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $category['seo_description']? : config('website_seo_description');
$this->assign($value);
return $this->fetch($template);
}
public function ajaxcatelists($id = 0) {
$arg_where = ['p.stat' => 0, 'c.stat' => 0, 'p.siteid' => $this->siteid, 'p.country_code' => $this->country_code];
$id = intval($id);
if ($id > 0) {
if (0) {
$ids = Loader::model('ProductCategory')->getChildIDArray(4);
$arg_where['cid'] = ['in', $ids];
} else {
$arg_where['cid'] = $id;
}
$category = Loader::model('ProductCategory')->getRow($id);
}
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$arg_field = ['p.id', 'p.cid', 'p.name', 'p.shortname', 'p.sort', 'p.ishot', 'p.isnew', 'p.recommend', 'p.viewcount', 'p.tags', 'p.description', 'p.picture', 'p.picture_back', 'p.createtime', 'p.createtime', 'c.name' => 'categoryname', 'c.id' => 'categoryid'];
$arg_order['p.sort'] = 'asc';
$arg_order['p.id'] = 'desc';
$dataObject = Loader::model('Product')->getCateProductLists($arg_where, $arg_order, $arg_field, 8);
if ($dataObject->isEmpty()) {
$value = ['list' => null];
} else {
$this->assign(['list' => $dataObject->items(), 'category' => $category,]);
$value = ['list' => $this->fetch()];
}
return $this->result($value, true, '分类列表');
}
public function detail($id = 0, $color = '') {
if ($id > 0) {
$detail = Loader::model('Product')->where(['stat' => 0, 'is_show' => 0, 'country_code' => $this->country_code, 'id' => $id])->find();
/*if ($this->customer_id > 0)
{
// 如果登录成功判断用户是否收藏该产品
$customer_info = json_decode(Cookie::get('c'), true);
if (empty($customer_info))
{
$detail['is_collection'] = 0;
}
else
{
$where = [
'customer_id' => $customer_info['id'],
'type' => 1,
'coll_id' => $detail['id'],
'stat' => 0
];
$result = model('collection')->where($where)->find();
if ($result)
{
$detail['is_collection'] = 1;
}
else
{
$detail['is_collection'] = 0;
}
}
}
else
{
$detail['is_collection'] = 0;
}*/
if(empty($detail)){
//return exception('该产品已下架,请检查后再操作');
return $this->error('该产品已下架,请检查后再操作');
}
$detail['is_collection'] = 0;
$category = Loader::model('ProductCategory')->getRow($detail['cid']);
$cid = Loader::model('ProductCategory')->getRow($category['pid']);
$pid = Loader::model('ProductCategory')->getRow($cid['pid']);
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$template = $category['tempdetail'];
//$prev_detail = Loader::model('Product')->getRow(['id' => ['gt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'asc']);
//$next_detail = Loader::model('Product')->getRow(['id' => ['lt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'desc']);
$value = [
'detail' => $detail,
'category' => $category,
'pid' =>$pid,
'cid'=>$cid
//'prev_detail' => $prev_detail,
//'next_detail' => $next_detail,
];
$value['product_attr'] = is_null(json_decode($detail['product_attr'])) ? $detail['product_attr'] : json_decode($detail['product_attr']);
$tmp_product_images = Loader::model('ProductImage')->getList(array('product_id' => $detail['id']), ['image_sort' => 'asc', 'id' => 'asc'], ['id', 'product_id', 'image_url', 'image_sort', 'image_desc', 'image_color']);
$value['product_dls'] = Loader::model('ProductDl')->getList(array('product_id' => $detail['id']), ['dl_sort' => 'asc', 'id' => 'desc'], ['id', 'product_id', 'dl_url', 'dl_sort', 'dl_name', 'dl_type']);
// $value['product_questions'] = Loader::model('Question')->getList(array('product' => $detail['id']), ['sort' => 'asc', 'id' => 'asc'], []);
$value['product_relateds'] = Loader::model('Product')->getRelatedProductList(array('pr.product_id' => $detail['id']), ['pr.related_sort' => 'asc', 'pr.id' => 'asc',], ['p.id', 'p.name', 'p.shortname', 'p.picture', 'p.sort', 'p.ishot', 'p.list_bk_img','p.isnew', 'p.recommend', 'p.description', 'p.createtime', 'p.brand_id','pr.id' => 'related_id', 'pr.related_product_id', 'pr.related_sort', 'pr.related_desc']);
$product_images = [];
$attributes = [];
foreach ($tmp_product_images as $k => $v) {
//兼容新旧两种版附加图、相册属性及图片
if (is_array($v['image_url']) && sizeof($v['image_url'])) {
$v['image_url'] = json_decode($v['image_url'], true); //多图Json格式
$v['image_color'] = json_decode($v['image_color'], true); //多属性规则: 颜色,尺码,排序等
foreach($detail['product_attr'] as $ka => $attr){
$attributes[$attr][] = $v['image_color'][$ka][$attr];
}
$product_images[] = $v;
}
//原版, 仅支持颜色属性
else{
$image_color = $v['image_color'];
$pos = strrpos($image_color, '/');
$key = substr($image_color, $pos + 1, strpos($image_color, '.') - $pos - 1);
$product_images[$key][] = $v;
}
}
foreach($attributes as $attrbute => $attrValue) {
$attributes[$attrbute] = array_unique($attrValue);
}
//echo "<pre>++"; print_r($attributes);
$value['attributes'] = $attributes;
$product_images = [];
$attributes = [];
foreach ($tmp_product_images as $k => $v) {
//兼容新旧两种版附加图、相册属性及图片
if (is_string($v['image_url']) && json_decode($v['image_url'])) {
$v['image_url'] = json_decode($v['image_url'], true); //多图Json格式
$v['image_color'] = json_decode($v['image_color'], true); //多属性规则: 颜色,尺码,排序等
if(isset($value['product_attr']) && is_array($value['product_attr'])){
foreach($value['product_attr'] as $ka => $attr){
if(isset($v['image_color']) && sizeof($v['image_color'])){
$attributes[$attr][] = $v['image_color'][$ka][$attr];
}
}
}
$product_images[] = $v;
}
//原版, 仅支持颜色属性
else{
$image_color = $v['image_color'];
$pos = strrpos($image_color, '/');
$key = substr($image_color, $pos + 1, strpos($image_color, '.') - $pos - 1);
$product_images[$key][] = $v;
}
}
foreach($attributes as $attrbute => $attrValue) {
$attributes[$attrbute] = array_unique($attrValue);
}
//echo "<pre>++"; print_r($attributes);
$value['attributes'] = $attributes;
$value['product_images'] = $product_images;
$value['seo_title'] = $detail['seo_title']? : $detail['name'] . '-' . config('website_seo_title');
$value['seo_keyword'] = $detail['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $detail['seo_description']? : config('website_seo_description');
$value['color'] = $color;
//评论数据获取
$where = [
'product_id' => $detail['id']
];
$count = db('shopselle')->where($where)->count();
$list = db('shopselle')->where($where)->paginate(10,$count);
foreach ($list as $k => $v){
$v['pics'] = json_decode($v['pics']);
$list[$k] = $v;
}
$page = $list->render();
$this->assign('page',$page);
$this->assign('list',$list);
$this->assign('count',$count);
$this->assign($value);
$this->viewcount($id);
$purchase_links = Db::name('product_purchase_links')->alias('links')
->field(['links.id', 'platforms.platform', 'links.link'])
->join('product_purchase_link_platforms platforms', 'platforms.id=links.platform_id')
->where('links.product_id', '=', $id)
->where('links.country_code', '=', $this->country_code)
->select();
$this->assign('purchase_links', $purchase_links);
//dump($value['product_relateds']);die;
return $this->fetch($template);
} else {
return exception('数据有误,请检查后再操作');
}
}
public function detailed($id = 0, $color = '') {
if ($id > 0) {
$detail = Loader::model('Product')->where(['stat' => 0, 'is_show' => 0, 'country_code' => $this->country_code, 'id' => $id])->find();
/*if ($this->customer_id > 0)
{
// 如果登录成功判断用户是否收藏该产品
$customer_info = json_decode(Cookie::get('c'), true);
if (empty($customer_info))
{
$detail['is_collection'] = 0;
}
else
{
$where = [
'customer_id' => $customer_info['id'],
'type' => 1,
'coll_id' => $detail['id'],
'stat' => 0
];
$result = model('collection')->where($where)->find();
if ($result)
{
$detail['is_collection'] = 1;
}
else
{
$detail['is_collection'] = 0;
}
}
}
else
{
$detail['is_collection'] = 0;
}*/
$detail['is_collection'] = 0;
$category = Loader::model('ProductCategory')->getRow($detail['cid']);
$cid = Loader::model('ProductCategory')->getRow($category['pid']);
$pid = Loader::model('ProductCategory')->getRow($cid['pid']);
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$template = $category['tempdetail'];
//$prev_detail = Loader::model('Product')->getRow(['id' => ['gt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'asc']);
//$next_detail = Loader::model('Product')->getRow(['id' => ['lt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'desc']);
$value = [
'detail' => $detail,
'category' => $category,
'pid' =>$pid,
'cid'=>$cid
//'prev_detail' => $prev_detail,
//'next_detail' => $next_detail,
];
$value['product_attr'] = is_null(json_decode($detail['product_attr'])) ? $detail['product_attr'] : json_decode($detail['product_attr']);
$tmp_product_images = Loader::model('ProductImage')->getList(array('product_id' => $detail['id']), ['image_sort' => 'asc', 'id' => 'asc'], ['id', 'product_id', 'image_url', 'image_sort', 'image_desc', 'image_color']);
$value['product_dls'] = Loader::model('ProductDl')->getList(array('product_id' => $detail['id']), ['dl_sort' => 'asc', 'id' => 'desc'], ['id', 'product_id', 'dl_url', 'dl_sort', 'dl_name', 'dl_type']);
// $value['product_questions'] = Loader::model('Question')->getList(array('product' => $detail['id']), ['sort' => 'asc', 'id' => 'asc'], []);
$value['product_relateds'] = Loader::model('Product')->getRelatedProductList(array('pr.product_id' => $detail['id']), ['pr.related_sort' => 'asc', 'pr.id' => 'asc',], ['p.id', 'p.name', 'p.shortname', 'p.picture', 'p.sort', 'p.ishot', 'p.list_bk_img','p.isnew', 'p.recommend', 'p.description', 'p.createtime', 'p.brand_id','pr.id' => 'related_id', 'pr.related_product_id', 'pr.related_sort', 'pr.related_desc']);
$product_images = [];
$attributes = [];
foreach ($tmp_product_images as $k => $v) {
//兼容新旧两种版附加图、相册属性及图片
if (is_string($v['image_url']) && json_decode($v['image_url'])) {
$v['image_url'] = json_decode($v['image_url'], true); //多图Json格式
$v['image_color'] = json_decode($v['image_color'], true); //多属性规则: 颜色,尺码,排序等
if(isset($value['product_attr']) && is_array($value['product_attr'])){
foreach($value['product_attr'] as $ka => $attr){
$attributes[$attr][] = $v['image_color'][$ka][$attr];
}
}
$product_images[] = $v;
}
//原版, 仅支持颜色属性
else{
$image_color = $v['image_color'];
$pos = strrpos($image_color, '/');
$key = substr($image_color, $pos + 1, strpos($image_color, '.') - $pos - 1);
$product_images[$key][] = $v;
}
}
foreach($attributes as $attrbute => $attrValue) {
$attributes[$attrbute] = array_unique($attrValue);
}
//echo "<pre>++"; print_r($attributes);
$value['attributes'] = $attributes;
$value['product_images'] = $product_images;
$value['seo_title'] = $detail['seo_title']? : $detail['name'] . '-' . config('website_seo_title');
$value['seo_keyword'] = $detail['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $detail['seo_description']? : config('website_seo_description');
$value['color'] = $color;
//评论数据获取
$where = [
'product_id' => $detail['id']
];
$count = db('shopselle')->where($where)->count();
$list = db('shopselle')->where($where)->paginate(10,$count);
foreach ($list as $k => $v){
$v['pics'] = json_decode($v['pics']);
$list[$k] = $v;
}
$page = $list->render();
$this->assign('page',$page);
$this->assign('list',$list);
$this->assign('count',$count);
$this->assign($value);
$this->viewcount($id);
//dump($value['product_relateds']);die;
return $this->fetch('detail_202312');
} else {
return exception('数据有误,请检查后再操作');
}
}
protected function viewcount($id) {
$view = Cookie::get('productview', 'history');
if (empty($view) || $view != $id) {
Loader::model('Product')->where(['id' => $id])->setInc('viewcount');
Cookie::set('productview', $id, ['prefix' => 'history', 'expire' => 3600]);
}
}
protected function historyproduct($id) {
$product = Cookie::get('product', 'history');
if (isset($product) && !empty($product)) {
$product_ids = explode(',', $product);
if ($product_ids[0] != $id) {
array_unshift($product_ids, $id);
$product_ids = array_unique($product_ids);
$num = Config::get('history_number') > 0 ? Config::get('history_number') : 10;
while (count($product_ids) > $num) {
array_pop($product_ids);
}
Cookie::set('product', implode(',', $product_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
} else {
Cookie::set('product', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
}
/********新品展示 *********/
public function newarrival() {
$value = Loader::model('Product')->getNewItemLists(array(),['t.sort' => 'asc', 't.id' => 'asc',], ['p.id', 'p.name', 'p.shortname', 'p.picture', 'p.sort', 'p.ishot', 'p.list_bk_img','p.isnew', 'p.recommend', 'p.description','p.brand_id', 'p.createtime', 't.id' => 'category_id', 't.name'=>'category_name', 't.sort']);
//分类分组
$newProduct = array();
foreach($value as $key => $item) {
$newProduct[$item['category_id']]['category_id'] = $item['category_id'];
$newProduct[$item['category_id']]['category_name'] = $item['category_name'];
$newProduct[$item['category_id']]['list'][] = $item;
}
//echo "<pre>---"; print_r($productCategory);die; //echo "<pre>=="; print_r($productCategory);die;
$this->assign('newProduct',$newProduct);
$value['category'] = "New Product";
$value['seo_title'] = $value['category']? : config('website_seo_title_us');
$value['seo_keyword'] = $value['category']? : config('website_seo_keyword');
$value['seo_description'] = $value['category']? : config('website_seo_description');
$this->assign($value);
return $this->fetch('newarrival');
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-01-23
* Time: 15:17
*/
namespace app\index\controller;
use think\Lang;
use think\Loader;
use think\Config;
use think\Session;
class Qqlogin extends BaseController
{
public function index(){
include_once ("../extend/API/qqConnectAPI.php");
$qc = new \QC();
$qc->qq_login();
}
}

87
app/index/controller/Search.php Executable file
View File

@@ -0,0 +1,87 @@
<?php
namespace app\index\controller;
use think\Loader;
use think\Config;
use think\Db;
class Search extends BaseController {
public function index() {
$skeyword = $this->request->get('skeyword');
$search = [];
$name_word = '';
$brand_word = '';
if ($skeyword != '') {
$skeyword = trim($skeyword);
$search['skeyword'] = $skeyword;
$pos = strpos($skeyword, '(');
if ($pos === false) {
$name_word = $brand_word = $skeyword;
} else {
$name_word = substr($skeyword, 0, $pos);
$brand_word = substr($skeyword, $pos+1, -1);
}
$arg_where = [
'a.name|a.brand_id|a.keyword|b.sku' => ['like', '%' . $name_word . '%']
];
Config::set('paginate.query', ['skeyword' => $skeyword]);
}
$arg_where['a.stat'] = 0;
// $arg_where['b.stat'] = 0;
$arg_where['a.country_code'] = $this->country_code;
$arg_where['a.is_show'] = 0;
$field = ['a.id', 'a.name', 'a.description', 'a.list_bk_img' => 'picture', 'a.createtime','a.brand_id', 'b.sku', "'productdetail'" => 'link'];
$dataObject = model('product')->alias('a')->join('product_sku b', 'a.brand_id=b.brand_id', 'LEFT')->field($field)->where($arg_where)->group('a.id')->paginate(12);
// echo model('product')->getLastSql();die;
$list = $dataObject->items();
// tiaoshi($list);die;
$arr_name = mb_str_split(strtolower($name_word));
$arr_brand = mb_str_split(strtolower($brand_word));
if (!empty($skeyword))
{
foreach ($list as $key => $value)
{
$weight = 0;
$curr_arr_name = mb_str_split(strtolower($value['name']));
$curr_arr_brand = mb_str_split(strtolower($value['brand_id']));
$weight += count(array_intersect($arr_name, $curr_arr_name));
$weight += count(array_intersect($arr_brand, $curr_arr_brand));
$list[$key] = $value;
$list[$key]['weight'] = $weight;
}
$len = count($list);
for ($i=0; $i<$len-1; $i++)
{
for ($j=0; $j<$len-1-$i; $j++)
{
if ($list[$j]['weight'] < $list[$j+1]['weight'])
{
$tmp = $list[$j];
$list[$j] = $list[$j+1];
$list[$j+1] = $tmp;
}
}
}
}
// tiaoshi($list);die;
$value = [
'list' => $list,
'page' => $dataObject->render(),
];
$value['search'] = $search;
$value['name_word'] = $name_word;
$value['brand_word'] = $brand_word;
$this->assign($value);
return $this->fetch();
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace app\index\controller;
use think\Loader;
use think\Config;
class Singlepage extends BaseController {
public function detail($id = 0, $view = '') {
if ($id > 0) {
$singlepage = Loader::model('Singlepage')->getRow($id);
if (empty($singlepage)) {
return exception('数据有误,请检查后再操作');
}
$value['singlepage'] = $singlepage;
$value['seo_title'] = $singlepage['seo_title']? : config('website_seo_title');
$value['seo_keyword'] = $singlepage['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $singlepage['seo_description']? : config('website_seo_description');
$this->assign($value);
if ($view) {
return $this->fetch($view);
} else {
return $this->fetch();
}
}
return exception('数据有误,请检查后再操作');
}
}

303
app/index/controller/TopsNas.php Executable file
View File

@@ -0,0 +1,303 @@
<?php
namespace app\index\controller;
use think\Loader;
class TopsNas extends BaseController
{
public function _initialize()
{
parent::_initialize();
parent::nasNavigation();
}
private function getBanners($typeids)
{
$banners = Loader::model("Banner")->alias('b')->field([
'b.id',
'b.typeid',
'bt.name' => 'typename',
'bt.description' => 'typedesc',
'b.name',
'b.categoryid',
'b.url',
'b.picture',
'b.alt',
'b.style',
'b.description' => 'desc',
'b.descolor',
'b.btncolor',
'b.videourl',
])
->join('banner_type bt', 'bt.stat= 0 and bt.id=b.typeid')
->where('b.stat', '=', 0)
->where('b.typeid', 'in', $typeids)
->order(['sort' => 'asc', 'id' => 'asc'])
->select();
$chucks = [];
foreach ($banners as $val) {
if (empty($chucks['typeid_' . $val['typeid']])) {
$chucks['typeid_' . $val['typeid']]['id'] = $val['typeid'];
$chucks['typeid_' . $val['typeid']]['name'] = $val['typename'];
$chucks['typeid_' . $val['typeid']]['desc'] = $val['typedesc'];
$chucks['typeid_' . $val['typeid']]['banners'] = [];
}
$link = $val['url'];
if (empty($val['url']) && !empty($val['categoryid'])) {
$link = url_rewrite('productsub', ['id' => $val['categoryid']]);
}
$chucks['typeid_' . $val['typeid']]['banners'][] = [
'id' => $val['id'],
'name' => $val['name'],
'link' => $link,
'picture' => $val['picture'],
'alt' => $val['alt'],
'style' => $val['style'],
'desc' => $val['desc'],
'desc_color' => $val['descolor'],
'btn_color' => $val['btncolor'],
'video_url' => $val['videourl'],
];
}
return $chucks;
}
/**
* nas专题首页
*/
public function index()
{
$chucks = $this->getBanners([107, 108, 109, 110, 111, 112]);
$data = [
'swiper' => $chucks['typeid_107'],
'product' => $chucks['typeid_108'],
'video' => $chucks['typeid_109'],
'plan' => $chucks['typeid_110'],
'weline' => $chucks['typeid_111'],
'download' => $chucks['typeid_112'],
];
$this->assign("data", $data);
return $this->fetch();
}
/**
* nas新品公测
*/
public function beta()
{
return $this->fetch();
}
/**
* nas 客户合作
*/
public function cooperation()
{
$chucks = $this->getBanners([119, 120, 121]);
$data = [
'image_text' => $chucks['typeid_119'],
'advantage' => $chucks['typeid_120'],
'expectation' => $chucks['typeid_121'],
];
$data['expectation']['banners'] = array_chunk($data['expectation']['banners'], 3);
$this->assign("data", $data);
return $this->fetch();
}
/**
* getCategoryChildren 获取子孙分类id
*/
private function getCategoryChildren($category)
{
return \think\Db::query("
SELECT t2.id
FROM (
SELECT
@r AS _id, (SELECT @r := GROUP_CONCAT(id) FROM cod_article_category WHERE FIND_IN_SET(pid, _id)) AS parent_id
FROM
(SELECT @r := $category) vars, cod_article_category h
WHERE @r <> 0) t1
JOIN cod_article_category t2
ON FIND_IN_SET(t2.pid, t1._id)
ORDER BY t2.id;
");
}
/**
* getProductSeriesIdMaps 获取文章系列型号
*/
private function getProductSeriesIdMaps($article)
{
$series = [];
$array_items = array_column($article, 'product_series');
array_walk($array_items, function ($val) use (&$series) {
$series = array_merge($series, explode(',', $val));
});
if (!empty($series)) {
$product_series = Loader::model('ProductSeries')
->where('id', 'in', array_unique($series))
->column('name', 'id');
foreach ($article as $key => $val) {
$p_series = explode(',', $val['product_series']);
$p_item = [];
foreach ($p_series as $k => $v) {
if (!empty($product_series[$v])) {
$p_item[] = $product_series[$v];
}
}
$article[$key]['product_series'] = $p_item;
}
}
return $article;
}
/**
* getProductSeries 获取产品系列
*/
private function getProductSeries()
{
return Loader::model('ProductSeries')
->field([
'id',
'name',
])
->where('stat', '=', 0)
->where('isshow', '=', 1)
->order(['id' => 'asc', 'sort' => 'asc'])
->select();
}
/**
* getCategoryTree 获取特定文章分类树
*/
private function getCategoryTree($cid = 36)
{
// 设备
$category = Loader::model('ArticleCategory')
->field([
'id',
'pid',
'name',
])
->where('isshow', '=', 1)
->where('country_code', '=', $this->country_code)
->order(['sort' => 'asc'])
->select();
$category_array = collection($category)->toArray();
$category_tree = $this->buildTree($category_array, $cid);
return $category_tree;
}
/**
* guide 使用教程
*/
public function guide()
{
if ($this->request->isAjax()) {
try {
$param = [
'series' => input("get.series/d"),
'device' => input('get.device/d'),
'category' => input('get.category'),
'keywords' => input('get.keywords'),
'page' => input('get.page/d', 1),
'size' => input('get.size/d', 4),
];
$data = Loader::model('Article')
->field([
'id',
'name',
'description',
'product_series',
'content',
])
->where('stat', '=', 0)
->where('country_code', '=', $this->country_code)
->where(function ($query) use ($param) {
if (!empty($param['series'])) {
$query->where(sprintf('find_in_set(%s, `product_series`)', $param['series']));
}
if (!empty($param['keywords'])) {
$query->where(function ($q) use ($param) {
$q->where('name', 'like', '%' . $param['keywords'] . '%')
->whereOr(sprintf('MATCH(content) AGAINST("%s" IN BOOLEAN MODE)', $param['keywords']));
});
}
$category = [];
if (!empty($param['device']) && empty($param['category'])) {
$category = array_merge([$param['device']], array_column($this->getCategoryChildren($param['device']), 'id'));
}
if (!empty($param['category'])) {
$category[] = $param['category'];
}
if (!empty($category)) {
$query->where('cid', 'in', $category);
}
})
->order(['id' => 'desc', 'sort' => 'desc'])
->paginate($param['size']);
// 组装系列型号
$article = $this->getProductSeriesIdMaps($data->items());
return json([
'code' => 0,
'data' => [
'article' => $article,
'page' => [
'current_page' => $data->currentPage(),
'total_page' => $data->lastPage(),
'list_size' => $data->listRows(),
'total_size' => $data->total(),
],
],
'message' => 'success',
]);
} catch (\Throwable $th) {
return json([
'code' => 1,
'data' => [],
'message' => $th->getMessage(),
]);
}
}
// 型号
$this->assign('product_series', $this->getProductSeries());
// 设备
$this->assign('category', $this->getCategoryTree(36));
// 文章列表
$article = Loader::model('Article')
->field([
'id',
'name',
'description',
'product_series',
'content',
])
->where('stat', '=', 0)
->where('country_code', '=', $this->country_code)
->where('cid', 'in', array_merge([38], array_column($this->getCategoryChildren(38), 'id')))
->order(['id' => 'desc', 'sort' => 'desc'])
->paginate(4);
$this->assign('article', $this->getProductSeriesIdMaps($article->items()));
$this->assign('page', [
'current_page' => $article->currentPage(),
'total_page' => $article->lastPage(),
'list_size' => $article->listRows(),
'total_size' => $article->total(),
]);
return $this->fetch();
}
}

142
app/index/controller/User.php Executable file
View File

@@ -0,0 +1,142 @@
<?php
namespace app\index\controller;
use think\Lang;
use think\Loader;
use think\Config;
use think\Session;
class User extends BaseController {
// 初始化
protected function _initialize() {
parent::_initialize();
if ($this->customer_id <= 0) {
abort(redirect(url('/login')));
}
}
public function index() {
$row = Loader::model('Customer')->getRow(['id' => $this->customer_id]);
if (empty($row)) {
return exception('数据有误,请检查后再操作');
}
$value['hangye'] = (array) Config::get('website_hangye');
$value['zhiye'] = (array) Config::get('website_zhiye');
$value['customer'] = $row;
$this->assign($value);
return $this->fetch();
}
public function update() {
if ($this->request->isPost()) {
$data = $this->request->post();
if (empty($data) || !is_array($data)) {
return $this->error(Lang::get('incorrect operation'));
}
// //验证规则
// $validaterule = ['birthday' => 'require|date',];
// //验证提示信息
// $validatemsg = ['birthday.date' => '生日不是日期格式',];
// $valid_result = $this->validate($data, $validaterule, $validatemsg);
// if (true !== $valid_result) {
// // 验证失败 输出错误信息
// return $this->error($valid_result);
// }
$data['id'] = $this->customer_id;
$model = Loader::model('Customer')->updateRow($data);
if ($model && $model->getData('id')) {
return $this->success(Lang::get('operation successed'));
} else {
return $this->error(Lang::get('operation failed'));
}
}
return $this->error(Lang::get('incorrect operation'));
}
public function resetpwd() {
if ($this->request->isPost()) {
$data = $this->request->post();
if (empty($data) || !is_array($data)) {
return $this->error(Lang::get('incorrect operation'));
}
//验证规则
$validaterule = [
'password' => 'require|min:6|max:32',
'repassword' => 'require|confirm:password',
];
//验证提示信息
$validatemsg = [
'password.require' => '密码不能为空',
'password.min' => '密码不少于6个字符',
'password.max' => '密码不多于32个字符',
'repassword.require' => '确认密码不能为空',
'repassword.confirm' => '两次密码不相符',
];
$valid_result = $this->validate($data, $validaterule, $validatemsg);
if (true !== $valid_result) {
// 验证失败 输出错误信息
return $this->error($valid_result);
}
$row = Loader::model('Customer')->getRow(['id' => $this->customer_id]);
if (empty($row)) {
return $this->error('数据有误,请检查后再操作');
}
$data['id'] = $this->customer_id;
$model = Loader::model('Customer')->updatePassword($data);
if ($model && $model->getData('id')) {
return $this->success('修改密码成功');
}
}
return $this->error(Lang::get('incorrect operation'));
}
public function resetemail() {
if ($this->request->isPost()) {
$data = $this->request->post();
if (empty($data) || !is_array($data)) {
return $this->error(Lang::get('incorrect operation'));
}
//验证规则
$validaterule = ['email' => 'email|unique:customer,email',];
//验证提示信息
$validatemsg = [
'email.email' => '邮箱格式错误',
'email.unique' => '邮箱已经被使用',
];
$valid_result = $this->validate($data, $validaterule, $validatemsg);
if (true !== $valid_result) {
// 验证失败 输出错误信息
return $this->error($valid_result);
}
$row = Loader::model('Customer')->getRow(['id' => $this->customer_id]);
if (empty($row)) {
return $this->error('数据有误,请检查后再操作');
}
$model = Loader::model('Customer')->update(['email' => $data['email'], 'id' => $this->customer_id]);
if ($model && $model->getData('id')) {
return $this->success('修改邮箱成功');
}
}
return $this->error(Lang::get('incorrect operation'));
}
public function resettx() {
if ($this->request->isPost()) {
$data = $this->request->post();
$txarr = range(0, 5);
shuffle($txarr);
$data['picture'] = '/uploads/user/ns' . $txarr[0] . '.jpg';
$data['id'] = $this->customer_id;
$model = Loader::model('Customer')->updateRow($data);
if ($model && $model->getData('id')) {
return $this->success(Lang::get('operation successed'), null, ['picture' => $data['picture']]);
} else {
return $this->error(Lang::get('operation failed'));
}
}
return $this->error(Lang::get('incorrect operation'));
}
}

186
app/index/controller/Video.php Executable file
View File

@@ -0,0 +1,186 @@
<?php
namespace app\index\controller;
use think\Loader;
use think\Cookie;
use think\Config;
class Video extends BaseController {
public function lists() {
$skeyword = $this->request->get('skeyword', '', 'urldecode');
$arg_where = ['a.siteid' => $this->siteid, 'country_code' => $this->country_code, 'isshow' => 1, 'stat' => 0];
if (!empty($skeyword)) {
$skeyword = trim($skeyword);
$arg_where['a.name'] = ['like', '%' . $skeyword . '%'];
Config::set('paginate.query', ['skeyword' => $skeyword]); //分页参数
}
$videoCategory = Loader::model('VideoCategory')->getList(['siteid' => $this->siteid, 'stat' => 0, 'isshow' => 1, 'country_code' => $this->country_code], ['sort', 'id'], ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'image1', 'image2', 'classtype', 'url']);
$value = [
'videoCategory' => $videoCategory,
];
$value['seo_title'] = config('video_seo_title')? : config('website_seo_title');
$value['seo_keyword'] = config('video_seo_keyword')? : config('website_seo_keyword');
$value['seo_description'] = config('video_seo_description')? : config('website_seo_description');
$this->assign($value);
return $this->fetch();
}
public function catelists($id = 0) {
$arg_where = ['a.siteid' => $this->siteid, 'a.country_code' => $this->country_code];
$id = intval($id);
if ($id > 0) {
$category = Loader::model('VideoCategory')->getRow($id);
if ($category['haschild']) {
$ids = Loader::model('VideoCategory')->getChildIDArray($id);
$arg_where['cid'] = ['in', $ids];
} else {
$arg_where['cid'] = $id;
}
}
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
unset($category['siteid']);
$value['category'] = $category;
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
if ($skeyword != '') {
$skeyword = trim($skeyword);
$search['skeyword'] = $skeyword;
$arg_where['a.name'] = ['like', '%' . $search['skeyword'] . '%'];
Config::set('paginate.query', ['skeyword' => $skeyword]); //分页参数
$value['search'] = $search;
}
switch ($category['classtype']) {
case 2:
$template = $category['templist'];
$arg_order = ['a.id' => 'desc'];
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.viewcount', 'a.videopath', 'a.videourl', 'a.description', 'a.picture', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = Loader::model('Video')->getCateVideoLists($arg_where, $arg_order, $arg_field, 10);
$value['list'] = $dataObject->isEmpty() ? null : $dataObject->items();
$value['page'] = $dataObject->render();
if ($this->request->isAjax()) {
return $this->result($value, true, '视频列表');
}
$videoCategory = Loader::model('VideoCategory')->getList(['siteid' => $this->siteid, 'stat' => 0, 'isshow' => 1, 'country_code' => $this->country_code], ['sort', 'id'], ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'image1', 'image2', 'classtype', 'url']);
$value['videoCategory'] = $videoCategory;
break;
case 3:
header('location:' . $category['url']);
exit;
break;
default:
$template = $category['tempindex'];
break;
}
$value['seo_title'] = $category['seo_title']? : config('website_seo_title');
$value['seo_keyword'] = $category['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $category['seo_description']? : config('website_seo_description');
$this->assign($value);
return $this->fetch($template);
}
public function detail($id = 0) {
if ($id > 0) {
$detail = Loader::model('Video')->getRow($id);
if (empty($detail)) {
return exception('数据有误,请检查后再操作');
}
//$addvideo = Loader::model('VideoAddition')->getRowAddition(['aid' => $detail['id']]);
$category = Loader::model('VideoCategory')->getRow($detail['cid']);
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
//$prev_detail = Loader::model('Video')->getRow(['id' => ['gt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'asc']);
//$next_detail = Loader::model('Video')->getRow(['id' => ['lt', $id], 'cid' => $category['id'], 'stat' => 0], ['id', 'name'], ['id' => 'desc']);
$value = [
'detail' => $detail,
//'addvideo' => $addvideo,
'category' => $category,
//'prev_detail' => $prev_detail,
//'next_detail' => $next_detail,
];
$value['seo_title'] = $detail['seo_title']? : $detail['name'] . '-' . config('website_seo_title');
$value['seo_keyword'] = $detail['seo_keyword']? : config('website_seo_keyword');
$value['seo_description'] = $detail['seo_description']? : config('website_seo_description');
$this->assign($value);
$this->viewcount($id);
return $this->fetch();
} else {
return exception('数据有误,请检查后再操作');
}
}
protected function viewcount($id) {
$view = Cookie::get('videoview', 'history'); //print_r($history);exit;
if (empty($view) || $view != $id) {
Loader::model('Video')->where(['id' => $id])->setInc('viewcount');
Cookie::set('videoview', $id, ['prefix' => 'history', 'expire' => 3600]);
}
}
protected function historyvideo($id) {
$video = Cookie::get('video', 'history'); //print_r($history);exit;
if (isset($video) && !empty($video)) {
$video_ids = explode(',', $video);
if ($video_ids[0] != $id) {
array_unshift($video_ids, $id);
$video_ids = array_unique($video_ids);
$num = Config::get('history_number') > 0 ? Config::get('history_number') : 10;
//$video_ids = array_slice($video_ids, 0, $num);
while (count($video_ids) > $num) {
array_pop($video_ids);
}
Cookie::set('video', implode(',', $video_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
} else {
Cookie::set('video', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
}
public function items($id = 0) {
$arg_where = ['a.siteid' => $this->siteid, 'a.country_code' => $this->country_code];
$id = intval($id);
$category = array();
if ($id > 0) {
$category = Loader::model('VideoCategory')->getRow($id);
if ($category['haschild']) {
$ids = Loader::model('VideoCategory')->getChildIDArray($id);
//$arg_where['cid'] = ['in', $ids];
}
}
unset($category['siteid']);
$value['category'] = $category;
$arg_order = ['a.id' => 'desc'];
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.viewcount', 'a.videopath', 'a.videourl', 'a.description', 'a.picture', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
$dataObject = Loader::model('Video')->getCateVideoLists($arg_where, $arg_order, $arg_field, 10);
$value['list'] = $dataObject->isEmpty() ? null : $dataObject->items();
$value['page'] = $dataObject->render();
if ($this->request->isAjax()) {
return $this->result($value, true, '视频列表');
}
$videoCategory = Loader::model('VideoCategory')->getList(['siteid' => $this->siteid, 'stat' => 0, 'isshow' => 1, 'country_code' => $this->country_code], ['sort', 'id'], ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'image1', 'image2', 'classtype', 'url']);
$value['videoCategory'] = $videoCategory;
//echo "<pre>=="; print_r($dataObject->items());
$value['seo_title'] = isset($category['seo_title']) ? : config('website_seo_title');
$value['seo_keyword'] = isset($category['seo_keyword'])? : config('website_seo_keyword');
$value['seo_description'] = isset($category['seo_description'])? : config('website_seo_description');
$this->assign($value);
return $this->fetch();
}
}