Php help (scrip)

Status
Niet open voor verdere reacties.

wimpel2

Gebruiker
Lid geworden
20 mei 2007
Berichten
39
hallo,

ik zocht voor een linkensysteem, en die heb ik gevonden:D er stond dat er een admin bij was.
Maar welke link is voor admin? danku! dit is het script:

PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
	<title>Easylinks</title>
	<META NAME="Robots" CONTENT="NOINDEX,NOFOLLOW">
<style type="text/css">
<!--
a {text-decoration:none}
a:hover {text-decoration:underline}
-->
</style>
</head>

<body bgcolor="#ffffff" link="#333333" alink="#999999" vlink="#000000" text="#333300">
<table border=0 cellpadding=0 cellspacing=1 bgcolor="#000000" width="100%">
	<tr>
		<td>
			<table border=0 cellpadding=10 cellspacing=0 width=100%>
				<tr>
					<td bgcolor="#cccc99">
				<font color="#000000">
							<pre>
Runescape ClanDatabase
							</pre>	
						</font>
<font face="verdana,arial" size=2>
<?


// General display variables
# File that contains the data
$filelocation="boomarks.txt";  
# Name of this document here
$boardname="easylinks.php"; 
# Password for the admin section
$pass="secret";
# The message to display when someone entered data $name is the name then
$thanksmessage="<br><br><b>Thank you for your entry!</b><br>";
# The message to display, if there is an error 
$errormessage="<br><br><b>Oops! You seem to have forgotten either the name, the url or the message!</b><br>";
# Replace special characters with their html equivalents like > to &gt; (0/1)
$specialchars=1;
# Convert Ascii linebreaks to html linebreaks <br> (0/1)
$linebreaks=1;
# Entrytext, displayed above the links
$entrytext = '';
# Rules, displayed when you enter some text...
$rules = 'Enter your link data here, please make sure to check the links before entering.';
# display (1) or hide (0) the dropdowns/textlinks above and below the links (navigation)
$dropdown_up=1;
$dropdown_down=0;
$textlinks_up=0;
$textlinks_down=1;
# Text to be displayed when a category has no data yet.
$no_link_yet="Sorry, there is no link yet";


// Display templates, the data in %% will be replaced by the real content.
// do not use ' !!! 
# detailed link display
# possible variables are %url% %name% and %message%
$detail_display='
		<b><a href="%url%" target="_blank">%name%</a></b><br>%message%<br><br>
		';
# compact link display
# possible variables are %url% and %name% 
$compact_display='
		<b><a href="%url%" target="_blank">%name%</a></b><br>
		';
# category header
# possible variables are %category%
$cat_display='
		<table width=100% border=0 cellspacing=0 cellpadding=1>
			<tr>
				<td bgcolor="#000000">
					<table width=100% border=0 cellspacing=0 cellpadding=1>
						<tr>
							<td bgcolor="#999966">
								<font face="verdana,arial" size=2 color="#ffff99">
									&nbsp;<b>%category%</b>
								</font>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		';
# text links template
# possible variables are %links%
$text_links_display = '
		<div align="center">
			<table width=50% border=0 cellpadding=1 cellspacing=0 bgcolor="#000000">
				<tr>
					<td>
						<table width=100% border=0 cellspacing=0 cellpadding=5>
							<tr>
								<td bgcolor="#ffff99" align="center">
									<font face="verdana,arial" size=2>
										%links%
									</font>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
		';
# dropdown template
# possible variables are %dropdown%
$dropdown_display = '
		<table width=50% border=0 cellpadding=1 cellspacing=0 bgcolor="#000000" align="center">
			<tr>
				<td>
					<table width=100% border=0 cellspacing=0 cellpadding=5>
						<tr>
							<td bgcolor="#ffff99" align="center">
								<font face="verdana,arial" size=2 color="#000000">
									%dropdown%
								</font>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		';

# Add link template, please ensure to use both %% expressions, otherwise the link
# will not be closed!!! 
# possible variables are %addlinkstart% and %addlinkend%</
$addlink_display = '
		<div align="center">
			<table width=20% border=0 cellpadding=1 cellspacing=0 bgcolor="#000000">
				<tr>
					<td>
						<table width=100% border=0 cellspacing=0 cellpadding=1>
							<tr>
								<td bgcolor="#ffff99" align="center">
									<font face="verdana,arial" size=2>
										%addlinkstart%
											Add your link
										%addlinkend%
									</font>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
		<br>
		';
				
// The categories, split them with a, do not use spaces after the comma				
$categories = "Clans,Hulpsites";				
$categories = split(",",$categories);
sort($categories);

if (!$pw || $pw != $pass){ // no admin
/*-----------------------------------------------------------------------------------------------
					Introduction Screen when there is no data from the form
------------------------------------------------------------------------------------------------*/
	if ($action != "view" && $action !="new" && $edit !="yes"){echo $entrytext;$action="view";$compact="yes";}
	if ($dropdown_up==1){ // display upper dropdown
		$dropdownchunks=split("%dropdown%",$dropdown_display);	
		echo "<form method=post>".$dropdownchunks[0];
		echo "Kies catogorie: 
				<select name=\"cat\"><option value=\"all\">Alles</option>";
				for ($i=0;$i<sizeof($categories);$i++):
					echo "<option value=\"$categories[$i]\"";
					if ($categories[$i] == $cat){echo "selected";}
					echo">$categories[$i]</option>";
				endfor;
				echo "</select><input type=\"hidden\" value=\"view\" name=\"action\">&nbsp;<input type=\"checkbox\" name=\"compact\" value=\"yes\"";
				if ($compact=="yes") echo "checked";
				echo">&nbsp;Verberg details&nbsp;<input type=\"submit\" value=\"Laat zien\">".$dropdownchunks[1]."</form>";
		}

	if ($textlinks_up==1){ // diplay upper textlinks
		$textchunks=split("%links%",$text_links_display);	
		echo $textchunks[0];
		for ($x=0;$x<sizeof($categories);$x++):
			if ($categories[$x] != $cat){echo "<a href=\"$boardname?action=view&compact=$compact&cat=$categories[$x]\">$categories[$x]</a>&nbsp;&nbsp;";}
			else {echo "<b>$categories[$x]</b>&nbsp;&nbsp;";}
		endfor;
		echo "<br>";
		if ($cat != "all"){echo "<a href=\"$boardname?action=view&compact=$compact&cat=all\">all</a>";}
		else echo "<b>all</b>";
		if ($compact=="yes"){$viewdisp="<a href=\"$boardname?action=view&cat=$cat\">show</a>&nbsp;<b>hide</b></a> details.";}
 		if ($compact!="yes"){$viewdisp="<b>show</b>&nbsp;<a href=\"$boardname?action=view&compact=yes&cat=$cat\">hide</a> details.";}
		echo "&nbsp;&nbsp;&nbsp;(".$viewdisp.")".$textchunks[1];
		}

/*-----------------------------------------------------------------------------------------------
                 					   Display the links
------------------------------------------------------------------------------------------------*/
	if ($action=="view"){
		// if there is no category, display all...
		if ($cat == "") $cat="all";
		echo $entrytext;
		$lines=get_data($filelocation); // reads datafile
		if ($cat == "all"){
		// loop over all categories
		for ($x=0;$x<sizeof($categories);$x++):
			// take template and put data in
			$cat_display_now = $cat_display;
			$cat_display_now=eregi_replace("%category%",$categories[$x],$cat_display_now);
			echo stripslashes($cat_display_now);
			$f=0;
			$found=0; // trigger for no link found
			while($f < sizeof($lines)){
				$user = explode("#",$lines[$f]);
				if ($user[2] == $categories[$x]){
					$found=1; // there is a link here 
					// if there is no http, add it
					if (substr($user[3],0,7)!= "http://"){$user[3]="http://".$user[3];}
					if ($compact != "yes"){// display with details
						// take template and put data in
						$detail_display_now = $detail_display;
						$detail_display_now=eregi_replace("%url%",$user[3],$detail_display_now);
						$detail_display_now=eregi_replace("%name%",$user[1],$detail_display_now);
						$detail_display_now=eregi_replace("%message%",$user[4],$detail_display_now);
						echo stripslashes($detail_display_now);
						}
					else { // display without details
						// take template and put data in
						$compact_display_now = $compact_display;
						$compact_display_now=eregi_replace("%url%",$user[3],$compact_display_now);
						$compact_display_now=eregi_replace("%name%",$user[1],$compact_display_now);
						echo stripslashes($compact_display_now);
						}
				}	
			$f++;
			}
			// no link in category, display message
			if ($found==0)echo $no_link_yet;
		endfor;
		}
		
		// display category
		else {
			// put data in template
			$cat_display_now = $cat_display;
			$cat_display_now=eregi_replace("%category%",$cat,$cat_display_now);
			echo stripslashes($cat_display_now);
			$f=0;
			$found=0; // trigger if there is a link
			while($f < sizeof($lines)){
				$user = explode("#",$lines[$f]);
				if ($user[2] == $cat){
					$found=1;// link found!
					// if there is no http, add it
					if (substr($user[3],0,7)!= "http://"){$user[3]="http://".$user[3];}
					if ($compact != "yes"){ // display with details
						// take template and put data in
						$detail_display_now = $detail_display;
						$detail_display_now=eregi_replace("%url%",$user[3],$detail_display_now);
						$detail_display_now=eregi_replace("%name%",$user[1],$detail_display_now);
						$detail_display_now=eregi_replace("%message%",$user[4],$detail_display_now);
						echo stripslashes($detail_display_now);
						}
					else { // display without details
						// take template and put data in
						$compact_display_now = $compact_display;
						$compact_display_now=eregi_replace("%url%",$user[3],$compact_display_now);
						$compact_display_now=eregi_replace("%name%",$user[1],$compact_display_now);
						echo stripslashes($compact_display_now);
						}
			}
			$f++;
		}
		// if there is no link in this category, say so
		if ($found==0)echo $no_link_yet;
		}
		
		// Display add link template	
		$addlink_display=eregi_replace("%addlinkstart%","<a href=\"$boardname?action=new&cat=$cat\">",$addlink_display);
		$addlink_display=eregi_replace("%addlinkend%","</a>",$addlink_display);
		echo $addlink_display;
	}
	
/*-----------------------------------------------------------------------------------------------
					Adding a new entry to the data file
------------------------------------------------------------------------------------------------*/
	if ($edit == "yes"){
		// When there is missing data, display the errormessage and reprint the form
		if ($name == "" || $message =="" || $url==""){
			echo $errormessage."\n";
			echo "
			<form method=post>
			<dl>
			<dt>Name:</dt>
			<dd><input type=\"text\" name=\"name\" value=\"$name\" size=30></dd>
			<dt>Category:</dt>
			<dd><select name=\"category\">";
			// loop over possible categories
			for ($i=0;$i<sizeof($categories);$i++){
			echo "<option value=\"$categories[$i]\"";
			if ($categories[$i] == $category){echo "selected";}
			echo">$categories[$i]</option>";
			}
			echo"
			</select></dd>
			<dt>url:</dt>
			<dd><input type=\"text\" name=\"url\" value=\"$url\" size=30></dd>
			<dt>Message:</dt>
			<dd><textarea name=\"message\" cols=30 rows=5>".$message."</textarea></dd>
			</dl>
			<div align=\"center\">
			<input type=\"hidden\" name=\"edit\" value=\"yes\">
			<input type=\"submit\" value=\"Add your link!\" border=0>
			</div>
			</form>
			";
		}
		// If all the entries are correct, display thanksmessage add to datafile
		else {
			echo $thanksmessage."\n";
			// Change % and # to percent and no, to avoid wrong splitting of the data.
			$message = eregi_replace("#","no.",$message);
			$message = eregi_replace("%","percent",$message);
			$name = eregi_replace("#","no.",$name);
			$name = eregi_replace("%","percent",$name);
			// When specialchars are to be replaced...
			if ($specialchars==1){$message=htmlentities($message);}
			// When ASCII Linebreaks should become <br>s
			if ($linebreaks==1){$message = nl2br($message);}
			$lines=get_data($filelocation);
			$counter = sizeof($lines);
			$newfile = fopen($filelocation,"a+");
			$add = "%".$counter."#".$name."#".$category."#".$url."#".$message."\n";
			fwrite($newfile, $add);
			fclose($newfile);
		}
	}
/*-----------------------------------------------------------------------------------------------
                 Add a new entry to the links, display the rules and show the form.
------------------------------------------------------------------------------------------------*/
	if ($action == "new" && $edit != "yes"){
		echo "$rules<br>\n
		<form method=post>
		<dl>
		<dt>Name:</dt>
		<dd><input type=\"text\" name=\"name\" size=30></dd>
		<dt>Category:</dt>
			<dd><select name=\"category\">";
			// loop over categories
			for ($i=0;$i<sizeof($categories);$i++){
			echo "<option value=\"$categories[$i]\"";
			if ($cat == $categories[$i]) echo "selected";
			echo">$categories[$i]</option>";;
			}
			echo"
			</select></dd>
		<dt>url:</dt>
		<dd><input type=\"text\" name=\"url\" size=30></dd>
		<dt>Message:</dt>
		<dd><textarea name=\"message\" cols=30 rows=5></textarea></dd>
		</dl>
		<div align=\"center\">
		<input type=\"hidden\" name=\"edit\" value=\"yes\">
		<input type=\"submit\" value=\"Add your link!\" border=0>
		</div>
		</form>
		";
		}
		
}

/*-----------------------------------------------------------------------------------------------	
									Admin Section!
------------------------------------------------------------------------------------------------*/
if ($pw == $pass){
// Display entries with delete / edit buttons
	if (!$del && !$edit & !$add){
		echo $entrytext;
		// load data from file 
		$lines=get_data($filelocation);
		// Display all the entries
		for ($f=1;$f<sizeof($lines);$f++):
			$user = explode("#",$lines[$f]);
			if (substr($user[3],0,7)!= "http://"){$user[3]="http://".$user[3];}
			// get display template, display it with data 
			$detail_display_now = $detail_display;
			$detail_display_now=eregi_replace("%url%",$user[3],$detail_display_now);
			$detail_display_now=eregi_replace("%name%",$user[1],$detail_display_now);
			$detail_display_now=eregi_replace("%message%",$user[4],$detail_display_now);
			echo stripslashes($detail_display_now);
			echo '<table border=0><tr><td><form method=post><input type="hidden" name="pw" value="'.$pw.'"><input type="hidden" name="del" value="'.$user[0].'"><input type="submit" value="delete"></form></td><td><form method=post><input type="hidden" name="pw" value="'.$pw.'"><input type="hidden" name="edit" value="'.$user[0].'"><input type="submit" value="edit"></form></td></tr></table>';
		endfor;
	}

// edit entry 
if ($edit){
	// read data
	$lines=get_data($filelocation);
	// loop over entries
	while(list($key)= each ($lines)){
			// when the entry is the one to be edited, split in and display the form with the data
			if ($key == $edit){$user = explode("#",$lines[$key]);}
		}
		echo "
			<form method=post>
			<dl>
			<dt>Handle:</dt>
			<dd><input type=\"text\" name=\"name\" value=\"".$user[1]."\" size=30></dd>
			<dt>category:</dt>
			<dd><select name=\"category\">";
			// loop over categories, highlight selected
			for ($i=0;$i<sizeof($categories);$i++){
			echo "<option value=\"$categories[$i]\"";
			if ($categories[$i] == $user[2]){echo "selected";}
			echo">$categories[$i]</option>";
			}
			echo"
			</select></dd>
			<dt>url:</dt>
			<dd><input type=\"text\" name=\"url\" value=\"".$user[3]."\" size=30></dd>
			<dt>Message:</dt>
			<dd><textarea name=\"message\" cols=30 rows=5>".$user[4]."</textarea></dd>
			</dl>
			<div align=\"center\">
			<input type=\"hidden\" name=\"add\" value=\"".$user[0]."\"><input type=\"hidden\" name=\"pw\" value=\"$pw\">
			<input type=\"submit\" value=\"save changes\" border=0>
			</div>
			</form>
		";
}

// Add the changed data to the datafile
if ($add){
	// exchange invalid characters
	$message = eregi_replace("#","no.",$message);
	$message = eregi_replace("%","percent",$message);
	$name = eregi_replace("#","no.",$name);
	$name = eregi_replace("%","percent",$name);
	$newdatas="";
	$lines=get_data($filelocation);
	// loop over entries
	while(list($key)= each ($lines)){
		// when the entry is not the one to be changed...
		if ($key != $add){
			// when it's not the first entry, don't add a % (prevents blank entry)
			if ($key != 0){$newdatas .= "%";}
			// else simply put in the old data
			$newdatas .= $lines[$key];
			}
		// if the entry is the one that was changed, insert the new data
		else {$newdatas .= "%".$add."#".$name."#".$category."#".$url."#".$message;}
		}
		// overwrite the old data file...
		$newfile = fopen($filelocation,"w+");
		fwrite($newfile, $newdatas);
		fclose($newfile);
		// display linkbutton back
		echo "<div align=\"center\">The data of entry ".$name." has been changed!<form method=post><input type=\"hidden\" name=\"pw\" value=\"$pw\"><input type=hidden name=action value=view><input type=submit value=\"see changes\"></form></div>";
}	
		
// Delete entry 
	if ($del){
		// reset datavariable
		$newdatas="";
		// read in old data
		$lines=get_data($filelocation);
		// reset new entry counter
		$count=0;
		// loop over entries
		while(list($key)= each ($lines)){
			// when the entry is not the one to be deleted...
			if ($key != $del){
			// when it's not the first entry, don't add a % (prevents blank entry)
			if ($key != 0){$newdatas .= "%";}
			// divide into data chunks
			$user = explode("#",$lines[$key]);
			// add new counter and add the data
			if ($key != 0){$newdatas .= $count."#".$user[1]."#".$user[2]."#".$user[3]."#".$user[4];}
			// increase counter
			$count++;
			}
			}
			// replace old data file
			$newfile = fopen($filelocation,"w+");
			fwrite($newfile, $newdatas);
			fclose($newfile);
			echo "<div align=\"center\">The entry has been deleted<form method=post><input type=hidden name=action value=view><input type=\"hidden\" name=\"pw\" value=\"$pw\"><input type=submit value=\"see changes\"></form></div>";
		}
		

}

// Display dropdown and links below
if ($dropdown_down==1){
	// get template, add data in it
	$dropdownchunks=split("%dropdown%",$dropdown_display);	
	echo "<form method=post>".$dropdownchunks[0];
	echo "Choose category: 
			<select name=\"cat\"><option value=\"all\">Display all</option>";
			for ($i=0;$i<sizeof($categories);$i++):
				echo "<option value=\"$categories[$i]\"";
				if ($categories[$i] == $cat){echo "selected";}
				echo">$categories[$i]</option>";
			endfor;
			echo "</select><input type=\"hidden\" value=\"view\" name=\"action\">&nbsp;<input type=\"checkbox\" name=\"compact\" value=\"yes\"";
			if ($compact=="yes")echo "checked";
			echo">&nbsp;hide details&nbsp;<input type=\"submit\" value=\"show\">".$dropdownchunks[1]."</form>";
	}
	if ($textlinks_down==1){

	
$textchunks=split("%links%",$text_links_display);	
echo $textchunks[0];
		for ($x=0;$x<sizeof($categories);$x++):
			if ($categories[$x] != $cat){echo "<a href=\"$boardname?action=view&compact=$compact&cat=$categories[$x]\">$categories[$x]</a>&nbsp;&nbsp;";}
			else {echo "<b>$categories[$x]</b>&nbsp;&nbsp;";}
		endfor;
		echo "<br>";
		if ($cat != "all"){echo "<a href=\"$boardname?action=view&compact=$compact&cat=all\">all</a>";}
		else echo "<b>all</b>";
		if ($compact=="yes"){$viewdisp="<a href=\"$boardname?action=view&cat=$cat\">show</a>&nbsp;<b>hide</b></a> details.";}
 		if ($compact!="yes"){$viewdisp="<b>show</b>&nbsp;<a href=\"$boardname?action=view&compact=yes&cat=$cat\">hide</a> details.";}
		echo "&nbsp;&nbsp;&nbsp;(".$viewdisp.")".$textchunks[1];
	}

// Function for reading and preparing the data...
function get_data($filelocation){
// check for the datafile, if it isn't there create blank one
if (!file_exists($filelocation)) {
	$newfile = fopen($filelocation,"w+");
	fclose($newfile);
	}
$newfile = fopen($filelocation,"r");
$content = fread($newfile, filesize($filelocation));
fclose($newfile);
$lines = explode("%",$content);
return $lines;
}
echo"<br><div align=\"right\"><font face=\"verdana,arial,helvetica\" size=2>Created with <a href=\"http://www.onlinetools.org/easylinks/\" target=\"_blank\">EasyLinks</a> 1.0, get it for free.</font></div>";

?>
						</font>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table><br><br>
<div align="center">
	<font face="verdana" size="-2">
		This is a link for all page, there is no quality control of the submitted data, and the owner of this server does not take responsibility for the displayed links.
	</font>
</div>
</body>
</html>
 
Zit er geen readme bestand bij? Kijk anders op de site waar je hem vandaan hebt (Of vermeld deze hier)
 
Waar heb je hem vandaan dan?
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan