IndexAction.class.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. *
  4. * IndexAction.class.php (前台首页)
  5. *
  6. */
  7. if(!defined("Ainaphp")) exit("Access Denied");
  8. class IndexAction extends BaseAction
  9. {
  10. public function index()
  11. {
  12. $this->assign('bcid',0);//顶级栏目
  13. $this->assign('ishome','home');
  14. $this->display();
  15. }
  16. public function message(){
  17. $mod = M("message");
  18. $_POST = get_safe_replace($_POST);
  19. if(false!==$mod->create()){
  20. $mod->status = 1;
  21. $mod->lang = 1;
  22. $mod->createtime = time();
  23. $mod->updatetime = time();
  24. $mod->add();
  25. $this->success("提交成功");
  26. }else{
  27. $this->error("提交失败");
  28. }
  29. }
  30. public function apply()
  31. {
  32. session_start();
  33. $this->stop_request();
  34. $mod = M("try");
  35. $_POST = get_safe_replace($_POST);
  36. if (false !== $mod->create()) {
  37. $mod->status = 1;
  38. $mod->lang = 1;
  39. $mod->createtime = time();
  40. $mod->updatetime = time();
  41. $mod->add();
  42. $this->success("提交成功");
  43. } else {
  44. $this->error("提交失败");
  45. }
  46. }
  47. //防止恶意请求
  48. public function stop_request(){
  49. $allow_sep = '120';
  50. if (isset($_SESSION["moban_apply"])){
  51. if (time() - $_SESSION["moban_apply"] < $allow_sep){
  52. $this->error('请不要反复提交~');
  53. }else{
  54. $_SESSION["moban_apply"] = time();
  55. }
  56. }
  57. $_SESSION["moban_apply"] = time();
  58. }
  59. }
  60. ?>