Author Topic: TGPX Updated to PHP5.4-5.5  (Read 3284 times)

0 Members and 1 Guest are viewing this topic.

Offline Zug

  • Newbie
  • *
  • Posts: 35
  • Karma: +12/-0
    • View Profile
    • http://www.teensinporn.biz
TGPX Updated to PHP5.4-5.5
« on: April 22, 2015, 02:19:23 AM »
Looks like someone has been working on TGPX upgrade to current PHP version:

http://gfy.com/fucking-around-and-program-discussion/1160595-tgpx-updated.html

Offline Abixxx

  • New Users
  • Newbie
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #1 on: April 25, 2015, 03:12:44 AM »
Hi
I appreciate their efforts, but the new installation does not work.
I get this error when installing.


Fatal Error
Error:
mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

Trace:
mysql_connect in mysql.class.php on line 39
Connect in install.php on line 174
CreateTables in install.php on line 66
Initialize in install.php on line 379

Offline The Dawg

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #2 on: May 06, 2015, 09:52:46 PM »
I have been trying to update this script myself to work with PHP 5.5.

I have some of it working.  I am hitting a snag displaying galleries.  This function doesn't seem to work:

Code: [Select]
function GetColumns($table, $as_hash = FALSE)
    {
        $columns = array();
        $result = $this->Query('DESCRIBE #', array($table));
        //$field = mysql_field_name($result, 0);
        $field = mysqli_fetch_field_direct($result, 0);

        while( $column = $this->NextRow($result) )
        {
            if( $as_hash )
            {
                $columns[$column[$field]] = $column[$field];
            }
            else
            {
                $columns[] = $column[$fie
            }
        }

        $this->Free($result);

        return $columns;
    }

Gives the illegal offset type error on ($columns[$column[$field]] = $column[$field]; ) line.  I can not find where $column is declared.

I var_dumped $result and it comes back as null.

Any ideas?

Offline frankmonique

  • New Users
  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #3 on: June 27, 2015, 07:28:15 AM »
i have the same problem.

how did you solved id

Offline frans12

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #4 on: July 06, 2015, 02:04:30 PM »
I managed to get thigs working again with the new file here: https://github.com/3UU/TGPX/blob/master/includes/mysql.class.php

But for some reason I can't get the galleries to show up when I want to do a search. Any ideas anyone?

Offline niels

  • New Users
  • Newbie
  • *
  • Posts: 1
  • Karma: +1/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #5 on: July 25, 2015, 02:47:30 PM »
Hi,

I had this problem too. When I looked at the mysql.class.php I noticed a small mistake.

Look up this line (around line 272 in the file):

Code: [Select]
function mysqli_field_name($result){

and change it to:

Code: [Select]
function mysqli_field_name($query){

Kind regards,
Niels

Offline The Dawg

  • Newbie
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #6 on: July 27, 2015, 03:21:13 PM »
Hi,

I had this problem too. When I looked at the mysql.class.php I noticed a small mistake.

Look up this line (around line 272 in the file):

Code: [Select]
function mysqli_field_name($result){

and change it to:

Code: [Select]
function mysqli_field_name($query){

Kind regards,
Niels

Appreciate the help Sir.  Fixed my issue!  :)

Offline amebb

  • New Users
  • Newbie
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #7 on: December 07, 2015, 08:38:51 AM »
Hi there

I am getting the same message as you guys are after installation.

Has anyone resolved this issue or are we all stuck ???

If you have any ideas on how it can be fixed please share ..

Thank you

Offline ppmedia

  • Newbie
  • *
  • Posts: 8
  • Karma: +2/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #8 on: May 27, 2016, 01:38:36 PM »
Hi there

I am getting the same message as you guys are after installation.

Has anyone resolved this issue or are we all stuck ???

If you have any ideas on how it can be fixed please share ..

Thank you

The complete function (around line 272) should be:


function mysqli_field_name($query){
     $retval = array();
     while ($tmp=mysqli_fetch_assoc($query)) {
         $retval[]=$tmp;
     }
     return $retval;
}


Offline ppmedia

  • Newbie
  • *
  • Posts: 8
  • Karma: +2/-0
    • View Profile
Re: TGPX Updated to PHP5.4-5.5
« Reply #9 on: May 27, 2016, 01:39:35 PM »
The complete mysql.class.php should be:

Code: [Select]
<?PHP
// Copyright 2011 JMB Software, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

class DB
{
    var $handle;
    var $hostname;
    var $username;
    var $password;
    var $connected;
    var $database;

    function DB($hostname, $username, $password, $database)
    {
        $this->handle = 0;
        $this->connected = FALSE;
        $this->hostname = $hostname;
        $this->password = $password;
        $this->username = $username;
        $this->database = $database;
    }

    function Connect()
    {
        if( !$this->connected )
        {
            #$this->handle = mysql_connect($this->hostname, $this->username, $this->password, TRUE);
            #$this->SelectDB($this->database);
            $this->handle = mysqli_connect($this->hostname, $this->username, $this->password, $this->database);
            $this->connected = TRUE;
        }
    }

    function IsConnected()
    {
        return $this->connected;
    }

    function Disconnect()
    {
        if( $this->connected )
        {
            mysqli_close($this->handle);
            $this->handle    = 0;
            $this->connected = FALSE;
        }
    }

    function SelectDB($database)
    {
        $this->database = $database;

        if( !mysql_select_db($this->database, $this->handle) )
        {
            trigger_error(mysql_error($this->handle), E_USER_ERROR);
        }
    }

    function Row($query, $binds = array())
    {
        $result = mysqli_query($this->handle,$this->Prepare($query, $binds));

        if( !$result )
        {
            trigger_error(mysqli_error($this->handle) . "<br />$query", E_USER_ERROR);
        }

        $row = mysqli_fetch_assoc($result);

        mysqli_free_result($result);

        return $row;
    }

    function Count($query, $binds = array())
    {
        $query = $this->Prepare($query, $binds);
        $result = mysqli_query($this->handle,$query);

        if( !$result )
        {
            trigger_error(mysqli_error($this->handle) . "<br />$query", E_USER_ERROR);
        }

        $row = mysqli_fetch_row($result);

        mysqli_free_result($result);

        return $row[0];
    }

    function Query($query, $binds = array())
    {
        $query = $this->Prepare($query, $binds);
        $result = mysqli_query($this->handle,$query);

        if( !$result )
        {
            trigger_error(mysqli_error($this->handle) . "<br />$query", E_USER_ERROR);
        }

        return $result;
    }

    function QueryWithPagination($query, $binds = array(), $page = 1, $per_page = 10, $nolimit = FALSE)
    {
        global $C;

        $result = array();

        // Get total number of results
        $count_query = preg_replace('~SELECT .* FROM~', 'SELECT COUNT(*) FROM', $query);
        $result['total'] = $this->Count($count_query, $binds);

        // Calculate pagination
        $result['pages'] = ceil($result['total']/$per_page);
        $result['page'] = min(max($page, 1), $result['pages']);
        $result['limit'] = max(($result['page'] - 1) * $per_page, 0);
        $result['start'] = max(($result['page'] - 1) * $per_page + 1, 0);
        $result['end'] = min($result['start'] - 1 + $per_page, $result['total']);
        $result['prev'] = ($result['page'] > 1);
        $result['next'] = ($result['end'] < $result['total']);

        if( $result['next'] )
            $result['next_page'] = $result['page'] + 1;

        if( $result['prev'] )
            $result['prev_page'] = $result['page'] - 1;

        if( $result['total'] > 0 )
            $result['result'] = $this->Query($query . ($nolimit ? '' : " LIMIT {$result['limit']},{$per_page}"), $binds);
        else
            $result['result'] = FALSE;

        // Format
        $result['fpages'] = number_format($result['pages'], 0, $C['dec_point'], $C['thousands_sep']);
        $result['start'] = number_format($result['start'], 0, $C['dec_point'], $C['thousands_sep']);
        $result['end'] = number_format($result['end'], 0, $C['dec_point'], $C['thousands_sep']);
        $result['ftotal'] = number_format($result['total'], 0, $C['dec_point'], $C['thousands_sep']);

        return $result;
    }

    function &FetchAll($query, $binds = array(), $key = null)
    {
        $all = array();
        $query = $this->Prepare($query, $binds);
        $result = mysqli_query($this->handle,$query);

        if( !$result )
        {
            trigger_error(mysqli_error($this->handle) . "<br />$query", E_USER_ERROR);
        }

        while( $row = mysqli_fetch_assoc($result) )
        {
            if( $key )
            {
                $all[$row[$key]] = $row;
            }
            else
            {
                $all[] = $row;
            }
        }

        return $all;
    }

    function Update($query, $binds = array())
    {
        $query = $this->Prepare($query, $binds);
        $result = mysqli_query($this->handle,$query);

        if( !$result )
        {
            trigger_error(mysqli_error($this->handle) . "<br />$query", E_USER_ERROR);
        }

        return mysqli_affected_rows($this->handle);
    }

    function NextRow($result)
    {
        return mysqli_fetch_assoc($result);
    }

    function Free($result)
    {
        mysqli_free_result($result);
    }

    function InsertID()
    {
        return mysqli_insert_id($this->handle);
    }

    function NumRows($result)
    {
        return mysqli_num_rows($result);
    }

    function FetchArray($result)
    {
        return mysqli_fetch_array($result);
    }

    function Seek($result, $where)
    {
        mysqli_data_seek($result, $where);
    }

    function BindList($count)
    {
        $list = "''";

        if( $count > 0 )
        {
            $list = join(',', array_fill(0, $count, '?'));
        }

        return $list;
    }

    function Prepare($query, &$binds)
    {
        $query_result = '';
        $index = 0;

        $pieces = preg_split('/(\?|#)/', $query, -1, PREG_SPLIT_DELIM_CAPTURE);
        foreach( $pieces as $piece )
        {
            if( $piece == '?' )
            {
                if( $binds[$index] === NULL )
                    $query_result .= 'NULL';
                else if( is_numeric($binds[$index]) )
                    $query_result .= $binds[$index];
                else
                    $query_result .= "'" . mysqli_real_escape_string($this->handle,$binds[$index]) . "'";

                $index++;
            }
            else if( $piece == '#' )
            {
                $binds[$index] = str_replace('`', '\`', $binds[$index]);
                $query_result .= "`" . $binds[$index] . "`";
                $index++;
            }
            else
            {
                $query_result .= $piece;
            }
        }

        return $query_result;
    }

// gibbet nur in den mysql_-Funktionen, daher hier als interne nachgebaut und der Tradition halben mysqli_ genannt
function mysqli_field_name($query){
     $retval = array();
     while ($tmp=mysqli_fetch_assoc($query)) {
         $retval[]=$tmp;
     }
     return $retval;
}

    function GetTables()
    {
        $tables = array();
        $result = $this->Query('SHOW TABLES');
        $field = $this->mysqli_field_name($result);

        while( $row = $this->NextRow($result) )
        {
            $tables[$row[$field]] = $row[$field];
        }

        $this->Free($result);

        return $tables;
    }

    function GetColumns($table, $as_hash = FALSE)
    {
        $columns = array();
        $result = $this->Query('DESCRIBE #', array($table));
        $field = $this->mysqli_field_name($result);

        while( $column = $this->NextRow($result) )
        {
            if( $as_hash )
            {
                $columns[$column[$field]] = $column[$field];
            }
            else
            {
                $columns[] = $column[$field];
            }
        }

        $this->Free($result);

        return $columns;
    }
}

?>

Unofficial JMB Support Forums

Re: TGPX Updated to PHP5.4-5.5
« Reply #9 on: May 27, 2016, 01:39:35 PM »


Tags: tgpx update 
 

Related Topics

  Subject / Started by Replies Last post
9 Replies
2579 Views
Last post August 15, 2014, 04:07:39 PM
by ppmedia
0 Replies
878 Views
Last post October 27, 2012, 09:03:15 AM
by hotndirtybabes
2 Replies
1187 Views
Last post November 11, 2013, 02:06:57 PM
by Chad
1 Replies
1452 Views
Last post September 10, 2015, 03:52:55 AM
by amebb
3 Replies
1648 Views
Last post October 01, 2017, 10:33:36 AM
by jonward55

anything