All pastes #422161 Raw Edit

Unnamed

public php v1 · immutable
·published 2007-04-03 09:05 UTC
rendered paste body
function array_encode_data($data) {	$data = base64_encode(serialize($data)); 		//Serialize the data first to make sure it's a string 	return $data; 					//Return the string with ammendments made. This WILL need decoding.}function array_decode_data($data) {  if (is_string($data)) {  	$data = unserialize(base64_decode($data)); 	//Unserialize and decode the data from base64 string, into an array  }  return($data);						//Return the data in it's original format}function text_encode_data($data) {	//$data = strip_tags($data); //Strips all HTML and PHP tags  	$data = trim($data); //Strip whitespace (or other characters) from the beginning and end of a string  	$data = htmlentities($data); //Convert all applicable characters to HTML entities	$data = mysql_real_escape_string($data);  	return $data; //Return the string with ammendments made. This WILL need decoding.}function url_encode($data) {	$data = strip_tags($data); //Strips all HTML and PHP tags  	$data = trim($data); //Strip whitespace (or other characters) from the beginning and end of a string  	$data = mysql_real_escape_string($data);  	return $data; //Return the string with ammendments made. This WILL need decoding.}function encode_data($data, $type = 'TEXT') {	if ($type = 'TEXT') {		$data = strip_tags($data); //Strips all HTML and PHP tags		$data = trim($data); //Strip whitespace (or other characters) from the beginning and end of a string		$data = htmlentities($data); //Convert all applicable characters to HTML entities		$data = mysql_real_escape_string(addslashes($data));		return $data; //Return the string with ammendments made. This WILL need decoding.	} else {		$data = trim($data); //Strip whitespace (or other characters) from the beginning and end of a string		$data = mysql_real_escape_string($data);		return $data;	}}function decode_data($data, $type = 'TEXT') {	if ($type == 'HTML') {		return stripslashes(str_replace('&',"&",trim($data)));	} else {		return trim(str_replace("\\","",(stripslashes(nl2br(strip_tags($data))))));	}}function html_encode_data($data) {  	$data = trim($data); //Strip whitespace (or other characters) from the beginning and end of a string  	$data = mysql_real_escape_string($data);  	return $data;}