AdminController.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443
  1. <?php
  2. /**
  3. * 纵横后台
  4. * @author cp
  5. */
  6. if (! defined ( 'IN_ZHASK' )) {
  7. exit ( 'invalid request' );
  8. }
  9. class AdminController extends DooController {
  10. private $userlogic;
  11. private $asklogic;
  12. private $adminlogic;
  13. private $menu = array ('navon' => array () );
  14. private $userinfo = array ('uid' => '0' );
  15. function __construct() {
  16. //parent::__construct ();
  17. Load::controller ( "BaseController" );
  18. $base = new BaseController ();
  19. $rs = $base->admin_init ();
  20. $this->userinfo = $rs ['userinfo'];
  21. $this->menu = $rs ['menu'];
  22. Load::logic ( 'User' );
  23. Load::logic ( 'Ask' );
  24. Load::logic ( 'Admin' );
  25. $this->userlogic = new UserLogic ();
  26. $this->asklogic = new AskLogic ();
  27. $this->adminlogic = new AdminLogic ();
  28. }
  29. /**
  30. * 进入后台登录页面
  31. */
  32. function login() {
  33. $data ['user_info'] = $this->userinfo;
  34. $this->render ( '/admin/login', $data );
  35. }
  36. /**
  37. * 用户登出
  38. */
  39. function admin_user_exit() {
  40. setcookie ( "auth_main", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );
  41. $this->Messager ( "登出成功", "/" );
  42. }
  43. /**
  44. * 进入后台
  45. */
  46. function do_login() {
  47. $data ['name'] = $this->get_args ( 'name' );
  48. $data ['password'] = $this->get_args ( 'password' );
  49. $user = $this->userlogic->get_users_by_name ( $data ['name'] );
  50. require_once (SITE_PATH . '/protected/plugin/client.php');
  51. $client = new client ( ZHSSO );
  52. $is_login = $client->zhsso_member_login ( $data ['name'], $data ['password'] );
  53. $is_login = explode ( "\r", $is_login );
  54. if (is_numeric ( $is_login [0] )) {
  55. if ($is_login [0] == USERNAME_ONFINE) {
  56. $this->Messager ( "您输入的帐号或者密码有误", "/login" );
  57. //删除用户相关记录--是否有同步删除功能
  58. if ($user) {
  59. //$this->userlogic->delete_user_tem( $user['uid']);
  60. }
  61. } elseif ($is_login [0] == PASSWORD_ERROR)
  62. $this->Messager ( "您输入的帐号或者密码有误", "/login" );
  63. elseif ($is_login [0] == - 3) //USER_NOACTION
  64. $this->Messager ( "用户未激活", "http://sso.smartcost.com.cn/" );
  65. } elseif (! empty ( $is_login [0] )) {
  66. $group = $this->userlogic->get_group_by_id ( $user ['groupid'] );
  67. if ($group ['grouptype'] != 1) {
  68. setcookie ( "auth_main", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );
  69. header ( 'Content-Type:text/html;charset=utf-8' );
  70. @header ( "Location: " . WEB_SITE . "/messager?content=无权进入后台&url=/" );
  71. }
  72. $userinfo = authcode ( $user ['username'], "tr" );
  73. setcookie ( "auth_main", $userinfo, time () + 3600 * 24, "/", COOKIE_WEB_SITE );
  74. define ( 'MEMBER_NAME', $user ['username'] );
  75. define ( "MASTER_ID", $user ['uid'] );
  76. $data ['now'] = 'use';
  77. $data ['li'] = $this->menu ['navon'];
  78. $data ['map'] = '';
  79. header ( 'Content-Type:text/html;charset=utf-8' );
  80. @header ( "Location: " . WEB_SITE . "/index/main_navon" );
  81. }
  82. // //对登录用户认证
  83. // if (empty ( $data ['name'] ) || empty ( $data ['password'] ) || $user_info ['username'] != $data ['name'] || $user_info ['password'] != md5 ( $data ['password'] )) {
  84. //
  85. // $this->Messager ( "请输入正确的账号密码", "/index/main_admin" );
  86. // } else {
  87. // //登录成功-写入session
  88. // $data ['now'] = 'use';
  89. //
  90. // $data ['li'] = $this->menu ['navon'];
  91. //
  92. // $data ['map'] = '';
  93. //
  94. // $this->render ( '/admin/index', $data );
  95. //
  96. // }
  97. }
  98. /**
  99. * 常用操作
  100. */
  101. function navon() {
  102. $data ['now'] = 'use';
  103. $data ['li'] = $this->menu ['navon'];
  104. $data ['map'] = '';
  105. $this->render ( '/admin/index', $data );
  106. }
  107. /**
  108. * 获取后台欢迎页
  109. */
  110. function welcome() {
  111. $this->render ( '/admin/welcome' );
  112. }
  113. /**
  114. * 获取用户管理
  115. */
  116. function user_manage() {
  117. $u = "";
  118. $n = "";
  119. $e = "";
  120. $i = "";
  121. $t = "";
  122. $on_page = is_numeric ( $this->params ['on_page'] ) ? $this->params ['on_page'] : 1;
  123. if ($on_page <= 0)
  124. $on_page = 1;
  125. $uid = $this->get_args ( 'uid' );
  126. $uid = is_numeric ( $uid ) ? $uid : 0;
  127. $name = $this->get_args ( 'name' );
  128. $email = $this->get_args ( 'email' );
  129. $regip = $this->get_args ( 'regip' );
  130. $srchregdatestart = $this->get_args ( 'srchregdatestart' );
  131. $srchregdateend = $this->get_args ( 'srchregdateend' );
  132. $page_size = 18;
  133. //检索条件
  134. if ($uid)
  135. $u = " and uid=" . $uid;
  136. if (! empty ( $name ))
  137. $n = " and username like '%" . $name . "%'";
  138. if (! empty ( $email ))
  139. $e = " and email like '%" . $email . "%'";
  140. if (! empty ( $regip ))
  141. $e = " and regip like '%" . $regip . "%'";
  142. if (! empty ( $srchregdatestart ) && ! empty ( $srchregdateend )) {
  143. $srchregdatestart = get_time ( $srchregdatestart );
  144. $srchregdateend = get_time ( $srchregdateend );
  145. $t = " and regtime between " . $srchregdatestart . " and " . $srchregdateend;
  146. }
  147. $condition = " and uid!= 1 " . $u . $n . $e . $i . $t;
  148. $action = "/index/main_user_manage/";
  149. //获取分页相关数据
  150. $page = $this->adminlogic->get_page ( t_user, $condition, $on_page, $page_size, $action, "", "admin" );
  151. $limit = " order by regtime desc limit " . $page ['lower'] . " , " . $page_size . " ";
  152. $page ['user_list'] = $this->userlogic->get_users_list ( array (), $condition, $limit );
  153. $data ['map'] = '用户管理';
  154. $data ['user'] = $page;
  155. $this->render ( '/admin/user_manage', $data );
  156. }
  157. /**
  158. * 添加用户-需要推送用户到通行证
  159. */
  160. function user_manage_add() {
  161. $data ['map'] = '<a href="/index/main_user_manage" target="main" >用户管理</a> » 添加用户';
  162. $this->render ( '/admin/user_manage_add', $data );
  163. }
  164. /**
  165. * 进入编辑用户基本信息
  166. */
  167. function user_manage_edit() {
  168. $uid = $this->check_params ( "uid" );
  169. if (is_numeric ( $uid )) {
  170. if ($uid == SUPER_ADMIN_UID || $uid <= 0) {
  171. echo "请输入正确请求";
  172. die ();
  173. }
  174. } else {
  175. echo "请输入正确请求";
  176. die ();
  177. }
  178. $data ['user'] = $this->userlogic->get_users_information ( $uid );
  179. $data ['group'] = $this->userlogic->get_group ();
  180. $data ['categoryinfo'] = $this->asklogic->get_category_list ();
  181. $data ['map'] = '<a href="/index/main_user_manage" target="main" >用户管理</a> » 编辑用户';
  182. $data ['success'] = "";
  183. $this->render ( '/admin/user_manage_edit', $data );
  184. }
  185. /**
  186. * 修改用户信息
  187. */
  188. function user_manage_update() {
  189. $params ['uid'] = $this->get_args ( 'uid' );
  190. $params ['password'] = $this->get_args ( 'password' );
  191. $confirmpw = $this->get_args ( 'confirmpw' );
  192. $params ['email'] = $this->get_args ( 'email' );
  193. $params ['groupid'] = $this->get_args ( 'groupid' );
  194. $params ['credits'] = $this->get_args ( 'credits' );
  195. $params ['credit1'] = $this->get_args ( 'credit1' );
  196. $params ['gender'] = $this->get_args ( 'gender' );
  197. $params ['bday'] = $this->get_args ( 'bday' );
  198. $params ['phone'] = $this->get_args ( 'phone' );
  199. $params ['qq'] = $this->get_args ( 'qq' );
  200. $params ['msn'] = $this->get_args ( 'msn' );
  201. $params ['signature'] = $this->get_args ( 'signature' );
  202. $params ['expert'] = $this->get_args ( 'expert' );
  203. $params ['cids'] = json_encode ( $_POST ['cids'] );
  204. if ($params ['password'] != $confirmpw) {
  205. echo "密码不一致";
  206. die ();
  207. }
  208. if (is_numeric ( $params ['uid'] )) {
  209. if ($params ['uid'] == SUPER_ADMIN_UID || $params ['uid'] <= 0) {
  210. echo "请输入正确请求";
  211. die ();
  212. }
  213. } else {
  214. echo "请输入正确请求";
  215. die ();
  216. }
  217. $this->userlogic->update_user ( $params );
  218. $data ['user'] = $this->userlogic->get_users_information ( $params ['uid'] );
  219. $data ['group'] = $this->userlogic->get_group ();
  220. $data ['map'] = '<a href="/index/main_user_manage" target="main" >用户管理</a> » 编辑用户';
  221. $data ['success'] = "编辑成功";
  222. header ( 'Content-Type:text/html;charset=utf-8' );
  223. @header ( "Location: /index/main_user_manage_edit/" . $params ['uid'] );
  224. }
  225. /**
  226. * 删除用户
  227. */
  228. function user_manage_delete() {
  229. $type = $this->check_params ( "type" );
  230. $uid = $this->get_args ( 'uid' );
  231. if ($type == "all") {
  232. $this->userlogic->delete_user_and_QA ( $uid );
  233. } else {
  234. $this->userlogic->delete_user ( $uid );
  235. }
  236. Header ( "Location:/index/main_user_manage" );
  237. }
  238. /**
  239. * 用户积分明细
  240. */
  241. function user_manage_credit() {
  242. $uid = $this->check_params ( "uid" );
  243. $data ['map'] = '<a href="/index/main_user_manage" target="main" >用户管理</a> » 用户积分明细';
  244. $data ['creditList'] = $this->asklogic->get_credit_details ( $uid );
  245. $this->render ( '/admin/user_manage_credits', $data );
  246. }
  247. /**
  248. * 专家用户
  249. */
  250. function user_manage_expert() {
  251. $data ['map'] = '专家管理 ';
  252. $param ['expert'] = 1;
  253. $data ['userExpert'] = $this->userlogic->get_users_list ( $param, '', "" );
  254. $this->render ( '/admin/user_manage_expert', $data );
  255. }
  256. /**
  257. * 进入用户组管理
  258. */
  259. function group_manage() {
  260. $data ['group'] = $this->userlogic->get_group ();
  261. $data ['map'] = '用户组管理 ';
  262. $data ['success'] = "";
  263. $this->render ( '/admin/group_manage', $data );
  264. }
  265. /**
  266. * 用户组管理-添加
  267. */
  268. function group_manage_add() {
  269. $params ['grouptitle'] = $this->get_args ( 'grouptitle' );
  270. if (empty ( $params ['grouptitle'] ))
  271. die ( '用户组名称为空' );
  272. $this->userlogic->add_group ( $params );
  273. $data ['group'] = $this->userlogic->get_group ();
  274. $data ['map'] = '用户组管理 ';
  275. $data ['success'] = "<span style='color:red'>添加成功</span>";
  276. $this->render ( '/admin/group_manage', $data );
  277. }
  278. /**
  279. * 用户组管理-编辑
  280. */
  281. function group_manage_edit() {
  282. $params ['groupid'] = $this->get_args ( 'groupid' );
  283. $params ['grouptitle'] = $this->get_args ( 'grouptitle' );
  284. $params ['creditslower'] = $this->get_args ( 'scorelower' );
  285. $this->userlogic->update_group_list ( $params );
  286. $data ['group'] = $this->userlogic->get_group ();
  287. $data ['map'] = '用户组管理';
  288. $data ['success'] = "<span style='color:red'>编辑成功</span> ";
  289. $this->render ( '/admin/group_manage', $data );
  290. }
  291. /**
  292. * 用户组管理-删除
  293. */
  294. function group_manage_delete() {
  295. $groupid = $this->check_params ( "groupid" );
  296. if (is_numeric ( $groupid )) {
  297. if ($groupid == SUPER_ADMIN_ID || $groupid <= 0) {
  298. echo "请输入正确请求";
  299. die ();
  300. }
  301. } else {
  302. echo "请输入正确请求";
  303. die ();
  304. }
  305. $this->userlogic->delete_group ( $groupid );
  306. $data ['group'] = $this->userlogic->get_group ();
  307. $data ['map'] = '用户组管理 ';
  308. $data ['success'] = "<span style='color:red'>删除成功</span> ";
  309. $this->render ( '/admin/group_manage', $data );
  310. }
  311. /**
  312. * 用户组管理-权限设置
  313. */
  314. function group_manage_set() {
  315. $data ['map'] = '用户组权限设置 ';
  316. $data ['success'] = "<span style='color:red'></span> ";
  317. $data ['groupid'] = $this->check_params ( 'groupid' );
  318. $data ['group'] = $this->userlogic->get_group_by_id ( $data ['groupid'] );
  319. $data ['PERMISSIONS'] = Doo::conf ()->PERMISSIONS_ACTION;
  320. include SITE_PATH . '/protected/config/permissions.conf.php';
  321. $data ['PERMISSIONS_user'] = "";
  322. if (isset ( $config ['GENERAL_USER_lv' . $data ['groupid']] ))
  323. $data ['PERMISSIONS_user'] = $config ['GENERAL_USER_lv' . $data ['groupid']];
  324. $this->render ( '/admin/group_manage_set', $data );
  325. }
  326. /**
  327. * 为用户组设置权限
  328. */
  329. function group_manage_update_set() {
  330. $permissions=$this->get_args('permissons_key');
  331. $b=array('##USER7','##/USER7');
  332. $Content="<USER7>
  333. \$config['GENERAL_USER_lv7']=array('index',
  334. 'show_ask_page',
  335. 'login',
  336. 'show_into_home',
  337. 'show_home_answer',
  338. 'show_home_question',
  339. 'do_login',
  340. 'upload_question_img',
  341. 'show_home_per_info',
  342. 'show_home_avatar',
  343. 'show_home_message',
  344. 'show_vip_ask_post',
  345. 'show_ask_post',
  346. 'show_post_enter',
  347. 'show_search',
  348. 'do_support_answer',
  349. 'do_edit_answer',
  350. 'do_edit_question',
  351. 'do_up_price',
  352. 'do_add_supply',
  353. 'upload_avatar',
  354. 'do_update_vip_question',
  355. 'do_add_vip_question',
  356. 'do_delete_answer',
  357. 'do_delete_question',
  358. 'do_question_close',
  359. 'do_update_user_info',
  360. 'do_update_avatar',
  361. 'answer_again',
  362. 'do_reply_question',
  363. 'to_ask_question',
  364. 'do_add_vip_question',
  365. 'do_add_question',
  366. 'show_advisory_page',
  367. 'user_exit',
  368. //编辑问题
  369. 'do_edit_vip_question',
  370. //设置满意
  371. 'set_vip_question_satisfy',
  372. //设置不满意
  373. 'set_vip_question_nosatisfy',
  374. //追加回答
  375. 'do_add_vip_tag',
  376. //评价回答
  377. 'do_comment_vip_answer',
  378. //添加评论
  379. 'do_add_discuss',
  380. //获取退款机会
  381. 'get_vip_refunds',
  382. //交易
  383. 'show_my_pay_oder',
  384. //充值
  385. 'show_my_recharge',
  386. //登录
  387. 'do_login_index',
  388. //充值记录
  389. 'show_recharge_oder',
  390. //编辑邮件
  391. 'do_add_email_config',
  392. 'do_best_answer',
  393. 'show_article_page',
  394. 'show_messager',
  395. 'show_tip2',
  396. 'get_search_works',
  397. );
  398. <USER7>";
  399. $Content="<USER7>fsdfsdfsdfwerewr</USER7>";
  400. preg_match("<USER7>(.*)</USER7>",$Content,$kk);
  401. //ereg_replace("PHP","",$temp)
  402. //preg_replace("^##USER7 ##USER7$", " \$config['GENERAL_USER_lv7']=array() ", $Content);
  403. echo $kk;
  404. // foreach ($permissions as $value){
  405. //
  406. // }
  407. //print_r($permissions);
  408. }
  409. /**
  410. * 进去问题管理-
  411. */
  412. function question_manage() {
  413. $u = "";
  414. $n = "";
  415. $e = "";
  416. $i = "";
  417. $t = "";
  418. $on_page = $this->check_params ( 'on_page' );
  419. $on_page = is_numeric ( $on_page ) ? $on_page : 1;
  420. $authorid = $this->get_args ( 'authorid' );
  421. $title = $this->get_args ( 'title' );
  422. $status = $this->get_args ( 'status' );
  423. $srchregdatestart = $this->get_args ( 'srchregdatestart' );
  424. $srchregdateend = $this->get_args ( 'srchregdateend' );
  425. $page_size = 18;
  426. //检索条件
  427. if ($authorid)
  428. $u = " and author like '%" . $authorid . "%'";
  429. if (! empty ( $title ))
  430. $n = " and title like '%" . $title . "%'";
  431. if ($status >= 1)
  432. $e = " and status = " . $status;
  433. if (! empty ( $srchregdatestart ) && ! empty ( $srchregdateend )) {
  434. $srchregdatestart = get_time ( $srchregdatestart );
  435. $srchregdateend = get_time ( $srchregdateend );
  436. $t = " and time between " . $srchregdatestart . " and " . $srchregdateend;
  437. }
  438. $condition = ' and 1 ' . $u . $n . $e . $i . $t;
  439. $action = "/index/main_question_manage/";
  440. $get = "?status=" . $status . "&authorid=" . $authorid . "&title=" . $title . "&srchregdatestart=" . $srchregdatestart . "&srchregdateend=" . $srchregdateend;
  441. //获取分页相关数据
  442. $page = $this->adminlogic->get_page ( t_question, $condition, $on_page, $page_size, $action, $get, "admin" );
  443. $limit = " order by time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  444. $data ['category'] = $this->asklogic->get_category_list ();
  445. $page ['question_list'] = $this->asklogic->get_questions_list_tem ( array (), $condition, $limit );
  446. $data ['question'] = $page;
  447. $data ['status'] = $status;
  448. $data ['authorid'] = $authorid;
  449. $data ['title'] = $title;
  450. $data ['srchregdatestart'] = $srchregdatestart;
  451. $data ['srchregdateend'] = $srchregdateend;
  452. $data ['map'] = '问题管理 ';
  453. $data ['success'] = "<span style='color:red'></span> ";
  454. $this->render ( '/admin/question_manage', $data );
  455. }
  456. /**
  457. * 移动问题分类
  458. */
  459. function question_manage_move_category() {
  460. }
  461. /**
  462. * 批量关闭问题
  463. */
  464. function question_manage_close() {
  465. $id = $this->get_args ( 'id' );
  466. $status = array ();
  467. $params ['id'] = $id;
  468. for($i = 0; $i < count ( $id ); $i ++) {
  469. array_push ( $status, 9 );
  470. }
  471. $params ['status'] = $status;
  472. $this->userlogic->update_list ( $params, t_question, "id" );
  473. Header ( "Location:/index/main_question_manage" );
  474. }
  475. /**
  476. * 批量删除问题
  477. */
  478. function question_manage_delete() {
  479. $id = $this->get_args ( 'id' );
  480. if (empty ( $id ))
  481. return "/index/main_question_manage";
  482. //推广
  483. //;$id = implode ( ",", $id );
  484. $fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
  485. if($fundstr){
  486. foreach ($id as $value){
  487. Doo::loadModel ( 'QuestionDao' );
  488. $questionDao = new QuestionDao ();
  489. $question=$questionDao->get_question_by_id($value);
  490. if($question['price']==1&&$question['status']=1){
  491. Doo::loadModel ( 'FundDao' );
  492. $funddao = new FundDao ();
  493. $fund=$funddao->get_fund_by_amount();
  494. if(!empty($fund)){
  495. $funddao->set_fund_amount_spread("+1",$fund['id']);
  496. }
  497. }
  498. }
  499. }
  500. $this->userlogic->delete_question_list ( $id );
  501. Header ( "Location:/index/main_question_manage" );
  502. }
  503. /**
  504. * 批量设置问题为待解决
  505. */
  506. function question_manage_set_status() {
  507. //只针对已关闭的问题进行操作--是否还有RMB问题
  508. $id = $this->get_args ( 'id' );
  509. $this->userlogic->update_question_list ( $id );
  510. return "/index/main_question_manage";
  511. }
  512. /**
  513. * 进去回答管理-
  514. */
  515. function answer_manage() {
  516. $u = "";
  517. $n = "";
  518. $e = "";
  519. $i = "";
  520. $t = "";
  521. $on_page = $this->check_params ( 'on_page' );
  522. $on_page = is_numeric ( $on_page ) ? $on_page : 1;
  523. $authorid = $this->get_args ( 'author' );
  524. $title = $this->get_args ( 'title' );
  525. $srchregdatestart = $this->get_args ( 'srchregdatestart' );
  526. $srchregdateend = $this->get_args ( 'srchregdateend' );
  527. $page_size = 18;
  528. //检索条件
  529. if ($authorid)
  530. $u = " and author like '%" . $authorid . "%'";
  531. if (! empty ( $title ))
  532. $n = " and title like '%" . $title . "%'";
  533. if (! empty ( $srchregdatestart ) && ! empty ( $srchregdateend )) {
  534. $srchregdatestart = get_time ( $srchregdatestart );
  535. $srchregdateend = get_time ( $srchregdateend );
  536. $t = " and time between " . $srchregdatestart . " and " . $srchregdateend;
  537. }
  538. $condition = $u . $n . $t;
  539. $action = "/index/main_answer_manage/";
  540. $get = "?author=" . $authorid . "&title=" . $title . "&srchregdatestart=" . $srchregdatestart . "&srchregdateend=" . $srchregdateend;
  541. //获取分页相关数据
  542. $page = $this->adminlogic->get_page ( t_answer, $condition, $on_page, $page_size, $action, $get, "admin" );
  543. $limit = " order by time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  544. $data ['category'] = $this->asklogic->get_category_list ();
  545. $answer_list = $this->asklogic->get_answers_list_tem ( array (), $condition, $limit );
  546. foreach ( $answer_list as $key => $value ) {
  547. $answer_list [$key] ['content'] = strip_tags ( $value ['content'] );
  548. }
  549. $page ['answer_list'] = $answer_list;
  550. $data ['answer'] = $page;
  551. $data ['author'] = $authorid;
  552. $data ['title'] = $title;
  553. $data ['srchregdatestart'] = $srchregdatestart;
  554. $data ['srchregdateend'] = $srchregdateend;
  555. $data ['map'] = '回答管理 ';
  556. $data ['success'] = "<span style='color:red'></span> ";
  557. $this->render ( '/admin/answer_manage', $data );
  558. }
  559. /**
  560. * 回答管理-删除回答
  561. */
  562. function answer_manage_delete() {
  563. $data ['map'] = '回答管理 ';
  564. $data ['success'] = "<span style='color:red'></span> ";
  565. $id = $this->get_args ( 'id' );
  566. if (empty ( $id ))
  567. return "/index/main_answer_manage";
  568. $this->userlogic->delete_answer_list ( $id );
  569. return "/index/main_answer_manage";
  570. }
  571. /**
  572. * 名师答疑管理
  573. */
  574. function vip_question_manage() {
  575. $u = "";
  576. $n = "";
  577. $e = "";
  578. $i = "";
  579. $t = "";
  580. $on_page = $this->check_params ( 'on_page' );
  581. $on_page = is_numeric ( $on_page ) ? $on_page : 1;
  582. $authorid = $this->get_args ( 'authorid' );
  583. $title = $this->get_args ( 'title' );
  584. $status = $this->get_args ( 'status' );
  585. $srchregdatestart = $this->get_args ( 'srchregdatestart' );
  586. $srchregdateend = $this->get_args ( 'srchregdateend' );
  587. $page_size = 18;
  588. //检索条件
  589. if ($authorid)
  590. $u = " and author like '%" . $authorid . "%'";
  591. if (! empty ( $title ))
  592. $n = " and title like '%" . $title . "%'";
  593. if ($status >= 1)
  594. $e = " and status = " . $status;
  595. if (! empty ( $srchregdatestart ) && ! empty ( $srchregdateend )) {
  596. $srchregdatestart = get_time ( $srchregdatestart );
  597. $srchregdateend = get_time ( $srchregdateend );
  598. $t = " and time between " . $srchregdatestart . " and " . $srchregdateend;
  599. }
  600. $nowtime = get_time ();
  601. $condition = " " . $u . $n . $e . $i . $t;
  602. $action = "/index/main_vip_question_manage/";
  603. $get = "?status=" . $status . "&authorid=" . $authorid . "&title=" . $title . "&srchregdatestart=" . $srchregdatestart . "&srchregdateend=" . $srchregdateend;
  604. //获取分页相关数据
  605. $page = $this->adminlogic->get_page ( t_vipquestion, $condition, $on_page, $page_size, $action, $get, "admin" );
  606. $limit = " order by time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  607. $data ['category'] = $this->asklogic->get_category_list ();
  608. $page ['question_list'] = $this->asklogic->get_vip_questions_list_admin ( array (), $condition, $limit, "vip" );
  609. $data ['question'] = $page;
  610. $data ['status'] = $status;
  611. $data ['authorid'] = $authorid;
  612. $data ['title'] = $title;
  613. $data ['srchregdatestart'] = $srchregdatestart;
  614. $data ['srchregdateend'] = $srchregdateend;
  615. $data ['map'] = '名师答疑管理 ';
  616. $data ['success'] = "<span style='color:red'></span> ";
  617. $this->render ( '/admin/vip_question_manage', $data );
  618. }
  619. /**
  620. * 编辑回答
  621. */
  622. function vip_question_edit_manage() {
  623. $id = $this->check_params ( 'id' );
  624. $id = is_numeric ( $id ) && $id > 0 ? $id : 1;
  625. $data ['vip_question'] = $this->asklogic->get_vip_questions_by_id ( $id );
  626. //获取回答
  627. $data ['vip_answer'] = $this->asklogic->get_vip_answer_by_id ( $id );
  628. $data ['map'] = '名师答疑管理 ';
  629. $this->render ( '/admin/vip_question_page_manage', $data );
  630. }
  631. /**
  632. * 回答名师答疑
  633. */
  634. function vip_question_add_answer_manage() {
  635. $id = $this->get_args ( 'qid' );
  636. $aid = $this->get_args ( 'aid' );
  637. $content = stripcslashes ( $this->get_args ( 'content_text' ) );
  638. $id = is_numeric ( $id ) && $id > 0 ? $id : 0;
  639. $data ['vip_question'] = $this->asklogic->get_vip_questions_by_id ( $id );
  640. $params ['id'] = array (0 => $aid );
  641. $params ['qid'] = array (0 => $id );
  642. $params ['content'] = array (0 => $content );
  643. $params ['title'] = array (0 => $data ['vip_question'] ['title'] );
  644. $params ['time'] = array (0 => get_date () );
  645. $params ['ip'] = array (0 => client_ip () );
  646. //加入回答
  647. $this->userlogic->update_list ( $params, t_vipanswer, "qid" );
  648. //发邮件
  649. $this->userlogic->send_email ( $data ['vip_question'] ['authorid'], "VIP_NEW_ANSWER", $id, 0 );
  650. //更新检索库
  651. $params ['vip_question'] = $data ['vip_question'];
  652. $ans ['time'] = get_date ();
  653. $ans ['content'] = $content;
  654. $answer = serialize ( array (0 => $ans ) );
  655. $params ['answer'] = $answer;
  656. $this->userlogic->update_vip_question_search ( $params );
  657. //发送系统信息
  658. $this->userlogic->update_vip_question_by_answers ( $id );
  659. $subject = "您的" . $data ['vip_question'] ['title'] . "问题有了新的回答";
  660. $content = "名师答疑-问题&nbsp;<a href=/advisory_page/" . $id . ">" . $data ['vip_question'] ['title'] . "</a>&nbsp;有了新的回答";
  661. $this->userlogic->send_sys_message ( $subject, $content, $data ['vip_question'] ['authorid'] );
  662. //获取回答
  663. $data ['vip_answer'] = $this->asklogic->get_vip_answer_by_id ( $id );
  664. $data ['map'] = '名师答疑管理 ';
  665. $this->render ( '/admin/vip_question_page_manage', $data );
  666. }
  667. /**
  668. * 回答追问--加入检索库
  669. */
  670. function vip_question_add_answeragain_manage() {
  671. $id = $this->get_args ( 'qid' );
  672. $content = stripcslashes ( $this->get_args ( 'answer_again_text' ) );
  673. $id = is_numeric ( $id ) && $id > 0 ? $id : 0;
  674. $data ['vip_question'] = $this->asklogic->get_vip_questions_by_id ( $id );
  675. //获取回答
  676. $data ['vip_answer'] = $this->asklogic->get_vip_answer_by_id ( $id );
  677. //加入追问
  678. $this->userlogic->update_vip_answer ( $content, $data ['vip_answer'] ['id'], $data ['vip_answer'] ['tag'] );
  679. //发邮件
  680. $this->userlogic->send_email ( $data ['vip_question'] ['authorid'], "VIP_FOLLOW_ANSWER", $id, 0 );
  681. //加入检索库
  682. $params ['vip_question'] = $data ['vip_question'];
  683. $answer = $data ['vip_answer'];
  684. $ans ['aid'] = $answer ['id'];
  685. $ans ['time'] = $answer ['time'];
  686. $ans ['content'] = $answer ['content'];
  687. $ans ['comment'] = $answer ['comment'];
  688. $tag_list = unserialize ( $answer ['tag'] );
  689. array_push ( $tag_list, $content );
  690. $tag = serialize ( $tag_list );
  691. $ans ['tag'] = $tag;
  692. $answer = serialize ( array (0 => $ans ) );
  693. $params ['answer'] = $answer;
  694. $this->userlogic->update_vip_question_search ( $params );
  695. //发送系统信息
  696. $this->userlogic->update_vip_question_by_answers ( $id );
  697. $subject = "您的" . $data ['vip_question'] ['title'] . "问题回答了您的追问";
  698. $content = "名师答疑-问题&nbsp;<a href=/advisory_page/" . $id . " >" . $data ['vip_question'] ['title'] . "</a>&nbsp;回答了追问";
  699. $this->userlogic->send_sys_message ( $subject, $content, $data ['vip_question'] ['authorid'] );
  700. $data ['map'] = '名师答疑管理 ';
  701. $this->render ( '/admin/vip_question_page_manage', $data );
  702. }
  703. /**
  704. * 公告管理
  705. */
  706. function article_manage() {
  707. $n = "";
  708. $t = "";
  709. $on_page = $this->check_params ( 'on_page' );
  710. $on_page = is_numeric ( $on_page ) ? $on_page : 1;
  711. $title = $this->get_args ( 'title' );
  712. $srchregdatestart = $this->get_args ( 'srchregdatestart' );
  713. $srchregdateend = $this->get_args ( 'srchregdateend' );
  714. $page_size = 18;
  715. //检索条件
  716. if (! empty ( $title ))
  717. $n = " and title like '%" . $title . "%'";
  718. if (! empty ( $srchregdatestart ) && ! empty ( $srchregdateend )) {
  719. $srchregdatestart = get_time ( $srchregdatestart );
  720. $srchregdateend = get_time ( $srchregdateend );
  721. $t = " and time between " . $srchregdatestart . " and " . $srchregdateend;
  722. }
  723. $condition = $n . $t;
  724. $action = "/index/main_article_manage/";
  725. $get = "?title=" . $title . "&srchregdatestart=" . $srchregdatestart . "&srchregdateend=" . $srchregdateend;
  726. //获取分页相关数据
  727. $page = $this->adminlogic->get_page ( t_article, $condition, $on_page, $page_size, $action, $get, "admin" );
  728. $limit = " order by time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  729. $page ['question_list'] = $this->asklogic->get_article_list ( array (), $condition, $limit );
  730. $data ['question'] = $page;
  731. $data ['title'] = $title;
  732. $data ['srchregdatestart'] = $srchregdatestart;
  733. $data ['srchregdateend'] = $srchregdateend;
  734. $data ['map'] = '公告管理 ';
  735. $data ['success'] = "<span style='color:red'></span> ";
  736. $this->render ( '/admin/article_manage', $data );
  737. }
  738. /**
  739. * 文章添加
  740. */
  741. function article_manage_add() {
  742. $params ['title'] = $this->get_args ( 'title' );
  743. $params ['content'] = stripcslashes ( $this->get_args ( 'content_text' ) );
  744. $is_add = $this->get_args ( 'is_add' );
  745. if (! empty ( $is_add )) {
  746. if (empty ( $params ['title'] ))
  747. die ( '标题为空' );
  748. if (empty ( $params ['content'] ))
  749. die ( '内容为空' );
  750. $this->userlogic->add_article ( $params );
  751. echo "添加成功&nbsp;<a href=/index/main_article_manage >点击进入公告</a>";
  752. die ();
  753. }
  754. $data ['map'] = '公告管理-添加 ';
  755. $data ['success'] = "";
  756. $this->render ( '/admin/article_manage_add', $data );
  757. }
  758. /**
  759. * 编辑公告
  760. */
  761. function article_manage_edit() {
  762. $params ['id'] = $this->check_params ( 'id' );
  763. $params ['title'] = $this->get_args ( 'title' );
  764. $params ['content'] = stripcslashes ( $this->get_args ( 'content_text' ) );
  765. $is_edit = $this->get_args ( 'is_edit' );
  766. if (! empty ( $is_edit )) {
  767. if (empty ( $params ['title'] ))
  768. die ( '标题为空' );
  769. if (empty ( $params ['content'] ))
  770. die ( '内容为空' );
  771. $params ['id'] = $this->get_args ( 'id' );
  772. $this->userlogic->update_article ( $params );
  773. echo "更新成功&nbsp;<a href=/index/main_article_edit_manage/" . $params ['id'] . " >点击进入公告</a>";
  774. die ();
  775. }
  776. $data ['article'] = $this->userlogic->get_article_by_id ( $params ['id'] );
  777. $data ['map'] = '公告管理-编辑 ';
  778. $data ['success'] = "";
  779. $this->render ( '/admin/article_manage_edit', $data );
  780. }
  781. /**
  782. * 删除公告
  783. */
  784. function article_manage_delete() {
  785. $id = $this->get_args ( 'id' );
  786. $this->userlogic->delete_article ( $id );
  787. Header ( "Location:/index/main_article_manage" );
  788. }
  789. /**
  790. * 分类管理
  791. */
  792. function category_manage() {
  793. $n = "";
  794. $on_page = $this->check_params ( 'on_page' );
  795. $on_page = is_numeric ( $on_page ) ? $on_page : 1;
  796. if ($on_page <= 0)
  797. $on_page = 1;
  798. $title = $this->get_args ( 'title' );
  799. $page_size = 18;
  800. //检索条件
  801. if (! empty ( $title ))
  802. $n = " and name like '%" . $title . "%'";
  803. $condition = $n;
  804. $action = "/index/main_category_manage/";
  805. $get = "?title=" . $title;
  806. //获取分页相关数据
  807. $page = $this->adminlogic->get_page ( t_category, $condition, $on_page, $page_size, $action, $get, "admin" );
  808. $limit = " limit " . $page ['lower'] . " , " . $page_size . " ";
  809. $page ['question_list'] = $this->asklogic->get_list ( array (), $condition, $limit, t_category );
  810. $data ['question'] = $page;
  811. $data ['title'] = $title;
  812. $data ['map'] = '分类管理 ';
  813. $data ['success'] = "<span style='color:red'></span> ";
  814. $this->render ( '/admin/category_manage', $data );
  815. }
  816. /**
  817. * 进入添加分类页面
  818. */
  819. function category_manage_add() {
  820. //获取顶级分类
  821. $data ['category'] = $this->asklogic->get_category_list ();
  822. $data ['map'] = '添加分类 ';
  823. $data ['success'] = "<span style='color:red'></span> ";
  824. $this->render ( '/admin/category_manage_add', $data );
  825. }
  826. /**
  827. * 添加分类
  828. */
  829. function category_manage_doadd() {
  830. $params ['name'] = $this->get_args ( 'name' );
  831. $params ['pid'] = $this->get_args ( 'pid' );
  832. if (empty ( $params ['name'] ))
  833. die ( '填写分类名称' );
  834. $this->userlogic->add_category ( $params );
  835. Header ( "Location:/index/main_category_manage" );
  836. }
  837. /**
  838. * 分类管理-删除
  839. */
  840. function category_manage_delete() {
  841. $id = $this->get_args ( 'id' );
  842. $this->userlogic->delete_category_list ( $id );
  843. Header ( "Location:/index/main_category_manage" );
  844. }
  845. /**
  846. * 编辑分类
  847. */
  848. function category_manage_edit() {
  849. $id = $this->check_params ( 'id' );
  850. $data ['categoryinfo'] = $this->asklogic->get_category_by_id ( $id );
  851. //获取顶级分类
  852. $data ['category'] = $this->asklogic->get_category_list ();
  853. $data ['map'] = '添加分类 ';
  854. $data ['success'] = "<span style='color:red'></span> ";
  855. $this->render ( '/admin/category_manage_edit', $data );
  856. }
  857. /**
  858. * 更新分类信息
  859. */
  860. function category_manage_update() {
  861. $id = $this->get_args ( 'id' );
  862. $name = $this->get_args ( 'name' );
  863. $pid = $this->get_args ( 'pid' );
  864. if (empty ( $name ))
  865. die ( '填写分类名称' );
  866. $this->userlogic->update_category ( $id, $name, $pid );
  867. Header ( "Location:/index/main_category_manage" );
  868. }
  869. /**
  870. * 进入系统设置
  871. */
  872. function system_manage() {
  873. $data ['map'] = '系统管理 ';
  874. include SITE_PATH . '/protected/config/set_email_to_admin.conf.php';
  875. $data ['email'] = $sys ['set_email'];
  876. $fundstr=file_get_contents(SITE_PATH . '/protected/config/fund.conf.php') ;
  877. $data['fund']=$fundstr;
  878. $this->render ( '/admin/system_manage', $data );
  879. }
  880. function system_fund_do(){
  881. $string=$this->get_args('fund');
  882. file_put_contents(SITE_PATH . '/protected/config/fund.conf.php', $string);
  883. Header ( "Location:/index/main_system_manage" );
  884. }
  885. /**
  886. * 系统设置
  887. */
  888. function system_manage_do() {
  889. $email = $this->get_args ( 'set_email_to_admin' );
  890. $string="<?php ";
  891. $string.="\$sys=array('set_email'=>'".$email."'";
  892. $string.=");";
  893. file_put_contents(SITE_PATH . '/protected/config/set_email_to_admin.conf.php', $string);
  894. Header ( "Location:/index/main_system_manage" );
  895. }
  896. /**
  897. * 获取get或者POST值
  898. * @param string $name 属性名称
  899. * @return fixed 值
  900. */
  901. function get_args($name) {
  902. if (isset ( $_GET [$name] )) {
  903. if (is_array ( $_GET [$name] ))
  904. return $_GET [$name];
  905. else
  906. return addslashes ( $_GET [$name] );
  907. } elseif (isset ( $_POST [$name] )) {
  908. if (is_array ( $_POST [$name] ))
  909. return $_POST [$name];
  910. else
  911. return addslashes ( $_POST [$name] );
  912. } else {
  913. return false;
  914. }
  915. }
  916. /**
  917. * 检测数据输入的非法字符和转义非法字符
  918. */
  919. function check_params($name = "") {
  920. if (isset ( $this->params [$name] )) {
  921. return addslashes ( $this->params [$name] );
  922. } else {
  923. return false;
  924. }
  925. }
  926. /**
  927. * 限时跳转
  928. * @param unknown_type $message
  929. * @param unknown_type $redirectto
  930. * @param unknown_type $time
  931. * @param unknown_type $return_msg
  932. * @param unknown_type $js
  933. */
  934. function Messager($message, $redirectto = '', $time = -1, $return_msg = false, $js = null) {
  935. global $rewriteHandler;
  936. $data ['redirectto'] = $redirectto;
  937. $data ['message'] = $message;
  938. if ($time === - 1) {
  939. //配置文件
  940. //$time=(is_numeric($this->Config['msg_time'])?$this->Config['msg_time']:5);
  941. $data ['time'] = 5;
  942. }
  943. $data ['to_title'] = ($data ['redirectto'] === '' or $data ['redirectto'] == - 1) ? "返回上一页" : "跳转到指定页面";
  944. if ($data ['redirectto'] === null) {
  945. $return_msg = $return_msg === false ? "&nbsp;" : $return_msg;
  946. } else {
  947. $data ['redirectto'] = ($data ['redirectto'] !== '') ? $data ['redirectto'] : ($from_referer = referer ());
  948. // if(str_exists($data['redirectto'],'mod=login','code=register','/login','/register'))
  949. // {
  950. // $referer='&referer='.urlencode('index.php?'.$_SERVER['QUERY_STRING']);
  951. // $this->CookieHandler->Setvar('referer','index.php?'.$_SERVER['QUERY_STRING']);
  952. // }
  953. if (is_numeric ( $data ['redirectto'] ) !== false and $data ['redirectto'] !== 0) {
  954. if ($data ['time'] !== null) {
  955. $data ['url_redirect'] = "<script language=\"JavaScript\" type=\"text/javascript\">\r\n";
  956. $data ['url_redirect'] .= sprintf ( "window.setTimeout(\"history.go(%s)\",%s);\r\n", $data ['redirectto'], $data ['time'] * 1000 );
  957. $data ['url_redirect'] .= "</script>\r\n";
  958. }
  959. $data ['redirectto'] = "javascript:history.go({$data['redirectto']})";
  960. } else {
  961. if ($rewriteHandler && null !== $data ['message']) {
  962. $data ['redirectto'] .= $referer;
  963. if (! $from_referer && ! $referer) {
  964. $data ['redirectto'] = $rewriteHandler->formatURL ( $data ['redirectto'], true );
  965. }
  966. }
  967. if ($data ['message'] === null) {
  968. $data ['redirectto'] = rawurldecode ( stripslashes ( ($data ['redirectto']) ) );
  969. @header ( "Location: " . $data ['redirectto'] ); #HEADER跳转
  970. }
  971. if ($data ['time'] !== null) {
  972. $data ['url_redirect'] = ($data ['redirectto'] ? '<meta http-equiv="refresh" content="' . $data ['time'] . '; URL=' . $data ['redirectto'] . '">' : null);
  973. }
  974. }
  975. }
  976. $title = "消息提示:" . (is_array ( $data ['message'] ) ? implode ( ',', $data ['message'] ) : $data ['message']);
  977. $title = strip_tags ( $title );
  978. if ($js != "") {
  979. $js = "<script language=\"JavaScript\" type=\"text/javascript\">{$js}</script>";
  980. }
  981. $additional_str = $data ['url_redirect'] . $js;
  982. $this->render ( 'messager', $data );
  983. exit ();
  984. }
  985. }
  986. ?>