Просмотр файла download.php

Размер файла: 5.52Kb
<?
############################################
# + xDLs [x-devDownloads] v 1.0		  	   #
# + by Robert Klikics			  	       #
# + visit: http://x-dev.de for more stuff  #
# + License: GPL  			  			   #
# + You may not remove the Copyrights	   #
############################################
# + Filename: download.php [main]	       #
############################################

include("func.inc.php");

// settings
$dbfile = "data.txt"; 			  // datei zum speichern der daten [absoluter Pfad]
$adminpass = "test"; 			 // admin-passwort
$scripturl = "$PHP_SELF"; 		// pfad zum script [kann so belassen werden]
// end settings

// ab hier nichts mehr дndern!!!!

if($act == "admin"):
?>
<html>
<head>
<title>xDLs</title>
<style type='text/css'>
 BODY,TD			{font: 10px Verdana; color:#000000;}
 BODY     			{scrollbar-face-color: #ffffff; scrollbar-shadow-color: #000000; scrollbar-highlight-color: #ffffff; scrollbar-3dlight-color: #000000; scrollbar-darkshadow-color: #ffffff; scrollbar-track-color: #ffffff;scrollbar-arrow-color: #000000}
 A:link   			{text-decoration: none; color: #000099}
 A:visited 			{text-decoration: none; color: #000099}
 A:active 			{color: #000099}
 A:hover  			{text-decoration: underline; color: #000099}
 TEXTAREA 			{ 
					FONT-FAMILY: verdana,arial;font-size:11px; color:#000000; 
           	    		background-color:#FFFFFF;
     		    		border:1; border-color:#000000; border-style:solid;
         			}
 INPUT    			{
 				background-color:#FFFFFF;
	   		 	font:verdana; color:#000000; font-size:10px;
	   			border:1; border-color:#000000; border-style:solid;
	   			}
</style>
</head>
<body>
<?
if($password != $adminpass):
echo "<p><form action=\"$scripturl\" method=\"get\"\n>";
echo "Passwort:<br><input type='password' name='password'>\n";
echo "<input type='hidden' name='act' value='admin'>";
echo "<input type='hidden' name='send' value='ok'>\n";
echo "<input type='submit' value='Login'>\n";
echo "\n</body></html>";
if($send == "ok" && $password != $adminpass) { echo "<p>Das Passwort <b>$password</b> ist falsch ..."; }
exit;
elseif($newid != ""):
$datei = fopen($dbfile, "a");
fputs($datei, $newid . "|" . $newurl . "|" . $startcount . "\n");
fclose($datei);
echo "<p>Eintrag erfolgreich<br><a href=\"$scripturl?act=admin&password=$password\">Zurьck zum Index</a></p></center></body></html>";
exit;
elseif($editid != ""):
if($editurl != ""):
$datei = fopen($dbfile, "r");
while($zeile = fgetcsv($datei, 1000, "|")):
if($zeile[0] == "$editid"):
$erg[] = "$editid|$editurl|$editcount\n";
else:
$erg[] = "$zeile[0]|$zeile[1]|$zeile[2]\n";
endif;
endwhile;
fclose($datei);
$datei = fopen($dbfile, "w");
$count = 0;
while($erg[$count] != ""):
fputs($datei, $erg[$count]);
$count++;
endwhile;
fclose($datei);
echo "<p>Eintrag erfolgreich editiert<br><a href=$scripturl?act=admin&password=$password>Zurьck zum Admin-Index</a></p></center></body></html>";
exit;
else:
$datei = fopen($dbfile, "r");
while($erg=fgetcsv($datei, 1000, "|")):
if($erg[0] == $editid):
echo "<p><form action=$scripturl?act=admin method=post>\n";
echo "<input type='hidden' name='password' value='$password'>\n";
echo "ID: <b>$erg[0]</b><br><input type=hidden name=editid value=\"$editid\"><br>\n";
echo "URL: <br><input type=text name=editurl value=\"$erg[1]\"><br>\n";
echo "Anzahl DLs: <br><input type=text name=editcount value=\"$erg[2]\"><br>\n";
echo "<input type=submit name=submit value=Дnderungen speichern>\n</p></center></body></html>";
break;
else:
continue;
endif;
endwhile;
endif;
exit;
elseif($delid != ""):
$datei = fopen($dbfile, "r");
while($zeile = fgetcsv($datei, 1000, "|")):
if($zeile[0] == $delid):
continue;
else:
$erg[] = "$zeile[0]|$zeile[1]|$zeile[2]";
endif;
endwhile;
fclose($datei);
$datei = fopen($dbfile, "w");
$count = 0;
while($erg[$count] != ""):
fputs($datei, "$erg[$count]\n");
$count++;
endwhile;
fclose($datei);
echo "<p>Gelцscht!<br><a href=$scripturl?act=admin&password=$password>Zurьck zum Admin-Andex</a>";
exit;
else:
$datei = fopen($dbfile, "r");
echo "<p><table border=1 width=90%>\n";
echo "<tr><td width=25%><b>ID</b></td><td width=50%><b>URL</b></td><td width=8%><b>DLs</b></td><td width=*%><b>Action</b></td></tr>\n";
while($erg = fgetcsv($datei, 1000, "|")):
echo "<td width=25%>$erg[0]</td><td width=50%>$erg[1]</td><td width=8%>$erg[2]</td><td width=*><a href=$scripturl?act=admin&password=$password&editid=$erg[0]>Edit</a>|<a href=$scripturl?act=admin&password=$password&delid=$erg[0]>Delete</a></td></tr>\n";
endwhile;
echo "</table>";
echo "<form action=$scripturl?act=admin method=post>\n";
echo "<input type='hidden' name='password' value='$password'>\n";
echo "<b>Add New DL:</b><br>";
echo "ID:<br><input type=text name=newid><br>\n";
echo "URL:<br><input type=text name=newurl value=\"http://\"><br>\n";
echo "Anzahl DLs:<br><input type=text name=startcount value=0><br>\n";
echo "<input type=submit name=submit value=Speichern>\n";
echo "</center></body></html>";
exit;
endif;
endif;

$datei = fopen($dbfile, "r");
while($zeile = fgetcsv($datei, 1000, "|")):
if($zeile[0] == $id):
$togo = $zeile[1];
$zahl = $zeile[2];
$zahl++;
else:
$erg[] = "$zeile[0]|$zeile[1]|$zeile[2]\n";
endif;
endwhile;
fclose($datei);

$datei = fopen($dbfile, "w");
fputs($datei, "$id|$togo|$zahl\n");
$count = 0;
while($erg[$count] != ""):
fputs($datei, $erg[$count]);
$count++;
endwhile;
fclose($datei);

//refresh:
if($go == "browser"):
echo "<p align='center'>\n";
echo "<font size='1' face='verdana,arial'>\n";
echo "Download wird in wenigen Sekunden gestartet ... [ <a href='$togo'>url</a> ]";
echo "<meta http-equiv=\"refresh\" content=\"2; URL=$togo\">";
exit;
endif;
header("Location: $togo");
?>