PDA

View Full Version : Need help with coding.


K33nny
06-26-2004, 03:17 AM
I'm in the process of taking on a large scale project that is hopefully going to help several fantasy wrestling hubs & hosts together. I got the idea for it after seeing iNet take over websites like Yaxay and so forth. They use a bar that links each website in their expansive network.

In fantasy wrestling there are several communities, some that have been around since prodigy some that have been around for 7-8 years, and ones like mine that have been around 2-4 years but are the most popular in the hobby. There are alot of divides between the major hubs, so in order to get rid of the gaps that exist most of the owners of these websites have agreed to partake in something similar. I started beta testing a bar but I quickly found out that it was slowing the forums down (both vBulletin & InvisionPB) as well as messing with the forums sessions.

I will list the code below that is being used to call the bar, what is the PHP file, and waht the content of the include file is. If you could possibly help me figure out why it' s slowing websites down and messing with forum sessions it would be appreciated.

What I mean by messing with the sessions, it rarely shows if someone is browsing anything past the Main Index (on vBulletin & InvisionPB). When I remove the call code for the bar things go back to normal so I know it's a problem with the bar.

Keep in mind the bar is being called from a different domain on a completely different server. This is how it has to be because there are several websites involved that aren't on the same server, such is life. It would be so much easier if we were all on the same server but that will never happen. ;)

Code calling the neXus bar
This is the easiest way for me to distribute the bar across several platforms. Not everyones website is made using PHP so I had to come up with a decent solution. COuld the javascript be causing the problem maybe? ID is a variable that represents the website the bar is being called from. IN the future statistics will be collected for each website.

<!-- BEGIN EWNEXUS.COM NETWORK BAR -->
<script language="JavaScript1.2" type="text/javascript">
<!--
document.write ("<" + "script language='JavaScript' type='text/javascript' src='http://www.ewnexus.com/x-files/bar.php?id=ewp'><" + "/script>");
// -->
</script>
<!-- END EWNEXUS.COM NETWORK BAR -->


bar.php
Script calling the bar HTML and outputting it

<?

// Variables

$bar = file_get_contents("http://www.ewnexus.com/x-files/bar.inc", "r");

// Functions

function encode ($str, $limit = 60) {
$str = str_replace("\r", '', $str);

print "var ewnexus = '';\n\n";

while (strlen($str) > 0) {
$line = substr ($str, 0, $limit);
$str = substr ($str, $limit);

$line = str_replace('\\', "\\\\", $line);
$line = str_replace('\'', "\\'", $line);
$line = str_replace("\r", '', $line);
$line = str_replace("\n", "\\n", $line);
$line = str_replace("\t", "\\t", $line);
$line = str_replace('<', "<'+'", $line);
print "ewnexus += '$line';\n";
}
print "\ndocument.write(ewnexus);\n";
}

if ($_GET['id'] == "") {
echo "Restricted access. Contact info@ewnexus.com for information.";
}
elseif ($_GET['id'] == "ewp") {
header("Content-type: application/x-javascript");
encode($bar);
}
elseif ($_GET['id'] == "ptc") {
header("Content-type: application/x-javascript");
encode($bar);
}
elseif ($_GET['id'] == "rwn") {
header("Content-type: application/x-javascript");
encode($bar);
}
else {
echo "Restricted access. Contact info@ewnexus.com for information.";
}

?>


bar.inc
Include file that bar.php grabs. A basic template file for the bar HTML.

<link rel="stylesheet" type="text/css" href="http://www.ewnexus.com/x-files/bar.css">
<table width="100%" height="32" cellpadding="0" cellspacing="0" background="http://www.ewnexus.com/x-imgs/bar/bg.gif">
<tr valign="middle">
<td><img src="http://www.ewnexus.com/x-imgs/bar/logo.gif"" width="147" height="32"></td>
<td align="right">
<table cellpadding="0" cellspacing="0">
<tr>
<td><img src="http://www.ewnexus.com/x-imgs/bar/divider.gif" width="5" height="32" hspace="0" vspace="0"></td>
<td class="xmenu">
<form name="menu">
<select name="bar"" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO" class="xdestination">
<option selected class="xtitle">-- Hubs</option>
<option value="http://www.ewplanet.com" class="xsite">eWPlanet</option>
<option value="http://www.primetimecentral.com" class="xsite">Primetime Central</option>
</select>
<form/>
</td>
<td><img src="http://www.ewnexus.com/x-imgs/bar/divider.gif" width="5" height="32" hspace="0" vspace="0"></td>
<td class="xmenu">
<form name="menu">
<select name="bar"" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO" class="xdestination">
<option selected class="xtitle">-- Hosts</option>
<option value="http://www.ewplanet.com" class="xsite">TPNHosting.com</option>
<option value="http://www.primetimecentral.com" class="xsite">eWrestle.net</option>
</select>
<form/>
</td>
</tr>
</table>
<td></td>
</tr>
<tr>
<td height="1" bgcolor="#000000"><img src="" height="1"></td>
</tr>
</table>


:tired:

vbmechanic
06-26-2004, 11:21 AM
I took a good look at your problem and I couldn't find the issue. After looking over all of the code, line by line, I did not see how it could mess with the sessions of two separate applications on different servers.

I then tested to see what the response speed was like from the bar host. Pretty fast; nothing slow about it. Then I put it in a web page and it loaded up just as quickly.

Next I put the bar into a sample forum skin to see it live... worked like a charm. Nothing slowed down and who's online was still displaying the proper location. You can see it here:

http://www.vbmechanic.com/skins/index.php?styleid=7

Sorry, but I don't see how it is slow or affecting sessions at all. Granted, the board only has 9 people on it at the moment, but it shouldn't make that much difference.

K33nny
06-26-2004, 05:39 PM
You probably won't notice a slow down with high speed access but I noticed a slow down on a dialup connection.

The one thing the bar is doing is effecting the who's online bit for some reason. It keeps people stuck on "View index"

vbmechanic
06-26-2004, 11:44 PM
I couldn't get the bar to affect the who's online on my forum. I still have it in the style-- you can test it yourself using two browsers. I put myself into a thread in one browser and went to view who's online in another, and it worked without hassle.

Also-- seeing a speed problem with dialup would indicate that you have a poor connection between you and the bar. Wouldn't you think that with a high speed connection, I would notice the delay more? If the rest of the page loaded fast, but the bar was slowing things down, I think I would see it.

Not doubting you on anything, just doing some testing for you-- you can see on my unrelated site that the bar is working as planned. Looking over the code, it works like I'd expect.. can't imagine how it would affect sessions on distinct servers.

vbmechanic
06-26-2004, 11:46 PM
Screenshot of me using who's online w/ the bar and viewing a thread..

K33nny
06-27-2004, 02:50 AM
It doesn't seem to effect everyone. I'm not sure what the problem is but I'm going to rethink the process and start over. Thanks for your help.