| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- <?php
- if (!defined('IN_MYMPS')) {
- exit('Forbidden');
- }
- $ac = in_array($ac, array('list', 'new', 'edit')) ? $ac : 'list';
- $documenttype = get_member_docutype();
- if (submit_check('document_submit')) {
- $name_file = 'docu_image';
- if (in_array($ac, array('new', 'edit'))) {
- require_once MYMPS_DATA . '/config.inc.php';
- $title = isset($title) ? trim($title) : '';
- $author = isset($author) ? trim($author) : '';
- $source = isset($source) ? trim($source) : '';
- $tid = isset($tid) ? intval($tid) : '';
- $content = isset($content) ? trim($content) : '';
- $content = maddslashes($content);
- $content = preg_replace('/<a[^>]+>(.+?)<\\/a>/i', '$1', $content);
- if (empty($title)) {
- write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=30&tid=' . $tid . '&id=' . $id);
- }
- if (empty($author)) {
- write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=31&tid=' . $tid . '&id=' . $id);
- }
- if (empty($author)) {
- write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=32&tid=' . $tid . '&id=' . $id);
- }
- if (empty($content)) {
- write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=33&tid=' . $tid . '&id=' . $id);
- }
- if (empty($tid)) {
- write_msg('', '?m=document&type=corp&ac=' . $ac . '&error=34&tid=' . $tid . '&id=' . $id);
- }
- }
- if ($ac == 'new') {
- $article_maxpost = $group['article_maxpost'];
- $cur_article = mymps_count('member_docu', ' WHERE userid = \'' . $s_uid . '\'');
- if ($article_maxpost <= $cur_article) {
- write_msg('', '?m=document&type=corp&ac=list&error=50');
- exit();
- }
- if ($documenttype[$tid]['arrid'] == '2' && $_FILES[$name_file]['name']) {
- require_once MYMPS_INC . '/upfile.fun.php';
- check_upimage($name_file);
- $destination = '/document/' . date('Ym') . '/';
- $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 = $mymps_image[0];
- $pre_imgpath = $mymps_image[1];
- $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 . '\')');
- }
- else {
- $db->query('INSERT INTO `' . $db_mymps . 'member_docu` (title,author,source,pubtime,userid,content,typeid) VALUES (\'' . $title . '\',\'' . $author . '\',\'' . $source . '\',\'' . $timestamp . '\',\'' . $s_uid . '\',\'' . $content . '\',\'' . $tid . '\')');
- }
- $id = $db->insert_id();
- write_msg('', '?m=document&type=corp&success=8&ac=list');
- }
- else {
- if ($ac == 'edit' && !empty($id)) {
- if (!($row = $db->getRow('SELECT typeid,id FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id = \'' . $id . '\''))) {
- write_msg('', '?m=document&type=corp&ac=list&error=1');
- }
- if ($docutype_arr[$row['typeid']]['arrid'] == '2' && $_FILES[$name_file]['name']) {
- require_once MYMPS_INC . '/upfile.fun.php';
- $destination = '/document/' . date('Ym') . '/';
- check_upimage($name_file);
- $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);
- $imgpath = $mymps_image[0];
- $pre_imgpath = $mymps_image[1];
- $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 . '\'');
- }
- else {
- $db->query('UPDATE `' . $db_mymps . 'member_docu` SET title = \'' . $title . '\',content = \'' . $content . '\',author = \'' . $author . '\', source = \'' . $source . '\' ,pubtime = \'' . $timestamp . '\' ' . $where . ' AND id = \'' . $id . '\'');
- }
- write_msg('', '?m=document&type=corp&success=8&tid=' . $row[tid]);
- }
- else {
- empty($selectedids) && write_msg('', '?m=document&type=corp&error=1&page=' . $page . '&tid=' . $tid . '&ac=' . $ac);
- $create_in = create_in($selectedids);
- $query = $db->query('SELECT * FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id ' . $create_in);
- while ($row = $db->fetchRow($query)) {
- $delete[$row['id']]['pre_imgpath'] = $row['pre_imgpath'];
- $delete[$row['id']]['imgpath'] = $row['imgpath'];
- }
- foreach ($delete as $k => $v) {
- @unlink(MYMPS_ROOT . $v['imgpath']);
- @unlink(MYMPS_ROOT . $v['pre_imgpath']);
- }
- $db->query('DELETE FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id ' . $create_in);
- unset($delete);
- unset($row);
- unset($query);
- unset($create_in);
- write_msg('', '?m=document&type=corp&success=3&page=' . $page . '&tid=' . $tid . '&ac=' . $ac);
- }
- }
- }
- else {
- $tid = isset($tid) ? intval($tid) : '';
- $ifcheck_arr = array('<font color=red>待审</font>', '<font color=green>正常</font>');
- if ($ac == 'list') {
- $tid == '' && ($tid = $db->getOne('SELECT MIN(typeid) FROM `' . $db_mymps . 'member_docutype` WHERE ifview = 2'));
- $where .= !empty($tid) ? ' AND typeid = \'' . $tid . '\'' : '';
- $rows_num = mymps_count('member_docu', $where);
- $param = setParam(array('m', 'type', 'tid', 'ac'));
- $document = page1('SELECT * FROM `' . $db_mymps . 'member_docu` ' . $where . ' ORDER BY id DESC');
- }
- else if ($ac == 'new') {
- $article_maxpost = $group['article_maxpost'];
- $cur_article = mymps_count('member_docu', ' WHERE userid = \'' . $s_uid . '\'');
- if ($article_maxpost <= $cur_article) {
- write_msg('', '?m=document&type=corp&ac=list&error=50');
- exit();
- }
- $acontent = get_editor('content', 'Member', '', '90%', '400px');
- }
- else if ($ac == 'edit') {
- if (empty($id)) {
- write_msg('', '?m=document&type=corp&error=1&ac=' . $ac . '&page=' . $page);
- }
- $edit = $db->getRow('SELECT * FROM `' . $db_mymps . 'member_docu` ' . $where . ' AND id = \'' . $id . '\'');
- $tid = $edit['typeid'];
- $acontent = get_editor('content', 'Member', $edit['content'], '90%', '400px');
- }
- $location = location('corp');
- include in_array($ac, array('new', 'edit')) ? mymps_tpl('document') : mymps_tpl('document_' . $ac);
- }
- ?>
|