open.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <?php
  2. class open_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","pdf");
  7. var $file_save_type = "Ym/d";
  8. var $file_uptype = "swf"; //附件上传方式
  9. function __construct()
  10. {
  11. parent::Control();
  12. $this->load_model("upfile");//读取附件操作类
  13. $this->load_lib("upload");
  14. $this->upload_lib->setting();//初始化
  15. $this->type_video = $this->upload_lib->type_video;
  16. $this->type_img = $this->upload_lib->type_img;
  17. $this->type_file = $this->upload_lib->type_file;
  18. $this->file_uptype = $this->upload_lib->file_uptype;
  19. $this->file_save_type = $this->upload_lib->file_save_type;
  20. $this->tpl->assign("type_video",$this->type_video);
  21. $this->tpl->assign("type_img",$this->type_img);
  22. $this->tpl->assign("type_file",$this->type_file);
  23. $this->tpl->assign("file_uptype",$this->file_uptype);
  24. }
  25. function open_c()
  26. {
  27. $this->__construct();
  28. }
  29. //读取列表
  30. function index_f()
  31. {
  32. $input_id = $this->trans_lib->safe("input");
  33. if(!$input_id) $input_id = "thumb_id";
  34. $input_view = $this->trans_lib->safe("view");
  35. if(!$input_view) $input_view = "thumb_view";
  36. $input_type = $this->trans_lib->safe("type");
  37. if($input_type != "video" && $input_type != "img" && $input_type != "download")
  38. {
  39. $input_type = "img";
  40. }
  41. $this->tpl->assign("input_id",$input_id);
  42. $this->tpl->assign("input_view",$input_view);
  43. $page_url = site_url("open")."input=".rawurlencode($input_id)."&";
  44. $page_url.= "view=".rawurlencode($input_view)."&type=".rawurlencode($input_type)."&";
  45. if($input_type == "video")
  46. {
  47. $condition = "ftype IN('".implode("','",$this->type_video)."')";
  48. $this->upfile_m->set_condition($condition);
  49. //设置上传的附件类型
  50. $tmp_array = array();
  51. foreach($this->type_video AS $key=>$value)
  52. {
  53. $tmp_array[] = "*.".$value;
  54. }
  55. $this->tpl->assign("swfupload_filetype",implode(";",$tmp_array));
  56. $this->tpl->assign("swfupload_note","Video Files");
  57. }
  58. elseif($input_type == "img")
  59. {
  60. $condition = "ftype IN('".implode("','",$this->type_img)."')";
  61. $this->upfile_m->set_condition($condition);
  62. $tmp_array = array();
  63. foreach($this->type_img AS $key=>$value)
  64. {
  65. $tmp_array[] = "*.".$value;
  66. }
  67. $this->tpl->assign("swfupload_filetype",implode(";",$tmp_array));
  68. $this->tpl->assign("swfupload_note","Image Files");
  69. }
  70. else
  71. {
  72. $this->tpl->assign("swfupload_filetype","*.*");
  73. //合并文件类型
  74. $filetype = array_merge($this->type_video,$this->type_img,$this->type_file);
  75. $this->tpl->assign("swfupload_note","All Files");
  76. }
  77. //查看postdate数据
  78. $page_url_2 = $page_url;
  79. $postdate = $this->trans_lib->safe("postdate");
  80. if($postdate)
  81. {
  82. $condition = "postdate>='".strtotime($postdate)."'";
  83. $this->upfile_m->set_condition($condition);
  84. $page_url_2 .= "postdate=".rawurlencode($postdate)."&";
  85. }
  86. $keywords = $this->trans_lib->safe("keywords");
  87. if($keywords)
  88. {
  89. $condition = "(title LIKE '%".$keywords."%' OR filename LIKE '%".$keywords."%' OR id LIKE '%".$keywords."%')";
  90. $this->upfile_m->set_condition($condition);
  91. $page_url_2 .= "keywords=".rawurlencode($keywords)."&";
  92. }
  93. $total = $this->upfile_m->get_count();//取得总数
  94. $this->upfile_m->set_psize(15);
  95. $this->page_lib->set_psize(15);
  96. $pagelist = $this->page_lib->page($page_url_2,$total);
  97. $this->tpl->assign("pagelist",$pagelist);
  98. $pageid = $this->trans_lib->int(SYS_PAGEID);
  99. $rslist = $this->upfile_m->get_list($pageid);
  100. $this->tpl->assign("rslist",$rslist);
  101. $this->tpl->assign("page_url",$page_url);
  102. //加载模板
  103. $tplfile = "list_".$input_type.".html";
  104. if($input_type == "img" && $input_id == "thumb_id")
  105. {
  106. $tplfile = "list_thumb.html";
  107. }
  108. $this->tpl->display("open/".$tplfile);
  109. }
  110. function img_f()
  111. {
  112. $input_id = $this->trans_lib->safe("input");
  113. if(!$input_id) $input_id = "ico";
  114. $input_type = "img";
  115. $this->tpl->assign("input_id",$input_id);
  116. $page_url = site_url("open,img")."input=".rawurlencode($input_id)."&";
  117. $condition = "ftype IN('".implode("','",$this->type_img)."')";
  118. $this->upfile_m->set_condition($condition);
  119. $tmp_array = array();
  120. foreach($this->type_img AS $key=>$value)
  121. {
  122. $tmp_array[] = "*.".$value;
  123. }
  124. $this->tpl->assign("swfupload_filetype",implode(";",$tmp_array));
  125. $this->tpl->assign("swfupload_note","Image Files");
  126. $page_url_2 = $page_url;
  127. $postdate = $this->trans_lib->safe("postdate");
  128. if($postdate)
  129. {
  130. $condition = "postdate>='".strtotime($postdate)."'";
  131. $this->upfile_m->set_condition($condition);
  132. $page_url_2 .= "postdate=".rawurlencode($postdate)."&";
  133. }
  134. $keywords = $this->trans_lib->safe("keywords");
  135. if($keywords)
  136. {
  137. $condition = "(title LIKE '%".$keywords."%' OR filename LIKE '%".$keywords."%')";
  138. $this->upfile_m->set_condition($condition);
  139. $page_url_2 .= "keywords=".rawurlencode($keywords)."&";
  140. }
  141. $total = $this->upfile_m->get_count();//取得总数
  142. $pagelist = $this->page_lib->page($page_url_2,$total);
  143. $this->tpl->assign("pagelist",$pagelist);
  144. $pageid = $this->trans_lib->int(SYS_PAGEID);
  145. $rslist = $this->upfile_m->get_list($pageid);
  146. $this->tpl->assign("rslist",$rslist);
  147. $this->tpl->assign("page_url",$page_url);
  148. $this->tpl->display("open/thumb.html");
  149. }
  150. //通过swf+php进行附件上传,支持大文件
  151. function upload_f()
  152. {
  153. $insert_id = $this->upload_lib->upload("Filedata");//上传图片
  154. if($insert_id)
  155. {
  156. $rs = $this->upfile_m->get_one($insert_id);
  157. if(!$rs)
  158. {
  159. exit("error");
  160. }
  161. exit($this->json_lib->encode($rs));
  162. }
  163. else
  164. {
  165. exit("error");
  166. }
  167. }
  168. //通过swf+php进行附件上传,支持大文件
  169. function upok_f()
  170. {
  171. $go_back = $this->trans_lib->safe("_go_back_url");
  172. $insert_id = $this->upload_lib->upload("upload_file");//上传图片
  173. if($insert_id)
  174. {
  175. error("附件上传成功,请稍候!",$go_back);
  176. }
  177. else
  178. {
  179. error("附件上传失败,请检查!",$go_back);
  180. }
  181. }
  182. //临时图片批量生成工具
  183. function pl_f()
  184. {
  185. $picid = $this->trans_lib->safe("picid");
  186. $now_id = $this->trans_lib->int("pid");
  187. if($picid == "all")
  188. {
  189. if(!$now_id)
  190. {
  191. $rs = $this->upfile_m->get_one_c("ftype IN('".implode("','",$this->type_img)."')");
  192. if(!$rs)
  193. {
  194. error("批量生成图片错误,没有取得一张有效图片");
  195. }
  196. $now_id = $rs["id"];
  197. }
  198. }
  199. else
  200. {
  201. if(!$picid)
  202. {
  203. error("没有指定要生成的图片ID");
  204. }
  205. $pic_array = explode(",",$picid);
  206. if(!$now_id)
  207. {
  208. $now_id = $pic_array[0];
  209. }
  210. }
  211. //重新批量生成新图片信息
  212. $this->upload_lib->gd_create($now_id);
  213. $tmp_rs = $this->upfile_m->get_one($now_id);
  214. //取得下一张图片信息
  215. $set_url = site_url("open,pl")."picid=".$picid."&pid=";
  216. if($picid == "all")
  217. {
  218. //[取得下一张图片ID]
  219. $condition = "ftype IN('".implode("','",$this->type_img)."') AND id>'".$now_id."'";
  220. $next_rs = $this->upfile_m->get_one_c($condition);
  221. if(!$next_rs)
  222. {
  223. error("图片批量生成完毕");
  224. }
  225. else
  226. {
  227. $next_id = $next_rs["id"];
  228. $set_url.= $next_id;
  229. error("请稍候,正在更新中,已更新至:".$tmp_rs["title"],$set_url);
  230. }
  231. }
  232. else
  233. {
  234. $next_id = 0;
  235. foreach($pic_array AS $key=>$value)
  236. {
  237. if($value == $now_id)
  238. {
  239. $next_id = $pic_array[$key+1];
  240. break;
  241. }
  242. }
  243. if(!$next_id)
  244. {
  245. error("图片批量生成完毕");
  246. }
  247. else
  248. {
  249. $set_url.= $next_id;
  250. //echo $set_url;
  251. error("请稍候,正在更新中,已更新至:".$tmp_rs["title"],$set_url);
  252. }
  253. }
  254. }
  255. //通过Ajax预览图片
  256. function ajax_preview_img_f()
  257. {
  258. $idstring = $this->trans_lib->safe("idstring");
  259. if(!$idstring)
  260. {
  261. exit("empty");
  262. }
  263. $idstring = sys_id_string($idstring,",","intval");
  264. $rslist = $this->upfile_m->piclist($idstring);
  265. exit($this->json_lib->encode($rslist));
  266. }
  267. //通过Ajax来执行图片排序
  268. function sort_order_f()
  269. {
  270. $order_list = $this->trans_lib->safe("taxis");//数组排序
  271. if(!$order_list)
  272. {
  273. exit("error");
  274. }
  275. natsort($order_list);//排序
  276. $keys = array_keys($order_list);
  277. $string = sys_id_string($keys);
  278. exit($string);
  279. }
  280. //预览图片
  281. function preview_f()
  282. {
  283. $id = $this->trans_lib->int("id");
  284. if(!$id)
  285. {
  286. error("没有选择要预览的ID");
  287. }
  288. $rs = $this->upfile_m->get_one($id);
  289. $this->tpl->assign("rs",$rs);
  290. $ftype = "file";
  291. if(in_array($rs["ftype"],$this->type_img))
  292. {
  293. $rslist = $this->upfile_m->get_one_gd($id);
  294. $this->tpl->assign("rslist",$rslist);
  295. $ftype = "img";
  296. }
  297. if(in_array($rs["ftype"],$this->type_video))
  298. {
  299. $ftype = "video";
  300. if(file_exists(ROOT_DATA."system_".$_SESSION["sys_lang_id"].".php"))
  301. {
  302. include(ROOT_DATA."system_".$_SESSION["sys_lang_id"].".php");
  303. }
  304. else
  305. {
  306. $_sys = array();
  307. $_sys["video_width"] = "500";
  308. $_sys["video_height"] = "400";
  309. }
  310. $this->tpl->assign("_sys",$_sys);
  311. }
  312. //判断是否预览
  313. $pretype = $this->trans_lib->safe("pretype");
  314. if($pretype && $pretype == "download")
  315. {
  316. $ftype = "file";
  317. }
  318. $this->tpl->assign("ftype",$ftype);
  319. $this->tpl->display("open/preview.html");
  320. }
  321. function copyurl_f()
  322. {
  323. $id = $this->trans_lib->int("id");
  324. if(!$id)
  325. {
  326. error("没有选择ID");
  327. }
  328. $rs = $this->upfile_m->get_one($id);
  329. $this->tpl->assign("rs",$rs);
  330. $ifimg = false;
  331. if(in_array($rs["ftype"],$this->type_img))
  332. {
  333. $rslist = $this->upfile_m->get_one_gd($id);
  334. $this->tpl->assign("rslist",$rslist);
  335. $ifimg = true;
  336. }
  337. $this->tpl->assign("ifimg",$ifimg);
  338. $this->tpl->display("open/copyurl.html");
  339. }
  340. function fck_f()
  341. {
  342. $fck_id = $this->trans_lib->safe("fck_id");
  343. if(!$fck_id) $fck_id = "content";
  344. $input_type = $this->trans_lib->safe("type");
  345. if($input_type != "video" && $input_type != "img" && $input_type != "download")
  346. {
  347. $input_type = "img";
  348. }
  349. $this->tpl->assign("fck_id",$fck_id);
  350. $this->tpl->assign("input_type",$input_type);
  351. $page_url = site_url("open,fck")."fck_id=".rawurlencode($fck_id)."&";
  352. $page_url.= "type=".rawurlencode($input_type)."&";
  353. if($input_type == "video")
  354. {
  355. $condition = "ftype IN('".implode("','",$this->type_video)."')";
  356. $this->upfile_m->set_condition($condition);
  357. //设置上传的附件类型
  358. $tmp_array = array();
  359. foreach($this->type_video AS $key=>$value)
  360. {
  361. $tmp_array[] = "*.".$value;
  362. }
  363. $this->tpl->assign("swfupload_filetype",implode(";",$tmp_array));
  364. $this->tpl->assign("swfupload_note","Video Files");
  365. }
  366. elseif($input_type == "img")
  367. {
  368. $condition = "ftype IN('".implode("','",$this->type_img)."')";
  369. $this->upfile_m->set_condition($condition);
  370. $tmp_array = array();
  371. foreach($this->type_img AS $key=>$value)
  372. {
  373. $tmp_array[] = "*.".$value;
  374. }
  375. $this->tpl->assign("swfupload_filetype",implode(";",$tmp_array));
  376. $this->tpl->assign("swfupload_note","Image Files");
  377. }
  378. else
  379. {
  380. $this->tpl->assign("swfupload_filetype","*.*");
  381. $filetype = array_merge($this->type_video,$this->type_img,$this->type_file);
  382. $this->tpl->assign("swfupload_note","All Files");
  383. }
  384. //查看postdate数据
  385. $page_url_2 = $page_url;
  386. $postdate = $this->trans_lib->safe("postdate");
  387. if($postdate)
  388. {
  389. $condition = "postdate>='".strtotime($postdate)."'";
  390. $this->upfile_m->set_condition($condition);
  391. $page_url_2 .= "postdate=".rawurlencode($postdate)."&";
  392. }
  393. $keywords = $this->trans_lib->safe("keywords");
  394. if($keywords)
  395. {
  396. $condition = "(title LIKE '%".$keywords."%' OR filename LIKE '%".$keywords."%')";
  397. $this->upfile_m->set_condition($condition);
  398. $page_url_2 .= "keywords=".rawurlencode($keywords)."&";
  399. }
  400. $total = $this->upfile_m->get_count();//取得总数
  401. $pagelist = $this->page_lib->page($page_url_2,$total);
  402. $this->tpl->assign("pagelist",$pagelist);
  403. $pageid = $this->trans_lib->int(SYS_PAGEID);
  404. $rslist = $this->upfile_m->get_list($pageid);
  405. $this->tpl->assign("rslist",$rslist);
  406. $this->tpl->assign("page_url",$page_url);
  407. //加载模板
  408. $tplfile = "fck_".$input_type.".html";
  409. //加载GD类型
  410. $this->load_model("gdtype");
  411. $gdlist = $this->gdtype_m->get_all(1,1);
  412. $this->tpl->assign("gdlist",$gdlist);
  413. $this->tpl->display("open/".$tplfile);
  414. }
  415. //获取图片信息,返回json字符串
  416. function fck_img_f()
  417. {
  418. $idstring = $this->trans_lib->safe("idstring");
  419. if(!$idstring)
  420. {
  421. exit("empty");
  422. }
  423. $idstring = sys_id_string($idstring,",","intval");
  424. $gd_type = $this->trans_lib->safe("gd_type");
  425. $rslist = $this->upfile_m->pic_list($idstring,$gd_type);
  426. if(!$rslist)
  427. {
  428. exit("empty");
  429. }
  430. exit($this->json_lib->encode($rslist));
  431. }
  432. }
  433. ?>