focus.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. //decode by http://dezend.qiling.org QQ 2859470
  3. define('CURSCRIPT', 'focus');
  4. require_once dirname(__FILE__) . '/global.php';
  5. require_once MYMPS_INC . '/db.class.php';
  6. $part = $part ? $part : 'list';
  7. (!in_array($typename, array('网站首页', '新闻首页')) || !$typename) && ($typename = '网站首页');
  8. !in_array($part, array('list', 'add', 'edit')) && ($part = 'list');
  9. require_once MYMPS_DATA . '/config.inc.php';
  10. $tpl_index = $db->getOne('SELECT value FROM `' . $db_mymps . 'config` WHERE type=\'tpl\' AND description = \'tpl_set\'');
  11. $tpl_index = $tpl_index ? $charset == 'utf-8' ? utf8_unserialize($tpl_index) : unserialize($tpl_index) : $defaultset['classic'];
  12. if (!submit_check(CURSCRIPT . '_submit')) {
  13. if ($part == 'list') {
  14. chk_admin_purview('purview_幻灯片列表');
  15. $sql = 'SELECT * FROM `' . $db_mymps . 'focus` WHERE typename = \'' . $typename . '\' ORDER BY focusorder DESC';
  16. $row = $db->getAll($sql);
  17. $here = $typename . '幻灯片修改';
  18. } else {
  19. if ($part == 'add') {
  20. chk_admin_purview('purview_上传幻灯片');
  21. $here = '添加幻灯片';
  22. $maxorder = $db->getOne('SELECT MAX(focusorder) FROM ' . $db_mymps . 'focus');
  23. $maxorder = $maxorder + 1;
  24. } else {
  25. if ($part == 'edit') {
  26. if (empty($id)) {
  27. write_msg('您未指定ID');
  28. }
  29. $row = $db->getRow('SELECT * FROM ' . $db_mymps . 'focus WHERE id =\'' . $id . '\'');
  30. $here = '修改' . $row[typename] . '幻灯片';
  31. }
  32. }
  33. }
  34. include mymps_tpl(CURSCRIPT . '_' . $part);
  35. } else {
  36. require_once MYMPS_INC . '/upfile.fun.php';
  37. $limit = $typename == '新闻首页' ? 'news' : 'index';
  38. if ($part == 'add') {
  39. $name_file = 'mymps_focus';
  40. if ($_FILES[$name_file]['name']) {
  41. check_upimage($name_file);
  42. $destination = '/focus/';
  43. $mymps_image = start_upload($name_file, $destination, 0, $mymps_mymps['cfg_focus_limit'][$tpl_index['banmian']]['index']['width'], $mymps_mymps['cfg_focus_limit'][$tpl_index['banmian']]['index']['height']);
  44. unset($limit);
  45. $db->query('INSERT INTO `' . $db_mymps . 'focus` (id,image,pre_image,words,url,pubdate,focusorder,typename)' . "\r\n\t\t\t\t\t" . 'VALUES(\'\',\'' . $mymps_image[0] . '\',\'' . $mymps_image[1] . '\',\'' . $words . '\',\'' . $url . '\',\'' . $timestamp . '\',\'' . $focusorder . '\',\'' . $typename . '\')');
  46. clear_cache_files('focus_index');
  47. clear_cache_files('focus_news');
  48. }
  49. } else {
  50. if ($part == 'edit') {
  51. $name_file = 'mymps_focus';
  52. if ($_FILES[$name_file]['name']) {
  53. check_upimage($name_file);
  54. $destination = '/focus/';
  55. $mymps_image = start_upload($name_file, $destination, 0, $mymps_mymps['cfg_focus_limit'][$tpl_index['banmian']]['index']['width'], $mymps_mymps['cfg_focus_limit'][$tpl_index['banmian']]['index']['height'], $image, $pre_image);
  56. unset($limit);
  57. $image = $mymps_image[0];
  58. $pre_image = $mymps_image[1];
  59. }
  60. $res = $db->query('UPDATE `' . $db_mymps . 'focus` SET image=\'' . $image . '\',pre_image=\'' . $pre_image . '\',words=\'' . $words . '\',url=\'' . $url . '\',focusorder=\'' . $focusorder . '\' WHERE id = \'' . $id . '\'');
  61. clear_cache_files('focus_index');
  62. clear_cache_files('focus_news');
  63. } else {
  64. if ($part == 'list') {
  65. if (is_array($delids)) {
  66. foreach ($delids as $kids => $vids) {
  67. $delrow = $db->getRow('SELECT image,pre_image FROM `' . $db_mymps . 'focus` WHERE id = \'' . $vids . '\'');
  68. @unlink(MYMPS_ROOT . $delrow['image']);
  69. @unlink(MYMPS_ROOT . $delrow['pre_image']);
  70. mymps_delete(CURSCRIPT, 'WHERE id = ' . $vids);
  71. }
  72. }
  73. if (is_array($displayorder)) {
  74. foreach ($displayorder as $key => $val) {
  75. $db->query('UPDATE `' . $db_mymps . 'focus` SET focusorder = \'' . $val . '\' WHERE id = ' . $key);
  76. }
  77. }
  78. clear_cache_files('focus_index');
  79. clear_cache_files('focus_news');
  80. }
  81. }
  82. }
  83. write_msg('成功上传或更新 ' . $typename . ' 幻灯片!', '?part=list&typename=' . $typename, 'mymps');
  84. }
  85. is_object($db) && $db->Close();
  86. $db = $mymps_global = $part = $action = $here = NULL;