Initial commit

This commit is contained in:
易焱
2021-03-13 18:42:01 +08:00
commit d9a3c376d5
3243 changed files with 627198 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
<?php
//获取地区中文
function get_region_name($arr,$str="-"){
if($arr){
$return_str="";
foreach($arr as $id){
$name=M("region")->where(array("id"=>$id))->getField("name");
if($name){
$return_str.="-".$name;
}
}
}
return trim($return_str,"-");
}
//USD TO RMB
function USD_RMB($usd){
$rmb=$usd*C("display.USD_RMB");
return $rmb;
}
//RMB TO USD 10000
function RMB_USD($rmb){
$rmb=intval($rmb);
$usd=$rmb*10000/C("display.USD_RMB");
return $usd;
}
function add_on($value,$common){
if($value==$common){return 'on';}
}
//转换标签
function tran_tag($tag){
$tag=trim($tag,"|");
$tag=explode("|",$tag);
if($tag){
$return_str="";
foreach($tag as $val){
$return_str.="<a>".$val."</a>";
}
}
return $return_str;
}
//修改url参数,用于筛选中的
function update_url($arr){
C("URL_MODEL", 0); //强制使用默认url模板,因为筛选中有中文,url中文不支持
$get=$_GET;
$get["p"]="";//删除分页参数
foreach($arr as $key=>$val){
$get[$key]=$val;
}
$url=U("",$get);
C("URL_MODEL",1); //强制使用默认url模板,因为筛选中有中文,url中文不支持
echo $url;
}
//adid函数,用于反回单张广告中的某一个字段
function adid($adid,$field='thumb'){
$data=M("ad_cat")->find($adid);
return $data[$field];
}
//替换url参数(一般用于筛选里)
function reurl($field,$value="",$url=''){
if(!$url){
//如果是生成静态页面的话,url是当前栏目的url
if(I("get.isSystemMakeHtml")){
$url=U("List/index",array("catid"=>I("catid")));
}else{
$url=$_SERVER["REQUEST_URI"];
}
}
//获取url query参数部
$urlarr=parse_url($url);
//将类似于:?a=1&b=2&c=3 参数转出成数组
parse_str($urlarr['query'],$arr);
//参数替换(如果$value为假则消除这个参数)
if($value===""){//注意这里一定要是恒等于,防止0和''混淆
unset($arr[$field]);
}else{
$arr[$field]=$value;
}
$reurl=$urlarr['path']."?".http_build_query($arr);
$reurl=trim($reurl,"?");
return $reurl;
}
//查看指定栏目是否为当前栏目的父栏目id里
function isParent($parent_id,$self_id=0){
$catid=$self_id?$self_id:$_GET[catid];
//如果是当前栏目的话也返回true
if($parent_id==$catid){
return true;
}
return strstr($GLOBALS[cat][$catid][parent_catids],"|".$parent_id."|");
}
function abc(){
return "diy fun";
}
+1
View File
@@ -0,0 +1 @@
+7
View File
@@ -0,0 +1,7 @@
<?php
return array(
//'配置项'=>'配置值'
//自定义success和error的提示页面模板
'TMPL_ACTION_SUCCESS'=>'Public:success',
'TMPL_ACTION_ERROR'=>'Public:error',
);
+1
View File
@@ -0,0 +1 @@
@@ -0,0 +1,37 @@
<?php
namespace Home\Controller;
use Think\Controller;
class BaseController extends Controller
{
private $loginStatus=1;//1为登录正常,0为登录异常
public $user_id;
public $openid;
function _initialize() {
//api接口相关设置
C("SHOW_PAGE_TRACE",false);//强制关闭调试器
header("Access-Control-Allow-Origin:*");//允许ajax远程跨域
header('Access-Control-Allow-Headers:x-requested-with,content-type,user_id,openid');
}
public function __construct(){
parent::__construct();
//校验用户登录信息
$this->checkLogin();
}
function checkLogin(){
$this->user_id=$_SERVER['HTTP_USER_ID'];
if(!$this->user_id){
$loginStatus = 0;
}
$this->openid = $_SERVER['HTTP_OPENID'];
if(!$this->openid){
$loginStatus = 0;
}
header('loginStatus:'.$this->loginStatus);
//error方法一定要放到header下而,否则客户端无法收到header中的loginStatus,newToken字段
if(!$this->loginStatus ){
$this->error('未登录');
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,61 @@
<?php
namespace Home\Controller;
use Think\Controller;
class PublicController extends Controller {
public function login(){
$user_name = I('user_name');
$user_password = I('user_password');
$user_info = D('user')->where(array('user_name'=>$user_name, 'user_password'=>md6($user_password)))->find();
if($user_info){
$role_info = D('role_user')->where(array('user_id'=>$user_info['user_id']))->find();
$res['role_id'] = $role_info['role_id'];
$res['user_id'] = $user_info['user_id'];
$res['can_check'] = $user_info['can_check'];
$this->success($res);
}
else{
$this->error('用户名或密码错误');
// $this->error($user_password);
}
}
public function notify()
{
$fileContent = file_get_contents("php://input");
$notify_post = json_decode(json_encode(simplexml_load_string($fileContent, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
D('notify')->add(array('res'=>json_encode($notify_post)));
// if ($notify_post["result_code"] == "SUCCESS") {
// $transaction_id = $notify_post['transaction_id'];
// $order_num = $notify_post['attach'];
// $real_pay = $notify_post["cash_fee"] * 0.01;
// $order_data = D('order')->where(array('order_num'=>$order_num))->find();
// if($order_data['status_code'] == 101 || $order_data['status_code'] == 301){
// $save = array();
// $save['transaction_id'] = $transaction_id;
// $save['real_pay'] = $real_pay;
// $save['paytime'] = time();
// $save['status_code'] = 110;
// if($order_data['status_code'] == 301){
// $save['status_code'] = 310;
// }
// $order_data = D('order')->where(array('order_num'=>$order_num))->save($save);
// $log_data = array();
// $log_data['order_id'] = $order_data['order_id'];
// $log_data['time'] = time();
// $log_data['status_code'] = $save['status_code'];
// $log_data['status_name'] = '检测中';
// $log_data['desc'] = '已付款(待邮寄切片)';
// $log_data['is_qiantai'] = 1;
// $log_data['user_id'] = $this->user_id;
// D('order_log')->add($log_data);
//
// }
//
// }
echo "success";
}
}
@@ -0,0 +1 @@
@@ -0,0 +1,135 @@
<?php
namespace Home\Model;
use Think\Model\RelationModel;
class FeedbackModel extends RelationModel{
protected $_validate,$fieldarr;
//关联模型
protected $_link = array(
//类别
"feedback_cat"=>array(
'mapping_type' => self::BELONGS_TO,
'foreign_key' => 'catid',
),
//用户
"member"=>array(
'mapping_type' => self::BELONGS_TO,
'mapping_fields' => "truename,member_id",
'foreign_key' => 'member_id',
)
);
public function __construct(){
//模型id
$catid=I("catid",0,"int");
$this->cat=M("feedback_cat")->find($catid);
if(!$this->cat){
$this->error="分类不存在";
return;
}
//录入项
$is_enter=$this->cat["is_enter"];
$is_enter_arr=explode(",",trim($is_enter,","));
$this->fieldarr=M("feedback_field")->where(array("field"=>array('in',$is_enter_arr)))->order("sort asc,field_id asc")->select();
//必填项
$must_enter=$this->cat["must_enter"];
$must_enter_arr=explode(",",trim($must_enter,","));
$this->must_enter_arr=M("feedback_field")->where(array("field"=>array('in',$must_enter_arr)))->order("sort asc,field_id asc")->select();
foreach($this->must_enter_arr as $v){
//自动验证=======================================================================
//array(验证字段,验证规则,错误提示,[验证条件,附加规则,验证时间])
//必填项(不能为空验证)
if(strstr($this->cat["is_enter"],",".$v[field].",")){
$error_tips=$v[name]."必须填写!";
//判断是不是checkbox,如果是执行函数验证
if($v[formtype]=="checkbox"){
$error_tips=$v[name]."必须勾选!";
$this->_validate[]=array($v[field],'validate_checkbox',$error_tips,1,"callback");
}
else{
$this->_validate[]=array($v[field],'require',$error_tips,1);
}
}
//正则验证
if($v[pattern]){
$p_error_tips=$v[errortips]?$v[errortips]:$v[name]."验证不通过!";
$this->_validate[]=array($v[field],$v[pattern],$p_error_tips,1,"regex");
}
//函数验证
if($v[savefun]){
$p_error_tips=$v[errortips]?$v[errortips]:$v[name]."验证不通过!";
$this->_validate[]=array($v[field],$v[savefun],$p_error_tips,1,"function");
}
//值维一验证
if($v[isunique]){
$p_error_tips=$v[name]."对应的记录已存在!";
$this->_validate[]=array($v[field],"",$p_error_tips,0,"unique");
}
}
//注意,这里父类析构函数一定要放到最下面,否则框架自带的方法不能使用
parent::__construct();
}
//自动验证的时候 验证checkbox
protected function validate_checkbox($arr){
if(count($arr)){
return true;
}else{
return false;
}
}
//数据完成
protected function data_create(){
$data=$this->create();
$data[addtime]=time();
$data[member_id]=intval(session("member_id"));
$data[ip]= get_client_ip();
foreach ($this->fieldarr as $v){
//复选框
if($v[formtype]=="checkbox"){
$data[$v[field]]=implode("|",$data[$v[field]]);
if($data[$v[field]]){
$data[$v[field]]="|".$data[$v[field]]."|";
}
}
//多图上传
if($v[formtype]=="morepic"){
$morepic_str="";
$smallimg=$_POST[$v[field]."_smallimg"];
$bigimg=$_POST[$v[field]."_bigimg"];
$imgname=$_POST[$v[field]."_imgname"];
foreach($smallimg as $key=>$val){
$morepic_str.=$smallimg[$key]."||".$bigimg[$key]."||".$imgname[$key]."\r\n";
}
$morepic_str=trim($morepic_str,"\r\n");
$data[$v[field]]=$morepic_str;
}
//如果是编辑器字段截取内容做为简介
if($v[formtype]=="editor"){
if(!$data[description]){
$data[description]= mb_substr(strip_tags(htmlspecialchars_decode($data[$v[field]])),0,C("display.description_len"),'utf-8');
}
}
//日期
if($v[formtype]=="date"){
$data[$v[field]]=$data[$v[field]]?strtotime($data[$v[field]]):"";
}
//未定义的数据设为空【否则mysql会报 cannot be null错误】
$data[$v[field]]=isset($data[$v[field]])?$data[$v[field]]:"";
//判断是否为 int smallint tinyint bigint
if(in_array($v[fieldtype],array("tinyint","smallint","int","bigint"))){
$data[$v[field]]=abs($data[$v[field]]);//禁止出现负数
}
}
return $data;
}
//增加
public function data_add(){
$data=$this->data_create();
$data['id']=$this->add($data);
if($data['id']){
return $data;
}else{
$this->error = '缺少字段id';
return false;
}
}
}
@@ -0,0 +1,45 @@
<?php
namespace Home\Model;
use Think\Model\RelationModel;
class InfoModel extends RelationModel{
protected $tableName,$_validate,$_link,$modelinfo,$modelid,$fieldarr;
public function __construct(){
//模型id
$catid=I("catid",0,"int");
if($catid){
$this->modelid=$GLOBALS['cat'][$catid]["modelid"];
}else{
$this->modelid=I("modelid",0,"int");
}
//模型信息
$modelinfo=$GLOBALS['model'][$this->modelid];
if(!$modelinfo){
return false;
}
$this->modelinfo=$modelinfo;
//
$this->_validate[]=array("catid","require","请选择分类",1);
//对应数据表
$this->tableName="cms_".$modelinfo['table_name'];
//关联模型
$this->_link = array(
//对应栏目表
"cat"=>array(
'mapping_type' => self::BELONGS_TO,
'foreign_key' => 'catid',
),
//【对应副表】
$this->tableName."_data"=>array(
'mapping_type' => self::HAS_ONE,
'foreign_key' => 'id',
),
);
//注意,这里父类析构函数一定要放到最下面,否则框架自带的方法不能使用
parent::__construct();
}
}
@@ -0,0 +1,31 @@
<?php
namespace Home\Model;
use Think\Model;
class MemberModel extends Model{
//验证
protected $_validate=array(
//array("字段","验证规则","错误提示",["验证条件","附加条件","验证时间"]),
array("username","require","用户名不能为空"),
array("username","5,40","用户名长度需要5位以上",2,"length"),
array("username","","用户名已存在",0,"unique"),
array("email","require","邮箱不能为空"),
array("email","email","邮箱格式不正确"),
array("email","","邮箱已存在",0,"unique"),
array("password","require","密码不能为空"),
array("password","6,40","密码长度需要6位以上",2,"length"),
array('repassword','password','确认密码不正确',0,'confirm'), // 验证确认密码是否和密码一致
);
//保存注册信息
public function data_save($site_id){
//创建数据
$data=$this->create();
//
$data[site_id]= $site_id;
$data[password]= md6($data[password]);
$data[status]=1;
$data[token]=md6(time());
$data[register_time]=time();
$data[member_id]=$this->data($data)->add();
return $data;
}
}
+113
View File
@@ -0,0 +1,113 @@
<?php
namespace Home\Model;
class Tongji{
private $search_engine_inc=array(
"baidu." =>"baidu",
"google." =>"google",
"sogou." =>"sogou",
"so." =>"360",
"bing." =>"bing",
);
public function start(){
$visit_userId =$_COOKIE["visit_userId"];
if(!$visit_userId){
$data=array();
//进站方式
$http_referer=$_SERVER['HTTP_REFERER'];
if(!$http_referer){
$data['visit_type']="website";
}else{
$searcn_engine=$this->search_engine();
if($searcn_engine){
$data['visit_type']="search";
$data['search_engine']=$searcn_engine;
}else{
$data['visit_type']="link";
}
}
//ip地址
$data['ip']= get_client_ip(0,true);
//访问时间
$data['visit_time']=time();
//先插入48小时的表
M("visit_48")->add($data);
//再插入visit表
$today_start=strtotime(date("Y-m-d ")."00:00:00");
$today_end=strtotime(date("Y-m-d ")."23:59:59");
$where=array();
$where["visit_time"]=array("between",array($today_start,$today_end));
$data2=array();
//时间
$data2['daytime']=strtotime(date("Y-m-d"));
//IP统计
$ip_total=M("visit_48")->field("ip")->where($where)->group("ip")->select();
$data2['ip']=count($ip_total);
//pv统计
$data2['pv']=M("visit_48")->where($where)->count();
//visit_search 搜索进来的用户
$where2=array();
$where2=$where;
$where2["visit_type"]="search";
$data2['visit_search']=M("visit_48")->where($where2)->count();
//website 输入网址进来的用户
$where2=array();
$where2=$where;
$where2["visit_type"]="website";
$data2['visit_website']=M("visit_48")->where($where2)->count();
//link 通过链接跳转进来的用户
$where2=array();
$where2=$where;
$where2["visit_type"]="link";
$data2['visit_link']=M("visit_48")->where($where2)->count();
//各大搜索引擎判断
//baidu
$where2=array();
$where2=$where;
$where2["visit_type"]="search";
$where2["search_engine"]="baidu";
$data2['engine_baidu']=M("visit_48")->where($where2)->count();
//google
$where2=array();
$where2=$where;
$where2["visit_type"]="search";
$where2["search_engine"]="google";
$data2['engine_google']=M("visit_48")->where($where2)->count();
//sogou
$where2=array();
$where2=$where;
$where2["visit_type"]="search";
$where2["search_engine"]="sogou";
$data2['engine_sogou']=M("visit_48")->where($where2)->count();
//360
$where2=array();
$where2=$where;
$where2["visit_type"]="search";
$where2["search_engine"]="360";
$data2['engine_360']=M("visit_48")->where($where2)->count();
//bing
$where2=array();
$where2=$where;
$where2["visit_type"]="search";
$where2["search_engine"]="bing";
$data2['engine_bing']=M("visit_48")->where($where2)->count();
//
$visit_id=M("visit")->where(array("daytime"=>$data2['daytime']))->getField("id");
if($visit_id){
$data2["id"]=$visit_id;
M("visit")->save($data2);
}else{
M("visit")->add($data2);
}
//设置访问cookie,过期时间为今天23:59:59
setcookie("visit_userId",time()+rand(10000,99999), strtotime(date("Y-d-m")." 23:59:59"));
}
}
//判断搜索引擎
private function search_engine(){
foreach($this->search_engine_inc as $key=>$engine){
if(strstr($_SERVER['HTTP_REFERER'],$key)){
return $engine;
}
}
}
}
+1
View File
@@ -0,0 +1 @@
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<title>{$pagetitle}</title>
</head>
<body>
<form action="{:U('add')}" method="post" onsubmit="return save_form(this,function(){alert('恭喜您留言提交成功!');history.go(0)})">
<input type="hidden" name="catid" value="{$cat.catid}">
<?php
include(APP_PATH."./Data/feedbackTemp/".$cat["catid"].".php");
if($cat["verify_code"]){
?>
<div class="control-group">
<label class="control-label">验证码<span></span></label>
<div class="controls">
<input type="text" placeholder="" name="verfy_code" class="span6" value="" style=""/><img src="{:U('Public/veryfyImg')}" class="verifyimg reloadverify" alt="点击切换">
</div>
</div>
<?php
}
?>
<button type="submit">提交</button>
</form>
</body>
</html>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/layer/layer.js"></script>
<script src="/Public/Admin/js/globals.js"></script>
<script src="/Public/Admin/My97DatePicker/WdatePicker.js"></script>
<script>
$(function(){
//刷新验证码
var verifyimg = $(".verifyimg").attr("src");
$(".reloadverify").click(function () {
if (verifyimg.indexOf('?') > 0) {
$(".verifyimg").attr("src", verifyimg + '&random=' + Math.random());
} else {
$(".verifyimg").attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
}
});
})
</script>
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
<title>跳转提示</title>
<link rel="stylesheet" href="/Public/Home/css/weui.css"/>
</head>
<body ontouchstart>
<div class="page msg_success js_show">
<div class="weui-msg">
<div class="weui-msg__icon-area"><i class="weui-icon-warn weui-icon_msg"></i></div>
<div class="weui-msg__text-area">
<h2 class="weui-msg__title">
<?php if(isset($message)) {?>
<?php echo($message); ?>
<?php }else{?>
<?php echo($error); ?>
<?php }?>
</h2>
</div>
<div class="weui-msg__opr-area">
<p class="weui-btn-area">
<a href="<?php echo($jumpUrl); ?>" id="href" class="weui-btn weui-btn_primary">返回上一页</a>
</p>
</div>
<div class="weui-msg__extra-area">
<div class="weui-footer">
<p class="weui-footer__links">
</p>
<p class="weui-footer__text">Copyright © {:date("Y")}-{:date("Y")+1}</p>
</div>
</div>
</div>
</div>
<script type="text/javascript">
(function(){
var wait = 3,href = document.getElementById('href').href;
var interval = setInterval(function(){
var time = --wait;
if(time <= 0) {
location.href = href;
clearInterval(interval);
};
}, 1000);
})();
</script>
</body>
</html>
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
<title>操作成功</title>
<link rel="stylesheet" href="/Public/Home/css/weui.css"/>
</head>
<body ontouchstart>
<div class="page msg_success js_show">
<div class="weui-msg">
<div class="weui-msg__icon-area"><i class="weui-icon-success weui-icon_msg"></i></div>
<div class="weui-msg__text-area">
<h2 class="weui-msg__title">
<?php if(isset($message)) {?>
<?php echo($message); ?>
<?php }else{?>
<?php echo($error); ?>
<?php }?>
</h2>
</div>
<div class="weui-msg__opr-area">
<p class="weui-btn-area">
<a href="<?php echo($jumpUrl); ?>" id="href" class="weui-btn weui-btn_primary">继续操作</a>
</p>
</div>
<div class="weui-msg__extra-area">
<div class="weui-footer">
<p class="weui-footer__links">
</p>
<p class="weui-footer__text">Copyright © {:date("Y")}-{:date("Y")+1}</p>
</div>
</div>
</div>
</div>
<script type="text/javascript">
(function(){
var wait = 3,href = document.getElementById('href').href;
var interval = setInterval(function(){
var time = --wait;
if(time <= 0) {
location.href = href;
clearInterval(interval);
};
}, 1000);
})();
</script>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@