All pastes #719434 Raw Edit

Something

public php v1 · immutable
#719434 ·published 2007-09-29 08:42 UTC
rendered paste body
				/**		  * saveasdialogue rewritten slightly to not be a jerk about images		  */				function SaveAsDialogue($FolderPath, $FileName, $DeleteFile = '0') {			global $Context;						$DeleteFile = ForceBool($DeleteFile, 0);			if ($FolderPath !== '') {				if (substr($FolderPath, strlen($FolderPath)-1) != '/') $FolderPath = $FolderPath.'/';			}			$FolderPath = $FolderPath.$FileName;						$match = false;						foreach( $Context->Configuration['ATTACHMENTS_ALLOWED_FILETYPES'] as $mime => $exts ) {				foreach($exts as $ext) {					if( substr($FileName, strlen($FileName) - strlen($ext) - 1) == '.'.$ext) {						header('Content-Type: ' . $mime);						$match = true;						break 2;					}				}			}						if( !$match ) {				header('Pragma: public');				header('Expires: 0');				header('Cache-Control: must-revalidate, post-check=0, pre-check=0');				header('Content-Type: application/force-download');				header('Content-Type: application/octet-stream');				header('Content-Type: application/download');				header('Content-Transfer-Encoding: binary');				header('Content-Disposition: attachment; filename="'.$FileName.'"');			}						readfile($FolderPath);			if ($DeleteFile) unlink($FolderPath);			die();		}