Little Help On SQL For Mafia Wars Clone Integration

Discussion forum for MOD Writers regarding MOD Development.
Locked
cdodds
Registered User
Posts: 228
Joined: Sat Jul 10, 2010 2:19 am
Name: Don Cdoddsy
Contact:

Little Help On SQL For Mafia Wars Clone Integration

Post by cdodds »

Name of script I am integrating:
Pimp Wars - this is a mafia wars clone which is no longer sold as the business that made it went out of business / shut down their site, but you can still download it / buy old licenses and lots of people still use it. There is already an integration made by someone else, but that integration uses Pimp Wars as the master and phpbb as the slave. Plus there are login issues. I want it the other way around and with no login issues.

Requirements: phpbb with ultimate points mod / UPS, and Pimp Wars are installed on the same database

Integration Features:
* Redirects the original Pimp Wars registration page to a custom phpbb page that auto registers the user using their phpbb user data + a new password entered by the user. If the user is not logged in to phpbb, then it sends them to the phpbb registration page.
* username changes on phpbb will also take place on Pimp Wars
* I plan on writing a script for the UPS (Ulimate Points Shop) that allows users to buy Pimp Wars Cash using Ultimate Points
* Display link to Pimp Wars profile on each users' phpbb profile

I am hoping that if I can get this to work, then I can write other auto registration scripts for phpbb integration. Here is what I have so far:

File: pimp_wars_register.php

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

//Get password parameter from URL
$password = htmlspecialchars($_GET["customer_avi"]);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

//If user is logged in
if ($user->data['user_id'] != ANONYMOUS)
{
	//Check if a password has been sent through the form
	if($password)
	{
		//Get registration data from users data
		$username = $user->data['username'];
		$password = $password;
		$email = $user->data['user_emai'];
		$first = "";
		$last = "";
		$age = time() - $user->data['user_birthday'];
		$messager = "";
		$messager_id = $user->data[''];
		$time = time();
		$REMOTE_ADDR  = $user->data[''];
		$host  = $host=gethostbyaddr("$REMOTE_ADDR");
		$code = md5($username.trucode.$password);
		$time  = $time();
		$referrer  = "";
	
		//Enter new Pimp Wars account data into the database		
		INSERT INTO $tab[user] (username,password,email,fullname,age,messager,online,ip,host,code,membersince,ref_by,status) 
		VALUES ('$username','$password','$email','$first $last','$age','$messager: $messager_id','$time','$REMOTE_ADDR','$host','$code','$time','$referrer'
	 
		//Display Page telling user that registration is complete & link to Pimp Wars
		page_header('Pimp Wars Registration Complete');
		$template->set_filenames(array('body' => 'pimp_wars_registration_complete_body.html',));
	}
	else
	{
		//Display form asking for user's Pimp Wars password
		page_header('Pimp Wars Registration');
		$template->set_filenames(array('body' => 'pimp_wars_registration_body.html',));
	}
//If user is not logged in
else
{
	//Display page with phpbb login form / phpbb registration link
	page_header('Must Be Logged In');
	$template->set_filenames(array('body' => 'pimp_wars_must_login__body.html',));
}

//Display page footer             
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
My problem at the moment is, I am not sure how to properly run the SQL.
Can someone please point me towards a tutorial on running SQL in a phpbb mod?
I know the statements I need to run. I am just not sure of the accepted way of running them in a phpbb mod.
That or perhaps some nice examples?
User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: Little Help On SQL For Mafia Wars Clone Integration

Post by A_Jelly_Doughnut »

To execute an arbitrary SQL query, run the

Code: Select all

$db->sql_query($query);
method.

P.S.: You should use request_var() rather than $_GET to retrieve the password.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish
Locked

Return to “[3.0.x] MOD Writers Discussion”