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

188
app/us/controller/Ad.php Executable file
View File

@@ -0,0 +1,188 @@
<?php
namespace app\us\controller;
use think\Lang;
use think\Loader;
use think\Config;
use app\common\controller\BaseController;
class Ad extends BaseController {
private $country_code = 'US';
public function tags($tags = '', $num = 1) {
if ($tags) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adus-' . md5($tags);
$htmlbody = $nocache ? '' : $this->cacheGet($cacheTag);
// tiaoshi($htmlbody);die;
if (empty($htmlbody)) {
$list = Loader::model('Ad')->getList(['stat' => ['eq', 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('adTagUs')->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('adTagUs')->set($cacheTag, $htmlbody, $expire);
}
echo $htmlbody;
exit;
}
exit(' Error! ');
}
public function tagsli($tags = '', $num = 1) {
if ($tags) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adus-' . md5($tags);
$htmlbody = $nocache ? '' : $this->cacheGet($cacheTag);
if (empty($htmlbody)) {
$list = Loader::model('Ad')->getList(['stat' => 0, 'tags' => $tags, 'typeid' => 26, '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('adTagUs')->set($cacheTag, "<!--\r\ndocument.write(\"<!--408-->\");\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";
//print_r($htmlbody);exit;
}
$this->cacheTag('adTagUs')->set($cacheTag, $htmlbody, $expire);
}
echo $htmlbody;
exit;
}
exit(' Error! ');
}
public function index($id = 0) {
if ($id > 0) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adus-' . $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('adTagUs')->set($cacheTag, "<!--\r\ndocument.write(\"<!--405-->\");\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('adTagUs')->set($cacheTag, $adbody, $expire);
}
echo $adbody;
exit;
}
exit(' Error! ');
}
public function cat($id = '', $num = 1) {
if ($id) {
$nocache = $this->request->param('nocache', 0);
$cacheTag = 'adus-' . $id;
$htmlbody = $nocache ? '' : $this->cacheGet($cacheTag);
if (empty($htmlbody)) {
$list = Loader::model('Ad')->getList(['stat' => ['eq', 0], 'typeid' => $id, '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('adTagUs')->set($cacheTag, "<!--\r\ndocument.write(\"<!--406-->\");\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('adTagUs')->set($cacheTag, $htmlbody, $expire);
}
echo $htmlbody;
exit;
}
exit(' Error! ');
}
public function previewjs($id) {
$id = intval($id);
if ($id > 0) {
echo '<script src="' . url('us/ad/index', ['id' => $id]) . '?nocache=1" language="javascript"></script>';
}
exit();
}
}

176
app/us/controller/Agents.php Executable file
View File

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

View File

@@ -0,0 +1,128 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-07-23
* Time: 15:40
*/
namespace app\us\controller;
use think\Loader;
class Antifake extends BaseController
{
public function 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'];
$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 {
$sn = https_request('http://mes.orico.com.cn:8084/api/SN/', $snnum);
$sn = json_decode($sn, true);
$sn = json_decode($sn, true);
if ($sn['result'] == 1) {
$data['sn'] = $sn['serial_number'];
$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['supplier'];
$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['sn']=$snnum;
$data['result'] = $sn['result'];
$this->assign('data',$data);
}
}
}
return $this->fetch();
}
public function anti_fake_result()
{
if ($_POST) {
$post = $this->request->post();
$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();
if ($arr) {
$data = $arr;//dump($data['sn']);die;
$data['result'] = 1;
$this->assign('data', $data);
} else {
$sn = https_request('http://mes.orico.com.cn:8084/api/values/', $fake);
$sn = json_decode($sn, true);
$sn = json_decode($sn, true);//dump($sn);die;
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['supplier'];
$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();
}
}

186
app/us/controller/Antifake.php Executable file
View File

@@ -0,0 +1,186 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-07-23
* Time: 15:40
*/
namespace app\us\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();//dump($arr);die;
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);
//echo "<pre>=="; print_r($sn);die;
$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'];
//$data['department'] = $sn['B2B_B2C'];
$data['made_up_articles_name'] = $sn['made_up_articles_name'];
if (strpos($data['made_up_articles_name'], 'NGFF') !== false) {
$data['aditmend'] = 5;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
}
else{
$data['delivery_time'] = '';
}
}
elseif(strpos($data['made_up_articles_name'], 'NVME') !== false){
$data['aditmend'] = 3;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+3year", $time));
}
else{
$data['delivery_time'] = '';
}
}
$data['chicktime'] = date("Y-m-d H:i:s");
//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();
//$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();
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);//dump($sn);die;
$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");
if (strpos($data['made_up_articles_name'], 'NGFF') !== false) {
$data['aditmend'] = 5;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+5year", $time));
}
else{
$data['delivery_time'] = '';
}
}
elseif(strpos($data['made_up_articles_name'], 'NVME') !== false){
$data['aditmend'] = 3;
if($sn['delivery_time']){
$data['delivery_time'] = $sn['delivery_time'];
$time = strtotime($data['delivery_time']);
$data['mendtime'] = date('Y-m-d H:i:s', strtotime("+3year", $time));
}
else{
$data['delivery_time'] = '';
}
}
/* $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();
}
}

217
app/us/controller/Article.php Executable file
View File

@@ -0,0 +1,217 @@
<?php
namespace app\us\controller;
use think\Loader;
use think\Cookie;
use think\Config;
class Article extends BaseController {
public function lists() {
$arg_where = ['a.country_code' => $this->country_code];
$arg_order = ['a.id' => 'desc'];
$search = array();
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
if ($skeyword != '') {
$arg_where['a.name'] =['like', '%' . $search['skeyword'] . '%'];
$search['name'] = $search['skeyword'];
}
$arg_order = ['a.id' => '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(),
'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) {
$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');
}
}

31
app/us/controller/Authcode.php Executable file
View File

@@ -0,0 +1,31 @@
<?php
namespace app\us\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,298 @@
<?php
namespace app\us\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 = 'US';
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();
}
$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);
$business_email = (string) Config::get('business_email');
$this->view->assign('business_email', $business_email);
$this->view->assign('seo_title', (string) Config::get('website_seo_title_us'));
$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);
}
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);
//搜索推荐产品
$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'=>79,'stat' => 0, 'country_code' => COUNTRY_CODE], ['sort' => 'asc', 'id' => 'desc'], array('*'), 3);
$this->view->assign('historyList', $historyList);
//echo "<pre>=="; print_r($historyList);
//导航
$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($this->nav_header);die;
//echo Loader::model('banner')->getlastsql();
$this->productCategory = $this->list_to_tree($this->categoryList);
$this->view->assign('productCategory', $this->productCategory);
$this->view->assign('allCategoryList', $this->categoryList);
}
//导航初始化
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' => 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' => 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' => 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' => 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'] = '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']);
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) {
//dump($root);die;
//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;
}
}

189
app/us/controller/Blog.php Executable file
View File

@@ -0,0 +1,189 @@
<?php
namespace app\us\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('数据有误,请检查后再操作');
}
}
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]);
}
}
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]);
}*/
}
//添加评论 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');
}
}

118
app/us/controller/Bulk.php Executable file
View File

@@ -0,0 +1,118 @@
<?php
namespace app\us\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('数据有误,请检查后再操作');
}
}
protected function viewcount($id) {
/*$view = Cookie::get('articleview', 'history'); //print_r($history);exit;
if (empty($view) || $view != $id) {
Loader::model('Article')->where(['id' => $id])->setInc('viewcount');
Cookie::set('articleview', $id, ['prefix' => 'history', 'expire' => 3600]);
}*/
}
protected function historyarticle($id) {
/*$article = Cookie::get('article', 'history'); //print_r($history);exit;
if (isset($article) && !empty($article)) {
$article_ids = explode(',', $article);
if ($article_ids[0] != $id) {
array_unshift($article_ids, $id);
$article_ids = array_unique($article_ids);
$num = Config::get('history_number') > 0 ? Config::get('history_number') : 10;
//$article_ids = array_slice($article_ids, 0, $num);
while (count($article_ids) > $num) {
array_pop($article_ids);
}
Cookie::set('article', implode(',', $article_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
} else {
Cookie::set('article', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}*/
}
public function create()
{
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(403, 'Data error ');
if ($data['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($_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' => isset($data['company']) ? $data['company'] : '',
'first_name' => $data['name'],
'last_name' => isset($data['last_name']) ?$data['last_name'] : '',
'email' => $data['email'],
'phone' => isset($data['last_name']) ? $data['phone'] : '',
'country' => isset($data['last_name']) ? $data['country'] : '',
'interested' => isset($data['last_name']) ? $data['interested'] : '',
'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');
}
}

119
app/us/controller/BulkInquiry.php Executable file
View File

@@ -0,0 +1,119 @@
<?php
namespace app\us\controller;
use think\Loader;
use think\Cookie;
use think\Config;
use think\Session;
class BulkInquiry extends BaseController {
public function BulkInquiry() {
return $this->view->fetch();
}
public function detail($id = 0) {
if ($id > 0) {
return $this->fetch();
} else {
return exception('数据有误,请检查后再操作');
}
}
protected function viewcount($id) {
/*$view = Cookie::get('articleview', 'history'); //print_r($history);exit;
if (empty($view) || $view != $id) {
Loader::model('Article')->where(['id' => $id])->setInc('viewcount');
Cookie::set('articleview', $id, ['prefix' => 'history', 'expire' => 3600]);
}*/
}
protected function historyarticle($id) {
/*$article = Cookie::get('article', 'history'); //print_r($history);exit;
if (isset($article) && !empty($article)) {
$article_ids = explode(',', $article);
if ($article_ids[0] != $id) {
array_unshift($article_ids, $id);
$article_ids = array_unique($article_ids);
$num = Config::get('history_number') > 0 ? Config::get('history_number') : 10;
//$article_ids = array_slice($article_ids, 0, $num);
while (count($article_ids) > $num) {
array_pop($article_ids);
}
Cookie::set('article', implode(',', $article_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
} else {
Cookie::set('article', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}*/
}
public function create()
{
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(403, 'Data error ');
if ($data['company'] == '')
return $this->json(403-2, 'Company name cannot be empty');
if ($data['name'] == '' && $data['last_name'])
return $this->json(403-3, 'Your name cannot be empty');
if ($data['email'] == '')
return $this->json(403-4, 'Email cannot be empty');
// if ($data['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'],
'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,
'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('bulk_inquiry')->insert($insert_data);
if (!$result)
return $this->json(201, 'Failure to submit');
return $this->json(200, 'ok');
}
}

37
app/us/controller/Clicksum.php Executable file
View File

@@ -0,0 +1,37 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-12-10
* Time: 13:48
*/
namespace app\us\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);
}
}

505
app/us/controller/Customer.php Executable file
View File

@@ -0,0 +1,505 @@
<?php
namespace app\us\controller;
use think\Cookie;
use think\Lang;
use think\Loader;
use think\Config;
use think\Session;
use think\Cache;
class Customer extends BaseController {
public function index() {
if ($this->customer_id > 0)
{
$this->redirect(url('us/customer/personal'));
}
$url = $this->request->get('url');
$url = $url != '' ? $url : '';
$this->assign('url', $url);
return $this->fetch();
}
# 用旧密码改新密码
public function update_pwd()
{
$data = $this->request->post();
// tiaoshi($data);die;
if (empty($data) || $this->customer_id <= 0)
{
return $this->json(-1, 'Data error');
}
if ($this->customer_info['have_pwd'])
{
$customer_info = model('customer')->where(['id' => $this->customer_id])->find();
if (md5($data['old_password']) != $customer_info['password'])
{
return $this->json(-2, 'Old password incorrect');
}
}
$update_data = [
'password' => md5($data['password']),
'salt' => $data['password']
];
$result = model('customer')->where(['id' => $this->customer_id])->update($update_data);
if (!$result)
{
return $this->json(-4, 'New passwords do not match.');
}
$customer_info = model('customer')->getBasicInfo($this->customer_id);
$this->set_login_token($customer_info);
return $this->json(200, 'Your password has been updated.');
}
# 用邮箱改密码
public function update_forget_pwd()
{
$data = $this->request->post();
// tiaoshi($data);die;
if (empty($data))
{
return $this->json(-1, 'Data error');
}
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['email']))
{
return $this->json(-2, 'Error Mail Form');
}
$customer_info = model('customer')->getBasicInfoByEmail($data['email']);
if (empty($customer_info))
{
return $this->json(-3, 'The email is not registered');
}
$token = md5($data['email'] . 'forgetpwd');
$this->cacheSet($token, $data['email'], 3600);
$result = $this->send_forgetpwd_email($data['email'], $token);
if ($result['code'] < 0)
{
return $this->json(-4, $result['msg']);
}
$this->_logout();
return $this->json(200, 'The email sending successful');
}
public function retrieve_password()
{
return view();
}
public function change_password()
{
$token = $this->request->post('token');
$password = $this->request->post('password');
$email = $this->cacheGet($token, '');
if ($email == '')
{
return $this->json(-1, 'Link Invalid');
}
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $email))
{
return $this->json(-2, 'Error Mail Form');
}
if (!preg_match("/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*-.]+$)[a-zA-Z\d!@#$%^&*-.]{8,20}$/", $password))
{
return $this->json(-3, 'The password must contain 8-20 characters and at least two types of characters.');
}
model('customer')->where(['stat' => 0, 'email' => $email])->update(['password' => md5($password)]);
$this->cacheDelete($token);
return $this->json(200, 'Your password has been updated.');
}
public function check_forgetpwd_email()
{
$token = $this->request->param('token');
$email = $this->cacheGet($token, '');
if ($email == '' || !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $email))
{
return $this->json(-1, 'Error Mail Form');
}
$password = $this->request->post('password');
if (!preg_match("/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*-.]+$)[a-zA-Z\d!@#$%^&*-.]{8,20}$/", $data['password']))
{
return $this->json(-2, 'The password must contain 8-20 characters and at least two types of characters.');
}
$customer = model('customer')->where(['stat' => 0, 'email' => $email])->find();
if (empty($customer))
{
return $this->json(-3, 'The email is not registered');
}
model('customer')->where(['stat' => 0, 'email' => $email])->update(['password' => md5($password)]);
$this->cacheDelete($token);
return $this->json(200, 'Your password has been updated.');
}
private function send_forgetpwd_email($email, $token)
{
//邮件标题
$subject = $this->request->host() . '-retrieve_password';
//邮件内容
$body = "<p>Dear $email,</p>
<p>We recently received a request to reset your password.</p>
<p>You may change your password to something secure and memorable here:</p>
<p>http://www.orico.cc/us/forgetpwd.html?token=$token</p>
<p>If you did not request to reset your password, please ignore this email and log in with your existing password.</p>
<p>Feel free to get in touch if you have any questions.</p>
<p>The Orico Team</p>
<p>supports@orico.com.cn</p>";
$res = $this->sendemail($email, $email, $subject, $body, 'oricogroup@orico.com.cn');
if ($res['code'] == 200) {
return ['code' => 200, 'msg' => "Well send you a link so you can please confirm."];
} else {
return ['code' => -3, 'msg' => $res['msg']];
}
}
public function activation()
{
$email = $this->request->param('email');
$email = isset($email) ? $email : '';
$this->assign('email', $email);
return $this->view->fetch();
}
public function forgetpwd_email()
{
return $this->view->fetch();
}
public function new_register()
{
$data = $this->request->post();
// tiaoshi($data);die;
if (empty($data) || $this->customer_id > 0)
{
return $this->json(-1, 'data error');
}
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $data['email']))
{
return $this->json(-2, 'Error Mail Form');
}
if (!isset($data['re_send']) && !preg_match("/^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*-.]+$)[a-zA-Z\d!@#$%^&*-.]{8,20}$/", $data['password']))
{
return $this->json(-3, 'The password must contain 8-20 characters and at least two types of characters.');
}
if (!isset($data['re_send']) && !$this->verify_check($data['captcha'], 'authcode'))
{
return $this->json(-4, 'Verification code error');
}
$customer = model('customer')->where(['email' => $data['email'], 'stat' => 0])->find();
if (!empty($customer))
{
return $this->json(-5, 'This email has previously been used.');
}
// if (!isset($data['re_send']))
// {
// }
// else
// {
// $token = md5($data['email'] . 'register');
// if ($this->cacheHas($token))
// {
// $this->cacheSet($token, $this->cacheGet($token), 3600);
// }
// else
// {
// return $this->json(-100, '该链接已失效,请重新获取');
// }
// }
$token = md5($data['email'] . 'register');
$result = $this->send_register_email($data['email'], $token);
if ($result['code'] < 0)
{
return $this->json(-6, $result['msg']);
}
if (!isset($data['re_send']))
{
$delimiter = '$*$%&';
$this->cacheSet($token, $data['email'] . $delimiter . md5($data['password']), 3600);
}
else
{
if ($this->cacheHas($token))
{
$this->cacheSet($token, $this->cacheGet($token), 3600);
}
else
{
return $this->json(-100, '该链接已失效');
}
}
return $this->json(200, 'Send Success');
}
public function check_register_email()
{
$token = $this->request->param('token');
$data = $this->cacheGet($token, '');
if ($data == '')
{
echo '<script>alert("Captcha Invalid")</script>';
exit;
}
$delimiter = '$*$%&';
$arr = explode($delimiter, $data);
if (!is_array($arr) || !isset($arr[0]) || !isset($arr[1]))
{
echo '<script>alert("Data Invalid")</script>';
exit;
}
$email = $arr[0];
$password = $arr[1];
if (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/", $email))
{
echo '<script>alert("Error Mail Form")</script>';
exit;
}
$customer = model('customer')->where(['stat' => 0, 'email' => $email])->find();
if (!empty($customer))
{
echo '<script>alert("This email has previously been used.")</script>';
exit;
}
$firstname = 'Orico' . rand(10000000, 99999999);
$insert_data = [
'firstname' => $firstname,
'email' => $email,
'password' => $password,
'country_code' => $this->country_code
];
$customer_id = model('customer')->insertGetId($insert_data);
if (!$customer_id)
{
echo '<script>alert("Registry Faild")</script>';
}
$customer_info = model('customer')->getBasicInfo($customer_id);
$this->set_login_token($customer_info);
$this->cacheDelete($token);
echo '<script>
alert("Registry Success");
location.href="http://www.orico.cc/us";
</script>';
exit;
}
private function send_register_email($email, $token)
{
//邮件标题
$subject = $this->request->host() . '-registry';
//邮件内容
$body = "<p>Dear $email</p><p>Thank you for registering at orico, were excited to have you with us!</p><p>Click the link below to activate your account:</p><p>http://www.orico.cc/us/customer/check_register_email.html?token=$token</p><p>The Orico Team</p><p>support@orico.com.cn</p>";
$res = $this->sendemail($email, $email, $subject, $body, 'oricogroup@orico.com.cn');
if ($res['code'] == 200) {
return ['code' => 200, 'msg' => "Well send you a link so you can please confirm."];
} else {
return ['code' => -3, 'msg' => $res['msg']];
}
}
public function new_login()
{
$data = $this->request->post();
if (empty($data) || $this->customer_id > 0)
{
return $this->json(-1, 'Data error');
}
$where = [
'stat' => 0,
'email' => $data['email']
];
$customer_info = model('customer')->where($where)->field('id, firstname, picture, sex, email, telephone, qq, birthday, password')->find();
if (empty($customer_info))
{
return $this->json(-2, 'The email is not registered');
}
if ($customer_info['password'] != md5($data['password']) || empty($data['password']))
{
return $this->json(-3, 'Email address or password incorrect');
}
$this->set_login_token($customer_info);
return $this->json(200, 'Login Successful');
}
public function register() {
if ($this->customer_id > 0) {
return $this->redirect(url('us/customer/index'));
}
return $this->fetch();
}
public function personal()
{
if ($this->customer_id <= 0)
{
$this->redirect(url('us/customer/index'));
}
return $this->fetch();
}
public function my_collection()
{
if ($this->customer_id <= 0)
{
$this->redirect(url('us/customer/index'));
}
$param = $this->request->param();
// tiaoshi($param);die;
$where = ['a.stat' => 0, 'b.stat' => 0, 'a.customer_id' => $this->customer_id, 'b.country_code' => $this->country_code];
if (isset($param['cid']))
{
$cid_arr = model('product_category')->getChildIDArray($param['cid']);
$where['b.cid'] = ['in', $cid_arr];
$cid = $param['cid'];
}
else
{
$cid = 0;
}
$field = ['b.id', 'b.cid', 'b.name', 'b.shortname', 'b.isnew', 'b.ishot', 'b.recommend', 'b.viewcount', 'b.brand_id'];
$order = ['a.id' => 'desc'];
$list = model('collection')->getList($where, $order, $field, 10);
foreach ($list as $key => $value) {
$product_two_img = model('product_two_img')->where(['product_id' => $value['id']])->find();
$list[$key]['product_two_img'] = $product_two_img['image_url'];
}
$data = [
'list' => $list->isEmpty() ? null : $list->items(),
'page' => $list->render(),
'cid' => $cid
];
$this->assign($data);
return $this->fetch();
}
public function new_logout()
{
$this->_logout();
return $this->redirect('us/customer/index');
}
public function forgetpwd() {
$token = $this->request->param('token') ? $this->request->param('token') : '';
$this->assign('token', $token);
return $this->fetch();
}
public function sendemail($to, $to_name, $subject, $body, $from_email = '', $from_name = 'ORICO') {
$email_host = (string) Config::get('email_host');
$email_tls = (string) Config::get('email_tls');
$email_port = (string) Config::get('email_port');
$email_user = (string) Config::get('email_user');
$email_pass = (string) Config::get('email_pass');
$email_code = (string) Config::get('email_code');
$email_replyaddr = (string) Config::get('email_replyaddr');
$website_email = (string) Config::get('website_email');
// Passing `true` enables exceptions
$mail = new \mail\PHPMailer\PHPMailer(true);
try {
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//$mail->setLanguage('en');
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
$mail->Host = $email_host;
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = $email_port;
$mail->CharSet = strtolower($email_code);
$mail->Encoding = 'base64';
$mail->SMTPKeepAlive = true;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = strtolower($email_tls);
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = $email_user;
//Password to use for SMTP authentication
$mail->Password = $email_pass;
//Set who the message is to be sent from
if ($from_email) {
$mail->setFrom($from_email, $from_name);
} else {
$mail->setFrom($email_replyaddr, 'Sender');
}
//Set an alternative reply-to address
if ($website_email) {
$mail->addReplyTo($website_email, 'Reply');
}
//Set who the message is to be sent to
$mail->addAddress($to, $to_name);
//$mail->addAddress($website_email, 'Recipient');
//Set the subject line
$mail->Subject = $subject;
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML($body);
//$mail->Body = 'This is the HTML message body <b>in bold!</b>';
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
$mail->WordWrap = 60;
//send the message, check for errors
if (!$mail->send()) {
$result = ['code' => -1, 'msg' => 'The email sending failed, try again later. '];
} else {
$result = ['code' => 200, 'msg' => 'The email sending successful'];
}
} catch (\mail\PHPMailer\Exception $e) {
$result = ['code' => -2, 'msg' => 'The email sending failed, try again later. '];
}
return $result;
}
}

328
app/us/controller/Download.php Executable file
View File

@@ -0,0 +1,328 @@
<?php
namespace app\us\controller;
use think\Loader;
use think\Cookie;
use think\Config;
class Download extends BaseController {
public function search($id = 0) {
$skeyword = $this->request->get('skeyword', '', 'urldecode');
$arg_where = ['a.siteid' => $this->siteid, '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.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'];
if (!empty($skeyword)) {
$skeyword = trim($skeyword);
$arg_where['a.name'] = ['like', '%' . $skeyword . '%'];
Config::set('paginate.query', ['skeyword' => $skeyword]); //分页参数
}
if ($id > 0) {
$category = Loader::model('DownloadCategory')->getRow($id);
}
$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['downloadCategoryEn'] = $downloadCategory;
$value['skeyword'] = $skeyword;
$value['category'] = $category;
$value['seo_title'] = config('download_seo_title')? : config('website_seo_title_us');
$value['seo_keyword'] = config('download_seo_keyword')? : config('website_seo_keyword');
$value['seo_description'] = config('download_seo_description')? : config('website_seo_description');
$this->assign($value);
return $this->fetch('catelists');
}
public function get_filter() {
$dl_name = model('download')->where(['stat' => 0, 'country_code' => $this->country_code])->field('name')->select();
$data = [
'dl_name' => $dl_name,
];
return $this->json(200, 'ok', $data);
}
public function catelists($id = 0) {
$arg_where = [
'a.siteid' => $this->siteid,
'a.country_code' => $this->country_code
];
if($this->country_code == 'US'){
$arg_where['a.cid'] = '22';
}
else{
$arg_where['a.cid'] = '1';
}
$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;
}
$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();die;
// tiaoshi($dataObject->items());die;
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(), //$dataObject->getCollection()->toArray()
'page' => $dataObject->render(),
];
if ($this->request->isAjax()) {
return $this->result($value, true, '下载列表');
}
//echo "<pre>=="; print_r($dataObject->getCollection()->toArray());die;
$downloadCategory = Loader::model('DownloadCategory')->getList(['siteid' => $this->siteid, 'stat' => 0, 'pid' => 2, 'country_code' => $this->country_code], ['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]);
ob_clean();
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileinfo['basename']);
header('Content-Length: ' . filesize($download));
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']);
$download = $directory . $detail['dl_url']; // 文件要下载的地址
Loader::model('ProductDl')->updateRow(['dl_count' => \think\Db::raw('`dl_count`+1')], ['id' => $id]);
ob_clean();
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $fileinfo['basename']);
header('Content-Length: ' . filesize($download));
readfile($download);
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'] = ['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, 'Download');
}
$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) {
//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('数据有误,请检查后再操作');
}
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);
}
}

38
app/us/controller/Email.php Executable file
View File

@@ -0,0 +1,38 @@
<?php
/**
* Created by PhpStorm.
* User: kingliang
* Date: 2020-10-21
* Time: 14:57
*/
namespace app\us\controller;
use think\Request;
use think\Config;
use think\Loader;
class Email extends BaseController
{
public function index()
{
if ($this->request->isPost()) {
$data = $this->request->post();
if (empty($data) || !is_array($data)) {
return $this->json(404, 'Email not find!!');
}
$model = Loader::model('Email');
$data['ip'] = Request::instance()->ip();
$data['createtime'] = time();
$chick = $model->chickEmail($data['email']);
if($chick==false){
return $this->json(500, 'Duplicate mailbox!');
}
$model = $model->insertRow($data);
if ($model) {
return $this->json(200, 'Success');
} else {
return $this->json(500, 'Internal server error');
}
}
}
}

241
app/us/controller/Group.php Executable file
View File

@@ -0,0 +1,241 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-09-21
* Time: 17:36
*/
namespace app\us\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 job(){
return $this->view->fetch();
}
public function policy(){
return $this->view->fetch();
}
public function culture(){
return $this->view->fetch();
}
public function fan(){
return $this->view->fetch();
}
public function charger(){
return $this->view->fetch();
}
public function submission(){
return $this->view->fetch();
}
public function honor(){
return $this->view->fetch();
}
public function question(){
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 search(){
return $this->view->fetch();
}
public function transparent(){
return $this->view->fetch();
}
public function headset(){
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 oricoindex()
{
return $this->view->fetch();
}
public function thunderbolt_3(){
return $this->view->fetch();
}
public function stripe(){
return $this->view->fetch();
}
public function series_95(){
return $this->view->fetch();
}
public function series_35(){
return $this->view->fetch();
}
public function pssd(){
return $this->view->fetch();
}
public function backup_treasure(){
return $this->view->fetch();
}
public function backuper(){
return $this->view->fetch();
}
public function report()
{
if ($this->customer_id <= 0)
$this->redirect('/login.html');
return $this->view->fetch();
}
/********20230720 顶部导航栏目************/
public function brand(){
return $this->view->fetch();
}
public function product(){
return $this->view->fetch();
}
public function achievement(){
return $this->view->fetch();
}
public function fq(){
$where = ['stat' => 0, 'country_code' => $this->country_code];
$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 query(){
return $this->view->fetch();
}
public function Contact(){
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 create_report()
{
if ($this->customer_id <= 0)
return $this->json(-100, 'Please log on first');
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(-1, 'Data error ');
if ($data['product_name'] == '')
return $this->json(-2, 'Product name cannot be empty');
if ($data['product_model'] == '')
return $this->json(-3, 'Product model cannot be empty');
if ($data['product_manufacturer'] == '')
return $this->json(-4, 'Manufacturer name 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['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, 'Email Address format error');
$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, 'Failure to submit');
return $this->json(200, 'ok');
}
}

View File

@@ -0,0 +1,113 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-09-21
* Time: 17:36
*/
namespace app\us\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 job(){
return $this->view->fetch();
}
public function policy(){
return $this->view->fetch();
}
public function culture(){
return $this->view->fetch();
}
public function fan(){
return $this->view->fetch();
}
public function charger(){
return $this->view->fetch();
}
public function Contact(){
return $this->view->fetch();
}
public function fq(){
return $this->view->fetch();
}
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 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 stripe(){
return $this->view->fetch();
}
public function series_95(){
return $this->view->fetch();
}
}

141
app/us/controller/Index.php Executable file
View File

@@ -0,0 +1,141 @@
<?php
namespace app\us\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("https://www.orico.cc/usmobile");
} else {
return $this->redirect('https://www.orico.com.cn/mobile');
}
}
//验证上级来源页
/*if (!isset($_SERVER['HTTP_REFERER'])) {
$domainUrl = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
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/Group/oricoindex");
return $this->fetch('/index');
}
else{*/
$lebel_list = getDifferentProduct("recommend",12);
$this->assign('recomment_items',$lebel_list);
$blog_list = getArticleList();
$this->assign('blog_items',$blog_list);
$faqData = getFaqList();
$this->assign('faqData',$faqData);
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('Unknown Error');
}
$data['way'] = isset($data['way']) ? $data['way'] : 'E-mail';
//$this->verify_check('yanzhengma', $data['authcode']) || $this->error('Incorrect security code');
$this->verify_check($data['authcode'], 'authcode') || $this->error('Incorrect security code');
$validaterule = [
'name' => 'require',
'subject' => 'require',
'contact' => 'require',
];
$validatemsg = [
'name.require' => 'Name cannot be empty',
'subject.require' => 'Theme cannot be empty',
'contact.require' => 'Content cannot be empty',
];
if (empty($data['way'])) {
return $this->error('Please select the correct contact information');
} else {
if ($data['way'] == 'E-mail') {
$validaterule['contact'] = 'email';
$validatemsg['contact.email'] = 'The contact information format is incorrect';
}
if ($data['way'] == 'tel') {
$validaterule['contact'] = ['regex' => '^1[345789]\d{9}$|^([0-9]{3,4}-?)?[0-9]{7,8}$'];
$validatemsg['contact.regex'] = 'The contact information format is incorrect';
}
}
$valid_result = $this->validate($data, $validaterule, $validatemsg);
if (true !== $valid_result) {
// 验证失败 输出错误信息
return $this->error($valid_result);
}
$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();
$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'] : '',
'order_id' => isset($data['order_id']) ? $data['order_id'] : '',
'country' => isset($data['country']) ? $data['country'] : '',
'channel' => isset($data['channel']) ? $data['channel'] : '',
'addtime' => date('Y-m-d H:i:s'),
'refer' => $referer,
'url' => $url,
'channels' => $channel,
'keyword' => $keyword,
'ip' => $fed['ip'],
'state' => $fed['country'],
'province' => $fed['province'],
'city' => $fed['city'],
'drvice' => $fed['drive'],
'user_agent' => $fed['system']." ".$fed['brower'],
];
$model = Loader::model('Msgform')->insertRow($set);
if ($model && $model->getData('id')) {
return $this->success('Success! Wait for administrator to view', url('/'));
} else {
return $this->error('Operation Failed');
}
}
return $this->result(['code' => false, 'msg' => '未知错误'], false, '未知错误');
}
}

123
app/us/controller/Inquiry.php Executable file
View File

@@ -0,0 +1,123 @@
<?php
namespace app\us\controller;
use think\Loader;
use think\Cookie;
use think\Config;
use think\Session;
class Inquiry extends BaseController {
public function inquiry() {
return $this->view->fetch();
}
public function detail($id = 0) {
if ($id > 0) {
return $this->fetch();
} else {
return exception('数据有误,请检查后再操作');
}
}
protected function viewcount($id) {
/*$view = Cookie::get('articleview', 'history'); //print_r($history);exit;
if (empty($view) || $view != $id) {
Loader::model('Article')->where(['id' => $id])->setInc('viewcount');
Cookie::set('articleview', $id, ['prefix' => 'history', 'expire' => 3600]);
}*/
}
protected function historyarticle($id) {
/*$article = Cookie::get('article', 'history'); //print_r($history);exit;
if (isset($article) && !empty($article)) {
$article_ids = explode(',', $article);
if ($article_ids[0] != $id) {
array_unshift($article_ids, $id);
$article_ids = array_unique($article_ids);
$num = Config::get('history_number') > 0 ? Config::get('history_number') : 10;
//$article_ids = array_slice($article_ids, 0, $num);
while (count($article_ids) > $num) {
array_pop($article_ids);
}
Cookie::set('article', implode(',', $article_ids), ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}
} else {
Cookie::set('article', $id, ['prefix' => 'history', 'setcookie' => true, 'expire' => 3600 * 24 * 30]);
}*/
}
public function create()
{
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(403, 'Data error ');
if ($data['company'] == '')
return $this->json(403-2, 'Company name cannot be empty');
if ($data['name'] == '' && $data['last_name'])
return $this->json(403-3, 'Your name cannot be empty');
if ($data['email'] == '')
return $this->json(403-4, 'Email cannot be empty');
if ($data['country'] == '')
return $this->json(403-5, 'Country region 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'],
'first_name' => $data['name'],
'last_name' => $data['last_name'],
'email' => $data['email'],
'phone' => trim($data['phone']),
'country' => $data['country'],
'industry' => isset($data['industry']) ? $data['industry'] : '',
'inquiry' => isset($data['inquiry']) ? $data['inquiry'] : '',
'interested' => isset($data['interested']) ? $data['interested'] : '',
'ip' => get_ip(),
'model' => isset($data['spu']) ? $data['spu'] : '',
'murl' => $_SERVER["HTTP_REFERER"],
'createtime' => date("Y-m-d H:i:s"),
'siteid' => $this->siteid,
'country_code' => $this->country_code,
'refer' => $referer,
//'url' => $url,
'channel' => $channel,
'keyword' => $keyword,
'ip' => $fed['ip'],
'state' => $fed['country'],
'province' => $fed['province'],
'city' => $fed['city'],
'drvice' => $fed['drive'],
'user_agent' => $fed['system']." ".$fed['brower'],
];
$result = model('inquiry')->insert($insert_data);
if (!$result)
return $this->json(201, 'Failure to submit');
return $this->json(200, 'ok');
}
}

96
app/us/controller/Pinglun.php Executable file
View File

@@ -0,0 +1,96 @@
<?php
namespace app\us\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_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);
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, '未知错误');
}
}

319
app/us/controller/Product.php Executable file
View File

@@ -0,0 +1,319 @@
<?php
namespace app\us\controller;
use think\Loader;
use think\Cookie;
use think\Config;
use think\Db;
class Product extends BaseController {
public function get_filter() {
if ($this->cacheHas('product_filter_us'))
{
$product_filter = $this->cacheGet('product_filter_us');
}
else
{
$product_filter = model('product')->where(['stat' => 0, 'is_show' => 0, 'country_code' => $this->country_code])->field('name, brand_id, keyword')->select();
$this->cacheSet('product_filter_us', $product_filter, 86400);
}
$data = [
'product_name' => $product_filter,
];
return $this->json(200, 'ok', $data);
}
public function lists($id = 0) {
$category = Loader::model('ProductCategory')->getRow(['stat' => 0, 'pid' => 0], null, ['id' => 'asc']);
if (empty($category)) {
return exception('数据有误,请检查后再操作');
}
$value = [
'category' => $category,
];
$value['seo_title'] = config('product_seo_title')? : config('website_seo_title_us');
$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];
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'];
// $arg_order = ['a.id' => 'desc'];
// $arg_field = ['a.*', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
// $dataObject = Loader::model('Product')->getCateProductLists($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;
}
$value['category'] = $category;
$value['seo_title'] = $category['seo_title']? : config('website_seo_title_us');
$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];
if ($id > 0) {
$arg_where['cid'] = $id;
$category = Loader::model('ProductCategory')->getRow($id);//dump($category);die;
}
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];//dump($subproductCategory);die;
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_us');
$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, 'is_show' => 0, 'p.siteid' => $this->siteid];
$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 = '') {
// echo $color;die;
if ($id > 0) {
$detail = Loader::model('Product')->where(['stat' => 0, 'is_show' => 0, 'country_code' => $this->country_code, 'id' => $id])->find();
//echo "<pre>=="; print_r($detail);die;
if(empty($detail)){
//return exception('该产品已下架,请检查后再操作');
return $this->error('该产品已下架,请检查后再操作');
}
$detail['is_collection'] = 0;
if (empty($detail)) {
return exception('数据有误,请检查后再操作');
}
$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']);
// echo "<pre>=="; print_r($value);die;
$value['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']);
// tiaoshi($value['product_images']);die;
$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'], ['id', 'name', 'product', 'sort', 'headline', 'recommend', 'description', 'createtime']);
$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.brand_id', 'p.createtime', 'pr.id' => 'related_id', 'pr.related_product_id', 'pr.related_sort', 'pr.related_desc']);
$value['seo_title'] = $detail['seo_title']? : $detail['name'] . '-' . config('website_seo_title_us');
$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']
];
$product_images = [];
$attributes = [];
foreach ($value['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;
$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);
return $this->fetch($template);
} 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'); //print_r($history);exit;
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;
//$product_ids = array_slice($product_ids, 0, $num);
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 new_arrival() {
$value = Loader::model('Product')->getNewProductLists(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('new');
}
}

56
app/us/controller/Search.php Executable file
View File

@@ -0,0 +1,56 @@
<?php
namespace app\us\controller;
use think\Loader;
use think\Config;
use think\Db;
class Search extends BaseController {
public function index() {
$skeyword = $this->request->get('skeyword', '', 'urldecode,strval');
$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();
// tiaoshi($dataObject->items());die;
$value = [
'list' => $dataObject->isEmpty() ? null : $dataObject->items(),
'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\us\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_us');
$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('数据有误,请检查后再操作');
}
}

68
app/us/controller/Track.php Executable file
View File

@@ -0,0 +1,68 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2023-08-21
* Time: 17:36
*/
namespace app\us\controller;
class Track extends BaseController
{
public function records()
{
$data = $this->request->post();
if (empty($data) || !is_array($data))
return $this->json(-1, 'Data error ');
$useragent = $data['user_agent'];
$ip = get_ip();
$address = GetIpLookup($ip);
//echo $ip."<pre>=="; print_r($address);die;
$url = $data['url'];
$keywords =getKeywords($url);
$arr_url = parse_url($url);
$content = pregReplaceImg($data['content'],'https://'.$arr_url['host']);
$fds = array(
"items" => 'ORICO Official',
"forum" => $data['forum'],
"forum_code" => $data['forum'],
"url" => $data['url'],
"refer" =>$data['refer'],
"channel" => isset($keywords['channel']) ? $keywords['channel'] :'',
"channel_type" => isset($keywords['channel']) ?$keywords['channel'] :'',
"keyword" => isset($keywords['search']) ?$keywords['search'] :'',
"start_time" => date("y-m-d H:i:s"),
"ip" => $ip,
"country" => isset($address['country']) ? $address['country'] :'',
"province" => isset($address['province']) ? $address['province'] :'',
"city" => isset($address['city']) ? $address['city'] :'',
"content" => $content,
"drive" => $data['drive'],
"event_type" => $data['event_type'],
"system" => getOs($useragent),
"brower" => getBroswer($useragent),
);
//echo "<pre>=="; print_r($fds);die;
$feeds = http_build_query($fds);
$result = CurlRequest('https://producer.datamaster.cc/api/v1/action_logs/send', $feeds);
$res = json_decode($result, true);
return $this->json(200, 'ok');
}
}

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

@@ -0,0 +1,142 @@
<?php
namespace app\us\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'));
}
}

153
app/us/controller/Video.php Executable file
View File

@@ -0,0 +1,153 @@
<?php
namespace app\us\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($arg_where, ['sort', 'id'], ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'image1', 'image2', 'classtype', 'url']);
$value = [
'videoCategory' => $videoCategory,
];
//echo \think\Db::table('VideoCategory')->getLastSql();die;
$value['seo_title'] = config('video_seo_title')? : config('website_seo_title_us');
$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, 'isshow' => 1, 'stat' => 0, 'country_code' => $this->country_code], ['sort', 'id'], ['id', 'pid', 'haschild', 'name', 'shortname', 'description', 'sort', 'isshow', 'recommend', 'picture', 'image1', 'image2', 'classtype', 'url']);
//echo \think\Db::table('VideoCategory')->getLastSql();die;
$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_us');
$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_us');
$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]);
}
}
}