Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #1  
Old 29th April 2021, 18:09
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default function dbconn
Hello all,


need little help here, so these fuctions need to be mysqli


Code:
function dbconn_announce() {
    global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;

    if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass))
    {
        die('dbconn: mysql_connect: ' . mysql_error());
    }
    mysql_query("SET NAMES UTF8");
    mysql_query("SET collation_connection = 'utf8_general_ci'");
    mysql_query("SET sql_mode=''");
    mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error());
}

and this one


Code:
function dbconn($autoclean = false)
{
    global $lang_functions;
    global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;
    global $useCronTriggerCleanUp;

    if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass))
    {
        switch (mysql_errno())
        {
            case 1040:
            case 2002:
                die("<html><head><meta http-equiv=refresh content=\"10 $_SERVER[REQUEST_URI]\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>".$lang_functions['std_server_load_very_high']."</h3></td></tr></table></body></html>");
            default:
                die("[" . mysql_errno() . "] dbconn: mysql_connect: " . mysql_error());
        }
    }
    mysql_query("SET NAMES UTF8");
    mysql_query("SET collation_connection = 'utf8_general_ci'");
    mysql_query("SET sql_mode=''");
    mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error());

    userlogin();

    if (!$useCronTriggerCleanUp && $autoclean) {
        register_shutdown_function("autoclean");
    }
}
and this one

Code:
function sql_query($query)
{
	global $query_name;
	$query_name[] = $query;
	return mysql_query($query);
}
Thank you for help

Last edited by elvira; 29th April 2021 at 20:16.
Reply With Quote
  #2  
Old 30th April 2021, 00:52
darkalchemy darkalchemy is offline
Administrator
 
Join Date: Dec 2017
United States
Posts: 101
Default
Without doing the rewrite for you, start by changing mysql to mysqli, in the code.

The connection signature changes to this:
Code:
mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db);
Also, I would move these to you mysql.conf file, it will save you 3 queries with every connection.
Code:
mysql_query("SET NAMES UTF8");
mysql_query("SET collation_connection = 'utf8_general_ci'");
mysql_query("SET sql_mode=''");
and you can remove this, as it's now part of the connection signature, saving another query with every connection.
Code:
mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error());
Also, you will need to pass the database connection to mysqli_query like:
Code:
mysqli_query($db, $query);
You can make the $db connection a global or fetch it as needed.
Reply With Quote
  #3  
Old 30th April 2021, 09:28
xblade's Avatar
xblade xblade is offline
Cod3r
 
Join Date: Nov 2020
P2P
Posts: 239
Default
also this will not work on seedbox and home pc torrents On cleanups
you will get DB locks on it via mysqli it will only work on PHP 5.6 NOT 7.0 SO ON

PHP Code:
    $fields explode(":""comments:leechers:seeders");
    
$res sql_query("SELECT id, seeders, leechers, comments FROM torrents");
    while (
$row mysqli_fetch_assoc($res)) {
        
$id $row["id"];
        
$torr $torrents[$id];
        foreach (
$fields as $field) {
            if (!isset(
$torr[$field]))
                
$torr[$field] = 0;
        }
        
$update = array();
        foreach (
$fields as $field) {
            if (
$torr[$field] != $row[$field])
                
$update[] = "$field = " $torr[$field];
        }
        if (
count($update))
            
sql_query("UPDATE torrents SET " implode(","$update) . " WHERE id = $id");
    } 
Reply With Quote
  #4  
Old 30th April 2021, 18:05
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default
I have something like this


Code:
function dbconn($autoclean = false)
{
    global $lang_functions;
    global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;
    global $useCronTriggerCleanUp;

    if (!@($GLOBALS["___mysqli_ston"] = mysqli_connect($mysql_host, $mysql_user, $mysql_pass, $mysql_db)))
    {
        switch (((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)))
        {
            case 1040:
            case 2002:
                die("<html><head><meta http-equiv=refresh content=\"10 $_SERVER[REQUEST_URI]\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>".$lang_functions['std_server_load_very_high']."</h3></td></tr></table></body></html>");
            default:
                die("[" . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)) . "] dbconn: mysql_connect: " . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
        }
    }
    mysqli_query($GLOBALS['___mysqli_ston'], "SET NAMES UTF8");
    mysqli_query($GLOBALS['___mysqli_ston'], "SET collation_connection = 'utf8_general_ci'");
    mysqli_query($GLOBALS['___mysqli_ston'], "SET sql_mode=''");
    //mysql_select_db($mysql_db) or die('dbconn: mysql_select_db: ' + mysql_error());
   ((bool)mysqli_query($GLOBALS['___mysqli_ston'], "USE " . $mysql_db)) or die('dbconn: mysql_select_db: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));

    userlogin();

    if (!$useCronTriggerCleanUp && $autoclean) {
        register_shutdown_function("autoclean");
    }
}
Reply With Quote
  #5  
Old 2nd May 2021, 08:59
xblade's Avatar
xblade xblade is offline
Cod3r
 
Join Date: Nov 2020
P2P
Posts: 239
Default
what TBDev are u using this would help me with you ?
Reply With Quote
  #6  
Old 2nd May 2021, 09:22
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 111
Default
Quote:
Originally Posted by elvira View Post
Hello all,
need little help here, so these fuctions need to be mysqli
....
Thank you for help
https://myrusakov.ru/php-connect-db.html

Reply With Quote
  #7  
Old 7th May 2021, 10:03
firefly007's Avatar
firefly007 firefly007 is offline
SUPPORT GURU
 
Join Date: Jun 2010
P2P
Posts: 721
Default
Quote:
Originally Posted by budgie View Post
also this will not work on seedbox and home pc torrents On cleanups
you will get DB locks on it via mysqli it will only work on PHP 5.6 NOT 7.0 SO ON

PHP Code:
    $fields explode(":""comments:leechers:seeders");
    
$res sql_query("SELECT id, seeders, leechers, comments FROM torrents");
    while (
$row mysqli_fetch_assoc($res)) {
        
$id $row["id"];
        
$torr $torrents[$id];
        foreach (
$fields as $field) {
            if (!isset(
$torr[$field]))
                
$torr[$field] = 0;
        }
        
$update = array();
        foreach (
$fields as $field) {
            if (
$torr[$field] != $row[$field])
                
$update[] = "$field = " $torr[$field];
        }
        if (
count($update))
            
sql_query("UPDATE torrents SET " implode(","$update) . " WHERE id = $id");
    } 
If you dont already know MYSQL is deprecated in later PHP -V. As pointed out by other users in this post u need to use MYSQLI.

Good luck!
__________________




Please Support Majority Report


You can contact me on Skype live:phesadent.elect but please let me know first.


If you are ever need me desperately then please email me at dan.oak44@gmail.com and I will contact u within a week.


Due to free time I'm able to help interested member's with their tracker.

Please Note!
Depending on your requests I will charge you for my assistance for Tracker installs and mods.
All my mods are custom and prices will very depending on the request.
I'm able to install any tracker and mods including themes.

Please PM me

Reply With Quote
  #8  
Old 7th May 2021, 10:18
xblade's Avatar
xblade xblade is offline
Cod3r
 
Join Date: Nov 2020
P2P
Posts: 239
Default
i do get where u are coming from i use mysqli all the time in the code base its set to mysqli but this part not working at all well when it first uploader works ok till clean up.. as someone said above its could be the memory so on but its not nor table locking ive done my checks on this in DB to no locking at all and the memory is all good

i could add this to backend
PHP Code:
((mysqli_free_result($res1) || (is_object($res1) && (get_class($res1) == "mysqli_result"))) ? true false); 
then add to cleanup too
works ok then stop seeding its still there no good like this
Reply With Quote
  #9  
Old 7th May 2021, 10:25
firefly007's Avatar
firefly007 firefly007 is offline
SUPPORT GURU
 
Join Date: Jun 2010
P2P
Posts: 721
Default
I presume you have enough space on the partition? DB can lockup if there's no space Look I will have to have a look to really find what is going on.
__________________




Please Support Majority Report


You can contact me on Skype live:phesadent.elect but please let me know first.


If you are ever need me desperately then please email me at dan.oak44@gmail.com and I will contact u within a week.


Due to free time I'm able to help interested member's with their tracker.

Please Note!
Depending on your requests I will charge you for my assistance for Tracker installs and mods.
All my mods are custom and prices will very depending on the request.
I'm able to install any tracker and mods including themes.

Please PM me

Reply With Quote
  #10  
Old 7th May 2021, 10:27
xblade's Avatar
xblade xblade is offline
Cod3r
 
Join Date: Nov 2020
P2P
Posts: 239
Default
yes i do a alot of it

i was on Debian 8 was working fine seeding and all, and all then they removed it so i had to go with Debian 9 and that when it all started on cleanup.. all the code base is mysqli nps on that everything works on but that part in clean up
Reply With Quote
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 18:16. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.