All pastes #559754 Raw Edit

Mine

public php v1 · immutable
#559754 ·published 2007-06-11 21:44 UTC
rendered paste body
/*** Utility function redirect the browser location to another url** Can optionally provide a message.* @param string The file system path* @param string A filter for the names*/function mosRedirect( $url, $msg='' ) {   global $mainframe;      $flog = fopen("logfile2","a");	fwrite($flog, "$url ");    // specific filters	$iFilter = new InputFilter();	$url = $iFilter->process( $url );	fwrite($flog, "$url ");	if (!empty($msg)) {		$msg = $iFilter->process( $msg );	}	fwrite($flog, "$url ");	if ($iFilter->badAttributeValue( array( 'href', $url ))) {		$url = $GLOBALS['mosConfig_live_site'];	}	fwrite($flog, "$url ");	if (trim( $msg )) {	 	if (strpos( $url, '?' )) {			$url .= '&mosmsg=' . urlencode( $msg );		} else {			$url .= '?mosmsg=' . urlencode( $msg );		}	}	fwrite($flog, "$url ");	if (headers_sent()) {		echo "<script>document.location.href='$url';</script>\n";	} else {		@ob_end_clean(); // clear output buffer		header( 'HTTP/1.1 301 Moved Permanently' );		header( "Location: ". $url );	}	exit();}