<?php
require_once 'class.linktest.php';
$format = 'MB';
$textarea = '';
$KBSelected = '';
$MBSelected = 'selected';
$GBSelected = '';
$round = 2;
$trueSelected = 'selected';
$falseSelected = '';
if (isset($_POST['submit'])) {
$linktest = new linktest();
$textarea = '';
$format = $_POST['format'];
$round = $_POST['round'];
if ($_POST['supported'] == 1) {
$supported = true;
} else {
$supported = false;
}
$links = explode("\n", $_POST['links']);
foreach ($links as $value) {
if (rtrim($value) !== '') {
$result = $linktest->test($value, $format, $supported);
if (!$result[0]) {
$message = $result[2];
} else {
$textarea = "$textarea$value\n";
$message = $result[0];
if (rtrim($round) !== '') {
$message = round($message, $round);
}
$message = "$message $format";
}
$results[] = "<p><a href=\"$value\">$value</a><br>$message</p>";
}
}
if ($_POST['supported'] == true) {
$trueSelected = 'selected';
$falseSelected = '';
} else {
$falseSelected = 'selected';
$trueSelected = '';
}
if ($_POST['format'] == 'KB') {
$KBSelected = 'selected';
$MBSelected = '';
$GBSelected = '';
} elseif ($_POST['format'] == 'GB') {
$KBSelected = '';
$MBSelected = '';
$GBSelected = 'selected';
}
}
$textarea = substr($textarea, 0, strlen($textarea)-1);
?>
<html>
<head>
<title>File Host Link Tester</title>
<script language="javascript" type="text/javascript">
function copytext(text2copy) {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
document.getElementById(flashcopier).innerHTML = divinfo;
}
</script>
</head>
<body>
<h1>File Host Link Tester</h1>
<form id="linktest" name="linktest" action="" method="post">
<textarea id="links" name="links" rows="20" style="width:100%" onFocus="getElementById('copy').disabled = false;"><?=$textarea?></textarea><br>
<input id="submit" name="submit" type="submit" value="submit" onClick="this.value = 'processing';">
<input id="copy" name="copy" type="button" value="copy" onClick="copytext(getElementById('links').value); getElementById('copy').disabled = true;">
<input id="help" name="help" type="button" value="help" onClick="location='help.html';">
Result format:
<select id="format" name="format">
<option value="KB" <?=$KBSelected?>>KB</option>
<option value="MB" <?=$MBSelected?>>MB</option>
<option value="GB" <?=$GBSelected?>>GB</option>
</select>
Rounding:
<input id="round" name="round" type="text" size="1" maxlength="1" value="<?=$round?>">
Supported hosts only:
<select id="supported" name="supported">
<option value="1" <?=$trueSelected?>>true</option>
<option value="0" <?=$falseSelected?>>false</option>
</select>
</form>
<?php
if (count($results) > 0) {
echo "<h1>Results</h1>";
foreach ($results as $value) {
echo $value;
}
}
?>
</body>
</html>
|