<? switch ($auth) {
case login: // change your password here if($password == "admin") { setcookie("adminloggedin", "loggedin", "+3600"); header("Location: $PHP_SELF");
}
else { echo "wrong password"; }
break;
case logout: setcookie("adminloggedin", "", "-3600"); header("Location: $PHP_SELF");
break; } ?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<style type="text/css">
BODY { SCROLLBAR-BASE-COLOR: #9BB3CE; SCROLLBAR-ARROW-COLOR: #ffffff; BACKGROUND-COLOR:
#666666; COLOR: #000000; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE:
9px; FONT-WEIGHT: normal; MARGIN: 0px ; cursor: default}
TD { COLOR: #000000; FONT-FAMILY: Verdana,
Arial, Helvetica, sans-serif; FONT-SIZE: 11px; line-height: normal}
A { COLOR:
#333333; FONT-FAMILY: verdana, tahoma, arial, helvetica; FONT-SIZE: 10px; FONT-WEIGHT:
normal; text-decoration: none}
A:active { COLOR: #FF9900; FONT-FAMILY: Verdana,
Arial, Helvetica, sans-serif; FONT-SIZE: 10px; FONT-WEIGHT: bold}
A:visited { COLOR: #333333; FONT-FAMILY: verdana, tahoma, arial, helvetica;
FONT-SIZE: 10px; FONT-WEIGHT: normal; TEXT-DECORATION: none }
A:hover { COLOR:
#CC9900; FONT-FAMILY: verdana, tahoma, arial, helvetica; FONT-SIZE: 10px; FONT-WEIGHT:
normal}
</style>
<body bgcolor="#666666" text="#000000" link="#0000FF" vlink="#000099">
<div align="center"><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</div>
<table border="0" cellspacing="0" cellpadding="0" height="1" align="center" width="100">
<tr>
<td bgcolor="#000000" valign="top" height="2">
<table width="500" border="0" cellspacing="1" cellpadding="0" height="2" align="center">
<tr>
<td height="15" bgcolor="#669933" width="445"><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">My
news - [<a href="?add">Add</a>] [<a href="?preview">Preview</a>] [<a href="?delete">Delete</a>]
[<a href="?edit">Edit</a>] [<a href="?build">Build</a>] [<a href="?logout">Logout</a>]</font></td>
<td height="15" bgcolor="#669933" width="52">
<div align="center"><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">[<a href="?credit">Credit</a>]</font></div>
</td>
</tr>
<tr>
<td height="225" bgcolor="#CECFD7" colspan="2">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? if($adminloggedin == "loggedin") { ?> <? switch($QUERY_STRING) {
default: ?>
</font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#000000">
<? switch($action) {
default:
echo "What do you want to do??";
break;
// add news to the news.db case addnews: $date = date("m-d-y @ h:iA"); $news_db = 'news.db'; $headline_stripped = stripslashes($headline); $news = stripslashes($news); $newsbiggrin = str_replace(":D", "<img src="images/biggrin.gif">",$news); $newssmile = str_replace(":)", "<img src="images/smile.gif">",$newsbiggrin); $newssad = str_replace(":(", "<img src="images/sad.gif">",$newssmile); $newswink = str_replace(";)", "<img src="images/wink.gif">",$newssad); $newst = str_replace(":p", "<img src="images/sticktongue.gif">",$newswink); $news = str_replace("n", "<br>",$newst); $fp = fopen("$news_db", "a+"); $fw = fwrite($fp, "n[~nl~]$headline_stripped [~]$date [~]$news");
echo "News added<br><br><a href="$PHP_SELF?add">Click here if you want to ADD more news</a>";
fclose($fp);
break;
// delete news from the db by searching for the news and replacing it with empty ""
case deletenews: $news_db = "news.db";
$fp = fopen($news_db, "r"); $data = fread($fp, filesize("$news_db")); $oldnews = $data; fclose($fp); $line = explode("[~nl~]", $data); $items_to_delete = "[~nl~]" . $line[$newsnum]; $deleted = str_replace("$items_to_delete", "", $oldnews); $fp = fopen($news_db, "w"); $fw = fwrite($fp, $deleted); fclose($fp);
echo "News deleted!!<br><br><a href="$PHP_SELF?delete">Click here if you want to DELETE more news</a>";
break;
// edit news by searching for the old news and replace it with the new one, simple str_replace
case editnews: $news_db = "news.db";
$fp = fopen($news_db, "r"); $oldnews = fread($fp, filesize("$news_db")); fclose($fp); $headline = stripslashes($headline); $news_replaced = str_replace("n", "<br>", $news); $newsf = stripslashes($news_replaced); $news_edited = $newsf; $news_old = $news_old; $edited = str_replace($news_old, $news_edited, $oldnews); $editedheadline = str_replace($headline_old, $headline, $edited); $fp = fopen($news_db, "w"); $fw = fwrite($fp, $editedheadline);
fclose($fp);
echo "<br>";
echo "Old :$news_old<br>";
echo "New :$news_edited";
break;
//build news using the news.db. to format your news, scroll down about 15 lines
case buildnews: $fp = fopen("news.txt", "w");
$fw = fwrite($fp,""); fclose($fp); $news_db = "news.db"; $fp = fopen($news_db, "r"); $data = fread($fp, filesize("$news_db")); fclose($fp);
$format = "$headline - $date"; $line = explode("[~nl~]", $data); $lastnews = sizeof($line) - "1";
for($i=$lastnews; $i > 0; $i--) {
list($headline,$date,$content) = explode("[~]", $line[$i]); $fp = fopen("news.txt", "a+");
// format your news here $fw = fwrite($fp, "<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr><td height="2" valign="top"><p align="left">
<font color="#999999"><b>$headline</b> - </font><font size="1" color="#000000">$date</font></p>
</td></tr><tr><td valign="top"><font color="#999999">$content</font></td></tr></table><br>n");
fclose($fp);}
echo "News built, you may now check your site to see the updated news";
break;
case logout:
header('Location: index.php');
break;
} ?>
</font><br>
<br>
<br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">My News
by Tuan Do</font><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break;
case add: ?>
</font>
<form name="form1" method="post" action="<? echo "$PHP_SELF"; ?>">
<br>
<br>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>Add news:<br>
<br>
</b></td>
</tr>
<tr>
<td> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
</font>
<table width="150" border="0" cellspacing="0" cellpadding="0" height="170">
<tr valign="top">
<td> <font size="1" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">Headline</font>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><br>
<input type="text" name="headline" maxlength="200" size="15" style="font-size:8pt; background-color:#CECFD7;color:black; border: 1 px;border-color:#000000;">
</font></td>
</tr>
<tr valign="top">
<td> <font size="1" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">News<br>
</font>
<table border="0" cellspacing="0" cellpadding="0" width="150" height="111">
<tr valign="top">
<td width="46%" rowspan="6"> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<textarea name="news" cols="18" rows="6" style="font-size:8pt; background-color:#CECFD7;color:black; border: 1 px;border-color:#000000;" wrap="PHYSICAL"></textarea>
<br>
<input type="submit" name="Submit" value="Add">
<input type="hidden" name="action" value="addnews">
</font></td>
</tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break; case preview: ?> <br>
<br>
<br>
</font>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>This is how your news will look like:<br>
<br>
</b></td>
</tr>
<tr>
<td bgcolor="#8C8C8C">
<?
$news_db = "news.db"; $fp = fopen($news_db, "r"); $data = fread($fp, filesize("$news_db")); $line = explode("[~nl~]", $data);
$lastnews = sizeof($line) - "1";
for($i=$lastnews; $i > 0; $i--) {
list($headline,$date,$content) = explode("[~]", $line[$i]);
echo "<b>$headline</b> - $date<br>$content<br><br>";
} ?>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<br>
</font> </td>
</tr>
</table>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break; case delete: ?> </font>
<form name="form2" method="post" action="<? echo "$PHP_SELF"; ?>">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <b> Delete News<br>
<br>
</b></td>
</tr>
<tr>
<td>
<?
$news_db = "news.db"; $fp = fopen($news_db, "r"); $data = fread($fp, filesize("$news_db")); $line = explode("[~nl~]", $data);
for($i=0;$i < sizeof($line); $i++){
list($headline,$date,$content) = explode("[~]", $line[$i]);
echo "<input type="radio" name="newsnum" value="$i"> <b>$headline - </b>$date <br>";
} ?>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<br>
<input type="submit" name="Delete" value="Delete">
<input type="hidden" name="action" value="deletenews">
</font> </td>
</tr>
</table>
</form>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break; case edit: ?> <?
if($selected != "yes") {
?> </font>
<form name="form2" method="post" action="<? echo "$PHP_SELF"; ?>?edit">
<br>
<br>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> <b> Edit news<br>
<br>
</b></td>
</tr>
<tr>
<td>
<?
$news_db = "news.db"; $fp = fopen($news_db, "r"); $data = fread($fp, filesize("$news_db")); $line = explode("[~nl~]", $data);
for($i=0;$i < sizeof($line); $i++){
list($headline,$date,$content) = explode("[~]", $line[$i]);
echo "<input type="radio" name="newsnum" value="$i"> <b>$headline - </b>$date <br>";
} ?>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<br>
<input type="submit" name="Edit" value="Select">
<input type="hidden" name="selected" value="yes">
</font> </td>
</tr>
</table>
<br>
</form>
<br><? } else { ?>
<form name="form1" method="post" action="<? echo "$PHP_SELF"; ?>">
<br>
<br>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><b>Editing news:<? $news_db = "news.db"; $fp = fopen($news_db, "r"); $data = fread($fp, filesize("$news_db")); $line = explode("[~nl~]", $data);
list($headline,$date,$content) = explode("[~]", $line[$newsnum]); ?><br>
<br>
</b></td>
</tr>
<tr>
<td> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
</font>
<table width="150" border="0" cellspacing="0" cellpadding="0" height="170">
<tr valign="top">
<td> <font size="1" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">This
is your old headline</font> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><br>
<input type="text" maxlength="200" size="25" style="font-size:8pt; background-color:#CECFD7;color:black; border: 1 px;border-color:#000000;" value="<? echo $headline; ?>" name="headline">
</font></td>
</tr>
<tr valign="top">
<td> <font size="1" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">This
is your old news</font><font size="1" color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><br>
</font>
<table border="0" cellspacing="0" cellpadding="0" width="150" height="111">
<tr valign="top">
<td width="46%" rowspan="6"> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<textarea name="news" cols="25" rows="6" style="font-size:8pt; background-color:#CECFD7;color:black; border: 1 px;border-color:#000000;" wrap="PHYSICAL"><? echo $content; ?></textarea>
</font></td>
</tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
</table>
</td>
</tr>
</table>
<br>
<br>
<br>
<br>
<br>
<table width="150" border="0" cellspacing="0" cellpadding="0" height="170">
<tr valign="top">
<td> <font size="1" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">Headline</font>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000"><br>
<input type="text" name="headline_old" maxlength="200" size="25" style="font-size:8pt; background-color:#CECFD7;color:black; border: 1 px;border-color:#000000;" value="<? echo $headline; ?>">
</font></td>
</tr>
<tr valign="top">
<td> <font size="1" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">News<br>
</font>
<table border="0" cellspacing="0" cellpadding="0" width="150" height="111">
<tr valign="top">
<td width="46%" rowspan="6"> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<textarea name="news_old" cols="25" rows="6" style="font-size:8pt; background-color:#CECFD7;color:black; border: 1 px;border-color:#000000;" wrap="PHYSICAL"><? echo $content; ?></textarea>
<br>
<input type="submit" name="Submit2" value="Save">
<input type="hidden" name="action" value="editnews">
</font></td>
</tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
<tr valign="top"> </tr>
</table>
</td>
</tr>
</table>
<br>
</td>
</tr>
</table>
</form><? } ?>
<br>
<br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break; case build: ?> </font>
<form name="form2" method="post" action="<? echo "$PHP_SELF"; ?>">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
Click here to build your news.<br>
Remember, all changes will not be visible until you Build!!<br>
<input type="submit" name="Build" value="Build">
<input type="hidden" name="action" value="buildnews">
</font> </div>
</td>
</tr>
</table>
</form>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
</font><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break; case logout: ?> </font>
<form name="logout" method="post" action="<? echo "$PHP_SELF"; ?>">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
Click here to logout. You will be retured to your homepage.<br>
<input type="submit" name="Log out" value="Log out">
<input type="hidden" name="auth" value="logout">
</font> </div>
</td>
</tr>
</table>
</form>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break; case credit: ?> </font>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="left"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
My News<br>
Scripted by Tuan Do after 5 hours and four cans of Pepsi.<br>
Contact me : <a href="mailto:celerondude@celerondude.com">celerondude@celerondude.com</a><br>
Aim: celerondude<br>
My homepage <a href="http://www.celerondude.com" target="_blank">www.celerondude.com</a></font>
</div>
</td>
</tr>
</table>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? break; } ?>
<br>
<? } else { ?>
</font>
<form name="form1" method="post" action="<? echo "$PHP_SELF"; ?>?auth=login">
You are not logged in.<br>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<input type="text" name="password" maxlength="200" size="15" style="font-size:8pt; background-color:#CECFD7;color:black; border: 1 px;border-color:#000000;">
<br>
<input type="submit" name="Login" value="Login">
</font>
</form>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<? } ?>
</font></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<br>
</body>
</html>
|
|