AdminController.php 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class AdminController extends DooController {
  6. private $adminlogic;
  7. function __construct() {
  8. include SITE_PATH . 'protected/config/admin_menu.conf.php';
  9. $this->menu = $menu ;
  10. Load::logic ( 'Admin' );
  11. $this->adminlogic = new AdminLogic ();
  12. }
  13. function index() {
  14. $data ['li'] = $this->menu ['navon'];
  15. $data['now']='use';
  16. $this->render ( "/admin/index", $data );
  17. }
  18. function login() {
  19. $data = array ();
  20. $this->render ( "admin/login", $data );
  21. }
  22. function do_login() {
  23. }
  24. /**
  25. * 上传问题图片--移动到user
  26. */
  27. public function upimg() {
  28. require_once (SITE_PATH . '/protected/plugin/Uploader.class.php');
  29. //上传配置
  30. $config = array ("savePath" => SITE_PATH . "/global/upload/img/", "maxSize" => 2000, //单位KB
  31. "allowFiles" => array (".gif", ".png", ".jpg", ".jpeg", ".bmp" ) );
  32. //上传图片框中的描述表单名称,
  33. $title = htmlspecialchars ( $_POST ['pictitle'], ENT_QUOTES );
  34. //生成上传实例对象并完成上传
  35. $up = new Uploader ( "upfile", $config );
  36. /**
  37. * 得到上传文件所对应的各个参数,数组结构
  38. * array(
  39. * "originalName" => "", //原始文件名
  40. * "name" => "", //新文件名
  41. * "url" => "", //返回的地址
  42. * "size" => "", //文件大小
  43. * "type" => "" , //文件类型
  44. * "state" => "" //上传状态,上传成功时必须返回"SUCCESS"
  45. * )
  46. */
  47. $info = $up->getFileInfo ();
  48. echo "{'url' :'" . $info ["name"] . "', 'title':'" . $title . "','original' :'" . $info ["originalName"] . "', 'state' :'" . $info ['state'] . "' }";
  49. /**
  50. * 向浏览器返回数据json数据
  51. * {
  52. * 'url' :'a.jpg', //保存后的文件路径
  53. * 'title' :'hello', //文件描述,对图片来说在前端会添加到title属性上
  54. * 'original' :'b.jpg', //原始文件名
  55. * 'state' :'SUCCESS' //上传状态,成功时返回SUCCESS,其他任何值将原样返回至图片上传框中
  56. * }
  57. */
  58. }
  59. function training_manag() {
  60. $n = "";
  61. $on_page = is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  62. //
  63. if ($on_page <= 0)
  64. $on_page = 1;
  65. $title = $this->get_args ( 'title' );
  66. $page_size = 18;
  67. // //检索条件
  68. if (! empty ( $title ))
  69. $n = " and (title like '%" . $title . "%' or enroll_title like '%". $title . "%')";
  70. $condition=$n;
  71. $action = "/admin/training_manage/";
  72. //获取分页相关数据
  73. $page = $this->adminlogic->get_page ( "sc_article", $condition.' and a_type ="2"', $on_page, $page_size, $action, "", "admin" );
  74. $limit = " order by time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  75. Doo::loadModel('Article');
  76. $article=new Article();
  77. $page ['article_list'] = $article->getArticleList ( array (), $condition.' and a_type ="2"', $limit );
  78. $data ['map'] = '文章管理';
  79. $data ['article'] = $page;
  80. $data['title']=$title;
  81. $this->render ( '/admin/training_manage', $data );
  82. }
  83. function training_manage_add() {
  84. if(isset($_POST['is_add'])){
  85. $cid=$this->get_args('cid');
  86. $title=$this->get_args('title');
  87. // if($cid==0){
  88. // echo "column is no select";
  89. // return false;
  90. // }
  91. if($title==""){
  92. //echo "title is empty";
  93. //return false;
  94. }
  95. Doo::loadModel ( 'Article' );
  96. $article = new Article ();
  97. $article->cid=3;
  98. $article->title=$title;
  99. $article->time=time();
  100. $article->content=stripcslashes ($this->get_args('content_text'));
  101. $article->enroll=stripcslashes ($this->get_args('enroll'));
  102. $article->enroll_title=$this->get_args('enroll_title');
  103. $article->enroll_obj=stripcslashes ($this->get_args('enroll_obj'));
  104. $article->enroll_content=stripcslashes ($this->get_args('enroll_content'));
  105. $article->enroll_fun=stripcslashes ($this->get_args('enroll_fun'));
  106. $article->enroll_adrr=stripcslashes ($this->get_args('enroll_adrr'));
  107. $article->enroll_pay=stripcslashes ($this->get_args('enroll_pay'));
  108. $article->enroll_name=stripcslashes ($this->get_args('enroll_name'));
  109. $article->trainingType=stripcslashes ($this->get_args('trainingType'));
  110. $article->area= $this->get_args('area');
  111. $article->synopsis=$this->get_args('synopsis');
  112. //缩略图
  113. $upload_file=$_FILES['thum']['tmp_name'];
  114. $upload_file_name=$_FILES['thum']['name'];
  115. $ext=_GetFileEXT($upload_file_name);
  116. $upload_file_name=time().".".$ext;
  117. if($upload_file){
  118. $store_dir="/upload_files/thum/";
  119. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  120. $article->thum="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  121. }
  122. }
  123. //缩略图
  124. $upload_file=$_FILES['enroll_downdoc']['tmp_name'];
  125. $upload_file_name=$_FILES['enroll_downdoc']['name'];
  126. $ext=_GetFileEXT($upload_file_name);
  127. $upload_file_name=time().".".$ext;
  128. if($upload_file){
  129. $store_dir="/upload_files/doc/";
  130. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  131. $article->enroll_downdoc="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  132. }
  133. }
  134. $article->enroll_mark=stripcslashes ($this->get_args('enroll_mark'));
  135. $article->enroll_time=$this->get_args("enroll_start").":".$this->get_args("enroll_end");
  136. $article->a_type=$this->get_args('a_type');
  137. if(!empty($title))
  138. $article->update_time=time();
  139. $article->insert();
  140. return '/admin/training_manage';
  141. }else{
  142. Doo::loadModel('Column');
  143. $column=new Column();
  144. $data['column']=$column->getColumnListByType(1);
  145. $data ['map'] = '<a href="/admin/article_manage" target="main">文章管理</a> » 添加培训班';
  146. $this->render ( '/admin/training_manage_add',$data);
  147. }
  148. }
  149. function training_manage_edit() {
  150. Doo::loadModel ( 'Article' );
  151. $article = new Article ();
  152. if(isset($_POST['is_edit'])){
  153. $cid=$this->get_args('cid');
  154. $title=$this->get_args('title');
  155. // if($cid==0){
  156. // echo "column is no select";
  157. // return false;
  158. // }
  159. $article->aid=$this->get_args('aid');
  160. //$article->cid=$cid;
  161. $article->title=$title;
  162. $article->content=stripcslashes ($this->get_args('content_text'));
  163. $article->enroll=stripcslashes ($this->get_args('enroll'));
  164. $article->enroll_title=$this->get_args('enroll_title');
  165. $article->enroll_obj=stripcslashes ($this->get_args('enroll_obj'));
  166. $article->enroll_content=stripcslashes ($this->get_args('enroll_content'));
  167. $article->enroll_fun=stripcslashes ($this->get_args('enroll_fun'));
  168. $article->enroll_adrr=stripcslashes ($this->get_args('enroll_adrr'));
  169. $article->enroll_pay=stripcslashes ($this->get_args('enroll_pay'));
  170. $article->enroll_name=stripcslashes ($this->get_args('enroll_name'));
  171. $article->trainingType=stripcslashes ($this->get_args('trainingType'));
  172. $article->area= $this->get_args('area');
  173. $article->synopsis=$this->get_args('synopsis');
  174. //缩略图
  175. $upload_file=$_FILES['thum']['tmp_name'];
  176. $upload_file_name=$_FILES['thum']['name'];
  177. $ext=_GetFileEXT($upload_file_name);
  178. $upload_file_name=time().".".$ext;
  179. if($upload_file){
  180. $store_dir="/upload_files/thum/";
  181. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  182. $article->thum="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  183. }
  184. }
  185. //缩略图
  186. $upload_file=$_FILES['enroll_downdoc']['tmp_name'];
  187. $upload_file_name=$_FILES['enroll_downdoc']['name'];
  188. $ext=_GetFileEXT($upload_file_name);
  189. $upload_file_name=time().".".$ext;
  190. if($upload_file){
  191. $store_dir="/upload_files/doc/";
  192. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  193. $article->enroll_downdoc="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  194. } else{
  195. echo "upload file error,";die;
  196. }
  197. }
  198. $article->enroll_mark=stripcslashes ($this->get_args('enroll_mark'));
  199. $article->enroll_time=$this->get_args("enroll_start").":".$this->get_args("enroll_end");
  200. $article->a_type=$this->get_args('a_type');
  201. $info=$article->getArticleById($this->get_args('aid'));
  202. if(!empty($title)&&empty($info[0]['update_time']))
  203. $article->update_time=time();
  204. $article->update();
  205. return '/admin/training_manage';
  206. }else{
  207. $aid=$this->check_params('aid');
  208. Doo::loadModel('Column');
  209. $column=new Column();
  210. $data['article']=$article->getArticleById($aid);
  211. $time=explode(":", $data['article'][0]['enroll_time']);
  212. $data['time']=$time;
  213. $data['column']=$column->getColumnListByType(1);
  214. $data ['map'] = '<a href="/admin/training_manage" target="main">文章管理</a> » 编辑培训班';
  215. $this->render ( '/admin/training_manage_edit',$data);
  216. }
  217. }
  218. function training_manage_delete() {
  219. $id = $this->get_args ( 'id' );
  220. Doo::loadModel ( 'Article' );
  221. $article = new Article ();
  222. $article->deleteArticleByIdList($id);
  223. return '/admin/training_manage';
  224. }
  225. function article_manage() {
  226. $n = "";
  227. $on_page = is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  228. //
  229. if ($on_page <= 0)
  230. $on_page = 1;
  231. $title = $this->get_args ( 'title' );
  232. $page_size = 18;
  233. // //检索条件
  234. if (! empty ( $title ))
  235. $n = " and (title like '%" . $title . "%' or enroll_title like '%". $title . "%')";
  236. $condition=$n;
  237. $action = "/admin/article_manage/";
  238. //获取分页相关数据
  239. $page = $this->adminlogic->get_page ( "sc_article", $condition.' and a_type ="1"', $on_page, $page_size, $action, "", "admin" );
  240. $limit = " order by time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  241. Doo::loadModel('Article');
  242. $article=new Article();
  243. $page ['article_list'] = $article->getArticleList ( array (), $condition.' and a_type ="1"', $limit );
  244. $data ['map'] = '文章管理';
  245. $data ['article'] = $page;
  246. $data['title']=$title;
  247. $this->render ( '/admin/article_manage', $data );
  248. }
  249. function article_manage_add() {
  250. if(isset($_POST['is_add'])){
  251. $cid=$this->get_args('cid');
  252. $title=$this->get_args('title');
  253. if($cid==0){
  254. echo "column is no select";
  255. return false;
  256. }
  257. if($title==""){
  258. //echo "title is empty";
  259. //return false;
  260. }
  261. Doo::loadModel ( 'Article' );
  262. $article = new Article ();
  263. $article->cid=$cid;
  264. $article->title=$title;
  265. $article->time=time();
  266. $article->content=stripcslashes ($this->get_args('content_text'));
  267. $article->enroll=stripcslashes ($this->get_args('enroll'));
  268. $article->enroll_title=$this->get_args('enroll_title');
  269. $article->enroll_obj=stripcslashes ($this->get_args('enroll_obj'));
  270. $article->enroll_content=stripcslashes ($this->get_args('enroll_content'));
  271. $article->enroll_fun=stripcslashes ($this->get_args('enroll_fun'));
  272. $article->enroll_adrr=stripcslashes ($this->get_args('enroll_adrr'));
  273. $article->enroll_pay=stripcslashes ($this->get_args('enroll_pay'));
  274. $article->enroll_name=stripcslashes ($this->get_args('enroll_name'));
  275. $article->synopsis=$this->get_args('synopsis');
  276. //缩略图
  277. $upload_file=$_FILES['thum']['tmp_name'];
  278. $upload_file_name=$_FILES['thum']['name'];
  279. $ext=_GetFileEXT($upload_file_name);
  280. $upload_file_name=time().".".$ext;
  281. if($upload_file){
  282. $store_dir="/upload_files/thum/";
  283. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  284. $article->thum="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  285. }
  286. }
  287. //缩略图
  288. $upload_file=$_FILES['enroll_downdoc']['tmp_name'];
  289. $upload_file_name=$_FILES['enroll_downdoc']['name'];
  290. $ext=_GetFileEXT($upload_file_name);
  291. $upload_file_name=time().".".$ext;
  292. if($upload_file){
  293. $store_dir="/upload_files/doc/";
  294. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  295. $article->enroll_downdoc="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  296. }
  297. }
  298. $article->enroll_mark=stripcslashes ($this->get_args('enroll_mark'));
  299. $article->enroll_time=$this->get_args("enroll_start").":".$this->get_args("enroll_end");
  300. $article->a_type=$this->get_args('a_type');
  301. if(!empty($title))
  302. $article->update_time=time();
  303. $article->insert();
  304. return '/admin/article_manage';
  305. }else{
  306. Doo::loadModel('Column');
  307. $column=new Column();
  308. $data['column']=$column->getColumnListByType(1);
  309. $data ['map'] = '<a href="/admin/article_manage" target="main">文章管理</a> » 添加文章';
  310. $this->render ( '/admin/article_manage_add',$data);
  311. }
  312. }
  313. function article_manage_edit() {
  314. Doo::loadModel ( 'Article' );
  315. $article = new Article ();
  316. if(isset($_POST['is_edit'])){
  317. $cid=$this->get_args('cid');
  318. $title=$this->get_args('title');
  319. if($cid==0){
  320. echo "column is no select";
  321. return false;
  322. }
  323. if($title==""){
  324. //echo "title is empty";
  325. //return false;
  326. }
  327. $article->aid=$this->get_args('aid');
  328. $article->cid=$cid;
  329. $article->title=$title;
  330. $article->content=stripcslashes ($this->get_args('content_text'));
  331. $article->enroll=stripcslashes ($this->get_args('enroll'));
  332. $article->enroll_title=$this->get_args('enroll_title');
  333. $article->enroll_obj=stripcslashes ($this->get_args('enroll_obj'));
  334. $article->enroll_content=stripcslashes ($this->get_args('enroll_content'));
  335. $article->enroll_fun=stripcslashes ($this->get_args('enroll_fun'));
  336. $article->enroll_adrr=stripcslashes ($this->get_args('enroll_adrr'));
  337. $article->enroll_pay=stripcslashes ($this->get_args('enroll_pay'));
  338. $article->enroll_name=stripcslashes ($this->get_args('enroll_name'));
  339. $article->synopsis=$this->get_args('synopsis');
  340. //缩略图
  341. $upload_file=$_FILES['thum']['tmp_name'];
  342. $upload_file_name=$_FILES['thum']['name'];
  343. $ext=_GetFileEXT($upload_file_name);
  344. $upload_file_name=time().".".$ext;
  345. if($upload_file){
  346. $store_dir="/upload_files/thum/";
  347. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  348. $article->thum="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  349. }
  350. //echo ".".$store_dir.$upload_file_name;die;
  351. }
  352. //缩略图
  353. $upload_file=$_FILES['enroll_downdoc']['tmp_name'];
  354. $upload_file_name=$_FILES['enroll_downdoc']['name'];
  355. $ext=_GetFileEXT($upload_file_name);
  356. $upload_file_name=time().".".$ext;
  357. if($upload_file){
  358. $store_dir="/upload_files/doc/";
  359. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  360. $article->enroll_downdoc="/sdown/".base64_encode(WEB_SITE.$store_dir.$upload_file_name);
  361. } else{
  362. echo "upload file error,";die;
  363. }
  364. }
  365. $article->enroll_mark=stripcslashes ($this->get_args('enroll_mark'));
  366. $article->enroll_time=$this->get_args("enroll_start").":".$this->get_args("enroll_end");
  367. $article->a_type=$this->get_args('a_type');
  368. $info=$article->getArticleById($this->get_args('aid'));
  369. if(!empty($title)&&empty($info[0]['update_time']))
  370. $article->update_time=time();
  371. $article->update();
  372. return '/admin/article_manage';
  373. }else{
  374. $aid=$this->check_params('aid');
  375. Doo::loadModel('Column');
  376. $column=new Column();
  377. $data['article']=$article->getArticleById($aid);
  378. $time=explode(":", $data['article'][0]['enroll_time']);
  379. $data['time']=$time;
  380. $data['column']=$column->getColumnListByType(1);
  381. $data ['map'] = '<a href="/admin/article_manage" target="main">文章管理</a> » 编辑文章';
  382. $this->render ( '/admin/article_manage_edit',$data);
  383. }
  384. }
  385. function trainingDeleteDoc(){
  386. $aid=isset($this->params ['aid'])&&is_numeric($this->params['aid'])?$this->params['aid']:0;
  387. if (!empty($aid)){
  388. Doo::loadModel ( 'Article' );
  389. $article = new Article ();
  390. $article->aid=$aid;
  391. $article->enroll_downdoc="";
  392. $article->update();
  393. header ( 'Content-Type:text/html;charset=utf-8' );
  394. echo '删除成功';die;
  395. }
  396. }
  397. function article_manage_delete() {
  398. $id = $this->get_args ( 'id' );
  399. Doo::loadModel ( 'Article' );
  400. $article = new Article ();
  401. $article->deleteArticleByIdList($id);
  402. return '/admin/article_manage';
  403. }
  404. function product_manage() {
  405. $n = "";
  406. $on_page = is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  407. //
  408. if ($on_page <= 0)
  409. $on_page = 1;
  410. $title = $this->get_args ( 'title' );
  411. $page_size = 18;
  412. // //检索条件
  413. if (! empty ( $title ))
  414. $n = " and title like '%" . $title . "%'";
  415. $condition=$n;
  416. $action = "/admin/product_manage/";
  417. //获取分页相关数据
  418. $page = $this->adminlogic->get_page ( "sc_product", $condition, $on_page, $page_size, $action, "", "admin" );
  419. $limit = " order by time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  420. Doo::loadModel('Product');
  421. $product=new Product();
  422. $page ['product_list'] = $product->getProductList ( array (), $condition, $limit );
  423. $data ['map'] = '产品管理';
  424. $data ['product'] = $page;
  425. $data['title']=$title;
  426. $this->render ( '/admin/product_manage', $data );
  427. }
  428. function product_manage_add() {
  429. if(isset($_POST['is_add'])){
  430. $cid=$this->get_args('cid');
  431. $title=$this->get_args('title');
  432. $fulltitle=$this->get_args('fulltitle');
  433. if($cid==0){
  434. echo "column is no select";
  435. return false;
  436. }
  437. if($title==""){
  438. echo "title is empty";
  439. return false;
  440. }
  441. Doo::loadModel ( 'Product' );
  442. $product = new Product ();
  443. $product->cid=$cid;
  444. $product->title=$title;
  445. $product->fulltitle=$fulltitle;
  446. $product->time=time();
  447. $product->p_type=$this->get_args('p_type');
  448. $product->content=stripcslashes ($this->get_args('content_text'));
  449. $product->edition=stripcslashes ($this->get_args('edition'));
  450. $upload_file=$_FILES['logo']['tmp_name'];
  451. $upload_file_name=$_FILES['logo']['name'];
  452. $ext=_GetFileEXT($upload_file_name);
  453. $upload_file_name=time().".".$ext;
  454. if($upload_file){
  455. $store_dir="/upload_files/proimg/";
  456. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  457. $product->logo=WEB_SITE.$store_dir.$upload_file_name;
  458. }
  459. }
  460. $product->link=$this->get_args('link');
  461. $anid=$this->get_args('anid');
  462. $anid=explode(",", $anid);
  463. $anid=array_unique($anid);
  464. $anid=implode(",", $anid);
  465. $product->anid=$anid;
  466. $did=$this->get_args('did');
  467. $did=explode(",", $did);
  468. $did=array_unique($did);
  469. $did=implode(",", $did);
  470. $product->did=$did;
  471. $product->insert();
  472. return '/admin/product_manage';
  473. }else{
  474. Doo::loadModel('Column');
  475. Doo::loadModel('Animation');
  476. Doo::loadModel('Down');
  477. $down=new Down();
  478. $animation = new Animation();
  479. $column=new Column();
  480. $data['animation']=$animation->getAnimationByBelong(2);
  481. $data['down']=$down->getDownList(array(), "", "limit 50");
  482. $data['column']=$column->getColumnListByType(1);
  483. $data ['map'] = '<a href="/admin/product_manage" target="main">产品管理</a> » 添加产品';
  484. $this->render ( '/admin/product_manage_add',$data);
  485. }
  486. }
  487. function product_manage_edit() {
  488. Doo::loadModel ( 'Product' );
  489. $product = new Product ();
  490. if(isset($_POST['is_edit'])){
  491. $cid=$this->get_args('cid');
  492. $title=$this->get_args('title');
  493. $fulltitle=$this->get_args('fulltitle');
  494. if($cid==0){
  495. echo "column is no select";
  496. return false;
  497. }
  498. if($title==""){
  499. echo "title is empty";
  500. return false;
  501. }
  502. $product->pid=$this->get_args('pid');
  503. $product->cid=$cid;
  504. $product->title=$title;
  505. $product->fulltitle=$fulltitle;
  506. $product->p_type=$this->get_args('p_type');
  507. $product->content=stripcslashes ($this->get_args('content'));
  508. $product->edition=stripcslashes ($this->get_args('edition'));
  509. $upload_file=$_FILES['logo']['tmp_name'];
  510. $upload_file_name=$_FILES['logo']['name'];
  511. $ext=_GetFileEXT($upload_file_name);
  512. $upload_file_name=time().".".$ext;
  513. if($upload_file){
  514. $store_dir="/upload_files/proimg/";
  515. if (move_uploaded_file($upload_file,".".$store_dir.$upload_file_name)) {
  516. $product->logo=WEB_SITE.$store_dir.$upload_file_name;
  517. }
  518. }
  519. $product->link=$this->get_args('link');
  520. $anid=$this->get_args('anid');
  521. $anid=explode(",", $anid);
  522. $anid=array_unique($anid);
  523. $anid=implode(",", $anid);
  524. $product->anid=$anid;
  525. $did=$this->get_args('did');
  526. $did=explode(",", $did);
  527. $did=array_unique($did);
  528. $did=implode(",", $did);
  529. $product->did=$did;
  530. $product->update();
  531. return '/admin/product_manage';
  532. }else{
  533. $pid=$this->check_params('pid');
  534. Doo::loadModel('Column');
  535. Doo::loadModel('Animation');
  536. Doo::loadModel('Down');
  537. $down=new Down();
  538. $animation = new Animation();
  539. $column=new Column();
  540. $data['product']=$product->getProductById($pid);
  541. $data['down']=$down->getDownList(array(), "", "limit 100");
  542. $data['column']=$column->getColumnListByType(1);
  543. $data['animation']=$animation->getAnimationByBelong(2);
  544. $data ['map'] = '<a href="/admin/product_manage" target="main">产品管理</a> » 编辑产品';
  545. $this->render ( '/admin/product_manage_edit',$data);
  546. }
  547. }
  548. function product_manage_delete() {
  549. $id = $this->get_args ( 'id' );
  550. Doo::loadModel ( 'Product' );
  551. $product = new Product ();
  552. $product->deleteProductByIdList($id);
  553. return '/admin/product_manage';
  554. }
  555. function column_manage() {
  556. $n = "";
  557. $on_page = is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  558. //
  559. if ($on_page <= 0)
  560. $on_page = 1;
  561. $title = $this->get_args ( 'title' );
  562. $page_size = 18;
  563. // //检索条件
  564. if (! empty ( $title ))
  565. $n = " and title like '%" . $title . "%'";
  566. $condition=$n;
  567. $action = "/admin/column_manage/";
  568. //获取分页相关数据
  569. $page = $this->adminlogic->get_page ( "sc_column", $condition, $on_page, $page_size, $action, "", "admin" );
  570. $limit = " order by cid desc limit " . $page ['lower'] . " , " . $page_size . " ";
  571. Doo::loadModel('Column');
  572. $column=new Column();
  573. $page ['column_list'] = $column->getColumnList ( array (), $condition, $limit );
  574. foreach ($page ['column_list'] as $key=>$value){
  575. $page ['column_list'][$key]['c_type']=getColumnType($value['c_type']);
  576. }
  577. $data ['map'] = '栏目管理';
  578. $data ['column'] = $page;
  579. $data['title']=$title;
  580. $this->render ( '/admin/column_manage', $data );
  581. }
  582. function column_manage_add() {
  583. if(isset($_POST['is_add'])){
  584. $title=$this->get_args('title');
  585. if($title==""){
  586. echo "title is empty";
  587. return false;
  588. }
  589. Doo::loadModel ( 'Column' );
  590. $column = new Column ();
  591. $column->c_type=$this->get_args('c_type');
  592. $column->title=$title;
  593. $column->display=$this->get_args('display');
  594. $column->link=$this->get_args('link');
  595. $column->description=$this->get_args('description');
  596. $column->insert();
  597. return '/admin/column_manage';
  598. }else{
  599. $data ['map'] = '<a href="/admin/column_manage" target="main">栏目管理</a> » 添加栏目';
  600. $this->render ( '/admin/column_manage_add',$data);
  601. }
  602. }
  603. function column_manage_edit() {
  604. Doo::loadModel ( 'Column' );
  605. $column = new Column ();
  606. if(isset($_POST['is_edit'])){
  607. $cid=$this->get_args('cid');
  608. $title=$this->get_args('title');
  609. if($cid==0){
  610. return false;
  611. }
  612. if($title==""){
  613. echo "title is empty";
  614. return false;
  615. }
  616. $column->cid=$cid;
  617. $column->title=$title;
  618. $column->display=$this->get_args('display');
  619. $column->link=$this->get_args('link');
  620. $column->description=$this->get_args('description');
  621. $column->update();
  622. return '/admin/column_manage';
  623. }else{
  624. $cid=$this->check_params('cid');
  625. $data['column']=$column->getColumnById($cid);
  626. $data ['map'] = '<a href="/admin/column_manage" target="main">栏目管理</a> » 编辑栏目';
  627. $this->render ( '/admin/column_manage_edit',$data);
  628. }
  629. }
  630. function column_manage_delete() {
  631. $id = $this->get_args ( 'id' );
  632. Doo::loadModel ( 'Column' );
  633. $column = new Column ();
  634. $column->deleteColumnByIdList($id);
  635. return '/admin/column_manage';
  636. }
  637. function animation_manage(){
  638. $n = "";
  639. $on_page = is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  640. //
  641. if ($on_page <= 0)
  642. $on_page = 1;
  643. $title = $this->get_args ( 'title' );
  644. $page_size = 18;
  645. // //检索条件
  646. if (! empty ( $title ))
  647. $n = " and title like '%" . $title . "%'";
  648. $condition=$n;
  649. $action = "/admin/animation_manage/";
  650. //获取分页相关数据
  651. $page = $this->adminlogic->get_page ( "sc_animation", $condition, $on_page, $page_size, $action, "", "admin" );
  652. $limit = " order by aid desc limit " . $page ['lower'] . " , " . $page_size . " ";
  653. Doo::loadModel('Animation');
  654. $animation=new Animation();
  655. $page ['animation_list'] = $animation->getAnimationList ( array (), $condition, $limit );
  656. $data ['map'] = '动画管理';
  657. $data ['animation'] = $page;
  658. $data['title']=$title;
  659. $this->render ( '/admin/animation_manage', $data );
  660. }
  661. function animation_manage_add(){
  662. if(isset($_POST['is_add'])){
  663. $title=$this->get_args('title');
  664. if($title==""){
  665. echo "title is empty";
  666. return false;
  667. }
  668. Doo::loadModel ( 'Animation' );
  669. $animation = new Animation ();
  670. $animation->title=$title;
  671. $animation->url=stripcslashes ($this->get_args('url'));
  672. //$animation->down_url="/sdown/".base64_encode(stripcslashes ($this->get_args('down_url')));
  673. $animation->down_url=$this->get_args('down_url');
  674. $animation->belong=$this->get_args('belong');
  675. $animation->img_url=$this->get_args('img_url');
  676. $animation->insert();
  677. return '/admin/animation_manage';
  678. }else{
  679. $data ['map'] = '<a href="/admin/animation_manage" target="main">动画管理</a> » 添加动画';
  680. $this->render ( '/admin/animation_manage_add',$data);
  681. }
  682. }
  683. function animation_manage_edit(){
  684. Doo::loadModel ( 'Animation' );
  685. $animation = new Animation ();
  686. if(isset($_POST['is_edit'])){
  687. $title=$this->get_args('title');
  688. if($title==""){
  689. echo "title is empty";
  690. return false;
  691. }
  692. $animation->aid=$this->get_args('aid');
  693. $animation->title=$title;
  694. $animation->url=stripcslashes ($this->get_args('url'));
  695. //$animation->down_url="/sdown/".base64_encode(stripcslashes ($this->get_args('down_url')));
  696. $animation->down_url=$this->get_args('down_url');
  697. $animation->belong=$this->get_args('belong');
  698. $animation->img_url=$this->get_args('img_url');
  699. $animation->update();
  700. return '/admin/animation_manage';
  701. }else{
  702. $aid=$this->check_params('aid');
  703. $data['animation']=$animation->getAnimationById($aid);
  704. $data ['map'] = '<a href="/admin/animation_manage" target="main">动画管理</a> » 编辑动画';
  705. $this->render ( '/admin/animation_manage_edit',$data);
  706. }
  707. }
  708. function animation_manage_delete(){
  709. $id = $this->get_args ( 'id' );
  710. Doo::loadModel ( 'Animation' );
  711. $animation = new Animation ();
  712. $animation->deleteAnimationByIdList($id);
  713. return '/admin/animation_manage';
  714. }
  715. function down_manage(){
  716. $n = "";
  717. $on_page = is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  718. //
  719. if ($on_page <= 0)
  720. $on_page = 1;
  721. $title = $this->get_args ( 'title' );
  722. $page_size = 18;
  723. //检索条件
  724. if (! empty ( $title ))
  725. $n = " and title like '%" . $title . "%'";
  726. $condition=$n;
  727. $action = "/admin/down_manage/";
  728. //获取分页相关数据
  729. $page = $this->adminlogic->get_page ( "sc_down", $condition, $on_page, $page_size, $action, "", "admin" );
  730. $limit = " order by did desc limit " . $page ['lower'] . " , " . $page_size . " ";
  731. Doo::loadModel('Down');
  732. $down=new Down();
  733. $page ['down_list'] = $down->getDownList ( array (), $condition, $limit );
  734. $data ['map'] = '下载管理';
  735. $data ['down'] = $page;
  736. $data['title']=$title;
  737. $this->render ( '/admin/down_manage', $data );
  738. }
  739. function down_manage_add(){
  740. if(isset($_POST['is_add'])){
  741. $title=$this->get_args('title');
  742. $fulltitle=$this->get_args('fulltitle');
  743. if($title==""){
  744. echo "title is empty";
  745. return false;
  746. }
  747. Doo::loadModel ( 'Down' );
  748. $down = new Down ();
  749. $down->did=$this->get_args('did');
  750. $down->title=$title;
  751. $down->fulltitle=$fulltitle;
  752. $down_url=$this->get_args('down_url');
  753. $down_url=explode("{b}", $down_url);
  754. foreach ($down_url as $key=>$value){
  755. //$down_url[$key]="/sdown/".base64_encode($value);
  756. $down_url[$key]=$value;
  757. }
  758. $down_url=implode("{b}", $down_url);
  759. $down->down_url=$down_url;
  760. $down->key_number=$this->get_args('key_number');
  761. $down->size=$this->get_args('size');
  762. $down->insert();
  763. return '/admin/down_manage';
  764. }else{
  765. $data ['map'] = '<a href="/admin/down_manage" target="main">下载管理</a> » 添加下载';
  766. $this->render ( '/admin/down_manage_add',$data);
  767. }
  768. }
  769. function down_manage_edit(){
  770. Doo::loadModel ( 'Down' );
  771. $down = new Down ();
  772. if(isset($_POST['is_edit'])){
  773. $title=$this->get_args('title');
  774. $fulltitle=$this->get_args('fulltitle');
  775. if($title==""){
  776. echo "title is empty";
  777. return false;
  778. }
  779. $down->did=$this->get_args('did');
  780. $down->title=$title;
  781. $down->fulltitle=$fulltitle;
  782. $down_url=$this->get_args('down_url');
  783. $down_url=explode("{b}", $down_url);
  784. foreach ($down_url as $key=>$value){
  785. //$down_url[$key]="/sdown/".base64_encode($value);
  786. $down_url[$key]=$value;
  787. }
  788. $down_url=implode("{b}", $down_url);
  789. $down->down_url=$down_url;
  790. $down->key_number=$this->get_args('key_number');
  791. $down->size=$this->get_args('size');
  792. $down->update();
  793. return '/admin/down_manage';
  794. }else{
  795. $did=$this->check_params('did');
  796. $data['down']=$down->getDownById($did);
  797. $data ['map'] = '<a href="/admin/down_manage" target="main">下载管理</a> » 下载文章';
  798. $this->render ( '/admin/down_manage_edit',$data);
  799. }
  800. }
  801. function down_manage_delete(){
  802. $id = $this->get_args ( 'id' );
  803. Doo::loadModel ( 'Down' );
  804. $down = new Down ();
  805. $down->deleteDownByIdList($id);
  806. return '/admin/down_manage';
  807. }
  808. /**
  809. * 检测数据输入的非法字符和转义非法字符
  810. */
  811. function check_params($name = "") {
  812. if (isset ( $this->params [$name] )) {
  813. return addslashes ( $this->params [$name] );
  814. } else {
  815. return false;
  816. }
  817. }
  818. /**
  819. * 获取get或者POST值
  820. * @param string $name 属性名称
  821. * @return fixed 值
  822. */
  823. function get_args($name) {
  824. if (isset ( $_GET [$name] )) {
  825. if (is_array ( $_GET [$name] ))
  826. return $_GET [$name];
  827. else
  828. return addslashes ( $_GET [$name] );
  829. } elseif (isset ( $_POST [$name] )) {
  830. if (is_array ( $_POST [$name] ))
  831. return $_POST [$name];
  832. else
  833. return addslashes ( $_POST [$name] );
  834. } else {
  835. return false;
  836. }
  837. }
  838. }
  839. ?>