Location: PHPKode > projects > PhpEselGui - a PHP mldonkey gui > phpEselGui/index.php
<?php
require("page_header.inc");
$finished="true"; # testing
buildNav($isActive);

if (!$HTTP_POST_VARS && !$HTTP_GET_VARS) {

	echo "<center>\n";
	if (file_exists("themes/$conf->theme/phpE_logo.gif")) { echo "<br><img src=\"themes/$conf->theme/phpE_logo.gif\"></img><br>\n"; }
	echo $loc->welcomeText, "\n";
	echo "</center>\n";
}

if ($HTTP_POST_VARS['start'] || $HTTP_GET_VARS['start']) {
	writeTitle("$loc->startDonkey");
	flush();
	sleep(3);
	if(!isActive($conf->host, $conf->port)) {
		if ($conf->DEBUG) writeLog ("Starting donkey");
		exec($conf->startup);
		echo "$loc->startWaiting";
		flush();
		while (!isActive($conf->host, $conf->port)) {
			echo ".";
			flush();
			sleep(1);
		}
		if ($DEBUG) writeLog ("Start was successful");
		echo "$loc->startFinished";
	}
	$isActive=isActive($conf->host, $conf->port);
}

if ($isActive) {
	if (($HTTP_POST_VARS['kill'] || $HTTP_GET_VARS['kill']) && !$HTTP_POST_VARS['sure']=="$loc->yes") {
		writeTitle($loc->sure);
		echo "<center>\n";
		echo "<form action=\"$PHP_SELF?kill=TRUE\" method=\"post\">\n";
		echo "  <input type=\"submit\" class=\"normalButton\" name=\"sure\" value=\"$loc->yes\"></input>\n";
		echo "  <input type=\"submit\" class=\"normalButton\" name=\"egal\" value=\"$loc->no\"></input>\n";
		echo "</form>\n";
		echo "</center>\n";
	}

	if (($HTTP_POST_VARS['kill'] || $HTTP_GET_VARS['kill']) && $HTTP_POST_VARS['sure']=="$loc->yes") {
		if ($conf->DEBUG) writeLog ("Stopping donkey");
		killDonkey($conf->host, $conf->port);
		if ($conf->DEBUG) writeLog ("Donkey has been stopped");
		$isActive=FALSE;
	}

	if (($HTTP_POST_VARS['vd'] || $HTTP_GET_VARS['vd']) && $HTTP_GET_VARS['vd'] != "details" && !$HTTP_POST_VARS['nr']) {
	//if (($HTTP_POST_VARS['vd']) && !$HTTP_POST_VARS['nr']) {
		$finished=array();
		$erfolg="LEER";
		while ($erfolg == "LEER") {
			$erfolg = showDownloads($conf->host, $conf->port);
		}
	}

	/*if (($HTTP_POST_VARS['vd'] || $HTTP_GET_VARS['vd']) && $HTTP_POST_VARS['nr']) {
		if ($conf->DEBUG) writeLog ("Got vd (".$HTTP_POST_VARS['vd'].") and nr (".$HTTP_POST_VARS['nr'].")");
		writeTitle("$loc->viewDetails");
		viewDetails($conf->host, $conf->port, $HTTP_POST_VARS['nr']);
	}*/

	if ($HTTP_GET_VARS['vd'] == "details" && $HTTP_GET_VARS['nr']) {
		if ($conf->DEBUG) writeLog ("Got vd (".$HTTP_GET_VARS['vd'].") and nr (".$HTTP_GET_VARS['nr'].")");
		writeTitle("$loc->viewDetails");
		viewDetails($conf->host, $conf->port, $HTTP_GET_VARS['nr']);
	}

	if (($HTTP_POST_VARS['upstats'] || $HTTP_GET_VARS['upstats'])) {
		showUploads($conf->host, $conf->port);
	}

	if(($HTTP_POST_VARS['pause'] || $HTTP_GET_VARS['pause']) && $HTTP_POST_VARS['nr']) {
		writeTitle("$loc->pause $loc->nr ".$HTTP_POST_VARS['nr']);
		$returnCode = array();
		$returnCode = askDonkey("pause ".$HTTP_POST_VARS['nr'], $conf->host, $conf->port);
		writeOutput($returnCode);
	}

	if(($HTTP_POST_VARS['resume'] || $HTTP_GET_VARS['resume']) && $HTTP_POST_VARS['nr']) {
		writeTitle("$loc->resume $loc->nr ".$HTTP_POST_VARS['nr']);
		$returnCode = array();
		$returnCode = askDonkey("resume ".$HTTP_POST_VARS['nr'], $conf->host, $conf->port);
		writeOutput($returnCode);
	}

	if(($HTTP_POST_VARS['cancel'] || $HTTP_GET_VARS['cancel']) && $HTTP_POST_VARS['nr']) {
		writeTitle("$loc->stop $loc->nr ".$HTTP_POST_VARS['nr']);
		$returnCode = array();
		$returnCode = askDonkey("cancel ".$HTTP_POST_VARS['nr'], $conf->host, $conf->port);
		writeOutput($returnCode);
	}

	if($HTTP_POST_VARS['edLink'] || $HTTP_GET_VARS['edLink'] || (($HTTP_POST_VARS['dllink'] || $HTTP_GET_VARS['dllink']) && $HTTP_POST_VARS['link'])) {
		writeTitle("$loc->askForLink");
		$returnCode = askDonkey("vd", $conf->host, $conf->port);
		foreach($returnCode as $key=>$value) {
			if (preg_match("/^Downloaded\s{1}\d*\/(\d*)/", $value)) {
				preg_match("/^Downloaded\s{1}\d*\/(\d*)/", $value, $downloads);
				break;
			}
		}
		if ($conf->maxNumDownloads > $downloads[1]) {
			echo "<table class=\"output\">\n";
			echo "  <tr>\n";
			echo "    <td align=\"center\">\n";
			echo "      <form method=\"post\" action=\"$PHP_SELF\">\n";
			echo "        <input name=\"link\" class=\"normalTextField\" size=\"100\"></input>\n<br />\n";
			echo "        <input type=\"submit\" class=\"normalButton\" name=\"dllink\" value=\"$loc->download\" alt=\"$loc->download\" title=\"$loc->download\"></input>\n";
			echo "      </form>\n";
			echo "    </td>\n";
			echo "  </tr>\n";
			echo "</table>\n";
		} else {
			writeTitle($loc->sorry($conf->maxNumDownloads, $downloads[1]));
		}
	}

	if($HTTP_POST_VARS['commandForm'] || $HTTP_GET_VARS['commandForm'] || (($HTTP_POST_VARS['commandExecute'] || $HTTP_GET_VARS['commandExecute']) &&
	$HTTP_POST_VARS['commandToExecute']))
	{
		writeTitle("$loc->askForCommand");

		echo "<table class=\"output\">\n";
		echo "  <tr>\n";
		echo "    <td align=\"center\">\n";
		echo "      <form method=\"post\" action=\"$PHP_SELF\">\n";
		echo "        <input name=\"commandToExecute\" class=\"normalTextField\" size=\"60\"></input>\n<br />\n";
		echo "        <input type=\"submit\" name=\"commandExecute\" class=\"normalButton\" value=\"$loc->commandSend\" alt=\"$loc->commandSend\" title=\"$loc->commandSend\"></input>\n";
		echo "      </form>\n";
		echo "    </td>\n";
		echo "  </tr>\n";
		echo "</table>\n";
	}
	if(($HTTP_POST_VARS['commandExecute'] || $HTTP_GET_VARS['commandExecute']) && $HTTP_POST_VARS['commandToExecute']) {
		writeTitle("$loc->commandWillBeExecuted ".$HTTP_POST_VARS['commandToExecute']);
		$returnCode = array();
		$returnCode = askDonkey($HTTP_POST_VARS['commandToExecute'], $conf->host, $conf->port);
		writeOutput($returnCode);
	}

	if(($HTTP_POST_VARS['dllink'] || $HTTP_GET_VARS['dllink']) && $HTTP_POST_VARS['link']) {
		// let's change the seperator, if it has been pasted wrong (e.g. Apple Safari
		$HTTP_POST_VARS['link'] = preg_replace("/\%7C/", "|", $HTTP_POST_VARS['link']);
		writeTitle("$loc->startDown ".$HTTP_POST_VARS['link']);
		$returnCode = array();
		$returnCode = askDonkey("dllink ".$HTTP_POST_VARS['link'], $conf->host, $conf->port);
		writeOutput($returnCode);
	}

	if($HTTP_POST_VARS['commit'] || $HTTP_GET_VARS['commit']) {
		writeTitle("$loc->commit");
		if ($conf->DEBUG) writeLog ("Found commit");
		$returnCode = array();
		$returnCode = askDonkey("commit", $conf->host, $conf->port);
		writeOutput($returnCode);
		if ($conf->DEBUG) writeLog ("commit finished");
	}
}

if ($_GET['x'] || $_POST['x']){
	$x = $_GET['nr'];
	if ("_$x" == "_") $x = $_POST['nr'];
	writeTitle($loc->xingServer($x));
	$returnCode = array();
	$returnCode = askDonkey("x ".$x, $conf->host, $conf->port);
	writeOutput($returnCode);
}
if ($_GET['c'] || $_POST['c']){
	$c = $_GET['nr'];
	if ("_$c" == "_") $c = $_POST['nr'];
	if ("_$c" != "_") $c = " $c";
	writeTitle($loc->cingServer($c));
	$returnCode = array();
	$returnCode = askDonkey("c".$c, $conf->host, $conf->port);
	writeOutput($returnCode);
}

if ($_GET['bs'] || $_POST['bs']){
	$bs = $_GET['nr'];
	if ("_$bs" == "_") $bs = $_POST['nr'];
	writeTitle($loc->bsingServer($bs));
	$returnCode = array();
	$returnCode = askDonkey("bs ".$bs, $conf->host, $conf->port);
	writeOutput($returnCode);
}

if (($HTTP_POST_VARS['vm'] || $HTTP_GET_VARS['vm'])){
	writeTitle ("$loc->server_conn");
	viewServer($conf->host, $conf->port, "vm");
}
if (($HTTP_POST_VARS['vma'] || $HTTP_GET_VARS['vma'])){
	writeTitle ("$loc->server_all");
	viewServer($conf->host, $conf->port, "vma");
}




buildNav($isActive);

require("page_bottom.inc");
?>
Return current item: PhpEselGui - a PHP mldonkey gui