Jump to content

move php4 script to php5


justmehere

Recommended Posts

I have a php script that was written for php4 and works perfectly.  I want to use it now on php5 with openSUSE linux but most of the script does not react correctly.  I have apache2, mysql and php5 all correctly setup.  Can someone tell me which part is wrong for php5.

 

<?php

 

include("updatesession.php");

include("dbconnect.php");

 

    $status=$HTTP_GET_VARS["status"];

 

function ende() {

mysql_close();

exit();

}

 

$f = $_GET["f"];    // wich function to call

$a = $_GET["a"];    // age

$x = $_GET["x"];    // sex

$fn = $_GET["fn"];  // first name

$co = $_GET["co"];  // country

$e = $_GET["e"];    // email

$pro = $_GET["pr"];  // profile

    $games_won = $_GET["gw"];

    $games_played = $_GET["gp"];

    $login_times = $_GET["lt"];

    $rating = $_GET["rating"];

 

if (!$f=="") {

 

$c = dbconnect();

$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];

 

        if ($f=="player_info")

        {

        // here we write inside the database info about the player

        $u = $_GET["u"];

        $handle = mysql_query("SELECT * FROM user WHERE username='$u'");

        // if you want to add a new game played

        if (isset($games_played) && ($games_played>0)) // if you want to increase the games played

        {

          $games_played = mysql_result($handle,0,"games_played");

          // increase the number of games played

          ++$games_played;

          // insert them into the database

          mysql_query("UPDATE user SET games_played='$games_played' WHERE username='$u'");

        }

        if (isset($games_won) && ($games_won>0))

        {

          $games_won = mysql_result($handle,0,"games_won"); // the actual games won

          // we increase them by one

          ++$games_won;

          // it`s inserted into the database

          mysql_query("UPDATE user SET games_won='$games_won' WHERE username='$u'");

        }

if (isset($login_times) && ($login_times>0))

        {

          $login_times = mysql_result($handle,0,"login_times"); // login times

          // we increase them by one

          ++$login_times;

          // it`s inserted into the database

          mysql_query("UPDATE user SET login_times='$login_times' WHERE username='$u'");

        }

        if (isset($rating))

        {

          $rating2 = mysql_result($handle,0,"player_rating"); // the actual rating

          $rating2 += $rating; // the new rating is added

          // the new rating is inserted into the database

          mysql_query("UPDATE user SET player_rating='$rating2' WHERE user_id='$u'");

        }

        }

        else

        if ($f=="1") {

// signup

// used for a new user to make an account on the poker server

 

$u = $_GET["u"];

$p = $_GET["p"];

$fn = $_GET["fn"];

$act = $_GET["act"];

            $time = time();

$date = date();

 

if (!$u || !$p) {

 

print "3 No username or password specified";

 

}

else {

 

$q = mysql_query("SELECT username FROM user WHERE username='$u'", $c);

 

if ($q=="") {

 

print "0 Internal Server Error";

 

}

else {

$i=mysql_num_rows($q);

 

if ($i==0) {

//Add user info to database

$s = updatesession();

$q = mysql_query("INSERT INTO user SET username='$u', passwd='$p', address='$ip', session='$s', age='$a', gender='$x', country='$co', firstname='$fn', email='$e',signup_date=now('Y-m-d'), profile='$pr'");

$q = mysql_query("INSERT INTO player_info SET player_id='$u', player_pwd='$p', gender='$x', activated='$act'");

            $q = mysql_query("INSERT INTO cams SET cam_name='$u', homepage='http://www.strippokerlive.net', email='$e', cam_url='http://www.strippokerlive.net/CamView/$u.jpg'");

print "2 Signup success";

 

}

else {

 

print "1 Username already exists";

 

}

 

}

}

 

}

elseif ($f=="2") {

// signin

// used for an existing user to sign in to the poker server

 

$u = $_GET["u"];

$p = $_GET["p"];

$reg = $_GET["reg"];

$time = time();

$date= date();

 

//$q = mysql_query("SELECT * FROM player_info WHERE player_id='$u' AND player_pwd='$p' AND activated='Y'", $c);

$q = mysql_query("SELECT * FROM player_info WHERE player_id='$u' AND player_pwd='$p'", $c);

 

$row = mysql_fetch_array($q);

 

if ($q=="") {

print "4 Invalid Username or Password";

}

else {

if ($row['player_id']==$u && $row['player_pwd']==$p) {

 

$s = updatesession();

$q = mysql_query("UPDATE user SET address='$ip', session='$s' WHERE username='$u' AND passwd='$p'");

$q = mysql_query("UPDATE player_info SET login_time=now('Y-m-d') WHERE player_id='$u'");

 

if (!$q) {

print "Login error";

 

}

else {

print "5 Login Successful $s";

}

 

}

else {

print "Login error (invalid username or password)";

 

}

}

 

}

elseif ($f=="3") {

// user ping

// used for the client to ping the database to update listing

 

$u = $_GET["u"];

 

$q = mysql_query("SELECT username FROM user WHERE username='$u' AND address='$ip'", $c);

 

if ($q=="") {

 

print "6 Username non existant or user not logged in";

 

}

else {

 

$row = mysql_fetch_array($q);

 

if ($row['username']==$u) {

 

$s = updatesession();

 

$q = mysql_query("UPDATE user SET session=$s WHERE username='$u' AND address='$ip'");

 

if (!$q) {

print "0 Internal Database Error";

}

else {

print "8 Session Update Successful";

}

 

}

else {

print "7 Invalid Username";

}

 

}

 

}

elseif ($f=="4") {

// signout

// used for an existing user to sign out

 

$u = $_GET["u"];

 

$q = mysql_query("SELECT username FROM user WHERE username='$u' AND address='$ip'", $c);

 

if ($q=="") {

 

print "6 Username non existant or user not logged in";

 

}

else {

 

$row = mysql_fetch_array($q);

 

if ($row['username']==$u) {

 

$s = 0;

 

$q = mysql_query("UPDATE user SET session=$s WHERE username='$u' AND address='$ip'");

 

if (!$q) {

print "0 Internal Database Error";

}

else {

print "9 User disconnected from database successfully";

}

 

}

else {

print "7 Invalid Username";

}

 

}

 

}

elseif ($f=="5") {

// register room

// used for a user to register a new room

 

$u = $_GET["u"];

$r = $_GET["r"];

$d = $_GET["d"];

 

if (!$u || !$r) {

 

print "10 No username or room name specified";

 

}

else {

 

$q = mysql_query("SELECT * FROM roombase WHERE roomname='$r'", $c);

 

$i=mysql_num_rows($q);

 

if ($i==0) {

//add room to database

 

$s = updatesession();

$q = mysql_query("INSERT INTO roombase SET roomname='$r', address='$ip', session='$s', owner='$u', description='$d'");

 

print "2 Room created";

}

else {

print "1 Room already exists";

}

 

}

 

}

elseif ($f=="6") {

// unregister room

// used for a user to unregister a room

 

$u = $_GET["u"]; //username

$r = $_GET["r"]; //roomname

 

if ($u=="" || $r=="") {

print("invalid parameters");

}

else {

$t = mysql_query("DELETE FROM roombase WHERE session<$time", $c);

$q = mysql_query("DELETE FROM roombase WHERE owner='$u' AND roomname='$r'", $c);

 

if (!$q) {

print ("Internal database error");

}

else {

print ("Room unregistered");

}

}

 

}

elseif ($f=="7") {

// room listing

// used to get the listing of currently opened rooms

 

$c = dbconnect();

 

$time = time();

 

$q = mysql_query("DELETE FROM roombase WHERE session<$time", $c);

$q = mysql_query("SELECT * FROM roombase", $c);

 

$i = mysql_num_rows($q);

 

$r = "";

$r = $i." Active rooms".chr(10);

 

for($i=0; $i < mysql_num_rows($q); $i++) {

$row = mysql_fetch_array($q);

if (!$row['roomname']=="") {

$r .= $row['roomname']."|".$row['address'].chr(255).chr(10);

}

}

 

print("$r");

 

 

}

elseif ($f=="8") {

// self address

// gets the address of self to determine whether behind firewall or not

 

print $ip;

 

}

elseif ($f=="9") {

 

$s = updatesession();

$q = mysql_query("UPDATE roombase SET session=$s WHERE roomname='$r'");

 

}

 

elseif ($f=="10") {

// Regiser account

// used for an existing user to register

 

$u = $_GET["u"];

 

$q = mysql_query("SELECT player_id FROM player_info WHERE player_id='$u'", $c);

 

if ($q=="") {

 

print "6 Username non existant or user not logged in";

 

}

else {

               

// if ($status == 1)

 

$row = mysql_fetch_array($q);

 

if ($row['player_id']==$u) {

 

                    $q = mysql_query("UPDATE player_info SET activated='Y' WHERE player_id='$u'");

 

if (!$q) {

print "0 Internal Database Error";

}

else {

print "10 Player registred successfully";

}

 

}

else {

print "7 Invalid Username";

}

 

}

 

}

 

elseif ($f=="11") {

// Activated

// used to to see if user is activated or not

 

$u = $_GET["u"];

//$p = $_GET["p"];

$reg = $_GET["reg"];

 

$q = mysql_query("SELECT * FROM player_info WHERE player_id='$u' AND activated='$reg'", $c);

 

$row = mysql_fetch_array($q);

 

if ($q=="") {

print "6 Invalid Username";

}

else {

if ($row['player_id']==$u && $row['activated']==$reg) {

 

print "12 Activated Yes";

 

}

         

else {

 

print "13 Activated No";

 

}

}

 

}

 

elseif ($f=="12") {

// bulletin board

// used to get the listing for the bulletin board

 

$c = dbconnect();

 

$timed = time();

$date = date();

 

$q = mysql_query("DELETE FROM bulletin WHERE session<$timed", $c);

$q = mysql_query("SELECT * FROM bulletin", $c);

 

$i = mysql_num_rows($q);

 

$r = "";

 

for($i=0; $i < mysql_num_rows($q); $i++) {

$row = mysql_fetch_array($q);

if (!$row['bulletin_text']=="") {

$r .= $row['bulletin_text'].chr(10);

}

}

 

print("$r");

 

}

 

      elseif ($f=="13") {

// Add New Bulletin

// used to add a new listing to the bulletin board

 

$bn = $_GET["bn"];

 

if (!$bn) {

 

print "10 No message to post";

 

}

 

else {

 

$i=mysql_num_rows($q);

 

if ($i==0) {

//add to database

 

$sd = updatesessiondate();

$q = mysql_query("INSERT INTO bulletin SET bulletin_text= '$bn', session='$sd'"); //'$r', address='$ip', session='$s', owner='$u', description='$d'");

 

print "2 Bulletin Posted";

}

else {

print "1 Duplicate Post";

}

 

}

 

}

 

      elseif ($f=="14") {

// room description

// used to get the listing of currently opened rooms

 

$c = dbconnect();

 

$time = time();

 

$q = mysql_query("DELETE FROM roombase WHERE session<$time", $c);

$q = mysql_query("SELECT * FROM roombase", $c);

 

$i = mysql_num_rows($q);

 

$rd = "";

$rd = $i."".chr(10);

 

for($i=0; $i < mysql_num_rows($q); $i++) {

$row = mysql_fetch_array($q);

if (!$row['description']=="") {

$rd .= $row['description'].chr(10);

}

}

 

print("$rd");

 

 

}

 

elseif ($f=="15") {

// Register account

// used for an existing user to register

 

$u = $_GET["u"];

            $st = $_GET["st"];

 

$q = mysql_query("SELECT player_id FROM player_info WHERE player_id='$u'", $c);

 

if ($q=="") {

 

print "6 Username non existant or user not logged in";

 

}

else {

               

// if ($status == 1)

 

$row = mysql_fetch_array($q);

            $st = $_GET["st"];

 

if ($row['player_id']==$u) {

 

                    $q = mysql_query("UPDATE player_info SET mystatus='$st' WHERE player_id='$u'");

 

if (!$q) {

print "0 Internal Database Error";

}

else {

print "10 Player status updated successfully";

}

 

}

else {

print "7 Invalid Username";

}

 

}

 

}

 

elseif ($f=="16") {

// Get Status

// used to to get players status

 

$u = $_GET["u"];

$st = $_GET["st"];

 

$q = mysql_query("SELECT * FROM player_info WHERE player_id='$u' AND mystatus='$st'", $c);

 

$row = mysql_fetch_array($q);

 

if ($q=="") {

print "6 Invalid Username";

}

else {

if ($row['player_id']==$u && $row['mystatus']==$st) {

 

print "1 Online";

 

}

         

else {

 

print "2 Away";

 

}

}

 

}

 

elseif ($f=="17") {

// Check Version

// used to check latest version of strip poker live

 

$v = $_GET["v"];

 

$q = mysql_query("SELECT * FROM updates WHERE version='$v'", $c);

 

$row = mysql_fetch_array($q);

 

if ($q=="") {

print "6 Invalid Version Number";

}

else {

 

if ($row['version']==$v) {

 

print "1 No Update Available";

 

}

    else {

        print "2 Update Available";

 

}

 

}

 

}

 

elseif ($f=="18") {

// Check Version

// used to check latest version of strip poker live

 

$ds = $_GET["ds"];

 

$q = mysql_query("SELECT * FROM ftpserver WHERE ftp='$ds'", $c);

 

$row = mysql_fetch_array($q);

 

if ($q=="") {

print "6 ERROR";

}

else {

 

if ($row['ftp']==1) {

 

print "1 ftp server1";

 

}

    else {

        print "1 ftp server2";

 

}

 

}

 

}

 

elseif ($f=="19") {

// Add Player Signed In

// used to show player signed in

 

$u = $_GET["u"];

 

if (!$u) {

 

print "10 No username specified";

 

}

else {

 

$q = mysql_query("SELECT * FROM players_online WHERE userid='$u'", $c);

 

$i=mysql_num_rows($q);

 

if ($i==0) {

//add user id to database

 

$s = updatesession();

$q = mysql_query("INSERT INTO players_online SET userid='$u'");

 

print "2 user added";

}

else {

print "1 user already exists";

}

 

}

 

}

elseif ($f=="20") {

// remove player from online list

// used remove player from users online list

 

$u = $_GET["u"]; //username

//$r = $_GET["st"]; //status

 

if ($u=="") {

print("invalid parameters");

}

else {

$q = mysql_query("DELETE FROM players_online WHERE userid='$u'", $c);

 

if (!$q) {

print ("Internal database error");

}

else {

print ("User Removed");

}

}

 

}

 

elseif ($f=="21") {

// users listing

// used to get the listing of users online

 

$c = dbconnect();

 

$q = mysql_query("SELECT * FROM players_online", $c);

 

$i = mysql_num_rows($q);

 

$r = "";

 

for($i=0; $i < mysql_num_rows($q); $i++) {

$row = mysql_fetch_array($q);

if (!$row['userid']=="") {

$r .= $row['userid'].chr(10);

}

}

 

print("$r");

 

 

}

 

elseif ($f=="22") {

// registration

// used for a new user to register an account on the poker server

 

$u = $_GET["u"];

$e = $_GET["e"];

$hn = $_GET["hn"];

      $ba = $_GET["ba"];

      $ao = $_GET["ao"];

      $co = $_GET["co"];

      $st = $_GET["st"];

      $zp = $_GET["zp"];

      $cn = $_GET["cn"];

      $ed = $_GET["ed"];

      $cv = $_GET["cv"];

      $pv = $_GET["pv"];

      $ct = $_GET["ct"];

      $time = time();

$date = date();

 

if (!$u) {

      // !$hn|| !$ba || !$co|| !$st|| !$zp|| !$cn || !$ed) {

 

print "1 Information MIssing Please try again";

 

}

else {

 

$q = mysql_query("SELECT user_id FROM registration WHERE user_id='$u'", $c);

 

if ($q=="") {

 

print "0 Internal Server Error";

 

}

else {

$i=mysql_num_rows($q);

 

if ($i==0) {

 

//Add user info to database

$s = updatesession();

$q = mysql_query("INSERT INTO registration SET user_id='$u', email='$e',holder_name='$hn',billing_address='$ba',apt_other='$ao',country='$co',state='$st',zip='$zp',ccn='$cn',exp_date='$ed',CVC='$cv',province='$pv',city='$ct',signup_date=now('Y-m-d')",$c);

 

print "2 Registration success";

 

}

else {

            // Update User Information

            $row = mysql_fetch_array($q);

 

if ($row['user_id']==$u) {

 

            $q = mysql_query("UPDATE registration SET user_id='$u', email='$e',holder_name='$hn',billing_address='$ba',apt_other='$ao',country='$co',state='$st',zip='$zp',ccn='$cn',exp_date='$ed',CVC='$cv',province='$pv',city='$ct' ,signup_date=now('Y-m-d') WHERE user_id='$u'");

            print "3 Registration updated successfully";

 

            }

 

}

 

}

}

 

}

 

elseif ($f=="23") {

// Add New Date for schedule game

// used to add a new listing to the scheduled game

 

$sd = $_GET["sd"];

$st = $_GET["st"];

$pt = $_GET["pt"];

      $p1 = $_GET["p1"];

      $p2 = $_GET["p2"];

      $p3 = $_GET["p3"];

      $p4 = $_GET["p4"];

 

if (!$sd) {

 

print "10 No message to post";

 

}

 

else {

 

$i=mysql_num_rows($q);

 

if ($i==0) {

//add to database

 

$q = mysql_query("INSERT INTO game_schedule SET Date= '$sd', Time= '$st', Player_Type='$pt', Host='$p1', Seat1='$p2', Seat2='$p3', Seat3='$p4'");

 

print "2 Posted";

}

else {

print "1 Duplicate Post";

}

 

}

 

}

 

elseif ($f=="24") {

// scheduled games list

// used to get the listing for the scheduled games

 

$c = dbconnect();

 

$sd = $_GET["sd"];

$st = $_GET["st"];

$pt = $_GET["pt"];

      $p1 = $_GET["p1"];

      $p2 = $_GET["p2"];

      $p3 = $_GET["p3"];

      $p4 = $_GET["p4"];

 

//$timed = time();

//$date = date();

 

//$q = mysql_query("DELETE FROM bulletin WHERE session<$timed", $c);

$q = mysql_query("SELECT * FROM game_schedule", $c);

 

$i = mysql_num_rows($q);

 

$r = "";

 

for($i=0; $i < mysql_num_rows($q); $i++) {

$row = mysql_fetch_array($q);

if (!$row['Date']=="") {

        $r .= $row['Host'].$row['Date'].$row['Time'].$row['Player_Type'].chr(10);

}

}

 

print("$r");

 

}

 

elseif ($f=="25") {

// scheduled games list seat

// used to add a player to a seat

 

  $h  = $_GET["h"];

  $u  = $_GET["u"];

 

 

{

 

$i=mysql_num_rows($q);

 

if ($i==0) {

//add to database

 

mysql_query("UPDATE game_schedule SET Seat1='$u' WHERE host='$h'");

print "2 Posted";

}

else {

print "1 Duplicate Post";

}

 

}

 

}

 

elseif ($f=="26") {

// scheduled games list seat

// used to add a player to a seat

 

  $h  = $_GET["h"];

  $u  = $_GET["u"];

 

 

{

 

$i=mysql_num_rows($q);

 

if ($i==0) {

//add to database

 

mysql_query("UPDATE game_schedule SET Seat2='$u' WHERE host='$h'");

print "2 Posted";

}

else {

print "1 Duplicate Post";

}

 

}

 

}

 

 

elseif ($f=="27") {

// scheduled games list seat

// used to add a player to a seat

 

  $h  = $_GET["h"];

  $u  = $_GET["u"];

 

{

 

$i=mysql_num_rows($q);

 

if ($i==0) {

//add to database

 

mysql_query("UPDATE game_schedule SET Seat3='$u' WHERE host='$h'");

print "2 Posted";

}

else {

print "1 Duplicate Post";

}

 

}

 

}

 

    elseif ($f=="28") {

// Update register room

// used to inform users that room is closed

 

$u = $_GET["u"];

$r = $_GET["r"];

$d = $_GET["d"];

 

if (!$u || !$r) {

 

print "10 No username or room name specified";

 

}

else {

 

{

//add room to database

 

$s = updatesession();

$q = mysql_query("UPDATE roombase SET roomname='$r', address='$ip', session='$s', owner='$u', description='$d' WHERE owner='$u'");

 

print "2 Room created";

}

 

}

 

}

 

mysql_close();

 

}

else {

 

print "<html><font face=arial size=2><b>All is good</b></html>";

 

}

 

ende();

 

?>

Link to comment
https://forums.phpfreaks.com/topic/134296-move-php4-script-to-php5/
Share on other sites

Please post the code in [ code ][ /code ] tags (without the spaces or use # menu icon on the forum edit window) so that someone will help you.

 

There are very few incompatible changes in going from php4 to php5. Most php4 code will work as is under php5 given the same php.ini configuration. Most problems will be due to php configuration differences and code that uses old depreciated features that have been turned off and/or removed in php5.

 

Start by trying your code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini (stop and start your web server to get any changes made to php.ini to take effect.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.