publish.php 23 KB

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