files.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. class files_c extends Control
  3. {
  4. var $type_video = array("wma","mp3","wmv","asf","mpg","mpeg","avi","asx","rm","rmvb","ram","ra","swf","flv","dat");
  5. var $type_img = array("jpg","gif","png","jpeg");
  6. var $type_file = array("zip","rar","txt","tgz","tar","gz");
  7. var $file_uptype = "swf";
  8. function __construct()
  9. {
  10. parent::Control();
  11. $this->load_model("upfile");//读取附件操作类
  12. if(file_exists(ROOT_DATA."attachment.php"))
  13. {
  14. include(ROOT_DATA."attachment.php");
  15. if($_sys["picture_type"])
  16. {
  17. $this->type_img = sys_id_list($_sys["picture_type"]);
  18. }
  19. if($_sys["video_type"])
  20. {
  21. $this->type_video = sys_id_list($_sys["video_type"]);
  22. }
  23. if($_sys["file_type"])
  24. {
  25. $this->type_file = sys_id_list($_sys["file_type"]);
  26. }
  27. $this->file_uptype = $_sys["file_uptype"];
  28. }
  29. $this->tpl->assign("type_video",$this->type_video);
  30. $this->tpl->assign("type_img",$this->type_img);
  31. $this->tpl->assign("type_file",$this->type_file);
  32. $this->tpl->assign("file_uptype",$this->file_uptype);
  33. }
  34. function files_c()
  35. {
  36. $this->__construct();
  37. }
  38. function index_f()
  39. {
  40. sys_popedom("files:list","tpl");
  41. $input_type = $this->trans_lib->safe("type");
  42. if($input_type != "video" && $input_type != "img" && $input_type != "download")
  43. {
  44. $input_type = "all";
  45. }
  46. $this->tpl->assign("input_type",$input_type);
  47. $page_url = site_url("files")."type=".rawurlencode($input_type)."&";
  48. if($input_type == "video")
  49. {
  50. $condition = "ftype IN('".implode("','",$this->type_video)."')";
  51. $this->upfile_m->set_condition($condition);
  52. }
  53. elseif($input_type == "img")
  54. {
  55. $condition = "ftype IN('".implode("','",$this->type_img)."')";
  56. $this->upfile_m->set_condition($condition);
  57. }
  58. elseif($input_type== "download")
  59. {
  60. $condition = "ftype IN('".implode("','",$this->type_file)."')";
  61. $this->upfile_m->set_condition($condition);
  62. }
  63. //查看postdate数据
  64. $postdate = $this->trans_lib->safe("postdate");
  65. if($postdate)
  66. {
  67. $condition = "postdate>='".strtotime($postdate)."'";
  68. $this->upfile_m->set_condition($condition);
  69. $page_url .= "postdate=".rawurlencode($postdate)."&";
  70. }
  71. $keywords = $this->trans_lib->safe("keywords");
  72. if($keywords)
  73. {
  74. $condition = "(title LIKE '%".$keywords."%' OR filename LIKE '%".$keywords."%')";
  75. $this->upfile_m->set_condition($condition);
  76. $page_url .= "keywords=".rawurlencode($keywords)."&";
  77. }
  78. $total = $this->upfile_m->get_count();//取得总数
  79. $pagelist = $this->page_lib->page($page_url,$total);
  80. $this->tpl->assign("pagelist",$pagelist);
  81. $pageid = $this->trans_lib->int(SYS_PAGEID);
  82. $rslist = $this->upfile_m->get_list($pageid);
  83. $this->tpl->assign("rslist",$rslist);
  84. $this->tpl->assign("page_url",$page_url.SYS_PAGEID."=".$pageid);
  85. $this->tpl->display("upfiles.html");
  86. }
  87. function update_name_f()
  88. {
  89. sys_popedom("files:modify","ajax");
  90. $id = $this->trans_lib->int("id");
  91. $tmpname = $this->trans_lib->safe("tmpname");
  92. if(!$id)
  93. {
  94. exit("error:没有指定ID");
  95. }
  96. if(!$tmpname)
  97. {
  98. exit("error:名称不允许为空!");
  99. }
  100. $array = array();
  101. $array["title"] = $tmpname;
  102. //判断是否有FLV
  103. $array["flv_pic"] = $this->trans_lib->safe("flv_pic");
  104. $this->upfile_m->save($array,$id);
  105. exit("ok");
  106. }
  107. //批量删除操作
  108. function del_f()
  109. {
  110. sys_popedom("files:delete","ajax");
  111. $id = $this->trans_lib->safe("id");
  112. if(!$id)
  113. {
  114. exit("error:没有指定删除ID!");
  115. }
  116. $rslist = $this->upfile_m->get_filelist($id);
  117. if(!$rslist)
  118. {
  119. exit("error:没有找到相关附件信息!");
  120. }
  121. foreach($rslist AS $key=>$value)
  122. {
  123. $this->file_lib->rm($value);
  124. }
  125. $this->upfile_m->del($id);
  126. exit("ok");
  127. }
  128. //设置附件上传参数
  129. function set_f()
  130. {
  131. if(file_exists(ROOT_DATA."attachment.php"))
  132. {
  133. include(ROOT_DATA."attachment.php");
  134. $this->tpl->assign("rs",$_sys);
  135. }
  136. $this->tpl->display("attachment.html");
  137. }
  138. function setok_f()
  139. {
  140. sys_popedom("files:setting","tpl");
  141. $rs = array();
  142. if($_POST && is_array($_POST) && count($_POST)>0)
  143. {
  144. foreach($_POST AS $key=>$value)
  145. {
  146. $rs[$key] = $this->trans_lib->safe($key);
  147. }
  148. }
  149. //判断如何附件使用activex上传时,则创建两个目录
  150. if($rs["file_uptype"] == "activex")
  151. {
  152. $this->file_lib->make(ROOT.SYS_UP_PATH."/xu_temp_");
  153. $this->file_lib->make(ROOT.SYS_UP_PATH."/xu_temp");
  154. }
  155. $this->file_lib->vi($rs,ROOT_DATA."attachment.php","_sys");
  156. error("附件参数配置成功!",site_url("files"));
  157. }
  158. }
  159. ?>