Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   SERIOUS problems with Chibifurs (http://www.mysidiaadoptables.com/forum/showthread.php?t=4073)

GuardiansWish 03-24-2013 04:18 PM

SERIOUS problems with Chibifurs
 
Okay for the past three months, Chibifurs has been dealing with some severe code issues. As seen here: http://www.chibifurs.com/ we are unable to get into the adopts half of the site. We have gone through the rings with our service providers who have essentially told us to come to you. I have included all screenshots and discussions we have had with them to help.

-----------------------------------

30 Dec.

Hi ----,

This is the error that comes about when an existing site (one with a valid /home/chibifur/public_html/classes/class_database.php ) points to a database that no longer exists.

Check /home/chibifur/public_html/classes/class_database.php and make sure that the database listed in there is able to be connected .

Regards,
Arun

----------------

Our response back:

http://fc03.deviantart.net/fs70/f/20...sh-d5pukij.png


Our uploaded file:

PHP Code:

<?php

class Database extends PDO{
    
/**
     * Tables' prefix
     *
     * @access private
     * @var string
     */
    
private $_prefix;

    
/**
     * Keep track of total rows from each query
     *
     * @access private
     * @var array
     */
    
private $_total_rows = array();

    
/**
     * Stores join table
     *
     * @access private
     * @var array
     */
    
private $_joins = array();

    
/**
     * If you don't know what this is, you shouldn't be here
     *
     * @param string $dbname
     * @param string $host
     * @param string $user
     * @param string $password
     * @param string $prefix    Tables' prefix
     * @access public
     */
    
public function __construct($dbname$host$user$password$prefix 'adopts_')
    {
        
parent::__construct('mysql:host=' $host ';dbname=' $dbname$user$password);
        
$this->_prefix $prefix;
    }

    
/**
     * Basic INSERT operation
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access public
     * @return object
     */
    
public function insert($tableName, array $data)
    {
        return 
$this->_query($tableName$data'insert');
    }

    
/**
     * Basic UPDATE operation
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access public
     * @return object
     */
    
public function update($tableName, array $data$clause NULL)
    {
        return 
$this->_query($tableName$data'update'$clause);
    }

    
/**
     * Basic SELECT operation
     *
     * @param string $tableName
     * @param array  $data        A key-value pair with values that correspond to the fields of the table
     * @param string $clause    Clauses for creating advance queries with JOINs, WHERE conditions, and whatnot
     * @access public
     * @return object
     */
    
public function select($tableName, array $data$clause NULL)
    {
        return 
$this->_query($tableName$data'select'$clause);
    }

    
/**
     * Basic DELETE operation
     *
     * @param string $tableName
     * @param string $clause    Clauses for creating advance queries with JOINs, WHERE conditions, and whatnot
     * @access public
     * @return object
     */
    
public function delete($tableName$clause NULL)
    {
        return 
$this->_query($tableName, array(), 'delete'$clause);
    }

    
/**
     * Adds JOIN to the next SELECT operation
     *
     * @param string $tableName
     * @param string $cond
     * @access public
     * @return object
     */
    
public function join($tableName$cond)
    {
        
$this->_joins[] = array($tableName$cond);
        return 
$this;
    }

    
/**
     * Get total rows affected by previous queries
     *
     * @param int    $index
     * @return int
     */
    
public function get_total_rows($index)
    {
        if (
$index 0)
        {
            return 
$this->_total_rows[count($this->_total_rows) + $index];
        }
        return 
$this->_total_rows[$index];
    }

    
/**
     * Handles queries
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @param string $operation Defines what kind of operation we'll carry on with the database
     * @access private
     * @return object
     */
    
private function _query($tableName, array $data$operation$clause NULL)
    {
        if ( ! 
is_string($tableName))
        {
            throw new 
Exception('Argument 1 to ' __CLASS__ '::' __METHOD__ ' must be a string');
        }

        if ( ! 
in_array($operation, array('insert''update''select''delete')))
        {
            throw new 
Exception('Unkown database operation.');
        }

        
$query call_user_func_array(array(&$this'_' $operation '_query'), array($tableName, &$data));

        if ( ! empty(
$clause))
        {
            
$query .= ' WHERE ' $clause;
        }
        
//The comments can be removed for debugging purposes.
        //echo $query;
        
$stmt $this->prepare($query);
        
$this->_bind_data($stmt$data);

        if ( ! 
$stmt->execute())
        {
            
$error $stmt->errorInfo();
            throw new 
Exception('Database error ' $error[1] . ' - ' $error[2]);
        }

        
$this->_total_rows[] = $stmt->rowCount();
        return 
$stmt;
    }

    
/**
     * Generates prepared INSERT query string
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access private
     * @return string
     */
    
private function _insert_query($tableName, &$data)
    {
        
$tableFields array_keys($data);
        return 
'INSERT INTO ' $this->_prefix $tableName '
                  (`' 
implode('`, `'$tableFields) . '`)
                  VALUES (:' 
implode(', :'$tableFields) . ')';
    }

    
/**
     * Generates prepared UPDATE query string
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access private
     * @return string
     */
    
private function _update_query($tableName, &$data)
    {
        
$setQuery = array();
        foreach (
$data as $field => &$value)
        {
            
$setQuery[] = '`' $field '` = :' $field;
        }
        return 
'UPDATE ' $this->_prefix $tableName '
                  SET ' 
implode(', '$setQuery);
    }

    
/**
     * Generates prepared SELECT query string
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with values that correspond to the fields of the table
     * @access private
     * @return string
     */
    
private function _select_query($tableName, &$data)
    {
        
$joins '';
        if ( ! empty(
$this->_joins))
        {
            foreach (
$this->_joins as $k => &$join)
            {
                
$exploded explode('='$join[1]);
                
$join_cond '`' $this->_prefix implode('`.`'explode('.'trim($exploded[0]))) . '` = `' $this->_prefix implode('`.`'explode('.'trim($exploded[1]))) . '`';   
                
$joins .= ' INNER JOIN `' $this->_prefix $join[0] . '` ON ' $join_cond;
            }
            
$this->_joins NULL;
            
$this->_joins = array();
        }
        
$fields = empty($data) ? '*' '`' implode('`, `'array_values($data)) . '`';
        return 
'SELECT ' $fields '
                  FROM `' 
$this->_prefix $tableName '`' $joins;
    }

    
/**
     * Generates prepared DELETE query string
     *
     * @param string $tableName
     * @access private
     * @return string
     */
    
private function _delete_query($tableName)
    {
        return 
'DELETE FROM `' $this->_prefix $tableName '`';
    }

    
/**
     * Binds data to the prepared statement
     *
     * @param object $stmt A PDOStatement object
     * @param array  $data A key-value pair to be bound with the statement
     * @access private
     * @return object
     */
    
private function _bind_data(&$stmt, &$data)
    {
        if ( ! empty(
$data))
        {
            foreach (
$data as $field => &$value)
            {
                
$stmt->bindParam(':' $field$value);
            }   
        }
        return 
$this;
    }
}

?>


Our base backup file (original):

PHP Code:

<?php

class Database extends PDO{
    
/**
     * Tables' prefix
     *
     * @access private
     * @var string
     */
    
private $_prefix;

    
/**
     * Keep track of total rows from each query
     *
     * @access private
     * @var array
     */
    
private $_total_rows = array();

    
/**
     * Stores join table
     *
     * @access private
     * @var array
     */
    
private $_joins = array();

    
/**
     * If you don't know what this is, you shouldn't be here
     *
     * @param string $dbname
     * @param string $host
     * @param string $user
     * @param string $password
     * @param string $prefix    Tables' prefix
     * @access public
     */
    
public function __construct($dbname$host$user$password$prefix 'adopts_')
    {
        
parent::__construct('mysql:host=' $host ';dbname=' $dbname$user$password);
        
$this->_prefix $prefix;
    }

    
/**
     * Basic INSERT operation
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access public
     * @return object
     */
    
public function insert($tableName, array $data)
    {
        return 
$this->_query($tableName$data'insert');
    }

    
/**
     * Basic UPDATE operation
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access public
     * @return object
     */
    
public function update($tableName, array $data$clause NULL)
    {
        return 
$this->_query($tableName$data'update'$clause);
    }

    
/**
     * Basic SELECT operation
     *
     * @param string $tableName
     * @param array  $data        A key-value pair with values that correspond to the fields of the table
     * @param string $clause    Clauses for creating advance queries with JOINs, WHERE conditions, and whatnot
     * @access public
     * @return object
     */
    
public function select($tableName, array $data$clause NULL)
    {
        return 
$this->_query($tableName$data'select'$clause);
    }

    
/**
     * Basic DELETE operation
     *
     * @param string $tableName
     * @param string $clause    Clauses for creating advance queries with JOINs, WHERE conditions, and whatnot
     * @access public
     * @return object
     */
    
public function delete($tableName$clause NULL)
    {
        return 
$this->_query($tableName, array(), 'delete'$clause);
    }

    
/**
     * Adds JOIN to the next SELECT operation
     *
     * @param string $tableName
     * @param string $cond
     * @access public
     * @return object
     */
    
public function join($tableName$cond)
    {
        
$this->_joins[] = array($tableName$cond);
        return 
$this;
    }

    
/**
     * Get total rows affected by previous queries
     *
     * @param int    $index
     * @return int
     */
    
public function get_total_rows($index)
    {
        if (
$index 0)
        {
            return 
$this->_total_rows[count($this->_total_rows) + $index];
        }
        return 
$this->_total_rows[$index];
    }

    
/**
     * Handles queries
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @param string $operation Defines what kind of operation we'll carry on with the database
     * @access private
     * @return object
     */
    
private function _query($tableName, array $data$operation$clause NULL)
    {
        if ( ! 
is_string($tableName))
        {
            throw new 
Exception('Argument 1 to ' __CLASS__ '::' __METHOD__ ' must be a string');
        }

        if ( ! 
in_array($operation, array('insert''update''select''delete')))
        {
            throw new 
Exception('Unkown database operation.');
        }

        
$query call_user_func_array(array(&$this'_' $operation '_query'), array($tableName, &$data));

        if ( ! empty(
$clause))
        {
            
$query .= ' WHERE ' $clause;
        }
        
//The comments can be removed for debugging purposes.
        //echo $query;
        
$stmt $this->prepare($query);
        
$this->_bind_data($stmt$data);

        if ( ! 
$stmt->execute())
        {
            
$error $stmt->errorInfo();
            throw new 
Exception('Database error ' $error[1] . ' - ' $error[2]);
        }

        
$this->_total_rows[] = $stmt->rowCount();
        return 
$stmt;
    }

    
/**
     * Generates prepared INSERT query string
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access private
     * @return string
     */
    
private function _insert_query($tableName, &$data)
    {
        
$tableFields array_keys($data);
        return 
'INSERT INTO ' $this->_prefix $tableName '
                  (`' 
implode('`, `'$tableFields) . '`)
                  VALUES (:' 
implode(', :'$tableFields) . ')';
    }

    
/**
     * Generates prepared UPDATE query string
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with keys that correspond to the fields of the table
     * @access private
     * @return string
     */
    
private function _update_query($tableName, &$data)
    {
        
$setQuery = array();
        foreach (
$data as $field => &$value)
        {
            
$setQuery[] = '`' $field '` = :' $field;
        }
        return 
'UPDATE ' $this->_prefix $tableName '
                  SET ' 
implode(', '$setQuery);
    }

    
/**
     * Generates prepared SELECT query string
     *
     * @param string $tableName
     * @param array  $data         A key-value pair with values that correspond to the fields of the table
     * @access private
     * @return string
     */
    
private function _select_query($tableName, &$data)
    {
        
$joins '';
        if ( ! empty(
$this->_joins))
        {
            foreach (
$this->_joins as $k => &$join)
            {
                
$exploded explode('='$join[1]);
                
$join_cond '`' $this->_prefix implode('`.`'explode('.'trim($exploded[0]))) . '` = `' $this->_prefix implode('`.`'explode('.'trim($exploded[1]))) . '`';   
                
$joins .= ' INNER JOIN `' $this->_prefix $join[0] . '` ON ' $join_cond;
            }
            
$this->_joins NULL;
            
$this->_joins = array();
        }
        
$fields = empty($data) ? '*' '`' implode('`, `'array_values($data)) . '`';
        return 
'SELECT ' $fields '
                  FROM `' 
$this->_prefix $tableName '`' $joins;
    }

    
/**
     * Generates prepared DELETE query string
     *
     * @param string $tableName
     * @access private
     * @return string
     */
    
private function _delete_query($tableName)
    {
        return 
'DELETE FROM `' $this->_prefix $tableName '`';
    }

    
/**
     * Binds data to the prepared statement
     *
     * @param object $stmt A PDOStatement object
     * @param array  $data A key-value pair to be bound with the statement
     * @access private
     * @return object
     */
    
private function _bind_data(&$stmt, &$data)
    {
        if ( ! empty(
$data))
        {
            foreach (
$data as $field => &$value)
            {
                
$stmt->bindParam(':' $field$value);
            }   
        }
        return 
$this;
    }
}

?>

--------------------------------------

30 Dec.

Hi,

Please be informed that the database table chibifur_adopts2.adopts_settings is missing in your database .
Please restore your complete database.

Regards,
Diwakar

--------------------------------------

It wasn't there. I re-uploaded it from one of my backups.

http://fc09.deviantart.net/fs70/f/20...sh-d5qpmur.png


---------------------------------------

Hi ,

We have checked your database but the Table 'chibifur_adopts2.adopts_settings' does not exist in it.

But /home/chibifur/public_html/classes/class_database.php script requires such a table.

Please contact your developer regarding this.


Regards,
Diwakar

---------------------------------------


We are now at the point where we may have to close down the site because of all of this and are begging for help.

Hall of Famer 03-24-2013 05:01 PM

well there is nothing wrong with the database class file, it has been untouched since Mys v1.3.1 and it still works the same way in Mys v1.3.3. Did you check from phpmyadmin whether the table prefix_settings has the necessary entries? It may be present but is actually an empty table?

Anyway, what error message do you get exactly on your site? Also you may want to check your config.php file to see if anything is abnormal from there. I wont be surprised if your host does not really understand the situation at all.

GuardiansWish 03-24-2013 05:23 PM

From what I can see, the table is fine but I'm pretty lost when it coes to the database and I generally leave it alone other than making back ups. An yea, I was getting that feeling too.

heres the error:

Fatal error: Uncaught exception 'Exception' with message 'Database error 1054 - Unknown column 'ip' in 'where clause'' in /home/chibifur/public_html/classes/class_database.php:161 Stack trace: #0 /home/chibifur/public_html/classes/class_database.php(81): Database->_query('online', Array, 'select', 'username = 'Vis...') #1 /home/chibifur/public_html/classes/class_online.php(57): Database->select('online', Array, 'username = 'Vis...') #2 /home/chibifur/public_html/inc/init.php(33): Online->update() #3 /home/chibifur/public_html/index.php(3): require('/home/chibifur/...') #4 {main} thrown in /home/chibifur/public_html/classes/class_database.php on line 161

Hall of Famer 03-24-2013 08:58 PM

umm is this the only error message you get? Looks like there is something wrong with the who's online system, it is not supposed to be loading the column IP for guest users. But if I recall correctly, your site was running Mys v1.3.1 wasnt it? Why do you get error message with a class available in Mys v1.3.2? Did you try to upgrade? If so, it seems to me that the upgrade failed.

GuardiansWish 03-24-2013 09:55 PM

We were running 1.3.1 and tried to get to 1.3.2.

It worked for a few days and then went down. We were one of the first sites to get it up. I don't know if there are any other errors hiding because we can't get to the other pages. If it did fail, what does that mean for the site? Is there a way to go back down, re-upgrade, go to 1.3.3 or something along those lines? Or is there a way to possibly fix the error without such drastic measures.

Hall of Famer 03-24-2013 10:35 PM

I see, so it was indeed due to a failed upgrade. Yes you can always reupgrade, but keep in mind that you need to run the upgrader script, do not just upload files to overwrite old files and expect everything to work. It does seem to me that you are missing some database columns made available in Mys v1.3.2.

GuardiansWish 03-25-2013 01:41 AM

After discussion with my fellow admins, we tied to update again to 1.3.2 but it failed. We have gone ahead and started from scratch and plan to do so with 1.3.3. We thank you for doing your best to help us with this matter <3

Hall of Famer 03-25-2013 06:17 AM

Well I wonder why your upgrade failed in the first place? Did you happen to modify your script files? I mean, by editing the php files? If so, you will have to manually upgrade the script rather than go for the shortcut upgrader approach.

GuardiansWish 03-25-2013 08:11 AM

I'm not quuite sure. We hadn't modified anything but the template for our skin and it was up for a few days and running decently smoothly before it crashed on us.


All times are GMT -5. The time now is 10:41 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.