TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-05-2008, 06:54 PM   #1 (permalink)
The Contributor
 
Join Date: May 2008
Location: Denmark
Posts: 70
Thanks: 3
SpYkE112 is on a distinguished road
Default 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?
SpYkE112 is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:31 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design