Help and questions
0

502 Gateway Errors: A temporary solution?

Al Gobroedited
I'm aware that adfoc.us publicly announced that these errors will be fixed when they upgrade their database. But a month passed on the announcement and there have not been any developments on the issue since, according to the related thread.

These errors keep on being received by visitors, and I have noticed that sometimes situation persists more than a few minutes. As a result, our visitors probably judge our websites as sh*t. And this renders adfoc.us unreliable. As we don't know when exactly it will be fixed I need a solution. I don't want to divert my entire traffic permanently to an alternative shortener because adfoc.us pays good. So I ended up with following idea, not knowing if it will work, and how to do it:

I am not a programmer but I think its possible to place a javascript code on our websites in order to check if adfoc.us is running properly, and if not, replace adfoc.us links (easylinks) on our websites to an alternative (such as adfly) so that visitors don't get annoyed.

Can someone (including adfoc.us support) provide guidance on if its possible and how to do it?
Link4 repliesFrom our old forum (2011-2012)

This topic is from our old forum and is kept as it was. Start a new topic to ask about it.

  • AdFoc.usStaff
    You will only see the gateway errors from the 6th to 7th of the month for a total of 1-2 hours (maximum) from now on while we are processing payments. In the next month, we'll be replacing that system with something better optimized so there should (hopefully) be no gateway errors during this time.

    That said, I am sure you can create a script to do this but I don't see the 1-2 hours per month as being worthwhile.

    php.net/manual/en/book.curl.php would be a good place to start
  • Al Gobro
    Thanks.
  • fig2k4
    If you haven't already implemented this workaround, I came up with this today..

    <?php
    function get_headers_curl($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);

    return explode("\n", curl_exec($ch));
    }

    function get_http_response_code($url) {
    $headers = get_headers_curl($url);
    return explode(" ", $headers[0], 3);
    }
    ?>


    Use it something like this..

    <?php

    $rc = get_http_response_code("http://adfoc.us/?refid=9713");
    $use_ads = isset($rc[1]) && ($rc[1]==200);

    if (!$use_ads) {
    ?>
  • AdFoc.usStaff
    Nice work. 🙂