PageRenderTime 148ms CodeModel.GetById 60ms app.highlight 47ms RepoModel.GetById 34ms app.codeStats 0ms

/wp-content/plugins/simple-forum/library/sf-post.php

https://bitbucket.org/openfarmtech/weblog-content
PHP | 617 lines | 453 code | 81 blank | 83 comment | 134 complexity | c77bf47f20ad99f4608cd01bffffa457 MD5 | raw file
  1<?php
  2/*
  3Simple:Press
  4Forum Topic/Post Saves
  5$LastChangedDate: 2010-04-09 06:11:48 -0700 (Fri, 09 Apr 2010) $
  6$Rev: 3881 $
  7*/
  8
  9if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF']))
 10{
 11	die('Access Denied');
 12}
 13
 14# --------------------------------------------
 15
 16# set up required globals
 17global $wpdb, $current_user, $sfglobals;
 18
 19sf_forum_ahah_support();
 20sf_setup_forum_hooks();
 21sf_setup_post_save_includes();
 22
 23# Initialise the array -------------------------------------------------------------
 24$newpost = array();
 25$newpost['forumid'] = 0;
 26$newpost['forumslug'] = '';
 27
 28# Validation checks on forum data ---------------------------------------------------
 29# if the forum is not set then this may be a back door approach
 30if((!isset($_POST['forumid'])) || (!isset($_POST['forumslug'])))
 31{
 32	echo (__('Forum not set - Unable to create post', 'sforum'));
 33	die();
 34} else {
 35	$newpost['forumid'] = sf_esc_int($_POST['forumid']);
 36	$newpost['forumslug'] = sf_esc_str($_POST['forumslug']);
 37}
 38
 39# If forum or system locked then refuse post
 40sf_initialise_globals($newpost['forumid']);
 41
 42if($current_user->moderator == false)
 43{
 44	if($sfglobals['lockdown'] || sf_forum_locked($newpost['forumid']))
 45	{
 46		echo (__("This forum is currently locked - access is read only", 'sforum'));
 47		die();
 48	}
 49}
 50
 51# clear out the message buffer
 52delete_sfnotice();
 53
 54# Check the pre-save hook
 55if(function_exists('sf_hook_pre_post_save'))
 56{
 57	if(sf_process_hook('sf_hook_pre_post_save', array($_POST['postitem'])) == false)
 58	{
 59		update_sfnotice('sfmessage', '1@'.__('This post has been refused', "sforum"));
 60		wp_redirect(SFURL);
 61		die();
 62	}
 63}
 64
 65# set up the main vars -------------------------------------------------------------
 66$newpost['topicid'] = 0;
 67$newpost['topicslug'] = '';
 68$newpost['postid'] = 0;
 69$newpost['submsg'] = '';
 70$action='';
 71if(isset($_POST['newtopic'])) $action = 'topic';
 72if(isset($_POST['newpost']))  $action = 'post';
 73
 74# if this is an existing topic check id and slug is set
 75if($action == 'post')
 76{
 77	if((!isset($_POST['topicid'])) || (!isset($_POST['topicslug'])))
 78	{
 79		echo (__('Topic not set - Unable to create post', 'sforum'));
 80		die();
 81	} else {
 82		$newpost['topicid'] = sf_esc_int($_POST['topicid']);
 83		$newpost['topicslug'] = sf_esc_str($_POST['topicslug']);
 84	}
 85}
 86
 87# check that current user is actually allowed to do this ---------------------------
 88if(($action == 'topic' && !$current_user->sfaddnew) || ($action == 'post' && !$current_user->sfreply))
 89{
 90	echo (__('Access Denied', "sforum"));
 91	die();
 92}
 93
 94# set up initial url to return to if save fails ------------------------------------
 95$returnURL = sf_build_url($newpost['forumslug'], $newpost['topicslug'], 0, $newpost['postid']);
 96
 97# setup and prepare post data ------------------------------------------------------
 98if($action == 'topic')
 99{
100	# topic specific items
101	if(empty($_POST['newtopicname']))
102	{
103		update_sfnotice('sfmessage', '1@'.__('No Topic Name has been entered! Post can not be saved', "sforum"));
104		wp_redirect($returnURL);
105		die();
106	} else {
107		$newpost['topicname'] = sf_filter_title_save(trim($_POST['newtopicname']));
108	}
109	$newpost['topicslug'] = sf_create_slug($newpost['topicname'], 'topic');
110	$newpost['topicpin']=0;
111	$newpost['topicsub']='NULL';
112	$newpost['statusflag']='0';
113	$newpost['bloglink']='0';
114	$newpost['post_category']='NULL';
115	if(isset($_POST['topiclock'])) $newpost['topiclock']=1;
116	if(isset($_POST['topicpin'])) $newpost['topicpin']=1;
117	if(isset($_POST['statusflag'])) $newpost['statusflag']=sf_esc_int($_POST['statusflag']);
118	if($_POST['bloglink'] == 'on') $newpost['bloglink']=true;
119	if(isset($_POST['post_category'])) $newpost['post_category'] = $_POST['post_category']; # array so santize later!!
120
121	# get the tags for the new topic
122	if (empty($_POST['topictags']))
123	{
124		$newpost['tags'] = '';
125	} else {
126		# check for duplicates and limit to max tag option
127	    $newpost['tags'] = sf_filter_title_save(trim($_POST['topictags']));
128	    $newpost['tags'] = trim($newpost['tags'], ',');  # no extra commas allowed
129		$newpost['taglist'] = $newpost['tags']; # save comma separated list for later use
130		$newpost['tags'] = explode(',', $newpost['tags']);
131		$newpost['tags'] = array_unique($newpost['tags']);  # remove any duplicates
132		$newpost['tags'] = array_values($newpost['tags']);  # put back in order
133		if ($sfglobals['display']['topics']['maxtags'] > 0 && count($newpost['tags']) > $sfglobals['display']['topics']['maxtags'])
134		{
135			$newpost['tags'] = array_slice($newpost['tags'], 0, $sfglobals['display']['topics']['maxtags']);  # limit to maxt tags opton
136		}
137	}
138}
139
140# post specific (needed by new topic and new post)
141$newpost['postpin']=0;
142$newpost['topiclock']=0;
143$newpost['topicsub']='';
144$newpost['topicwatch']='';
145$newpost['topicsubend']='';
146$newpost['topicwatchend']='';
147$newpost['statvalue']='';
148$newpost['posttimestamp'] = "'" . current_time('mysql') . "'";
149if(isset($_POST['postpin'])) $newpost['postpin']=1;
150if(isset($_POST['topiclock'])) $newpost['topiclock']=1;
151if(isset($_POST['topicsub'])) $newpost['topicsub']=sf_esc_str($_POST['topicsub']);
152if(isset($_POST['topicwatch'])) $newpost['topicwatch']=sf_esc_str($_POST['topicwatch']);
153if(isset($_POST['topicsubend'])) $newpost['topicsubend']=sf_esc_str($_POST['topicsubend']);
154if(isset($_POST['topicwatchend'])) $newpost['topicwatchend']=sf_esc_str($_POST['topicwatchend']);
155if(isset($_POST['statvalue'])) $newpost['statvalue']=sf_esc_int($_POST['statvalue']);
156if(!empty($_POST['editTimestamp']))
157{
158	$yy = sf_esc_int($_POST['tsYear']);
159	$mm = sf_esc_int($_POST['tsMonth']);
160	$dd = sf_esc_int($_POST['tsDay']);
161	$hh = sf_esc_int($_POST['tsHour']);
162	$mn = sf_esc_int($_POST['tsMinute']);
163	$ss = sf_esc_int($_POST['tsSecond']);
164	$dd = ($dd > 31 ) ? 31 : $dd;
165	$hh = ($hh > 23 ) ? $hh -24 : $hh;
166	$mn = ($mn > 59 ) ? $mn -60 : $mn;
167	$ss = ($ss > 59 ) ? $ss -60 : $ss;
168	$posttimestamp = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $yy, $mm, $dd, $hh, $mn, $ss );
169	$newpost['posttimestamp'] = '"'.( $posttimestamp ).'"';
170}
171
172$newpost['poststatus'] = 0;
173if(empty($_POST['postitem']))
174{
175	update_sfnotice('sfmessage', '1@'.__('No Topic Post has been entered! Post can not be saved', "sforum"));
176	wp_redirect($returnURL);
177	die();
178} else {
179	$newpost['postcontent'] = $_POST['postitem'];
180	$newpost['postcontent'] = sf_filter_content_save($newpost['postcontent'], 'new');
181}
182
183# Check if maxmium links has been exceeded
184$sffilters = sf_get_option('sffilters');
185if($sffilters['sfmaxlinks'] > 0 && !$current_user->forumadmin)
186{
187	if(substr_count($newpost['postcontent'], '</a>') > $sffilters['sfmaxlinks'])
188	{
189		update_sfnotice('sfmessage', '1@'.__('Maximum Number of Links Exceeded', "sforum"));
190		wp_redirect(SFURL);
191		die();
192	}
193}
194
195$newpost['guestname']='';
196$newpost['guestemail']='';
197if ($current_user->guest)
198{
199	$sfguests = sf_get_option('sfguests');
200	$newpost['guestname'] = sf_filter_name_save($_POST['guestname']);
201	$newpost['guestemail'] = sf_filter_email_save($_POST['guestemail']);
202	if (empty($newpost['guestname']) || ((empty($newpost['guestemail']) || !is_email($newpost['guestemail'])) && $sfguests['reqemail']))
203	{
204		update_sfnotice('sfmessage', '1@'.__('Guest name and valid Email address required', "sforum"));
205		wp_redirect($returnURL);
206		die();
207	}
208	# force maximum lengths
209	$newpost['guestname'] = substr($newpost['guestname'], 0, 20);
210	$newpost['guestemail'] = substr($newpost['guestemail'], 0, 50);
211	$newpost['postername'] = sf_filter_name_save($newpost['guestname']);
212	$newpost['posteremail'] = sf_filter_email_save($newpost['guestemail']);
213	$newpost['userid']='';
214} else {
215	$newpost['postername'] = sf_filter_name_save($current_user->display_name);
216	$newpost['posteremail'] = sf_filter_email_save($current_user->user_email);
217	$newpost['userid'] = $current_user->ID;
218}
219
220# grab poster IP address and store in db
221$newpost['ip'] = $_SERVER['REMOTE_ADDR'];
222
223# Check for duplicate post of option is set
224if(($current_user->member && $sffilters['sfdupemember'] == true) || ($current_user->guest && $sffilters['sfdupeguest'] == true))
225{
226	# Bur not admin or moderator
227	if($current_user->forumadmin == false && $current_user->moderator == false)
228	{
229		$dupecheck = $wpdb->get_row("SELECT post_id, forum_id, topic_id FROM ".SFPOSTS." WHERE post_content = '".$newpost['postcontent']."' AND poster_ip = '".$newpost['ip']."';", ARRAY_A);
230		if($dupecheck)
231		{
232			update_sfnotice('sfmessage', '1@'.__('Duplicate Post Refused', "sforum"));
233			$returnURL = sf_build_url(sf_get_forum_slug($dupecheck['forum_id']), sf_get_topic_slug($dupecheck['topic_id']), 0, $$dupecheck['post_id'], 0);
234			wp_redirect($returnURL);
235			die();
236		}
237	}
238}
239
240# Branch to correct routine --------------------------------------------------------
241if($action == 'topic')
242{
243	$newpost = sf_create_topic($newpost, $action);
244}
245if($action == 'post')
246{
247	$newpost = sf_create_post($newpost, $action);
248}
249
250# reset the url now we should have kosher values and re-direct
251$returnURL = sf_build_url($newpost['forumslug'], $newpost['topicslug'], 0, $newpost['postid']);
252
253wp_redirect($returnURL);
254die();
255
256
257# ==================================================================================
258# CREATION FUNCTIONS
259# ==================================================================================
260
261# Create new Topic and First Post --------------------------------------------------
262function sf_create_topic($newpost, $action)
263{
264	global $wpdb, $current_user;
265
266	# security checks
267	check_admin_referer('forum-userform_addtopic', 'forum-userform_addtopic');
268	$spamcheck = sf_check_spammath();
269	if($spamcheck[0]==true)
270	{
271		update_sfnotice('sfmessage', $spamcheck[1]);
272		return;
273	}
274
275	# save the new topic record to db
276	$newpost = sf_write_topic($newpost);
277	if(!$newpost['db'])
278	{
279		update_sfnotice('sfmessage', __("Unable to Save New Topic Record", "sforum"));
280		return;
281	} else {
282		# lets grab the new topic id
283		$newpost['topicid'] = $wpdb->insert_id;
284	}
285
286	# check the topic slug and if empty use the topic id
287	if(empty($newpost['topicslug']))
288	{
289		$newpost['topicslug'] = 'topic-'.$newpost['topicid'];
290		$wpdb->query("UPDATE ".SFTOPICS." SET topic_slug='".$newpost['topicslug']."' WHERE topic_id=".$newpost['topicid']);
291	}
292
293	# save the tags
294	if ($newpost['tags'] != '')
295	{
296		sfc_add_tags($newpost['topicid'], $newpost['tags']);
297	}
298
299	# Now save the new post record to db
300	$newpost = sf_write_post($newpost);
301	if(!$newpost['db'])
302	{
303		update_sfnotice('sfmessage', __("Unable to Save New Post Message", "sforum"));
304		return;
305	} else {
306		# lets grab the new post id
307		$newpost['postid'] = $wpdb->insert_id;
308	}
309
310	$wpdb->flush();
311
312	# Post-Save New Post Processing
313	$newpost = sf_post_save_processing($newpost, $action);
314
315	# do we need to create a blog link?
316	if($newpost['bloglink'])
317	{
318		include_once(SF_PLUGIN_DIR.'/linking/sf-links-forum.php');
319
320		$catlist = array();
321		if($newpost['post_category'])
322		{
323			foreach ($newpost['post_category'] as $key=>$value)
324			{
325				$catlist[] = sf_esc_int($value);
326			}
327		} else {
328			$catlist[] = get_option('default_category');
329		}
330
331		# set up post stuff
332		$post_content = $newpost['postcontent'];
333		$post_title   = $newpost['topicname'];
334		$post_status  = 'publish';
335		$tags_input = $newpost['taglist'];
336		$post = compact('post_content', 'post_title', 'post_status', 'tags_input');
337		$blog_post_id = wp_insert_post($post);
338
339		# save categories
340		wp_set_post_categories($blog_post_id, $catlist);
341
342		# save postmeta
343		$metadata = $newpost['forumid'].'@'.$newpost['topicid'];
344		sf_blog_links_control('save', $blog_post_id, $newpost['forumid'], $newpost['topicid']);
345
346		# go back and insert blog_post_id in topic record
347		$wpdb->query("UPDATE ".SFTOPICS." SET blog_post_id = ".$blog_post_id." WHERE topic_id = ".$newpost['topicid'].";");
348	}
349
350	# udpate sitemap if set for every new topic
351    if (sf_get_option('sfbuildsitemap') == 2)
352    {
353        do_action("sm_rebuild");
354    }
355
356	if($newpost['poststatus'])
357	{
358		$newpost['submsg'] .= ' - '.__("Placed in Moderation", "sforum").' ';
359	}
360	update_sfnotice('sfmessage', '0@'.__("New Topic Saved", "sforum").$newpost['submsg'].' '.$newpost['emailmsg']);
361	return $newpost;
362}
363
364# Create new Post in existing Topic ------------------------------------------------
365function sf_create_post($newpost, $action)
366{
367	global $wpdb, $current_user;
368
369	check_admin_referer('forum-userform_addpost', 'forum-userform_addpost');
370	$spamcheck = sf_check_spammath();
371	if($spamcheck[0]==true)
372	{
373		update_sfnotice('sfmessage', $spamcheck[1]);
374		return;
375	}
376	# Write the post
377	$newpost = sf_write_post($newpost);
378	if(!$newpost['db'])
379	{
380		update_sfnotice('sfmessage', __("Unable to Save New Post Message", "sforum"));
381		return;
382	}
383
384	$wpdb->flush();
385
386	# Post-Save New Post Processing
387	$newpost = sf_post_save_processing($newpost, $action);
388
389	# Is there a topic status flag to save?
390	if(!empty($newpost['statvalue']))
391	{
392		sf_update_topic_status_flag($newpost['statvalue'], $newpost['topicid']);
393	}
394
395	if($newpost['poststatus'])
396	{
397		$newpost['submsg'] .= ' - '.__("Placed in Moderation", "sforum").' ';
398	}
399
400	update_sfnotice('sfmessage', '0@'.__("New Post Saved", "sforum").$newpost['submsg'].' '.$newpost['emailmsg']);
401	return $newpost;
402}
403
404
405# ==================================================================================
406# DATABASE WRITE FUNCTIONS
407# ==================================================================================
408
409# Save new Topic to database -------------------------------------------------------
410function sf_write_topic($newpost)
411{
412	global $wpdb;
413
414	$now = "'" . current_time('mysql') . "'";
415
416	$sql =  "INSERT INTO ".SFTOPICS;
417	$sql .= " (topic_name, topic_slug, topic_date, forum_id, topic_status, topic_pinned, topic_status_flag, user_id) ";
418	$sql .= "VALUES (";
419	$sql .= "'".$newpost['topicname']."', ";
420	$sql .= "'".$newpost['topicslug']."', ";
421	$sql .= $now.", ";
422	$sql .= $newpost['forumid'].", ";
423	$sql .= $newpost['topiclock'].", ";
424	$sql .= $newpost['topicpin'].", ";
425	$sql .= $newpost['statusflag'].", ";
426	if('' == $newpost['userid'])
427	{
428		$sql .= "NULL);";
429	} else {
430		$sql .= $newpost['userid'].");";
431	}
432
433	if($wpdb->query($sql) === false)
434	{
435		$newpost['db'] = false;
436	} else {
437		$newpost['db'] = true;
438	}
439	return $newpost;
440}
441
442# Save new Post to database --------------------------------------------------------
443function sf_write_post($newpost)
444{
445	global $wpdb, $current_user;
446
447	# If a Guest posting...
448	if((($current_user->sfmoderated) || ($current_user->sfmodonce)) && ($current_user->guest))
449	{
450		$newpost['poststatus'] = 1;
451		# unless mod once is on and they have posted before...
452		if(($current_user->sfmodonce == true) && ($current_user->sfmoderated == false))
453		{
454			$prior=$wpdb->get_row("SELECT post_id FROM ".SFPOSTS." WHERE guest_name='".$newpost['guestname']."' AND guest_email='".sf_filter_email_display($newpost['guestemail'])."' AND post_status=0 LIMIT 1");
455			if($prior) $newpost['poststatus']=0;
456		}
457	}
458
459	# If a Member posting...
460	if((($current_user->sfmoderated) || ($current_user->sfmodonce)) && ($current_user->member))
461	{
462		$newpost['poststatus'] = 1;
463		# unless mod once is on and they have posted before...
464		if(($current_user->sfmodonce == true) && ($current_user->sfmoderated == false))
465		{
466			$prior=$wpdb->get_row("SELECT post_id FROM ".SFPOSTS." WHERE user_id=".$newpost['userid']." AND post_status=0 LIMIT 1");
467			if($prior) $newpost['poststatus']=0;
468		}
469	}
470
471	# Double check forum id is correct - it has been known for a topic to have just been moved!
472	$newpost['forumid'] = sf_get_topics_forum_id($newpost['topicid']);
473
474	# Get post count in topic to enable index setting
475	$index=$wpdb->get_var("SELECT COUNT(post_id) FROM ".SFPOSTS." WHERE topic_id = ".$newpost['topicid']);
476	$index++;
477
478	# if topic lock set in post reply update topic
479	if($newpost['topiclock'])
480	{
481		$wpdb->query("UPDATE ".SFTOPICS." SET topic_status=1 WHERE topic_id=".$newpost['topicid']);
482	}
483
484	$sql =  "INSERT INTO ".SFPOSTS;
485	$sql .= " (post_content, post_date, topic_id, forum_id, user_id, guest_name, guest_email, post_pinned, post_index, post_status, poster_ip) ";
486	$sql .= "VALUES (";
487	$sql .= "'".$newpost['postcontent']."', ";
488	$sql .= $newpost['posttimestamp'].", ";
489	$sql .= $newpost['topicid'].", ";
490	$sql .= $newpost['forumid'].", ";
491	if('' == $newpost['userid'])
492	{
493		$sql .= "NULL, ";
494	} else {
495		$sql .= $newpost['userid'].", ";
496	}
497	$sql .= "'".$newpost['guestname']."', ";
498	$sql .= "'".$newpost['guestemail']."', ";
499	$sql .= $newpost['postpin']. ", ";
500	$sql .= $index.", ";
501	$sql .= $newpost['poststatus'].", ";
502	$sql .= "'".$newpost['ip']."');";
503
504	if($wpdb->query($sql) === false)
505	{
506		$newpost['db'] = false;
507	} else {
508		$newpost['db'] = true;
509		$newpost['postid'] = $wpdb->insert_id;
510
511		if ($current_user->guest)
512		{
513    		$sfguests = sf_get_option('sfguests');
514    		if ($sfguests['storecookie']) sf_write_guest_cookie($newpost['guestname'], $newpost['guestemail']);
515		} else {
516			$postcount = sf_get_member_item($newpost['userid'], 'posts');
517			$postcount++;
518			sf_update_member_item($newpost['userid'], 'posts', $postcount);
519
520			# see if postcount qualifies member for new user group membership
521			# get rankings information
522			if (!$current_user->forumadmin)  # ignore for admins as they dont belong to user groups
523			{
524				$rankdata = sf_get_sfmeta('forum_rank');
525				if ($rankdata)
526				{
527					# put into arrays to make easy to sort
528					foreach ($rankdata as $x => $info)
529					{
530						$ranks['title'][$x] = $info['meta_key'];
531						$data = unserialize($info['meta_value']);
532						$ranks['posts'][$x] = $data['posts'];
533						$ranks['usergroup'][$x] = $data['usergroup'];
534					}
535					# sort rankings highest to lowest
536					array_multisort($ranks['posts'], SORT_DESC, $ranks['title'], $ranks['usergroup']);
537
538					# check for new ranking
539					for ($x=0; $x<count($rankdata); $x++)
540					{
541						if ($postcount > $ranks['posts'][$x])
542						{
543							# if a user group is tied to forum rank add member to the user group
544							if ($ranks['usergroup'][$x] != 'none')
545							{
546								sfc_add_membership($ranks['usergroup'][$x], $newpost['userid']);
547								break;  # only update highest rank
548							}
549						}
550					}
551				}
552			}
553		}
554	}
555	return $newpost;
556}
557
558# ==================================================================================
559# POST-SAVE NEW POST ROUTINES
560# ==================================================================================
561
562# Post-Save New Post processing ----------------------------------------------------
563function sf_post_save_processing($newpost, $action)
564{
565	global $current_user;
566
567	# construct new url
568	$newpost['url']=sf_build_url($newpost['forumslug'], $newpost['topicslug'], 0, $newpost['postid']);
569
570	$newpost['submsg'] = '';
571
572	# subscribing?
573	if ($current_user->sfsubscriptions && !empty($newpost['topicsub']))
574	{
575		sf_save_subscription($newpost['topicid'], $newpost['userid'], true);
576		$newpost['submsg'] .= ' '.__('and Subscribed', 'sforum');
577	}
578
579	# unsubscribing?
580	if ($current_user->sfsubscriptions && !empty($newpost['topicsubend']))
581	{
582		sf_remove_subscription($newpost['topicid'], $newpost['userid']);
583		$newpost['submsg'] .= ' '.__('and Unsubscribing', 'sforum');
584	}
585
586	# watching?
587	if ($current_user->sfwatch && !empty($newpost['topicwatch']))
588	{
589		sf_save_watch($newpost['topicid'], $newpost['userid'], true);
590		$newpost['submsg'] .= ' '.__('and Watching', 'sforum');
591	}
592
593	# stop watching?
594	if ($current_user->sfwatch && !empty($newpost['topicwatchend']))
595	{
596		sf_remove_watch($newpost['topicid'], $newpost['userid']);
597		$newpost['submsg'] .= ' '.__('and Ending Watch', 'sforum');
598	}
599
600	# save hook
601	sf_process_hook('sf_hook_post_save', array($newpost, $action));
602
603	# add to admins new post queue
604	sf_add_to_waiting($newpost['topicid'], $newpost['forumid'], $newpost['postid'], $newpost['userid']);
605
606	# send out email notifications
607	$newpost['emailmsg']='';
608	$newpost['emailmsg'] = sf_email_notifications($newpost);
609
610	# Update forum, topic and post index data
611	sf_build_forum_index($newpost['forumid']);
612	sf_build_post_index($newpost['topicid'], $newpost['topicslug']);
613
614	return $newpost;
615}
616
617?>