init
This commit is contained in:
186
app/vn/controller/Ad.php
Executable file
186
app/vn/controller/Ad.php
Executable file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\controller;
|
||||
|
||||
use think\Lang;
|
||||
use think\Loader;
|
||||
use think\Config;
|
||||
use app\common\controller\BaseController;
|
||||
|
||||
class Ad extends BaseController {
|
||||
private $country_code = 'VN';
|
||||
public function tags($tags = '', $num = 1) {
|
||||
if ($tags) {
|
||||
$nocache = $this->request->param('nocache', 0);
|
||||
$cacheTag = 'advn-' . md5($tags);
|
||||
$htmlbody = $nocache ? '' : $this->cacheGet($cacheTag);
|
||||
|
||||
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('adTagVn')->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('adTagVn')->set($cacheTag, $htmlbody, $expire);
|
||||
}
|
||||
echo $htmlbody;
|
||||
exit;
|
||||
}
|
||||
exit(' Error! ');
|
||||
}
|
||||
|
||||
public function tagsli($tags = '', $num = 1) {
|
||||
if ($tags) {
|
||||
$nocache = $this->request->param('nocache', 0);
|
||||
$cacheTag = 'advn-' . md5($tags);
|
||||
$htmlbody = $nocache ? '' : $this->cacheGet($cacheTag);
|
||||
if (empty($htmlbody)) {
|
||||
$list = Loader::model('ad')->getList(['stat' => ['eq', 0], 'tags' => $tags, 'typeid' => 32, '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('adTagVn')->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('adTagVn')->set($cacheTag, $htmlbody, $expire);
|
||||
}
|
||||
echo $htmlbody;
|
||||
exit;
|
||||
}
|
||||
exit(' Error! ');
|
||||
}
|
||||
|
||||
public function index($id = 0) {
|
||||
if ($id > 0) {
|
||||
$nocache = $this->request->param('nocache', 0);
|
||||
$cacheTag = 'advn-' . $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('adTagVn')->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('adTagVn')->set($cacheTag, $adbody, $expire);
|
||||
}
|
||||
echo $adbody;
|
||||
exit;
|
||||
}
|
||||
exit(' Error! ');
|
||||
}
|
||||
|
||||
public function cat($id = '', $num = 1) {
|
||||
if ($id) {
|
||||
$nocache = $this->request->param('nocache', 0);
|
||||
$cacheTag = 'advn-' . $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('adTagVn')->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('adTagVn')->set($cacheTag, $htmlbody, $expire);
|
||||
}
|
||||
echo $htmlbody;
|
||||
exit;
|
||||
}
|
||||
exit(' Error! ');
|
||||
}
|
||||
|
||||
public function previewjs($id) {
|
||||
$id = intval($id);
|
||||
if ($id > 0) {
|
||||
echo '<script src="' . url('vn/ad/index', ['id' => $id]) . '?nocache=1" language="javascript"></script>';
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
148
app/vn/controller/Article.php
Executable file
148
app/vn/controller/Article.php
Executable file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\controller;
|
||||
|
||||
use think\Loader;
|
||||
use think\Cookie;
|
||||
use think\Config;
|
||||
|
||||
class Article extends BaseController {
|
||||
|
||||
public function lists() {
|
||||
$arg_where = ['a.siteid' => $this->siteid, 'a.country_code' => $this->country_code];
|
||||
$arg_order = ['a.id' => 'desc'];
|
||||
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.writer', 'a.source', 'a.viewcount', 'a.zancount', 'a.commentcount', 'a.description', 'a.picture', 'a.tags', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
|
||||
$dataObject = 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' => '新闻资讯'],
|
||||
];
|
||||
$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();
|
||||
}
|
||||
|
||||
public function catelists($id = 0) {
|
||||
if ($id > 0) {
|
||||
$category = Loader::model('ArticleCategory')->getRow($id);
|
||||
}
|
||||
if (empty($category)) {
|
||||
return exception('数据有误,请检查后再操作');
|
||||
}
|
||||
switch ($category['classtype']) {
|
||||
case 2:
|
||||
$template = $category['templist'];
|
||||
$arg_where = ['cid' => $id, 'a.siteid' => $this->siteid, 'a.country_code' => $this->country_code];
|
||||
$arg_order = ['a.id' => 'desc'];
|
||||
$arg_field = ['a.id', 'a.cid', 'a.name', 'a.sort', 'a.headline', 'a.ishot', 'a.recommend', 'a.writer', 'a.source', 'a.viewcount', 'a.zancount', 'a.commentcount', 'a.description', 'a.picture', 'a.tags', 'a.createtime', 'c.id' => 'categoryid', 'c.name' => 'categoryname'];
|
||||
$dataObject = Loader::model('article')->getCateArticleLists($arg_where, $arg_order, $arg_field, 8);
|
||||
$value = [
|
||||
'list' => $dataObject->isEmpty() ? null : $dataObject->items(),
|
||||
'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');
|
||||
$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('数据有误,请检查后再操作');
|
||||
}
|
||||
|
||||
$category = Loader::model('article_category')->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,
|
||||
'category' => $category,
|
||||
//'prev_detail' => $prev_detail,
|
||||
//'next_detail' => $next_detail,
|
||||
];
|
||||
|
||||
$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);
|
||||
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
31
app/vn/controller/Authcode.php
Executable file
31
app/vn/controller/Authcode.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\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);
|
||||
}
|
||||
|
||||
}
|
||||
90
app/vn/controller/BaseController.php
Executable file
90
app/vn/controller/BaseController.php
Executable file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\controller;
|
||||
|
||||
use think\Lang;
|
||||
use think\Loader;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
use app\common\controller\BaseController as Controller;
|
||||
|
||||
//<!--#include file="([0-9a-zA-Z/._-]+?)\.html" -->
|
||||
class BaseController extends Controller {
|
||||
|
||||
//当前用户
|
||||
protected $customer_id = 0;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
protected function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->country_code = 'VN';
|
||||
|
||||
$this->customer_id = is_session_login('customer');
|
||||
$this->current_customer = Session::get('customer_auth');
|
||||
$this->view->assign('customer_id', $this->customer_id);
|
||||
$this->view->assign('current_customer', $this->current_customer);
|
||||
$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('product_category')->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', 'm_icon', 'image', '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);
|
||||
}
|
||||
// tiaoshi($this->country_list);die;
|
||||
$this->view->assign('country_list', $this->country_list);
|
||||
|
||||
$this->productCategory = $this->list_to_tree($this->categoryList);
|
||||
$this->view->assign('productCategory', $this->productCategory);
|
||||
$this->view->assign('allCategoryList', $this->categoryList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点遍历
|
||||
* @param $list
|
||||
* @param string $pk
|
||||
* @param string $pid
|
||||
* @param string $child
|
||||
* @param int $root
|
||||
* return array
|
||||
*/
|
||||
protected function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = 'child', $root = 0) {
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
369
app/vn/controller/Customer.php
Executable file
369
app/vn/controller/Customer.php
Executable file
@@ -0,0 +1,369 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\controller;
|
||||
|
||||
use think\Lang;
|
||||
use think\Loader;
|
||||
use think\Config;
|
||||
use think\Session;
|
||||
|
||||
class Customer extends BaseController {
|
||||
|
||||
public function index() {
|
||||
if ($this->customer_id) {
|
||||
return $this->redirect(url('vn/user/index'));
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 前台用户登录
|
||||
* @param string $username 前台用户名
|
||||
* @param string $password 密码
|
||||
* @param string $verify 验证码
|
||||
*/
|
||||
public function login() {
|
||||
if ($this->customer_id) {
|
||||
return $this->redirect(url('vn/user/index'));
|
||||
}
|
||||
$this->request->isPost() || $this->error(Lang::get('illegal request')); //判断是否ajax登录
|
||||
$data = $this->request->post();
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return $this->error('未知错误');
|
||||
}
|
||||
$this->verify_check($data['authcode'], 'yanzhengma') || $this->error('验证码 ' . Lang::get('error'), url('/login'));
|
||||
$validaterule = [
|
||||
//会员登陆字段验证
|
||||
'firstname|' . Lang::get('user name') => 'require|min:2',
|
||||
'password|' . Lang::get('user password') => 'require|min:6',
|
||||
];
|
||||
// 数据验证
|
||||
$valid_result = $this->validate($data, $validaterule);
|
||||
if (true !== $valid_result) {
|
||||
// 验证失败 输出错误信息
|
||||
return $this->error($valid_result);
|
||||
}
|
||||
|
||||
$result = Loader::model('Customer')->login($data['firstname'], $data['password']);
|
||||
$result['status'] !== true && $this->error($result['msg'], url('us/login')); //登录失败
|
||||
if ($this->request->isAjax()) {
|
||||
$result['id'] ? $this->success('登录成功', url('us/user/index')) : $this->error(Lang::get('unknown error'), url('us/login'));
|
||||
}
|
||||
return $result['id'] ? $this->redirect(url('us/user/index')) : $this->error(Lang::get('unknown error'), url('us/login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
public function logout() {
|
||||
if (!$this->customer_id) {
|
||||
return $this->redirect(url('us/login'));
|
||||
}
|
||||
Session::delete('customer_auth', null);
|
||||
Session::delete('customer_auth_sign', null);
|
||||
return $this->redirect(url('us/login'));
|
||||
}
|
||||
|
||||
public function register() {
|
||||
if ($this->customer_id) {
|
||||
return $this->redirect(url('us/user/index'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return $this->error(Lang::get('incorrect operation'));
|
||||
}
|
||||
$this->verify_check($data['authcode'], 'yanzhengma') || $this->error('验证码 ' . Lang::get('error'), url('/login'));
|
||||
|
||||
//验证规则
|
||||
$validaterule = [
|
||||
'firstname' => 'require|length:2,32|unique:customer,firstname',
|
||||
'email' => 'email|unique:customer,email',
|
||||
'telephone' => ['regex' => '^1[345789]\d{9}$', 'unique' => 'customer,telephone',],
|
||||
'password' => 'require|min:6|max:32',
|
||||
'repassword' => 'require|confirm:password',
|
||||
//'group_id' => 'require|between:0,2147483647',
|
||||
'item' => 'accepted',
|
||||
];
|
||||
//验证提示信息
|
||||
$validatemsg = [
|
||||
'firstname.require' => '用户名不能为空',
|
||||
'firstname.unique' => '用户名已经被使用',
|
||||
'firstname.length' => '用户名在2-32个字符之间',
|
||||
'email.email' => '邮箱格式错误',
|
||||
'email.unique' => '邮箱已经被使用',
|
||||
'telephone.regex' => '电话格式错误',
|
||||
'telephone.unique' => '电话已经被使用',
|
||||
'password.require' => '密码不能为空',
|
||||
'password.min' => '密码不少于6个字符',
|
||||
'password.max' => '密码不多于32个字符',
|
||||
'repassword.require' => '确认密码不能为空',
|
||||
'repassword.confirm' => '两次密码不相符',
|
||||
'group_id.require' => '用户组不能为空',
|
||||
'item' => '请确认阅读服务条款',
|
||||
];
|
||||
$valid_result = $this->validate($data, $validaterule, $validatemsg);
|
||||
if (true !== $valid_result) {
|
||||
// 验证失败 输出错误信息
|
||||
return $this->error($valid_result);
|
||||
}
|
||||
$code = $this->cacheGet('regtel' . $data['telephone']);
|
||||
if ($code != $data['code']) {
|
||||
return $this->error('短信验证码不正确,请输入正确验证码');
|
||||
}
|
||||
$addtime = time();
|
||||
$set = [
|
||||
'group_id' => 1,
|
||||
'email' => isset($data['email']) ? $data['email'] : '',
|
||||
'telephone' => isset($data['telephone']) ? $data['telephone'] : '',
|
||||
'firstname' => $data['firstname'],
|
||||
'lastname' => isset($data['lastname']) ? $data['lastname'] : '',
|
||||
'newsletter' => isset($data['newsletter']) ? $data['newsletter'] : 0,
|
||||
'salt' => $data['password'],
|
||||
'password' => md5($data['password']),
|
||||
'stat' => 0,
|
||||
'safe' => 1,
|
||||
'code' => '',
|
||||
'item' => isset($data['item']) ? $data['item'] : 0,
|
||||
'token' => isset($data['token']) ? $data['token'] : '',
|
||||
'wishlist' => isset($data['wishlist']) ? $data['wishlist'] : '',
|
||||
'ip' => isset($data['ip']) ? $data['ip'] : '',
|
||||
'fenxiang' => isset($data['fenxiang']) ? $data['fenxiang'] : 0,
|
||||
'guanzhu' => isset($data['guanzhu']) ? $data['guanzhu'] : 0,
|
||||
'hangye' => isset($data['hangye']) ? $data['hangye'] : '',
|
||||
'zhiye' => isset($data['zhiye']) ? $data['zhiye'] : '',
|
||||
'sex' => isset($data['sex']) ? $data['sex'] : '',
|
||||
'birthday' => isset($data['birthday']) ? $data['birthday'] : '',
|
||||
'qq' => isset($data['qq']) ? $data['qq'] : '',
|
||||
'addtime' => $addtime,
|
||||
'custom_field' => json_encode([]),
|
||||
];
|
||||
$model = Loader::model('Customer')->insertRow($set);
|
||||
if ($model && $customer_id = $model->getData('id')) {
|
||||
return $this->success('注册成功', url('/us/customer/information', ['key' => 'regsuccess']));
|
||||
}
|
||||
return $this->error(Lang::get('operation failed'));
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function information($key) {
|
||||
$key = (string) $key;
|
||||
$this->engine->layout(false);
|
||||
$result = [
|
||||
'regsuccess' => ['msg' => '注册成功', 'url' => ''],
|
||||
'getpwdsuccess' => ['msg' => '找回密码完成', 'url' => ''],
|
||||
];
|
||||
if ($result[$key]) {
|
||||
$value = $result[$key];
|
||||
} else {
|
||||
$value = ['msg' => '信息提示', 'url' => ''];
|
||||
}
|
||||
$this->assign($value);
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function forgetpwd() {
|
||||
if ($this->customer_id) {
|
||||
return $this->redirect(url('us/user/index'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return $this->error(Lang::get('incorrect operation'));
|
||||
}
|
||||
//验证规则
|
||||
$validaterule = [
|
||||
'email' => 'email',
|
||||
'password' => 'require|min:6|max:32',
|
||||
'repassword' => 'require|confirm:password',
|
||||
];
|
||||
//验证提示信息
|
||||
$validatemsg = [
|
||||
'email.email' => '邮箱格式错误',
|
||||
'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(['email' => $data['email']]);
|
||||
if (empty($row)) {
|
||||
return $this->error('该邮箱尚未注册!');
|
||||
}
|
||||
$code = $this->cacheGet('regemail' . $data['email']);
|
||||
if ($code != $data['code']) {
|
||||
return $this->error('邮箱验证码不正确,请输入正确验证码');
|
||||
}
|
||||
// if ($row['password'] != md5($data['password'])) {
|
||||
// return $this->error('原密码不正确');
|
||||
// }
|
||||
$data['id'] = $row['id'];
|
||||
$model = Loader::model('Customer')->updatePassword($data);
|
||||
if ($model && $model->getData('id')) {
|
||||
return $this->success('找回密码完成', url('/us/customer/information', ['key' => 'getpwdsuccess']));
|
||||
}
|
||||
}
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function sendsms() {
|
||||
$data = $this->request->param();
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return $this->error(Lang::get('incorrect operation'));
|
||||
}
|
||||
//验证规则
|
||||
$validaterule = [
|
||||
'telephone' => ['regex' => '^1[345789]\d{9}$', 'unique' => 'customer,telephone',],
|
||||
];
|
||||
//验证提示信息
|
||||
$validatemsg = [
|
||||
'telephone.regex' => '电话格式错误',
|
||||
'telephone.unique' => '电话已经被使用',
|
||||
];
|
||||
$valid_result = $this->validate($data, $validaterule, $validatemsg);
|
||||
if (true !== $valid_result) {
|
||||
// 验证失败 输出错误信息
|
||||
return $this->error($valid_result);
|
||||
}
|
||||
//$mobile = $data['telephone'];
|
||||
//$code = mt_rand(10000, 99999);
|
||||
//$this->cacheSet('regtel' . $mobile, $code, 300);
|
||||
//return $this->success($code);
|
||||
//获取对象,如果上面没有引入命名空间,可以这样实例化:$sms = new \alisms\SendSms()
|
||||
$sms = new \alisms\SendSms();
|
||||
//设置关键的四个配置参数,其实配置参数应该写在公共或者模块下的config配置文件中,然后在获取使用,这里我就直接使用了。
|
||||
$sms->accessKeyId = (string) Config::get('sms_accesskeyid');
|
||||
$sms->accessKeySecret = (string) Config::get('sms_accesskeysecret');
|
||||
$sms->signName = (string) Config::get('sms_signname');
|
||||
$sms->templateCode = (string) Config::get('sms_templatecode');
|
||||
//$mobile为手机号
|
||||
$mobile = $data['telephone'];
|
||||
//模板参数,自定义了随机数,你可以在这里保存在缓存或者cookie等设置有效期以便逻辑发送后用户使用后的逻辑处理
|
||||
$code = mt_rand(10000, 99999);
|
||||
$this->cacheSet('regtel' . $mobile, $code, 300);
|
||||
$templateParam = array('code' => $code);
|
||||
$m = $sms->send($mobile, $templateParam);
|
||||
//类中有说明,默认返回的数组格式,如果需要json,在自行修改类,或者在这里将$m转换后在输出
|
||||
if ($m['Code'] == 'OK') {
|
||||
return $this->success($m['Message']);
|
||||
} else {
|
||||
return $this->error($m['Message']);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendresetemail() {
|
||||
$data = $this->request->param();
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return $this->error(Lang::get('incorrect operation'));
|
||||
}
|
||||
//验证规则
|
||||
$validaterule = ['email' => 'email',];
|
||||
//验证提示信息
|
||||
$validatemsg = ['email.email' => '邮箱格式错误',];
|
||||
$valid_result = $this->validate($data, $validaterule, $validatemsg);
|
||||
if (true !== $valid_result) {
|
||||
// 验证失败 输出错误信息
|
||||
return $this->error($valid_result);
|
||||
}
|
||||
$row = Loader::model('Customer')->getRow(['email' => $data['email']]);
|
||||
if (empty($row)) {
|
||||
return $this->error('该邮箱尚未注册!');
|
||||
}
|
||||
//$email = $data['email'];
|
||||
//$code = mt_rand(10000, 99999);
|
||||
//$this->cacheSet('regemail' . $email, $code, 1800);
|
||||
//return $this->success($code);
|
||||
//$email为邮箱
|
||||
$email = $data['email'];
|
||||
//模板参数,自定义了随机数,你可以在这里保存在缓存或者cookie等设置有效期以便逻辑发送后用户使用后的逻辑处理
|
||||
$code = mt_rand(10000, 99999);
|
||||
$this->cacheSet('regemail' . $email, $code, 1800);
|
||||
//邮件标题
|
||||
$subject = $this->request->host() . '-找回密码';
|
||||
//邮件内容
|
||||
$body = "<h1>亲爱的" . $row['firstname'] . "</h1><h2>您在" . date('Y-m-d H:i') . "提交了找回密码请求.</h2><h2>本次验证码:" . $code . "</h2>有效期为30分钟,请及时做出处理.";
|
||||
|
||||
$res = $this->sendemail($data['email'], $row['firstname'], $subject, $body);
|
||||
if ($res['code'] == 'Success') {
|
||||
return $this->success("系统已向您的邮箱发送了一封邮件\n请登录到您的邮箱及时获取您的验证码!");
|
||||
} else {
|
||||
return $this->error($res['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendemail($to, $to_name, $subject, $body, $from_email = '', $from_name = 'From') {
|
||||
$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(false);
|
||||
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' => 'Failure', 'msg' => "Mailer Error: " . $mail->ErrorInfo];
|
||||
} else {
|
||||
$result = ['code' => 'Success', 'msg' => 'Message has been sent'];
|
||||
}
|
||||
} catch (\mail\PHPMailer\Exception $e) {
|
||||
$result = ['code' => 'Failure', 'msg' => 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
296
app/vn/controller/Download.php
Executable file
296
app/vn/controller/Download.php
Executable file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\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];
|
||||
$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('download_category_vn')->getRow($id);
|
||||
}
|
||||
$dataObject = Loader::model('download_vn')->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('download_category_vn')->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 catelists($id = 0) {
|
||||
$arg_where = ['a.siteid' => $this->siteid];
|
||||
if ($id > 0) {
|
||||
$arg_where['cid'] = $id;
|
||||
$category = Loader::model('download_category')->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('download_category')->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 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('download_category')->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_id')->updateRow(['downloadcount' => \think\Db::raw('`downloadcount`+1')], ['id' => $id]);
|
||||
header('Content-type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename=' . $fileinfo['basename']);
|
||||
header('Content-Length: ' . filesize($download));
|
||||
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('product_dl')->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('product_dl_id')->updateRow(['dl_count' => \think\Db::raw('`dl_count`+1')], ['id' => $id]);
|
||||
header('Content-type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename=' . $fileinfo['basename']);
|
||||
header('Content-Length: ' . filesize($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_id')->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('download_category_vn')->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_id')->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('download_category_vn')->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('download_category')->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('download_category')->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);
|
||||
}
|
||||
|
||||
}
|
||||
109
app/vn/controller/Group.php
Executable file
109
app/vn/controller/Group.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ORICO
|
||||
* Date: 2018-09-21
|
||||
* Time: 17:36
|
||||
*/
|
||||
|
||||
namespace app\vn\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 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();
|
||||
}
|
||||
|
||||
}
|
||||
79
app/vn/controller/Index.php
Executable file
79
app/vn/controller/Index.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\controller;
|
||||
|
||||
use think\Lang;
|
||||
use think\Loader;
|
||||
use think\Config;
|
||||
use think\TransDb;
|
||||
class Index extends BaseController {
|
||||
|
||||
public function index() {
|
||||
return $this->fetch('/index');
|
||||
}
|
||||
public function info(){
|
||||
echo "\nstart: ".date("Y-m-d H:i:s")."\n";
|
||||
$TransDb = new TransDb();
|
||||
$TransDb->selectAllStruct("ProductCategory");
|
||||
//$getDb = $TransDb->getkv();
|
||||
echo "\nend :".date("Y-m-d H:i:s")."\n";
|
||||
|
||||
dump($TransDb);
|
||||
// phpinfo();
|
||||
}
|
||||
public function feedback() {
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post();
|
||||
if (empty($data) || !is_array($data)) {
|
||||
return $this->error('未知错误');
|
||||
}
|
||||
$this->verify_check($data['authcode'], 'authcode') || $this->error('验证码不正确');
|
||||
$validaterule = [
|
||||
'name' => 'require',
|
||||
'subject' => 'require',
|
||||
'contact' => 'require',
|
||||
'content' => 'require',
|
||||
];
|
||||
$validatemsg = [
|
||||
'name.require' => '名称不能为空',
|
||||
'subject.require' => '主题不能为空',
|
||||
'contact.require' => '联系方式不能为空',
|
||||
'content.require' => '内容不能为空',
|
||||
];
|
||||
if (empty($data['way'])) {
|
||||
return $this->error('请选择正确的联系方式');
|
||||
} else {
|
||||
if ($data['way'] == 'E-mail') {
|
||||
$validaterule['contact'] = 'email';
|
||||
$validatemsg['contact.email'] = '联系方式格式不正确';
|
||||
}
|
||||
if ($data['way'] == 'tel') {
|
||||
$validaterule['contact'] = ['regex' => '^1[345789]\d{9}$|^([0-9]{3,4}-?)?[0-9]{7,8}$'];
|
||||
$validatemsg['contact.regex'] = '联系方式格式不正确';
|
||||
}
|
||||
}
|
||||
$valid_result = $this->validate($data, $validaterule, $validatemsg);
|
||||
if (true !== $valid_result) {
|
||||
// 验证失败 输出错误信息
|
||||
return $this->error($valid_result);
|
||||
}
|
||||
$set = [
|
||||
'feedback_type' => isset($data['feedback_type']) ? $data['feedback_type'] : '',
|
||||
'name' => isset($data['name']) ? $data['name'] : 'Name',
|
||||
'subject' => isset($data['subject']) ? $data['subject'] : '',
|
||||
'content' => isset($data['content']) ? $data['content'] : '',
|
||||
'way' => isset($data['way']) ? $data['way'] : '',
|
||||
'contact' => isset($data['contact']) ? $data['contact'] : '',
|
||||
'addtime' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
$model = Loader::model('Msgform')->insertRow($set);
|
||||
if ($model && $model->getData('id')) {
|
||||
return $this->success('成功!成功!等待管理员查看', url('/'));
|
||||
} else {
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
}
|
||||
return $this->result(['code' => false, 'msg' => '未知错误'], false, '未知错误');
|
||||
}
|
||||
|
||||
}
|
||||
96
app/vn/controller/Pinglun.php
Executable file
96
app/vn/controller/Pinglun.php
Executable file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\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_vn')->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_vn')->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_vn')->insertRow($set);
|
||||
if ($model && $model->getData('id')) {
|
||||
isset($data['cid']) ? Loader::model('article_vn')->where(['id' => $data['cid']])->setInc('commentcount') : '';
|
||||
return $this->success('成功!成功!等待管理员的审核后,方可显示', url('/'));
|
||||
} else {
|
||||
return $this->error('操作失败');
|
||||
}
|
||||
}
|
||||
return $this->result(['code' => false, 'msg' => '未知错误'], false, '未知错误');
|
||||
}
|
||||
|
||||
}
|
||||
222
app/vn/controller/Product.php
Executable file
222
app/vn/controller/Product.php
Executable file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\controller;
|
||||
|
||||
use think\Loader;
|
||||
use think\Cookie;
|
||||
use think\Config;
|
||||
|
||||
class Product extends BaseController {
|
||||
|
||||
public function get_filter() {
|
||||
if ($this->cacheHas('product_filter_vn'))
|
||||
{
|
||||
$product_filter = $this->cacheGet('product_filter_vn');
|
||||
}
|
||||
else
|
||||
{
|
||||
$product_filter = model('product')->where(['stat' => 0, 'country_code' => $this->country_code])->field('name, brand_id, keyword')->select();
|
||||
$this->cacheSet('product_filter_vn', $product_filter, 86400);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'product_name' => $product_filter,
|
||||
];
|
||||
|
||||
return $this->json(200, 'ok', $data);
|
||||
}
|
||||
|
||||
public function lists($id = 0) {
|
||||
$category = Loader::model('product_category')->getRow(['stat' => 0, 'pid' => 0, 'country_code' => $this->country_code], null, ['id' => 'asc']);
|
||||
if (empty($category)) {
|
||||
return exception('数据有误,请检查后再操作');
|
||||
}
|
||||
$value = [
|
||||
'category' => $category,
|
||||
];
|
||||
$value['seo_title'] = config('product_seo_title')? : config('website_seo_title_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('product_category')->getRow($id);
|
||||
}
|
||||
if (empty($category)) {
|
||||
return exception('数据有误,请检查后再操作');
|
||||
}
|
||||
switch ($category['classtype']) {
|
||||
case 2:
|
||||
$template = $category['templist'];
|
||||
break;
|
||||
case 3:
|
||||
header('location:' . $category['url']);
|
||||
exit;
|
||||
break;
|
||||
default:
|
||||
$template = $category['tempindex'];
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$value['category'] = $category;
|
||||
$value['seo_title'] = $category['seo_title']? : config('website_seo_title_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('product_category')->getRow($id);
|
||||
}
|
||||
if (empty($category)) {
|
||||
return exception('数据有误,请检查后再操作');
|
||||
}
|
||||
switch ($category['classtype']) {
|
||||
case 2:
|
||||
$template = $category['templist'];
|
||||
$subproductCategory = $this->list_to_tree($this->categoryList, 'id', 'pid', 'child', $id);
|
||||
$value = ['subproductCategory' => $subproductCategory];
|
||||
break;
|
||||
case 3:
|
||||
header('location:' . $category['url']);
|
||||
exit;
|
||||
break;
|
||||
default:
|
||||
$template = $category['tempindex'];
|
||||
break;
|
||||
}
|
||||
|
||||
$result = model('ProductCategory')->where(['pid' => $category['id']])->find();
|
||||
$last_cate = empty($result) ? 1 : 0;
|
||||
$value['last_cate'] = $last_cate;
|
||||
|
||||
$value['pid'] = $id;
|
||||
$value['category'] = $category;
|
||||
$value['seo_title'] = $category['seo_title']? : config('website_seo_title_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, 'p.siteid' => $this->siteid];
|
||||
$id = intval($id);
|
||||
if ($id > 0) {
|
||||
if (0) {
|
||||
$ids = Loader::model('product_category')->getChildIDArray(4);
|
||||
$arg_where['cid'] = ['in', $ids];
|
||||
} else {
|
||||
$arg_where['cid'] = $id;
|
||||
}
|
||||
$category = Loader::model('product_category')->getRow($id);
|
||||
}
|
||||
if (empty($category)) {
|
||||
return exception('数据有误,请检查后再操作');
|
||||
}
|
||||
$arg_field = ['p.id', 'p.cid', 'p.name', 'p.shortname', 'p.sort', 'p.ishot', 'p.isnew', 'p.recommend', 'p.viewcount', 'p.tags', 'p.description', 'p.picture', 'p.picture_back', 'p.createtime', 'p.createtime', 'c.name' => 'categoryname', 'c.id' => 'categoryid'];
|
||||
$arg_order['p.sort'] = 'asc';
|
||||
$arg_order['p.id'] = 'desc';
|
||||
$dataObject = Loader::model('product')->getCateProductLists($arg_where, $arg_order, $arg_field, 8);
|
||||
if ($dataObject->isEmpty()) {
|
||||
$value = ['list' => null];
|
||||
} else {
|
||||
$this->assign(['list' => $dataObject->items(), 'category' => $category,]);
|
||||
$value = ['list' => $this->fetch()];
|
||||
}
|
||||
return $this->result($value, true, '分类列表');
|
||||
}
|
||||
|
||||
public function detail($id = 0, $color = '') {
|
||||
if ($id > 0) {
|
||||
$detail = Loader::model('Product')->where(['stat' => 0, 'is_show' => 0, 'country_code' => $this->country_code, 'id' => $id])->find();
|
||||
|
||||
if (empty($detail)) {
|
||||
return exception('数据有误,请检查后再操作');
|
||||
}
|
||||
$category = Loader::model('product_category')->getRow($detail['cid']);
|
||||
$cid = Loader::model('product_category')->getRow($category['pid']);
|
||||
$pid = Loader::model('product_category')->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_images'] = Loader::model('product_image')->getList(array('product_id' => $detail['id']), ['image_sort' => 'asc', 'id' => 'asc'], ['id', 'product_id', 'image_url', 'image_sort', 'image_desc', 'image_color']);
|
||||
$value['product_dls'] = Loader::model('product_dl')->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']
|
||||
];
|
||||
|
||||
$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);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
56
app/vn/controller/Search.php
Executable file
56
app/vn/controller/Search.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\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 \think\Db::table('product')->getlastSql();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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
30
app/vn/controller/Singlepage.php
Executable file
30
app/vn/controller/Singlepage.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\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('数据有误,请检查后再操作');
|
||||
}
|
||||
|
||||
}
|
||||
142
app/vn/controller/User.php
Executable file
142
app/vn/controller/User.php
Executable file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\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'));
|
||||
}
|
||||
|
||||
}
|
||||
127
app/vn/controller/Video.php
Executable file
127
app/vn/controller/Video.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace app\vn\controller;
|
||||
|
||||
use think\Loader;
|
||||
use think\Cookie;
|
||||
use think\Config;
|
||||
|
||||
class Video extends BaseController {
|
||||
|
||||
public function lists() {
|
||||
$videoCategory = Loader::model('video_category')->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']);
|
||||
$value = [
|
||||
'videoCategory' => $videoCategory,
|
||||
];
|
||||
$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];
|
||||
$id = intval($id);
|
||||
if ($id > 0) {
|
||||
$category = Loader::model('video_category')->getRow($id);
|
||||
if ($category['haschild']) {
|
||||
$ids = Loader::model('video_category')->getChildIDArray($id);
|
||||
$arg_where['cid'] = ['in', $ids];
|
||||
} else {
|
||||
$arg_where['cid'] = $id;
|
||||
}
|
||||
}
|
||||
if (empty($category)) {
|
||||
return exception('数据有误,请检查后再操作');
|
||||
}
|
||||
unset($category['siteid']);
|
||||
$value['category'] = $category;
|
||||
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('video_category')->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']);
|
||||
$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('video_category')->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_id')->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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user