06-05-2008, 06:54 PM
|
#1 (permalink)
|
|
The Contributor
Join Date: May 2008
Location: Denmark
Posts: 70
Thanks: 3
|
Redeclaring class, but i don't ?
Well i keep getting this error:
Fatal error: Cannot redeclare class clean in /customers/pulse101.net/pulse101.net/httpd.www/dev1/backend/classes/clean.class.php on line 66
But i just can't understand it :(
Here is the file with the "error"?
PHP Code:
<?php //Check if ticket if (!defined('BACKEND_TICKET')) { die(); }
//Declare the class class clean extends p101 { public function clean_var($var) { //If $var = array , treat as an array if (is_array($var)) { //$buffer = array(); foreach ($var as $key => $val) { if (is_array($var[$key])) { $var[$key] = $this->clean_var($val); } else { $var[$key] = $this->do_clean($val); } } } else { $var = $this->do_clean($var);
}
return($var); } public function clean_globals() { $array = array( 'POST' => $_POST, 'GET' => $_GET, 'COOKIE' => $_COOKIE, 'REQUEST' => $_REQUEST, 'SESSION' => $_SESSION, 'FILES' => $_FILES ); foreach($array as $key => $val) { $this->global_vars[$key] = $this->clean_var($val); } } private function do_clean($var) { if(function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) { $var = stripslashes($var); } $var = addslashes($var); $var = htmlspecialchars($var); return($var); } } // Line 66
?>
If you wan't the class i'm extending then here it is, i got a little help from Kalle;
PHP Code:
<?php //Check if ticket if (!defined('BACKEND_TICKET')) { die(); }
class p101 { protected $instances = array(); public function __construct() { // Load classes foreach(glob(CLASS_PATH . '*.class.php') as $filename) { if (!is_readable($filename)) { $this->error[] = 'File: ' . $filename . ' is not readable'; continue; } require($filename); //$classname = substr($filename, strlen(CLASS_PATH), strpos($filename, '.', 0)); $classname = explode('/', $filename); $classname = end($classname); $classname = explode('.', $classname); $classname = $classname[0];
if (class_exists($classname)) { $this->instances[$classname] = new $classname; } else { $this->error[] = 'Problem declaring ' . $classname; } } // Clean globals $this->clean->clean_globals();
} public function __get($varname) { $varname = (string) $varname;
if(array_key_exists($varname, $this->instances)) { return($this->instances[$varname]); } elseif(isset($this->{$varname})) { return($this->{$varname}); } } }
?>
I'm pretty stuck with this at the moment. Any suggestions?
|
|
|
|