Jump to content
xisto Community
Sign in to follow this  
Albus Dumbledore

An Announcement Box Like The One In Ipb Admin Panel

Recommended Posts

Ok, well what i am looking for is an "announcement box" like the one on the first page of Invision Powerboards Administration Panel... basicly all you do it type somthing into it, and hit submit, and it gets saved im guessing into a writable document somewhere in the admin directory, and what i am looking for is somthing exactly like that....on my website, the webmaster and I both keep a backup of all of the files and every so often someone doesn't make a backup after the other has edited somthing, and so they may upload old content, so what i want is a box like the one on Invision Powerboard admin panel so we can put in there what we edited so the other one can update their backup just on the files that we changed...ill be looking around the net, but i thought i might get somthing a little faster here <_<thanks in advaced

Share this post


Link to post
Share on other sites

I can write that for you now <_< Hopefully, it should all work okay:

 


 

if (isset($_POST['submit'])) {

 

$content = $_POST['content'];

 

$fopen = fopen($file, 'w');

$fwrite = fwrite($fopen, $content);

 

if ($fwrite == FALSE) {

 

$error_msg .= ' <b> Error writing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> ';

 

} else {

 

$done .= ' Announcement saved ';

 

}

 

fclose($fopen);

 

}

 

if ($_REQUEST['do'] == 'delete') {

 

$fopen_b = fopen ($file, 'w');

$fwrite_b = fwrite ($fopen_b, '');

 

if ($fwrite_b == FALSE) {

 

$error_msg .= ' <b> Error clearing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> ';

 

} else {

 

$done .= ' Announcements cleared. ';

 

}

 

fclose($fopen_B);

 

}

 

 

?>

<form method="post" action="<?php=$_SERVER['PHP_SELF'];?>">

<span style="font-size _linenums:11'><?php $file = ''; if (isset($_POST['submit'])) { $content = $_POST['content']; $fopen = fopen($file, 'w'); $fwrite = fwrite($fopen, $content); if ($fwrite == FALSE) { $error_msg .= ' <b> Error writing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> '; } else { $done .= ' Announcement saved '; } fclose($fopen); } if ($_REQUEST['do'] == 'delete') { $fopen_b = fopen ($file, 'w'); $fwrite_b = fwrite ($fopen_b, ''); if ($fwrite_b == FALSE) { $error_msg .= ' <b> Error clearing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> '; } else { $done .= ' Announcements cleared. '; } fclose($fopen_B); } ?><form method="post" action="<?php=$_SERVER['PHP_SELF'];?>"> <span style="font-size: 11pt"> Announcements: </span> <textarea style="border: 1px" name="content"> <?php=file_get_contents($file); ?> </textarea> <input type="submit" value="Change Announcements" name="submit"> <input type="button" onClick="window.location='<?php=$_SERVER['PHP_SELF'];?>?do=delete';"></form> <p> <?php if (isset($error_msg)) { echo ' <span style="color: red"> ERROR: </span> ' . $error_msg . ' <br>'; } if (isset($done)) { echo ' <span style="color: green"> ' . $done . ' </span>'; } ?>


There are probably some errors there somewhere. If you find them, tell me and I'll fix them.

 

You need to:

Create a small text file and change its permissions to 0777

Copy the absolute path of the file (ie. /home/you/public_html/dir/dir/file.txt) between the two apostrophes where it says $file = '';

If the script does not work after doing those to things, you should set the directory's permissions to 0777 although that should not be neccessary.


Share this post


Link to post
Share on other sites

wow thank you <_<

now i have a problem...

i figured out where i screwed up and amended it, but now, http://forums.xisto.com/no_longer_exists/

i can type in the "Invisible box" that is there and hit change announcement, but when i leave the page and come back, i cannot see what i typed in.... :ph34r:

Edited by Albus Dumbledore (see edit history)

Share this post


Link to post
Share on other sites

Sorry for the late reply. I've just been busy and I've downloaded supercool VB 2005 Express Edition and tweaking with that. I've created a web browser <_<

Well I've changed the code a bit. See if this works:



if (isset($_POST['submit'])) {

$content = $_POST['content'];

$fopen = fopen($file, 'w');
$fwrite = fwrite($fopen, $content);

if ($fwrite == FALSE) {

$error_msg .= ' <b> Error writing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> ';

} else {

$done .= ' Announcement saved ';

}

fclose($fopen);

}

if ($_REQUEST['do'] == 'delete') {

$fopen_b = fopen ($file, 'w');
$fwrite_b = fwrite ($fopen_b, ' ');

if ($fwrite_b == FALSE) {

$error_msg .= ' <b> Error clearing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> ';

} else {

$done .= ' Announcements cleared. ';

}

fclose($fopen_B);

}


?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<span style="font-size _linenums:11'><?php$file = ' ';if (isset($_POST['submit'])) {$content = $_POST['content'];$fopen = fopen($file, 'w');$fwrite = fwrite($fopen, $content);if ($fwrite == FALSE) {$error_msg .= ' <b> Error writing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> ';} else {$done .= ' Announcement saved ';}fclose($fopen);}if ($_REQUEST['do'] == 'delete') {$fopen_b = fopen ($file, 'w');$fwrite_b = fwrite ($fopen_b, ' ');if ($fwrite_b == FALSE) {$error_msg .= ' <b> Error clearing file. Check that both the file and its directory permissions are set to <i>0777</i> or <i>777</i> </b> ';} else {$done .= ' Announcements cleared. ';}fclose($fopen_B);}?><form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"><span style="font-size: 11pt"> Announcements: </span> <br><textarea style="border-width: 1px; background-color: blue; color: white" name="content"> <?php echo file_get_contents($file); ?> </textarea> <br><input type="submit" value="Change Announcements" name="submit"> <input type="button" onClick="window.location='<?php echo $_SERVER['PHP_SELF'];?>?do=delete';" value="Clear All Announcements"></form><p> <?phpif (isset($error_msg)) {echo ' <span style="color: red"> ERROR: </span> ' . $error_msg . ' <br>';}if (isset($done)) {echo ' <span style="color: green"> ' . $done . ' </span>';}?>
If that doesn't then I can't see what it is. It works perfectly when I test it out here:

http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

sorry i havent replyed, ive been on vacation for the last three weeks, so i just now uploaded it up to my site and that one works fine :)thanks a bunch!!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.