M8than
yes
- Mar 16, 2012
- 463
- 102
I'm trying my hand at OOP and I am stuck, I try to pass some variables to an oop class and it comes up with that error.
My Global.php:
The code that causes the error:
The functions:
My Global.php:
Code:
<?php
session_start();
if(isset($_SERVER['HTTP_CF_CONNECTING_IP']))
{
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
include "includes/config.php";
include "includes/class.essentials.php";
include "includes/class.users.php";
$db_host = $config['database']['host'];
$db_username = $config['database']['username'];
$db_password = $config['database']['password'];
$db_name = $config['database']['name'];
$db_connect = mysql_connect("$db_host", "$db_username", "$db_password");
$db_select = mysql_select_db("$db_name");
if(!$db_connect){
die("Can not connect to database!");
}
if(!$db_select){
die("Can not select database!");
}
$reg = new users\REG();
$login = new users\LOGIN();
$security = new cms\SECURITY();
?>
The code that causes the error:
Code:
<?php include "global.php";?>
<?php
if (isset($_POST['register']))
{
$password = $_POST['reg_password'];
$password2 = $_POST['reg_rep_password'];
$username = $_POST['reg_username'];
$refer = $_POST['reg_refer'];
$reg->regcheck($username, $password, $password2, $refer);
}
?>
The functions:
Code:
public function regcheck($username, $password, $confpassword, $refer)
{
$errors = "";
$username1 = $security->filter($username);
$password1 = $security->filter($password);
$confpassword1 = $security->filter($confpassword);
$refer1 = $security->filter($refer);
if ($password1 != $confpassword1)
Code:
public function filter($data)
{
if(empty($data)){
return $data;
}
$data = str_replace(array('&','<','>'), array('&amp;','&lt;','&gt;'), $data);
$data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data);
$data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data);
$data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');
$data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);
$data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2nojavascript...', $data);
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2novbscript...', $data);
$data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u', '$1=$2nomozbinding...', $data);
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
$data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu', '$1>', $data);
$data = preg_replace('#</*\w+:\w[^>]*+>#i', '', $data);
do
{
$old_data = $data;
$data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#i', '', $data);
}
while ($old_data !== $data);
return mysql_real_escape_string($data);
}