Forced ads..

Discussion in 'Programming' started by bquast, May 5, 2014.

  1. #1
    Pretty sure this is the right forum, but looking for a a way to serve forced ads on web pages that I am hosting, tutorials scripts etc, my current script hosts sites through whm / cpanel, but I want ads hosted on their websites not on their control panels.

    If anyone has any ideas etc it would be greatly appreciated, searched google but can't really find anything concrete
     
    bquast, May 5, 2014 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    I'll assume it's a "free" hosting setup that is ad supported, and I'll just ignore the whole argument if it's a good idea or a good business model or not and move on to the actual question...

    Either way you are going to have to alter their page source, which you could do by passing everything through an internal rewrite rule. Of course you will want to check that you are altering the base page and not content that goes along with it (like CSS, JS or images). From there, the simplest way would be to inject a single JavaScript line into the <head> section of their page which ultimately is your ad serving JavaScript.
     
    digitalpoint, May 5, 2014 IP
  3. bquast

    bquast Active Member

    Messages:
    275
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #3
    well i was looking at the apend function, still need to do a bit of research, and there accounts are not touchable from mine, so dont this .htaccess like that would work, it would have to be done by the apche global ini file from research, thanks for posting and giving me the idea, ill research more however and see
     
    bquast, May 5, 2014 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #4
    I'm going to actually say it...

    So... you WANT to make people not want to use your hosting? :D

    As to actually doing it, it really comes down to what you are going to support hosting; with static files (.html) it would be easy enough to just trap them with "AddOutputFilterByType" and just "SUBSTITUTE text/html", looking for some tag you know is going to be there like </body> and replace it with "yourAdCode</body>"... Been a while since I've done that (buggered if I can remember the syntax) but that's the best way if you aren't supporting CGI/SSI.

    Once you have code executing server-side this is where it can bite you; the biggest problem being that if the language is handling gzip compression instead of the server (like a lot of people do in PHP) you would either have to "buffer the output, decompress it, add your code, then send" or trap inside PHP's execution somehow -- otherwise anything you append is actually gonna result in a 500 error or worse, gibberish on the client-side of things.

    It's actually why most free hosts who pull these types of stunts generally don't allow PHP/Perl/ASP/Ruby/whatever'sTrendyThisWeek
     
    deathshadow, May 5, 2014 IP
  5. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #5
    I figured you'd probably save me the trouble. ;)
     
    digitalpoint, May 5, 2014 IP