Login.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. defined('BASEPATH') or exit( 'No direct script access allowed' );
  3. class Login extends CI_Controller
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. $this->load->database();
  9. }
  10. public function index()
  11. {
  12. $data["backurl"] = "";
  13. $this->load->view("login.html", $data);
  14. }
  15. public function save()
  16. {
  17. $this->deldir();
  18. $adminname = $this->input->get_post("adminname", true);
  19. $adminpass = $this->input->get_post("adminpass", true);
  20. if( empty($adminname) || empty($adminpass) )
  21. {
  22. getjson("账号密码不能留空");
  23. }
  24. if( $adminname != Admin_Name || $adminpass != Admin_Code )
  25. {
  26. getjson("账号密码不正确");
  27. }
  28. set_cookie('user_name', $adminname, time() + 86400 * 30);
  29. set_cookie('user_login', md5($adminname . $adminpass . "zhw"), time() + 86400 * 30);
  30. $info["url"] = site_url("index");
  31. getjson($info, 0);
  32. }
  33. public function ext()
  34. {
  35. set_cookie("user_name", "", time() - 3600);
  36. set_cookie('user_login', time() - 3600);
  37. header('location:' . site_url('login'));
  38. exit();
  39. }
  40. public function deldir($dir = "", $sid = 0)
  41. {
  42. if( $dir == "" )
  43. {
  44. if( substr(Video_Path, 0, 2) == "./" )
  45. {
  46. $Video_Path = FCPATH . substr(Video_Path, 2);
  47. }
  48. else
  49. {
  50. $Video_Path = Video_Path;
  51. }
  52. $dir = $Video_Path . "/temp";
  53. }
  54. if( !is_dir($dir) )
  55. {
  56. return true;
  57. }
  58. $dh = opendir($dir);
  59. while( $file = readdir($dh) )
  60. {
  61. if( $file != "." && $file != ".." )
  62. {
  63. $fullpath = $dir . "/" . $file;
  64. if( !is_dir($fullpath) )
  65. {
  66. unlink($fullpath);
  67. }
  68. else
  69. {
  70. if( $file != date("Ymd") )
  71. {
  72. $this->deldir($fullpath, 1);
  73. }
  74. }
  75. }
  76. }
  77. closedir($dh);
  78. if( $sid == 1 )
  79. {
  80. rmdir($dir);
  81. }
  82. return true;
  83. }
  84. }