Browse Source

- Start to remove duplicate error checking

Signed-off-by: John Rayes <[email protected]>
John Rayes 12 years ago
parent
commit
d55addc772
2 changed files with 2 additions and 48 deletions
  1. 0 46
      Sources/Post.php
  2. 2 2
      Themes/default/Post.template.php

+ 0 - 46
Sources/Post.php

@@ -381,44 +381,6 @@ function Post($post_errors = array())
 		// Validate inputs.
 		if (empty($context['post_error']))
 		{
-			if (htmltrim__recursive(htmlspecialchars__recursive($_REQUEST['subject'])) == '')
-				$post_errors[] = 'no_subject';
-			if (htmltrim__recursive(htmlspecialchars__recursive($_REQUEST['message'])) == '')
-				$post_errors[] = 'no_message';
-			if (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength'])
-				$post_errors[] = array('long_message', $modSettings['max_messageLength']);
-
-			// Are you... a guest?
-			if ($user_info['is_guest'])
-			{
-				$_REQUEST['guestname'] = !isset($_REQUEST['guestname']) ? '' : trim($_REQUEST['guestname']);
-				$_REQUEST['email'] = !isset($_REQUEST['email']) ? '' : trim($_REQUEST['email']);
-
-				// Validate the name and email.
-				if (!isset($_REQUEST['guestname']) || trim(strtr($_REQUEST['guestname'], '_', ' ')) == '')
-					$post_errors[] = 'no_name';
-				elseif ($smcFunc['strlen']($_REQUEST['guestname']) > 25)
-					$post_errors[] = 'long_name';
-				else
-				{
-					require_once($sourcedir . '/Subs-Members.php');
-					if (isReservedName(htmlspecialchars($_REQUEST['guestname']), 0, true, false))
-						$post_errors[] = 'bad_name';
-				}
-
-				if (empty($modSettings['guest_post_no_email']))
-				{
-					if (!isset($_REQUEST['email']) || $_REQUEST['email'] == '')
-						$post_errors[] = 'no_email';
-					elseif (preg_match('~^[0-9A-Za-z=_+\-/][0-9A-Za-z=_\'+\-/\.]*@[\w\-]+(\.[\w\-]+)*(\.[\w]{2,6})$~', $_REQUEST['email']) == 0)
-						$post_errors[] = 'bad_email';
-				}
-			}
-
-			// This is self explanatory - got any questions?
-			if (isset($_REQUEST['question']) && trim($_REQUEST['question']) == '')
-				$post_errors[] = 'no_question';
-
 			// This means they didn't click Post and get an error.
 			$really_previewing = true;
 		}
@@ -448,10 +410,6 @@ function Post($post_errors = array())
 		if ($smcFunc['strlen']($form_subject) > 100)
 			$form_subject = $smcFunc['substr']($form_subject, 0, 100);
 
-		// Have we inadvertently trimmed off the subject of useful information?
-		if ($smcFunc['htmltrim']($form_subject) === '')
-			$post_errors[] = 'no_subject';
-
 		$context['post_error'] = array('messages' => array());
 
 		/*
@@ -1261,10 +1219,6 @@ function Post2()
 		$_POST['message'] = $_REQUEST['message'];
 	}
 
-	// Previewing? Go back to start.
-	if (isset($_REQUEST['preview']))
-		return Post();
-
 	// Prevent double submission of this form.
 	checkSubmitOnce('check');
 

+ 2 - 2
Themes/default/Post.template.php

@@ -426,7 +426,7 @@ function template_main()
 	{
 		echo '
 					<dl id="postAttachment2">';
-		
+
 		// But, only show them if they haven't reached a limit. Or a mod author hasn't hidden them.
 		if ($context['num_allowed_attachments'] > 0 || !empty($context['dont_show_them']))
 		{
@@ -569,7 +569,7 @@ function template_main()
 					}
 					// @todo Currently not sending poll options and option checkboxes.
 					var x = new Array();
-					var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ', \'icon\', \'guestname\', \'email\', \'evtitle\', \'question\', \'topic\'];
+					var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ', ', JavaScriptEscape($context['session_var']), ', \'icon\', \'guestname\', \'email\', \'evtitle\', \'question\', \'topic\'];
 					var numericFields = [
 						\'board\', \'topic\', \'last_msg\',
 						\'eventid\', \'calendar\', \'year\', \'month\', \'day\',