mayi-post.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <?php
  2. function post_cat_info($catid)
  3. {
  4. global $db;
  5. global $db_mymps;
  6. return $db->getRow('SELECT a.catid,a.modid,a.if_upimg,a.catname,b.catid as parentid,a.if_mappoint,b.catname as parentname FROM `' . $db_mymps . 'category` AS a LEFT JOIN `' . $db_mymps . 'category` AS b ON a.parentid = b.catid WHERE a.catid = \'' . $catid . '\'');
  7. }
  8. define('IN_SMT', true);
  9. define('CURSCRIPT', 'post');
  10. define('IN_MYMPS', true);
  11. define('IN_MANAGE', true);
  12. require_once dirname(__FILE__) . '/include/global.php';
  13. require_once dirname(__FILE__) . '/data/config.php';
  14. require_once MYMPS_DATA . '/config.db.php';
  15. require_once MYMPS_INC . '/db.class.php';
  16. require_once MYMPS_INC . '/upfile.fun.php';
  17. require_once MYMPS_DATA . '/config.inc.php';
  18. ifsiteopen();
  19. $authcodesettings = read_static_cache('authcodesettings');
  20. !in_array($action, array('input', 'edit', 'ok')) && ($action = 'input');
  21. $action = isset($action) ? trim($action) : '';
  22. if ($action != 'ok') {
  23. $ip = '';
  24. $ip = GetIP();
  25. $ip2area = ip2area($ip);
  26. }
  27. if ($act == 'dopost') {
  28. if (!$mixcode || $mixcode != md5($cookiepre)) {
  29. exit('FORBIDDEN');
  30. exit();
  31. }
  32. empty($areaid) && write_msg('请选择您要发布的地区!');
  33. empty($title) && write_msg('请输入信息标题!');
  34. empty($content) && write_msg('您还没有输入信息描述!');
  35. empty($tel) && write_msg('联系电话不能为空!');
  36. empty($contact_who) && write_msg('联系人不能为空!');
  37. mymps_check_upimage('mymps_img_');
  38. $lat = isset($lat) ? (double) $lat : '';
  39. $lng = isset($lng) ? (double) $lng : '';
  40. $id = $action == 'edit' ? intval($id) : '';
  41. $userid = isset($userid) ? mhtmlspecialchars($userid) : '';
  42. $manage_pwd = isset($manage_pwd) ? trim($manage_pwd) : '';
  43. $catid = intval($catid);
  44. if (empty($catid)) {
  45. write_msg('您未指定发布的信息栏目');
  46. }
  47. $areaid = intval($areaid);
  48. $streetid = intval($streetid);
  49. $title = trim(mhtmlspecialchars($title));
  50. $content = $mymps_global['cfg_post_editor'] == 1 ? $content : textarea_post_change($content);
  51. $begintime = $timestamp;
  52. $activetime = $endtime = intval($endtime);
  53. $endtime = $endtime == 0 ? 0 : $endtime * 3600 * 24 + $begintime;
  54. $ismember = intval($ismember);
  55. $mappoint = isset($mappoint) ? trim(mhtmlspecialchars($mappoint)) : '';
  56. $tel = isset($tel) ? trim(mhtmlspecialchars($tel)) : '';
  57. $qq = isset($qq) ? trim(mhtmlspecialchars($qq)) : '';
  58. $web_address = trim(mhtmlspecialchars($web_address));
  59. $email = isset($email) ? trim(mhtmlspecialchars($email)) : '';
  60. $result = verify_badwords_filter($mymps_global['cfg_if_info_verify'], $title, $content);
  61. $title = $result['title'];
  62. $content = $result['content'];
  63. $content = preg_replace('/<a[^>]+>(.+?)<\\/a>/i', '$1', $content);
  64. $info_level = $result['level'];
  65. unset($result);
  66. $extra = isset($extra) ? $extra : '';
  67. $d = $db->getRow('SELECT catname,dir_typename,modid,gid FROM `' . $db_mymps . 'category` WHERE catid = \'' . $catid . '\'');
  68. if ($action == 'input') {
  69. if (!empty($mymps_global['cfg_allow_post_area']) && !empty($ip2area)) {
  70. $i = 1;
  71. $allow_post_area = array();
  72. $allow_post_area = explode('=', $mymps_global['cfg_allow_post_area']);
  73. $allow_post_areas = explode(',', $allow_post_area[0]);
  74. foreach ($allow_post_areas as $k => $v) {
  75. if (strstr($ip2area, $v)) {
  76. $i = $i + 1;
  77. }
  78. }
  79. if ($allow_post_area[1] == '-1' && $i == 1) {
  80. write_msg('系统判断您的IP并非<b style=\'color:red\'>' . $allow_post_area[0] . '</b>本地IP!<br />如果您要继续操作,请联系客服。');
  81. exit();
  82. }
  83. else {
  84. if ($allow_post_area[1] == 0 && $i == 1) {
  85. $info_level = 0;
  86. }
  87. }
  88. unset($allow_post_area);
  89. unset($address);
  90. unset($ipdata);
  91. unset($allow_post_areas);
  92. unset($i);
  93. }
  94. $checkquestion = isset($checkquestion) ? $checkquestion : '';
  95. $data = '';
  96. @include MYMPS_DATA . '/caches/checkanswer_settings.php';
  97. if (is_array($data)) {
  98. $whenpost = $data['whenpost'];
  99. $result = read_static_cache('checkanswer');
  100. if ($whenpost == 1 && is_array($result)) {
  101. if (!is_array($checkquestion) || empty($checkquestion['answer']) || empty($checkquestion['id'])) {
  102. write_msg('您还没有输入验证问题!');
  103. exit();
  104. }
  105. if ($result[$checkquestion['id']]['answer'] != $checkquestion['answer']) {
  106. write_msg('您输入的验证问题答案不正确,请重新输入!');
  107. }
  108. }
  109. $result = $checkquestion = $whenpost = $data = NULL;
  110. }
  111. $img_count = upload_img_num('mymps_img_');
  112. if (!empty($mymps_global['cfg_disallow_post_tel']) && !empty($tel)) {
  113. $disallow_tel = array();
  114. $disallow_tel = explode('=', $mymps_global['cfg_disallow_post_tel']);
  115. $disallow_telarray = explode(',', $disallow_tel[0]);
  116. if ($disallow_tel[1] == -1) {
  117. in_array($tel, $disallow_telarray) && write_msg('您的电话号码<b style=\'color:red\'>' . $tel . '</b> 已被管理员加入黑名单!<br />如果您要继续操作,请联系客服。');
  118. }
  119. else if ($disallow_tel[1] == 0) {
  120. in_array($tel, $disallow_telarray) && ($info_level = 0);
  121. }
  122. unset($disallow_tel);
  123. unset($disallow_telarray);
  124. }
  125. if ($yet = $db->getOne('SELECT begintime FROM `' . $db_mymps . 'information` WHERE title=\'' . $title . '\' AND tel = \'' . $tel . '\' ORDER BY id DESC')) {
  126. if ($timestamp - $yet < 3600 * 24) {
  127. write_msg('请勿重复发布信息!', '?action=input&catid=' . $catid);
  128. }
  129. unset($yet);
  130. }
  131. if (empty($ismember)) {
  132. if ($mymps_global['cfg_if_nonmember_info'] != 1) {
  133. write_msg('对不起,您还没有登录!请您登录后再发布信息!');
  134. }
  135. if ($mymps_global['cfg_if_nonmember_info'] == 1 && 0 < $mymps_global['cfg_nonmember_perday_post']) {
  136. $count = mymps_count('information', 'WHERE ip = \'' . $ip . '\' AND begintime > \'' . mktime(0, 0, 0) . '\' AND ismember = \'0\'');
  137. $mymps_global[cfg_nonmember_perday_post] <= $count && write_msg('很抱歉!游客每天只能发布 <b style=\'color:red\'>' . $mymps_global[cfg_nonmember_perday_post] . '</b> 条信息<br />如果您要继续操作,请联系客服。');
  138. }
  139. empty($manage_pwd) && write_msg('请输入您的管理密码!以便于以后对该信息的修改和删除');
  140. empty($contact_who) && write_msg('请填写联系人!');
  141. $manage_pwd = md5($manage_pwd);
  142. if ($authcodesettings['post'] == 1 && !($randcode = mymps_chk_randcode($checkcode))) {
  143. write_msg('验证码输入错误,请返回重新输入');
  144. }
  145. $sql = 'INSERT INTO `' . $db_mymps . 'information` (title,content,gid,catid,catname,dir_typename,areaid,begintime,activetime,endtime,manage_pwd,ismember,ip,ip2area,info_level,qq,email,tel,contact_who,img_count,mappoint,latitude,longitude)VALUES(\'' . $title . '\',\'' . $content . '\',\'' . $d['gid'] . '\',\'' . $catid . '\',\'' . $d['catname'] . '\',\'' . $d['dir_typename'] . '\',\'' . $areaid . '\',\'' . $begintime . '\',\'' . $activetime . '\',\'' . $endtime . '\',\'' . $manage_pwd . '\',\'' . $ismember . '\',\'' . $ip . '\',\'' . $ip2area . '\',\'' . $info_level . '\',\'' . $qq . '\',\'' . $email . '\',\'' . $tel . '\',\'' . $contact_who . '\',\'' . $img_count . '\',\'' . $mappoint . '\',\'' . $lat . '\',\'' . $lng . '\')';
  146. }
  147. else if ($ismember == 1) {
  148. $s_uid = $status = '';
  149. require_once MYMPS_INC . '/member.class.php';
  150. if (!$member_log->chk_in()) {
  151. write_msg('对不起,您还没有登录!');
  152. }
  153. $memberinfo = $member_log->get_info();
  154. $status = $memberinfo['status'];
  155. $face = $memberinfo['prelogo'];
  156. if (empty($status)) {
  157. write_msg('您的账号 [<b>' . $s_uid . '</b>] 目前处于<font color=red>待审状态</font>!<br>请进入邮箱查收验证邮件或等待客服人员开通账号!');
  158. exit();
  159. }
  160. $per = $db->getRow('SELECT a.money_own,b.perday_maxpost,b.info_maxpost FROM `' . $db_mymps . 'member` AS a LEFT JOIN `' . $db_mymps . 'member_level` AS b ON a.levelid = b.id WHERE a.userid = \'' . $s_uid . '\'');
  161. $perday_maxpost = $per['perday_maxpost'];
  162. if (!empty($perday_maxpost)) {
  163. $count = mymps_count('information', 'WHERE userid LIKE \'' . $s_uid . '\' AND begintime > \'' . mktime(0, 0, 0) . '\'');
  164. $perday_maxpost <= $count && write_msg('很抱歉!您当前的会员级别每天只能发布 <b style=\'color:red\'>' . $perday_maxpost . '</b> 条信息<br />如果您要继续操作,请联系客服。');
  165. }
  166. if ($per[info_maxpost]) {
  167. $count = mymps_count('information', 'WHERE userid = \'' . $s_uid . '\'');
  168. $per[info_maxpost] <= $count && write_msg('很抱歉!您已超出发布数量总量限制<br />如果您要继续发布信息,请升级会员。');
  169. }
  170. if (!empty($perpost_money_cost)) {
  171. if ($per['money_own'] < $perpost_money_cost) {
  172. write_msg('您当前金币余额不足,发布一条信息需要支付' . $perpost_money_cost . '个金币!');
  173. exit();
  174. }
  175. }
  176. chk_member_purview('purview_info');
  177. $perpost_money_cost = $mymps_global['cfg_member_perpost_consume'] ? $mymps_global['cfg_member_perpost_consume'] : 0;
  178. $userid = trim($s_uid);
  179. if ($userid) {
  180. $row = $db->getRow('SELECT per_certify,com_certify FROM `' . $db_mymps . 'member` WHERE userid = \'' . $userid . '\'');
  181. if ($row['per_certify'] == 1 || $row['com_certify'] == 1) {
  182. $certify = 1;
  183. }
  184. else {
  185. $certify = 0;
  186. }
  187. unset($row);
  188. }
  189. if ($authcodesettings['memberpost'] == 1 && !($randcode = mymps_chk_randcode($checkcode))) {
  190. write_msg('验证码输入错误,请返回重新输入');
  191. }
  192. $sql = 'INSERT INTO `' . $db_mymps . 'information` (title,content,begintime,activetime,endtime,gid,catid,catname,dir_typename,areaid,userid,ismember,ip,ip2area,info_level,qq,email,tel,contact_who,img_count,mappoint,certify,latitude,longitude,face) Values (\'' . $title . '\',\'' . $content . '\',\'' . $begintime . '\',\'' . $activetime . '\',\'' . $endtime . '\',\'' . $d['gid'] . '\',\'' . $catid . '\',\'' . $d['catname'] . '\',\'' . $d['dir_typename'] . '\',\'' . $areaid . '\',\'' . $userid . '\',\'' . $ismember . '\',\'' . $ip . '\',\'' . $ip2area . '\',\'' . $info_level . '\',\'' . $qq . '\',\'' . $email . '\',\'' . $tel . '\',\'' . $contact_who . '\',\'' . $img_count . '\',\'' . $mappoint . '\',\'' . $certify . '\',\'' . $lat . '\',\'' . $lng . '\',\'' . $face . '\')';
  193. $score_change = get_credit_score();
  194. $score_changer = $score_change['score']['rank']['information'];
  195. $score_changer = $score_changer == 0 ? '+0' : $score_changer;
  196. if ($score_changer) {
  197. $db->query('UPDATE `' . $db_mymps . 'member` SET score = score' . $score_changer . (' WHERE userid = \'' . $userid . '\''));
  198. }
  199. $score_change = $score_changer = NULL;
  200. if (!empty($perpost_money_cost)) {
  201. $db->query('UPDATE `' . $db_mymps . 'member` SET money_own = money_own-\'' . $perpost_money_cost . '\' WHERE userid = \'' . $userid . '\'');
  202. }
  203. }
  204. else {
  205. exit('Access Denied!');
  206. }
  207. $db->query($sql);
  208. $id = $db->insert_id();
  209. $k = $v = NULL;
  210. if (is_array($extra) && 1 < $d['modid']) {
  211. foreach ($extra as $k => $v) {
  212. $v = is_array($v) ? implode(',', $v) : $v;
  213. $sql1 .= ',`' . $k . '`';
  214. $sql2 .= ',\'' . $v . '\'';
  215. }
  216. $sql = '(id.' . $sql1 . ')VALUES(\'' . $id . '\',\'\',\'\')';
  217. $db->query('INSERT INTO `' . $db_mymps . 'information_' . $d[modid] . '` (`id`' . $sql1 . ')VALUES(\'' . $id . '\'' . $sql2 . ')');
  218. unset($sql1);
  219. unset($sql2);
  220. }
  221. if (0 < $img_count) {
  222. $img_path = '';
  223. for ($i = 0; $i < $img_count; $i++) {
  224. $name_file = 'mymps_img_' . $i;
  225. if ($_FILES[$name_file]['name']) {
  226. $destination = '/information/' . date('Ym') . '/';
  227. $mymps_image = start_upload($name_file, $destination, $mymps_global['cfg_upimg_watermark'], $mymps_mymps['cfg_information_limit']['width'], $mymps_mymps['cfg_information_limit']['height']);
  228. $db->query('INSERT INTO `' . $db_mymps . 'info_img` (image_id,path,prepath,infoid,uptime) VALUES (\'' . $i . '\',\'' . $mymps_image[0] . '\',\'' . $mymps_image[1] . '\',\'' . $id . '\',\'' . $timestamp . '\')');
  229. }
  230. if ($i === 0) {
  231. $img_path = $mymps_image[1];
  232. }
  233. }
  234. if ($img_path) {
  235. $db->query('UPDATE `' . $db_mymps . 'information` SET img_path = \'' . $img_path . '\' WHERE id = \'' . $id . '\'');
  236. }
  237. }
  238. write_msg('', '?action=ok&id=' . $id . '&title=' . urlencode($title) . '&level=' . $info_level . '&filepath=' . $infopath);
  239. }
  240. else if ($action == 'edit') {
  241. if (is_array($_FILES)) {
  242. for ($i = 0; $i < count($_FILES); $i++) {
  243. $name_file = 'mymps_img_' . $i;
  244. if ($_FILES[$name_file]['name']) {
  245. $destination = '/information/' . date('Ym') . '/';
  246. $mymps_image = start_upload($name_file, $destination, $mymps_global['cfg_upimg_watermark'], $mymps_mymps['cfg_information_limit']['width'], $mymps_mymps['cfg_information_limit']['height']);
  247. if ($row = $db->getRow('SELECT path,prepath FROM `' . $db_mymps . 'info_img` WHERE infoid = \'' . $id . '\' AND image_id = \'' . $i . '\'')) {
  248. @unlink(MYMPS_ROOT . $row['path']);
  249. @unlink(MYMPS_ROOT . $row['prepath']);
  250. $db->query('UPDATE `' . $db_mymps . 'info_img` SET image_id = \'' . $i . '\' , path = \'' . $mymps_image[0] . '\' , prepath = \'' . $mymps_image[1] . '\' , uptime = \'' . $timestamp . '\' WHERE image_id = \'' . $i . '\' AND infoid = \'' . $id . '\'');
  251. }
  252. else {
  253. $db->query('INSERT INTO `' . $db_mymps . 'info_img` (image_id,path,prepath,infoid,uptime) VALUES (\'' . $i . '\',\'' . $mymps_image[0] . '\',\'' . $mymps_image[1] . '\',\'' . $id . '\',\'' . $timestamp . '\')');
  254. }
  255. if ($i === 0 && $mymps_image[1]) {
  256. $db->query('UPDATE `' . $db_mymps . 'information` SET img_path = \'' . $mymps_image[1] . '\' WHERE id = \'' . $id . '\'');
  257. }
  258. }
  259. }
  260. }
  261. if (is_array($delinfoimg)) {
  262. $img_path = $db->getOne('SELECT img_path FROM `' . $db_mymps . 'information` WHERE id = \'' . $id . '\'');
  263. foreach ($delinfoimg as $key => $val) {
  264. if ($val == 'on') {
  265. $infoimgrow = $db->getRow('SELECT id,path,prepath FROM `' . $db_mymps . 'info_img` WHERE image_id = \'' . $key . '\' AND infoid = \'' . $id . '\'');
  266. if ($infoimgrow) {
  267. @unlink(MYMPS_ROOT . $infoimgrow['path']);
  268. @unlink(MYMPS_ROOT . $infoimgrow['prepath']);
  269. mymps_delete('info_img', 'WHERE id = \'' . $infoimgrow['id'] . '\'');
  270. if ($infoimgrow['prepath'] == $img_path) {
  271. $db->query('UPDATE `' . $db_mymps . 'information` SET img_path = \'\' WHERE id = \'' . $id . '\'');
  272. }
  273. }
  274. unset($infoimgrow);
  275. }
  276. }
  277. }
  278. $sql = $k = $v = NULL;
  279. if (is_array($extra) && 1 < $d['modid']) {
  280. foreach ($extra as $k => $v) {
  281. $sql .= is_array($v) ? '`' . $k . '` = \'' . implode(',', $v) . '\',' : '`' . $k . ('` = \'' . $v . '\',');
  282. }
  283. $sql = $sql ? substr($sql, 0, -1) : NULL;
  284. if ($sql) {
  285. $db->query('UPDATE `' . $db_mymps . 'information_' . $d[modid] . '` SET ' . $sql . ' WHERE id = \'' . $id . '\'');
  286. unset($sql);
  287. }
  288. }
  289. $manage_pwd = empty($manage_pwd) ? '' : 'manage_pwd=\'' . md5($manage_pwd) . '\',';
  290. $userid = empty($userid) ? '' : 'userid=\'' . $userid . '\',';
  291. $img_count = mymps_count('info_img', 'WHERE infoid = \'' . $id . '\'');
  292. $img_path = $mymps_image[1] ? $mymps_image[1] : '';
  293. $d = $db->getRow('SELECT catname,dir_typename FROM `' . $db_mymps . 'category` WHERE catid = \'' . $catid . '\'');
  294. $sql = 'UPDATE `' . $db_mymps . 'information` SET ' . $manage_pwd . ' ' . $userid . ' title = \'' . $title . '\',content = \'' . $content . '\',catid = \'' . $catid . '\', areaid = \'' . $areaid . '\', activetime = \'' . $activetime . '\', endtime = \'' . $endtime . '\', ismember = \'' . $ismember . '\' , ip = \'' . $ip . '\' , ip2area = \'' . $ip2area . '\' , info_level = \'' . $info_level . '\' , qq = \'' . $qq . '\' , email = \'' . $email . '\' , tel = \'' . $tel . '\' , contact_who = \'' . $contact_who . '\' , img_count = \'' . $img_count . '\' , mappoint = \'' . $mappoint . '\',catname=\'' . $d['catname'] . '\',dir_typename=\'' . $d['dir_typename'] . '\' WHERE id = \'' . $id . '\'';
  295. $db->query($sql);
  296. $editlimit = mgetcookie('editlimit');
  297. $editlimit = $editlimit + 1;
  298. msetcookie('editlimit', $editlimit, 3600 * 24);
  299. write_msg('操作成功!您已经成功修改该信息!<br />若信息内容无变化请刷新浏览器!', Rewrite('info', array('id' => $id, 'dir_typename' => $d['dir_typename'])));
  300. }
  301. }
  302. else {
  303. $catid = isset($catid) ? intval($catid) : '';
  304. if ($action == 'input') {
  305. if ($catname && !$catid) {
  306. $catid = $db->getOne('SELECT catid FROM `' . $db_mymps . 'category` WHERE catname = \'' . $catname . '\'');
  307. }
  308. if (!$catid) {
  309. $loc = get_location('post', '', '选择分类-发布信息');
  310. $page_title = $loc['page_title'];
  311. globalassign();
  312. $categories = get_categories_tree(0, 'category');
  313. include mymps_tpl('info_post');
  314. }
  315. else {
  316. if (!empty($mymps_global['cfg_allow_post_area']) && !empty($ip2area)) {
  317. $i = 1;
  318. $allow_post_area = array();
  319. $allow_post_area = explode('=', $mymps_global['cfg_allow_post_area']);
  320. $allow_post_areas = explode(',', $allow_post_area[0]);
  321. foreach ($allow_post_areas as $k => $v) {
  322. if (strstr($ip2area, $v)) {
  323. $i = $i + 1;
  324. }
  325. }
  326. if ($allow_post_area[1] == '-1' && $i == 1) {
  327. write_msg('系统判断您的IP并非<b style=\'color:red\'>' . $allow_post_area[0] . '</b>本地IP!<br />如果您要继续操作,请联系客服。');
  328. exit();
  329. }
  330. else {
  331. if ($allow_post_area[1] == 0 && $i == 1) {
  332. $info_level = 0;
  333. }
  334. }
  335. unset($allow_post_area);
  336. unset($ip2area);
  337. unset($address);
  338. unset($ipdata);
  339. unset($allow_post_areas);
  340. unset($i);
  341. }
  342. if (!empty($mymps_global['cfg_forbidden_post_ip'])) {
  343. foreach (explode(',', $mymps_global['cfg_forbidden_post_ip']) as $ctrlip) {
  344. if (preg_match('/^(' . preg_quote($ctrlip = trim($ctrlip), '/') . ')/', $ip)) {
  345. $ctrlip = $ctrlip . '%';
  346. write_msg('您当前的IP <b style=\'color:red\'>' . $ip . '</b> 已被管理员加入黑名单,不允许发布信息!');
  347. exit();
  348. }
  349. }
  350. }
  351. $cat = post_cat_info($catid);
  352. if ($cat['parentid'] == 0) {
  353. $loc = get_location('post', '', '选择分类-发布' . $cat[catname] . '信息');
  354. $page_title = $loc['page_title'];
  355. $categories = get_categories_tree($catid, 'category');
  356. globalassign();
  357. include mymps_tpl('info_post');
  358. exit();
  359. }
  360. else if ($db->getOne('SELECT COUNT(catid) FROM `' . $db_mymps . 'category` WHERE parentid = \'' . $catid . '\'')) {
  361. $cat_option = $db->getAll('SELECT catid,catname FROM `' . $db_mymps . 'category` WHERE parentid = \'' . $catid . '\' ORDER BY catorder ASC');
  362. }
  363. require_once MYMPS_DATA . '/info_lasttime.php';
  364. require_once MYMPS_DATA . '/info.type.inc.php';
  365. require_once MYMPS_INC . '/member.class.php';
  366. if ($log = $member_log->chk_in()) {
  367. chk_member_purview('purview_info');
  368. }
  369. if ($mymps_global['cfg_post_editor'] == 1) {
  370. $acontent = get_editor('content', 'Member', '', '350px', '300px', 'include/kindeditor');
  371. }
  372. else {
  373. $acontent = '<textarea name="content" style="width:400px;height:300px;" class="input" require="true" datatype="limit" msg="请填写信息内容描述"></textarea>';
  374. }
  375. $post = array();
  376. if ($log) {
  377. $memberinfo = $member_log->get_info();
  378. $his_money = $memberinfo['money_own'];
  379. $status = $memberinfo['status'];
  380. $sj_certify = $memberinfo['sj_certify'];
  381. if ($status < 1) {
  382. write_msg('您的会员账号尚未通过审核,不能发布信息!');
  383. exit();
  384. }
  385. if ($sj_certify == 0 && $mymps_global['cfg_member_verify'] == 4) {
  386. write_msg('还差最后一步,填写手机号码认证通过后就可以发布信息啦 ^_^', 'member/index.php?m=certify&ac=sjrz');
  387. }
  388. $his_money - $mymps_global['cfg_member_perpost_consume'] < 0 && write_msg('您的用户余额 <font color=red><b>' . $his_money . '</b></font>过低 不能再发布信息,请联系管理员充值', '/member/index.php?m=pay');
  389. $per = $db->getRow('SELECT b.perday_maxpost,b.info_maxpost FROM `' . $db_mymps . 'member` AS a LEFT JOIN `' . $db_mymps . 'member_level` AS b ON a.levelid = b.id WHERE a.userid = \'' . $s_uid . '\'');
  390. $perday_maxpost = $per[perday_maxpost];
  391. if (!empty($perday_maxpost)) {
  392. $count = mymps_count('information', 'WHERE userid = \'' . $s_uid . '\' AND begintime > \'' . mktime(0, 0, 0) . '\'');
  393. $perday_maxpost <= $count && write_msg('很抱歉!您当前的会员级别每天只能发布' . $perday_maxpost . '条信息');
  394. }
  395. if ($per[info_maxpost]) {
  396. $count = mymps_count('information', 'WHERE userid = \'' . $s_uid . '\'');
  397. $per[info_maxpost] <= $count && write_msg('很抱歉!您已超出发布数量总量限制<br />如果您要继续发布信息,请升级会员。');
  398. }
  399. $onload = '';
  400. $post['mobile'] = $memberinfo['mobile'];
  401. $post['qq'] = $memberinfo['qq'];
  402. $post['email'] = $memberinfo['email'];
  403. $post['userid'] = $memberinfo['userid'];
  404. $post['contact_who'] = $memberinfo['cname'];
  405. $post['ismember'] = 1;
  406. $post['manage_pwd'] = '';
  407. $post['imgcode'] = $authcodesettings['memberpost'] == 1 ? 1 : '';
  408. }
  409. else {
  410. if (!empty($mymps_global['cfg_nonmember_perday_post'])) {
  411. $count = mymps_count('information', 'WHERE ip = \'' . $ip . '\' AND begintime > \'' . mktime(0, 0, 0) . '\' AND ismember = \'0\'');
  412. $mymps_global[cfg_nonmember_perday_post] <= $count && write_msg('很抱歉!游客每天只能发布' . $mymps_global[cfg_nonmember_perday_post] . '条信息');
  413. }
  414. $mymps_global['cfg_if_nonmember_info'] == '0' && write_msg('对不起,您还没有登录!请您登录后再发布信息!', $mymps_global['cfg_member_logfile'] . '?url=' . urlencode(getUrl()));
  415. $onload = '';
  416. $post['manage_pwd'] = 1;
  417. $post['ismember'] = 0;
  418. $post['imgcode'] = $authcodesettings['post'] == 1 ? 1 : '';
  419. }
  420. $post['mymps_extra_value'] = return_category_info_options($cat['modid']);
  421. $post['upload_img'] = $cat['if_upimg'] == 1 ? get_upload_image_view(1, $id) : '';
  422. $post['GetInfoLastTime'] = GetInfoLastTime();
  423. $post['action'] = 'input';
  424. $post['submit'] = '提交发布';
  425. $post['ip'] = $ip;
  426. $post['catid'] = $catid;
  427. $post['mixcode'] = md5($cookiepre);
  428. $post['select_where_option'] = cat_list('area');
  429. $loc = get_location('post', '', '发布' . $cat[catname] . '信息-发布信息');
  430. $page_title = $loc['page_title'];
  431. $whenpost = '';
  432. $whenpost = $db->getOne('SELECT value FROM `' . $db_mymps . 'config` WHERE description = \'whenpost\' AND type = \'checkanswe\'');
  433. if ($whenpost == '1' && ($checkanswer = read_static_cache('checkanswer'))) {
  434. $checkquestion['id'] = $randid = array_rand($checkanswer, 1);
  435. $checkquestion['question'] = $checkanswer[$randid]['question'];
  436. $checkquestion['answer'] = $checkanswer[$randid]['answer'];
  437. }
  438. globalassign();
  439. include mymps_tpl('info_post_write');
  440. }
  441. }
  442. else if ($action == 'edit') {
  443. $page_title = '修改信息-' . $mymps_global['SiteName'];
  444. require_once MYMPS_DATA . '/info_lasttime.php';
  445. require_once MYMPS_DATA . '/info.type.inc.php';
  446. require_once MYMPS_INC . '/member.class.php';
  447. $editlimit = mgetcookie('editlimit');
  448. if (30 < $editlimit) {
  449. write_msg('您今天修改的信息太多了,休息一下吧 ^_^');
  450. }
  451. $id = intval($id);
  452. if (!($post = is_member_info($id))) {
  453. write_msg('操作失败!你所指定的信息不存在或者已被删除!');
  454. }
  455. $catid = $post['catid'];
  456. $areaid = $post['areaid'];
  457. $cat = $db->getRow('SELECT a.if_upimg,a.modid,b.catid FROM `' . $db_mymps . 'category` AS a LEFT JOIN `' . $db_mymps . 'category` AS b ON a.parentid = b.catid WHERE a.catid = \'' . $catid . '\'');
  458. if ($post['ismember'] == 1) {
  459. if (!($log = $member_log->chk_in())) {
  460. write_msg('', $mymps_global['SiteUrl'] . '/' . $mymps_global['cfg_member_logfile'] . '?url=' . urlencode($mymps_global['SiteUrl'] . '/' . $mymps_global['cfg_postfile'] . '?action=edit&id=' . $id));
  461. }
  462. else {
  463. if ($log && $s_uid != $post['userid']) {
  464. write_msg('操作失败!该信息不是您发布的!', 'information.php?id=' . $id);
  465. }
  466. }
  467. $nav_bar = '<a href="info.php?id=' . $id . '">' . $post['title'] . '</a> &raquo; 修改信息';
  468. }
  469. else {
  470. if ($post[ismember] == 0 && !empty($manage_pwd)) {
  471. if (mymps_count('information', 'WHERE id = \'' . $id . '\' AND manage_pwd = \'' . md5($manage_pwd) . '\' AND ismember = 0') == 0) {
  472. write_msg('操作失败!您输入的管理密码不正确!');
  473. }
  474. $post['manage_pwd'] = '<tr><td class="tdr">管理密码:</td><td><input type="password" name="manage_pwd" class="text"/>
  475. 如不修改,请留空</td></tr>';
  476. $post[ismember] = 0;
  477. $nav_bar = '<a href="info.php?id=' . $id . '">' . $post['title'] . '</a> &raquo; <a href="../member/info.php?part=edit&id=' . $id . '">输入管理密码</a> &raquo; 修改信息';
  478. }
  479. else {
  480. if ($post[ismember] == 0 && empty($manage_pwd)) {
  481. $action = '修改';
  482. $title = '输入管理密码-' . $action . '信息-' . $post[title];
  483. $nav_bar = '<a href="../information.php?id=' . $id . '">' . $post[title] . '</a> &raquo; 输入管理密码 &raquo; ' . $action . '信息</li>';
  484. $post['part'] = $part;
  485. globalassign();
  486. include mymps_tpl('info_write_pwd');
  487. exit();
  488. }
  489. }
  490. }
  491. $post['mobile'] = $post['tel'];
  492. if ($mymps_global['cfg_post_editor'] == 1) {
  493. $acontent = get_editor('content', 'Member', $post[content], '350px', '300px', 'include/kindeditor');
  494. }
  495. else {
  496. $acontent = '<textarea name="content" style=\'width:400px;height:300px;\'>' . de_textarea_post_change($post[content]) . '</textarea>';
  497. }
  498. $title = '修改信息内容-' . $post['title'];
  499. $post['GetInfoLastTime'] = GetInfoLastTime($post['activetime']);
  500. $post['mymps_extra_value'] = return_category_info_options($cat['modid'], $id);
  501. $post['mymps_extra_value'] = is_array($post['mymps_extra_value']) ? $post['mymps_extra_value'] : array();
  502. $post['upload_img'] = get_upload_image_edit($cat['if_upimg'], $id);
  503. $post['action'] = 'edit';
  504. $post['submit'] = '保存修改';
  505. $post['select_where_option'] = cat_list('area', 0, $post[areaid]);
  506. $post['mixcode'] = md5($cookiepre);
  507. $cat = post_cat_info($catid);
  508. globalassign();
  509. include mymps_tpl('info_post_write');
  510. }
  511. else if ($action == 'ok') {
  512. $ok['id'] = intval($id);
  513. $ok['filepath'] = trim(mhtmlspecialchars($filepath));
  514. $ok['title'] = trim(mhtmlspecialchars($title));
  515. $ok['level'] = intval($level);
  516. $r = $db->getRow('SELECT a.dir_typename,a.userid FROM `' . $db_mymps . 'information` AS a WHERE a.id = \'' . $ok['id'] . '\'');
  517. $ok['info_uri'] = Rewrite('info', array('id' => $ok['id'], 'dir_typename' => $r['dir_typename']));
  518. if (!$title || !$id) {
  519. exit('Access Denied!');
  520. }
  521. $nav_bar = '信息发布状态提示';
  522. globalassign();
  523. include mymps_tpl('info_post_write_ok');
  524. }
  525. }
  526. is_object($db) && $db->Close();
  527. ?>