gd.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. class gd_c extends Control
  3. {
  4. function __construct()
  5. {
  6. parent::Control();
  7. $this->load_model("gd");
  8. }
  9. function gd_c()
  10. {
  11. $this->__construct();
  12. }
  13. function index_f()
  14. {
  15. sys_popedom("gd:list","tpl");
  16. $rslist = $this->gd_m->get_list();
  17. $this->tpl->assign("rslist",$rslist);
  18. $this->tpl->display("gd/list.html");
  19. }
  20. function set_f()
  21. {
  22. $id = $this->trans_lib->int("id");
  23. if($id)
  24. {
  25. sys_popedom("gd:modify","tpl");
  26. }
  27. else
  28. {
  29. sys_popedom("gd:add","tpl");
  30. }
  31. $this->tpl->assign("id",$id);
  32. if($id)
  33. {
  34. $rs = $this->gd_m->get_one($id);
  35. $this->tpl->assign("rs",$rs);
  36. }
  37. $this->tpl->display("gd/set.html");
  38. }
  39. function setok_f()
  40. {
  41. $id = $this->trans_lib->int("id");
  42. if($id)
  43. {
  44. sys_popedom("gd:modify","tpl");
  45. }
  46. else
  47. {
  48. sys_popedom("gd:add","tpl");
  49. }
  50. $array = array();
  51. if(!$id)
  52. {
  53. $array["pictype"] = $this->trans_lib->safe("pictype");
  54. }
  55. $array["picsubject"] = $this->trans_lib->safe("picsubject");
  56. $array["width"] = $this->trans_lib->int("width");
  57. $array["height"] = $this->trans_lib->int("height");
  58. $array["water"] = $this->trans_lib->safe("water");
  59. $array["picposition"] = $this->trans_lib->safe("picposition");
  60. $array["trans"] = $this->trans_lib->safe("trans");
  61. $array["cuttype"] = $this->trans_lib->safe("cuttype");
  62. $array["quality"] = $this->trans_lib->safe("quality");
  63. $array["border"] = $this->trans_lib->safe("border");
  64. $array["bordercolor"] = $this->trans_lib->safe("bordercolor");
  65. $array["padding"] = $this->trans_lib->safe("padding");
  66. $array["bgcolor"] = $this->trans_lib->safe("bgcolor");
  67. $array["bgimg"] = $this->trans_lib->safe("bgimg");
  68. $array["taxis"] = $this->trans_lib->int("taxis");
  69. $array["status"] = $this->trans_lib->int("status");
  70. $array["edit_default"] = $this->trans_lib->int("edit_default");
  71. #[检测相关信息]
  72. if(!$array["picsubject"])
  73. {
  74. error("方案名称不允许为空",site_url("gd,set","id=".$id));
  75. }
  76. if(!$array["width"] || !$array["height"])
  77. {
  78. error("方案的宽和高都不允许为空",site_url("gd,set","id=".$id));
  79. }
  80. $this->gd_m->save($array,$id);
  81. error("方案操作成功",site_url("gd"));
  82. }
  83. //检测编号是否唯一
  84. function gd_chk_f()
  85. {
  86. $pictype = $this->trans_lib->safe("pictype");
  87. if(!$pictype)
  88. {
  89. exit("Error:操作非法,没有填写识别号");
  90. }
  91. $rs = $this->gd_m->chk_sign($pictype);
  92. if($rs)
  93. {
  94. exit("ok");
  95. }
  96. else
  97. {
  98. exit("Error:标识符已经被使用了");
  99. }
  100. }
  101. //删除图片库方案
  102. function del_gd_f()
  103. {
  104. $id = $this->trans_lib->int("id");
  105. if(!$id)
  106. {
  107. exit("Error:操作非法,没有指定ID");
  108. }
  109. sys_popedom("gd:delete","ajax");
  110. $rs = $this->gd_m->get_one($id);
  111. $sign = $rs["pictype"];
  112. //获取数据
  113. $rslist = $this->gd_m->gd_list($sign);
  114. if($rslist && count($rslist) > 0 && is_array($rslist))
  115. {
  116. foreach($rslist AS $key=>$value)
  117. {
  118. if($value["filename"] && file_exists(ROOT.$value["filename"]) && is_file(ROOT.$value["filename"]))
  119. {
  120. $this->file_lib->rm(ROOT.$value["filename"]);
  121. }
  122. }
  123. }
  124. $this->gd_m->gd_del($sign);
  125. $this->gd_m->del($id);
  126. exit("ok");
  127. }
  128. }
  129. ?>