help:-Undefined variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stefman123
    New Member
    • Nov 2009
    • 6

    help:-Undefined variable

    hey guys just wondering if you can help with this error ive started receiving(im not brilliant at coding so it probs something obvious)

    Notice: Undefined variable: lang in C:\xampp\htdocs \armory\source\ charlist.php on line 24

    20<ul class="heading" >
    21<img class="ieimg" src="images/pixel.gif"><li class="hleft"></li>
    22<li class="hcont">
    23<div class="generic-title">
    24<h1><?php echo $lang['search_for_pro files'] ?>:</h1>
    25</div>

    thanks for reading
    stef
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    The variable $lang does not exist in the current scope. Where do you define $lang?

    Comment

    • stefman123
      New Member
      • Nov 2009
      • 6

      #3
      i dont 100% understand the code im afraid im not brilliant with php i wrote a basic script sent it to a freand and he sent it back with some nice new features that mostly work its just this one is throwing up that error

      sorry im no more use but im fairly new to coding

      Comment

      • stefman123
        New Member
        • Nov 2009
        • 6

        #4
        Code:
        17<h3><?php echo $lang['char_search'] ?></h3>
        18</b>
        19</blockquote>
        20<ul class="heading">
        21<img class="ieimg" src="images/pixel.gif"><li class="hleft"></li>
        22<li class="hcont">
        23<div class="generic-title">
        24<h1><?php echo $lang['search_for_profiles'] ?>:</h1>
        25</div>
        line 17 hasent thrown in an error and its using the same code thats why i dont understand whats happning

        this is the hole script if it will help

        Code:
        <?php
        if(!defined('Armory'))
        {
        	header('Location: ../index.php?searchType=characters');
        	exit();
        }
        if(!isset($_GET["searchQuery"]))
        {
        	startcontenttable();
        ?>
        <div class="profile-wrapper">
        <blockquote>
        <b class="icharacters">
        <h4>
        <a href="index.php?searchType=characters"><?php echo $lang['char_profiles'] ?></a>
        </h4>
        <h3><?php echo $lang['char_search'] ?></h3>
        </b>
        </blockquote>
        <ul class="heading">
        <img class="ieimg" src="images/pixel.gif"><li class="hleft"></li>
        <li class="hcont">
        <div class="generic-title">
        <h1><?php echo $lang['search_for_profiles'] ?>:</h1>
        </div>
        </li>
        <li class="hright"></li>
        </ul>
        <form action="index.php" method="get" name="formSearchCharacter" onsubmit="javascript: return menuCheckLength(document.formSearchCharacter);">
        <div id="formSearchCharacter_errorSearchLength" style="position: relative; left: 150px; top: 150px; white-space: nowrap;"></div>
        <input name="searchType" type="hidden" value="characters">
        <input name="realm" type="hidden" value= "<?php echo DefaultRealmName ?>">
        <p class="scroll-padding"></p>
        <div class="scroll">
        <div class="scroll-bot">
        <div class="scroll-top">
        <div class="scroll-right">
        <div class="scroll-left">
        <div class="scroll-bot-right">
        <div class="scroll-bot-left">
        <div class="scroll-top-right">
        <div class="scroll-top-left">
        <div class="header-cp">
        <span><?php echo $lang['char_profiles'] ?></span>
        </div>
        <table class="scroll-content">
        <tr>
        <td><a class="title-cn"><span>Character Name</span></a></td><td><input maxlength="72" name="searchQuery" onblur="if (this.value=='') this.value=textEnterCharacterName" onfocus="this.value=''" size="16" type="text" value=""></td><td class="srch"><a class="scroll-search" onClick="javascript: return menuCheckLength(document.formSearchCharacter);"><span>Search</span></a></td>
        </tr>
        </table>
        </div>
        </div>
        </div>
        </div>
        </div>
        </div>
        </div>
        </div>
        </div>
        </form>
        <script type="text/javascript">
        document.forms['formSearchCharacter'].searchQuery.value = textEnterCharacterName;
        </script>
        </div>
        <?php
        	endcontenttable();
        }
        else
        {
        ?>
        <script type="text/javascript">
        	rightSideImage = "character";
        	changeRightSideImage(rightSideImage);
        
        	setcookie("cookieMenuText", "<?php echo $lang['characters'] ?>");
        	document.getElementById('replaceSearchOption').innerHTML = "<?php echo $lang['characters'] ?>";
        </script>
        <?php
        	startcontenttable();
        ?>
        <div class="profile-wrapper">
        <blockquote>
        <b class="icharacters">
        <h4>
        <a href="index.php"><?php echo $lang['armory_search'] ?></a>
        </h4>
        <h3><?php echo $lang['char_profiles'] ?></h3>
        </b>
        </blockquote>
        <?php
        	// urlencode for IE Cyrillic compatibility
        ?>
        <body onLoad="showResult('?searchQuery=<?php echo urlencode($_GET["searchQuery"]) ?>&realm=<?php echo urlencode(REALM_NAME) ?>','source/ajax/ajax-search-getresults.php')">
        <div id="ajaxResult">
        <span class="csearch-results-info"><?php echo $lang['search_result'] ?></span>
        </div>
        <?php
        	endcontenttable();
        }
        ?>

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Can you post the whole file, please. Also, omit the line numbers.

          Thanks,
          Mark.

          Comment

          • stefman123
            New Member
            • Nov 2009
            • 6

            #6
            just done it in an edit whiles you were typing sorry

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              Okay.

              Nowhere in that file do you create the $lang variable. Is the file you just showed included from another file from include(), require() or a function like that? If so, please post that file also.

              Comment

              • stefman123
                New Member
                • Nov 2009
                • 6

                #8
                it all links from this main index page
                Code:
                <?php
                define('Armory', 1);
                require "configuration/settings.inc.php";
                require "configuration/functions.php";
                require "configuration/mysql.php";
                require "configuration/output.inc.php";
                require "configuration/infoarray.php";
                require "configuration/resources.inc.php";
                require "configuration/defines.php";
                $o = new Output;
                $o->init();
                // Security Check //
                $PagesArray = array( 
                'idx' => 'main.php',
                'profile' => 'character-sheet.php',
                'characters' => 'charlist.php',
                'guilds' => 'guildlist.php',
                'guildinfo' => 'guild-info.php',
                'honor' => 'honorranking.php',
                'Items' => 'itemlist.php',
                'items' => 'itemlist.php',
                'iteminfo' => 'item-info.php',
                'arena' => 'arenaranking.php',
                'arenateams' => 'arenalist.php',
                'teaminfo' => 'team-info.php',
                'registration' => 'registration.php',
                'login' => 'login.php'
                );
                if(isset($_GET["searchType"]))
                {
                	if (array_key_exists($_GET["searchType"], $PagesArray))
                		define("REQUESTED_ACTION", $_GET["searchType"]);
                	else
                		define("REQUESTED_ACTION", 'idx');
                }
                else
                	define("REQUESTED_ACTION", 'idx');
                error_reporting(E_ALL);
                session_start();
                function session_security($fingerprint = 'fingerprint001')
                {
                	if(isset($_SESSION["HTTP_USER_AGENT"]))
                	{
                		if($_SESSION["HTTP_USER_AGENT"] != md5($_SERVER["HTTP_USER_AGENT"].$fingerprint))
                		{
                			print "Session Terminated. This has been recorded as a possible session hijack attempt and the session has been terminated for security reasons. If this is an inconvenience, please contact the administrator.<br><b>What this means:</b> You have been logged out.";
                			session_destroy();
                		}
                	}
                	else
                		$_SESSION["HTTP_USER_AGENT"] = md5($_SERVER["HTTP_USER_AGENT"].$fingerprint);
                }
                $o->string("<head>");
                $o->string("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/armory-css.css\">");
                // Tooltips stylesheet(s)//
                $o->string("<link rel=\"stylesheet\" type=\"text/css\" href=\"css/armory-tooltips.css\">");
                // Ajax //
                $o->string("<script src=\"source/ajax/coreajax.js\" type=\"text/javascript\">  </script>");
                $o->string("</head>");
                $o->string("<body OB_AFTER_BODYTAG>");
                $o->setobvar("AFTER_BODYTAG", "");
                // Javascript Tooltips //
                // aah //
                $o->string("<script type=\"text/javascript\" src=\"source/ajax/tooltipajax.js\"></script>");
                
                include "head.php";
                
                // Make sure the session is secure... //
                session_security();
                require_once $o->sourcefolder."/".$PagesArray[REQUESTED_ACTION];
                $o->string("<div id=\"loading-box\">LOADING</div>");
                
                // The final output call. Any $o-> calls after this will be ignored //
                $o->outputPage();
                
                include "foot.php";
                ?>
                which requiers
                settings.inc
                Code:
                <?php
                // for all options bellow: 1 - enable, 0 - disable
                $config = array(
                // MBA title
                "Title" => "The World of Warcraft Armory",
                // Client compatible with the server, 0 - 2.4.3, 1 - 3.0.3
                "Client" => 0,
                // Use registration page
                "Registration" => 0,
                // Use login page
                "Login" => 0,
                // Number of account registrations per IP, 0 - no limits
                "LockReg" => 0,
                // Lock accout to IP after registration
                "LockAcc" => 0,
                // The gmlevel which new accounts have
                "GmLevel" => 0,
                // The expansion which new accounts are using, 0 - Original, 1 - TBC, 2 - WotLK
                "AccExpansion" => 0,
                // Show source information for items
                "ShowSource" => 1,
                // Show Random Enchantments for items
                "ShowRandomEnch" => 1,
                // Show Disenchant information for items
                "ShowDisenchant" => 1,
                // Show error messages for items
                "ShowError" => 0,
                // Results number for Honor Ranking page
                "PvPTop" => 50,
                // Results number for Arena Ranking page
                "ArenaTop" => 50,
                );
                functions
                Code:
                <?php
                function GetCharacterPortrait($CharacterLevel, $CharacterGender, $CharacterRace, $CharacterClass)
                {
                	if($CharacterLevel <= 59)
                		return "wow-default/".$CharacterGender."-".$CharacterRace."-".$CharacterClass.".gif";
                	else if($CharacterLevel >= 60 && $CharacterLevel <= 69)
                		return "wow/".$CharacterGender."-".$CharacterRace."-".$CharacterClass.".gif";
                	else if($CharacterLevel >= 70 && $CharacterLevel <= 79)
                		return "wow-70/".$CharacterGender."-".$CharacterRace."-".$CharacterClass.".gif";
                	else if($CharacterLevel >= 80)
                		return "wow-80/".$CharacterGender."-".$CharacterRace."-".$CharacterClass.".gif";
                }
                function GetFaction($CharacterRace)
                {
                	if($CharacterRace == 1 || $CharacterRace == 3 || $CharacterRace == 4 || $CharacterRace == 7 || $CharacterRace == 11)
                		return "alliance";
                	else
                		return "horde";
                }
                function GetIcon($Type, $DisplayIconId)
                {
                	if($Type == "item")
                	{
                		$Table = "itemdisplayinfo";
                		$Field = "icon";
                	}
                	else //$Type == "spell"
                	{
                		$Table = "spellicon";
                		$Field = "name";
                	}
                	switchConnection("armory", REALM_NAME);
                	$DisplayIconQuery = execute_query("SELECT `".$Field."` FROM `".$Table."` WHERE `id` = ".$DisplayIconId." LIMIT 1");
                	if($row = mysql_fetch_assoc($DisplayIconQuery))
                		return "images/icons/64x64/".$row[$Field].".png";
                	else
                		return "images/icons/64x64/404.png";
                }
                function GetItemSource($item_id, $pvpreward = 0)
                {
                	global $lang;
                	switchConnection("mangos", REALM_NAME);
                	if(mysql_num_rows(execute_query("SELECT `entry` FROM `quest_template` WHERE `SrcItemId` = ".$item_id." LIMIT 1")))
                		return $lang['quest_item'];
                	else if(mysql_num_rows(execute_query("SELECT `entry` FROM `npc_vendor` WHERE `item` = ".$item_id." LIMIT 1")))
                		return $pvpreward ? $lang['pvp_reward'] : $lang['vendor'];
                	else if(mysql_num_rows(execute_query("SELECT `entry` FROM `gameobject_loot_template` WHERE `item` = ".$item_id." LIMIT 1")))
                		return $lang['chest_drop'];
                	else if(mysql_num_rows(execute_query("SELECT `entry` FROM `creature_loot_template` WHERE `item` = ".$item_id." LIMIT 1")))
                		return $lang['drop'];
                	else if(mysql_num_rows(execute_query("SELECT `entry` FROM `quest_template` WHERE `RewChoiceItemId1` = ".$item_id." OR `RewChoiceItemId2` = ".$item_id."
                	OR `RewChoiceItemId3` = ".$item_id." OR `RewChoiceItemId4` = ".$item_id." OR `RewChoiceItemId5` = ".$item_id." OR `RewChoiceItemId6` = ".$item_id."
                	OR `RewItemId1` = ".$item_id." OR `RewItemId2` = ".$item_id." OR `RewItemId3` = ".$item_id." OR `RewItemId4` = ".$item_id." LIMIT 1")))
                		return $lang['quest_reward'];
                	else
                		return $lang['created'];
                }
                function spell_bonuses($spell_id, $RandomSuffixValue = 0)
                {
                	switchConnection("armory", REALM_NAME);
                	$itemStat = array();
                	for($ii = 1; $ii <= 3; $ii ++)
                	{
                		if($sData = mysql_fetch_assoc(execute_query("SELECT `id`,`effect_basepoints_".$ii."`,`effect_aura_".$ii."`,`effect_misc_1` FROM `spell` WHERE `id` = ".$spell_id." LIMIT 1")))
                		{
                			if($sData["effect_aura_".$ii] == 13)
                			{
                				switch($sData["effect_misc_1"])
                				{
                					case 2: $magicSchool = "holydmg"; break;
                					case 4: $magicSchool = "firedmg"; break;
                					case 8: $magicSchool = "naturedmg"; break;
                					case 16: $magicSchool = "frostdmg"; break;
                					case 32: $magicSchool = "shadowdmg"; break;
                					case 64: $magicSchool = "arcanedmg"; break;
                					case 126: $magicSchool = "spelldmg"; break;
                					default: $magicSchool = "";
                				}
                				if($magicSchool)
                				{
                					if($RandomSuffixValue)
                						$itemStat[$magicSchool] = $RandomSuffixValue;
                					else
                						$itemStat[$magicSchool] = $sData["effect_basepoints_".$ii] + 1;
                				}
                			}
                			else if($sData["effect_aura_".$ii] == 135)
                			{
                				if($RandomSuffixValue)
                					$itemStat["healing"] = $RandomSuffixValue;
                				else
                					$itemStat["healing"] = $sData["effect_basepoints_".$ii] + 1;
                			}
                		}
                	}
                	return $itemStat;
                }
                function cache_item($itemid)
                {
                	global $config, $realms;
                	//Get item data
                	switchConnection("mangos", REALM_NAME);
                	if($config['locales'])
                	{
                		$nameloc = "name_loc".$config['locales'];
                		$itemData = mysql_fetch_assoc(execute_query("SELECT `name`, `".$nameloc."`, `Quality`, `displayid` FROM `item_template` LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry` WHERE `item_template`.`entry` = ".$itemid." LIMIT 1", "Error in item cache process for item ".$itemid));
                		if($itemData[$nameloc])
                			$itemData["name"] = $itemData[$nameloc];
                	}
                	else
                		$itemData = mysql_fetch_assoc(execute_query("SELECT `name`, `Quality`, `displayid` FROM `item_template` WHERE `entry` = ".$itemid." LIMIT 1", "Error in item cache process for item ".$itemid));
                	$db_fields = array(
                	"item_id" => $itemid,
                	"mangosdbkey" => $realms[REALM_NAME][2],
                	"item_name" => $itemData["name"],
                	"item_quality" => $itemData["Quality"],
                	"item_icon" => GetIcon("item",$itemData["displayid"]),
                	);
                	return InsertCache($db_fields , 'cache_item');
                }
                function cache_item_spellstats($itemid)
                {
                	global $realms, $CharItemStats, $stattype;
                	$itemStat = array();
                	foreach($CharItemStats as $key)
                		$itemStat[$key] = 0;
                	//Get item data
                	switchConnection("mangos", REALM_NAME);
                	$itemData = mysql_fetch_assoc(execute_query("SELECT * FROM `item_template` WHERE `entry` = ".$itemid." LIMIT 1", "Error in item cache process for item ".$itemid));
                	for($i = 1; $i <= 10; $i ++)
                	{
                		if($itemData["stat_type".$i])
                		{
                			$statId = $itemData["stat_type".$i];
                			if(array_key_exists($statId, $stattype))
                				if(array_key_exists($stattype[$statId], $CharItemStats))
                					$itemStat[$stattype[$statId]] += $itemData["stat_value".$i];
                		}
                		else
                			break;
                	}
                	for($i = 1; $i <= 5; $i ++)
                	{
                		// only when effect is triggered "on equip"
                		if($itemData["spellid_".$i] && $itemData["spelltrigger_".$i] == 1)
                		{
                			$spell_bonuses = spell_bonuses($itemData["spellid_".$i]);
                			foreach($spell_bonuses as $key => $value)
                				$itemStat[$key] += $value;
                		}
                	}
                	$db_fields = array(
                	"item_id" => $itemid,
                	"mangosdbkey" => $realms[REALM_NAME][2],
                	"item_frostdmg" => $itemStat["frostdmg"],
                	"item_firedmg" => $itemStat["firedmg"],
                	"item_naturedmg" => $itemStat["naturedmg"],
                	"item_shadowdmg" => $itemStat["shadowdmg"],
                	"item_arcanedmg" => $itemStat["arcanedmg"],
                	"item_holydmg" => $itemStat["holydmg"],
                	"item_healing" => $itemStat["healing"],
                	"item_spelldmg" => $itemStat["spelldmg"],
                	"item_spellpower" => $itemStat["spellpower"],
                	);
                	return InsertCache($db_fields , 'cache_item_spellstats');
                }
                function cache_item_tooltip($itemid)
                {
                	global $realms;
                	require_once "tooltipmgr.php";
                	$item_tooltip = outputTooltip($itemid);
                	$db_fields = array(
                	"item_id" => $itemid,
                	"mangosdbkey" => $realms[REALM_NAME][2],
                	"item_html" => $item_tooltip[0],
                	"item_info_html" => $item_tooltip[1],
                	);
                	return InsertCache($db_fields , 'cache_item_tooltip');
                }
                function cache_item_char($itemid, $owner, $slot, $itemguid, $itemlist)
                {
                	global $realms, $defines, $CharItemStats;
                	require_once "tooltipmgr.php";
                	$itemStat = array();
                	foreach($CharItemStats as $key)
                		$itemStat[$key] = 0;
                	$enchant_array = array(
                	$defines["PERMANENT"][CLIENT],
                	$defines["SOCKET_1"][CLIENT],
                	$defines["SOCKET_1"][CLIENT] + 3,
                	$defines["SOCKET_1"][CLIENT] + 6,
                	$defines["SOCKET_BONUS"][CLIENT],
                	);
                	switchConnection("characters", REALM_NAME);
                	$enchantmentsData = explode(' ', mysql_result(execute_query("SELECT `data` FROM `item_instance` WHERE `guid` = ".$itemguid." LIMIT 1"), 0));
                	// Random Enchantments
                	switchConnection("mangos", REALM_NAME);
                	$itemData = mysql_fetch_assoc(execute_query("SELECT `RandomProperty`, `RandomSuffix`, `ItemLevel`, `InventoryType`, `Quality` FROM `item_template` WHERE `entry` = ".$itemid." LIMIT 1", "Error in item cache process for item ".$itemid));
                	$FirstEnchant = $defines["RANDOM_1"][CLIENT];
                	if($itemData["RandomProperty"] || $itemData["RandomSuffix"])
                	{
                		if($itemData["RandomProperty"])
                			$FirstEnchant += 6;
                		else //if($itemData["RandomSuffix"])
                		{
                			switchConnection("armory", REALM_NAME);
                			$ItemRandomData = mysql_fetch_assoc(execute_query("SELECT `enchvalue_1`, `enchvalue_2`, `enchvalue_3` FROM `itemrandomsuffix`
                				WHERE `spellitemench_1` = ".$enchantmentsData[$FirstEnchant]." AND `spellitemench_2` = ".$enchantmentsData[$FirstEnchant+3]." AND `spellitemench_3` = ".$enchantmentsData[$FirstEnchant+6]." LIMIT 1"));
                		}
                		$enchant_array[] = $FirstEnchant;
                		$enchant_array[] = $FirstEnchant + 3;
                		$enchant_array[] = $FirstEnchant + 6;
                	}
                	switchConnection("armory", REALM_NAME);
                	foreach($enchant_array as $key)
                	{
                		if($enchantmentsData[$key])
                		{
                			$enchantment = mysql_fetch_assoc(execute_query("SELECT `statorspell1`, `statorspell2`, `statorspell3`, `type1`, `type2`, `type3` FROM  `spellitemenchantment` WHERE `id` = ".$enchantmentsData[$key]." LIMIT 1"));
                			for($i = 1; $i <= 3; $i ++)
                			{
                				if($enchantment["type".$i] == 3)
                				{
                					if($itemData["RandomSuffix"] && $key >= $FirstEnchant)
                					{
                						$suffixFactor = GenerateEnchSuffixFactor($itemData["ItemLevel"], $itemData["InventoryType"], $itemData["Quality"]);
                						$enchantvalue = round($suffixFactor*($ItemRandomData["enchvalue_".$i]/10000));
                						$spell_bonuses = spell_bonuses($enchantment["statorspell".$i], $enchantvalue);
                					}
                					else
                						$spell_bonuses = spell_bonuses($enchantment["statorspell".$i]);
                					foreach($spell_bonuses as $key => $value)
                						$itemStat[$key] += $value;
                				}
                			}
                		}
                	}
                	$db_fields = array(
                	"item_guid" => $itemguid,
                	"chardbkey" => $realms[REALM_NAME][1],
                	"item_owner" => $owner,
                	"item_slot" => $slot,
                	"item_html" => outputTooltip($itemid, $itemguid, $itemlist),
                	"item_frostdmg" => $itemStat["frostdmg"],
                	"item_firedmg" => $itemStat["firedmg"],
                	"item_naturedmg" => $itemStat["naturedmg"],
                	"item_shadowdmg" => $itemStat["shadowdmg"],
                	"item_arcanedmg" => $itemStat["arcanedmg"],
                	"item_holydmg" => $itemStat["holydmg"],
                	"item_healing" => $itemStat["healing"],
                	"item_spelldmg" => $itemStat["spelldmg"],
                	"item_spellpower" => $itemStat["spellpower"],
                	);
                	return InsertCache($db_fields , 'cache_item_char');
                }
                function cache_item_search($itemid)
                {
                	global $config, $realms;
                	switchConnection("mangos", REALM_NAME);
                	if($config['locales'])
                	{
                		$nameloc="name_loc".$config['locales'];
                		$itemData = mysql_fetch_assoc(execute_query("SELECT `name`, `".$nameloc."`, `ItemLevel`, `Quality`, `ItemLevel`, `Flags` FROM `item_template` LEFT JOIN `locales_item` ON `item_template`.`entry` = `locales_item`.`entry` WHERE `item_template`.`entry` = ".$itemid." LIMIT 1", "Error in item cache process for item ".$itemid));
                		if($itemData[$nameloc])
                			$itemData["name"] = $itemData[$nameloc];
                	}
                	else
                		$itemData = mysql_fetch_assoc(execute_query("SELECT `name`, `ItemLevel`, `Quality`, `ItemLevel`, `Flags` FROM `item_template` WHERE `entry` = ".$itemid." LIMIT 1", "Error in item cache process for item ".$itemid));
                	if(($itemData["Flags"] & 32768) == 32768)
                		$pvpreward = 1;
                	else
                		$pvpreward = 0;
                	$db_fields = array(
                	"item_id" => $itemid,
                	"mangosdbkey" => $realms[REALM_NAME][2],
                	"item_name" => $itemData["name"],
                	"item_level" => $itemData["ItemLevel"],
                	"item_source" => GetItemSource($itemid,$pvpreward),
                	"item_relevance" => $itemData["Quality"]*25+$itemData["ItemLevel"],
                	);
                	return InsertCache($db_fields, 'cache_item_search');
                }
                function InsertCache($db_fields, $db)
                {
                	// Insert
                	switchConnection("armory", REALM_NAME);
                	$querystring = "INSERT INTO `".$db."` (";
                	foreach($db_fields as $field => $value)
                		$querystring .= "`".$field."`,";
                	// Chop the end of $querystring off
                	$querystring = substr($querystring, 0, -1);
                	$querystring .= ") VALUES (";
                	foreach($db_fields as $field => $value)
                		$querystring .= "'".str_replace("'", "\'", $value)."',";
                	// Chop the end off again
                	$querystring = substr($querystring, 0, -1);
                	$querystring .= ")";
                	execute_query($querystring, "Could not cache: ");
                	return $db_fields; //return an associative array
                }
                function GetNameFromDB($Id, $table)
                {
                	switchConnection("armory", REALM_NAME);
                	$Query = execute_query("SELECT `name` FROM `".$table."` WHERE `id`=".$Id." LIMIT 1");
                	if($row = mysql_fetch_assoc($Query))
                		return $row["name"];
                	else
                		return "";
                }
                // validate input - preventing SQL injection
                function validate_string($string)
                {
                	$string = trim($string);
                	// strips excess whitespace
                	$string = preg_replace('/\s\s+/', ' ', $string);
                	if(preg_match('/[^[:alnum:]\sА-ПР-Яа-пр-я]/', $string))
                		$string = "";
                	return $string;
                }
                function exclude_GMs()
                {
                	global $config;
                	$excludeGMs = "";
                	if($config['ExcludeGMs'])
                		$excludeGMs = " AND (`extra_flags` & 1) = 0";
                	if(isset($_SESSION['GM']))
                		$excludeGMs = "";
                	return $excludeGMs;
                }
                function microtime_float()
                {
                	list($utime, $time) = explode(" ", microtime());
                	return ((float)$utime + (float)$time);
                }
                function ordinal_suffix($number)
                {
                	global $lang;
                	if(!$number)
                		return $lang["none"];
                	switch($number % 10)
                	{
                		case 1: return $number.$lang['st'];
                		case 2: return $number.$lang['nd'];
                		case 3: return $number.$lang['rd'];
                		default: return $number.$lang['th'];
                	}
                }
                function startcontenttable($class="full-list")
                {
                	echo "<div class=\"list\">
                	<div class=\"",$class,"\">
                	<div class=\"tip\" style=\"clear: left;\">
                	<table width=\"100\">
                	<tr>
                	<td class=\"tip-top-left\"></td><td class=\"tip-top\"></td><td class=\"tip-top-right\"></td>
                	</tr>
                	<tr>
                	<td class=\"tip-left\"></td><td class=\"tip-bg\">";
                }
                function endcontenttable()
                {
                	echo "</td>
                	<td class=\"tip-right\"></td>
                	</tr>
                	<tr>
                	<td class=\"tip-bot-left\"></td><td class=\"tip-bot\"></td><td class=\"tip-bot-right\"></td>
                	</tr>
                	</table>
                	</div>
                	</div>
                	</div>";
                }
                function showerror($errTitle, $errMessage)
                {
                	startcontenttable("team-side");
                	echo "Error - ",$errTitle,"<br>",$errMessage;
                	endcontenttable();
                }
                function guild_arenateam_tooltip_frame($type, $id, $name, $leader_name, $num_members)
                {
                	global $lang;
                	if($type == "guild")
                	{
                		$type_name = $lang["guild"];
                		$id_field = "guildid";
                		$leader = $lang["leader"];
                	}
                	else//if($type == "team")
                	{
                		$type_name = $lang["arena_team"];
                		$id_field = "arenateamid";
                		$leader = $lang["captain"];
                	}
                	$guild_arenateam_tooltip = "<a href=\"index.php?searchType=".$type."info&".$id_field."=".$id."&realm=".REALM_NAME."\" onmouseover=\"showTip('";
                	$guild_arenateam_tooltip .= "<span class=\'profile-tooltip-header\'>".$type_name." - ".$name."</span><br>";
                	$guild_arenateam_tooltip .= "<span class=\'profile-tooltip-description\'>".$leader.": ".$leader_name."<br>".$lang["members"].": ".$num_members."</span>";
                	$guild_arenateam_tooltip .= "')\" onmouseout=\"hideTip()\">".$name."</a>";
                	return $guild_arenateam_tooltip;
                }
                function guild_tooltip($guildid)
                {
                	global $lang, $guildInfoTooltip;
                	if(!$guildid)
                		return $lang["none"];
                	if(!isset($guildInfoTooltip[$guildid]))
                	{
                		switchConnection("characters", REALM_NAME);
                		$glinkresults = mysql_fetch_assoc(execute_query("SELECT `name`, `leaderguid` FROM `guild` WHERE `guildid` = ".$guildid." LIMIT 1"));
                		if($guildLeader = mysql_fetch_assoc(execute_query("SELECT `name` FROM `characters` WHERE `guid` = ".$glinkresults["leaderguid"]." LIMIT 1")))
                			$guildLeaderName = $guildLeader["name"];
                		else
                			$guildLeaderName = $lang["unknown"];
                		$guildMembers = mysql_result(execute_query("SELECT COUNT(*) FROM `guild_member` WHERE `guildid` = ".$guildid), 0);
                		$guildInfoTooltip[$guildid] = guild_arenateam_tooltip_frame("guild", $guildid, $glinkresults["name"], $guildLeaderName, $guildMembers);
                	}
                	return $guildInfoTooltip[$guildid];
                }
                function initialize_realm()
                {
                	global $realms;
                	if(isset($_GET["realm"]) && array_key_exists($realm_name = stripslashes($_GET["realm"]), $realms))
                		define("REALM_NAME", $realm_name);
                	else
                		define("REALM_NAME", DefaultRealmName);
                	switchConnection("armory", REALM_NAME);
                	define("CLIENT", mysql_result(execute_query("SELECT `value` FROM `conf_client` LIMIT 1"), 0));
                	define("LANGUAGE", mysql_result(execute_query("SELECT `value` FROM `conf_lang` LIMIT 1"), 0));
                }
                ?>
                ill post the rest up in a moment if this is what you meant but as you can see this isnt the code of a new programmer he took it and went mad i think i sent it to him and a week later i got it back with some fixes and around 20 new files there is some define functions at the bottom are those what im looking for?

                Comment

                • stefman123
                  New Member
                  • Nov 2009
                  • 6

                  #9
                  i got it fixed thanks for the help u nuged me in the right direction

                  Comment

                  Working...