diff -wurN org/torrentflux_1.5/html/admin.php torrentflux_1.5/html/admin.php --- org/torrentflux_1.5/html/admin.php 2004-11-05 07:18:14.000000000 +0100 +++ torrentflux_1.5/html/admin.php 2005-08-14 22:07:07.000000000 +0200 @@ -288,10 +288,10 @@ $max = $min+$offset; $output = ""; - $sql = "SELECT cid, user_id, file, action, ip, ip_resolved, user_agent, time FROM tf_log WHERE ".$sqlForSearch."action!='".$cfg["constants"]["hit"]."' ORDER BY time desc LIMIT ".$min.", ".$offset; + $sql = "SELECT cid, user_id, file, action, ip, ip_resolved, user_agent, time FROM tf_log WHERE ".$sqlForSearch."action!='".$cfg["constants"]["hit"]."' ORDER BY time desc LIMIT ".$min." OFFSET ".$offset; - $result = mysql_query($sql); - while(list($cid, $user_id, $file, $action, $ip, $ip_resolved, $user_agent, $time) = mysql_fetch_row($result)) + $result = SqlQuery($sql); + while(list($cid, $user_id, $file, $action, $ip, $ip_resolved, $user_agent, $time) = SqlFetchRow($result)) { $user_icon = "images/user_offline.gif"; if (IsOnline($user_id)) @@ -447,8 +447,8 @@ $total_activity = GetActivityCount(); $sql= "SELECT user_id, hits, last_visit, time_created, user_level FROM tf_users ORDER BY user_id"; - $result = mysql_query($sql); - while(list($user_id, $hits, $last_visit, $time_created, $user_level) = mysql_fetch_row($result)) + $result = SqlQuery($sql); + while(list($user_id, $hits, $last_visit, $time_created, $user_level) = SqlFetchRow($result)) { $user_activity = GetActivityCount($user_id); @@ -560,8 +560,8 @@ $total_activity = GetActivityCount(); $sql= "SELECT user_id, hits, last_visit, time_created, user_level, hide_offline, theme, language_file FROM tf_users WHERE user_id='".$user_id."'"; - $result = mysql_query($sql); - list($user_id, $hits, $last_visit, $time_created, $user_level, $hide_offline, $theme, $language_file) = mysql_fetch_row($result); + $result = SqlQuery($sql); + list($user_id, $hits, $last_visit, $time_created, $user_level, $hide_offline, $theme, $language_file) = SqlFetchRow($result); $user_type = _NORMALUSER; if ($user_level == 1) diff -wurN org/torrentflux_1.5/html/config.php torrentflux_1.5/html/config.php --- org/torrentflux_1.5/html/config.php 2004-11-14 07:05:51.000000000 +0100 +++ torrentflux_1.5/html/config.php 2005-08-14 22:08:04.000000000 +0200 @@ -26,6 +26,7 @@ /**************************************************************************/ // YOUR DATABASE CONNECTION INFORMATION /**************************************************************************/ +$cfg["db_driver"] = "postgres"; // Type of database server (postgres or mysql) $cfg["db_host"] = "localhost"; // DB host computer name or IP $cfg["db_name"] = "torrentflux"; // Name of the Database $cfg["db_user"] = "user"; // username for your MySQL database diff -wurN org/torrentflux_1.5/html/functions.php torrentflux_1.5/html/functions.php --- org/torrentflux_1.5/html/functions.php 2004-11-08 19:08:11.000000000 +0100 +++ torrentflux_1.5/html/functions.php 2005-08-14 22:07:28.000000000 +0200 @@ -22,34 +22,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -// Start Session and grab user -session_start(); -$cfg["user"] = strtolower($_SESSION['user']); - -// Create Connection. -$connect = @mysql_connect($cfg["db_host"], $cfg["db_user"], $cfg["db_pass"]); -if (!$connect) { - die ('Could not connect to database: '.mysql_error().'
Check your database settings in the config.php file.'); -} -$select_db = @mysql_select_db($cfg["db_name"]); -if (!$select_db) { - die ('Could not use database '.$cfg["db_name"].': '.mysql_error().'
Check your database settings in the config.php file.'); -} - -Authenticate(); - -include_once("language/".$cfg["language_file"]); -include_once("themes/".$cfg["theme"]."/index.php"); -AuditAction($cfg["constants"]["hit"], $_SERVER['PHP_SELF']); -PruneDB(); - -// is there a stat and torrent dir? If not then it will create it. -checkTorrentPath(); +include_once("sql.php"); //********************************************************************************** // START FUNCTIONS HERE //********************************************************************************** + //********************************************************* // avddelete() function avddelete($file) @@ -85,20 +64,20 @@ if(!isset($_SESSION['user'])) { - header('location: login.php'); + header('Location: login.php'); exit(); } if ($_SESSION['user'] == md5($cfg["pagetitle"])) { // user changed password and needs to login again - header('location: logout.php'); + header('Location: logout.php'); exit(); } $sql = "SELECT uid, hits, hide_offline, theme, language_file FROM tf_users WHERE user_id='".$cfg['user']."'"; - $result = mysql_query($sql); - if(mysql_numrows($result) != 1) + $result = SqlQuery($sql); + if(SqlNumRows($result) != 1) { AuditAction($cfg["constants"]["error"], "FAILED AUTH: ".$cfg['user']); session_destroy(); @@ -106,7 +85,7 @@ exit(); } - list($uid, $hits, $cfg["hide_offline"], $cfg["theme"], $cfg["language_file"]) = mysql_fetch_row($result); + list($uid, $hits, $cfg["hide_offline"], $cfg["theme"], $cfg["language_file"]) = SqlFetchRow($result); // Check for valid theme if (!ereg('^[^./][^/]*$', $cfg["theme"])) @@ -135,7 +114,7 @@ $hits++; - $result = mysql_query("UPDATE tf_users SET hits=".$hits.", last_visit='".$create_time."', theme='".$cfg["theme"]."', language_file='".$cfg["language_file"]."' WHERE uid=".$uid); + $result = SqlQuery("UPDATE tf_users SET hits=".$hits.", last_visit='".$create_time."', theme='".$cfg["theme"]."', language_file='".$cfg["language_file"]."' WHERE uid=".$uid); } @@ -148,10 +127,10 @@ $host_resolved = gethostbyaddr($cfg['ip']); $create_time = time(); - $sql = "insert into tf_log values (NULL, '".$cfg['user']."', '".$file."', '".$action."', '".$cfg['ip']."', '".$host_resolved."', '".$_SERVER['HTTP_USER_AGENT']."', '".$create_time."')"; + $sql = "insert into tf_log (user_id, file, action, ip, ip_resolved, user_agent, time) values ('".$cfg['user']."', '".$file."', '".$action."', '".$cfg['ip']."', '".$host_resolved."', '".$_SERVER['HTTP_USER_AGENT']."', '".$create_time."')"; // add record to the log - $result = mysql_query($sql); + $result = SqlQuery($sql); } //********************************************************* @@ -167,20 +146,20 @@ if($to_all == 1) { $message .= "\n\n__________________________________\n*** "._MESSAGETOALL." ***"; - $result = mysql_query("select user_id from tf_users"); - while(list($user) = mysql_fetch_row($result)) + $result = SqlQuery("select user_id from tf_users"); + while(list($user) = SqlFetchRow($result)) { - $sql = "insert into tf_messages values (NULL, '".$user."', '".$from_user."', '".$message."', 1, '".$cfg['ip']."', '".$create_time."', ".$force_read.")"; + $sql = "insert into tf_messages (to_user, from_user, message, \"new\", ip, time, force_read) values ('".$user."', '".$from_user."', '".$message."', 1, '".$cfg['ip']."', '".$create_time."', ".$force_read.")"; - $result2 = mysql_query($sql); + $result2 = SqlQuery($sql); } } else { // Only Send to one Person - $sql = "insert into tf_messages values (NULL, '".$to_user."', '".$from_user."', '".$message."', 1, '".$cfg['ip']."', '".$create_time."', ".$force_read.")"; + $sql = "insert into tf_messages (to_user, from_user, message, \"new\", ip, time, force_read) values ('".$to_user."', '".$from_user."', '".$message."', 1, '".$cfg['ip']."', '".$create_time."', ".$force_read.")"; - $result = mysql_query($sql); + $result = SqlQuery($sql); } } @@ -191,7 +170,7 @@ Global $cfg; $create_time = time(); $sql = "INSERT INTO tf_users VALUES (NULL, '".strtolower($newUser)."', '".md5($pass1)."', 0, '".$create_time."', '".$create_time."', ".$userType.", ".$cfg["hide_offline"].", '".$cfg["default_theme"]."', '".$cfg["default_language"]."')"; - $result = mysql_query($sql); + $result = SqlQuery($sql); } //********************************************************* @@ -200,11 +179,11 @@ global $cfg; // Prune LOG $testTime = time()-($cfg['days_to_keep'] * 86400); // 86400 is one day in seconds - $result = mysql_query("delete from tf_log where time < '$testTime'"); + $result = SqlQuery("delete from tf_log where time < '$testTime'"); unset($result); $testTime = time()-($cfg['minutes_to_keep'] * 60); - $result = mysql_query("delete from tf_log where time < '$testTime' and action='".$cfg["constants"]["hit"]."'"); + $result = SqlQuery("delete from tf_log where time < '$testTime' and action='".$cfg["constants"]["hit"]."'"); unset($result); } @@ -215,7 +194,7 @@ $online = false; $sql = "SELECT count(*) FROM tf_log WHERE user_id='".$user."' AND action='".$cfg["constants"]["hit"]."'"; - list($number_hits) = mysql_fetch_row(mysql_query($sql)); + list($number_hits) = SqlFetchRow(SqlQuery($sql)); if ($number_hits > 0) { @@ -232,7 +211,7 @@ $isUser = false; $sql = "SELECT count(*) FROM tf_users WHERE user_id='".$user."'"; - list($number_users) = mysql_fetch_row(mysql_query($sql)); + list($number_users) = SqlFetchRow(SqlQuery($sql)); if ($number_users > 0) { @@ -251,7 +230,7 @@ // Check log to see what user has a history with this file $sql = "SELECT user_id FROM tf_log WHERE file='".$file."' AND (action='".$cfg["constants"]["file_upload"]."' OR action='".$cfg["constants"]["url_upload"]."') ORDER BY time DESC"; - list($user_id) = mysql_fetch_row(mysql_query($sql)); + list($user_id) = SqlFetchRow(SqlQuery($sql)); if($user_id != "") { $rtnValue = $user_id; @@ -268,7 +247,7 @@ $sql = "SELECT url FROM tf_links WHERE lid=".$lid; - list($rtnValue) = mysql_fetch_row(mysql_query($sql)); + list($rtnValue) = SqlFetchRow(SqlQuery($sql)); return $rtnValue; } @@ -281,7 +260,7 @@ $sql = "SELECT url FROM tf_rss WHERE rid=".$rid; - list($rtnValue) = mysql_fetch_row(mysql_query($sql)); + list($rtnValue) = SqlFetchRow(SqlQuery($sql)); return $rtnValue; } @@ -312,7 +291,7 @@ } $sql = "SELECT count(*) FROM tf_log WHERE ".$for_user."(action='".$cfg["constants"]["file_upload"]."' OR action='".$cfg["constants"]["url_upload"]."')"; - list($count) = mysql_fetch_row(mysql_query($sql)); + list($count) = SqlFetchRow(SqlQuery($sql)); return $count; } @@ -344,7 +323,7 @@ } $sql = "SELECT user_level FROM tf_users WHERE user_id='".$user."'"; - list($user_level) = mysql_fetch_row(mysql_query($sql)); + list($user_level) = SqlFetchRow(SqlQuery($sql)); if ($user_level >= 1) { @@ -367,7 +346,7 @@ } $sql = "SELECT user_level FROM tf_users WHERE user_id='".$user."'"; - list($user_level) = mysql_fetch_row(mysql_query($sql)); + list($user_level) = SqlFetchRow(SqlQuery($sql)); if ($user_level > 1) { @@ -385,7 +364,7 @@ $rtnValue = false; $sql = "SELECT count(*) FROM tf_messages WHERE to_user='".$cfg["user"]."' AND force_read=1"; - list($count) = mysql_fetch_row(mysql_query($sql)); + list($count) = SqlFetchRow(SqlQuery($sql)); if ($count >= 1) { @@ -402,7 +381,7 @@ $sql = "select from_user, message, ip, time, force_read from tf_messages where mid=".$mid." and to_user='".$cfg['user']."'"; - return mysql_fetch_row(mysql_query($sql)); + return SqlFetchRow(SqlQuery($sql)); } // *************************************************************************** @@ -472,7 +451,7 @@ Global $cfg; $sql = "delete from tf_messages where mid=".$mid." and to_user='".$cfg['user']."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); } @@ -481,7 +460,7 @@ function deleteOldLink($lid) { $sql = "delete from tf_links where lid=".$lid; - $result = mysql_query($sql); + $result = SqlQuery($sql); } // *************************************************************************** @@ -489,7 +468,7 @@ function deleteOldRSS($rid) { $sql = "delete from tf_rss where rid=".$rid; - $result = mysql_query($sql); + $result = SqlQuery($sql); } // *************************************************************************** @@ -497,11 +476,11 @@ function DeleteThisUser($user_id) { $sql = "DELETE FROM tf_users WHERE user_id='".$user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); // Now cleanup any message this person may have had $sql = "DELETE FROM tf_messages WHERE to_user='".$user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); } // *************************************************************************** @@ -521,19 +500,19 @@ } $sql = "UPDATE tf_users SET user_id='".$user_id."', ".$setter." user_level=".$userType.", hide_offline=".$hideOffline." WHERE user_id='".$org_user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); // if the original user id and the new id do not match, we need to update messages and log if ($user_id != $org_user_id) { $sql = "UPDATE tf_messages SET to_user='".$user_id."' WHERE to_user='".$org_user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); $sql = "UPDATE tf_messages SET from_user='".$user_id."' WHERE from_user='".$org_user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); $sql = "UPDATE tf_log SET user_id='".$user_id."' WHERE user_id='".$org_user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); } } @@ -542,7 +521,7 @@ function changeUserLevel($user_id, $level) { $sql = "UPDATE tf_users SET user_level=".$level." where user_id='".$user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); } // *************************************************************************** @@ -551,7 +530,7 @@ { Global $cfg; - mysql_query("update tf_messages set new=0, force_read=0 where mid=".$mid); + SqlQuery("update tf_messages set \"new\"=0, force_read=0 where mid=".$mid); } @@ -559,7 +538,7 @@ // addNewLink - Add New Link function addNewLink($newLink) { - mysql_query("INSERT INTO tf_links VALUES (NULL, '".$newLink."')"); + SqlQuery("INSERT INTO tf_links VALUES (NULL, '".$newLink."')"); } @@ -567,7 +546,7 @@ // addNewRSS - Add New RSS Link function addNewRSS($newRSS) { - mysql_query("INSERT INTO tf_rss VALUES (NULL, '".$newRSS."')"); + SqlQuery("INSERT INTO tf_rss VALUES (NULL, '".$newRSS."')"); } // *************************************************************************** @@ -590,7 +569,7 @@ $sql = "UPDATE tf_users SET ".$setter." hide_offline=".$hideOffline.", theme='".$theme."', language_file='".$language."' WHERE user_id='".$user_id."'"; - $result = mysql_query($sql); + $result = SqlQuery($sql); } @@ -602,8 +581,8 @@ $user_array = array(); - $result = mysql_query("select user_id from tf_users order by user_id"); - while(list($user) = mysql_fetch_row($result)) + $result = SqlQuery("select user_id from tf_users order by user_id"); + while(list($user) = SqlFetchRow($result)) { array_push($user_array, $user); } @@ -619,8 +598,8 @@ $link_array = array(); - $result = mysql_query("SELECT lid, url FROM tf_links ORDER BY lid"); - while(list($lid, $link) = mysql_fetch_row($result)) + $result = SqlQuery("SELECT lid, url FROM tf_links ORDER BY lid"); + while(list($lid, $link) = SqlFetchRow($result)) { $link_array[$lid] = $link; } @@ -636,8 +615,8 @@ $link_array = array(); - $result = mysql_query("SELECT rid, url FROM tf_rss ORDER BY rid"); - while(list($rid, $link) = mysql_fetch_row($result)) + $result = SqlQuery("SELECT rid, url FROM tf_rss ORDER BY rid"); + while(list($rid, $link) = SqlFetchRow($result)) { $link_array[$rid] = $link; } @@ -774,8 +753,8 @@ echo " "; // Does the user have messages? - $sql = "select count(*) from tf_messages where to_user='".$cfg['user']."' and new=1"; - list($number_messages) = mysql_fetch_row(mysql_query($sql)); + $sql = "select count(*) from tf_messages where to_user='".$cfg['user']."' and \"new\"=1"; + list($number_messages) = SqlFetchRow(SqlQuery($sql)); if ($number_messages > 0) { // We have messages @@ -1361,4 +1340,22 @@ } +// Start Session and grab user +session_start(); +$cfg["user"] = strtolower($_SESSION['user']); + +// Create Connection. +SqlConnect($cfg["db_driver"], $cfg["db_host"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_name"]); + +Authenticate(); + +include_once("language/".$cfg["language_file"]); +include_once("themes/".$cfg["theme"]."/index.php"); +AuditAction($cfg["constants"]["hit"], $_SERVER['PHP_SELF']); +PruneDB(); + +// is there a stat and torrent dir? If not then it will create it. +checkTorrentPath(); + + ?> diff -wurN org/torrentflux_1.5/html/history.php torrentflux_1.5/html/history.php --- org/torrentflux_1.5/html/history.php 2004-11-05 07:18:14.000000000 +0100 +++ torrentflux_1.5/html/history.php 2005-08-14 22:07:07.000000000 +0200 @@ -58,10 +58,10 @@ $max = $min+$offset; $output = ""; - $sql = "SELECT user_id, file, time FROM tf_log WHERE action='".$cfg["constants"]["url_upload"]."' OR action='".$cfg["constants"]["file_upload"]."' ORDER BY time desc LIMIT ".$min.", ".$offset; + $sql = "SELECT user_id, file, time FROM tf_log WHERE action='".$cfg["constants"]["url_upload"]."' OR action='".$cfg["constants"]["file_upload"]."' ORDER BY time desc LIMIT ".$min." OFFSET ".$offset; - $result = mysql_query($sql); - while(list($user_id, $file, $time) = mysql_fetch_row($result)) + $result = SqlQuery($sql); + while(list($user_id, $file, $time) = SqlFetchRow($result)) { $user_icon = "images/user_offline.gif"; if (IsOnline($user_id)) diff -wurN org/torrentflux_1.5/html/login.php torrentflux_1.5/html/login.php --- org/torrentflux_1.5/html/login.php 2004-11-07 08:37:34.000000000 +0100 +++ torrentflux_1.5/html/login.php 2005-08-14 22:07:36.000000000 +0200 @@ -24,6 +24,7 @@ session_start(); include("config.php"); +include("sql.php"); include("themes/".$cfg["default_theme"]."/index.php"); global $cfg; if(isset($_SESSION['user'])) @@ -112,36 +113,27 @@ // Check for user if(!empty($user) && !empty($iamhim)) { - // Create Connection. - $connect = @mysql_connect($cfg["db_host"], $cfg["db_user"], $cfg["db_pass"]); - if (!$connect) { - die ('Could not connect to database: '.mysql_error().'
Check your database settings in the config.php file.'); - } - $select_db = @mysql_select_db($cfg["db_name"]); - if (!$select_db) { - die ('Could not use database '.$cfg["db_name"].': '.mysql_error().'
Check your database settings in the config.php file.'); - } - + SqlConnect($cfg["db_driver"], $cfg["db_host"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_name"]); /* First User check */ $sql = "SELECT count(*) FROM tf_users"; - list($user_count) = mysql_fetch_row(mysql_query($sql)); + list($count)=SqlFetchRow(SqlQuery($sql)); - if($user_count == 0) - { + if($count == 0) { + echo "Creating a new user"; // This user is first in DB. Make them super admin. // this is The Super USER, add them to the user table - $sql = "INSERT INTO tf_users VALUES (NULL, '".$user."', '".md5($iamhim)."', 1, '".$create_time."', '".$create_time."', 2, 0, '".$cfg["default_theme"]."', '".$cfg["default_language"]."')"; - $result = mysql_query($sql); + $sql = "INSERT INTO tf_users (user_id, password, hits, last_visit, time_created, user_level, hide_offline, theme, language_file) VALUES ('".$user."', '".md5($iamhim)."', 1, '".$create_time."', '".$create_time."', 2, 0, '".$cfg["default_theme"]."', '".$cfg["default_language"]."')"; + $result = SqlQuery($sql); } $sql = "SELECT uid, hits, hide_offline, theme, language_file FROM tf_users WHERE user_id='".$user."' AND password='".md5($iamhim)."'"; - $result = mysql_query($sql); - list($uid, $hits, $cfg["hide_offline"], $cfg["theme"], $cfg["language_file"]) = mysql_fetch_row($result); - if(mysql_numrows($result)==1) + $result = SqlQuery($sql); + list($uid, $hits, $cfg["hide_offline"], $cfg["theme"], $cfg["language_file"]) = SqlFetchRow($result); + if(SqlNumRows($result)==1) { // Add a hit to the user $hits++; - $result = mysql_query("UPDATE tf_users SET hits=".$hits.", last_visit='".$create_time."', theme='".$cfg["theme"]."', language_file='".$cfg["language_file"]."', shutdown='".$cfg["shutdown"]."', upload_rate='".$cfg["upload_rate"]."' WHERE uid=".$uid); + $result = SqlQuery("UPDATE tf_users SET hits=".$hits.", last_visit='".$create_time."', theme='".$cfg["theme"]."', language_file='".$cfg["language_file"]."', shutdown='".$cfg["shutdown"]."', upload_rate='".$cfg["upload_rate"]."' WHERE uid=".$uid); $_SESSION['user'] = $user; header("location: index.php"); exit(); @@ -212,10 +204,10 @@ $host_resolved = gethostbyaddr($cfg['ip']); $create_time = time(); - $sql = "insert into tf_log values (NULL, '".$cfg['user']."', '".$file."', '".$action."', '".$cfg['ip']."', '".$host_resolved."', '".$_SERVER['HTTP_USER_AGENT']."', '".$create_time."')"; + $sql = "insert into tf_log (user_id,file,action,ip,ip_resolved,user_agent,time) values ('".$cfg['user']."', '".$file."', '".$action."', '".$cfg['ip']."', '".$host_resolved."', '".$_SERVER['HTTP_USER_AGENT']."', '".$create_time."')"; // add record to the log - $result = mysql_query($sql); + $result = SqlQuery($sql); } ?> diff -wurN org/torrentflux_1.5/html/logout.php torrentflux_1.5/html/logout.php --- org/torrentflux_1.5/html/logout.php 2004-11-05 07:18:14.000000000 +0100 +++ torrentflux_1.5/html/logout.php 2005-08-14 22:07:44.000000000 +0200 @@ -23,6 +23,7 @@ */ +include_once("sql.php"); include_once("config.php"); // Start Session and grab user @@ -30,14 +31,7 @@ $cfg["user"] = strtolower($_SESSION['user']); // Create Connection. -$connect = @mysql_connect($cfg["db_host"], $cfg["db_user"], $cfg["db_pass"]); -if (!$connect) { - die ('Could not connect to database: '.mysql_error().'
Check your database settings in the config.php file.'); -} -$select_db = @mysql_select_db($cfg["db_name"]); -if (!$select_db) { - die ('Could not use database '.$cfg["db_name"].': '.mysql_error().'
Check your database settings in the config.php file.'); -} +SqlConnect($cfg["db_driver"], $cfg["db_host"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_name"]); logoutUser(); session_destroy(); @@ -51,6 +45,6 @@ $sql = "DELETE FROM tf_log WHERE user_id='".$cfg["user"]."' and action='".$cfg["constants"]["hit"]."'"; // do the SQL - $result = mysql_query($sql); + $result = SqlQuery($sql); } ?> \ No newline at end of file diff -wurN org/torrentflux_1.5/html/profile.php torrentflux_1.5/html/profile.php --- org/torrentflux_1.5/html/profile.php 2004-11-05 07:18:14.000000000 +0100 +++ torrentflux_1.5/html/profile.php 2005-08-14 22:07:07.000000000 +0200 @@ -48,8 +48,8 @@ $total_activity = GetActivityCount(); $sql= "SELECT user_id, hits, last_visit, time_created, user_level FROM tf_users WHERE user_id='".$cfg["user"]."'"; - $result = mysql_query($sql); - list($user_id, $hits, $last_visit, $time_created, $user_level) = mysql_fetch_row($result); + $result = SqlQuery($sql); + list($user_id, $hits, $last_visit, $time_created, $user_level) = SqlFetchRow($result); $user_type = _NORMALUSER; if (IsAdmin()) diff -wurN org/torrentflux_1.5/html/readmsg.php torrentflux_1.5/html/readmsg.php --- org/torrentflux_1.5/html/readmsg.php 2004-11-05 07:18:14.000000000 +0100 +++ torrentflux_1.5/html/readmsg.php 2005-08-14 22:07:07.000000000 +0200 @@ -80,8 +80,8 @@ echo ""; $sql = "SELECT mid, from_user, message, new, ip, time, force_read FROM tf_messages WHERE to_user='".$cfg['user']."' ORDER BY time"; - $result = mysql_query($sql); - while(list($mid, $from_user, $message, $new, $ip, $time, $force_read) = mysql_fetch_row($result)) + $result = SqlQuery($sql); + while(list($mid, $from_user, $message, $new, $ip, $time, $force_read) = SqlFetchRow($result)) { if($new == 1) { diff -wurN org/torrentflux_1.5/html/sql.php torrentflux_1.5/html/sql.php --- org/torrentflux_1.5/html/sql.php 1970-01-01 01:00:00.000000000 +0100 +++ torrentflux_1.5/html/sql.php 2005-08-14 22:07:07.000000000 +0200 @@ -0,0 +1,63 @@ +Check your database settings in the config.php file.'); + } + $select_db = @mysql_select_db($db); + if (!$select_db) { + die ('Could not use database '.$db.': '.SqlError().'
Check your database settings in the config.php file.'); + } + } else if ($driver == "postgres") { + $dbc = @pg_connect("host=$host user=$user password=$passwd dbname=$db"); + if (!$dbc) { + die ('Could not connect to database: '.SqlError().'
Check your database settings in the config.php file.'); + } + } +} + +function SqlError() { + global $dbc, $db_driver; + + if ($db_driver=="mysql") + return @mysql_error(); + else if ($db_driver=="postgres") + return @pg_errormessage($dbc); +} + +function SqlQuery($query) { + global $db_driver; + + if ($db_driver=="mysql") + $result=@mysql_query($query); + else if ($db_driver=="postgres") + $result=@pg_query($query); + return $result; +} + + +function SqlFetchRow($result) { + global $db_driver; + + if ($db_driver=="mysql") + return @mysql_fetch_row($result); + else if ($db_driver=="postgres") + return @pg_fetch_row($result); +} + + +function SqlNumRows($result) { + global $db_driver; + + if ($db_driver=="mysql") + return mysql_numrows($result); + else if ($db_driver=="postgres") + return pg_num_rows($result); +} + +?> diff -wurN org/torrentflux_1.5/html/test.php torrentflux_1.5/html/test.php --- org/torrentflux_1.5/html/test.php 1970-01-01 01:00:00.000000000 +0100 +++ torrentflux_1.5/html/test.php 2005-08-14 22:07:07.000000000 +0200 @@ -0,0 +1,4 @@ + diff -wurN org/torrentflux_1.5/sql/postgres.sql torrentflux_1.5/sql/postgres.sql --- org/torrentflux_1.5/sql/postgres.sql 1970-01-01 01:00:00.000000000 +0100 +++ torrentflux_1.5/sql/postgres.sql 2005-08-14 22:07:07.000000000 +0200 @@ -0,0 +1,100 @@ +-- TorrentFlux 1.3 Database Script +-- Only run this for a new Installation. +-- If you are upgrading please read the INSTALL File + +-- +-- Table structure for table `tf_links` +-- + +CREATE TABLE tf_links ( + lid SERIAL NOT NULL, + url varchar(255) NOT NULL default '', + PRIMARY KEY (lid) +); + +-- +-- Dumping data for table `tf_links` +-- + +INSERT INTO tf_links VALUES (1, 'http://www.suprnova.org'); +INSERT INTO tf_links VALUES (2, 'http://www.torrentbits.org'); +INSERT INTO tf_links VALUES (3, 'http://varchars.com/rss/'); +INSERT INTO tf_links VALUES (4, 'http://www.litezone.com'); +INSERT INTO tf_links VALUES (5, 'http://www.torrentflux.com'); +INSERT INTO tf_links VALUES (6, 'http://www.imdb.com'); +-- -------------------------------------------------------- + +-- +-- Table structure for table `tf_log` +-- + +CREATE TABLE tf_log ( + cid SERIAL NOT NULL, + user_id varchar(32) NOT NULL default '', + file varchar(200) NOT NULL default '', + action varchar(200) NOT NULL default '', + ip varchar(128) NOT NULL default '', + ip_resolved varchar(200) NOT NULL default '', + user_agent varchar(200) NOT NULL default '', + time varchar(14) NOT NULL default '0', + PRIMARY KEY (cid) +); + + +-- +-- Table structure for table `tf_messages` +-- + +CREATE TABLE tf_messages ( + mid SERIAL NOT NULL, + to_user varchar(32) NOT NULL default '', + from_user varchar(32) NOT NULL default '', + message text, + "new" int NOT NULL default '1', + ip varchar(128) NOT NULL default '', + time varchar(14) NOT NULL default '0', + force_read int default '0', + PRIMARY KEY (mid) +); + + +-- +-- Table structure for table `tf_rss` +-- + +CREATE TABLE tf_rss ( + rid SERIAL NOT NULL, + url varchar(255) NOT NULL default '', + PRIMARY KEY (rid) +); + +-- +-- Dumping data for table `tf_rss` +-- + +INSERT INTO tf_rss VALUES (1, 'http://www.tvtorrents.net/rss.php'); +INSERT INTO tf_rss VALUES (2, 'http://btefnet.com/backend.php'); +INSERT INTO tf_rss VALUES (3, 'http://varchars.com/rss/suprnova-tv.rss'); +-- -------------------------------------------------------- + +-- +-- Table structure for table `tf_users` +-- + +CREATE TABLE tf_users ( + uid SERIAL NOT NULL, + user_id varchar(32) NOT NULL default '', + password varchar(34) NOT NULL default '', + hits int NOT NULL default '0', + last_visit varchar(14) NOT NULL default '0', + time_created varchar(14) NOT NULL default '0', + user_level int NOT NULL default '0', + hide_offline int NOT NULL default '0', + theme varchar(100) NOT NULL default 'mint', + language_file varchar(60) default 'lang-english.php', + PRIMARY KEY (uid) +); + + + +