CoolFace
Apppublic

kenken999/php

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
file.php69 linesDownload Raw Back to public
1<?php2// download a file3 4@ini_set("display_errors","1");5//	don't read permissions from the database, use version saved in session6$gReadPermissions = false;7include_once ("include/dbcommon.php");8 9$table = postvalue("table");10$field = postvalue("field");11$thumb = postvalue( "thumb" );12$outputAsAttachment = postvalue("nodisp") == 1;13 14if( postvalue("userpic") ) {15	if( !Security::showUserPic() )16		exit();17	$userData =& Security::currentUserData();18	$userpicField = Security::userpicField() ? Security::userpicField() : "picture";19	20	$value =& $userData[ $userpicField ];21	$ftype = SupposeImageType($value);22	if( !$ftype ) {23		$ftype = "image/png";		24	}25	header("Cache-Control: max-age=0");26	header("Content-Type: ".$ftype);27	echoBinary( $value );28	exit();29}30 31if ( !GetTableURL($table) ) {32	echo 'unknown table';33	exit();34}35 36$formStamp = postvalue("fkey");37if( !$formStamp ) {38	// verify security only when formstamp is not used39	// when formstamp is used, RunnerFileHandler::getFileInfo does the access control40	if( !Security::checkFieldAccess( $table, $field, false ) ) {41		echo 'access denied';42		exit();43	}44}45 46$pSet = new ProjectSettings( $table );47 48// caching is enabled on purpose, don't uncomment nor delete this.	49// add_nocache_headers();50 51require_once getabspath('classes/filehandler.php');52 53$fileHandler = new RunnerFileHandler( $field, $pSet, $formStamp );54$filename = postvalue("file") != "" ? postvalue("file") : postvalue("filename");55 56$useHttpRange = !postvalue('norange');57 58$keys = array();59if( !$formStamp ) {60	//	ignore keys when formStamp is specified61	foreach( $pSet->getTableKeys() as $ind => $k ) {62		$keys[ $k ] = postvalue("key".($ind + 1));63	}64}65 66$fileHandler->showFile( $filename, !!postvalue("thumbnail"), !!postvalue("icon"), $outputAsAttachment, $useHttpRange, $keys );67 68exit();69?>