DIR : /home/kozerus/public_html/go/eidogo/tourney/download.php

/home/kozerus/public_html/go/eidogo/tourney

<?php

	$filnam="sgf/print1.sgf";
#	phpinfo();

#	$lines=ko_readfile($filename);
#	print_r($lines);

#	$id="print1";
	$id="kludge";
        if( isset($_REQUEST['id']) || isset($_REQUEST['id'] )) {
		$id=$_REQUEST['id'];
		}



	$php_self=$_SERVER['PHP_SELF'];
	$script_name=$_SERVER['SCRIPT_NAME'];
	$script_filename=$_SERVER['SCRIPT_FILENAME'];
	$dr=str_replace($script_name,"",$script_filename);

	$path_parts = pathinfo($script_name);
	$dir=$path_parts['dirname'];
	$name=$path_parts['basename'];
	$ext=$path_parts['extension'];
	$base=$path_parts['filename'];
	$dr_pathfile=$dr.$dir."/sgf/$id.sgf";



	$content_type="application/java-archive";
	$content_type="application/EDI-X12";
	$content_type="application/EDIFACT";  
	$content_type="application/javascript";	#  (obsolete) 
	$content_type="application/octet-stream"; 
	$content_type="application/ogg";
	$content_type="application/pdf";
	$content_type="application/xhtml+xml";
	$content_type="application/x-shockwave-flash";
	$content_type="application/json";  
	$content_type="application/ld+json";  
	$content_type="application/xml";
	$content_type="application/zip";
	$content_type="application/x-www-form-urlencoded";
	$content_type="audio/mpeg";
	$content_type="audio/x-ms-wma";
	$content_type="audio/vnd.rn-realaudio";
	$content_type="audio/x-wav";
	$content_type="image/gif";
	$content_type="image/jpeg";
	$content_type="image/png";
	$content_type="image/tiff";
	$content_type="image/vnd.microsoft.icon";
	$content_type="image/x-icon";
	$content_type="image/vnd.djvu";
	$content_type="image/svg+xml";
	$content_type="multipart/mixed";
	$content_type="multipart/alternative";
	$content_type="multipart/related";	#  (using by MHTML (HTML mail).)  ";
	$content_type="multipart/form-data";
	$content_type="text/css";
	$content_type="text/csv";
	$content_type="text/event-stream";
	$content_type="text/html";
	$content_type="text/javascript";
	$content_type="text/plain";
	$content_type="text/xml";
	$content_type="video/mpeg";
	$content_type="video/mp4";
	$content_type="video/quicktime";
	$content_type="video/x-ms-wmv";
	$content_type="video/x-msvideo";
	$content_type="video/x-flv";
	$content_type="video/webm";
	$content_type="application/vnd.android.package-archive";
	$content_type="application/vnd.oasis.opendocument.text";
	$content_type="application/vnd.oasis.opendocument.spreadsheet";
	$content_type="application/vnd.oasis.opendocument.presentation";
	$content_type="application/vnd.oasis.opendocument.graphics";
	$content_type="application/vnd.ms-excel";
	$content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
	$content_type="application/vnd.ms-powerpoint";
	$content_type="application/vnd.openxmlformats-officedocument.presentationml.presentation";
	$content_type="application/msword";
	$content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document";
	$content_type="application/vnd.mozilla.xul+xml";
	$content_type="application/sgf";
	$content_type="text/plain";



// headers to send your file
	if( file_exists( $dr_pathfile )) {
#		$filetext=read_htmlfile($dr_pathfile);
		$filetext=file_get_contents($dr_pathfile);
		$outname="$id.sgf";

#		print( "FOUND $dr_pathfile outname=$outname<br>\n" );
#		header("Content-Type: $content_type");
#		header("Content-Length: " . filesize($dr_pathfile));
#		header('Content-Disposition: attachment; filename="' . $outname . '"');

#		$ko_mime=ko_mime_content_type($dr_pathfile);
# 		$mime=mime_content_type($dr_pathfile);
#		printf( "BUGS_ko_mime=<b>$ko_mime</b><br>\n" );
#		printf( "BUGS_mime=<b>$mime</b><br>\n" );

		download_file($dr_pathfile, $outname);

// upload the file to the user and quit
#		readfile($dr_pathfile);
		exit;
		}
	else {

		print( "<html>\n" );
		print( "<head><title>$script_name</title></head>\n" );
		print( "<body bgcolor=linen>\n" );
		print( "<hr>\n" );
		print( "id=<b>$id</b><br>\n" );
		print( "script_name=$script_name<br>\n" );
		print( "script_filename=$script_filename<br>\n" );
		print( "dr=$dr<br>\n" );
		print( "dir=$dir<br>\n");
		print( "name=$name<br>\n" );
		print( "base=$base<br>\n" );
		print( "ext=$ext<br>\n" );
		print( "<hr>\n" );
		print( "filetext=$filetext<br>\n" );
		print( "ERR_901: NOTFOUND $dr_pathfile<br>\n" );
		print( "<hr>\n" );
		print( "	</body>\n" );
		print( "	</html>\n" );
		}

	exit;

function download_file(string $file_path, $outname){
	$content_type="application/sgf";
# 	header('Content-Type: ' . mime_content_type($file_path));
 	header('Content-Type: ' . $content_type );
 	header('Content-Length: ' . filesize($file_path));
 	header('Content-Disposition: attachment; filename="' . $outname . '"');

        $file = fopen($file_path, 'rb');
 	while (!feof($file)) {
 		echo fread($file, 8192);
 		flush();
 		}
 	fclose($file);
 	}
 
function ko_mime_content_type($filename) {
 	$result = new finfo();
#	print( "BUGS_201: ko_mime_content_type=".print_r($result)."<br>\n" );
#	print( "BUGS_202: FILEINFO_MIME_TYPE=".$result->file($filename,FILEINFO_MIME_TYPE)."<br>\n" );
	return $result->file($filename, FILEINFO_MIME_TYPE);

 	if (is_resource($result) === true) {
 		return $result->file($filename, FILEINFO_MIME_TYPE);
 		}
 	return false;
 	}


function ko_readfile($filename) {

	$lines = array();
	$fp = fopen($filename, "r");

	if(filesize($filename) > 0){
		$content = fread($fp, filesize($filename));
		$lines = explode("\n", $content);
		fclose($fp);
		}
	return($lines);
	}

//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer