rendered paste body<?php/* * Created on 17-Jun-06 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates item slots info & list of point allowances, create item form, Javascript to handle allowances item: Field Type Attributes Null Default Extra Action id int(11) No 0 Browse Change Drop Primary Index Unique Fulltext name varchar(250) No Browse Change Drop Primary Index Unique Fulltext userId int(11) No 0 Browse Change Drop Primary Index Unique Fulltext ogreName varchar(150) No Browse Change Drop Primary Index Unique Fulltext description text No Browse Change Drop Primary Index Unique Fulltext type enum('defend', 'attack') No defend Browse Change Drop Primary Index Unique Fulltext level int(11) No 0 Browse Change Drop Primary Index Unique Fulltext gold int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental int(11) No 0 Browse Change Drop Primary Index Unique Fulltext physical int(11) No 0 Browse Change Drop Primary Index Unique Fulltext magic int(11) No 0 Browse Change Drop Primary Index Unique Fulltext general int(11) No 0 Browse Change Drop Primary Index Unique Fulltext rating int(11) No 0 Browse Change Drop Primary Index Unique Fulltext damage int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_fire int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_water int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_air int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_earth int(11) No 0 Browse Change Drop Primary Index Unique Fulltext physical_stab int(11) No 0 Browse Change Drop Primary Index Unique Fulltext physical_bludgeon int(11) No 0 Browse Change Drop Primary Index Unique Fulltext magic_mystical int(11) No 0 Browse Change Drop Primary Index Unique Fulltext magic_necro int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_poison int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_weak int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_frail int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_beserk int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_glass int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_sleep int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_death int(11) No 0 Browse Change Drop Primary Index Unique Fulltext created datetime No 0000-00-00 00:00:00 Browse Change Drop Primary Index Unique Fulltext Ogre: Field Type Attributes Null Default Extra Action id int(11) No auto_increment Browse Change Drop Primary Index Unique Fulltext userId int(11) No 0 Browse Change Drop Primary Index Unique Fulltext name varchar(150) No 0 Browse Change Drop Primary Index Unique Fulltext level int(11) No 0 Browse Change Drop Primary Index Unique Fulltext gold int(11) No 0 Browse Change Drop Primary Index Unique Fulltext itemSlot int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental int(11) No 0 Browse Change Drop Primary Index Unique Fulltext physical int(11) No 0 Browse Change Drop Primary Index Unique Fulltext magic int(11) No 0 Browse Change Drop Primary Index Unique Fulltext defense int(11) No 0 Browse Change Drop Primary Index Unique Fulltext skill int(11) No 0 Browse Change Drop Primary Index Unique Fulltext */class itemCreatorDoc extends document implements gamePage,dataItem { private $id; private $userId; private $ogreTitle; private $ogreName; private $xp; private $gold; private $level; private $score; private $ogreId; private $OMT; //the following are specific to preferencesDoc private $items; //array of stuff private $itemSlot; private $elemental; private $physical; private $magic; private $defense; private $skill; private $allowances; public function createItemCreatorForm(){ $itemForm = $this->createForm($this->main,'createItem();','passwordForm'); $this->createNappend('h2',$itemForm,'Create an Item'); $h3 = $this->createNappend('h3',$itemForm,'Basics'); $h3->setAttribute('class','itemHeader'); $p = $this->createNappend('p',$itemForm,'Name:'); $this->createInput('name','text',$itemForm,'itemFormName'); $this->createNappend('p',$itemForm,'Type:'); $options = array( "Offensive" => 'attack', "Defensive" => 'defend' ); $select = $this->createSelect('type',$itemForm,'itemFormType',$options); $this->createNappend('p',$itemForm,'Damage:'); $item = $this->createInput('damage','text',$itemForm,'itemFormDamage','0'); $h3 = $this->createNappend('h3',$itemForm,'Elemental Special Damage'); $h3->setAttribute('class','itemHeader'); $p = $this->createNappend('p',$itemForm,'Fire:'); $p->setAttribute('class','itemP'); $item = $this->createInput('fire','text',$itemForm,'itemFormFire','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Water:'); $p->setAttribute('class','itemP'); $item = $this->createInput('water','text',$itemForm,'itemFormWater','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Air:'); $p->setAttribute('class','itemP'); $item = $this->createInput('air','text',$itemForm,'itemFormAir','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Earth:'); $p->setAttribute('class','itemP'); $item = $this->createInput('earth','text',$itemForm,'itemFormEarth','0','itemInput','itemP'); $h3 = $this->createNappend('h3',$itemForm,'Physical Special Damage'); $h3->setAttribute('class','itemHeader'); $p = $this->createNappend('p',$itemForm,'Stab:'); $p->setAttribute('class','itemP'); $item = $this->createInput('stab','text',$itemForm,'itemStab','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Bludgeon:'); $p->setAttribute('class','itemP'); $item = $this->createInput('bludgeon','text',$itemForm,'itemFormBludgeon','0','itemInput','itemP'); $h3 = $this->createNappend('h3',$itemForm,'Magical Special Damage'); $h3->setAttribute('class','itemHeader'); $p = $this->createNappend('p',$itemForm,'Mystical:'); $p->setAttribute('class','itemP'); $item = $this->createInput('mystical','text',$itemForm,'itemFormMystical','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Necro:'); $p->setAttribute('class','itemP'); $item = $this->createInput('necro','text',$itemForm,'itemFormNecro','0','itemInput','itemP'); $h3 = $this->createNappend('h3',$itemForm,'Magical State Attacks'); $h3->setAttribute('class','itemHeader'); $p = $this->createNappend('p',$itemForm,'poison:'); $p->setAttribute('class','itemP'); $item = $this->createInput('poison','text',$itemForm,'itemFormPoison','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Weak:'); $p->setAttribute('class','itemP'); $item = $this->createInput('weak','text',$itemForm,'itemFormWeak','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Frail:'); $p->setAttribute('class','itemP'); $item = $this->createInput('frail','text',$itemForm,'itemFormFrail','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Beserk:'); $p->setAttribute('class','itemP'); $item = $this->createInput('beserk','text',$itemForm,'itemFormBeserk','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Glass:'); $p->setAttribute('class','itemP'); $item = $this->createInput('glass','text',$itemForm,'itemFormGlass','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Sleep:'); $p->setAttribute('class','itemP'); $item = $this->createInput('sleep','text',$itemForm,'itemFormSleep','0','itemInput','itemP'); $p = $this->createNappend('p',$itemForm,'Death:'); $p->setAttribute('class','itemP'); $item = $this->createInput('death','text',$itemForm,'itemFormDeath','0','itemInput','itemP'); $h3 = $this->createNappend('h3',$itemForm,'Description'); $h3->setAttribute('class','itemHeader'); $this->createNappend('p',$itemForm,'Be creative:'); $this->createTextarea('description',$itemForm,'descriptionTextArea'); $infoDiv = $this->createNappend('div',$itemForm,'Click the button below to create the item.'); $infoDiv->setAttribute('id','itemInfoDiv'); $this->createInput('submit','submit',$itemForm,'descriptionSub','Create Item'); return; } public function createItemList(){ if(count($this->items) < 1){ $itemList = $this->createNappend('p',$this->main,'You have created no Items'); }else{ $itemList = $this->createNappend('div',$this->main); $itemTable = $this->createNappend('table',$this->main); $table->setAttribute('class','itemTable'); $thead = $this->createNappend('thead',$itemTable); $tr = $this->createNappend('tr',$thead); $this->createNappend('th',$tr,'Name'); $this->createNappend('th',$tr,'Level'); $this->createNappend('th',$tr,'Worth'); $this->createNappend('td',$tr,'Type'); $this->createNappend('th',$tr,'Created'); $tbody = $this->createNappend('tbody',$itemTable); $tr = $this->createNappend('tr',$tbody); foreach($this->items as $item){ $worth = $this->getItemWorth($item); $this->createNappend('td',$tr,$item['name']); $this->createNappend('td',$tr,$item['level']); $this->createNappend('td',$tr,$worth); $this->createNappend('td',$tr,$item['type']); $this->createNappend('td',$tr,$item['created']); } } return; } public function createItemTable(){ if(count($this->items) > 0){ $itemTableDiv = $this->createNappend('div',$this->main); $infoP = $this->createNappend('p',$itemTableDiv,'Select an item to display below.'); $itemTable = $this->createNappend('table',$itemTableDiv); $tr = $this->createNappend('tr',$itemTable); $this->createNappend('th',$tr,'Name'); $this->createNappend('th',$tr,'Level'); $this->createNappend('th',$tr,'Worth'); $this->createNappend('td',$tr,'Type'); $this->createNappend('th',$tr,'Created'); $tr = $this->createNappend('tr',$itemTable); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemName'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemLevel'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemWorth'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemType'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemDate'); $tr = $this->createNappend('tr',$itemTable); $this->createNappend('th',$tr,'Gold'); $this->createNappend('th',$tr,'Elemental Level'); $this->createNappend('th',$tr,'Physical Level'); $this->createNappend('td',$tr,'Magical Level'); $this->createNappend('th',$tr,'Defense Level'); $tr = $this->createNappend('tr',$itemTable); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemGold'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemElemental'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemPhysical'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemMagical'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemDefense'); $tr = $this->createNappend('tr',$itemTable); $this->createNappend('th',$tr,'Rating'); $this->createNappend('th',$tr,'Damage'); $this->createNappend('th',$tr,' '); $this->createNappend('td',$tr,' '); $this->createNappend('th',$tr,' '); $tr = $this->createNappend('tr',$itemTable); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemRating'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemDamage'); $td = $this->createNappend('td',$tr,' '); $td = $this->createNappend('td',$tr,' '); $td = $this->createNappend('td',$tr,' '); $tr = $this->createNappend('tr',$itemTable); $this->createNappend('th',$tr,'Elemental Fire'); $this->createNappend('th',$tr,'Elemental Water'); $this->createNappend('th',$tr,'Elemental Air'); $this->createNappend('td',$tr,'Elemental Earth'); $this->createNappend('th',$tr,'Physical Stab'); $tr = $this->createNappend('tr',$itemTable); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemElemFire'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemElemWater'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemElemAir'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemElemEarth'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemPhysStab'); $tr = $this->createNappend('tr',$itemTable); $this->createNappend('th',$tr,'Physical Bludgeon'); $this->createNappend('th',$tr,'Magic Mystical'); $this->createNappend('th',$tr,'Magic Necro'); $this->createNappend('td',$tr,'State Poison'); $this->createNappend('th',$tr,'State Weak'); $tr = $this->createNappend('tr',$itemTable); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemPhysBludgeon'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemMagicMystical'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemMagicNecro'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemStatePoison'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemStateWeak'); $tr = $this->createNappend('tr',$itemTable); $this->createNappend('th',$tr,'State Frail'); $this->createNappend('th',$tr,'State Beserk'); $this->createNappend('th',$tr,'State Glass'); $this->createNappend('td',$tr,'State Sleep'); $this->createNappend('th',$tr,'State Death'); $tr = $this->createNappend('tr',$itemTable); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemStateFrail'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemStateBeserk'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemStateGlass'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemStateSleep'); $td = $this->createNappend('td',$tr,' '); $td->setAttribute('id','itemStateDeath'); $description = $this->createNappend('p',$itemTableDiv,'Description'); $description->setAttribute('id','itemDescription'); } return; } private function getItemWorth(array $item){ $worth = 0; $worth += $item['damage']; $worth += $item['elemental_fire']; $worth += $item['elemental_water']; $worth += $item['elemental_air']; $worth += $item['elemental_earth']; $worth += $item['physical_stab']; $worth += $item['physical_bludgeon']; $worth += $item['magic_mystical']; $worth += $item['magic_necro']; $worth += $item['state_poison']; $worth += $item['state_weak']; $worth += $item['state_frail']; $worth += $item['state_beserk']; $worth += $item['state_glass']; $worth += $item['state_sleep']; $worth += $item['state_death']; return $worth; } public function createAllowanceInfo(){ $allowances = determineAllowances($this->physical ,$this->magic ,$this->elemental ,$this->defense ,$this->skill ,$this->level); $allowanceDiv = $this->createNappend('div',$this->main); $allowanceInfoP = $this->createNappend('p',$allowanceDiv,'Allowances for item creation.'); $allowanceTable = $this->createNappend('table',$allowanceDiv); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Open Slots"); $td = $this->createNappend('td',$tr,$this->itemSlot); $td->setAttribute('id','allowanceSlot'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Total Points"); $td = $this->createNappend('td',$tr,$allowances['total']); $td->setAttribute('id','allowanceTotal'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Physical"); $td = $this->createNappend('td',$tr,$allowances['physical']); $td->setAttribute('id','allowancePhysical'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Magic Mystical"); $td = $this->createNappend('td',$tr,$allowances['magic_mystical']); $td->setAttribute('id','allowanceMystical'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Magic Necro"); $td = $this->createNappend('td',$tr,$allowances['magic_necro']); $td->setAttribute('id','allowanceNecro'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"State Poison"); $td = $this->createNappend('td',$tr,$allowances['state_poison']); $td->setAttribute('id','allowancePoison'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"State Weak"); $td = $this->createNappend('td',$tr,$allowances['state_weak']); $td->setAttribute('id','allowanceWeak'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"State Frail"); $td = $this->createNappend('td',$tr,$allowances['state_frail']); $td->setAttribute('id','allowanceFrail'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"State Beserk"); $td = $this->createNappend('td',$tr,$allowances['state_beserk']); $td->setAttribute('id','allowanceBeserk'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"State Glass"); $td = $this->createNappend('td',$tr,$allowances['state_glass']); $td->setAttribute('id','allowanceGlass'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"State Sleep"); $td = $this->createNappend('td',$tr,$allowances['state_sleep']); $td->setAttribute('id','allowanceSleep'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"State Death"); $td = $this->createNappend('td',$tr,$allowances['state_death']); $td->setAttribute('id','allowanceDeath'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Elemental Fire"); $td = $this->createNappend('td',$tr,$allowances['fire']); $td->setAttribute('id','allowanceFire'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Elemental Water"); $td = $this->createNappend('td',$tr,$allowances['water']); $td->setAttribute('id','allowanceWater'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Elemental Air"); $td = $this->createNappend('td',$tr,$allowances['air']); $td->setAttribute('id','allowanceAir'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Elemental Earth"); $td = $this->createNappend('td',$tr,$allowances['earth']); $td->setAttribute('id','allowanceEarth'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Defense Physical"); $td = $this->createNappend('td',$tr,$allowances['def_physical']); $td->setAttribute('id','allowanceEarth'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Defense Magic"); $td = $this->createNappend('td',$tr,$allowances['def_magic']); $td->setAttribute('id','allowanceEarth'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Defense Elemental"); $td = $this->createNappend('td',$tr,$allowances['def_elemental']); $td->setAttribute('id','allowanceEarth'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Skill Low"); $td = $this->createNappend('td',$tr,$allowances['skillLow']); $td->setAttribute('id','allowanceEarth'); $tr = $this->createNappend('tr',$allowanceTable); $this->createNappend('th',$tr,"Skill High"); $td = $this->createNappend('td',$tr,$allowances['skillHigh']); $td->setAttribute('id','allowanceEarth'); return; } public function setInfoLayOut(){ $infoDiv = $this->createNappend('div',$this->main); $infoDiv->setAttribute('id','infoDiv'); //$infoDiv->setAttribute('class','clearfix'); $ogreName = $this->createNappend('h3',$infoDiv); //I'm adding a span for the title so I can change it with JS $infoTitle = $this->createNappend('span',$ogreName,$this->ogreTitle); $infoTitle->setAttribute('id','infoTitle'); $ogreName->appendChild($infoTitle); $ogreNameText = $this->doc->createTextNode(' ' . $this->ogreName); $ogreName->appendChild($ogreNameText); $ogreName->setAttribute('id','ogreName'); $ogreName->setAttribute('class','info_set'); $OMT = $this->createNappend('h3',$infoDiv,$this->OMT . ' OMT'); $OMT->setAttribute('id','OMT'); $OMT->setAttribute('class','info_set'); $basicDataDiv = $this->createNappend('div',$infoDiv); $basicDataDiv->setAttribute('id','basicData'); $basicDataDiv->setAttribute('class','info_set'); $this->addInfoItem($this->gold,'gold',$basicDataDiv); $this->addInfoItem($this->score,'score',$basicDataDiv); $this->addInfoItem($this->level,'level',$basicDataDiv); $this->addInfoItem($this->xp,'experience',$basicDataDiv); return; } private function addInfoItem($data,$id,$parent){ $p = $this->createNappend('p',$parent,ucfirst($id) . ": " . ogre::number($data)); $p->setAttribute('id','info_' . $id); $p->setAttribute('class','info_item'); return; } public function loadData(){ //loads the item from a data resource such as a database, xml file, etc $sql = "SELECT * "; $sql .= "FROM `ogre` WHERE `userId` = " . $_SESSION['id'] . " LIMIT 1"; $res = mysql_query($sql) or die(mysql_error()); $myR = mysql_fetch_array($res); $this->id = $_SESSION['id']; $this->userId = $_SESSION['userId']; $this->ogreName = $myR['name']; $this->ogreTitle = $myR['title']; $this->xp = $myR['experience']; $this->gold = $myR['gold']; $this->level = $myR['level']; $this->score = $myR['score']; $this->ogreId = $myR['id']; $this->itemSlot = $myR['itemSlot']; $this->elemental = $myR['elemental']; $this->physical = $myR['physical']; $this->magic = $myR['magic']; $this->defense = $myR['defense']; $this->skill = $myR['skill']; $sql = "SELECT * FROM `item` WHERE `userId` = " . $_SESSION['id']; $res = mysql_query($sql) or die(mysql_error()); while($myR = mysql_fetch_array($res)){ $this->items[] = $myR; } $sql = "SELECT * FROM `omt` LIMIT 1"; $res = mysql_query($sql) or die(mysql_error()); $myR = mysql_fetch_array($res); $this->OMT = $myR['omt']; return; } public function saveData(){ $sql = "UPDATE `ogre` SET "; $sql .= "`experience` = " . $this->experience . ", "; $sql .= "`gold` = " . $this->gold . " "; $sql .= "WHERE `id` = " . $this->ogreId; mysql_query($sql) or die(mysql_error()); return; } public function checkLogin(){ //required to be loggeed in to see a game page; if(!isset($_SESSION['id'])){ $_SESSION = array(); header('Location: login.php5'); exit(); } } public function updateUserActivity(){ $sql = "UPDATE `user` SET `active` = '" . date('Y-m-d h:i:s') . "' "; $sql .= "WHERE `id` = " . $this->id; mysql_query($sql) or die(mysql_error()); return; } //the following are common things needed on every game page: public function getItems(){ return $this->items; } public function getXp(){ return $this->xp; } public function getLevel(){ return $this->level; } public function getGold(){ return $this->gold; } public function getScore(){ return $this->score; } public function getOgreTitle(){ return $this->ogreTitle; } public function getOgreName(){ return $this->ogreName; } public function getOgreId(){ return $this->ogreId; } public function getOMT(){ return $this->OMT; }}?><?phprequire_once('./common/include.php5');require_once('./documents/itemCreatorDoc.php5');require_once('./common/allowances.php5');session_start();$document = new itemCreatorDoc('Item Creator');$document->checkLogin();$document->addScript('itemCreator');$document->loadData();$document->updateUserActivity();$document->setInfoLayOut();$document->addPrimaryHeader('Item Creator');$info = "This page is where you can create weapons, armor, items and more ";$info .= "if you have any open item creation points.";$help = "This column has helpful information";$columnArray = array('Help' => $help,'Page Info' => $info);$document->setColumn($columnArray);$document->setMenu($menuArray);//$document->addTextContent('This is the preferences page.');$document->createItemList();$document->createItemTable();$document->createAllowanceInfo();$document->createItemCreatorForm();echo $document->getDocument();?><?phpsession_start();require_once('defaults.php');require_once('../common/allowances.php5');if(isset($_POST) && (count($_POST) > 1)){ mysql_connect($DBhostname,$DBusername, $DBpassword) OR die(mysql_error()); mysql_select_db($DBdbname); $returnError = array(); foreach($_POST as $key => $var){ $key = htmlspecialchars(strip_tags($key)); $var = htmlspecialchars(strip_tags(trim($var))); $var = preg_replace('/\s+/', ' ', $var); //replaces multiple whitespace with one space if(preg_match('/[^0-9]/',$var)){ if($key != 'name'){ $returnError[] = ucfirst($key) . " must be a number."; }else if(preg_match('/[^a-zA-Z0-9 ]/',$var)){ $returnError[] = 'Invalid character in Name.'; } } if((strlen($var) < 1) ){ $returnError[] = ucfirst($key) . " needs to be at least 1 character"; } $_POST[$key] = $var; } $action = $_POST['action']; switch($action){ case "createItem": //incase I want to do something later with these vars: $name = $_POST['name']; $damage = $_POST['damage']; $fire = $_POST['fire']; $water = $_POST['water']; $air = $_POST['air']; $earth = $_POST['earth']; $stab = $_POST['stab']; $bludgeon = $_POST['bludgeon']; $mystical = $_POST['mystical']; $necro = $_POST['necro']; $poison = $_POST['poison']; $weak = $_POST['weak']; $frail = $_POST['frail']; $beserk = $_POST['beserk']; $glass = $_POST['glass']; $sleep = $_POST['sleep']; $death = $_POST['death']; $description = $_POST['description']; //removing delimiters used by OM: $description = str_replace('||//||',"",$description); $description = str_replace('|||',"",$description); $sql = "SELECT `magic`, `elemental`, `defense`, `skill`, `level`"; $sql .= " WHERE `userId` = " . $_SESSION['id']; $res = mysql_query($sql) or die($sql . " -> " . mysql_error()); $ogre = mysql_fetch_array($res); $allowances = determineAllowances($ogre['physical'] ,$ogre['magic'] ,$ogre['elemental'] ,$ogre['defense'] ,$ogre['skill'] ,$ogre['level']); $total = ($damage + $fire + $water + $air + $earth + $stab + $bludgeon + $mystical + $necro + $poison + $weak + $frail + $beserk + $glass + $sleep + $death ); if($total > $allowances['total']){ $returnError[] = "You allocated more points than you have available" . ", please check your total."; } if($type == 'attack'){ if($fire > $allowances['fire']){ $returnError[] = "You exceeded your allowance for fire."; } if($water > $allowances['water']){ $returnError[] = "You exceeded your allowance for water."; } if($air > $allowances['air']){ $returnError[] = "You exceeded your allowance for air."; } if($earth > $allowances['earth']){ $returnError[] = "You exceeded your allowance for earth."; } $physicalAttackTotal = ($stab + $bludgeon); if($physicalAttackTotal > $allowances['physical']){ $returnError[] = "You exceeded your allowance for " . "special physical attacks."; } if($mystical > $allowances['magic_mystical']){ $returnError[] = "You exceeded your allowance for mystical."; } if($necro > $allowances['magic_necro']){ $returnError[] = "You exceeded your allowance for necro."; } if($poison > $allowances['state_poison']){ $returnError[] = "You exceeded your allowance for poison."; } if($weak > $allowances['state_weak']){ $returnError[] = "You exceeded your allowance for weak."; } if($beserk > $allowances['state_frail']){ $returnError[] = "You exceeded your allowance for frail."; } if($glass > $allowances['state_beserk']){ $returnError[] = "You exceeded your allowance for beserk."; } if($fire > $allowances['state_glass']){ $returnError[] = "You exceeded your allowance for glass."; } if($sleep > $allowances['state_sleep']){ $returnError[] = "You exceeded your allowance for sleep."; } if($death > $allowances['state_death']){ $returnError[] = "You exceeded your allowance for death."; } }else{ $elementalDef = ($fire + $water + $air + $earth); $physicalDef = ($stab + $bludgeon); $magicalDef = ($mystical + $necro + $poison + $weak + $frail + $beserk + $glass + $sleep + $death ); if($physicalDef > $allowances['def_physical']){ $returnError[] = "You exceeded your allowance for physical defense."; } if($magicalDef > $allowances['def_magic']){ $returnError[] = "You exceeded your allowance for magical defense."; } if($elementalDef > $allowances['def_elemental']){ $returnError[] = "You exceeded your allowance for elemental defense."; } } $returnString = ""; if(count($returnError) > 0){ foreach($returnError as $message){ $returnString .= "<p class='formAlert'>" . $message . "</p>"; } echo 'item' . '|||' . $returnString; }else{ $sql = "INSERT INTO `item` SET `id` = 'NULL', "; $sql .= "`name` = " . $name . ", "; $sql .= "`description` = " . $description . ", "; $sql .= "`damage` = " . ceil(rand( ($damage * $allowances['skillLow']), ($damage * $allowances['skillHigh']) )) . ", "; $sql .= "`elemental_fire` = " . ceil(rand( ($fire * $allowances['skillLow']), ($fire * $allowances['skillHigh']) )) . ", "; $sql .= "`elemental_water` = " . ceil(rand( ($water * $allowances['skillLow']), ($water * $allowances['skillHigh']) )) . ", "; $sql .= "`elemental_air` = " . ceil(rand( ($air * $allowances['skillLow']), ($air * $allowances['skillHigh']) )) . ", "; $sql .= "`elemental_earth` = " . ceil(rand( ($earth * $allowances['skillLow']), ($earth * $allowances['skillHigh']) )) . ", "; $sql .= "`physical_stab` = " . ceil(rand( ($stab * $allowances['skillLow']), ($stab * $allowances['skillHigh']) )) . ", "; $sql .= "`physical_bludgeon` = " . ceil(rand( ($bludgeon * $allowances['skillLow']), ($bludgeon * $allowances['skillHigh']) )) . ", "; $sql .= "`magic_mystical` = " . ceil(rand( ($mystical * $allowances['skillLow']), ($mystical * $allowances['skillHigh']) )) . ", "; $sql .= "`magic_necro` = " . ceil(rand( ($necro * $allowances['skillLow']), ($necro * $allowances['skillHigh']) )) . ", "; $sql .= "`state_poison` = " . ceil(rand( ($poison * $allowances['skillLow']), ($poison * $allowances['skillHigh']) )) . ", "; $sql .= "`state_weak` = " . ceil(rand( ($weak * $allowances['skillLow']), ($weak * $allowances['skillHigh']) )) . ", "; $sql .= "`state_frail` = " . ceil(rand( ($frail * $allowances['skillLow']), ($frail * $allowances['skillHigh']) )) . ", "; $sql .= "`state_beserk` = " . ceil(rand( ($beserk * $allowances['skillLow']), ($beserk * $allowances['skillHigh']) )) . ", "; $sql .= "`state_glass` = " . ceil(rand( ($glass * $allowances['skillLow']), ($glass * $allowances['skillHigh']) )) . ", "; $sql .= "`state_sleep` = " . ceil(rand( ($sleep * $allowances['skillLow']), ($sleep * $allowances['skillHigh']) )) . ", "; $sql .= "`state_death` = " . ceil(rand( ($death * $allowances['skillLow']), ($death * $allowances['skillHigh']) )) ; $res = mysql_query($sql) or die(mysql_error()); $returnString = "Item created."; echo 'item_success' . '|||' . $returnString; } break; }} mysql_close();if(isset($res)){ @mysql_free_result($res);}?>function createItem(){ var itemName = document.getElementById('itemFormName'); var description = document.getElementById('descriptionTextArea'); var type = document.getElementById('itemFormType'); var damage = document.getElementById('itemFormDamage'); var fire = document.getElementById('itemFormFire'); var water = document.getElementById('itemFormWater'); var air = document.getElementById('itemFormAir'); var earth = document.getElementById('itemFormEarth'); var stab = document.getElementById('itemFormStab'); var bludgeon = document.getElementById('itemFormBludgeon'); var mystical = document.getElementById('itemFormMystical'); var necro = document.getElementById('itemFormNecro'); var poison = document.getElementById('itemFormPoison'); var weak = document.getElementById('itemFormWeak'); var frail = document.getElementById('itemFormFrail'); var beserk = document.getElementById('itemFormBeserk'); var glass = document.getElementById('itemFormGlass'); var sleep = document.getElementById('itemFormSleep'); var death = document.getElementById('itemFormDeath'); var queryString; document.getElementById('itemInfoDiv').innerHTML = "<h3>Loading...Please wait.</h3>"; strSubmit = 'name=' + escape(itemName.value); strSubmit += '&description=' + escape(description.value); strSubmit += '&type=' + escape(type.value); strSubmit += '&damage=' + escape(damage.value); strSubmit += '&fire=' + escape(fire.value); strSubmit += '&water=' + escape(water.value); strSubmit += '&air=' + escape(air.value); strSubmit += '&earth=' + escape(earth.value); strSubmit += '&stab=' + escape(stab.value); strSubmit += '&bludgeon=' + escape(bludgeon.value); strSubmit += '&mystical=' + escape(mystical.value); strSubmit += '&necro=' + escape(necro.value); strSubmit += '&poison=' + escape(poison.value); strSubmit += '&weak=' + escape(weak.value); strSubmit += '&frail=' + escape(frail.value); strSubmit += '&beserk=' + escape(beserk.value); strSubmit += '&glass=' + escape(glass.value); strSubmit += '&sleep=' + escape(sleep.value); strSubmit += '&death=' + escape(death.value); strSubmit += '&action=createItem'; getText('./requests/itemCreatorRequest.php5',strSubmit);} /* * No 0 Browse Change Drop Primary Index Unique Fulltext damage int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_fire int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_water int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_air int(11) No 0 Browse Change Drop Primary Index Unique Fulltext elemental_earth int(11) No 0 Browse Change Drop Primary Index Unique Fulltext physical_stab int(11) No 0 Browse Change Drop Primary Index Unique Fulltext physical_bludgeon int(11) No 0 Browse Change Drop Primary Index Unique Fulltext magic_mystical int(11) No 0 Browse Change Drop Primary Index Unique Fulltext magic_necro int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_poison int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_weak int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_frail int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_beserk int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_glass int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_sleep int(11) No 0 Browse Change Drop Primary Index Unique Fulltext state_deat */