Jump to content
MakeWebGames

Tutorial: v2 - v1 Conversion


Cyanide

Recommended Posts

To convert a v2 mod to work with v1:

Open the file you want to convert and find:

include "globals.php";
 

 

replace that with:

require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm);
$h->menuarea();
 

 

now you will need to change all the sql querys to look like the mccodes v1 querys:

examples:

v1 query:

mysql_query("UPDATE users SET exp=exp+{$exga}, energy=0 WHERE gang={$ir['gang']}", $c);
 

 

v2 query:

$db->query("SELECT * FROM users WHERE userid={$_POST['userid']}");
 

 

when you are done the v2 query should look like this:

mysql_query("SELECT * FROM users WHERE userid={$_POST['userid']}");
 

 

*note* there are fast ways to do this using dreamweaver or wordpad*

Using DreamWeaver:

Press CTRL+F, this will bring up the search / replace function

type this in the first box:

$db->
 

 

type this in the replace with box:

mysql_
 

 

click replace all, and you're done.

Using Wordpad:

press CTRL+H

this will bring up the replace menu

 

type this in the find what box:

$db->
 

 

type this in the replace with box:

mysql_
 

 

click ok and you're done.

I hope this helps someone out.

Link to comment
Share on other sites

Re: Tutorial: v2 - v1 Conversion

Not being mean..just putting up a simpler thing..

Convert V2 to V1

To convert from v2 to v1 you will need to simply do the opposite of the conversion from v1 to v2.

In the v2 version find:

 

include "globals.php";
 

 

And replace with:

 

session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
 

 

Find all the places where it says:

 

$db->query
 

 

And replace it with:

 

mysql_query
 

 

Then you're done!

Feel free to contact me..

[email protected]

Link to comment
Share on other sites

  • 1 month later...

Re: Tutorial: v2 - v1 Conversion

assuming your mysql.php file (or whatever the file that contains your mysql connection is call) is included in your cron file, and assuming the variable containing the connection is named $c, you can change:

$db->query

to

mysql_query

and add in a second argument to the function i.e., mysql_query($string, $c) instead of $db->query($string)

Link to comment
Share on other sites

  • 1 month later...
  • 5 weeks later...
  • 3 weeks later...

Re: Tutorial: v2 - v1 Conversion

Right, so...

 

include "globals.php";
becomes
session_start();
require_once __DIR__.'/mysql.php';
global $c;
require_once __DIR__.'/global_func.php';
if (!array_key_exists('loggedin', $_SESSION) or 0 == $_SESSION['loggedin']) {
    exit(header('Location: /login.php'));
}
$userid = array_key_exists('userid', $_SESSION) && ctype_digit($_SESSION['userid']) && $_SESSION['userid'] > 0 ? $_SESSION['userid'] : null;
$is = mysql_query('SELECT u.*, us.*
    FROM users AS u
    INNER JOIN userstats AS us ON u.userid = us.userid
    WHERE u.userid = '.$userid, $c) or die(mysql_error());
if (!mysql_num_rows($is)) {
    session_unset();
    session_destroy();
    exit(header('Location: /login.php'));
}
$ir = mysql_fetch_assoc($is);
check_level();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
require_once __DIR__.'/header.php';
$h = new headers();
$h->startheaders();
$h->userdata($ir, $lv, $fm, $cm);
$h->menuarea();
 
include "sglobals.php";
becomes
session_start();
require_once __DIR__.'/mysql.php';
global $c;
require_once __DIR__.'/global_func.php';
if (!array_key_exists('loggedin', $_SESSION) or 0 == $_SESSION['loggedin']) {
    exit(header('Location: /login.php'));
}
$userid = array_key_exists('userid', $_SESSION) && ctype_digit($_SESSION['userid']) && $_SESSION['userid'] > 0 ? $_SESSION['userid'] : null;
$is = mysql_query('SELECT u.*, us.*
    FROM users AS u
    INNER JOIN userstats AS us ON u.userid = us.userid
    WHERE u.userid = '.$userid, $c) or die(mysql_error());
if (!mysql_num_rows($is)) {
    session_unset();
    session_destroy();
    exit(header('Location: /login.php'));
}
$ir = mysql_fetch_assoc($is);
if(!in_array($ir['user_level'], array(2, 3, 5))) {
    exit(header('Location: /index.php'));
}
require_once __DIR__.'/header.php';
$h = new headers();
$h->startheaders();
check_level();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
$h->userdata($ir, $lv, $fm, $cm);
$h->smenuarea();

 
$db->query
becomes
mysql_query

 
$db->fetch_row
becomes
mysql_fetch_assoc

 
$db->num_rows
becomes
mysql_num_rows
 

 

$db->fetch_single
becomes
mysql_result
 
Link to comment
Share on other sites

Re: Tutorial: v2 - v1 Conversion

 

Right so...

 

include "globals.php";

 

becomes

 

session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();

 

$db->query

 

becomes

 

mysql_query

 

$db->fetch_row

 

becomes

 

mysql_fetch_array

 

$db->num_rows

 

becomes

 

mysql_num_rows

 

$db->fetch_single

 

becomes

 

mysql_fetch_object

 

$db->result

 

becomes

 

mysql_result

 

Lol, maybe someone will come up with more :-P

Link to comment
Share on other sites

Re: Tutorial: v2 - v1 Conversion

oh yeah thanks to MTG for this

but this might help some newbie coders if you take that whole v1 part from the session start down to the mainmenu part put into a file called v1.php and just edit it like when u convert v2 to v1 put

<?

include "v1.php";

something like that it will help you loads than haveing all that codeing in there

Link to comment
Share on other sites

  • 2 weeks later...

Re: Tutorial: v2 - v1 Conversion

Ok it says i have a error on lines 258 and 268 someone tell me what they are i havent found any .... :?

 

here is lines

254-269

function gang_forums_viewtopic()
{
global $ir,$c,$userid,$gangdata;
$tpcd=mysql_query("SELECT t.*,u1.* FROM gangforums_topics t LEFT JOIN users u1 ON t.gft_userid=u1.userid WHERE t.gft_id={$_GET['t']}",$c);
mysql_query("UPDATE gangforums_topics SET gft_views=gft_views+1 WHERE gft_id={$_GET['t']}",$c);
$topic=mysql_fetch_array($tpcd);
$posts[0]['username']=$topic['username'];
$posts[0]['userid']=$topic['userid'];
$posts[0]['time']=$topic['gft_starttime'];
$posts[0]['level']=$topic['level'];
$posts[0]['nr']=1;
$posts[0]['text']=str_replace("\n","
",$topic['gft_text']);
$cntr=0;
$pq=mysql_query("SELECT r.*,u.* FROM gangforums_replies r LEFT JOIN users u ON r.gfr_userid=u.userid WHERE r.gfr_topic={$_GET['t']} ORDER BY gfr_posttime ASC;",$c);
while($r=mysql_fetch_array($pq))
{
Link to comment
Share on other sites

Re: Tutorial: v2 - v1 Conversion

 

Ok it says i have a error on lines 258 and 268 someone tell me what they are i havent found any .... :?

 

here is lines

254-269

function gang_forums_viewtopic()
{
global $ir,$c,$userid,$gangdata;
$tpcd=mysql_query("SELECT t.*,u1.* FROM gangforums_topics t LEFT JOIN users u1 ON t.gft_userid=u1.userid WHERE t.gft_id={$_GET['t']}",$c);
mysql_query("UPDATE gangforums_topics SET gft_views=gft_views+1 WHERE gft_id={$_GET['t']}",$c);
$topic=mysql_fetch_array($tpcd);
$posts[0]['username']=$topic['username'];
$posts[0]['userid']=$topic['userid'];
$posts[0]['time']=$topic['gft_starttime'];
$posts[0]['level']=$topic['level'];
$posts[0]['nr']=1;
$posts[0]['text']=str_replace("\n","
",$topic['gft_text']);
$cntr=0;
$pq=mysql_query("SELECT r.*,u.* FROM gangforums_replies r LEFT JOIN users u ON r.gfr_userid=u.userid WHERE r.gfr_topic={$_GET['t']} ORDER BY gfr_posttime ASC;",$c);
while($r=mysql_fetch_array($pq))
{

 

Have you added the Structure table?

Link to comment
Share on other sites

Re: Tutorial: v2 - v1 Conversion

that is all you basiaclly need i gave u the error lines and a few extra that is the whole function that is messing up but atm i ave just restord my orginal when this has been fixed i will re do what i was doing :-)

Link to comment
Share on other sites

  • 3 months later...

Re: Tutorial: v2 - v1 Conversion

LMAO you have no idea what he is saying....

Does your DB match that Info on the page....

is there gft_views in the table gangforums_topics???

Tell the error...dont just say error..

crap the error could be..

 

Internet Explore could not connect to website

 

for as far as we know, lol...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...