inc_document.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. if (!defined('IN_MYMPS')) {
  3. exit('Forbidden');
  4. }
  5. $ac = in_array($ac, array('list', 'new', 'edit')) ? $ac : 'list';
  6. $documenttype = get_member_docutype();
  7. if (submit_check('document_submit')) {
  8. $name_file = 'docu_image';
  9. if (in_array($ac, array('new', 'edit'))) {
  10. require_once MYMPS_DATA . '/config.inc.php';
  11. $title = isset($title) ? trim($title) : '';
  12. $author = isset($author) ? trim($author) : '';
  13. $source = isset($source) ? trim($source) : '';
  14. $tid = isset($tid) ? intval($tid) : '';
  15. $content = isset($content) ? trim($content) : '';
  16. $content = maddslashes($content);
  17. $content = preg_replace('/<a[^>]+>(.+?)<\\/a>/i', '$1', $content);
  18. if (empty($title)) {
  19. write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=30&tid=' . $tid . '&id=' . $id);
  20. }
  21. if (empty($author)) {
  22. write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=31&tid=' . $tid . '&id=' . $id);
  23. }
  24. if (empty($author)) {
  25. write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=32&tid=' . $tid . '&id=' . $id);
  26. }
  27. if (empty($content)) {
  28. write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=33&tid=' . $tid . '&id=' . $id);
  29. }
  30. if (empty($tid)) {
  31. write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=34&tid=' . $tid . '&id=' . $id);
  32. }
  33. }
  34. if ($ac == 'new') {
  35. $article_maxpost = $group['article_maxpost'];
  36. $cur_article = mymps_count('member_docu', ' WHERE userid = \'' . $s_uid . '\'');
  37. if ($article_maxpost <= $cur_article) {
  38. write_msg('', '?m=document&type=corp&ac=list&error=50');
  39. exit();
  40. }
  41. if ($documenttype[$tid]['arrid'] == '2' && $_FILES[$name_file]['name']) {
  42. require_once MYMPS_INC . '/upfile.fun.php';
  43. check_upimage($name_file);
  44. $destination = '/document/' . date('Ym') . '/';
  45. $mymps_image = start_upload($name_file, $destination, $mymps_global['cfg_upimg_watermark'], $mymps_mymps['cfg_normal_limit']['width'], $mymps_mymps['cfg_normal_limit']['height']);
  46. $imgpath = $mymps_image[0];
  47. $pre_imgpath = $mymps_image[1];
  48. $db->query('INSERT INTO `' . $db_mymps . 'member_docu` (title,author,source,pubtime,userid,content,imgpath,pre_imgpath,typeid) VALUES (\'' . $title . '\',\'' . $author . '\',\'' . $source . '\',\'' . $timestamp . '\',\'' . $s_uid . '\',\'' . $content . '\',\'' . $imgpath . '\',\'' . $pre_imgpath . '\',\'' . $tid . '\')');
  49. }
  50. else {
  51. $db->query('INSERT INTO `' . $db_mymps . 'member_docu` (title,author,source,pubtime,userid,content,typeid) VALUES (\'' . $title . '\',\'' . $author . '\',\'' . $source . '\',\'' . $timestamp . '\',\'' . $s_uid . '\',\'' . $content . '\',\'' . $tid . '\')');
  52. }
  53. $id = $db->insert_id();
  54. write_msg('', '?m=document&type=corp&success=8&ac=list');
  55. }
  56. else {
  57. if ($ac == 'edit' && !empty($id)) {
  58. if (!($row = $db->getRow('SELECT typeid,id FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id = \'' . $id . '\''))) {
  59. write_msg('', '?m=document&type=corp&ac=list&error=1');
  60. }
  61. if ($docutype_arr[$row['typeid']]['arrid'] == '2' && $_FILES[$name_file]['name']) {
  62. require_once MYMPS_INC . '/upfile.fun.php';
  63. $destination = '/document/' . date('Ym') . '/';
  64. check_upimage($name_file);
  65. $mymps_image = start_upload($name_file, $destination, $mymps_global['cfg_upimg_watermark'], $mymps_mymps['cfg_normal_limit']['width'], $mymps_mymps['cfg_normal_limit']['height'], $imgpath, $pre_imgpath);
  66. $imgpath = $mymps_image[0];
  67. $pre_imgpath = $mymps_image[1];
  68. $db->query('UPDATE `' . $db_mymps . 'member_docu` SET title = \'' . $title . '\',content = \'' . $content . '\',author = \'' . $author . '\', source = \'' . $source . '\' ,pubtime = \'' . $timestamp . '\' ,imgpath = \'' . $imgpath . '\' , pre_imgpath = \'' . $pre_imgpath . '\' ' . $where . ' AND id = \'' . $id . '\'');
  69. }
  70. else {
  71. $db->query('UPDATE `' . $db_mymps . 'member_docu` SET title = \'' . $title . '\',content = \'' . $content . '\',author = \'' . $author . '\', source = \'' . $source . '\' ,pubtime = \'' . $timestamp . '\' ' . $where . ' AND id = \'' . $id . '\'');
  72. }
  73. write_msg('', '?m=document&type=corp&success=8&tid=' . $row[tid]);
  74. }
  75. else {
  76. empty($selectedids) && write_msg('', '?m=document&type=corp&error=1&page=' . $page . '&tid=' . $tid . '&ac=' . $ac);
  77. $create_in = create_in($selectedids);
  78. $query = $db->query('SELECT * FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id ' . $create_in);
  79. while ($row = $db->fetchRow($query)) {
  80. $delete[$row['id']]['pre_imgpath'] = $row['pre_imgpath'];
  81. $delete[$row['id']]['imgpath'] = $row['imgpath'];
  82. }
  83. foreach ($delete as $k => $v) {
  84. @unlink(MYMPS_ROOT . $v['imgpath']);
  85. @unlink(MYMPS_ROOT . $v['pre_imgpath']);
  86. }
  87. $db->query('DELETE FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id ' . $create_in);
  88. unset($delete);
  89. unset($row);
  90. unset($query);
  91. unset($create_in);
  92. write_msg('', '?m=document&type=corp&success=3&page=' . $page . '&tid=' . $tid . '&ac=' . $ac);
  93. }
  94. }
  95. }
  96. else {
  97. $tid = isset($tid) ? intval($tid) : '';
  98. $ifcheck_arr = array('<font color=red>待审</font>', '<font color=green>正常</font>');
  99. if ($ac == 'list') {
  100. $tid == '' && ($tid = $db->getOne('SELECT MIN(typeid) FROM `' . $db_mymps . 'member_docutype` WHERE ifview = 2'));
  101. $where .= !empty($tid) ? ' AND typeid = \'' . $tid . '\'' : '';
  102. $rows_num = mymps_count('member_docu', $where);
  103. $param = setParam(array('m', 'type', 'tid', 'ac'));
  104. $document = page1('SELECT * FROM `' . $db_mymps . 'member_docu` ' . $where . ' ORDER BY id DESC');
  105. }
  106. else if ($ac == 'new') {
  107. $article_maxpost = $group['article_maxpost'];
  108. $cur_article = mymps_count('member_docu', ' WHERE userid = \'' . $s_uid . '\'');
  109. if ($article_maxpost <= $cur_article) {
  110. write_msg('', '?m=document&type=corp&ac=list&error=50');
  111. exit();
  112. }
  113. $acontent = get_editor('content', 'Member', '', '90%', '400px');
  114. }
  115. else if ($ac == 'edit') {
  116. if (empty($id)) {
  117. write_msg('', '?m=document&type=corp&error=1&ac=' . $ac . '&page=' . $page);
  118. }
  119. $edit = $db->getRow('SELECT * FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id = \'' . $id . '\'');
  120. $tid = $edit['typeid'];
  121. $acontent = get_editor('content', 'Member', $edit['content'], '90%', '400px');
  122. }
  123. $location = location('corp');
  124. include in_array($ac, array('new', 'edit')) ? mymps_tpl('document') : mymps_tpl('document_' . $ac);
  125. }
  126. ?>