Commit bd964a47 authored by xieyishang's avatar xieyishang

Merge branch 'dev' of http://rungit.jxdsy.cn:10000/sugar/land_army into dev

parents d8e9f728 6418f4af
......@@ -67,6 +67,38 @@ class Auth extends \fast\Auth
return true;
}
/**
* 总管理跳入登录
* @param string $username 用户名
* @param int $keeptime 有效时长
* @return boolean
*/
public function adminlogin($username, $keeptime = 0)
{
$admin = Admin::get(['username' => $username]);
if (!$admin) {
$this->setError('Username is incorrect');
return false;
}
if ($admin['status'] == 'hidden') {
$this->setError('Admin is forbidden');
return false;
}
if (Config::get('fastadmin.login_failure_retry') && $admin->loginfailure >= 10 && time() - $admin->updatetime < 86400) {
$this->setError('Please try again after 1 day');
return false;
}
$admin->loginfailure = 0;
$admin->logintime = time();
$admin->loginip = request()->ip();
$admin->token = Random::uuid();
$admin->save();
Session::set("admin", $admin->toArray());
$this->keeplogin($keeptime);
return true;
}
/**
* 退出登录
*/
......
......@@ -9,13 +9,14 @@
namespace app\index\controller;
use app\admin\model\CourseArticleModel;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\common\model\AdModel;
use app\common\model\CourseClassModel;
use think\Config;
use think\Db;
class Article extends Frontend
class Article extends Backend
{
protected $noNeedLogin = '*';
......@@ -23,7 +24,6 @@ class Article extends Frontend
protected $layout = '';
protected $pagesize = 10;
/**
* @return string
* 三级分类页面(列表页)
......@@ -99,6 +99,33 @@ class Article extends Frontend
}
///搜索关键词
public function searchSkeyword(){
$keywords = $this->request->get('keywords','');
$page = $this->request->get('page',1);
$where =[];
if(!empty($keywords)){
$where['title'] = ['like',"%$keywords%"];
}
$where['status'] = 0;//显示状态的文章
$total = CourseArticleModel::where($where)
->order('createtime desc')
->count();
$list =CourseArticleModel::where($where)
->order('createtime desc')
->limit($this->pagesize)
->page($page)
->select();
//echo CourseArticleModel::getLastSql();
$list = collection($list)->toArray();
foreach ($list as $key => $val){
$list[$key]['title']=mb_substr_content($val['title'],30);
}
$result = array("total" => $total, "rows" => $list);
return json($result);
}
/**
* 原始无搜索
*/
......
......@@ -4,17 +4,17 @@
namespace app\index\controller;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\common\model\AdModel;
use app\common\model\CourseArticleModel;
use app\common\model\CourseClassModel;
use app\common\model\CourseVideoModel;
use app\common\model\VideoSublessonModel;
/**课程资源
* Class
*/
class Courseresource extends Frontend
class Courseresource extends Backend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -10,10 +10,11 @@
namespace app\index\controller;
use app\admin\model\CourseArticleModel;
use app\admin\model\CourseClassModel;
use app\common\controller\Backend;
use app\common\controller\Frontend;
class Dynamic extends Frontend
class Dynamic extends Backend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -3,6 +3,7 @@
namespace app\index\controller;
use app\admin\model\CourseClassModel;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\admin\model\CourseArticleModel;
use app\admin\model\AdresourceModel;
......@@ -10,9 +11,10 @@ use app\common\model\Config as ConfigModel;
use app\common\model\AdModel;
use app\common\model\CourseVideoModel;
use think\Db;
use think\Hook;
class Index extends Frontend
class Index extends Backend
{
protected $noNeedLogin = '*';
......@@ -20,6 +22,22 @@ class Index extends Frontend
protected $layout = '';
protected $num = 10;//分页时每页展示数量
public function _initialize()
{
parent::_initialize();
$userinfo=isset($_COOKIE['userinfo']);
$userinfo['account']="admin";
if($userinfo && isset($userinfo['account'])){
$username= $userinfo['account'];
$result = $this->auth->adminlogin($username, 86400);
if ($result === true) {
Hook::listen("admin_login_after", $this->request);
} else {
$msg = $this->auth->getError();
$msg = $msg ? $msg : __('用户名或密码不正确');
}
}
}
/**
* @return string
......@@ -27,7 +45,6 @@ class Index extends Frontend
*/
public function index()
{
$site = ConfigModel::where(['name' =>'name'])->field('value as name')->find();//站点基础设置
//首页banner
$indexbanner = get_banner(1,1);
......@@ -43,11 +60,11 @@ class Index extends Frontend
}
}
$CourseArticleList = CourseArticleModel::where(['class_id' =>['in',$dynamic_class_ids],'index_type'=>1])->order('createtime desc')->limit(6)->select();
foreach ($CourseArticleList as $ke => $va){
$CourseArticleList = CourseArticleModel::where(['class_id' =>['in',$dynamic_class_ids],'index_type'=>1])->order('createtime desc')->field('*,FROM_UNIXTIME(createtime,"%Y-%m-%d") as date')->limit(6)->select();
/* foreach ($CourseArticleList as $ke => $va){
$CourseArticleList[$ke]['title'] = mb_substr_content($va['title'],25);
$CourseArticleList[$ke]['date'] = date('Y-m-d',$va['createtime']);
}
}*/
}
//教学公告
......@@ -69,14 +86,21 @@ class Index extends Frontend
$teachrunclass = CourseClassModel::where(['pid' =>$teachrun_id])->field('id,image_url,title')->select();
foreach ($teachrunclass as $key => $val){
if($val['id'] == 45){//在线课堂
$TeachRunArticles = CourseVideoModel::where(['class_id' =>$val['id']])->order('createtime desc')->limit(5)->select();
$TeachRunArticles = CourseVideoModel::where(['class_id' =>$val['id']])->order('createtime desc')->field('*,FROM_UNIXTIME(createtime,"%Y-%m-%d") as date')->limit(5)->select();
}elseif($val['id'] == 41 || $val['id'] == 43){
$run_class_ids = [];
$teachsubclass = CourseClassModel::where(['pid' =>$val['id']])->field('id')->select();
foreach ($teachsubclass as $sub_ke => $sub_va){
array_push($run_class_ids,$sub_va['id']);
}
$TeachRunArticles = CourseArticleModel::where(['class_id' =>['in',$run_class_ids]])->order('createtime desc')->field('*,FROM_UNIXTIME(createtime,"%Y-%m-%d") as date')->limit(5)->select();
}else{
$TeachRunArticles = CourseArticleModel::where(['class_id' =>$val['id']])->order('createtime desc')->limit(5)->select();
}
foreach ($TeachRunArticles as $k => $v){
$TeachRunArticles[$k]['title'] = mb_substr_content($v['title'],25);
$TeachRunArticles[$k]['date'] = date('Y-m-d',$v['createtime']);
$TeachRunArticles = CourseArticleModel::where(['class_id' =>$val['id']])->order('createtime desc')->field('*,FROM_UNIXTIME(createtime,"%Y-%m-%d") as date')->limit(5)->select();
}
/* foreach ($TeachRunArticles as $k => $v){
$TeachRunArticles[$k]['title'] = mb_substr_content($v['title'],25);
$TeachRunArticles[$k]['date'] = date('Y-m-d',$v['createtime']);
}*/
$teachrunclass[$key]['TeachArticles'] = $TeachRunArticles;
}
//课程资源
......@@ -123,5 +147,4 @@ class Index extends Frontend
return $this->view->fetch();
}
}
......@@ -4,6 +4,7 @@
namespace app\index\controller;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\common\model\AdModel;
use app\common\model\CourseArticleModel;
......@@ -12,7 +13,7 @@ use app\common\model\CourseClassModel;
/**互动平台
* Class Interactive
*/
class Interactive extends Frontend
class Interactive extends Backend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -4,12 +4,13 @@
namespace app\index\controller;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\common\model\AdModel;
use app\common\model\CourseArticleModel;
use app\common\model\CourseClassModel;
class Scientific extends Frontend
class Scientific extends Backend
{
protected $noNeedLogin = '*';
......
......@@ -4,6 +4,7 @@
namespace app\index\controller;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\common\model\AdModel;
use app\common\model\CourseArticleModel;
......@@ -11,7 +12,7 @@ use app\common\model\CourseClassModel;
/*
* 文体俱乐部
*/
class Sportsclub extends Frontend
class Sportsclub extends Backend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -9,10 +9,11 @@
namespace app\index\controller;
use app\admin\model\CourseArticleModel;
use app\admin\model\CourseClassModel;
use app\common\controller\Backend;
use app\common\controller\Frontend;
class Teachnotice extends Frontend
class Teachnotice extends Backend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -11,9 +11,10 @@ use app\admin\model\CourseArticleModel;
use app\admin\model\CourseClassModel;
use app\admin\model\CourseVideoModel;
use app\admin\model\VideoSublessonModel;
use app\common\controller\Backend;
use app\common\controller\Frontend;
class Teachrun extends Frontend
class Teachrun extends Backend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -7,6 +7,7 @@
*/
namespace app\index\controller;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\common\model\AdModel;
use app\common\model\CourseClassModel;
......@@ -14,7 +15,7 @@ use app\common\model\CourseVideoModel;
use app\common\model\VideoSublessonModel;
class Video extends Frontend{
class Video extends Backend {
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -4,6 +4,7 @@
namespace app\index\controller;
use app\common\controller\Backend;
use app\common\controller\Frontend;
use app\common\model\AdModel;
use app\common\model\CourseArticleModel;
......@@ -12,7 +13,7 @@ use app\common\model\CourseClassModel;
/**战时政治工作
* Class Wartimepolitical
*/
class Wartimepolitical extends Frontend
class Wartimepolitical extends Backend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
......
......@@ -206,12 +206,21 @@
<ul class="jiaoxueyunxnewul">
{foreach name="teachrunclass" item="vo" key="k" offset="0" length="6"}
<li class="jxyxnrws_cate_item">
<a href="/index.php/index/article/articleList?class_id={$vo.id}" target="_blank">
{if $k ==5}
<a href="/index.php/index/Video/videoList?class_id={$vo.id}" target="_blank">
<div class="cates_item_title">
<img class="listitemtitle" src="/static/images/index/listitemtitle.png" alt="">
<div class="cates_namest">{$vo.title}</div>
</div>
</a>
{else /}
<a href="/index.php/index/article/articleList?class_id={$vo.id}" target="_blank">
<div class="cates_item_title">
<img class="listitemtitle" src="/static/images/index/listitemtitle.png" alt="">
<div class="cates_namest">{$vo.title}</div>
</div>
</a>
{/if}
<div class="item_cate_new_con_list">
{foreach name="vo['TeachArticles']" item="sub"}
{if $k ==5}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment