/home/wpollock1/public_html/PHP/RSSupdate.php

<?php include "mimetype.php" ?>

<!--
  The above sets the content type and generates the following prolog,
  if the browser accepts XHTML (else generates HTML 4.01 prolog):

< ?xml version="1.0" encoding="utf-8"?>
< ?xml-stylesheet href="#internalStyle" type="text/css"?>
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-->

<head>
<meta http-equiv="Content-Type"
      content="application/xhtml+xml; charset='utf-8'" />
<meta http-equiv="Vary" content="Content-language" />

<title> RSS Feed Updater </title>

<style type="text/css" id="internalStyle">
<![CDATA[
body        { background-color: cyan; }
h1, h2      { text-align: center; }
#notification { color: red; font-style: bold; font-size: 150%; }
#name       { float: left; padding-right: 5em; }
#medInfo    { float: left; padding-right: 5em; }
#feedselect { clear: both; padding: .25em; }
#sess_open, #sess_close { background-color: gray; }
#topOfForm  { text-align: center; vertical-align: top; }
#pw         { float: left; margin-top:0; vertical-align: top; }
]]>
</style>

<script type="text/JavaScript" src="MD5.js"></script>

<script type="text/JavaScript">
<![CDATA[

var notification = document.getElementById( 'notification' );

function do_chap ()
{
var userid = document.getElementById('userid');
if( !userid || !userid.value )
{  showError( userid, 'Enter your username' );
   return false;
}
var password=document.getElementById('password');

if( !password || !password.value )
{  showError( password, 'Enter your password');
   return false;
}

var challenge = document.getElementById('challenge');
if( !challenge ) { return false; }

// Calculate: MD5( MD5(password) + challenge ) and replace challenge:
password.value = hex_md5( hex_md5(password.value) + challenge.value );
return true;
}

function clearError ()
{  if ( notification )
     while ( notification.firstChild )
        notification.removeChild( notification.firstChild );
}

function showError ( obj, message )
{
  clearError();
  if ( !notification )
     notification = document.getElementById( 'notification' );
  notification.appendChild( document.createTextNode( message ) );
  obj.focus();
}

]]>
</script>

</head>

<body>
<div>
<pre id="sess_open">
<?php
function sess_open ( $sess_path, $sess_name )
{
  print "Session Opened: Path=\"$sess_path\", Name=\"$sess_name\"\n";
  return true;
}

function sess_close ()
{
  print "Session closed.\n";
  return true;
}

function sess_read ( $sess_id )
{
  print "Session read: ID=\"$sess_id\"\n";
  return '';
}

function sess_write ( $sess_id, $data )
{
  print "Session written: ID=\"$sess_id\"\n   Data=\"$data\"\n";
  return true;
}

function sess_destroy ( $sess_id )
{
  print "Session destroyed: ID=\"$sess_id\"\n";
  return true;
}

function sess_gc ( $sess_max_lifetime )
{
  print "Session garbage collected: "
    . "Max Lifetime=\"$sess_max_lifetime\"\n";
  return true;
}

session_set_save_handler( "sess_open", "sess_close", "sess_read",
    "sess_write", "sess_destroy", "sess_gc" );

session_start();

// Generate a challenge string:
$_SESSION['challenge']=md5(rand(1,100000));

if (empty($_SESSION['count'])) {
   $_SESSION['count'] = 1;
} else {
   $_SESSION['count']++;
}
$scriptName = basename( __FILE__ );
define( "FEED_SUFFIX", "RSS.xml" );
$site = $_SERVER['SERVER_NAME'];
?>
</pre>

<h1> RSS Site Feed Updater </h1>
<h2> For <a href="<?php
print "http://$site/";
?>" tabindex="999"> <?php
print "$site";
?></a> </h2>

<form action="<?php print $scriptName; ?>" method="post"
      onsubmit="return do_chap();">

<fieldset id="topOfForm">
<legend> Administrator Authentication </legend>

<div id="pw">

<input type="hidden" name="challenge" id="challenge"
value="<?php print $_SESSION['challenge']; ?>" />

<p>
<label> Admin Name:
   <input type="text" id="userid" tabindex="5"
          onkeypress="clearError();" />
</label>
</p>

<p>
<label> Password:&nbsp;&nbsp;&nbsp;&nbsp;
   <input type="password" id="password" tabindex="10"
          onkeypress="clearError();" />
</label>
</p>
</div>

<p id="submit">
<input type="submit" value=" Login " tabindex="20" />
</p>

<p id="notification">
</p>

</fieldset>

<div id="feedselect">
<p>
<?php
// On my site, all feed file names end with "*RSS.xml".
function isFeed ( $filename )  // return true if $filename is a feed:
{
   return (substr($filename, -(strlen(FEED_SUFFIX) )) == FEED_SUFFIX);
}

$feeds = array_filter( scandir( ".." ), isFeed );

if ( count($feeds) == 0 )
{  print "<h2>No feeds found!</h2>\n";
   x;
} else
{
   ksort( $feeds );

   // Display list of feeds:
   print "<label> Feed:\n<select id=\"feed\" tabindex=\"30\">\n";
   print "  <option value=\"None\">Select</option>\n";

   foreach ( $feeds as $feed )
      print "  <option value=\"$feed\">" . rtrim($feed, FEED_SUFFIX)
          . "</option>\n";

   print "</select></label>\n\n";
}
?>
</p>
</div>
</form>
</div>

<div>
<pre id="sess_close">
<?php
session_write_close();
// $_SESSION = array(); session_destroy();
?>
</pre>
</div>

</body></html>