Initial commit,修正

This commit is contained in:
2025-07-13 19:37:38 +08:00
parent 38ce288e27
commit 65bbd06981
12384 changed files with 3985464 additions and 8 deletions
+44
View File
@@ -0,0 +1,44 @@
<?php
/**
* @Author: fm453
* @Date: 2018-11-21 04:18:24
* @Last Modified by: fm453
* @Last Modified time: 2019-10-07 17:16:03
* @Email: fm453@lukegzs.com
*/
namespace common\components;
use Yii;
use yii\data\Pagination;
use yii\widgets\ActiveForm;
class Attachment extends ActiveForm
{
/*处理分页*/
private $pagination;
/**
* 获取$pagination,提供给外部代码调用
* @return mixed
*/
public function getPagination()
{
return $this->pagination;
}
public function getData($model,$where,$orderby)
{
// 预查询,此时还没有执行。where()条件查询、orderBy()排序等都应该放在这里
$query = $model->find()->where($where)->orderBy($orderby);
// 获取能够查询到的数据条目数量(这就是条件查询等语句要放在上一行代码的原因),但是还没有执行查询
$count = $query->count();
// 构造分页对象
$this->pagination = new Pagination(['totalCount'=>$count,'defaultPageSize' => 12]);
// 使用分页对象填充limit语句,并获得数据(此时才真正执行数据库查询)
return $query->offset($this->pagination->offset)
->limit($this->pagination->limit)
->asArray()
->all();
}
}
+68
View File
@@ -0,0 +1,68 @@
<?php
/**
* Description:操作日志记录
*/
namespace common\components;
use common\models\Logs;
use Yii;
class DoLogs {
public static function record(){
$username = '';
$uid = 0;
if(isset(Yii::$app->user->identity)){
$username = Yii::$app->user->identity->username;
$uid = Yii::$app->user->identity->id;
}
$usertypes = array(
'app-backend' => '1',
'app-frontend' => '2',
);
$usertype = $usertypes[Yii::$app->id];
$request = Yii::$app->getRequest();
$nowFile = $request -> getScriptFile();
$r = isset($_GET['r']) ? $_GET['r'] : 'null/null';
$r = explode('/',$r);
$m = '';
$m = $r[0];
$v = '';
$c = '';
$c = $r[1];
//$a = __METHOD__; //当前方法
$a = '';
$ip = Yii::$app->request->userIP;
$domain=$_SERVER['HTTP_HOST'];
$data = '';
Yii::$app->db->createCommand()->insert(
'c_logs', [
'username' => $username,
'uid' => $uid,
'usertype' => $usertype,
'file' => $nowFile,
'm' => $m,
'v' => $v,
'c' => $c,
'a' => $a,
'ip'=>$ip,
'domain' => $domain,
'data'=>$data,
'create_time' => time(),
])->execute();
}
//历史访客数
public static function getHistoryVisNum(){
$res = Logs::find()->count();
return $res;
}
//最近一个月访问量
public static function getMonthHistoryVisNum(){
$LastMonth = strtotime("-1 month");
$res = Logs::find()->where(['>','create_time',$LastMonth])->count();
return $res;
}
}
+67
View File
@@ -0,0 +1,67 @@
<?php
/**
* @Author: fm453
* @Date: 2021-09-08 00:25:51
* @Last Modified by: fm453
* @Last Modified time: 2021-09-09 02:03:09
* @Email: fm453@lukegzs.com
*/
namespace common\components;
use Yii;
class HiCookie {
//添加Cookie
public static function set($name,$value,$httpOnly=true,$expire=null)
{
$cookie = new \yii\web\Cookie();
$cookie->name = $name; //cookie的名称
$expire = $expire>0 ? $expire : '180'; //默认180s
$cookie->expire = time() + $expire; //存活的时间
$cookie->httpOnly = $httpOnly; //无法通过js读取cookie
$cookie->value = $value; //cookie的值
\Yii::$app->response->getCookies()->add($cookie);
}
//读取Cookie
public static function get($name)
{
if(\Yii::$app->request->cookies->has($name)){
return \Yii::$app->request->cookies->getValue($name);
}
return false;
}
public static function getObj($name)
{
if(\Yii::$app->request->cookies->has($name)){
return \Yii::$app->request->cookies->get($name);
}
return false;
}
//删除Cookie /*注意删除用的是response而不是request*/
public static function delete($name)
{
$cookie = $this->getObj($name);
//移除一个Cookie对象
if($cookie){
\Yii::$app->response->getCookies()->remove($cookie);
}
}
public static function deleteAll()
{
//移除所有Cookie,目前好像不太好使
\Yii::$app->response->getCookies()->removeAll();
}
//读取Cookie的总数
public static function count()
{
return \Yii::$app->request->cookies->count();
}
}