Location: PHPKode > projects > InvisiblePortal > trunk/news-config.php
<?
/***********************************************************************************
Copyright (C) 2006  Mike Ramirez Da-Shiznit Blogger, a simple blogging script.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Contact me: hide@address.com
*************************************************************************************/

//database variables
//DB info 
$dbserver = "localhost";			//database host, if it is remotely hosted, the ip or url must be put here
$dbname = "reika";			//database name
$dbuser = "gufymike";				//database user
$dbpass = "eZFEp3sA";			//database user pass

 
/***************DO NOT EDIT BELOW THIS LINE**************************************/
$dbx = mysql_connect($dbserver, $dbuser, $dbpass);
  if (!$dbx) {
     die ("Could not connect to database with this error:  " . mysql_error());
    }
if (!mysql_select_db($dbname)) {
   echo "Unable to select to " . $dbname ." with this errer:  " . mysql_error();
   exit;
}

// Functions for cleaning the inputed text.
function clean_name($name){
				 
//array of invalid characters
  				$junk = array('.' , ',' , '/' , '\\' , '`' , ';' , '[' ,  ']' , '-', '*', '&', '^', '%', '$', '#', '@', '!', '~', '+', '(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '='); 
			  
  //starting lenght of uname
  				$len = strlen($name);
  
  //replace invalid characters
  				$name = str_replace($junk, '', $name);
	  			$test = $name;
  
  //if lenghts are different ($len smaller), invalid characters found, so prompt error.
  				if(strlen($test) != $len || ($test == "")) {
     					die('Username Error: Name Field contained invalid characters. You can only use A-Z, 0-9 and the underscore \'_\'.');
  				}else{
					$cname = mysql_real_escape_string($test);
					return($cname);
				}
				//shouldn't get here
				die('You Fail!');
}
function clean_title($title){
				 
//array of invalid characters
  				$junk = array('.' , ',' , '/' , '\\' , '`' , ';' , '[' ,  ']' , '-', '*', '&', '^', '%', '$', '#', '@', '!', '~', '+', '(', ')', '|', '{', '}', '<', '>', '?', ':', '"', '='); 
			  
  //starting lenght of uname
  				$len = strlen($title);
  
  //replace invalid characters
  				$title = str_replace($junk, '', $title);
	  			$test = $title;
  
  //if lenghts are different ($len smaller), invalid characters found, so prompt error.
  				if(strlen($test) != $len || ($test == "")){
     					die('Title Error: Title contained invalid characters. You can only use A-Z, 0-9 and the underscore \'_\'.');
  				}else{
					$ctitle = mysql_real_escape_string($test);
					return($title);
				}
}

function clean_text($text){
				 
//array of invalid characters
  				$junk = array( '\\' , '`' , ';' , '*', '&', '^', '%', '$', '#', '@', '~', '+', '(', ')', '|', '{', '}', '<', '>', '"'); 
			  
  //starting lenght of uname
  				$len = strlen($text);
  
  //replace invalid characters
  				$text = str_replace($junk, '', $text);
	  			$test = $text;
  
  //if lenghts are different ($len smaller), invalid characters found, so prompt error.
  				if(strlen($test) != $len || ( $test == "")){
     					die('Text Error: Text contained invalid characters. You can only use A-Z, 0-9 \'.\', \',\', \':\', \'!\', \'?\' and the underscore \'_\'.');
  				}
				$ctext = mysql_real_escape_string($test);
				return($ctext);
}

//should be self explanatory, checking for if it is a vaild email.
function clean_email($email){

				if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) || ($email == "")){
					die('Error: Invalid E-Mail format.');
				} 
				$cemail = mysql_real_escape_string($email);
				return($cemail);
}
function clean_idc($idc){
//Check Credit input is an interger value
				if(eregi("^[0-9]{1,3}", $idc)|| ($idc == " ") || (eregi("[a-zA-Z]", $idc))){
					if (!($idc >= "1" && $idc <= "999")){
					die('Input Error: This input isn\'t an integer for post id.');
					}else{
						$cidc = mysql_real_escape_string($idc);
						return($cidc);
					}
				}
}

//remove html sequences
function unhtmlentities($string)
{
   // replace numeric entities
   $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
   $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
   // replace literal entities
   $trans_tbl = get_html_translation_table(HTML_ENTITIES);
   $trans_tbl = array_flip($trans_tbl);
   return strtr($string, $trans_tbl);
}
function bbcode($text)
{
	$bbcodetext = $text;
  	//set an array to find the bbcode
	$find = array(
                   "'\[b\](.*?)\[/b\]'is", 
		   "'\[i\](.*?)\[/i\]'is",
		   "'\[u\](.*?)\[/u\]'is",
		   "'\[center\](.*?)\[/center\]'is",
		   "'\[image\](.*?)\[/image\]'is",
                   "'\[link\](.*?)\[/link\]'is", 
                   "'\[link=(.*?)\](.*?)\[/link\]'is"
                ); 

	$replace = array(
	//set an array that holds the styles for the bbcode
                   "<span class=\"bbbold\"\\1</span>",
		   "<span class=\"bbitalics\">\\1</span>",
		   "<span class=bbunderline>\\1</span>",
		   "<span class=\"bbcenter\">\\1</span>",
		   "<span class=\"bbbcode\">\\1</span>",
		   "<img src=\"\\1\" alt=\"\\1\" border=\"0\" />",
                   "<a href=\"\\1\">\\1</a>", 
                   "<a href=\"\\1\">\\2</a>" 
                );
	//  Replace the [bbcode] with the styles in the text.
	$parsedtext = preg_replace($find,$replace,$bbcodetext);
	return $parsedtext;
}
?>
Return current item: InvisiblePortal