Hire A Programmer
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherHire A Programmer

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old May 7th, 2008, 06:58 PM
defiance defiance is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 3 defiance User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 7 sec
Reputation Power: 0
Fatal error: Cannot redeclare CSQLAdmin::$functions ---- Help Wanted

Hello,

I have a program that works perfectly when I first moved to my host, but a few weeks later, it stopped working and gives out this error


"Fatal error: Cannot redeclare CSQLAdmin::$functions"

I asked my webhost but they said they didnt change anything and do not claim responsible. So, I am left alone.

I know that this error is caused by having 2 var$functions in one class. but when I changed one to another name, it gives out just blank page.

I have tried looking at the code to change the original $functions that i changed, but to no avail.

So, anyone.?

Here is the full code of sqladmin.php

PHP Code:
<?php
/*
*/
class CSQLAdmin extends CLibrary {

    
/**
    * description
    *
    * @var type
    *
    * @access type
    */
    
var $form;

    
/**
    * description
    *
    * @var type
    *
    * @access type
    */
    
var $functions;
    

    
/**
    * description functions list which will be executed in variouse points of sqladmin
    *
    * @var type
    *
    * @access type
    */
    
var $functions;
    

    function 
CSQLAdmin($section $templates $db $tables $extra "") {
        global 
$_CONF;

        if (!
$_GET["page"])
            
$_GET["page"] = 1;        


        
parent::CLibrary("SQLAdmin");
        
        
//checking if the templates are orblects or path to a template file
        
if (!is_array($templates))                    
            
//if path the load the tempmate form that file
            
$this->templates = array("generic_form" => new CTemplate($templates));
        else
            
$this->templates $templates;
        
        
$this->db $db;
        
$this->tables $tables;
        
//extra variables to be passed to cform
        
$this->extra $extra;

        
//loading the forms , changed the varialbes locations, but still keeping the compatibility
        
$path = ($_CONF["forms"]["adminpath"] ? $_CONF["forms"]["adminpath"] : $_CONF["formspath"] );
        if (
dirname($section)) {

            
$path .= dirname($section) . "/" ;
            
$section basename($section);
        }
        
        
//debuging part 
        
if (defined("PB_DEBUG") && (PB_DEBUG == "1"))
            echo 
"<br>FILE:SQLADMIN:MAIN:{$path}{$section}.xml";

        
$conf = new CConfig$path $section ".xml");

        
$this->forms $conf->vars["form"];
        
        
//loading the edit/add forms
        
if (is_array($this->forms["forms"])) {
            foreach (
$this->forms["forms"] as $key => $val) {    
                unset(
$conf);

                
//debuging part 
//                if (defined("PB_DEBUG") && PB_DEBUG == "1")        
//                    echo "<br>FILE:SQLADMIN:SECTION:{$path}{$section}.xml";

                
$conf = new CConfig($path $val );
                
$this->forms["forms"][$key] = $conf->vars["form"];

                
//adding the tables
                
$this->forms["forms"][$key]["table"] = $this->forms["table"];
                
$this->forms["forms"][$key]["table_uid"] = $this->forms["table_uid"];
                
$this->forms["forms"][$key]["xmlfile"] = $path $val ;
            }            
        }

        
$this->form = new CForm($this->templates["generic_form"], &$db , &$tables);
    }

    
/**
    * description
    *
    * @param
    *
    * @return
    *
    * @access
    */
    
function FormList($items "") {
        global 
$base;

        
//checking if hte values weren't inputed ion the main object
        
if (is_array($this->items)) {
            
$items $this->items;
        }        

        
//preexecute a function, which is suposed in some times to preload the items too

        
if (is_array($this->functions["list"]["pre"]))
            
call_user_func($this->functions["list"]["pre"], &$items , &$items_count);

        
//if i got no elements from preloader functions, then i load it manualy
        
if (!is_array($items) && !is_array($this->forms["forms"]["list"]["sql"])) {

            
//cheking if is a normal browse or a search method
            
if (isset($this->forms["uridata"]["search"]) && ($_GET[$this->forms["uridata"]["action"]] == $this->forms["uridata"]["search"])) {

                
$items $this->db->QuerySelectLimit($this->tables[$this->forms["forms"]["list"]["table"]],"*""`" $_GET["what"] . "` " . ( $_GET["type"] == "int" "='" $_GET["search"] . "'" "LIKE '%" $_GET["search"] . "%'"),(int) $_GET["page"],$this->forms["forms"]["list"]["items"]);
                
$count $this->db->RowCount($this->tables[$this->forms["forms"]["list"]["table"]] , " WHERE `" $_GET["what"] . "` " . ( $_GET["type"] == "int" "='" $_GET["search"] . "'" "LIKE '%" $_GET["search"] . "%'"));

            } else {
            
                
$items $this->db->QuerySelectLimit($this->tables[$this->forms["forms"]["list"]["table"]],"*","",(int) $_GET["page"],$this->forms["forms"]["list"]["items"]);
                
$count $this->db->RowCount($this->tables[$this->forms["forms"]["list"]["table"]]);
            }
        }

        
$_GET["page"] = $_GET["page"] ? $_GET["page"] : 1;
        
//auto index the element
        
$start $this->forms["forms"]["list"]["items"] * ($_GET["page"] - );

        if (
is_array($items)) {
            foreach (
$items as $key => $val) {
                
$items[$key]["_count"] = ++$start;
            }            
        }        

        
//$data = new CForm($this->templates["generic_form"], &$this->db , &$this->tables);
        
return $this->form->SimpleList($this->forms["forms"]["list"] , $items $count $this->extra["list"]);
    }


    
/**
    * description
    *
    * @param
    *
    * @return
    *
    * @access
    */
    
function SetFunction$form $event $function) {
        
$this->functions[$form][$event] = $function;
    }
    

    
/**
    * description
    *
    * @param
    *
    * @return
    *
    * @access
    */
    
function ListProcess($pre "" $after "" ) {

        
$this->functions["list"]["pre"] = $pre;
        
$this->functions["list"]["after"] = $after;
    }

    
/**
    * description
    *
    * @param
    *
    * @return
    *
    * @access
    */
    
function StoreRecord($redirect true) {
        global 
$base$_CONF;

        
//validating the input data
        
if ($_SERVER["REQUEST_METHOD"] == "POST") {

            
//doing a autodetect for storing type , edit or add
            //if $_GET["type"]    is set is simple, else detecting after the id form
            
if (!isset($_GET["type"])) {
                if (
$_POST[$this->forms["table_uid"]])
                    
$_GET["type"] = "edit";
                else
                    
$_GET["type"] = "add";
            }    

            
//if validation succeeds then i move the files from /tmp to their directory, else i will proceed to add
            //precheck for uploaded files, like temporary images, etc.
            
$form $this->forms["forms"][$_GET["type"]];

            if (
is_array($form["fields"])) {
                foreach (
$form["fields"] as $key => $val) {

                    switch (
$val["type"]) {

                        case 
"date":
                            
$_POST[$key] = mktime $_POST[$key "_hour"] , $_POST[$key "_minute"] , $_POST[$key "_second"] , $_POST[$key"_month"] , $_POST[$key"_day"] , $_POST[$key"_year"]);
                        break;

                        case 
"droplist":
                            if (
$val["subtype"] == "multiple") {

                                
//detect the fields which should be available for this field
                                
if (is_array($_POST)) {
                                    
                                    foreach (
$_POST as $k => $v) {
                                        if (
strstr($k $key "_option_")) {
                                            
$option[] = $v;
                                        }                                        
                                    }                        
                                    
//ok, now build the result
                                    
if (is_array($option)) {
                                        
$_POST[$key] = implode($val["tree"]["db_separator"],$option);
                                    } else {
                                        
$_POST[$key] = "";
                                    }
                                } else {
                                    
                                }
                            }
                            
                        break;

                        case 
"upload":
                            
$file true;
                        case 
"image":
                            unset(
$_POST[$key]);

//                            echo "<pre style=\"background-color:white\">";
//                            print_r($_FILES);

                            //checking how choosed the client to set the image
                            
switch ($_POST[$key "_radio_type"]) {
                                case 
0:
                                    
//checking if the client specified any image type
                                    
if (is_array($_FILES[$key "_upload_client"]) && is_uploaded_file($_FILES[$key "_upload_client"]["tmp_name"])) {                                    
                                        
$img = &$_FILES[$key "_upload_client"];
                                        
//temporary upload the file in images/upload/tmp/
                                        
$name $_POST[$key "_temp"] != "" $_POST[$key "_temp"] : $val["file"]["default"] . time() . $val["file"]["ext"];    
                                        
                                        @
move_uploaded_file($img["tmp_name"] , $_CONF["path"] . $_CONF["upload"] . "tmp/" $name );
                                        
//z:\forum.phpbase.net\images\smiles\icon_smile.gif

                                        // generate the tn image
                                        
if ($val["tn"]["generate"] == "true") {
                                            
$base->image->Resize(
                                                                    
$_CONF["path"] . $_CONF["upload"] . "tmp/" $name ,
                                                                    
$_CONF["path"] . $_CONF["upload"] . "tmp/" $val["tn"]["preffix"] . $name ,
                                                                    
$val["tn"]["width"]
                                                                );
                                            
$_POST["tn_" $key] = "1";
                                        }
                                        
                                        
//setting read/delete/save permission for all users, usefull if the httpd is working as normal user ( most cases )
                                        
chmod ($_CONF["path"] . $_CONF["upload"] . "tmp/" $name 0777);
//                                        die;
                                        //setting the temp variable
                                        
$_fields["values"][$key "_temp"] = $name;
                                        
$_POST[$key "_temp"] = $name;
                                        
$_POST[$key "_file"] = $_FILES[$key "_upload_client"]["name"];
                                        
$_POST[$key] = "1";

                                    }                                
                                break;

                                case 
"1":
                                    
//, the guy wants to download a ing image

                                    
if ($_POST[$key "_upload_web"] != "http://") {                                        
                                        
//i have to be very carefully here, if the image is not a valid link, then 
                                        //everithing get messed.
                                        
$image = @GetFileContents($_POST[$key "_upload_web"]);
                                        
                                        
$name $_POST[$key "_temp"] != "" $_POST[$key "_temp"] : $val["file"]["default"] . time() . $val["file"]["ext"];

                                        
SaveFileContents$_CONF["path"] . $_CONF["upload"] . "tmp/" $name $image);
                                        
chmod ($_CONF["path"] . $_CONF["upload"] . "tmp/" $name 0777);

                                        
// generate the tn image
                                        
if ($val["tn"]["generate"] == "true") {
                                            @
$base->image->Resize(
                                                                    
$_CONF["path"] . $_CONF["upload"] . "tmp/" $name ,
                                                                    
$_CONF["path"] . $_CONF["upload"] . "tmp/" $val["tn"]["preffix"] . $name ,
                                                                    
$val["tn"]["width"]
                                                                );

                                            
$_POST["tn_" $key] = "1";
                                        }

                                        
//setting the temp variable
                                        
$_fields["values"][$key "_temp"] = $name;
                                        
$_POST[$key "_temp"] = $name;
                                        
$_POST[$key "_file"] = basename($_POST[$key "_upload_web"]);
                                        
$_POST[$key] = "1";
                                    }

                                break;

                                case 
"-1":
//                                    echo "<pre style=\"background-color:white\">";
//                                    print_r($_POST);
//                                    die;
                                    //trying to remove the tmp image is exists
                                    
if (file_exists($_CONF["path"] . $_CONF["upload"] . "tmp/" $_POST[$key "_temp"]) && is_file($_CONF["path"] . $_CONF["upload"] . "tmp/" $_POST[$key "_temp"]))
                                        @
unlink($_CONF["path"] . $_CONF["upload"] . "tmp/" $_POST[$key "_temp"]);                                        
                                    
//removing the original image too if exists
                                    
else
                                        @
unlink($_CONF["path"] . $_CONF["upload"] .