gfxgfx
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
logo
 
gfx gfx
gfx
14537 Posts in 1904 Topics by 7002 Members - Latest Member: derhaluter July 31, 2010, 09:50:00 AM
*
gfx*HomeHelpSearchLoginRegistergfx
gfxgfx
0 Members and 1 Guest are viewing this topic.       « previous next »
Pages: [1] 2 Print
Author Topic: ISK-Sense blocking the page from loading  (Read 6342 times)
StukaRT
Newbie
*
Offline Offline

Posts: 4


« on: December 06, 2008, 10:18:47 PM »

Hey there,
isk-sense adds sometimes load rly slow or not at all, i have the same trouble on my site. But somehow on this site with firefox the whole jumpplaner stuff doesnt load when isk-sense hangs up. Maybe you are already aware of that problem, just thought i point it out, cause at the times isk-sense bugs around its a real hassle to use the jumpplaner Sad
Logged
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #1 on: December 06, 2008, 10:51:50 PM »

Yes, I noticed and I already have manually disabled ISK Sense a couple of times because of this. I'll try to come up with a better solution though.
Logged

Weeks of programming can save you hours of planning.
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #2 on: December 07, 2008, 12:56:00 AM »

Since you have the same problem I will post my solution here. It is not deployed on this server yet though, I need to make some additional changes because of the high volume of requests for this site. I want to cache the state of the isksense servers (if a requests times out I want it to ignore it for the next 5 minutes).

Anyway, I tried to do it using XMLHttpRequest, but some/most browsers will not allow you to make requests to a different site. My second approach was to dynamicly create a script element and attach it to a div where I wanted to display the ads. The problem is that my entire page get's ereased, I guess it has to do with the document.write.

My solution is to create a 'proxy' on my server that fetches the content from isksense and put it in an xml document:
Code: (isksenseproxy.php)
<?
// Create a context with the timeout set to 10 seconds
$cnx = stream_context_create(array('http' => array('timeout' => 10)));
if ($str = @file_get_contents('http://www.isksense.com/renderer/220', 0, $cnx)) {
        if (!preg_match('/document\.write\(\'(.*)\'\);/i', $str, $matches))
                $out = $str;
        else
                $out = $matches[1];
        $out = str_replace('\\\'', '\'', $out);
} else
        $out = '';

$xml = new DOMDocument('1.0', 'utf-8');
$content = $xml->createElement('content', $out);
$xml->appendChild($content);

header('Content-type: text/xml');
noCacheHeaders();
echo '<?xml version="1.0" encoding="utf-8"?>
',
$xml->saveXML($xml->documentElement);

?>
Don't forget to replace the number for your own ads or you will be sponsoring me (not that I would mind that). This script will fetch the ads, strip out the javascript document.write and remove the escaping on quotes. Then it is outputted as XML. If the request to isksense failes it will still output an XML document. noCacheHeaders does what the name suggests, for info see http://www.php.net/manual/en/function.header.php#75507

Next I added an id="isksense" to the attributes of the div that I want to display the ads in. The body-element got the attribute onLoad="javascript:placeISKSense();". Next I added this to my existing script file:
Code: (site.js)
function placeISKSense() {
        if (window.XMLHttpRequest) { // Mozilla, Safari,...
                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                        http_request.overrideMimeType('text/xml');
                }
        } else if (window.ActiveXObject) { // IE
                try {
                        http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                        try {
                                http_request = new ActiveXObject("Microsoft.XMLHTTP");
                        } catch (e) {}
                }
        }
        if (http_request) {
                http_request.onreadystatechange = function () {
                        if (http_request.readyState == 4) {
                                if (http_request.status == 200) {
                                        var d = document.getElementById('isksense');
                                        try {
                                                var txt = http_request.responseXML.getElementsByTagName('content')[0].firstChild.nodeValue;
                                        } catch(e1) {
                                                var txt = '';
                                        }
                                        if (txt == '') {
                                                d.style.display = 'none';
                                        } else {
                                                d.innerHTML = txt;
                                        }
                                }
                        }
                }
                http_request.open('GET', '/isksenseproxy.php');
                http_request.send('');
        }
        return;
}
This will make a request to the isksenseproxy.php script and will put the ads in the div. If the result is empty (i.e. the isksense website is down) it will hide the div.

I tested this in Internet Explorer, FireFox, Chrome and Safari.

I hope you can use it and post a link to your site so I can see it as well Wink
Logged

Weeks of programming can save you hours of planning.
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #3 on: December 07, 2008, 01:22:33 AM »

Talk about coincidence, I deployed it on this server and *BAM* isksense goes down. I swear I had nothing to do with it!

At least I know it works properly Tongue
Logged

Weeks of programming can save you hours of planning.
StukaRT
Newbie
*
Offline Offline

Posts: 4


« Reply #4 on: December 07, 2008, 11:26:50 AM »

You should post the function too Smiley


Code:
function noCacheHeaders ()
{
    /* gib Header aus, damit die folgende Seite oder Grafik nicht gecached wird */

    header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header ("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header ("Cache-Control: no-cache, must-revalidate");
    header ("Pragma: no-cache");
}

No i can retrieve the xml... but it doesnt display anything on my page... working on it. Thx so far!
Logged
StukaRT
Newbie
*
Offline Offline

Posts: 4


« Reply #5 on: December 07, 2008, 11:44:31 AM »

Ok great i did it on our corp homepage and it works good it seems Smiley  Need to do it on the forums now too... Thanks alot for sharing this.

http://www.geo-corp.net/index.php
Logged
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #6 on: December 07, 2008, 01:10:17 PM »

It seems to be working nicely at your site as well. I'm glad you can use it
Logged

Weeks of programming can save you hours of planning.
Seymour VanBuskirk
Newbie
*
Offline Offline

Posts: 2


« Reply #7 on: December 17, 2008, 12:49:29 PM »

I added isk-sense to my hosts file with an address of 127.0.0.1. It doesn't bother me anymore.  Grin
Logged
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #8 on: December 17, 2008, 03:34:34 PM »

I added isk-sense to my hosts file with an address of 127.0.0.1. It doesn't bother me anymore.  Grin

They should still show up for you on my website then since the ads are coming from my server. Your client (ie webbrowser) has no interaction with the isksense servers until you click on a advertisement (at least with this solution).

In this case you are trying to block eve related advertisements on a website. I don't care about the ISK; it ain't much anyway, and I use it to get my own ad out. But it gives smaller website owners an opportunity to advertise on some of the bigger eve related websites.

But that's a bit beside the point. The point is that you are trying to block advertisements on a website. If you would do that for advertisements that would gain revenue for the website owner, you are cutting the site from money that is being used to fund the website that you are using. That you are using for free. I know quite a few sites where you would get banned instantly if you would post something similar like you did here.

Please try to be supportive of the people that provide you with free services and content and do not block ads.
Logged

Weeks of programming can save you hours of planning.
Seymour VanBuskirk
Newbie
*
Offline Offline

Posts: 2


« Reply #9 on: December 19, 2008, 05:23:51 AM »

I unblocked it and it works correctly. I blocked it earlier because it was giving me a 30 second delay on every session change when using the jump planner.
Logged
Ix Forres
Newbie
*
Offline Offline

Posts: 2


« Reply #10 on: January 06, 2009, 10:52:56 PM »

As the guy who runs ISKsense, I do apologise for this.

Unfortunately because all the websites I operate (99% EVE related and free Tongue) are hosted on the same server and increasingly under fairly hefty load, the server occasionally has it's moments.

I am trying to work out some solutions like caching. A very easy Javascript fix is to add the 'defer="defer"' tag to the ISKsense tag. This allows the rest of the page to render in browsers before the javascript is forced to load. However, I intend to be switching all the apps I operate (EVE Metrics, ISKsense, RLS-EVE, and others) over to a caching system that will reduce load on the server and return some basic adverts if a response can't be fullfilled within a second or so.

I do try and keep people in the loop over at my blog (http://talkunafraid.co.uk) where possible, and you can see what the server's doing over here: http://talkunafraid.co.uk/status/

Once again, sorry for causing these problem, and hope that the updates for performance and stability I rolled out a few days back help.
Logged
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #11 on: January 06, 2009, 11:23:09 PM »

Hi Ix Forres,

I did not know about the defer-tag. The solution that I implemented works for me and I'll keep it going that way, unless there are strong objections against it. The only problem that I can see is that for your server it seems that all the impressions are coming from the same IP-address.

- Elissen
Logged

Weeks of programming can save you hours of planning.
Ix Forres
Newbie
*
Offline Offline

Posts: 2


« Reply #12 on: January 07, 2009, 12:31:05 AM »

Hi Ix Forres,

I did not know about the defer-tag. The solution that I implemented works for me and I'll keep it going that way, unless there are strong objections against it. The only problem that I can see is that for your server it seems that all the impressions are coming from the same IP-address.

- Elissen

So long as you pass along a new impression ID (The second number in the advert link URLs) each time, it's all good.  Duplicating those numbers would result in clicks not being registered.
Logged
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #13 on: January 07, 2009, 12:43:10 AM »

Each pageview does make a new request to your servers so that is covered.
Logged

Weeks of programming can save you hours of planning.
Elissen
Forum Administrator
Administrator
Hero Member
*****
Offline Offline

Gender: Male
Posts: 1596



« Reply #14 on: January 29, 2009, 08:58:49 PM »

The Isksense output changed. This is a new version of isksenseproxy.php
Code:
<?

if ($disabled = apc_fetch('isksensedisabled'))
        $out = '';
else {
        // Create a context with the timeout set to 10 seconds
        $cnx = stream_context_create(array('http' => array('timeout' => 10)));
        if ($str = @file_get_contents('http://www.isksense.com/renderer/220', 0, $cnx)) {
                $out = preg_replace('/\<style (.*)\<\/style\>/is', '',
                        preg_replace('/document\.write\(\'(.*)\'\);/i', '\1',
                                str_replace('\\\'', '\'', $str)));
        } else {
                $out = 'error';
                apc_store('isksensedisabled', true, 5 * 60);
        }
}
$xml = new DOMDocument('1.0', 'utf-8');
$content = $xml->createElement('content', $out);
$xml->appendChild($content);

header('Content-type: text/xml');
noCacheHeaders();
echo '<?xml version="1.0" encoding="utf-8"?>
',
$xml->saveXML($xml->documentElement);

?>

I added the CSS to my regular CSS file:
Code:
.isksense_ad {
        width: 160px;
        height: 50px;
        padding: 2px;
        margin: 4px;
        font-size: 12px;
        font-family: inherit;
        overflow: hidden;
        background: #141b24;
        border: solid none 0px;
        color: #C0C0C0
}

.isksense_a {
        color: white;
        font-weight: bold;
        font-size: 10px;
        border: 0px;
        text-decoration: none
}

Just go to your adsource url and copy paste it.
« Last Edit: January 29, 2009, 09:03:51 PM by Elissen » Logged

Weeks of programming can save you hours of planning.
gfx
Pages: [1] 2 Print 
gfx
Jump to:  
gfx
Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Page created in 0.085 seconds with 13 queries.
Helios Multi design by Bloc
gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!