/home/wpollock1/public_html/PHP/RSSupdate.php
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
146: print "http://$site/";
147: ?>" tabindex="999"> <?php
148: print "$site";
149: ?></a> </h2>
150:
151: <form action="<?php print $scriptName; ?>" method="post"
152: onsubmit="return do_chap();">
153:
154: <fieldset id="topOfForm">
155: <legend> Administrator Authentication </legend>
156:
157: <div id="pw">
158:
159: <input type="hidden" name="challenge" id="challenge"
160: value="<?php print $_SESSION['challenge']; ?>" />
161:
162: <p>
163: <label> Admin Name:
164: <input type="text" id="userid" tabindex="5"
165: onkeypress="clearError();" />
166: </label>
167: </p>
168:
169: <p>
170: <label> Password:
171: <input type="password" id="password" tabindex="10"
172: onkeypress="clearError();" />
173: </label>
174: </p>
175: </div>
176:
177: <p id="submit">
178: <input type="submit" value=" Login " tabindex="20" />
179: </p>
180:
181: <p id="notification">
182: </p>
183:
184: </fieldset>
185:
186: <div id="feedselect">
187: <p>
188: <?php
189: // On my site, all feed file names end with "*RSS.xml".
190: function isFeed ( $filename ) // return true if $filename is a feed:
191: {
192: return (substr($filename, -(strlen(FEED_SUFFIX) )) == FEED_SUFFIX);
193: }
194:
195: $feeds = array_filter( scandir( ".." ), isFeed );
196:
197: if ( count($feeds) == 0 )
198: { print "<h2>No feeds found!</h2>\n";
199: x;
200: } else
201: {
202: ksort( $feeds );
203:
204: // Display list of feeds:
205: print "<label> Feed:\n<select id=\"feed\" tabindex=\"30\">\n";
206: print " <option value=\"None\">Select</option>\n";
207:
208: foreach ( $feeds as $feed )
209: print " <option value=\"$feed\">" . rtrim($feed, FEED_SUFFIX)
210: . "</option>\n";
211:
212: print "</select></label>\n\n";
213: }
214: ?>
215: </p>
216: </div>
217: </form>
218: </div>
219:
220: <div>
221: <pre id="sess_close">
222: <?php
223: session_write_close();
224: // $_SESSION = array(); session_destroy();
225: ?>
226: </pre>
227: </div>
228:
229: </body></html>