Post by Admin on Jul 20, 2005 23:07:12 GMT
well this is the admin area of the script
<?php
////////////////////////////////////////////////////////////////////////////
// "Bands-Script" Copyright Dippee.com 2005 //
////////////////////////////////////////////////////////////////////////////
// Please feel free to develop this script for the better. but please post
// your modifications on our forum, http://bandsscript.proboards50.com
// you can not sell these script's in any form, but you may charge for
// customisations such as design changes.
// Thank You. Only change that which you are told. otherwise it may not work
// properly. these scripts are designed for http://www.t35.com and
// http://www.tripod.co.uk but should work on any webhost.
// well this is a basic script it creates .php include files so the
// index page can read them if you wanted to know what it does.
// Please change the Admin login Username and Password.
// i.e. where 'Username' is to 'yourunsername' remember to keep the ' before
// and after it so that
$user = 'Username';
$pass = 'Password';
// don't change anything below this line, unless you are developing the
// scripts or fancy playing around with it, and then make sure you have a back-up,
// i made that mistake and just think it could all have been very different.
// I have tried to make it as beginer friendly as i can, so than people can learn from it.
//WHICH PAGE (GET)
$page = $_GET['page'];
$submit = $_GET['submit'];
$rock = $_GET['rock'];
//THE SUB PAGES OF ABOVE (POST)
$text = $_POST['text'];
$date = $_POST['date'];
$time = $_POST['time'];
$location = $_POST['location'];
$forum = $_POST['forum'];
$title = $_POST['title'];
$words = $_POST['words'];
$meaning = $_POST['meaning'];
echo "<html>\n<head>\n</head>\n<body>\n";
//this is the Bulleten Board Code function
function replaceMessage($message) {
$message = strip_tags($message, '<b></b><i></i><u></u><a></a><img>');
$message = str_replace ("\n", "<BR>", "$message");
// When you store the $message in a database you might get errors cause of the quotes
$message = str_replace("[singleQuote]", "'", $message);
$message = str_replace("[doubleQuote]", "\"", $message);
// for UPPER case bb code.
$message = str_replace ("[U]", "<U>", "$message");
$message = str_replace ("[/U]", "</U>", "$message");
$message = str_replace ("[I]", "<I>", "$message");
$message = str_replace ("[/I]", "</I>", "$message");
$message = str_replace ("[B]", "<B>", "$message");
$message = str_replace ("[/B]", "</B>", "$message");
// for LOWER case bb code.
$message = str_replace ("[u]", "<u>", "$message");
$message = str_replace ("[/u]", "</u>", "$message");
$message = str_replace ("[i]", "<i>", "$message");
$message = str_replace ("[/i]", "</i>", "$message");
$message = str_replace ("[b]", "<b>", "$message");
$message = str_replace ("[/b]", "</b>", "$message");
// bb code font so their can be different coloured text
$message = str_replace ("[font=red]", "<font color=red>", "$message");
$message = str_replace ("[font=orange]", "<font color=orange>", "$message");
$message = str_replace ("[font=yellow]", "<font color=yellow>", "$message");
$message = str_replace ("[font=green]", "<font color=green>", "$message");
$message = str_replace ("[font=blue]", "<font color=blue>", "$message");
$message = str_replace ("[font=purple]", "<font color=purple>", "$message");
$message = str_replace ("[/font]", "</font ´color´>", "$message");
// bb code font size
$message = str_replace ("[size=1]", "<font size=1>", "$message");
$message = str_replace ("[size=2]", "<font size=2>", "$message");
$message = str_replace ("[size=3]", "<font size=3>", "$message");
$message = str_replace ("[size=4]", "<font size=4>", "$message");
$message = str_replace ("[size=5]", "<font size=5>", "$message");
$message = str_replace ("[size=6]", "<font size=6>", "$message");
$message = str_replace ("[/size]", "</font ´size´>", "$message");
// bb code position
$message = str_replace ("[center]", "<p align=center>", "$message");
$message = str_replace ("[left]", "<p align=left>", "$message");
$message = str_replace ("[right]", "<p align=right>", "$message");
$message = str_replace ("[/center]", "</p 'center'>", "$message");
$message = str_replace ("[/left]", "</p 'left'>", "$message");
$message = str_replace ("[/right]", "</p 'right'>", "$message");
$message = replaceUrl($message);
$message = replaceImg($message);
return $message;
}
function replaceImg($message) {
// Make image from [img]htp://.... [/img]
while(strpos($message, "[img]")!==false){
$begImg = strpos($message, "[img]");
$endImg = strpos($message, "[/img]");
$img = substr($message, $begImg, $endImg-$begImg+6);
$link = substr($img, 5, $endImg - $begImg -5);
$htmlImg = "<img src=$link border='0'>";
$message = str_replace($img, $htmlImg, $message);
// searches for other [img]-nodes
}
return $message;
}
function replaceUrl($message) {
// Make link from [url]htp://.... [/url] or [url=http://.... ]text[/url]
while(strpos($message, "[url")!==false){
$begUrl = strpos($message, "[url");
$endUrl = strpos($message, "[/url]");
$url = substr($message, $begUrl, $endUrl-$begUrl+6);
$posBracket = strpos($url, "]");
if ($posBracket != null){
if ($posBracket == 4){
// [url]http://.... [/url]
$link = substr($url, 5, $endUrl - $begUrl -5);
$htmlUrl = "<a href=$link target='_blank'>$link</A>";
} else {
// [url=http://....]text[/url]
$link = substr($url, 5, $posBracket-5);
$text = substr($url, $posBracket+1, strpos($url, "[/url]") - $posBracket-1);
$htmlUrl = "<a href=$link target='main'>$text</A>";
}
}
$message = str_replace($url, $htmlUrl, $message);
// searches for other [url]-nodes
}
return $message;
}
// html tags that are made by bb code corrasponding so <b> here = [b] below
$html = array("<U>", "</U>", "<I>", "</I>", "<B>", "</B>", "<u>", "</u>", "<i>", "</i>", "<b>", "</b>", "<BR>", "<font color=red>", "<font color=orange>", "<font color=yellow>", "<font color=green>", "<font color=blue>", "<font color=purple>", "</font ´color´>", "<p align=center>", "<p align=left>", "<p align=right>", "</p 'center'>", "</p 'left'>", "</p 'right'>", "<font size=1>", "<font size=2>", "<font size=3>", "<font size=4>", "<font size=5>", "<font size=6>", "</font ´size´>");
// bb code that are made by html tags corrasponding so <b> above = [b] here
$bbcode = array("[U]", "[/U]", "[I]", "[/I]", "[B]", "[/B]", "[u]", "[/u]", "[i]", "[/i]", "[b]", "[/b]", "\n", "[font=red]", "[font=orange]", "[font=yellow]", "[font=green]", "[font=blue]", "[font=purple]", "[/font]", "[center]", "[left]", "[right]", "[/center]", "[/left]", "[/right]", "[size=1]", "[size=2]", "[size=3]", "[size=4]", "[size=5]", "[size=6]", "[/size]");
//end of Bulleten Board code, just need to be able to revert html image and url back to bb code
// This is where the login starts for the admin area it uses header-WWW-Authenticate
function auth_user() {
header('WWW-Authenticate: Basic realm="Bands-Script Admin Login"');
header('HTTP/1.0 401 Unauthorized');
die("Unauthorized access forbidden!"); //message for a bad username and/or password. Change this if you wish to something like "OY! you b******s keep your nose out or get the right password.
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
auth_user();
} else if (!isset($_SERVER['PHP_AUTH_USER'])) {
auth_user();
} else if ($_SERVER['PHP_AUTH_USER'] != $user || $_SERVER['PHP_AUTH_PW'] != $pass) {
auth_user();
} else if (isset($_GET['action']) && $_GET['action'] == "logout") {
auth_user();
}
// This is where the login ends and the pages that are generated start it uses mainly switches.
echo "<p align=\"right\"><a href=\"?action=logout\">Log-Out</a></p>\n<center>\n";// Does a rerequest for you to Authenticate, in other words logs out, just incase you use a shared computer this is really handy.
echo "<p align=\"left\"><a href=\"?page=\">Home</a></p>";
//well this is the main part which creates the pages looks complicated, don't it! don't worry this script is written fully in php so any info you need can be found at http://www.php.net the main things to look for @ php.net is fopen, fwrite, switch, if, else & elseif they should really help you out or yeah and echo, basic html knowledge would be handy if you are wanting to develop this HTML for dummies is quite handy even if it does make you feel stupid.
switch ($page){
case bio:
include('bio.inc.php');
$geo = str_replace($html, $bbcode, $bio);
echo "Edit Your Bands Biography";
echo "<form action=\"?page=submit&submit=bio\" method=\"POST\">\n";
echo "<textarea name=\"text\" style=\"width:600px; height:200px;\" rows=\"5\" cols=\"60\">$geo";
echo "</textarea><br/>\n";
echo "<input type=\"submit\" name=\"submit\"><BR>\n";
echo "N.B. these bands-script uses BB code please <a href=\"?page=help#bbcode\">click here</a> for more info";
break;
case shows:
echo "Edit Your Bands Show/Gigs";
echo "<form action=\"?page=submit&submit=shows\" method=\"POST\"><br/>\nDate<Input type\"text\" name=\"date\" style=\"width:600px;\"><br/>\nTime<Input type\"text\" name=\"time\" style=\"width:600px;\"><br/>\nLocataion<Input type\"text\" name=\"location\" style=\"width:600px;\"><br/>\n<input type=\"submit\" name=\"submit\"><BR>\n";
echo "N.B. these bands-script uses BB code please <a href=\"?page=help#bbcode\">click here</a> for more info";
break;
//because this is a non-database script an remote forum is need
case forum:
echo "Add a URL to Remote forum like <a href=\"http://www.proboards.com\">ProBoards</a> or <a href=\"http://www.bravenet.com\">BraveNet</a> were you have\n<br/>to sign-up and they give you a forum on their site just for you. Best of all their \"FREE\"";
echo "<form action=\"?page=submit&submit=forum\" method=\"POST\"><br/>\nYour Forum Location<Input type=\"text\" name=\"forum\" value=\"http://\"";
include('forum.php');
echo "\" style=\"width:600px;\"><br/>\n<input type=\"submit\" name=\"submit\">";
break;
case lyrics:
switch ($rock){
case new1:
echo "hello new";
break;
case old:
echo "hello old";
break;
case remove:
echo "hello remove";
break;
default:
echo "Edit Your Bands Show/Gigs";
echo "<form action=\"?page=submit&submit=lyrics\" method=\"POST\"><br/>\nTitle<Input type\"text\" name=\"title\" style=\"width:600px;\"><br/>\nLyrics<textarea name=\"words\" style=\"width:600px; height:200px;\" rows=\"5\" cols=\"60\"></textarea><br/>\nMeaning<textarea name=\"meaning\" style=\"width:600px; height:200px;\" rows=\"5\" cols=\"60\"></textarea><br/>\n<input type=\"submit\" name=\"submit\"><BR>\n";
echo "N.B. these bands-script uses BB code please <a href=\"?page=help#bbcode\">click here</a> for more info";
}
break;
case links:
echo "page: case links";
break;
case pics:
echo "page: case pics";
break;
case merch:
echo "page: case merch";
break;
case home:
include('default.inc.php');
$geo = str_replace($html, $bbcode, $default);
echo "Edit Your Bands Home Page";
echo "<form action=\"?page=submit&submit=home\" method=\"POST\">\n";
echo "<textarea name=\"text\" style=\"width:600px; height:200px;\" rows=\"5\" cols=\"60\">$geo";
echo "</textarea><br/>\n";
echo "<input type=\"submit\" name=\"submit\"><BR>\n";
echo "N.B. these bands-script uses BB code please <a href=\"?page=help#bbcode\">click here</a> for more info";
break;
case help:
echo "help page";
break;
case submit:
switch ($submit){
case bio:
//this will create and change the biography file for the band.
$filename = 'bio.inc.php';
$replace = replaceMessage($text);
$somecontent = "<? \$bio = \"$replace\"; ?>";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote:<br /><p align=\"left\">$replace</p> <br />to file <b>$filename</b>";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
break;
case shows:
$fp = fopen('shows.inc.php','a');
if(!$fp) {
echo "Error writing to file";
}
$write="<br>DATE: $date<br>TIME: $time<br>WHERE: $location<br>";
fwrite($fp,$write);
fclose($fp);
echo "Your post has been made";
break;
case forum:
//this will create and change the forum forwarding page.
$filename = 'forum.inc.php';
$somecontent = "$forum";
$data = fopen("$filename","w");
fwrite($data, $somecontent);
fclose($data);
break;
case lyrics:
$random = rand(1000, 9999);
$words2 = replaceMessage($words);
$meaning2 = replaceMessage($meaning);
$fp = fopen('lyrics.inc.php','a');
if(!$fp) {
echo "Error writing to file";
}
$write="<?\n \$a$random = \"$title\";\n\$b$random = \"$words2\";\n\$c$random = \"$meaning2\";\necho \"<b>\$a$random</b><br>\$b$random\"\n ?>";
fwrite($fp,$write);
fclose($fp);
echo "Your post has been made";
break;
case home:
//this will create and change the home page.
$filename = 'default.inc.php';
$replace = replaceMessage($text);
$somecontent = "<? \$default = \"$replace\"; ?>";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote:<br /><p align=\"left\">$replace</p> <br />to file <b>$filename</b>";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
break;
default:
echo "Nothing To Submit";
}
break;
default:
echo "| <a href=\"?page=bio\">bio</a> | <a href=\"?page=shows\">shows</a> | <a href=\"?page=forum\">forum</a> | <a href=\"?page=lyrics\">lyrics</a> | <a href=\"?page=links\">links</a> | <a href=\"?page=pics\">pics</a> | <a href=\"?page=merch\">merch</a> | <a href=\"?page=home\">home</a> |";
}
echo "</center>\n</body>\n<html>";
// ain't these php tags great never used them before anyway some useful stuff that can be added to these scripts @ our forum http://bandsscript.proboards50.com
?>