Skip to content

Commit

Permalink
v3.3 First pass of multi tenancy, first pass for bots
Browse files Browse the repository at this point in the history
Setup the multi tenancy for every page except the bazaar. If you're
using it, you'll need to disable the bazaar for now.
Did a first pass of
displaying bots. There is a "bots" button in the side menu now which
will display a gallery of a characters bots. You can click the bot to
see their gear. The AC/HP/Mana/End/Atk are not accurate right now. Will
be addressed in the future.
  • Loading branch information
maudigan committed Apr 25, 2020
1 parent dc41c5f commit f7a4eb0
Show file tree
Hide file tree
Showing 33 changed files with 1,951 additions and 147 deletions.
14 changes: 14 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
v3.3.0
----------------------------------------------------------------------
first pass of multi tenancy implementation, first pass of bots

April 25, 2020 - Setup the multi tenancy for every page except the
bazaar. If you're using it, you'll need to disable
the bazaar for now.
Did a first pass of displaying bots. There is a "bots"
button in the side menu now which will display
a gallery of a characters bots. You can click the
bot to see their gear. The AC/HP/Mana/End/Atk are
not accurate right now. Will be addressed in the
future.

v3.2.1
----------------------------------------------------------------------
css tweaks, custom templates, code relocation
Expand Down
12 changes: 7 additions & 5 deletions aas.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
* April 3, 2020 - Maudigan
* dont show AAs if they dont have a first rank, some custom server
* hide AA by deleting their ranks
* April 25, 2020 - Maudigan
* implement multi-tenancy
*
***************************************************************************/

Expand Down Expand Up @@ -112,7 +114,7 @@ function getRankCost($first_rank, $value)
else $charName = $_GET['char'];

//character initializations
$char = new profile($charName, $cbsql, $language, $showsoftdelete, $charbrowser_is_admin_page); //the profile class will sanitize the character name
$char = new profile($charName, $cbsql, $cbsql_content, $language, $showsoftdelete, $charbrowser_is_admin_page); //the profile class will sanitize the character name
$charID = $char->char_id();
$name = $char->GetValue('name');
$mypermission = GetPermissions($char->GetValue('gm'), $char->GetValue('anon'), $char->char_id());
Expand Down Expand Up @@ -142,14 +144,14 @@ function getRankCost($first_rank, $value)
FROM aa_ranks
TPL;
$query = $tpl;
$result = $cbsql->query($query);
$result = $cbsql_content->query($query);

//the ranks are stored in a record
//that is similar to a linked list
//loop through each one and load it
//into a poor-man's linked list
$aa_ranks = array();
while ($row = $cbsql->nextrow($result))
while ($row = $cbsql_content->nextrow($result))
{
$aa_rank = array('COST' => intval($row['cost']),
'NEXT' => intval($row['next_id']));
Expand All @@ -165,11 +167,11 @@ function getRankCost($first_rank, $value)
ORDER BY type, name
TPL;
$query = sprintf($tpl, $classbit);
$result = $cbsql->query($query);
$result = $cbsql_content->query($query);

//stage them in the final array
$aa_abilities = array();
while ($row = $cbsql->nextrow($result))
while ($row = $cbsql_content->nextrow($result))
{
//calculate all the values
$first_rank_id = $row['first_rank_id'];
Expand Down
249 changes: 249 additions & 0 deletions bot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
<?php
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Portions of this program are derived from publicly licensed software
* projects including, but not limited to phpBB, Magelo Clone,
* EQEmulator, EQEditor, and Allakhazam Clone.
*
* Author:
* Maudigan(Airwalking)
*
* April 17, 2020 - initial revision (Maudigan)
* April 25, 2020 - Maudigan
* implement multi-tenancy
*
***************************************************************************/


/*********************************************
INCLUDES
*********************************************/
define('INCHARBROWSER', true);
include_once(__DIR__ . "/include/common.php");
include_once(__DIR__ . "/include/bot_profile.php");
include_once(__DIR__ . "/include/profile.php");
include_once(__DIR__ . "/include/itemclass.php");
include_once(__DIR__ . "/include/db.php");


/*********************************************
SETUP PROFILE/PERMISSIONS
*********************************************/
if(!$_GET['bot']) cb_message_die($language['MESSAGE_ERROR'],$language['MESSAGE_NO_CHAR']);
else $botName = $_GET['bot'];

//bot initializations
$bot = new bot_profile($botName, $cbsql, $cbsql_content, $language, $charbrowser_is_admin_page); //the profile class will sanitize the bot name
$charID = $bot->char_id();
$botID = $bot->bot_id();
$botName = $bot->GetValue('name');

//char initialization
$tpl = <<<TPL
SELECT name
FROM character_data
WHERE id = '%s'
TPL;
$query = sprintf($tpl, $charID);
$result = $cbsql->query($query);
if (!($row = $cbsql->nextrow($result))) cb_message_die($language['MESSAGE_ERROR'],$language['MESSAGE_NO_CHAR']);
$charName = $row['name'];
$char = new profile($charName, $cbsql, $cbsql_content, $language, $showsoftdelete, $charbrowser_is_admin_page);
$mypermission = GetPermissions($char->GetValue('gm'), $char->GetValue('anon'), $char->char_id());

//block view if user level doesnt have permission
if ($mypermission['bots']) cb_message_die($language['MESSAGE_ERROR'],$language['MESSAGE_ITEM_NO_VIEW']);


/*********************************************
GATHER RELEVANT PAGE DATA
*********************************************/
//get bot info
$class = $bot->GetValue('class');


/*********************************************
DROP HEADER
*********************************************/
$d_title = " - ".$botName.$language['PAGE_TITLES_CHARACTER'];
include(__DIR__ . "/include/header.php");


/*********************************************
DROP PROFILE MENU
*********************************************/
output_profile_menu($charName, 'bot');


/*********************************************
POPULATE BODY
*********************************************/
$cb_template->set_filenames(array(
'bot' => 'bot_body.tpl')
);


$cb_template->assign_both_vars(array(
'NAME' => $charName,
'REGEN' => number_format($bot->getRegen()),
'FT' => number_format($bot->getFT()),
'DS' => number_format($bot->getDS()),
'HASTE' => $bot->getHaste(),
'DELETED' => (($char->GetValue('deleted_at')) ? " ".$language['CHAR_DELETED']:""),
'FIRST_NAME' => $botName,
'LAST_NAME' => $bot->GetValue('last_name'),
'TITLE' => $bot->GetValue('title'),
'LEVEL' => $bot->GetValue('level'),
'CLASS' => $dbclassnames[$class],
'RACE' => $dbracenames[$bot->GetValue('race')],
'RACE_ID' => $bot->GetValue('race'),
'GENDER_ID' => $bot->GetValue('gender'),
'FACE_ID' => $bot->GetValue('face'),
'AVATAR_IMG' => getAvatarImage($bot->GetValue('race'), $bot->GetValue('gender'), $bot->GetValue('face')),
'CLASS_NUM' => $class,
'DEITY' => $dbdeities[$bot->GetValue('deity')],
'HP' => number_format($bot->GetItemHP()),
'MANA' => number_format($bot->GetItemMana()),
'ENDR' => number_format($bot->GetItemEndurance()),
'AC' => number_format($bot->GetItemAC()),
'ATK' => number_format($bot->GetItemATK()),
'STR' => number_format($bot->getSTR()),
'STA' => number_format($bot->getSTA()),
'DEX' => number_format($bot->getDEX()),
'AGI' => number_format($bot->getAGI()),
'INT' => number_format($bot->getINT()),
'WIS' => number_format($bot->getWIS()),
'CHA' => number_format($bot->getCHA()),
'HSTR' => number_format($bot->getHSTR()),
'HSTA' => number_format($bot->getHSTA()),
'HDEX' => number_format($bot->getHDEX()),
'HAGI' => number_format($bot->getHAGI()),
'HINT' => number_format($bot->getHINT()),
'HWIS' => number_format($bot->getHWIS()),
'HCHA' => number_format($bot->getHCHA()),
'POISON' => $bot->getPR(),
'FIRE' => $bot->getFR(),
'MAGIC' => $bot->getMR(),
'DISEASE' => $bot->getDR(),
'COLD' => $bot->getCR(),
'CORRUPT' => $bot->getCOR(),
'HPOISON' => $bot->getHPR(),
'HFIRE' => $bot->getHFR(),
'HMAGIC' => $bot->getHMR(),
'HDISEASE' => $bot->getHDR(),
'HCOLD' => $bot->getHCR(),
'HCORRUPT' => $bot->getHCOR(),
'WEIGHT' => round($bot->getWT()/10))
);

$cb_template->assign_vars(array(
'L_HEADER_INVENTORY' => $language['CHAR_INVENTORY'],
'L_REGEN' => $language['CHAR_REGEN'],
'L_FT' => $language['CHAR_FT'],
'L_DS' => $language['CHAR_DS'],
'L_HASTE' => $language['CHAR_HASTE'],
'L_HP' => $language['CHAR_HP'],
'L_MANA' => $language['CHAR_MANA'],
'L_ENDR' => $language['CHAR_ENDR'],
'L_AC' => $language['CHAR_AC'],
'L_ATK' => $language['CHAR_ATK'],
'L_STR' => $language['CHAR_STR'],
'L_STA' => $language['CHAR_STA'],
'L_DEX' => $language['CHAR_DEX'],
'L_AGI' => $language['CHAR_AGI'],
'L_INT' => $language['CHAR_INT'],
'L_WIS' => $language['CHAR_WIS'],
'L_CHA' => $language['CHAR_CHA'],
'L_HSTR' => $language['CHAR_HSTR'],
'L_HSTA' => $language['CHAR_HSTA'],
'L_HDEX' => $language['CHAR_HDEX'],
'L_HAGI' => $language['CHAR_HAGI'],
'L_HINT' => $language['CHAR_HINT'],
'L_HWIS' => $language['CHAR_HWIS'],
'L_HCHA' => $language['CHAR_HCHA'],
'L_POISON' => $language['CHAR_POISON'],
'L_MAGIC' => $language['CHAR_MAGIC'],
'L_DISEASE' => $language['CHAR_DISEASE'],
'L_FIRE' => $language['CHAR_FIRE'],
'L_COLD' => $language['CHAR_COLD'],
'L_CORRUPT' => $language['CHAR_CORRUPT'],
'L_HPOISON' => $language['CHAR_HPOISON'],
'L_HMAGIC' => $language['CHAR_HMAGIC'],
'L_HDISEASE' => $language['CHAR_HDISEASE'],
'L_HFIRE' => $language['CHAR_HFIRE'],
'L_HCOLD' => $language['CHAR_HCOLD'],
'L_HCORRUPT' => $language['CHAR_HCORRUPT'],
'L_WEIGHT' => $language['CHAR_WEIGHT'],
'L_DONE' => $language['BUTTON_DONE'])
);

//---------------------------------
// SLOTS TEMPLATE VARS
//---------------------------------
//EQUIPMENT
for ( $i = SLOT_EQUIPMENT_START; $i <= SLOT_EQUIPMENT_END; $i++ ) {
$cb_template->assign_block_vars("equipslots", array(
'SLOT' => $i)
);
}


//---------------------------------
// ITEM ICONS TEMPLATE VARS
//---------------------------------
$allitems = $bot->getAllItems();


//EQUIPMENT
foreach ($allitems as $value) {
if ($value->type() != EQUIPMENT) continue;
$cb_template->assign_block_vars("equipitem", array(
'SLOT' => $value->slot(),
'ICON' => $value->icon(),
'STACK' => $value->stack())
);
}


//---------------------------------
// ITEM WINDOW TEMPLATE VARS
//---------------------------------
//the item inspect windows that hold
//the item stats. this does equipment,
//inventory, bank and shared bank
foreach ($allitems as $value) {
$cb_template->assign_both_block_vars("item", array(
'SLOT' => $value->slot(),
'ICON' => $value->icon(),
'NAME' => $value->name(),
'STACK' => $value->stack(),
'ID' => $value->id(),
'LINK' => QuickTemplate($link_item, array('ITEM_ID' => $value->id())),
'HTML' => $value->html())
);
for ( $i = 0 ; $i < $value->augcount() ; $i++ ) {
$cb_template->assign_both_block_vars("item.augment", array(
'AUG_NAME' => $value->augname($i),
'AUG_ID' => $value->augid($i),
'AUG_LINK' => QuickTemplate($link_item, array('ITEM_ID' => $value->augid($i))),
'AUG_ICON' => $value->augicon($i),
'AUG_HTML' => $value->aughtml($i))
);
}
}


/*********************************************
OUTPUT BODY AND FOOTER
*********************************************/
$cb_template->pparse('bot');

$cb_template->destroy;

include(__DIR__ . "/include/footer.php");
?>
Loading

0 comments on commit f7a4eb0

Please sign in to comment.