RSSupdate-saved.txt

  1: <?php include "mimetype.php" ?>
  2: 
  3: <!--
  4:   The above sets the content type and generates the following prolog,
  5:   if the browser accepts XHTML (else generates HTML 4.01 prolog):
  6: 
  7: < ?xml version="1.0" encoding="utf-8"?>
  8: < ?xml-stylesheet href="#internalStyle" type="text/css"?>
  9: < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 10:            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 11: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 12: -->
 13: 
 14: <head>
 15: <meta http-equiv="Content-Type"
 16:       content="application/xhtml+xml; charset='utf-8'" />
 17: <meta http-equiv="Vary" content="Content-language" />
 18: 
 19: <title> RSS Feed Updater </title>
 20: 
 21: <style type="text/css" id="internalStyle">
 22: <![CDATA[
 23: body        { background-color: cyan; }
 24: h1, h2      { text-align: center; }
 25: #notification { color: red; font-style: bold; font-size: 150%; }
 26: #name       { float: left; padding-right: 5em; }
 27: #medInfo    { float: left; padding-right: 5em; }
 28: #feedselect { clear: both; padding: .25em; }
 29: #sess_open, #sess_close { background-color: gray; }
 30: #topOfForm  { text-align: center; vertical-align: top; }
 31: #pw         { float: left; margin-top:0; vertical-align: top; }
 32: ]]>
 33: </style>
 34: 
 35: <script type="text/JavaScript" src="MD5.js"></script>
 36: 
 37: <script type="text/JavaScript">
 38: <![CDATA[
 39: 
 40: var notification = document.getElementById( 'notification' );
 41: 
 42: function do_chap ()
 43: {
 44: var userid = document.getElementById('userid');
 45: if( !userid || !userid.value )
 46: {  showError( userid, 'Enter your username' );
 47:    return false;
 48: }
 49: var password=document.getElementById('password');
 50: 
 51: if( !password || !password.value )
 52: {  showError( password, 'Enter your password');
 53:    return false;
 54: }
 55: 
 56: var challenge = document.getElementById('challenge');
 57: if( !challenge ) { return false; }
 58: 
 59: // Calculate: MD5( MD5(password) + challenge ) and replace challenge:
 60: password.value = hex_md5( hex_md5(password.value) + challenge.value );
 61: return true;
 62: }
 63: 
 64: function clearError ()
 65: {  if ( notification )
 66:      while ( notification.firstChild )
 67:         notification.removeChild( notification.firstChild );
 68: }
 69: 
 70: function showError ( obj, message )
 71: {
 72:   clearError();
 73:   if ( !notification )
 74:      notification = document.getElementById( 'notification' );
 75:   notification.appendChild( document.createTextNode( message ) );
 76:   obj.focus();
 77: }
 78: 
 79: ]]>
 80: </script>
 81: 
 82: </head>
 83: 
 84: <body>
 85: <div>
 86: <pre id="sess_open">
 87: <?php
 88: function sess_open ( $sess_path, $sess_name )
 89: {
 90:   print "Session Opened: Path=\"$sess_path\", Name=\"$sess_name\"\n";
 91:   return true;
 92: }
 93: 
 94: function sess_close ()
 95: {
 96:   print "Session closed.\n";
 97:   return true;
 98: }
 99: 
100: function sess_read ( $sess_id )
101: {
102:   print "Session read: ID=\"$sess_id\"\n";
103:   return '';
104: }
105: 
106: function sess_write ( $sess_id, $data )
107: {
108:   print "Session written: ID=\"$sess_id\"\n   Data=\"$data\"\n";
109:   return true;
110: }
111: 
112: function sess_destroy ( $sess_id )
113: {
114:   print "Session destroyed: ID=\"$sess_id\"\n";
115:   return true;
116: }
117: 
118: function sess_gc ( $sess_max_lifetime )
119: {
120:   print "Session garbage collected: "
121:     . "Max Lifetime=\"$sess_max_lifetime\"\n";
122:   return true;
123: }
124: 
125: session_set_save_handler( "sess_open", "sess_close", "sess_read",
126:     "sess_write", "sess_destroy", "sess_gc" );
127: 
128: session_start();
129: 
130: // Generate a challenge string:
131: $_SESSION['challenge']=md5(rand(1,100000));
132: 
133: if (empty($_SESSION['count'])) {
134:    $_SESSION['count'] = 1;
135: } else {
136:    $_SESSION['count']++;
137: }
138: $scriptName = basename( __FILE__ );
139: define( "FEED_SUFFIX", "RSS.xml" );
140: $site = $_SERVER['SERVER_NAME'];
141: ?>
142: </pre>
143: 
144: <h1> RSS Site Feed Updater </h1>
145: <h2> For <a href="<?php print "http://$site/"; ?>" tabindex="999">
146: <?php print "$site"; ?></a> </h2>
147: 
148: <form action="<?php print $scriptName; ?>" method="post"
149:       onsubmit="return do_chap();">
150: 
151: <fieldset id="topOfForm">
152: <legend> Administrator Authentication </legend>
153: 
154: <div id="pw">
155: 
156: <input type="hidden" name="challenge" id="challenge"
157: value="<?php print $_SESSION['challenge']; ?>" />
158: 
159: <p>
160: <label> Admin Name:
161:    <input type="text" id="userid" tabindex="5"
162:           onkeypress="clearError();" />
163: </label>
164: </p>
165: 
166: <p>
167: <label> Password:&nbsp;&nbsp;&nbsp;&nbsp;
168:    <input type="password" id="password" tabindex="10"
169:           onkeypress="clearError();" />
170: </label>
171: </p>
172: </div>
173: 
174: <p id="submit">
175: <input type="submit" value=" Login " tabindex="20" />
176: </p>
177: 
178: <p id="notification">
179: </p>
180: 
181: </fieldset>
182: 
183: <div id="feedselect">
184: <p>
185: <?php
186: // On my site, all feed file names end with "*RSS.xml".
187: function isFeed ( $filename )  // return true if $filename is a feed:
188: {
189:    return (substr($filename, -(strlen(FEED_SUFFIX) )) == FEED_SUFFIX);
190: }
191: 
192: $feeds = array_filter( scandir( ".." ), isFeed );
193: 
194: if ( count($feeds) == 0 )
195: {  print "<h2>No feeds found!</h2>\n";
196:    x;
197: } else
198: {
199:    ksort( $feeds );
200: 
201:    // Display list of feeds:
202:    print "<label> Feed:\n<select id=\"feed\" tabindex=\"30\">\n";
203:    print "  <option value=\"None\">Select</option>\n";
204: 
205:    foreach ( $feeds as $feed )
206:       print "  <option value=\"$feed\">" . rtrim($feed, FEED_SUFFIX)
207:           . "</option>\n";
208: 
209:    print "</select></label>\n\n";
210: }
211: ?>
212: </p>
213: </div>
214: </form>
215: </div>
216: 
217: <div>
218: <pre id="sess_close">
219: <?php
220: session_write_close();
221: // $_SESSION = array(); session_destroy();
222: ?>
223: </pre>
224: </div>
225: 
226: </body></html>