Hi, I downloaded this news script for my site and I can get it to work just fine with it in its own file. There are a couple of changes that I would like to make that I cant figure out. There is no help from the creator of this script. It is a flat file script. Script is located here. - http://www.phptoys.com/download/news-publishing.html I would like to add the admin section to my exsisting admin page. I was able to do this but when I click to post the new text it has to go to the news file which has to be in the admin directory as well. This makes it so that I cant call up the news file from my index. I can of course put a link in my admin to the admin of the news script but would prefer to have it on the admin page. The second is to make the script overwrite the file instead of adding to it. As it is now it writes to the file and will just add to it and all previous news shows up as well unless you go into the file and delete the previous news items. My admin page w/newsbox installed and working. Have marked the news box edits. There are 3 places edited. <? /** * Admin.php * * This is the Admin Center page. Only administrators * are allowed to view this page. This page displays the * database table of users and banned users. Admins can * choose to delete specific users, delete inactive users, * ban users, update user levels, etc. * * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC) * Last Updated: August 26, 2004 */ include("../include/session.php"); /** * displayUsers - Displays the users database table in * a nicely formatted html table. */ function displayUsers(){ global $database; $q = "SELECT username,userlevel,email,timestamp " ."FROM ".TBL_USERS." ORDER BY userlevel DESC,username"; $result = $database->query($q); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if(!$result || ($num_rows < 0)){ echo "Error displaying info"; return; } if($num_rows == 0){ echo "Database table empty"; return; } /* Display table contents */ echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"; echo "<tr><td><b>Username</b></td><td><b>Level</b></td><td><b>Email</b></td><td><b>Last Active</b></td></tr>\n"; for($i=0; $i<$num_rows; $i++){ $uname = mysql_result($result,$i,"username"); $ulevel = mysql_result($result,$i,"userlevel"); $email = mysql_result($result,$i,"email"); $time = mysql_result($result,$i,"timestamp"); echo "<tr><td>$uname</td><td>$ulevel</td><td>$email</td><td>$time</td></tr>\n"; } echo "</table><br>\n"; } /** * displayBannedUsers - Displays the banned users * database table in a nicely formatted html table. */ function displayBannedUsers(){ global $database; $q = "SELECT username,timestamp " ."FROM ".TBL_BANNED_USERS." ORDER BY username"; $result = $database->query($q); /* Error occurred, return given name by default */ $num_rows = mysql_numrows($result); if(!$result || ($num_rows < 0)){ echo "Error displaying info"; return; } if($num_rows == 0){ echo "Database table empty"; return; } /* Display table contents */ echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n"; echo "<tr><td><b>Username</b></td><td><b>Time Banned</b></td></tr>\n"; for($i=0; $i<$num_rows; $i++){ $uname = mysql_result($result,$i,"username"); $time = mysql_result($result,$i,"timestamp"); echo "<tr><td>$uname</td><td>$time</td></tr>\n"; } echo "</table><br>\n"; } /** * User not an administrator, redirect to main page * automatically. */ if(!$session->isAdmin()){ header("Location: ../main.php"); } else{ /** * Administrator is viewing page, so display all * forms. */ /** *News box above body code added here-------------------------------------- */ if (!isset($_POST['submit'])) {?> <link href="style/style.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript" src="js/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced", theme_advanced_buttons3 : "", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", }); </script> /** *End news box top edit--------------------------------------- */ <html> <title>My Site Admin Settings</title> <body> <h1>Admin Center</h1> <font size="5" color="#ff0000"> <b>::::::::::::::::::::::::::::::::::::::::::::</b></font> <font size="4">Logged in as <b><? echo $session->username; ?></b></font><br><br> <div id="menu"> <ul> <li class="current_page_item"><a href="#" class="first">Homepage</a></li> <li><a href="users.php">Members</a></li> <li><a href="contact.php">Contact</a></li> <li><a href="register.php">Join</a></li> <li><a href="main.php">Login</a></li> <li><a href="process.php">Log Out</a></li> </ul> </div> Back to [<a href="../main.php">Main Page</a>]<br><br> /** *News box body code added here-------------------------------------- */ <div id="main"> <div id="caption">Micro News - Add news</div> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> News title:<br/> <input type="text" name="title" size="40"/><br/><br/> Content:<br/> <textarea name="newstext" rows="15" cols="67"></textarea><br/> <center><input type="submit" name="submit" value="Save" /></center> </form> <div id="source">Micro News 1.0</div> </div> /** *End news box body edit--------------------------------------- */ <? if($form->num_errors > 0){ echo "<font size=\"4\" color=\"#ff0000\">" ."!*** Error with request, please fix</font><br><br>"; } ?> <table align="left" border="0" cellspacing="5" cellpadding="5"> <tr><td> <? /** * Display Users Table */ ?> <h3>Users Table Contents:</h3> <? displayUsers(); ?> </td></tr> <tr> <td> <br> <? /** * Update User Level */ ?> <h3>Update User Level</h3> <? echo $form->error("upduser"); ?> <table> <form action="adminprocess.php" method="POST"> <tr><td> Username:<br> <input type="text" name="upduser" maxlength="30" value="<? echo $form->value("upduser"); ?>"> </td> <td> Level:<br> <select name="updlevel"> <option value="1">1 <option value="9">9 </select> </td> <td> <br> <input type="hidden" name="subupdlevel" value="1"> <input type="submit" value="Update Level"> </td></tr> </form> </table> </td> </tr> <tr> <td><hr></td> </tr> <tr> <td> <? /** * Delete User */ ?> <h3>Delete User</h3> <? echo $form->error("deluser"); ?> <form action="adminprocess.php" method="POST"> Username:<br> <input type="text" name="deluser" maxlength="30" value="<? echo $form->value("deluser"); ?>"> <input type="hidden" name="subdeluser" value="1"> <input type="submit" value="Delete User"> </form> </td> </tr> <tr> <td><hr></td> </tr> <tr> <td> <? /** * Delete Inactive Users */ ?> <h3>Delete Inactive Users</h3> This will delete all users (not administrators), who have not logged in to the site<br> within a certain time period. You specify the days spent inactive.<br><br> <table> <form action="adminprocess.php" method="POST"> <tr><td> Days:<br> <select name="inactdays"> <option value="3">3 <option value="7">7 <option value="14">14 <option value="30">30 <option value="100">100 <option value="365">365 </select> </td> <td> <br> <input type="hidden" name="subdelinact" value="1"> <input type="submit" value="Delete All Inactive"> </td> </form> </table> </td> </tr> <tr> <td><hr></td> </tr> <tr> <td> <? /** * Ban User */ ?> <h3>Ban User</h3> <? echo $form->error("banuser"); ?> <form action="adminprocess.php" method="POST"> Username:<br> <input type="text" name="banuser" maxlength="30" value="<? echo $form->value("banuser"); ?>"> <input type="hidden" name="subbanuser" value="1"> <input type="submit" value="Ban User"> </form> </td> </tr> <tr> <td><hr></td> </tr> <tr><td> <? /** * Display Banned Users Table */ ?> <h3>Banned Users Table Contents:</h3> <? displayBannedUsers(); ?> </td></tr> <tr> <td><hr></td> </tr> <tr> <td> <? /** * Delete Banned User */ ?> <h3>Delete Banned User</h3> <? echo $form->error("delbanuser"); ?> <form action="adminprocess.php" method="POST"> Username:<br> <input type="text" name="delbanuser" maxlength="30" value="<? echo $form->value("delbanuser"); ?>"> <input type="hidden" name="subdelbanned" value="1"> <input type="submit" value="Delete Banned User"> </form> </td> </tr> </table> <br> <br> <br> </body> /** *News box below body code added here-------------------------------------- */ <?php } else { $newsTitel = isset($_POST['title']) ? $_POST['title'] : 'Untitled'; $submitDate = date('Y-m-d g:i:s A'); $newsContent = isset($_POST['newstext']) ? $_POST['newstext'] : 'No content'; $filename = date('YmdHis'); $f = fopen('news/'.$filename.".txt","w+"); fwrite($f,$newsTitel."\n"); fwrite($f,$submitDate."\n"); fwrite($f,$newsContent."\n"); fclose($f); header('Location:index.php'); } ?> /** *End news box below body edit--------------------------------------- */ </html> <? } ?> Code (markup): My index for the news box <?php /************************************************* * Micro News * * Version: 1.0 * Date: 2007-07-12 * * Usage: * ****************************************************/ // This function reads all available news function getNewsList(){ $fileList = array(); // Open the actual directory if ($handle = opendir("news")) { // Read all file from the actual directory while ($file = readdir($handle)) { if (!is_dir($file)) { $fileList[] = $file; } } } rsort($fileList); return $fileList; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Micro News</title> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="caption">Site News</div> <table width="100%"> <?php $list = getNewsList(); foreach ($list as $value) { $newsData = file("news/".$value); $newsTitle = $newsData[0]; $submitDate = $newsData[1]; unset ($newsData['0']); unset ($newsData['1']); $newsContent = ""; foreach ($newsData as $value) { $newsContent .= $value; } echo "<tr><th align='left'>$newsTitle</th><th align='right'>$submitDate</th></tr>"; echo "<tr><td colspan='2'>".$newsContent."<br/><hr size='1'/></td></tr>"; } ?> </table> </body> Code (markup):