Esempio n. 1
0
    if ($Result === $Key) {
        echo 'PASS';
    } else {
        echo "FAIL ('" . $Key . "')";
    }
    echo "\n";
}
echo "\nBase32 Encode/Decode Excercise";
$Passes = 100;
$MaxLen = 100;
$Failures = 0;
mt_srand();
for ($i = 0; $i < $Passes; $i++) {
    $RandStr = '';
    $Len = mt_rand(0, $MaxLen);
    for ($Leni = 0; $Leni < $Len; $Leni++) {
        $RandStr .= chr(mt_rand(0, 255));
    }
    $Encoded = Base32::Encode($RandStr);
    $Decoded = Base32::Decode($Encoded);
    if ($Decoded != $RandStr) {
        echo "\nFAIL\n";
        echo "Input:\t\t " . DumpBinStr($RandStr) . "\n";
        echo "Encoded:\t " . $Encoded . "\n";
        echo "Decoded:\t " . DumpBinStr($Decoded) . "\n";
        $Failures++;
    }
}
if ($Failures == 0) {
    echo ": PASS\n";
}
Esempio n. 2
0
$languageCode='EN';
initHittr();

switch (getTriageValue()) {

	case 'UPLOAD_REQUEST':
		$hashToUse=getUnusedHash();
		print generateUploadNotification($hashToUse,moveAndWriteFile($hashToUse,realpath('./files'),$_FILES['file']));
	break;

	case 'RETRIEVAL_REQUEST':
		$hashToSend=$_GET['h'];
		$fileToSend=glob("files/$hashToSend*");
		if (sizeof($fileToSend)>0) {
			$fileInfoString=substr(str_replace('files/','',$fileToSend[0]),32);
			$fileInfoArray=explode('|',Base32::Decode($fileInfoString));
			header('Content-type: '.trim($fileInfoArray[1]));
			readfile($fileToSend[0]);
			unlink($fileToSend[0]);
			break;
		}

	default:
		print generateUploadPage();
}


function initHittr() {
	include('./encode32.php');
	include('./language.php');
	checkPreRequisites();