Need help fixing some code..

Discussion in 'JavaScript' started by VsUK, Oct 28, 2010.

  1. #1
    Hi, i've been using a page that used to work fine from last time i used it a few months ago. However I've recently found a use for it again & some of the functions stopped working. What dosnt work is the popup on mouse over functions that it grabs the js from another website that the page is designed to work with externally on my own website.

    Anyways I've been on #javascript & they was more rude than helpful so I've decided to come here for some real help :D

    Anyways hope you can help me.. The full page script is below.

    
    <h1 class="title">Crew Vault Inventory</h1>
    <html>
    <head>
    	<link rel="STYLESHEET" type="text/css" href="http://torax.outwar.com/pop.css">
    	<script type="text/javascript" src="http://torax.outwar.com/js/jquery.min.js"></script>
    		
    	<!-- SLIDER JS INCLUDES	-->
    	<script type="text/javascript" src="http://torax.outwar.com/js/range.js"></script>
    	<script type="text/javascript" src="http://torax.outwar.com/js/timer.js"></script>
    
    	<script type="text/javascript" src="http://torax.outwar.com/js/slider.js"></script>		
    
    	<!-- MAIN JAVASCRIPT -->
    	<script language="javascript" src="http://torax.outwar.com/main.js"></script>
    
    	<!-- AJAX FUNCTIONS -->
    	<script language="javascript" src="http://torax.outwar.com/ajax.js"></script>
    
    	<!-- DRAG AND DROP -->
    	<script language="javascript" src="http://torax.outwar.com/drag.js"></script>
    
    
    	<!-- AnyLink Menu -->
    	<script type="text/javascript" src="http://torax.outwar.com/anylink.js"></script>
    </head>
    
    <body>
    <div id="tutorialtip"></div>
    <div id="dhtmltooltip" style="z-index:2000;"></div>
    
    <script type="text/javascript">
    disable_rollover = false;
    
    /************************
    * RAMPID TOOLTIP SYSTEM *
    ************************/
    var tutobj = document.getElementById("tutorialtip");
    var tutorial_text = '';
    var tipwidth = '';
    
    var showtut = false;
    
    var ie=document.all;
    var ns6=document.getElementById && !document.all;
    
    function ietruebody(){
    	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    function repositiontut()
    {
    		if(showtut)
    		{
    				var winWidth=document.all&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
    				var winHeight=document.all&&!window.opera? ietruebody().clientHeight : window.innerHeight
    				var floatHeight=tutobj.offsetHeight
    				var PageOffset=(ie) ?  document.body.scrollTop : window.pageYOffset
    				tutobj.style.left= winWidth-tipwidth-10+"px"
    				tutobj.style.top= PageOffset+winHeight-floatHeight-10+"px"
    			}
    }
    
    setInterval("repositiontut()", 250);
    
    </script>
    <script type="text/javascript">
    
    /***********************************************
    * Fixed ToolTip script- © Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    		
    var tipwidth='150px' //default tooltip width
    var tipbgcolor='lightyellow'  //tooltip bgcolor
    var disappeardelay=250  //tooltip disappear speed onMouseout (in miliseconds)
    var vertical_offset="5px" //horizontal offset of tooltip from anchor link
    var horizontal_offset="5px" //horizontal offset of tooltip from anchor link
    var offsetxpoint=10 //Customize x offset of tooltip
    var offsetypoint=-10 //Customize y offset of tooltip
    
    
    tipobj = document.getElementById("dhtmltooltip");
    
    /////No further editting needed
    
    var ie4=document.all
    var ns6=document.getElementById&&!document.all
    
    function positiontip(e){
    	var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
    	var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
    		
    	//Find out how close the mouse is to the corner of the window
    	var rightedge=ie4&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
    	var bottomedge=ie4&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
    
    	var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
    
    	//if the horizontal distance isn't enough to accomodate the width of the context menu
    	if (rightedge<tipobj.offsetWidth)
    		//move the horizontal position of the menu to the left by it's width
    		tipobj.style.left=ie4? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
    	else if (curX<leftedge)
    		tipobj.style.left="5px"
    	else
    		//position the horizontal position of the menu where the mouse is positioned
    		tipobj.style.left=curX+offsetxpoint+"px"
    
    	//same concept with the vertical position
    	if (bottomedge<tipobj.offsetHeight)
    		tipobj.style.top=ie4? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
    	else
    		tipobj.style.top=curY+offsetypoint+"px"
    	
    	tipobj.style.visibility="visible"
    }
    
    function fixedtooltip(e, menucontents, tipcolor, tipwidth){
    	positiontip(e);
    	if(tipcolor)
    		tipobj.style.backgroundColor=tipcolor;
    	tipobj.innerHTML=menucontents
    }
    
    function kill(){
    	tipobj.style.width="";
    	tipobj.style.height="";
    	tipobj.style.visibility="hidden"
    	offsetxpoint=10 //Customize x offset of tooltip
    	offsetypoint=-10 //Customize y offset of tooltip
    }
    
    function itempopup(e, itemid, item_data, server){
    	if(disable_rollover == true)
    		return;
    	
    	if(!item_data)
    		item_data = 0;
    	
    	offsetxpoint=0 //Customize x offset of tooltip
    	offsetypoint=20 //Customize y offset of tooltip
    	
    	tipobj.className = '';
    	tipobj.style.width='300';
    	fixedtooltip(e, 'Retrieving data...');
    	getPopup(itemid, item_data, server);
    }
    
    function getPopup(itemid,dat,server){
    	var myRand = parseInt(Math.random()*999999);
    	if(!server){
    		server = "2";
    	}
    	
    	send_url = "http://torax.outwar.com/item_rollover.php?id="+itemid+"&data="+dat+"&r="+myRand+"&serverid="+server;	requester = createRequester();
    	requester.onreadystatechange = function(){
    		if(requester.readyState == 4 && requester.status == 200){
    			tipobj.innerHTML = requester.responseText;
    		}
    	}
    	
    	requester.open("GET", send_url, true);
    	
    	if(OS == 'IE'){
    		requester.send();
    	}
    	else{
    		requester.send(null);
    	}
    }
    </script>
    
    <?php
    	$ch = curl_init();
    	login();
    	
    	$url = "http://torax.outwar.com/crew_vault.php";
    	$post = "prompt_number=1&answer=google&security_submitted=Continue";
    	$page = curl($url);
    	if (strpos($page, "Security Prompt"))
    		$page = curl('http://torax.outwar.com/security_prompt.php',$post);
    	$page = preg_replace("/\n|\r\n|\r|\t/", '' , $page);
    	$page = preg_replace("/\s\s*/", " ", $page);
    	preg_match_all("/<form(.*)form>/", $page, $matches);
    	$page = $matches[0][0];
    	$page = preg_replace("/> </", ">\r\n<", $page);
    	$page = preg_replace('/<td width="30" height="30".*?\r\n.*?(?:potion|orb\d|red|botset).*?\.(?:gif|jpg).*?\r\n<\/td>\r\n/', '', $page);
    	
    	preg_match("/^.*?<tr>\r\n<\/tr><tr>/s", $page, $matches);
    	$page2 = $matches[0];
    	$page2 = preg_replace("/<\/tr><tr>$/", '', $page2);
    	preg_match_all('/<td width="30" height="30".*?<img id="v_item_border\d*?" src="(.*?)" .*?\(event,\'(\d*?)\'\)".*?<\/td>/s', $page, $matches);
    	$items = $matches;
    	
    	for($i=0; $i<count($items[1]); $i++)
    	{
    		if ($i % 20 == 0 && $i != 0)
    		{
    			$page2 .= '</tr>' . "\r\n";
    			$page2 .= '<tr>' . "\r\n";
    			$page2 .= '<td width="30" height="30" align="center" valign="middle" style="background-image:url(http://torax.outwar.com/images/crewup/vault_tile.gif); width:30px; height:30px;padding:3px;">' . "\r\n";
    			$page2 .= '<img id="v_item_border' . $i . '" src="' . $items[1][$i] . '" style="border:0px;margin:0px;width:23px;height:24px;" ONMOUSEOVER="itempopup(event,\'' . $items[2][$i] . '\')" ONMOUSEOUT="kill()" onclick="selectItem(\'' . $i . '\');kill();">' . "\r\n";
    			$page2 .= '</td>' . "\r\n";
    		}
    		else
    		{
    			$page2 .= '<td width="30" height="30" align="center" valign="middle" style="background-image:url(http://torax.outwar.com/images/crewup/vault_tile.gif); width:30px; height:30px;padding:3px;">' . "\r\n";
    			$page2 .= '<img id="v_item_border' . $i . '" src="' . $items[1][$i] . '" style="border:0px;margin:0px;width:23px;height:24px;" ONMOUSEOVER="itempopup(event,\'' . $items[2][$i] . '\')" ONMOUSEOUT="kill()" onclick="selectItem(\'' . $i . '\');kill();">' . "\r\n";
    			$page2 .= '</td>' . "\r\n";
    		}
    	}
    	
    	echo $page2;
    	echo '</tr>' . "\r\n";
    	echo '</table>' . "\r\n";
    	
    	function curl($url,$post=null)
    	{
    		global $ch;
    		$cookies = "cookie.txt";
    		$post = is_null($post) ? '' : $post;
    		$ch = curl_init();
    		if ($cookies != '')
    		{
    			if (substr(PHP_OS, 0, 3) == 'WIN')
    			{
    				$cookies = str_replace('\\','/', getcwd().'/'.$cookies);
    			}
    			curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookies);
    			curl_setopt ($ch, CURLOPT_URL, $url);
    			curl_setopt ($ch, CURLOPT_POST, 1);
    			curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
    			curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookies);
    			curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    			curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
    			curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 300);
    			curl_setopt ($ch, CURLOPT_TIMEOUT, 300);
            
    			$html = curl_exec ($ch);
    			$html = parse($html);
    			return $html;
    		}
    	}
    	function login()
    	{
    		$user = "Username";
    		$pass = "Password";
    		$url = "http://torax.outwar.com/world.php?suid=2352013&serverid=2";
    		$post = "login_username=" . $user . "&login_password=" . $pass;
    		
    		curl($url,$post);
    	}
    	
    	function parse ($page)
    	{
    		$page = str_replace('src="images/','src="http://torax.outwar.com/images/',$page);
    		$page = str_replace("'/","'http://torax.outwar.com/",$page);
    		$page = str_replace('"/','"http://torax.outwar.com/',$page);
    		$page = str_replace('url(/images/','url(http://torax.outwar.com/images/',$page);
    		$page = str_replace('href="myaccount','href="http://torax.outwar.com/myaccount',$page);
    		$page = str_replace('src="accounts','src="http://torax.outwar.com/accounts',$page);
    		return $page;
    	}
    ?>
    
    
    Code (markup):

     
    VsUK, Oct 28, 2010 IP