sxjun@ulucu.com 2 years ago
parent
commit
e3751c3456
100 changed files with 9856 additions and 0 deletions
  1. BIN
      words20201124.tar.gz
  2. 5 0
      www.hanlinyuanonline.com/.buildpath
  3. 8 0
      www.hanlinyuanonline.com/.htaccess
  4. 27 0
      www.hanlinyuanonline.com/.project
  5. BIN
      www.hanlinyuanonline.com/Application/Admin/.zip
  6. 1 0
      www.hanlinyuanonline.com/Application/Admin/Common/index.html
  7. 17 0
      www.hanlinyuanonline.com/Application/Admin/Conf/config.php
  8. 31 0
      www.hanlinyuanonline.com/Application/Admin/Conf/development.php
  9. 1 0
      www.hanlinyuanonline.com/Application/Admin/Conf/index.html
  10. 38 0
      www.hanlinyuanonline.com/Application/Admin/Conf/online.php
  11. 70 0
      www.hanlinyuanonline.com/Application/Admin/Controller/ActivityController.class.php
  12. 144 0
      www.hanlinyuanonline.com/Application/Admin/Controller/AlarmController.class.php
  13. 168 0
      www.hanlinyuanonline.com/Application/Admin/Controller/ChoiceController.class.php
  14. 266 0
      www.hanlinyuanonline.com/Application/Admin/Controller/CourseController.class.php
  15. 80 0
      www.hanlinyuanonline.com/Application/Admin/Controller/CoursetypeController.class.php
  16. 51 0
      www.hanlinyuanonline.com/Application/Admin/Controller/FeedbackController.class.php
  17. 122 0
      www.hanlinyuanonline.com/Application/Admin/Controller/GoodController.class.php
  18. 108 0
      www.hanlinyuanonline.com/Application/Admin/Controller/IndexController.class.php
  19. 69 0
      www.hanlinyuanonline.com/Application/Admin/Controller/LoginController.class.php
  20. 64 0
      www.hanlinyuanonline.com/Application/Admin/Controller/ManagerController.class.php
  21. 118 0
      www.hanlinyuanonline.com/Application/Admin/Controller/NotepadController.class.php
  22. 87 0
      www.hanlinyuanonline.com/Application/Admin/Controller/NoticeController.class.php
  23. 74 0
      www.hanlinyuanonline.com/Application/Admin/Controller/SliderController.class.php
  24. 58 0
      www.hanlinyuanonline.com/Application/Admin/Controller/SoftController.class.php
  25. 214 0
      www.hanlinyuanonline.com/Application/Admin/Controller/SquareController.class.php
  26. 171 0
      www.hanlinyuanonline.com/Application/Admin/Controller/StoreController.class.php
  27. 464 0
      www.hanlinyuanonline.com/Application/Admin/Controller/UeditorController.class.php
  28. 239 0
      www.hanlinyuanonline.com/Application/Admin/Controller/UserController.class.php
  29. 319 0
      www.hanlinyuanonline.com/Application/Admin/Controller/WordsController.class.php
  30. 1 0
      www.hanlinyuanonline.com/Application/Admin/Controller/index.html
  31. 40 0
      www.hanlinyuanonline.com/Application/Admin/Model/CourseModel.class.php
  32. 21 0
      www.hanlinyuanonline.com/Application/Admin/Model/FeedbackModel.class.php
  33. 41 0
      www.hanlinyuanonline.com/Application/Admin/Model/NotepadModel.class.php
  34. 12 0
      www.hanlinyuanonline.com/Application/Admin/Model/UserConnectModel.class.php
  35. 1 0
      www.hanlinyuanonline.com/Application/Admin/Model/index.html
  36. 167 0
      www.hanlinyuanonline.com/Application/Admin/View/Activity/edit.html
  37. 83 0
      www.hanlinyuanonline.com/Application/Admin/View/Activity/index.html
  38. 85 0
      www.hanlinyuanonline.com/Application/Admin/View/Alarm/index.html
  39. 173 0
      www.hanlinyuanonline.com/Application/Admin/View/Alarm/info.html
  40. 64 0
      www.hanlinyuanonline.com/Application/Admin/View/Alarm/refuse.html
  41. 65 0
      www.hanlinyuanonline.com/Application/Admin/View/Choice/detail.html
  42. 146 0
      www.hanlinyuanonline.com/Application/Admin/View/Choice/edit.html
  43. 133 0
      www.hanlinyuanonline.com/Application/Admin/View/Choice/index.html
  44. 222 0
      www.hanlinyuanonline.com/Application/Admin/View/Course/detail.html
  45. 78 0
      www.hanlinyuanonline.com/Application/Admin/View/Course/edit.html
  46. 131 0
      www.hanlinyuanonline.com/Application/Admin/View/Course/import.html
  47. 128 0
      www.hanlinyuanonline.com/Application/Admin/View/Course/index.html
  48. 71 0
      www.hanlinyuanonline.com/Application/Admin/View/Coursetype/course.html.bak
  49. 57 0
      www.hanlinyuanonline.com/Application/Admin/View/Coursetype/edit.html
  50. 76 0
      www.hanlinyuanonline.com/Application/Admin/View/Coursetype/index.html
  51. 107 0
      www.hanlinyuanonline.com/Application/Admin/View/Feedback/index.html
  52. 81 0
      www.hanlinyuanonline.com/Application/Admin/View/Feedback/sys.html
  53. 116 0
      www.hanlinyuanonline.com/Application/Admin/View/Good/add.html
  54. 65 0
      www.hanlinyuanonline.com/Application/Admin/View/Good/edit.html
  55. 112 0
      www.hanlinyuanonline.com/Application/Admin/View/Good/index.html
  56. 162 0
      www.hanlinyuanonline.com/Application/Admin/View/Index/index.html
  57. 108 0
      www.hanlinyuanonline.com/Application/Admin/View/Index/pwd.html
  58. 78 0
      www.hanlinyuanonline.com/Application/Admin/View/Login/index.html
  59. 114 0
      www.hanlinyuanonline.com/Application/Admin/View/Manager/edit.html
  60. 93 0
      www.hanlinyuanonline.com/Application/Admin/View/Manager/index.html
  61. 65 0
      www.hanlinyuanonline.com/Application/Admin/View/Notepad/edit.html
  62. 113 0
      www.hanlinyuanonline.com/Application/Admin/View/Notepad/index.html
  63. 106 0
      www.hanlinyuanonline.com/Application/Admin/View/Notice/edit.html
  64. 79 0
      www.hanlinyuanonline.com/Application/Admin/View/Notice/index.html
  65. 10 0
      www.hanlinyuanonline.com/Application/Admin/View/Public/bar.html
  66. 276 0
      www.hanlinyuanonline.com/Application/Admin/View/Public/left.html
  67. 104 0
      www.hanlinyuanonline.com/Application/Admin/View/Public/top.html
  68. 69 0
      www.hanlinyuanonline.com/Application/Admin/View/Public/top1.html
  69. 81 0
      www.hanlinyuanonline.com/Application/Admin/View/Public/topbak.html
  70. 132 0
      www.hanlinyuanonline.com/Application/Admin/View/Slider/edit.html
  71. 75 0
      www.hanlinyuanonline.com/Application/Admin/View/Slider/index.html
  72. 113 0
      www.hanlinyuanonline.com/Application/Admin/View/Soft/edit.html
  73. 71 0
      www.hanlinyuanonline.com/Application/Admin/View/Soft/index.html
  74. 116 0
      www.hanlinyuanonline.com/Application/Admin/View/Square/course.html
  75. 133 0
      www.hanlinyuanonline.com/Application/Admin/View/Square/detailCourse.html
  76. 61 0
      www.hanlinyuanonline.com/Application/Admin/View/Square/detailNotepad.html
  77. 119 0
      www.hanlinyuanonline.com/Application/Admin/View/Square/notepad.html
  78. 155 0
      www.hanlinyuanonline.com/Application/Admin/View/Square/show.html
  79. 60 0
      www.hanlinyuanonline.com/Application/Admin/View/Square/unpass.html
  80. 140 0
      www.hanlinyuanonline.com/Application/Admin/View/Store/detail.html
  81. 69 0
      www.hanlinyuanonline.com/Application/Admin/View/Store/edit.html
  82. 88 0
      www.hanlinyuanonline.com/Application/Admin/View/Store/index.html
  83. 86 0
      www.hanlinyuanonline.com/Application/Admin/View/Store/words.html
  84. 71 0
      www.hanlinyuanonline.com/Application/Admin/View/User/course.html
  85. 117 0
      www.hanlinyuanonline.com/Application/Admin/View/User/detail.html
  86. 189 0
      www.hanlinyuanonline.com/Application/Admin/View/User/index.html
  87. 69 0
      www.hanlinyuanonline.com/Application/Admin/View/User/notepad.html
  88. 353 0
      www.hanlinyuanonline.com/Application/Admin/View/Words/edit.html
  89. 1 0
      www.hanlinyuanonline.com/Application/Admin/View/index.html
  90. 1 0
      www.hanlinyuanonline.com/Application/Admin/index.html
  91. 237 0
      www.hanlinyuanonline.com/Application/Api/Common/function.php
  92. 1 0
      www.hanlinyuanonline.com/Application/Api/Common/index.html
  93. 19 0
      www.hanlinyuanonline.com/Application/Api/Conf/config.php
  94. 50 0
      www.hanlinyuanonline.com/Application/Api/Conf/development.php
  95. 1 0
      www.hanlinyuanonline.com/Application/Api/Conf/index.html
  96. 60 0
      www.hanlinyuanonline.com/Application/Api/Conf/online.php
  97. BIN
      www.hanlinyuanonline.com/Application/Api/Controller/.UserController.class.php.swp
  98. 62 0
      www.hanlinyuanonline.com/Application/Api/Controller/AcfunController.class.php
  99. 459 0
      www.hanlinyuanonline.com/Application/Api/Controller/ChoiceController.class.php
  100. 0 0
      www.hanlinyuanonline.com/Application/Api/Controller/CourseController.class.php

BIN
words20201124.tar.gz


+ 5 - 0
www.hanlinyuanonline.com/.buildpath

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<buildpath>
+	<buildpathentry excluding="vendor/**/test*/**" kind="src" path=""/>
+	<buildpathentry kind="con" path="org.eclipse.php.core.LANGUAGE"/>
+</buildpath>

+ 8 - 0
www.hanlinyuanonline.com/.htaccess

@@ -0,0 +1,8 @@
+<IfModule mod_rewrite.c>
+  Options +FollowSymlinks
+  RewriteEngine On
+
+  RewriteCond %{REQUEST_FILENAME} !-d
+  RewriteCond %{REQUEST_FILENAME} !-f
+  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
+</IfModule>

+ 27 - 0
www.hanlinyuanonline.com/.project

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>words</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.dltk.core.scriptbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.zend.php.composer.core.ComposerJsonBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.php.core.PHPNature</nature>
+	</natures>
+</projectDescription>

BIN
www.hanlinyuanonline.com/Application/Admin/.zip


+ 1 - 0
www.hanlinyuanonline.com/Application/Admin/Common/index.html

@@ -0,0 +1 @@
+ 

+ 17 - 0
www.hanlinyuanonline.com/Application/Admin/Conf/config.php

@@ -0,0 +1,17 @@
+<?php
+if($_SERVER['DEPLOY_ENV']=='DEVELOPMENT'){//本地开发环境
+    return array(
+        //'配置项'=>'配置值'
+        'LOAD_EXT_CONFIG' => 'development',
+    );
+}elseif($_SERVER['DEPLOY_ENV']=='ONLINE'){//线上环境
+    return array(
+        //'配置项'=>'配置值'
+        'LOAD_EXT_CONFIG' => 'online',
+    );
+}else{
+    return array(
+        //'配置项'=>'配置值'
+        'LOAD_EXT_CONFIG' => 'online',
+    );
+}

+ 31 - 0
www.hanlinyuanonline.com/Application/Admin/Conf/development.php

@@ -0,0 +1,31 @@
+<?php
+return array(
+    //'配置项'=>'配置值'
+    'DB_TYPE'       => 'mysql', //分布式数据库类型必须相同
+    'DB_HOST'       => 'localhost',
+    'DB_NAME'       => 'words', //如果相同可以不用定义多个
+    'DB_USER'       => 'root',
+    'DB_PWD'        => '',
+    'DB_PORT'       => '3306',
+    'DB_PREFIX'     => 't_',
+
+    'URL_CASE_INSENSITIVE'=>false,//设置url区分大小写
+
+    'TMPL_L_DELIM'          =>  '<{',// 模板引擎普通标签开始标记
+    'TMPL_R_DELIM'          =>  '}>',// 模板引擎普通标签结束标记
+
+    //验证码
+    'VERIFY_CODE'=>array(
+        'fontSize'    =>    50,    // 验证码字体大小
+        'length'      =>    4,     // 验证码位数
+        'useNoise'    =>    true, // 关闭验证码杂点
+    ),
+    
+    'WEB_HOST'=> 'http://words.my',
+    
+    'URL_HTML_SUFFIX'=>'',
+    'IMG_PATH'=>'./Uploads/img/',
+    'MUSIC_PATH'=>'./Uploads/music/',
+    
+    'TRANS' => 'http://dict-co.iciba.com/api/dictionary.php?key=293E92740629E0F44C315F64B9BDE4A6',
+);

+ 1 - 0
www.hanlinyuanonline.com/Application/Admin/Conf/index.html

@@ -0,0 +1 @@
+ 

+ 38 - 0
www.hanlinyuanonline.com/Application/Admin/Conf/online.php

@@ -0,0 +1,38 @@
+<?php
+return array(
+    //'配置项'=>'配置值'
+    'DB_TYPE'       => 'mysql', //分布式数据库类型必须相同
+    'DB_HOST'       => 'localhost',
+    'DB_NAME'       => 'words', //如果相同可以不用定义多个
+    'DB_USER'       => 'root',
+    'DB_PWD'        => 'KeYpZrZx',
+    'DB_PORT'       => '3306',
+    'DB_PREFIX'     => 't_',
+
+    'URL_CASE_INSENSITIVE'=>true,//设置url区分大小写
+
+    'TMPL_L_DELIM'          =>  '<{',// 模板引擎普通标签开始标记
+    'TMPL_R_DELIM'          =>  '}>',// 模板引擎普通标签结束标记
+
+    /* 'HTML_CACHE_ON' =>true,
+    'HTML_CACHE_TIME'   =>    86400,   // 全局静态缓存有效期(秒)
+    'HTML_FILE_SUFFIX'  =>    '.htm', // 设置静态缓存文件后缀
+    'HTML_CACHE_RULES'  =>     array(
+        '*'=>array('{$_SERVER.REQUEST_URI|md5}')
+    ), */
+    
+    //验证码
+    'VERIFY_CODE'=>array(
+        'fontSize'    =>    50,    // 验证码字体大小
+        'length'      =>    4,     // 验证码位数
+        'useNoise'    =>    true, // 关闭验证码杂点
+    ),
+    
+    'WEB_HOST'=> 'http://www.hanlinyuanonline.com',
+    
+    'URL_HTML_SUFFIX'=>'',
+    'IMG_PATH'=>'./Uploads/img/',
+    'MUSIC_PATH'=>'./Uploads/music/',
+    
+    'TRANS' => 'http://dict-co.iciba.com/api/dictionary.php?key=293E92740629E0F44C315F64B9BDE4A6',
+);

+ 70 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/ActivityController.class.php

@@ -0,0 +1,70 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class ActivityController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    public function index(){
+        $count = M('Activity')->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $list = M('Activity')->order('act_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$list);
+        $this->display();
+    }
+    
+    public function edit(){
+        $step = I('step','');
+        $actId = I('act_id','');
+        if (empty($step)){
+            $info = array();
+            if (!empty($actId)){
+                $info = M('Activity')->where(array('act_id'=>$actId))->find();
+            }
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $saveData =[
+                'act_title'=>I('act_title',''),
+                'act_sort'=>I('act_sort','0'),
+                'act_pic'=>I('act_pic',''),
+                'act_name'=>I('act_name',''),
+                'act_content'=>I('act_content',''),
+            ] ;
+            if (empty($saveData['act_pic'])){
+                $this->error('图片不能为空');
+            }
+            if (empty($saveData['act_title'])){
+                $this->error('活动名称不能为空');
+            }
+            if (empty($saveData['act_name'])){
+                $this->error('出品方不能为空');
+            }
+            if ($actId){
+                M('Activity')->where(array('act_id'=>$actId))->save($saveData);
+            }else{
+                $saveData['operate_dt'] = time();
+                M('Activity')->add($saveData);
+            }
+            $this->success('操作成功','/admin/activity/index');
+        }
+    }
+    
+    public function status(){
+        $actId = I('act_id','');
+        $actStatus = I('act_status','');
+        M('Activity')->where(array('act_id'=>$actId))->save(['act_status'=>$actStatus]);
+        $this->success('操作成功','/admin/activity/index');
+    }
+    
+    //删除
+    public function del(){
+        $actId = I('act_id','');
+        M('Activity')->where(array('act_id'=>$actId))->delete();
+        $this->success('操作成功','/admin/activity/index');
+    }
+}

+ 144 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/AlarmController.class.php

@@ -0,0 +1,144 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class AlarmController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    public function index(){
+        $page = I('get.p','1');
+        session('page',$page);
+        $condition = array('is_delete'=>1,'notice_flag'=>array('IN','5,6,7'));
+        $count = M('Notice')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $noticeList = M('Notice')->where($condition)->field()->order('notice_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        foreach($noticeList as $k=>$v){
+			$tmp=json_decode($v['extra'],1);
+			$wc_id=$tmp['wc_id'];
+			$checkinfo = M('words_check')->where(array('wc_id'=>$wc_id))->field('*')->find();
+			if($v['notice_flag']==5){
+				if($checkinfo['wc_status']==0){
+					$noticeList[$k]['status_info']='未处理';
+				}elseif($checkinfo['wc_status']==1){
+					$noticeList[$k]['status_info']='已通过';
+				}else{
+					$noticeList[$k]['status_info']='未通过';
+				}
+			}else{
+				$noticeList[$k]['status_info']='';
+			}
+			$noticeList[$k]['wc_info']=$checkinfo;
+			if($v['notice_read']==0){
+				$c=session('alarm');
+				$c--;
+				session('alarm',$c);
+				M('Notice')->where(array('notice_id'=>$v['notice_id']))->save(array('notice_read'=>1));
+			}
+		}
+		
+		$this->assign('page',$show);
+        $this->assign('list',$noticeList);
+        $this->display();
+    }
+    
+    public function refuse(){
+		$noticeId = I('notice_id','');
+		$this->assign('notice_id',$noticeId);
+        $this->display();
+	}
+	public function info(){
+		$noticeId = I('notice_id','');
+		$wordsKeys = array('n'=>'words_n','pron'=>'words_pron','adj'=>'words_adj','num'=>'words_num','v'=>'words_v','adv'=>'words_adv','art'=>'words_art',
+            'prep'=>'words_prep','conj'=>'words_conj','int'=>'words_int','vt'=>'words_vt','vi'=>'words_vi','other'=>'words_other',);
+        
+		if (empty($noticeId)){
+            $this->error("通知消息ID错误",'/admin/alarm/index');
+        }
+		$info = M('Notice')->where(array('notice_id'=>$noticeId))->find();
+		$tmp=json_decode($info['extra'],1);
+		$wc_id=$tmp['wc_id'];
+		$checkinfo = M('words_check')->where(array('wc_id'=>$wc_id))->field('*')->find();
+		if(!$checkinfo){
+			$this->error("审核信息错误",'/admin/alarm/index');
+		}
+		
+		$info = json_decode($checkinfo['wc_json'],1);
+		
+		$where=array();
+		$where['course_id']=$checkinfo['course_id'];
+		$where['words_id']=$checkinfo['words_id'];
+		
+        $info2 = M('Words')->where($where)->field('*')->find();
+		if(!$info2){
+			$this->error("原课程单词信息获取失败",'/admin/alarm/index');
+		}
+		$dif=array();
+		foreach($info as $k=>$v){
+			if(in_array($k,array('id','words_voice1','words_voice2')))continue;
+			if($v!=$info2[$k]){
+				$dif[]=$k;
+			}
+		}
+	
+		if($info['words_img']){
+				$arr=explode(',',$info['words_img']);
+				$info['words_img1']=$arr[0];
+				$info['words_img2']=$arr[1];
+				$info['words_img3']=$arr[2];
+		}
+        $this->assign('info',$info);
+		$this->assign('dif',$dif);
+		$this->assign('notice_id',$noticeId);
+		$this->assign('wordsKeys', $wordsKeys);
+		$this->assign('status', $checkinfo['wc_status']);
+		$this->assign('wc_content', $checkinfo['wc_content']);
+		
+		$this->display();
+	}
+    public function check(){
+        $noticeId = I('notice_id','');
+		$wc_status= I('wc_status','');
+		$wc_content = I('wc_content','');
+        if (empty($noticeId)){
+            $this->error("通知消息ID错误",'/admin/alarm/index');
+        }
+		$info = M('Notice')->where(array('notice_id'=>$noticeId))->find();
+		$tmp=json_decode($info['extra'],1);
+		$wc_id=$tmp['wc_id'];
+		$checkinfo = M('words_check')->where(array('wc_id'=>$wc_id))->field('*')->find();
+		M('words_check')->where(array('wc_id'=>$wc_id))->save(array('wc_status'=>$wc_status,'wc_content'=>$wc_content));
+        $saveData=json_decode($checkinfo['wc_json'],1);
+		$courseInfo = M('Course')->where(array('course_id'=>$saveData['course_id'],'is_delete'=>1))->field('course_id,user_id,course_name,course_num,course_status,course_source')->find();
+    
+		if($wc_status==1){
+			if($checkinfo['words_id']){
+				M('Words')->where(array('words_id'=>$checkinfo['words_id']))->save($saveData);
+			}
+			$Content="亲爱的小主,您提交的关于课程《".$courseInfo['course_name']."》的修改,作者已同意修改,并已更新课程内容";
+			$temp=array();
+			$temp['wc_id']=$checkinfo['wc_id'];
+			M('Notice')->add(array('ref_user_id'=>$checkinfo['user_id'],'user_id'=>$this->userId,'notice_flag'=>6,'notice_status'=>1,'notice_type'=>0,'notice_title'=>'课程修改审核通过','notice_content'=>$Content,'operate_dt'=>time(),'extra'=>json_encode($temp)));
+			M('User')->where(array('user_id'=>$checkinfo['user_id']))->setInc('sys_notice');
+			$data = json_encode(array('type'=>0,'msg'=>$Content,'data'=>array('title'=>"课程修改审核通过",'wc_id'=>$checkinfo['wc_id'],'course_id'=>$saveData['course_id'],'words_id'=>$saveData['words_id'],'content'=>$Content)));
+			
+		}else{
+			$Content="亲爱的小主,您提交的关于课程《".$courseInfo['course_name']."》的修改,作者拒绝修改,拒绝原因:".$wc_content;
+			$temp=array();
+			$temp['wc_id']=$checkinfo['wc_id'];
+			M('Notice')->add(array('ref_user_id'=>$checkinfo['user_id'],'user_id'=>$this->userId,'notice_flag'=>7,'notice_status'=>1,'notice_type'=>0,'notice_title'=>'课程修改审核不通过','notice_content'=>$Content,'operate_dt'=>time(),'extra'=>json_encode($temp)));
+			M('User')->where(array('user_id'=>$checkinfo['user_id']))->setInc('sys_notice');
+			$data = json_encode(array('type'=>0,'msg'=>$Content,'data'=>array('title'=>"课程修改审核不通过",'wc_id'=>$checkinfo['wc_id'],'course_id'=>$saveData['course_id'],'words_id'=>$saveData['words_id'],'content'=>$Content)));	
+		}
+		$uid=$checkinfo['user_id'];
+		$url="http://www.hanlinyuanonline.com/api/choice/push?uid=".$uid."&data=".urlencode(base64_encode(json_encode($data)));
+		$ch = curl_init(); 
+		curl_setopt($ch, CURLOPT_URL, $url); 
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
+		$output = curl_exec($ch); 
+		curl_close($ch); 
+        $this->success('消息处理成功','/admin/alarm/index');
+    }
+}

File diff suppressed because it is too large
+ 168 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/ChoiceController.class.php


File diff suppressed because it is too large
+ 266 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/CourseController.class.php


+ 80 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/CoursetypeController.class.php

@@ -0,0 +1,80 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class CoursetypeController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    //课程类型列表
+    public function index(){
+        $page = I('get.p','1');
+        session('page',$page);
+        $res = M('CourseType')->select();
+        foreach ($res as $r){
+            $typeNum = M('Course')->where(array('course_type'=>$r['type_id']))->count();
+            M('CourseType')->where(array('type_id'=>$r['type_id']))->save(array('type_num'=>$typeNum));
+        }
+        $count = M('CourseType')->where(array('is_delete'=>1))->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $typeList = M('CourseType')->where(array('is_delete'=>1))->field()->order('type_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$typeList);
+        $this->display();
+    }
+    //课程类型编辑
+    public function edit(){
+        $step = I('step','');
+        $typeId = I('type_id','');
+        if (empty($step)){
+            $info = array();
+            if (!empty($typeId)){
+                $info = M('CourseType')->where(array('type_id'=>$typeId))->find();
+            }
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $typeName = I('type_name','');
+            if (mb_strlen($typeName,'UTF8')<2 || mb_strlen($typeName,'UTF8')>12){
+                $this->error('课程类型名称2到12个汉字');
+            }
+            $res = M('CourseType')->where(array('type_name'=>$typeName,'is_delete'=>1))->find();
+            if ($res!=NULL){
+                $this->error('课程类型名称已经存在');
+            }
+            if ($typeId){
+                M('CourseType')->where(array('type_id'=>$typeId))->save(array('type_name'=>$typeName));
+            }else{
+                M('CourseType')->add(array('type_name'=>$typeName,'operate_dt'=>time()));
+            }
+            $this->success('课程类型操作成功','/admin/coursetype/index');
+        }
+    }
+    //删除
+    public function del(){
+        $typeId = I('type_id','');
+        if (!$typeId){
+            $this->error('课程类型ID错误');
+        }
+        //M('CourseType')->where(array('type_id'=>$typeId))->save(array('is_delete'=>2));
+        M('CourseType')->where(array('type_id'=>$typeId))->delete();
+        $this->success('课程类型操作成功','/admin/coursetype/index');
+    }
+    //分类下课程列表
+    public function course(){
+        $typeId = I('type_id','');
+        if (!$typeId){
+            $this->error('课程类型ID错误');
+        }
+        $condition = array('is_delete'=>1,'course_type'=>$typeId,'course_source'=>1);
+        $count = M('Course')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $courseList = M('Course')->where($condition)->field()->order('course_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$courseList);
+        $this->display('User/course');
+    }
+}

+ 51 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/FeedbackController.class.php

@@ -0,0 +1,51 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class FeedbackController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    public function index(){
+        $fbStatus = I('fb_status');
+        if (empty($fbStatus)){
+            $count = M('Feedback')->where(array('is_delete'=>1,'fb_source'=>1))->count();
+        }else{
+            $count = M('Feedback')->where(array('is_delete'=>1,'fb_source'=>1,'fb_status'=>$fbStatus,))->count();
+        }
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        if (empty($fbStatus)){
+            $fbList = D('Feedback')->getFbList(array('fb_source'=>1),$Page->firstRow, $Page->listRows);
+        }else{
+            $fbList = D('Feedback')->getFbList(array('fb_source'=>1,'fb_status'=>$fbStatus,),$Page->firstRow, $Page->listRows);
+        }
+        $this->assign('page',$show);
+        $this->assign('list',$fbList);
+        $this->assign('fbStatus',$fbStatus);
+        $this->display();
+    }
+    
+    public function sys(){
+        $page = I('get.p','1');
+        session('page',$page);
+        $count = M('Feedback')->where(array('is_delete'=>1,'fb_source'=>2))->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $fbList = D('Feedback')->getFbSysList(array('fb_source'=>2),$Page->firstRow, $Page->listRows);
+        
+        $this->assign('page',$show);
+        $this->assign('list',$fbList);
+        $this->display();
+    }
+    
+    public function status(){
+        $fbId = I('fb_id','');
+        if (empty($fbId)){
+            $this->error("反馈ID错误",'/admin/feedback/index');
+        }
+        M('Feedback')->where(array('fb_id'=>$fbId))->save(array('fb_status'=>2));
+        $this->success('反馈状态修改成功','/admin/feedback/index');
+    }
+}

+ 122 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/GoodController.class.php

@@ -0,0 +1,122 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class GoodController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    public function index(){
+        $sort = I('sort','1');
+        $orderList = array(
+            1=>array('good_id desc','时间倒序',1),
+            2=>array('good_id asc','时间正序',2),
+            3=>array('course_join desc','加入量倒序',3),
+            4=>array('course_join asc','加入量正序',4),
+            5=>array('course_join desc','排序id倒序',5),
+            6=>array('course_join asc','排序id正序',6),
+        );
+        $orderby = $orderList[$sort][0];
+        $condition = array('course_flag'=>1);
+        $count = M('GoodCourse')->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $field = 'gc.*,c.course_name,c.course_num,c.course_join,u.user_name';
+        $join = 'gc LEFT JOIN t_course c ON gc.course_id=c.course_id LEFT JOIN t_user u ON c.user_id=u.user_id';
+        $res = M('GoodCourse')->join($join)->where($condition)->field($field)->order($orderby)->limit($Page->firstRow.','.$Page->listRows)->select();
+
+        $resShow = M('GoodCourseShow')->find();
+        
+        $this->assign('page',$show);
+        $this->assign('list',$res);
+        $this->assign('sort',$sort);
+        $this->assign('orderby',$orderby);
+        $this->assign('resShow',$resShow);
+        $this->assign('orderList',$orderList);
+        $this->display();
+    }
+    
+    public function add(){
+        $step = I('step');
+        if (empty($step)){
+            $sort = I('sort','1');
+            $orderList = array(
+                1=>array('good_id desc','时间倒序',1),
+                2=>array('good_id asc','时间正序',2),
+                3=>array('course_join desc','加入量倒序',3),
+                4=>array('course_join asc','加入量正序',4),
+                5=>array('course_join desc','排序id倒序',5),
+                6=>array('course_join asc','排序id正序',6),
+            );
+            $orderby = $orderList[$sort][0];
+            $condition = array('course_flag'=>1,'course_status'=>3);
+            $count = M('GoodCourse')->count();
+            //分页
+            $Page = new \Think\Page($count);
+            $show = $Page->show();
+            $field = 'gc.good_id,c.course_id,c.course_name,c.course_num,c.course_join,u.user_name';
+            $join = 'c LEFT JOIN t_good_course gc ON gc.course_id=c.course_id LEFT JOIN t_user u ON c.user_id=u.user_id';
+            $res = M('Course')->join($join)->where($condition)->field($field)->order($orderby)->limit($Page->firstRow.','.$Page->listRows)->select();
+            
+            //echo D('Course')->getLastSql();exit;
+            $this->assign('page',$show);
+            $this->assign('list',$res);
+            $this->assign('sort',$sort);
+            $this->assign('orderby',$orderby);
+            $this->assign('orderList',$orderList);
+            $this->display();
+        }else if($step==2){
+            $courseIdArr = I('course_id');
+            if (empty($courseIdArr)){
+                $this->error('请选择需要添加的课程');
+            }
+            foreach ($courseIdArr as $courseId){
+                $dataList[] = array('course_id'=>$courseId,'operate_dt'=>time());
+            }
+            M('GoodCourse')->addAll($dataList);
+            $this->success('添加成功');
+        }
+    }
+    
+    public function del(){
+        $goodId = I('good_id');
+        if (empty($goodId)){
+            $this->error('请选择需要删除的课程');
+        }
+        M('GoodCourse')->where(array('good_id'=>$goodId))->delete();
+        $this->success('删除成功');
+    }
+    
+    public function edit(){
+        $step = I('step');
+        $goodId = I('good_id');
+        if (empty($step)){
+            if (empty($goodId)){
+                $this->error('请选择需要删除的课程');
+            }
+            $info = M('GoodCourse')->where(array('good_id'=>$goodId))->find();
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $goodSort = I('good_sort');
+            $courseInfo = I('course_info');
+            if ($goodSort<=0){
+                $this->error('排序id错误');
+            }
+            if (!empty($courseInfo)){
+                if (mb_strlen($courseInfo,'UTF8')<2 || mb_strlen($courseInfo,'UTF8')>140){
+                    $this->error('介绍说明2到140个汉字');
+                }
+            }
+            M('GoodCourse')->where(array('good_id'=>$goodId))->save(array('good_sort'=>$goodSort,'course_info'=>$courseInfo,));
+            $this->success('编辑成功','/admin/good/index');
+        }
+    }
+    
+    public function status(){
+        $goodShow = I('good_show');
+        M('GoodCourseShow')->where(array('show_id'=>1))->save(array('good_show'=>$goodShow));
+        $this->success('推送设置成功','/admin/good/index');
+    }
+}

+ 108 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/IndexController.class.php

@@ -0,0 +1,108 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class IndexController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    public function index() {
+		
+		
+        $flag = I('flag',1);
+        $dayType = I('day_type',3);
+        $startDate = I('start_date');
+        $endDate = I('end_date');
+        $dayList = array(
+            1=>array('startDate'=>date('Y-m-d'),'endDate'=>date('Y-m-d',strtotime('+1 day'))),
+            2=>array('startDate'=>date('Y-m-d',strtotime('-1 day')),'endDate'=>date('Y-m-d')),
+            3=>array('startDate'=>date('Y-m-d',strtotime('-7 day')),'endDate'=>date('Y-m-d')),
+            4=>array('startDate'=>date('Y-m-d',strtotime('-30 day')),'endDate'=>date('Y-m-d')),
+        );
+        if (empty($startDate)||empty($endDate)){
+            $startDate = $dayList[$dayType]['startDate'];
+            $endDate = $dayList[$dayType]['endDate'];
+        }
+        if ($flag==1){
+            $startDate = $dayList[$dayType]['startDate'];
+            $endDate = $dayList[$dayType]['endDate'];
+        }
+        
+        $startTime = strtotime($startDate);
+        $endTime = strtotime($endDate);
+        if ($endTime<2){
+            $this->error('结束时间错误');
+        }
+        //统计全部
+        $info = M('Sta')->field('sum(sta_reg) reg,sum(sta_normal) normal,sum(sta_rank) rank,sum(sta_pve) pve')->find();
+        //分天统计
+        $condition = array('operate_dt'=>array('BETWEEN',array($startTime,$endTime+1)));
+        $staRes = M('Sta')->where($condition)->field('sta_reg, sta_normal, sta_rank, sta_pve, operate_dt')->select();
+        foreach ($staRes as $row){
+            $staList[$row['operate_dt']] = array('reg'=>$row['sta_reg'], 'normal'=>$row['sta_normal'], 'rank'=>$row['sta_rank'], 'pve'=>$row['sta_pve']);
+        }
+        $xAxis = '';
+        $yAxisReg = '';
+        $yAxisPve = '';
+        $yAxisRank = '';
+        $yAxisNormal = '';
+        for($i=$startTime;$i<=$endTime;$i=$i+86400){
+            $xAxis .= "'".date('md',$i)."',";
+            if (isset($staList[$i])){
+                $yAxisPve .= $staList[$i]['pve'].',';
+                $yAxisReg .= $staList[$i]['reg'].',';
+                $yAxisRank .= $staList[$i]['rank'].',';
+                $yAxisNormal .= $staList[$i]['normal'].',';
+            }else{
+                $yAxisPve .= '0,';
+                $yAxisReg .= '0,';
+                $yAxisRank .= '0,';
+                $yAxisNormal .= '0,';
+            }
+        }
+        $xAxis = substr($xAxis, 0, -1);
+        $yAxisPve = substr($yAxisPve, 0, -1);
+        $yAxisReg = substr($yAxisReg, 0, -1);
+        $yAxisRank = substr($yAxisRank, 0, -1);
+        $yAxisNormal = substr($yAxisNormal, 0, -1);
+        $this->assign('info',$info);
+        $this->assign('xAxis', $xAxis);
+        $this->assign('yAxisPve',$yAxisPve);
+        $this->assign('yAxisReg', $yAxisReg);
+        $this->assign('yAxisRank', $yAxisRank);
+        $this->assign('yAxisNormal', $yAxisNormal);
+        $this->assign('dayType', $dayType);
+        $this->assign('endDate',$endDate);
+        $this->assign('startDate',$startDate);
+        $this->display();
+    }
+    
+    public function pwd(){
+        $step = I('step','');
+        $adminId = session('admin_id');
+        $info = M('Admin')->where(array('admin_id'=>$adminId))->field('admin_account,admin_pwd')->find();
+        if (empty($step)){
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $oldPwd = I('old_pwd');
+            $newPwd = I('new_pwd');
+            $newRepwd = I('new_repwd');
+            if (mb_strlen($oldPwd,'UTF8')<6 || mb_strlen($oldPwd,'UTF8')>20){
+                $this->error('旧密码长度6到20之间');
+            }
+            if (mb_strlen($newPwd,'UTF8')<6 || mb_strlen($newPwd,'UTF8')>20){
+                $this->error('新密码长度6到20之间');
+            }
+            if ($newPwd!==$newRepwd){
+                $this->error('两次输入的新密码不一致,请重新输入');
+            }
+            if ($info!=NULL && $info['admin_pwd']!=md5($info['admin_pwd'])){
+                $this->error('输入的原密码有误,请重新输入');
+            }
+            M('Admin')->where(array('admin_id'=>$adminId))->save(array('admin_pwd'=>md5($newPwd)));
+            $this->success('修改密码成功','/admin/index/index');
+        }
+    }
+    
+
+}

+ 69 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/LoginController.class.php

@@ -0,0 +1,69 @@
+<?php
+namespace Admin\Controller;
+use Think\Controller;
+class LoginController extends Controller {
+    public function index(){
+        $step = I('post.step','');
+        if (empty($step)){
+            $this->display();
+        }else if($step==2){
+            $admin_account = I('post.admin_account','');
+            $admin_pwd = I('post.admin_pwd','');
+            $admin_code = I('post.admin_code','');
+            if ($this->checkVerify($admin_code)=== false){
+                $this->error("验证码错误",'/admin/login/index');
+            }
+            $adminInfo = M('Admin')->where("admin_account='".$admin_account."'")->find();
+            if ($adminInfo==NULL || $adminInfo['admin_pwd']!=md5($admin_pwd)){
+				$info = M('User')->where(array('user_phone'=>$admin_account))->field('user_id,user_phone,user_intro,user_pwd,user_name,user_level,user_sex,user_icon,zan_notice,friend_notice,sys_notice,user_city,user_province,user_birthdate,user_score,access_token,operate_dt,unionid,fbid,imei')->find();
+				if ($info==NULL){
+					$this->error("用户名或密码错误",'/admin/login/index');
+				}
+				if ($info['user_pwd']!=md5($admin_pwd)){
+					$this->error("用户名或密码错误",'/admin/login/index');
+				}
+				$adminInfo = M('Admin')->where("admin_id='".$info['admin_id']."'")->find();
+				if(!$adminInfo){
+					$this->error("登陆异常",'/admin/login/index');
+				}
+                
+            }
+			$condition=array('notice_flag'=>array('IN','5,6,7'),'notice_read'=>0);
+			$count = M('notice')->where($condition)->count();
+			session('alarm',$count);
+			session('admin_id',$adminInfo['admin_id']);
+			session('admin_account',$adminInfo['admin_account']);
+			session('group_id',$adminInfo['group_id']);
+			if($adminInfo['admin_id']!=1){
+				$this->success("登录成功",'/admin/course/index');
+			}else{
+				$this->success("登录成功",'/admin/index/index');
+			}
+			
+        }
+    }
+    
+    public function logout(){
+        session(null);
+        $this->error("退出成功",'/admin/login/index');
+    }
+    /**
+     * 验证码
+     */
+    public function code(){
+        $config =  C('VERIFY_CODE');
+        $Verify =     new \Think\Verify($config);
+        // 设置验证码字符为纯数字
+        //$Verify->codeSet = '0123456789';
+        // 开启验证码背景图片功能
+        $Verify->useImgBg = true;
+        //verify_code
+        $Verify->entry();
+    }
+    
+    // 检测输入的验证码是否正确,$code为用户输入的验证码字符串
+    private function checkVerify($code, $id = ''){
+        $verify = new \Think\Verify();
+        return $verify->check($code, $id);
+    }
+}

+ 64 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/ManagerController.class.php

@@ -0,0 +1,64 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class ManagerController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    public function index(){
+        $keyword = I('get.keyword','');
+        $condition = array();
+        if (!empty($keyword)){
+            $condition['admin_account'] = array('LIKE','%'.$keyword.'%');
+            $this->assign('keyword',$keyword);
+        }
+        $count = M('Admin')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $userList = M('Admin')->where($condition)->field()->order('admin_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$userList);
+        $this->display();
+    }
+    
+    public function edit(){
+        $step = I('step','');
+        if (empty($step)){
+            $this->display();
+        }else if($step==2){
+            $adminAccount = I('admin_account');
+            $newPwd = I('new_pwd');
+            $newRepwd = I('new_repwd');
+            $groupId = I('group_id');
+            if (mb_strlen($adminAccount,'UTF8')<6 || mb_strlen($adminAccount,'UTF8')>20){
+                $this->error('用户名长度6到20之间');
+            }
+            if (mb_strlen($newPwd,'UTF8')<6 || mb_strlen($newPwd,'UTF8')>20){
+                $this->error('新密码长度6到20之间');
+            }
+            if ($newPwd!==$newRepwd){
+                $this->error('两次输入的新密码不一致,请重新输入');
+            }
+            $info = M('Admin')->where(array('admin_account'=>$adminAccount))->field('admin_id')->find();
+            if ($info!=NULL){
+                $this->error('用户名已经存在');
+            }
+            $saveData = array(
+                'admin_account'=>$adminAccount,
+                'admin_pwd'=>md5($newPwd),
+                'group_id'=>$groupId,
+                'operate_dt'=>time(),
+            );
+            M('Admin')->add($saveData);
+            $this->success('创建账号成功','/admin/manager/index');
+        }
+    }
+    
+    public function del(){
+        $adminId = I('admin_id');
+        M('Admin')->where(array('admin_id'=>$adminId))->delete();
+        $this->success('删除成功','/admin/manager/index');
+    }
+}

+ 118 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/NotepadController.class.php

@@ -0,0 +1,118 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class NotepadController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    //自由记列表
+    public function index(){
+        $sort = I('sort','1');
+        $courseStatus = I('course_status','');
+        $keyword = I('get.keyword','');
+        $condition = array('is_delete'=>1,'course_flag'=>2,'course_source'=>1);
+        $orderList = array(
+            1=>array('operate_dt desc','时间倒序',1),
+            2=>array('operate_dt asc','时间正序',2),
+            3=>array('course_join desc','加入量倒序',3),
+            4=>array('course_join asc','加入量倒序',4),
+        );
+        $statusList = array('全部状态','未上架',3=>'已上架');
+        $orderby = $orderList[$sort][0];
+        if (!empty($keyword)){
+            $condition['course_id|course_name'] = array('LIKE','%'.$keyword.'%');
+        }
+        if (!empty($courseStatus)){
+            $condition['course_status'] = $courseStatus;
+        }
+        $this->assign('sort',$sort);
+        $this->assign('orderby',$orderby);
+        $this->assign('keyword',$keyword);
+        $this->assign('orderList',$orderList);
+        $this->assign('statusList',$statusList);
+        $this->assign('courseStatus',$courseStatus);
+        
+        $count = M('Course')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $courseList = M('Course')->where($condition)->field()->order($orderby)->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$courseList);
+        $this->display();
+    }
+    
+    //编辑自由记
+    public function edit(){
+        $step = I('step','');
+        $courseId = I('course_id','');
+        if (empty($step)){
+            $info = array();
+            if (!empty($courseId)){
+                $info = M('Course')->where(array('course_id'=>$courseId))->find();
+            }
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $courseName = I('course_name','');
+            $courseContent = I('course_content','');
+            if (mb_strlen($courseName,'UTF8')<2 || mb_strlen($courseName,'UTF8')>40){
+                $this->error('自由记名称2到40个汉字');
+            }
+            if (mb_strlen($courseContent,'UTF8')<2 || mb_strlen($courseContent,'UTF8')>10000){
+                $this->error('自由记名称2到10000个汉字');
+            }
+            
+            $res = M('Course')->where(array('course_name'=>$courseName,'is_delete'=>1))->field('course_id')->find();
+            //新增
+            if (empty($courseId) && $res!=NULL){
+                $courseName = $this->getNotepadName($courseName);
+            }
+            //更新
+            if (!empty($courseId) && $courseId!=$res['course_id']){
+                $courseName = $this->getNotepadName($courseName);
+            }
+            if (empty($courseId)){
+                M('Course')->add(array('course_content'=>$courseContent,'course_name'=>$courseName,'course_source'=>1,'course_flag'=>2,'operate_dt'=>time()));
+            }else{
+                M('Course')->where(array('course_id'=>$courseId))->save(array('course_content'=>$courseContent,'course_name'=>$courseName));
+            }
+            $this->success('自由记操作成功','/admin/notepad/index');
+        }
+    }
+    
+    //获取课程名称相同时,新的课程名称
+    private function getNotepadName($courseName){
+        $course = M('Course')->where(array('course_name'=>$courseName,'is_delete'=>1))->field('course_id')->find();
+        $res = M('TitleNum')->where(array('title_name'=>$courseName,'title_source'=>2))->field('title_id,title_num')->find();
+        if ($res!=NULL){
+            $courseName = $courseName.'('.($res['title_num']+1).')';
+            M('TitleNum')->where(array('title_id'=>$res['title_id']))->setInc('title_num');
+        }else if($course!=NULL){
+            $courseName = $courseName.'('.($res['title_num']+1).')';
+            M('TitleNum')->add(array('title_name'=>$courseName,'operate_dt'=>time()));
+            //$courseName = $courseName;
+        }
+        return $courseName;
+    }
+    
+    public function del(){
+        $courseId = I('course_id','');
+        if (empty($courseId)){
+            $this->error("自由记ID错误",'/admin/notepad/index');
+        }
+        //M('Course')->where(array('course_id'=>$courseId))->save(array('is_delete'=>2));
+        M('Course')->where(array('course_id'=>$courseId))->delete();
+        $this->success('自由记删除成功','/admin/notepad/index');
+    }
+    
+    public function status(){
+        $courseId = I('course_id','');
+        $courseStatus = I('course_status','');
+        if (empty($courseId)){
+            $this->error("自由记ID错误",'/admin/notepad/index');
+        }
+        M('Course')->where(array('course_id'=>$courseId))->save(array('course_status'=>$courseStatus));
+        $this->success('自由记状态修改成功','/admin/notepad/index');
+    }
+}

+ 87 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/NoticeController.class.php

@@ -0,0 +1,87 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class NoticeController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    public function index(){
+        $page = I('get.p','1');
+        session('page',$page);
+        $condition = array('is_delete'=>1,'user_id'=>0);
+        $count = M('Notice')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $noticeList = M('Notice')->where($condition)->field()->order('notice_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$noticeList);
+        $this->display();
+    }
+    
+    public function edit(){
+        $step = I('step','');
+        $noticeId = I('notice_id','');
+        if (empty($step)){
+            $info = array();
+            if (!empty($noticeId)){
+                $info = M('Notice')->where(array('notice_id'=>$noticeId))->find();
+            }
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $userIdArr = array();
+            $userType = I('user_type','');
+            $refUserId = I('ref_user_id','');
+            $refUserId = str_replace(',', ',', $refUserId);
+            $refUserId = trim($refUserId,',');
+            if ($userType==2){
+                if (empty($refUserId)){
+                    $this->error('用户id不能为空');
+                }
+                $userIdArr = explode(',', $refUserId);
+                $userInfo = M('User')->where(array('user_id'=>array('IN',$userIdArr)))->field('user_id')->select();
+                if (function_exists('array_column')){
+                    $userIdDbArr = array_column($userInfo, 'user_id');
+                }else{
+                    foreach ($userInfo as $r){
+                        $userIdDbArr[] = $r['user_id'];
+                    }
+                }
+                if (count($userIdArr)!=count($userIdDbArr)){
+                    $userIdDiff = array_diff($userIdArr, $userIdDbArr);
+                    $userIdDiffStr = implode(',', $userIdDiff);
+                    $this->error('您输入的“'.$userIdDiffStr.'”未找到相关用户id信息,请仔细核实后提交。');
+                }
+            }
+            $noticeContent = I('notice_content','');
+            if (mb_strlen($noticeContent,'UTF8')<2 || mb_strlen($noticeContent,'UTF8')>500){
+                $this->error('通知消息2到500个汉字');
+            }
+            
+            if (empty($noticeId)){
+                if ($userType==2){
+                    M('Notice')->add(array('notice_content'=>$noticeContent,'notice_title'=>'系统消息','ref_user_id'=>$refUserId,'user_id'=>0,'operate_dt'=>time()));
+                    M('User')->where(array('user_id'=>array('IN',$userIdArr),'is_delete'=>1))->setInc('sys_notice');
+                }else{
+                    M('Notice')->add(array('notice_content'=>$noticeContent,'notice_title'=>'系统消息','user_id'=>0,'operate_dt'=>time()));
+                    M('User')->where(array('is_delete'=>1))->setInc('sys_notice');
+                }
+            }else{
+                M('Notice')->where(array('notice_id'=>$noticeId))->save(array('notice_content'=>$noticeContent));
+            }
+            $this->success('通知消息操作成功','/admin/notice/index');
+        }
+    }
+    
+    public function del(){
+        $noticeId = I('notice_id','');
+        if (empty($noticeId)){
+            $this->error("通知消息ID错误",'/admin/notice/index');
+        }
+        //M('Notice')->where(array('notice_id'=>$noticeId))->save(array('is_delete'=>2));
+        M('Notice')->where(array('notice_id'=>$noticeId))->delete();
+        $this->success('通知消息删除成功','/admin/notice/index');
+    }
+}

+ 74 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/SliderController.class.php

@@ -0,0 +1,74 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class SliderController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    public function index(){
+        $count = M('Slider')->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $list = M('Slider')->order('slider_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$list);
+        $this->display();
+    }
+    
+    public function edit(){
+        $step = I('step','');
+        $sliderId = I('slider_id','');
+        if (empty($step)){
+            $info = array();
+            if (!empty($sliderId)){
+                $info = M('Slider')->where(array('slider_id'=>$sliderId))->find();
+            }
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $saveData =[
+                'link_url'=>I('link_url',''),
+                'slider_sort'=>I('slider_sort','0'),
+                'slider_pic'=>I('slider_pic',''),
+            ] ;
+            if (empty($saveData['slider_pic'])){
+                $this->error('Banner图片不能为空');
+            }
+            if ($sliderId){
+                M('Slider')->where(array('slider_id'=>$sliderId))->save($saveData);
+            }else{
+                $saveData['operate_dt'] = time();
+                M('Slider')->add($saveData);
+            }
+            $this->success('操作成功','/admin/slider/index');
+        }
+    }
+    
+    //删除
+    public function del(){
+        $sliderId = I('slider_id','');
+        M('Slider')->where(array('slider_id'=>$sliderId))->delete();
+        $this->success('操作成功','/admin/slider/index');
+    }
+    
+    public function upload(){
+        $upload = new \Think\Upload();// 实例化上传类
+        $upload->maxSize = 10485760;// 设置附件上传大小
+        $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
+        $upload->rootPath = './Uploads/'; // 设置附件上传根目录
+        $upload->savePath = ''; // 设置附件上传(子)目录
+        // 上传文件
+        $info = $upload->upload();
+        if (!$info) {// 上传错误提示错误信息
+            //$this->error($upload->getError());
+            $this->ajaxReturn(['code' => 1, 'msg' => $upload->getError()]);
+        } else {// 上传成功 获取上传文件信息
+            $file = array_pop($info);
+            $filePath = C('WEB_HOST').'/Uploads/'.$file['savepath'].$file['savename'];
+            $this->ajaxReturn(['code' => 0, 'info' => '', 'path' => $filePath]);
+        }
+        
+    }
+}

+ 58 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/SoftController.class.php

@@ -0,0 +1,58 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class SoftController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    public function index(){
+        $os  = I('os');
+        $condition = array();
+        if (!empty($os)){
+            $condition['os'] = $os;
+        }
+        $count = M('Soft')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $softList = M('Soft')->where($condition)->field()->order('soft_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$softList);
+        $this->display();
+    }
+    
+    public function edit(){
+        $step = I('step','');
+        $softId = I('soft_id','');
+        if (empty($step)){
+            $info = array();
+            if (!empty($softId)){
+                $info = M('Soft')->where(array('soft_id'=>$softId))->find();
+            }
+            $this->assign('info',$info);
+            $this->display();
+        }else if($step==2){
+            $data['os'] = I('os');
+            $data['force_up'] = I('force_up');
+            $data['new_ver'] = I('new_ver');
+            $data['up_info'] = I('up_info');
+            $data['url'] = I('app_url');
+            if (empty($data['up_info'])){
+                $this->error('更新内容不能为空');
+            }
+            if (empty($data['url'])){
+                $this->error('app链接不能为空');
+            }
+            if (empty($softId)){
+                $data['operate_dt'] = time();
+                M('Soft')->add($data);
+            }else{
+                M('Soft')->where(array('soft_id'=>$softId))->save($data);
+            }
+            $this->success('APP操作成功','/admin/soft/index');
+        }
+    }
+    
+    
+}

+ 214 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/SquareController.class.php

@@ -0,0 +1,214 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class SquareController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    public function course(){
+        $sort = I('sort','1');
+        $courseStatus = I('course_status','');
+        $keyword = I('get.keyword','');
+        $condition = array('course_flag'=>1);
+        $orderList = array(
+            1=>array('operate_dt desc','时间倒序',1),
+            2=>array('operate_dt asc','时间正序',2),
+            3=>array('course_join desc','加入量倒序',3),
+            4=>array('course_join asc','加入量倒序',4),
+        );
+        $statusList = array('全部状态',2=>'待审核',3=>'已上架',4=>'审核不通过');
+        $orderby = $orderList[$sort][0];
+        if (!empty($keyword)){
+            $condition['course_id|course_name'] = array('LIKE','%'.$keyword.'%');
+        }
+        if (!empty($courseStatus)){
+            $condition['course_status'] = $courseStatus;
+        }else{
+            $condition['course_status'] = array('IN','2,3,4');
+        }
+        $this->assign('sort',$sort);
+        $this->assign('orderby',$orderby);
+        $this->assign('keyword',$keyword);
+        $this->assign('orderList',$orderList);
+        $this->assign('statusList',$statusList);
+        $this->assign('courseStatus',$courseStatus);
+        $crons = $condition;
+        $crons['is_delete'] = 1;
+        $count = M('Course')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $courseList = D('Course')->getCourseList($condition,$Page->firstRow, $Page->listRows, $orderby);
+        $this->assign('page',$show);
+        $this->assign('list',$courseList);
+        $this->display();
+    }
+    
+    public function detailCourse(){
+        $courseId = I('course_id','');
+        if (empty($courseId) || $courseId<1000000){
+            $this->error("课程ID错误",'/admin/square/course');
+        }
+        $keyword = I('get.keyword','');
+        $condition = array('is_delete'=>1,'course_id'=>$courseId);
+        if (!empty($keyword)){
+            $condition['words_name'] = array('LIKE','%'.$keyword.'%');
+        }
+        $count = M('Words')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $wordsRes = M('Words')->where($condition)->field()->order('words_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $wordsList = array();
+        foreach ($wordsRes as $row){
+            $wordsList[] = array(
+                'words_id' => $row['words_id'],
+                'course_id' => $row['course_id'],
+                'words_name' => $row['words_name'],
+                'words_voice' => $row['words_voice'],
+                'words_read' => $row['words_read'],
+                'operate_dt' => $row['operate_dt'],
+                'words_text' => $this->getWordsText($row),
+            );
+        }
+        $this->assign('page',$show);
+        $this->assign('list',$wordsList);
+        $this->assign('keyword',$keyword);
+        $this->assign('courseId',$courseId);
+        $this->display('detailCourse');
+    }
+    
+    public function show(){
+        $wordsId = I('words_id','');
+        $wordsKeys = array('n'=>'words_n','pron'=>'words_pron','adj'=>'words_adj','num'=>'words_num','v'=>'words_v','adv'=>'words_adv','art'=>'words_art','prep'=>'words_prep','conj'=>'words_conj','int'=>'words_int','vt'=>'words_vt','vi'=>'words_vi',);
+        $info = array();
+        if (!empty($wordsId)){
+            $info = M('Words')->where(array('words_id'=>$wordsId))->find();
+        }
+        $this->assign('info',$info);
+        $this->assign('wordsKeys', $wordsKeys);
+        $this->display();
+    }
+    //修改课程状态
+    public function statusCourse(){
+        $courseId = I('course_id','');
+        $courseStatus = I('course_status','');
+        if (empty($courseId) || $courseId<1000000){
+            $this->error("课程ID错误",'/admin/square/course');
+        }
+        M('Course')->where(array('course_id'=>$courseId))->save(array('course_status'=>$courseStatus));
+        if ($courseStatus==3){
+            $info = M('Course')->where(array('course_id'=>$courseId))->find();
+            $noticeTitle = '上传课程审核已通过';
+            $noticeContent = '亲爱的小主,你上传至单词广场的《'.$info['course_name'].'》课程已审核通过,赶紧去单词广场查看下吧。';
+            M('Notice')->add(array('notice_title'=>$noticeTitle,'notice_content'=>$noticeContent,'ref_user_id'=>$info['user_id'],'user_id'=>0,'operate_dt'=>time()));
+            M('User')->where(array('user_id'=>$info['user_id'],'is_delete'=>1))->setInc('sys_notice');
+        }
+        $this->success('课程状态修改成功','/admin/square/course');
+    }
+    
+    //修改自由记
+    public function statusNotepad(){
+        $courseId = I('course_id','');
+        $courseStatus = I('course_status','');
+        if (empty($courseId) || $courseId<1000000){
+            $this->error("自由记ID错误",'/admin/square/notepad');
+        }
+        M('Course')->where(array('course_id'=>$courseId))->save(array('course_status'=>$courseStatus));
+        if ($courseStatus==3){
+            $info = M('Course')->where(array('course_id'=>$courseId))->find();
+            $noticeTitle = '上传自由记审核已通过';
+            $noticeContent = '亲爱的小主,你上传至单词广场的《'.$info['course_name'].'》自由记已审核通过,赶紧去单词广场查看下吧。';
+            M('Notice')->add(array('notice_title'=>$noticeTitle,'notice_content'=>$noticeContent,'ref_user_id'=>$info['user_id'],'user_id'=>0,'operate_dt'=>time()));
+            M('User')->where(array('user_id'=>$info['user_id'],'is_delete'=>1))->setInc('sys_notice');
+        }
+        $this->success('自由记状态修改成功','/admin/square/notepad');
+    }
+    
+    public function notepad(){
+        $sort = I('sort','1');
+        $courseStatus = I('course_status','');
+        $keyword = I('get.keyword','');
+        $condition = array('course_source'=>2,'couse_flag'=>2);
+        $orderList = array(
+            1=>array('operate_dt desc','时间倒序',1),
+            2=>array('operate_dt asc','时间正序',2),
+            3=>array('course_join desc','加入量倒序',3),
+            4=>array('course_join asc','加入量倒序',4),
+        );
+        $statusList = array('全部状态',2=>'待审核',3=>'已上架',4=>'审核不通过');
+        $orderby = $orderList[$sort][0];
+        if (!empty($keyword)){
+            $condition['course_id|course_name'] = array('LIKE','%'.$keyword.'%');
+        }
+        if (!empty($courseStatus)){
+            $condition['course_status'] = $courseStatus;
+        }else{
+            $condition['course_status'] = array('IN','2,3,4');
+        }
+        $this->assign('sort',$sort);
+        $this->assign('orderby',$orderby);
+        $this->assign('keyword',$keyword);
+        $this->assign('orderList',$orderList);
+        $this->assign('statusList',$statusList);
+        $this->assign('courseStatus',$courseStatus);
+
+        $crons = $condition;
+        $crons['is_delete'] = 1;
+        $count = M('Course')->where($crons)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $notepadList = D('Course')->getCourseList($condition,$Page->firstRow, $Page->listRows, $orderby);
+        $this->assign('page',$show);
+        $this->assign('list',$notepadList);
+        $this->display();
+    }
+    
+    public function detailNotepad(){
+        $courseId = I('course_id','');
+        $info = array();
+        if (!empty($courseId)){
+            $info = M('Course')->where(array('course_id'=>$courseId))->find();
+        }
+        $this->assign('info',$info);
+        $this->assign('courseId', $courseId);
+        $this->display();
+    }
+    
+    public function unpass(){
+        $step = I('step');
+        $courseId = I('course_id','');
+        if (empty($courseId) || $courseId<1000000){
+            $this->error("ID错误",$_SERVER['HTTP_REFERER']);
+        }
+        $info = M('Course')->where(array('course_id'=>$courseId))->find();
+        if (empty($step)){
+            $refererUrl = $_SERVER['HTTP_REFERER'];
+            if (empty($refererUrl)){
+                $refererUrl = '/admin/square/index';
+            }
+            $this->assign('info',$info);
+            $this->assign('courseId', $courseId);
+            $this->assign('refererUrl', $refererUrl);
+            $this->display();
+        }else if($step==2){
+            $refererUrl = I('refererUrl');
+            $courseReason = I('course_reason');
+            if (mb_strlen($courseReason,'UTF8')<3 || mb_strlen($courseReason,'UTF8')>50){
+                $this->error('未通过原因3到50个汉字');
+            }
+            M('Course')->where(array('course_id'=>$courseId))->save(array('course_reason'=>$courseReason,'course_status'=>4));
+            if ($info['course_flag']==1){
+                $noticeTitle = '上传课程审核不通过';
+                $noticeContent = '亲爱的小主,你上传至单词广场的《'.$info['course_name'].'》课程审核不通过,原因为:'.$courseReason.'。请修改后再重新上传。';
+            }else{
+                $noticeTitle = '上传自由记审核不通过';
+                $noticeContent = '亲爱的小主,你上传至单词广场的《'.$info['course_name'].'》自由记审核不通过,原因为:'.$courseReason.'。请修改后再重新上传。';
+            }
+            M('Notice')->add(array('notice_title'=>$noticeTitle,'notice_content'=>$noticeContent,'ref_user_id'=>$info['user_id'],'user_id'=>0,'operate_dt'=>time()));
+            M('User')->where(array('user_id'=>$info['user_id'],'is_delete'=>1))->setInc('sys_notice');
+            $this->success('审核未通过成功',$refererUrl);
+        }
+    }
+}

+ 171 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/StoreController.class.php

@@ -0,0 +1,171 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class StoreController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    //题库列表
+    public function index(){
+        $condition = array('is_delete'=>1);
+        //课程类型
+        $levelRes = M('UserLevel')->where(array('is_delete'=>1))->field('level_id,level_name')->select();
+        $levelList = array();
+        foreach ($levelRes as $type){
+            $levelList[$type['level_id']] = $type['level_name'];
+        }
+        $count = M('Store')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $storeList = M('Store')->where($condition)->field()->order('store_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$storeList);
+        $this->assign('levelList',$levelList);
+        $this->display();
+    }
+
+    //编辑题库
+    public function edit(){
+        $step = I('step','');
+        $storeId = I('store_id','');
+        if (empty($step)){
+            $info = array();
+            if (!empty($storeId)){
+                $info = M('Store')->where(array('store_id'=>$storeId))->find();
+            }
+            $levelList = M('UserLevel')->where(array('is_delete'=>1))->field('level_id,level_name')->select();
+            $this->assign('info',$info);
+            $this->assign('levelList',$levelList);
+            $this->display();
+        }else if($step==2){
+            $levelId = I('level_id','');
+            /* $storeName = I('store_name','');
+            if (mb_strlen($storeName,'UTF8')<2 || mb_strlen($storeName,'UTF8')>12){
+                $this->error('题库名称2到12个汉字');
+            }
+            $res = M('Store')->where(array('store_name'=>$storeName,'is_delete'=>1))->field('store_id')->find();
+            //新增
+            if (empty($storeId) && $res!=NULL){
+                $this->error('题库名称已经存在');
+            }
+            //更新
+            if (!empty($storeId) && $storeId!=$res['store_id']){
+                $this->error('题库名称已经存在');
+            } */
+            $res = M('Store')->where(array('level_id'=>$levelId,'is_delete'=>1))->field('store_id')->find();
+            //新增
+            if (empty($storeId) && $res!=NULL){
+                $this->error('题库类型已经存在');
+            }
+            //更新
+            if (!empty($storeId) && $storeId!=$res['store_id']){
+                $this->error('题库类型已经存在');
+            }
+            if (empty($storeId)){
+                //M('Store')->add(array('level_id'=>$levelId,'store_name'=>$storeName,'operate_dt'=>time()));
+                M('Store')->add(array('level_id'=>$levelId,'operate_dt'=>time()));
+            }else{
+                M('Store')->where(array('store_id'=>$storeId))->save(array('level_id'=>$levelId));
+            }
+            $this->success('题库操作成功','/admin/store/index');
+        }
+    }
+    
+    //删除题库
+    public function del(){
+        $storeId = I('store_id','');
+        if (empty($storeId)){
+            $this->error("题库ID错误",'/admin/store/index');
+        }
+        //M('store')->where(array('store_id'=>$storeId))->save(array('is_delete'=>2));
+        M('store')->where(array('store_id'=>$storeId))->delete();
+        $this->success('题库删除成功','/admin/store/index');
+    }
+    
+     //获取课程的单词列表
+    public function detail(){
+        $storeId = I('store_id','');
+        if (empty($storeId)){
+            $this->error("题库ID错误",'/admin/store/index');
+        }
+        $keyword = I('get.keyword','');
+        $condition = array('is_delete'=>1,'store_id'=>$storeId);
+        if (!empty($keyword)){
+            $condition['words_name'] = array('LIKE','%'.$keyword.'%');
+        }
+        $count = M('StoreWords')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $wordsRes = M('StoreWords')->where($condition)->field()->order('words_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $wordsList = array();
+        foreach ($wordsRes as $row){
+            $wordsList[] = array(
+                'words_id' => $row['words_id'],
+                'store_id' => $row['store_id'],
+                'words_name' => $row['words_name'],
+                'operate_dt' => $row['operate_dt'],
+                'words_text' => $this->getWordsText($row),
+            );
+        }
+        $this->assign('page',$show);
+        $this->assign('list',$wordsList);
+        $this->assign('storeId', $storeId);
+        $this->display();
+    }
+    
+    //编辑题库单词
+    public function words(){
+        $step = I('step','');
+        $wordsId = I('words_id','');
+        $storeId = I('store_id','');
+        $wordsKeys = array('n'=>'words_n','pron'=>'words_pron','adj'=>'words_adj','num'=>'words_num','v'=>'words_v','adv'=>'words_adv','art'=>'words_art','prep'=>'words_prep','conj'=>'words_conj','int'=>'words_int','vt'=>'words_vt','vi'=>'words_vi','other'=>'words_other',);
+        if (empty($step)){
+            $info = array();
+            if (!empty($storeId)){
+                $info = M('StoreWords')->where(array('words_id'=>$wordsId))->find();
+            }
+            $this->assign('info',$info);
+            $this->assign('storeId', $storeId);
+            $this->assign('wordsKeys', $wordsKeys);
+            $this->display();
+        }else if($step==2){
+            $data['store_id'] = $storeId;
+            $data['words_name'] = I('words_name','');
+            $wordsVals = array_values($wordsKeys);
+            $checkWords = true;
+            foreach ($wordsVals as $keys){
+                $data[$keys] = I($keys,'');
+                if (!empty($data[$keys])){
+                    $checkWords = false;
+                }
+            }
+            if (empty($data['words_name'])){
+                $this->error('单词不能为空');
+            }
+            if ($checkWords){
+                $this->error('中文释义不能为空');
+            }
+            $data['operate_dt'] = time();
+            if ($wordsId){
+                M('StoreWords')->where(array('words_id'=>$wordsId))->save($data);
+            }else{
+                M('StoreWords')->add($data);
+                M('Store')->where(array('store_id'=>$storeId))->setInc('store_num');
+            }
+            //$this->success('单词操作成功','/admin/store/detail?store_id='.$storeId);
+            $this->success('单词操作成功','/admin/store/words?store_id='.$storeId);
+        }
+    }
+    
+    //删除题库单词
+    public function delWords(){
+        $wordsId = I('words_id','');
+        $storeId = I('store_id','');
+        //M('StoreWords')->where(array('words_id'=>$wordsId))->save(array('is_delete'=>2));
+        M('StoreWords')->where(array('words_id'=>$wordsId))->delete();
+        M('Store')->where(array('store_id'=>$storeId))->setDec('store_num');
+        $this->success('题库单词删除成功','/admin/store/detail/index?store_id='.$storeId);
+    }
+}

+ 464 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/UeditorController.class.php

@@ -0,0 +1,464 @@
+<?php
+/**
+* 百度编辑器控制器
+*/
+namespace Admin\Controller;
+use Think\Controller;
+class UeditorController extends Controller{
+	
+	private $thumb;//缩略图模式(看手册)
+	private $water;	//是否加水印(0:无水印,1:水印文字,2水印图片)
+	private $waterText;//水印文字
+	private $waterPosition;//水印位置
+	private $savePath; //保存位置
+	private $userid; //操作用户名
+
+
+	public function _initialize(){
+		$this->userid=empty($_SESSION['userid'])? $_GET['userid'] : $_SESSION['userid'];
+		if(empty($this->userid)){
+			$this->userid= 'anonymity';
+		}
+
+		$this->rootPath= './Public/uploads/';
+		$this->savePath='';
+		$this->thumb=1;
+		$this->water=1;
+		$this->waterText='逐日软件';
+ 		$this->waterPosition= 9;
+	}
+
+	public function index(){
+		$CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents(CONF_PATH."config.json")), true);
+
+		$action = htmlspecialchars($_GET['action']);
+		switch ($action) {
+		    case 'config':
+		        $result =  json_encode($CONFIG);
+		        break;
+
+		    /* 上传图片 */
+		    case 'uploadimage':
+		        $config = array(
+		            "pathFormat" => $CONFIG['imagePathFormat'],
+		            "maxSize" => $CONFIG['imageMaxSize'],
+		            "allowFiles" => $CONFIG['imageAllowFiles']
+		        );
+		        $fieldName = $CONFIG['imageFieldName'];
+		        $result=$this->upFile($config, $fieldName);
+		        break;
+
+		    /* 上传涂鸦 */
+		    case 'uploadscrawl':
+		        $config = array(
+		            "pathFormat" => $CONFIG['scrawlPathFormat'],
+		            "maxSize" => $CONFIG['scrawlMaxSize'],
+		            "allowFiles" => $CONFIG['scrawlAllowFiles'],
+		            "oriName" => "scrawl.png"
+		        );
+		        $fieldName = $CONFIG['scrawlFieldName'];
+		        $base64 = "base64";
+		        $result=$this->upBase64($config,$fieldName);
+		        break;
+
+		    /* 上传视频 */
+		    case 'uploadvideo':
+		        $config = array(
+		            "pathFormat" => $CONFIG['videoPathFormat'],
+		            "maxSize" => $CONFIG['videoMaxSize'],
+		            "allowFiles" => $CONFIG['videoAllowFiles']
+		        );
+		        $fieldName = $CONFIG['videoFieldName'];
+		        $result=$this->upFile($config, $fieldName);
+		        break;
+
+		    /* 上传文件 */
+		    case 'uploadfile':
+		    // default:
+		        $config = array(
+		            "pathFormat" => $CONFIG['filePathFormat'],
+		            "maxSize" => $CONFIG['fileMaxSize'],
+		            "allowFiles" => $CONFIG['fileAllowFiles']
+		        );
+		        $fieldName = $CONFIG['fileFieldName'];
+		        $result=$this->upFile($config, $fieldName);
+		        break;
+
+		    /* 列出图片 */
+		    case 'listimage':
+			$allowFiles = $CONFIG['imageManagerAllowFiles'];
+			$listSize = $CONFIG['imageManagerListSize'];
+			$path = $CONFIG['imageManagerListPath'];
+			$get=$_GET;
+			$result =$this->file_list($allowFiles, $listSize, $get);
+		        	break;
+		    /* 列出文件 */
+		    case 'listfile':
+			$allowFiles = $CONFIG['fileManagerAllowFiles'];
+			$listSize = $CONFIG['fileManagerListSize'];
+			$path = $CONFIG['fileManagerListPath'];
+			$get=$_GET;
+			$result =$this->file_list($allowFiles, $listSize, $get);
+	    	            break;
+
+		    /* 抓取远程文件 */
+		    case 'catchimage':
+		    	$config = array(
+			    "pathFormat" => $CONFIG['catcherPathFormat'],
+			    "maxSize" => $CONFIG['catcherMaxSize'],
+			    "allowFiles" => $CONFIG['catcherAllowFiles'],
+			    "oriName" => "remote.png"
+			);
+			$fieldName = $CONFIG['catcherFieldName'];
+			/* 抓取远程图片 */
+			$list = array();
+			if (isset($_POST[$fieldName])) {
+			    $source = $_POST[$fieldName];
+			} else {
+			    $source = $_GET[$fieldName];
+			}
+			foreach ($source as $imgUrl) {
+			    $info=json_decode($this->saveRemote($config, $imgUrl),true);
+			    // dump($info);
+			    array_push($list, array(
+			        "state" => $info["state"],
+			        "url" => $info["url"],
+			        "size" => $info["size"],
+			        "title" => htmlspecialchars($info["title"]),
+			        "original" => htmlspecialchars($info["original"]),
+			        "source" => htmlspecialchars($imgUrl)
+			    ));
+			}
+
+			$result= json_encode(array(
+			    'state'=> count($list) ? 'SUCCESS':'ERROR',
+			    'list'=> $list
+			));
+		        break;
+
+		    default:
+		        $result = json_encode(array(
+		            'state'=> '请求地址出错'
+		        ));
+		        break;
+		}
+
+		/* 输出结果 */
+		if (isset($_GET["callback"])) {
+		    if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
+		        echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
+		    } else {
+		        echo json_encode(array(
+		            'state'=> 'callback参数不合法'
+		        ));
+		    }
+		} else {
+		    echo $result;
+		}
+
+	}
+	/**
+	     * 上传文件的主处理方法
+	     * @return mixed
+	     */
+	private function upFile($config,$fieldName){
+		$conf=array(
+			'rootPath' => $this->rootPath,
+			'savePath' => $this->savePath,
+			'autoSub' => true,
+			'subName'=>$this->userid . '/' . date('Ym',time()) ,// 子目录命名的规则为 用户名/年月/
+			'maxSize'=>$config['maxSize'],
+			'exts'=>$this->format_exts($config['allowFiles']),//去除扩展名前的点 .
+			);
+
+		$upload=new \Think\Upload($conf);
+		$info=$upload->uploadOne($_FILES[$fieldName]);
+		if($info){
+			$fname=$upload->rootPath .$info['savepath'].$info['savename'];
+			$imagearr = explode(',', 'jpg,gif,png,jpeg,bmp,ttf,tif'); 
+			$info['ext']= strtolower($info['ext']);
+
+			$isimage = in_array($info['ext'],$imagearr) ? 1 : 0;
+			if ($isimage) {
+				$image=new \Think\Image();
+				$image->Open($fname);
+				$image->thumb(680,680,$this->thumb)->save($fname);
+				if ($this->water==1) {
+					$image->text($this->waterText,'./Public/font/STXINGKA.TTF',18,'#9a9a9a',$this->waterPosition,array(-2,0))->save($fname); 
+				}
+				if ($this->water==2) {
+					$image->water($this->waterImage)->save($fname);
+				}	
+			}
+
+			$data=array(
+				'state'=>'SUCCESS',
+				//'url'=>__ROOT__. strtolower(substr($fname,1)),
+			    'url'=>C('WEB_HOST'). strtolower(substr($fname,1)),
+				'title'=>$info['savename'],
+				'original'=>$info['name'],
+				'type'=>'.' . $info['ext'],
+				'size'=>$info['size'],
+				);
+		}else{
+			$data=array(
+				'state'=>$upload->getError(),
+				);
+		}
+		return json_encode($data);
+	}
+
+	/**
+	 * 处理base64编码的图片上传
+	 * @return mixed
+	 */
+	private function upBase64($config,$fieldName)
+	{
+	    $base64Data = $_POST[$fieldName];
+	    $img = base64_decode($base64Data);
+
+	    $dirname=$this->rootPath . $this->savePath . $this->userid . '/scrawl/';
+	    $file['filesize']=strlen($img);
+	    $file['oriName']=$config['oriName'];
+	    $file['ext']=strtolower(strrchr($config['oriName'], '.'));
+	    $file['name']= uniqid() .  $file['ext'];
+	    $file['fullName']=$dirname . $file['name'];
+	    $fullName=$file['fullName'];
+	    // dump($file);
+
+ 	//检查文件大小是否超出限制
+	    if ($file['filesize'] >= ($config["maxSize"])) {
+  		$data=array(
+			'state'=>'文件大小超出网站限制',
+		);
+		return json_encode($data);
+	    }
+
+	    //创建目录失败
+	    if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
+	           $data=array(
+			'state'=>'目录创建失败',
+		);
+		return json_encode($data);
+	    } else if (!is_writeable($dirname)) {
+	         $data=array(
+			'state'=>'目录没有写权限',
+		);
+		return json_encode($data);
+	    }
+
+	    //移动文件
+	    if (!(file_put_contents($fullName, $img) && file_exists($fullName))) { //移动失败
+        	         $data=array(
+		'state'=>'写入文件内容错误',
+		);
+	    } else { //移动成功	       
+	        	$data=array(
+			'state'=>'SUCCESS',
+			'url'=>__ROOT__ . substr($file['fullName'],1),
+			'title'=>$file['name'],
+			'original'=>$file['oriName'],
+			'type'=>$file['ext'],
+			'size'=>$file['filesize'],
+		);
+	    }
+	    return json_encode($data);
+	}
+
+	/**
+	 * 拉取远程图片
+	 * @return mixed
+	 */
+	private function saveRemote($config, $fieldName)
+	{
+	    $imgUrl = htmlspecialchars($fieldName);
+	    $imgUrl = str_replace("&amp;", "&", $imgUrl);
+
+	    //http开头验证
+	    if (strpos($imgUrl, "http") !== 0) {
+	         $data=array(
+		'state'=>'链接不是http链接',
+		);
+	         return json_encode($data);
+	    }
+	    //获取请求头并检测死链
+	    $heads = get_headers($imgUrl);
+	    if (!(stristr($heads[0], "200") && stristr($heads[0], "OK"))) {
+	         $data=array(
+		'state'=>'链接不可用',
+		);
+	         return json_encode($data);
+	    }
+	    //格式验证(扩展名验证和Content-Type验证)
+	    $fileType = strtolower(strrchr($imgUrl, '.'));
+	    if (!in_array($fileType, $config['allowFiles']) || stristr($heads['Content-Type'], "image")) {
+	        $data=array(
+		'state'=>'链接contentType不正确',
+		);
+	         return json_encode($data);
+	    }
+
+	    //打开输出缓冲区并获取远程图片
+	    ob_start();
+	    $context = stream_context_create(
+	        array('http' => array(
+	            'follow_location' => false // don't follow redirects
+	        ))
+	    );
+	    readfile($imgUrl, false, $context);
+	    $img = ob_get_contents();
+	    ob_end_clean();
+	    preg_match("/[\/]([^\/]*)[\.]?[^\.\/]*$/", $imgUrl, $m);
+
+	    $dirname=$this->rootPath . $this->savePath . $this->userid . '/remote/';
+	    $file['oriName']=$m ? $m[1]:"";
+	    $file['filesize']=strlen($img);
+	    $file['ext']=strtolower(strrchr($config['oriName'], '.'));
+	    $file['name']= uniqid() .  $file['ext'];
+	    $file['fullName']=$dirname . $file['name'];
+	    $fullName=$file['fullName'];
+
+	    //检查文件大小是否超出限制
+	    if ($file['filesize'] >= ($config["maxSize"])) {
+  		$data=array(
+			'state'=>'文件大小超出网站限制',
+		);
+		return json_encode($data);
+	    }
+
+	    //创建目录失败
+	    if (!file_exists($dirname) && !mkdir($dirname, 0777, true)) {
+  		$data=array(
+			'state'=>'目录创建失败',
+		);
+		return json_encode($data);
+	    } else if (!is_writeable($dirname)) {
+  		$data=array(
+			'state'=>'目录没有写权限',
+		);
+		return json_encode($data);
+	    }
+
+	    //移动文件
+	    if (!(file_put_contents($fullName, $img) && file_exists($fullName))) { //移动失败
+  		$data=array(
+			'state'=>'写入文件内容错误',
+		);
+		return json_encode($data);
+	    } else { //移动成功
+	       	 $data=array(
+			'state'=>'SUCCESS',
+			'url'=>__ROOT__ . substr($file['fullName'],1),
+			'title'=>$file['name'],
+			'original'=>$file['oriName'],
+			'type'=>$file['ext'],
+			'size'=>$file['filesize'],
+		);
+	    }
+	    return json_encode($data);
+	}
+	private function file_list($allowFiles, $listSize, $get){
+		$dirname=$this->rootPath . $this->savePath ;
+		if ($this->userid!='admin') {
+			$dirname.=$this->userid . '/';
+		}
+		$allowFiles = substr(str_replace(".", "|", join("", $allowFiles)), 1);
+
+		/* 获取参数 */
+		$size = isset($get['size']) ? htmlspecialchars($get['size']) : $listSize;
+		$start = isset($get['start']) ? htmlspecialchars($get['start']) : 0;
+		$end = $start + $size;
+
+		/* 获取文件列表 */
+		// $path = $_SERVER['DOCUMENT_ROOT'] . (substr($path, 0, 1) == "/" ? "":"/") . $path;
+		$path=$dirname;
+		$files = $this->getfiles($path, $allowFiles);
+		if (!count($files)) {
+		    return json_encode(array(
+		        "state" => "no match file",
+		        "list" => array(),
+		        "start" => $start,
+		        "total" => count($files)
+		    ));
+		}
+
+		/* 获取指定范围的列表 */
+		$len = count($files);
+		for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--){
+		    $list[] = $files[$i];
+		}
+		//倒序
+		//for ($i = $end, $list = array(); $i < $len && $i < $end; $i++){
+		//    $list[] = $files[$i];
+		//}
+
+		/* 返回数据 */
+		$result = json_encode(array(
+		    "state" => "SUCCESS",
+		    "list" => $list,
+		    "start" => $start,
+		    "total" => count($files)
+		));
+
+		return $result;
+	}
+
+   	 /**
+	     * 遍历获取目录下的指定类型的文件
+	     * @param $path
+	     * @param array $files
+	     * @return array
+	     */
+	    private function getfiles( $path , $allowFiles, &$files = array() ) {
+	        if ( !is_dir( $path ) ) return null;
+	        if(substr($path, strlen($path) - 1) != '/') $path .= '/';
+	        $handle = opendir( $path);
+	        while ( false !== ( $file = readdir( $handle ) ) ) {
+	            if ( $file != '.' && $file != '..' ) {
+	                $path2 = $path . $file;
+	                if ( is_dir( $path2)) {
+	                    $this->getfiles( $path2 ,$allowFiles,  $files );
+	                } else {
+		                if (preg_match("/\.(".$allowFiles.")$/i", $file)) {
+		                    $files[] = array(
+		                        'url'=> __ROOT__ . substr($path2, 1),
+		                        'mtime'=> filemtime($path2)
+		                    );
+		                }
+	                }
+	            }
+	        }
+	        return $files;
+	    }
+	    /**
+	     * [formatUrl 格式化url,用于将getfiles返回的文件路径进行格式化,起因是中文文件名的不支持浏览]
+	     * @param  [type] $files [文件数组]
+	     * @return [type]        [格式化后的文件数组]
+	     */
+	    private function formatUrl($files){
+	    	if(!is_array($files)) return $files;
+	    	foreach ($files as  $key => $value) {
+	    		$data=array();
+	    		$data=explode('/', $value);
+	    		foreach ($data as $k=>$v) {
+	    			if($v!='.' && $v!='..'){
+	    				$data[$k]=urlencode($v);
+	    				$data[$k] = str_replace("+", "%20", $data[$k]); 
+	    			}
+	    		}
+	    		$files[$key]=implode('/', $data);
+	    	}
+	    	return $files;
+	    }	
+
+
+	private function format_exts($exts){
+		$data=array();
+		foreach ($exts as $key => $value) {
+			$data[]=ltrim($value,'.');
+		}
+		return $data;
+	}
+
+}
+?>

+ 239 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/UserController.class.php

@@ -0,0 +1,239 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class UserController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    //用户列表
+    public function index(){
+        $page = I('get.p','1');
+        session('page',$page);
+        $keyword = I('get.keyword','');
+		$is_admin = I('get.is_admin',2);
+		$is_auth = I('get.is_auth',2);
+        $condition = array();
+        if (!empty($keyword)){
+            $condition['user_id|user_phone|user_name'] = array('LIKE','%'.$keyword.'%');
+            $this->assign('keyword',$keyword);
+        }
+		if($is_admin==0){
+			$condition['admin_id']=0;
+		}elseif($is_admin==1){
+			$condition['admin_id']=array('GT',0);
+		}
+		
+		if($is_auth!=2){
+			$Model = M();
+			$sql = "select a.user_id from ((select user_id from `t_choice` where choice_status=3 and choice_type=2) union all (select user_id from `t_course` where course_status=3)) as a group by a.user_id";
+			$list = $Model->query($sql);
+			$ids=array();
+			foreach($list as $k=>$v){
+				$ids[]=$v['user_id'];
+			}
+			if($is_auth==0){
+				$condition['user_id']=array('not in',$ids);
+			}elseif($is_auth==1){
+				$condition['user_id']=array('in',$ids);
+			}
+			
+		}
+		
+		$this->assign('is_admin',$is_admin);
+		$this->assign('is_auth',$is_auth);
+        $count = M('User')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $userList = M('User')->where($condition)->field()->order('user_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        //获取用户等级
+        $levelRes = M('UserLevel')->field('level_id,level_name')->select();
+        $levelList = array();
+        foreach ($levelRes as $level){
+            $levelList[$level['level_id']] = $level['level_name'];
+        }
+		foreach($userList as $k=>$v){
+			if($v['forbidden']-time()>0){
+				$userList[$k]['is_forbidden']=1;
+				$time=$v['forbidden']-time();
+				$d = floor($time / (3600*24));
+				$h = floor(($time % (3600*24)) / 3600);
+				$m = floor((($time % (3600*24)) % 3600) / 60);
+				$tmp='';
+				if($d>'0'){
+					$tmp=$d.'天'.$h.'小时'.$m.'分';
+				}else{
+					if($h!='0'){
+						$tmp=$h.'小时'.$m.'分';
+					}else{
+						$tmp=$m.'分';
+					}
+				}
+				$userList[$k]['str_forbidden']=$tmp;
+				$userList[$k]['is_forbidden']=1;
+			}else{
+				$userList[$k]['str_forbidden']='';
+				$userList[$k]['is_forbidden']=0;
+			}
+		}
+        $this->assign('page',$show);
+        $this->assign('list',$userList);
+        $this->assign('levelList',$levelList);
+        $this->display();
+    }
+    //用户详细信息
+    public function detail(){
+        $userId = I('user_id','');
+        if (empty($userId) || $userId<1000000){
+            //$this->error("用户ID错误",'/admin/user/index');
+        }
+        $userInfo = M('User')->where(array('user_id'=>$userId))->find();
+        //用户好友
+        $Model = M();
+        $count = $Model->field('user_id2')->table('t_user_connect')->where(array('user_id1'=>$userId))
+        ->union(array('field'=>'user_id1','table'=>'t_user_connect','where'=>array('user_id2'=>$userId)))->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $userIdList = D('UserConnect')->getConnectUserList($userId, $Page->firstRow, $Page->listRows);
+        $userList = array();
+        $userIdArr = array();
+        if (function_exists('array_column')){
+            $userIdArr = array_column($userIdList, 'user_id');
+        }else{
+            foreach ($userIdList as $row){
+                $userIdArr[] = $row['user_id'];
+            }
+        }
+        if (count($userIdArr)){
+            $userList = M('User')->where(array('user_id'=>array('IN',implode(',', $userIdArr))))->field()->order('user_id desc')->select();
+        }
+        //获取用户等级
+        $levelRes = M('UserLevel')->field('level_id,level_name')->select();
+        $levelList = array();
+        foreach ($levelRes as $level){
+            $levelList[$level['level_id']] = $level['level_name'];
+        }
+        
+        $areaRes = M('China')->select();
+        $areaList = array();
+        foreach ($areaRes as $row){
+            $areaList[$row['id']] = $row['name'];
+        }
+        $this->assign('areaList',$areaList);
+        $this->assign('levelList',$levelList);
+        $this->assign('userList',$userList);
+        $this->assign('userInfo',$userInfo);
+        $this->display();
+    }
+    //用户课程
+    public function course(){
+        $courseStatus = I('course_status','');
+        $userId = I('user_id','');
+        if (empty($userId) || $userId<1000000){
+            $this->error("用户ID错误",'/admin/user/index');
+        }
+        $condition = array('course_source'=>2,'user_id'=>$userId, 'is_delete'=>1,'course_flag'=>1);
+        if (!empty($courseStatus)){
+            $condition['course_status'] = array('IN',$courseStatus);
+        }
+        $count = M('Course')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $courseList = M('Course')->where($condition)->field()->order('course_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$courseList);
+        $this->display();
+    }
+    //用户自由记
+    public function notepad(){
+        $courseStatus = I('course_status','');
+        $userId = I('user_id','');
+        if (empty($userId) || $userId<1000000){
+            $this->error("用户ID错误",'/admin/user/index');
+        }
+        $condition = array('user_id'=>$userId,'course_flag'=>2, 'is_delete'=>1,'course_source'=>2,);
+        if (!empty($courseStatus)){
+            $condition['course_status'] = array('IN',$courseStatus);
+        }
+        $count = M('Course')->where($condition)->count();
+        //分页
+        $Page = new \Think\Page($count);
+        $show = $Page->show();
+        $notepadList = M('Course')->where($condition)->field()->order('course_id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
+        $this->assign('page',$show);
+        $this->assign('list',$notepadList);
+        $this->display();
+    }
+	//用户禁言
+    public function forbidden(){
+        $userId = I('user_id','');
+        $days = I('days','0');
+        if (empty($userId) || $userId<1000000){
+            $this->error("用户ID错误",'/admin/user/index');
+        }
+        M('user')->where(array('user_id'=>$userId))->save(array('forbidden'=>time()+$days*24*60*60));
+    }
+	
+	//设置用户管理员
+    public function set_admin(){
+        $userId = I('user_id','');
+       
+        if (empty($userId) || $userId<1000000){
+            $this->error("用户ID错误",'/admin/user/index');
+        }
+		$userInfo = M('User')->where(array('user_id'=>$userId))->find();
+		
+		if (!$userInfo){
+            $this->error("用户ID错误",'/admin/user/index');
+        }
+		$adminInfo = M('admin')->where(array('admin_account'=>$userInfo['user_phone']))->find();
+		
+		if (!$adminInfo){
+			$data=array();
+			$data['admin_account']=$userInfo['user_phone'];
+			$data['admin_pwd']=$userInfo['user_pwd'];
+			$data['group_id']=1;
+			$data['operate_dt'] = time();
+			M('admin')->add($data);
+			$adminInfo = M('admin')->where($data)->find();
+        }
+		
+		$admin_id=$adminInfo['admin_id'];
+		
+		$uid=$userId;
+		$noticeContent = '您已被设置为管理员,遇到恶意评论长摁评论可以删除,情节严重可长摁用户ID进行一段时间的禁言。';
+		$temp=array();
+		M('Notice')->add(array('ref_user_id'=>$uid,'user_id'=>0,'notice_flag'=>0,'notice_status'=>1,'notice_type'=>0,'notice_title'=>$noticeContent,'notice_content'=>$noticeContent,'operate_dt'=>time(),'extra'=>json_encode($temp)));
+		M('User')->where(array('user_id'=>$uid))->setInc('sys_notice');
+		$data = array('type'=>0,'msg'=>$noticeContent,'data'=>array());
+		$url="http://www.hanlinyuanonline.com/api/choice/push?uid=".$uid."&data=".urlencode(base64_encode(json_encode($data)));
+		$ch = curl_init(); 
+		curl_setopt($ch, CURLOPT_URL, $url); 
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
+		$output = curl_exec($ch); 
+
+		curl_close($ch);
+		M('user')->where(array('user_id'=>$userId))->save(array('admin_id'=>$admin_id,'is_delete'=>1));
+    }
+	
+	//取消用户管理员
+    public function cancle_admin(){
+        $userId = I('user_id','');
+       
+        if (empty($userId) || $userId<1000000){
+            $this->error("用户ID错误",'/admin/user/index');
+        }
+		if($userId==0){
+			$this->error("超管无法取消",'/admin/user/index');
+		}
+		$userInfo = M('User')->where(array('user_id'=>$userId))->find();
+		if (!$userInfo){
+            $this->error("用户ID错误",'/admin/user/index');
+        }
+		M('admin')->where(array('admin_id'=>$userInfo['admin_id']))->delete();
+		M('user')->where(array('user_id'=>$userId))->save(array('admin_id'=>0));
+    }
+    
+}

+ 319 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/WordsController.class.php

@@ -0,0 +1,319 @@
+<?php
+namespace Admin\Controller;
+use Common\Controller\AdminController;
+class WordsController extends AdminController {
+    public function __construct(){
+        parent::__construct();
+    }
+    
+    //单词编辑
+    public function edit() {
+        $step = I('step','');
+        $wordsId = I('words_id','');
+        $courseId = I('course_id','');
+        $wordsKeys = array('n'=>'words_n','pron'=>'words_pron','adj'=>'words_adj','num'=>'words_num','v'=>'words_v','adv'=>'words_adv','art'=>'words_art',
+            'prep'=>'words_prep','conj'=>'words_conj','int'=>'words_int','vt'=>'words_vt','vi'=>'words_vi','other'=>'words_other',);
+        if (empty($step)){
+            $info = array();
+            $wordsPreId = '';
+            $wordsNextId = '';
+            if (!empty($courseId)){
+                $info = M('Words')->where(array('words_id'=>$wordsId))->find();
+                $wordsPreInfo = M('Words')->where(array('course_id'=>$courseId,'words_id'=>array('LT',$wordsId)))->order('words_id desc')->field('words_id')->find();
+                if ($wordsPreInfo!=null){
+                    $wordsPreId = $wordsPreInfo['words_id'];
+                }
+                $wordsNextInfo = M('Words')->where(array('course_id'=>$courseId,'words_id'=>array('GT',$wordsId)))->order('words_id asc')->field('words_id')->find();
+                if ($wordsNextInfo!=null){
+                    $wordsNextId = $wordsNextInfo['words_id'];
+                }
+				if($info['words_img']){
+					$arr=explode(',',$info['words_img']);
+					$info['words_img1']=$arr[0];
+					$info['words_img2']=$arr[1];
+					$info['words_img3']=$arr[2];
+				}
+				
+				$ttt='';
+				if($info['words_voice1']){
+					if($ttt){
+						$ttt.=",".$info['words_voice1'];
+					}else{
+						$ttt=$info['words_voice1'];
+					}
+				}
+				if($info['words_voice2']){
+					if($ttt){
+						$ttt.=",".$info['words_voice2'];
+					}else{
+						$ttt=$info['words_voice2'];
+					}
+				}
+				if($info['words_voice3']){
+					if($ttt){
+						$ttt.=",".$info['words_voice3'];
+					}else{
+						$ttt=$info['words_voice3'];
+					}
+				}
+				$info['words_voice']=$ttt;
+				
+				$ttt='';
+				if($info['words_read1']){
+					if($ttt){
+						$ttt.=",".$info['words_read1'];
+					}else{
+						$ttt=$info['words_read1'];
+					}
+				}
+				if($info['words_read2']){
+					if($ttt){
+						$ttt.=",".$info['words_read2'];
+					}else{
+						$ttt=$info['words_read2'];
+					}
+				}
+				if($info['words_read3']){
+					if($ttt){
+						$ttt.=",".$info['words_read3'];
+					}else{
+						$ttt=$info['words_read3'];
+					}
+				}
+				$info['words_read']=$ttt;
+				
+            }
+            $this->assign('info',$info);
+            $this->assign('courseId', $courseId);
+            $this->assign('wordsKeys', $wordsKeys);
+            $this->assign('wordsPreId', $wordsPreId);
+            $this->assign('wordsNextId', $wordsNextId);
+            $this->display();
+        }else if($step==2){
+            $data['course_id'] = $courseId;
+            $data['words_name'] = trim(I('words_name',''));
+            $wordsVoice = I('words_voice','');
+            $wordsRead = I('words_read','');
+            if (substr($wordsVoice,-1)==','){
+                $wordsVoice = substr($wordsVoice, 0, -1);
+            }
+            $wordsVoiceArr = explode(',', $wordsVoice);
+            $wordsReadArr = explode(',', $wordsRead);
+            for ($i=0;$i<count($wordsVoiceArr);$i++){
+                $j = $i+1;
+                $data['words_read'.$j] = $wordsReadArr[$i];
+                $data['words_voice'.$j] = $wordsVoiceArr[$i];
+            }
+            $wordsVals = array_values($wordsKeys);
+            $checkWords = true;
+            foreach ($wordsVals as $keys){
+                $data[$keys] = I($keys,'');
+                if (!empty($data[$keys])){
+                    $checkWords = false;
+                }
+            }
+            if (empty($data['words_name'])){
+                $this->error('单词不能为空');
+            }
+            /* if (empty($data['words_voice1'])){
+                $this->error('读音不能为空');
+            }
+            if (empty($data['words_read1'])){
+                $this->error('音标不能为空');
+            } */
+            if ($checkWords){
+                $this->error('中文释义不能为空');
+            }
+            $data['jz_en1'] = I('jz_en1','');
+            $data['jz_cn1'] = I('jz_cn1','');
+            $data['jz_en2'] = I('jz_en2','');
+            $data['jz_cn2'] = I('jz_cn2','');
+            $data['jz_en3'] = I('jz_en3','');
+            $data['jz_cn3'] = I('jz_cn3','');
+            $data['words_similar'] = I('words_similar','');
+            $data['annotation_cn'] = I('annotation_cn','');
+            $data['similar_cn'] = I('similar_cn','');
+			$words_img1=I('words_img1','');
+			$words_img2=I('words_img2','');
+			$words_img3=I('words_img3','');
+			$ttt='';
+			if($words_img1){
+				if($ttt){
+					$ttt.=",".$words_img1;
+				}else{
+					$ttt=$words_img1;
+				}
+			}
+			if($words_img2){
+				if($ttt){
+					$ttt.=",".$words_img2;
+				}else{
+					$ttt=$words_img2;
+				}
+			}
+			if($words_img3){
+				if($ttt){
+					$ttt.=",".$words_img3;
+				}else{
+					$ttt=$words_img3;
+				}
+			}
+			$data['words_img']=$ttt;
+			
+			
+			/*
+            if (!empty($data['jz_en1']) && strpos(strtolower($data['jz_en1']), strtolower($data['words_name']))===FALSE){
+                $this->error('您添加的例句1不包含对应单词,请仔细核对后提交');
+            }
+            if (!empty($data['jz_en2']) && strpos(strtolower($data['jz_en2']), strtolower($data['words_name']))===FALSE){
+                $this->error('您添加的例句2不包含对应单词,请仔细核对后提交');
+            }
+            if (!empty($data['jz_en3']) && strpos(strtolower($data['jz_en3']), strtolower($data['words_name']))===FALSE){
+                $this->error('您添加的例句3不包含对应单词,请仔细核对后提交');
+            }
+			*/
+            if (!empty($data['jz_en1']) && empty($data['jz_cn1'])){
+                $this->error('您添加的例句1释义不能为空,请仔细核对后提交');
+            }
+            if (!empty($data['jz_en2']) && empty($data['jz_cn2'])){
+                $this->error('您添加的例句1释义不能为空,请仔细核对后提交');
+            }
+            if (!empty($data['jz_en3']) && empty($data['jz_cn3'])){
+                $this->error('您添加的例句1释义不能为空,请仔细核对后提交');
+            }
+            if (!empty($data['words_similar']) && strlen($data['words_similar'])>50){
+                $this->error('近义词不能大于50个字节');
+            }
+            if (!empty($data['similar_cn']) && strlen($data['similar_cn'])>500){
+                $this->error('英文释义不能大于500个字节');
+            }
+            $data['operate_dt'] = time();
+            if ($wordsId){
+                $jumpType = 1;
+                M('Words')->where(array('words_id'=>$wordsId))->save($data);
+            }else{
+                $jumpType = 2;
+                $wordsId = M('Words')->add($data);
+                M('Course')->where(array('course_id'=>$courseId))->setInc('course_num');
+            }
+            //$this->success('单词操作成功','/admin/course/detail?course_id='.$courseId);
+            $jumpId = I('jumpId');
+            if ($jumpId==1){
+                if ($jumpType==1){
+                    $this->success('单词操作成功','/admin/words/edit?course_id='.$courseId.'&words_id='.$wordsId);
+                }else{
+                    $this->success('单词操作成功','/admin/words/edit?course_id='.$courseId);
+                }
+            }else if($jumpId==2){
+                $wordsInfo = M('Words')->where(array('course_id'=>$courseId,'words_id'=>array('LT',$wordsId)))->order('words_id desc')->field('words_id')->find();
+                if ($wordsInfo==NULL){
+                    $this->success('单词操作成功,暂无上一个单词','/admin/words/edit?course_id='.$courseId);
+                }
+                $this->success('单词操作成功,跳转至上一个单词','/admin/words/edit?course_id='.$courseId.'&words_id='.$wordsInfo['words_id']);
+            }else if($jumpId==3){
+                $wordsInfo = M('Words')->where(array('course_id'=>$courseId,'words_id'=>array('GT',$wordsId)))->order('words_id asc')->field('words_id')->find();
+                if ($wordsInfo==NULL){
+                    $this->success('单词操作成功,暂无下一个单词','/admin/words/edit?course_id='.$courseId);
+                }
+                $this->success('单词操作成功,跳转至下一个单词','/admin/words/edit?course_id='.$courseId.'&words_id='.$wordsInfo['words_id']);
+            }
+        }
+    }
+    
+    //删除单词
+    public function del(){
+        $wordsId = I('words_id','');
+        $courseId = I('course_id','');
+        //M('Words')->where(array('words_id'=>$wordsId))->save(array('is_delete'=>2));
+        M('Words')->where(array('words_id'=>$wordsId))->delete();
+        M('Course')->where(array('course_id'=>$courseId))->setDec('course_num');
+        $this->success('单词删除成功','/admin/course/detail/index?course_id='.$courseId);
+    }
+    
+    //获取单词信息接口
+    public function dict(){
+        $wordsFields = array('n','pron','adj','num','v','adv','art','prep','conj','int','vt','vi','other',);
+        $wordsName = I('words_name','');
+        if (empty($wordsName)){
+            $data = array('code'=>1,'msg'=>'单词不能为空');
+            echo json_encode($data);
+        }
+        $httpCurl = new \Org\Net\HttpCurl();
+        $url = C('TRANS').'&w='.$wordsName;
+        $res = $httpCurl->get($url,'xml');
+        $res = json_decode(json_encode(simplexml_load_string($res, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+        /* $url = C('TRANS').'&type=json&w='.$wordsName;
+        $res = $httpCurl->get($url); */
+        
+        if (!isset($res['key'])){
+            $data = array('code'=>1,'msg'=>'单词翻译出错');
+            echo json_encode($data);
+        }
+        if (isset($res['ps'])){
+            if (!is_array($res['ps'])){
+                $data['data']['ps'][] = $res['ps'];
+            }else{
+                $data['data']['ps'] = $res['ps'];
+            }
+        }else{
+            $data['data']['ps'] = array();
+        }
+        if (isset($res['pron'])){
+            if (!is_array($res['pron'])){
+                $data['data']['pron'][] = $res['pron'];
+            }else{
+                $data['data']['pron'] = $res['pron'];
+            }
+            /* $data['data']['pron'] = array(
+                'http://res.iciba.com/resource/amp3/0/0/c4/7d/c47d187067c6cf953245f128b5fde62a.mp3',
+                'http://res.iciba.com/resource/amp3/0/0/34/d1/34d1f91fb2e514b8576fab1a75a89a6b.mp3'
+            ); */
+        }else{
+            $data['data']['pron'] = array();
+        }
+        if (isset($res['pos']) && !empty($res['pos'])){
+            if (is_array($res['pos'])){
+                foreach ($res['pos'] as $k=>$v){
+                    $key = str_replace('.', '', $v);
+                    if (!in_array($key, $wordsFields)){
+                        $pos[] = array('other', trim($res['acceptation'][$k]));
+                    }else{
+                        $pos[] = array($key, trim($res['acceptation'][$k]));
+                    }
+                }
+            }else{
+                $key = str_replace('.', '', $res['pos']);
+                //$pos[] = array(str_replace('.', '', $res['pos']),trim($res['acceptation']));
+                if (!in_array($key, $wordsFields)){
+                    $pos[] = array('other', trim($res['acceptation']));
+                }else{
+                    $pos[] = array($key, trim($res['acceptation']));
+                }
+                /* if (isset($wordsKeys[str_replace('.', '', $res['pos'])])){
+                    $pos[] = array(str_replace('.', '', $res['pos']),trim($res['acceptation']));
+                }else{
+                    $pos[] = array('words_other',trim($res['acceptation']));
+                } */
+            }
+            $data['data']['pos'] = $pos;
+        }else{
+            $pos[] = array('other', trim($res['acceptation']));
+            $data['data']['pos'] = $pos;
+        }
+        if (isset($res['sent'])){
+            if (empty($res['sent'][0])){
+                $sent[] = array(trim($res['sent']['orig']),trim($res['sent']['trans']));
+            }else{
+                foreach ($res['sent'] as $k=>$v){
+                    if ($k>2){
+                        continue;
+                    }
+                    $sent[] = array(trim($v['orig']),trim($v['trans']));
+                }
+            }
+            $data['data']['sent'] = $sent;
+        }
+        $data['code'] = 0;
+        $this->ajaxReturn($data);exit;
+    }
+}

+ 1 - 0
www.hanlinyuanonline.com/Application/Admin/Controller/index.html

@@ -0,0 +1 @@
+ 

+ 40 - 0
www.hanlinyuanonline.com/Application/Admin/Model/CourseModel.class.php

@@ -0,0 +1,40 @@
+<?php
+namespace Admin\Model;
+use Think\Model;
+
+class CourseModel extends Model{
+    /* public function getCourseList($condition, $page, $pageSize, $orderby){
+        $condition[] = 'A.user_id = B.user_id';
+        $condition['A.is_delete'] = 1;
+        $fields = 'A.*,B.user_name,B.user_nickname,B.user_phone';
+        return $this->table('t_course A, t_user B')->where($condition)->field($fields)->order($orderby)->limit($page, $pageSize)->select();
+    } */
+    public function  getCourseList($condition, $page, $pageSize, $orderby){
+        $condition['is_delete']=1;
+        $res = M('Course')->where($condition)->field('course_id,course_status,user_id,course_flag,course_name,course_join,course_num,course_source,operate_dt')
+        ->order($orderby)->limit($page, $pageSize)->select();
+        $userInfo = array();
+        foreach ($res as $key=>$row){
+            if ($row['course_source']==1){
+                $res[$key]['user_name'] = '系统课程';
+                //$res[$key]['user_icon'] = C('DOMAIN').'/Public/img/admin_icon.png';
+                $res[$key]['user_icon'] = '/Public/img/admin_icon.png';
+                $res[$key]['user_city'] = '';
+                $res[$key]['user_province'] = '';
+            }else{
+                if (isset($userInfo[$row['user_id']])){
+                    $info = $userInfo[$row['user_id']];
+                }else{
+                    $info = M('User')->where(array('user_id'=>$row['user_id']))->field('user_name,user_phone,user_icon,user_city,user_province')->find();
+                    $userInfo[$row['user_id']] = $info;
+                }
+                $res[$key]['user_name'] = $info['user_name'];
+                $res[$key]['user_phone'] = $info['user_phone'];
+                $res[$key]['user_icon'] = $info['user_icon'];
+                $res[$key]['user_city'] = $info['user_city'];
+                $res[$key]['user_province'] = $info['user_province'];
+            }
+        }
+        return $res;
+    }
+}

+ 21 - 0
www.hanlinyuanonline.com/Application/Admin/Model/FeedbackModel.class.php

@@ -0,0 +1,21 @@
+<?php
+namespace Admin\Model;
+use Think\Model;
+
+class FeedbackModel extends Model{
+    public function getFbList($condition, $page, $pageSize){
+        $condition[] = 'A.words_id = B.words_id';
+        $condition[] = 'A.course_id = C.course_id';
+        $condition[] = 'A.user_id = D.user_id';
</