PRICE: $75/copy
A few people have inquired about this script and I have developed it a bit further. mostly bug fixes but a few bug fixes.
Heres the latest list of features:
To create games, go to http://www.orpgcreator.com
To view my demo account visit: http://www.hehrpg.com/Sim/
user: testing
pass: testing
This is an admin account
This scritp allows "anyone" to create there own game with simple data entry which is hosted on one of owners domains.
The script requires mod rewrite and uses OOP techniques and uses smarty templating. All php and html code is seperate.
Game Owners can do the following:
Read oRPG Creator News
Vote in oRPG Creator Polls
Create/Manage Tasks (quest, crimes, missions)
Create/Manage Items with images
Create/Manage Bot's (NPC's) with images
Create/Manage Levels
Create/Manage Custom Pages
Change Banner
Change Name of Task/Gold/Turns/# of turns starting with/# of turns regenerated every few minutes
Create News
View/Delete Players
View some Basic Stats
Game Players Can:
Complete Task(quest, crimes, missions)
Purchase Items
Equip Items
Battle Bots (NPC's)
Battle Other Players
View Player Stats
View Events (When a task is complete, or when attacked)
View Homepage (game activity feed)
Level up now!!
Distribute Stats upon leveling up
Refer Friends via referral link
View Top Players
Change Avatar
Master Admin Panel
Create News For Game Owners
Create Polls For Game Owners
Mass eMail Owners/Players
View Games
Add new domain (like hehrpg.com)
misc notes
HTML emails are sent during orpgcreator registration activation email and welcome emails
Some code samples:
Code samples: Partial User class:
<?
include "includes/constants.php";
class user
{
//vars
private $db;
private $smarty;
//place holder
function __autoload()
{
}
public function __construct($dbRef, $smartyRef)
{
$this->db = $dbRef;
$this->smarty = $smartyRef;
//see what we doing here.
//login, register, forgot password, or reset password
switch ($_GET['action'])
{
case "activate":
$this->userActivate();
break;
case "forgot":
$this->userResetPass();
break;
case "login":
$this->userLogin();
break;
case "logout":
session_destroy();
$_SESSION[$_SESSION['game'] . '_msg'] = "You are now logged out...";
header("Location: " . $_SESSION[$_SESSION['game'] . '_url'] . "/");
break;
case "register":
$this->userRegister();
break;
case "resend":
$this->userResendCode();
break;
}
$this->smarty->assign("msg", $_SESSION[$_SESSION['game'] . '_msg']);
unset($_SESSION[$_SESSION['game'] . '_msg']);
}
//attempt to login user
public function userLogin()
{
//check if username pass string test
if($this->checkUser() == true && $this->checkPass() == true)
{
//query to check if user name or email in use
$pass = sha1(strtoupper($_POST['textUser']) . $_POST['textPass1']);
$rec = $this->db->fetch("SELECT userImage, userLogins, userID, userHandle, userActCode, userRank, COUNT(userID) as ammount FROM " . USER_TABLE . " WHERE userHandle='" . $this->db->escape($_POST['textUser']) . "' AND userPass='" . $this->db->escape($pass) . "' AND userGameRefID='" . $_SESSION[$_SESSION['game'] . '_userGameID'] . "'");
//user name and password match
if($rec['ammount'] == 1)
{
//user account activated
if($rec['userActCode'] == 0)
{
//session
$_SESSION[$_SESSION['game'] . '_userID'] = $rec['userID'];
$_SESSION[$_SESSION['game'] . '_userRank'] = $rec['userRank'];
$_SESSION[$_SESSION['game'] . '_userImage'] = $rec['userImage'];
$_SESSION[$_SESSION['game'] . '_userHandle'] = $rec['userHandle'];
//update last activitity
$data = array("userLastActive" => time(), "userLogins" => $rec['userLogins']+1, "userLastIP" => $_SERVER['SERVER_ADDR']);
$this->db->update(USER_TABLE, $data, "userID='" . $rec['userID'] . "'");
header("Location: " . $_SESSION[$_SESSION['game'] . '_url'] . "/game/feeds/");
}
else
{
//display error
$_SESSION[$_SESSION['game'] . '_msg'] = "You must first activate your account...";
}
}
else
{
//display error
$_SESSION[$_SESSION['game'] . '_msg'] = "Incorrect User name and password combination...";
}
}
}
//attempt to register user
public function userRegister()
{
//check if username, password, email pass string test
if($this->checkUser() == true && $this->checkEmail() == true)
{
//query to check if user name or email in use
$rec = $this->db->fetch("SELECT COUNT(userID) AS ammount FROM " . USER_TABLE . " WHERE userGameRefID='" . $_SESSION[$_SESSION['game'] . '_userGameID'] . "' AND (userHandle='" . $this->db->escape($_POST['textUser']) . "' OR userEmail='" . $this->db->escape($_POST['textEmail']) . "')");
//user name and email not in use
if($rec['ammount'] == 0)
{
if($_POST['textPass1'] == $_POST['textPass2'])
{
//encrypt pass
$pass = sha1(strtoupper($_POST['textUser']) . $_POST['textPass1']);
//query to check if email verification is set
$rec = $this->db->fetch("SELECT settingResult FROM " . SETTINGS_TABLE . " WHERE settingType='actRequired' AND settingGameRefID='" . $_SESSION[$_SESSION['game'] . '_userGameID'] . "'");
//activation required
if($rec['settingResult'] == 'y')
{
//set activation code
$code = rand(10000, 99999);
//insert userdata
$data = array("userGameRefID" => $_SESSION[$_SESSION['game'] . '_userGameID'], "userHandle" => $_POST['textUser'], "userEmail" => $_POST['textEmail'], "userPass" => $pass, "userRegDate" => time(), "userActCode" => $code);
$this->db->insert(USER_TABLE, $data);
//dispatch activation email
$this->userEmail($_POST['textEmail'], array("url", "user", "code"), array($_SESSION[$_SESSION['game'] . '_url'], $_POST['textUser'], $code), $type = "activate");
//display msg
$_SESSION[$_SESSION['game'] . '_msg'] = "Account successfully created. You must first activate your account before logging in...";
}
else
{
//activation not required. insert user. log user in
$data = array("userGameRefID" => $_SESSION[$_SESSION['game'] . '_userGameID'], "userHandle" => $_POST['textUser'], "userEmail" => $_POST['textEmail'], "userPass" => $pass, "userRegDate" => time(), "userActCode" => 0);
$this->db->insert(USER_TABLE, $data);
$rec = $this->db->fetch("SELECT userID FROM " . USER_TABLE . " ORDER BY userID DESC LIMIT 1");
//create user character
$this->createChar($rec['userID']);
//dispatch welcome email(thanks)
$this->userEmail($_POST['textEmail'], array("url", "user"), array($_SESSION[$_SESSION['game'] . '_url'], $_POST['textUser']), $type = "thanks");
//log user in
$this->userLogin();
}
}
else
{
//display error
$_SESSION[$_SESSION['game'] . '_msg'] = "Passwords do not match...";
}
}
else
{
//display error
$_SESSION[$_SESSION['game'] . '_msg'] = "User name and/or email address is allready in use...";
}
}
}
//create users character
public function createChar($userID)
{
$rec2 = $this->db->fetch("SELECT settingResult FROM " . SETTINGS_TABLE . " WHERE settingType='turnMax' AND settingGameRefID='" . $_SESSION[$_SESSION['game'] . '_userGameID'] . "'");
//insert character data
$data = array("charGameRefID" => $_SESSION[$_SESSION['game'] . "_userGameID"], "charUserID" => $userID, "charTurnsLeft" => $rec2['settingResult'], "charTurnsMax" => $rec2['settingResult']);
$this->db->insert(CHAR_TABLE, $data);
}
admin file for adding/managing/deleting levels
<?
include "../includes/constants.php";
class levels
{
//vars
private $db;
private $smarty;
private $game_id;
public function __construct($dbRef, $smartyRef, $gameRefID)
{
//vars
$this->db = $dbRef;
$this->smarty = $smartyRef;
$this->game_id = $gameRefID;
//if inserting news
if(isset($_POST['submitForm']))
{
$this->levelInsert();
}
//if listing level's
if($_GET['action'] == "manage")
{
//if wanting to edit item
if(isset($_POST['StartEditDetails']))
{
$this->displayEdit();
}
//if submitting edit item form
elseif(isset($_POST['EditDetails']))
{
$this->levelEdit();
$this->levelList();
}
elseif(isset($_POST['StartDelete']))
{
$this->smarty->assign("delete", "y");
$this->smarty->assign("id", $_POST['hidden']);
}
elseif(isset($_POST['ConfirmDelete']))
{
$this->levelDelete();
$this->levelList();
}
else
{
$this->levelList();
}
$this->getNextLevel();
}
$this->smarty->assign("site_page", "Create Level");
}
//display edit level form
public function displayEdit()
{
$rec = $this->db->fetch("SELECT COUNT(levelID) AS ammount, levelNum, levelExpNeeded FROM " . LEVELS_TABLE . " WHERE levelOwnerID='" . $this->game_id . "' AND levelID='" . $this->db->escape($_POST['hidden']) . "'");
if($rec['ammount'] == 1)
{
//template vars
$this->smarty->assign("level", $rec['levelNum']);
$this->smarty->assign("exp", $rec['levelExpNeeded']);
$this->smarty->assign("id", $_POST['hidden']);
$this->smarty->assign("edit", "y");
}
}
//display edit level form
public function levelEdit()
{
$rec = $this->db->fetch("SELECT COUNT(levelID) AS ammount, levelNum, levelExpNeeded FROM " . LEVELS_TABLE . " WHERE levelOwnerID='" . $this->game_id . "' AND levelID='" . $this->db->escape($_POST['hidden']) . "'");
if($rec['ammount'] == 1)
{
//template vars
$Data = array("levelExpNeeded" => $_POST['textEXP']);
$this->db->update(LEVELS_TABLE, $Data, "levelID='" . $this->db->escape($_POST['hidden']) . "'");
$this->smarty->assign("msg", "Level updated...");
}
}
//delete level
public function levelDelete()
{
//fetch information
$rec = $this->db->fetch("SELECT COUNT(levelID) AS ammount, levelNum FROM " . LEVELS_TABLE . " WHERE levelOwnerID='" . $this->game_id . "' AND levelID='" . $this->db->escape($_POST['hidden']) . "'");
//record exist for level belonging to game
if($rec['ammount'] == 1)
{
$this->db->del("DELETE FROM " . LEVELS_TABLE . " WHERE levelOwnerID='" . $this->game_id . "' AND levelID='" . $this->db->escape($_POST['hidden']) . "'");
$this->db->inc("UPDATE " . LEVELS_TABLE . " SET levelNum=levelNum-1 WHERE levelOwnerID='" . $this->game_id . "' AND levelNum>" . $rec['levelNum']);
}
}
//list all levels
public function levelList()
{
$Data = array();
//query to get all tasks that player can do..
$rows = $this->db->fetch_array("SELECT * FROM " . LEVELS_TABLE . " WHERE levelOwnerID='" . $this->game_id . "' ORDER BY levelNum ASC");
//get all records
foreach($rows as $rec)
{
//set data for template
$Data[] = array("id" => $rec['levelID'], "level" => $rec['levelNum'], "exp" => $rec['levelExpNeeded']);
}
//template vars
$this->smarty->assign("looper", $Data);
$this->smarty->assign("list", "y");
}
//insert new created level
public function levelInsert()
{
if($_POST['textEXP'] > 0)
{
$Data = array("levelExpNeeded" => $_POST['textEXP'], "levelNum" => $this->getNextLevel(), "levelOwnerID" => $this->game_id);
$this->db->insert(LEVELS_TABLE, $Data);
$msg = "Level created...";
}
else
{
$msg = "Experience must be greater then 0";
}
//template var
$this->smarty->assign("msg", $msg);
}
public function getNextLevel()
{
//get # of levels in game, next level would be ammount + 1
$rec = $this->db->fetch("SELECT COUNT(levelID) AS ammount FROM " . LEVELS_TABLE . " WHERE levelOwnerID='" . $this->game_id . "'");
//var
$next_level = $rec['ammount'] + 2;
//template var
$this->smarty->assign("level", $next_level);
//return level
return $next_level;
}
}
?>