<?

// Post script for the add_news form.
// PJ Waskiewicz, 10/2/2001
// add_news_post.php

// This file is in a directory not accessible by the
// outside world, for obvious reasons...  But I wanted
// to make it available for viewing just because.

$action $_GET["action"];
if(
$action != "post") {
  print 
"Shithead!!  Don't try to post without actually putting something in!!  <a href=\"/admin/add_news.php\" onmouseover=\"window.status='Add News'\; return 1\">Get back</a> there dumbass!!\n";
} else {
  
// Before we get the MySQL connection open, get the date and time
  // as well as the posted scoop...
  
$time_epoch time();
  
$date_str date("j F Y"$time_epoch);
  
$time_str date("h:i:s A"$time_epoch);
  
$body $_POST["news"];
  
// Now escape any special characters that will fuck up MySQL.
  
$body preg_replace("/\r/"""$body);
  
$body preg_replace("/'/""\'"$body);
  
  
// Good to go.  Open up MySQL and then insert.
  
$mysql_connect_string "/home/waskiewicz.org/etc/mysql_connect_string";
  
$fp fopen($mysql_connect_string"r");
  
$username fgets($fp4096);
  
$password fgets($fp4096);
  
fclose($fp);
  
  
$username chop($username);
  
$password chop($password);

  
$link mysql_connect("localhost"$username$password)
    or die(
"Could not connect to MySQL!!");
  
  
// Select the database
  
mysql_select_db("pj_web"$link);
  
mysql_query("INSERT into pj_newstable (id, date, body, time) VALUES (NULL, '$date_str', '$body', '$time_str')") or die ("INSERT query on pj_newstable died: " mysql_error());
  
  
mysql_close($link);
    
  print 
"<html><title>Post News</title><body><center>The news has been added.</center><br><br><center>Click <a href=\"/\" onmouseover=\"window.status='Home'\; return 1\">here</a> to go home.</body></html>\n";

}

?>