<?php
require_once "cmsAdmin/lib/viewer_functions.php";   
 if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }


// submit form
if (@$_REQUEST['submit']) {

  // error checking
  $errorsAndAlerts = "";
  if (!@$_REQUEST['title'])    { $errorsAndAlerts .= "Post Title/Headline!<br/>\n"; }
  if (!@$_REQUEST['link'])  { $errorsAndAlerts .= "Post web site or youtube link !<br/>\n"; }
   if (!@$_REQUEST['summary'])  { $errorsAndAlerts .= "Post Comments/Summary!<br/>\n"; }

 
  // turn off strict mysql error checking for: STRICT_ALL_TABLES
  mysqlStrictMode(false); // disable Mysql strict errors for when a field isn't defined below (can be caused when fields are added later)

 // add record
  if (!@$errorsAndAlerts) {
    mysql_query("INSERT INTO `{$TABLE_PREFIX}news` SET
                      title            = '".mysql_real_escape_string( $_REQUEST['title'] )."',
                      link              = '".mysql_real_escape_string( $_REQUEST['link'] )."',
                      summary           = '".mysql_real_escape_string( $_REQUEST['summary'] )."',
					  

             createdDate      = NOW(),
                      updatedDate      = NOW(),
                      createdByUserNum = '".mysql_escape($CURRENT_USER['num'])."', 
                      updatedByUserNum = '".mysql_escape($CURRENT_USER['num'])."'") 
    or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
    $recordNum = mysql_insert_id();
    }
    // send email user
    if (!$errorsAndAlerts) {
      $from    = @$CURRENT_USER['email'];
      $to      = "patricia@thenetgirl.com";
      $subject = "News submitted from {$CURRENT_USER['fullname']}";
      $message = <<<__TEXT__
You've received an email:

 
  Title:{$_REQUEST['title']}  
  link:{$_REQUEST['link']}    
  City:{$_REQUEST['summary']}   
  


The user who sent this message had the IP address {$_SERVER['REMOTE_ADDR']}.
__TEXT__;
     
      // send message
      $mailResult =  mail($to,$subject,$message,$from);
      if (!$mailResult) { die("Mail Error: $php_errormsg"); }

    // display thanks message and clear form
    $errorsAndAlerts = "Thanks, we've added your News! <br/>
    <a href='{$GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']}'>Click here to continue to your profile page!</a>";
    $_REQUEST = array();
  }

}



?><?php include "header.php"; ?>





<div align="center">
<table border="0" width="96%" id="table1">
	<tr>
		<td>
<form method="post" action="">
<input type="hidden" name="submit" value="1" />


<h1><font color="#FF0000">Add News</font></h1>
 <?php if (@$errorsAndAlerts): ?>
  &nbsp;<div style="color: red; font-weight: bold; font-size: 16px;"><br/>   
   <?php echo $errorsAndAlerts; ?>&nbsp;  </div>
<?php endif ?>
<div align="center">
<div style="border: 1px solid #000; background-color: #E9E9D1; padding: 10px; width: 581px; height:301px">


<table border="0" cellpadding="2" width="93%" id="table2">
 <tr>
  <td valign="top" width="37%">
	<h4><b><font face="Verdana">Title/Headline</font></b></h4>
	</td>
  <td>
	<h4>
	<input type="text" name="name" value="<?php echo htmlspecialchars(@$_REQUEST['title']) ?>" size="60" /></h4>
	</td>
</tr>
 <tr>
  <td valign="top" width="37%">
	<h4><b><font face="Verdana">Link -News/Youtube</font></b></h4>
	</td>
  <td>
	<h4><input type="text" name="address" value="<?php echo htmlspecialchars(@$_REQUEST['link']) ?>" size="60" /></h4>
	</td>
</tr>
<td valign="top" width="37%">
<h4><b><font face="Verdana">Summary</font></b></h4>
	</td> 
<td>
<h4><textarea name="notes" cols="37" rows="4"><?php echo htmlspecialchars(@$_REQUEST['summary']) ?></textarea></h4>
	</td> 
</tr> 

</table>
<p align="center">


<input type="submit" name="add" value="POST NEWS &gt;&gt;" />
</form></div>
</p>


</body>
		</div>
		<p>&nbsp;</td>
	</tr>
</table>

</div>


<?php include "footer.php"; ?>