Page 1 of 1

A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:02 pm
by Starblaster1234
As you probably know, with HTML you can write:

Code: Select all

<frameset cols="100%"><frame src="{URL}"></frameset>
to essentially copy the display of the target {URL} to display the same on your site, no matter what buttons are clicked unless they lead to a new page.

So herein lies the problem. I have a perfectly designed site that has a nice CMS that my graphic and content developers can work on. However it is a free site and the advertisements are quite unprofessional and unsightly. I would like to display the source code, but parse out the advertisements.

Why do I want to do this? Not only are the advertisements unsightly, but the URL is also not preferred and I would like my URL to be displayed instead.

How could I possibly do this? I've scoured all that Google has to offer (if you have some reading I can do that I missed, it would be appreciated) and would like some advice on how I can complete this task as easily and painlessly as possible. Any script is helpful.

To answer a few questions:
1. Do you have FTP access on both sites?
No, I only have FTP access on the local site, the target site is a free host.
2. Can you use any language?
Yes, javascript, java (applets), HTML, CSS, PHP, mySQL, etc. are fine. Pssh...even ActionScript is fine if you have an idea of how I could do it that way. However, ColdFusion is not okay...screw you eBay.

(if you have any more questions, feel free to ask)

Thank you for your time, I appreciate any help or advise on how to attack this problem.

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:37 pm
by daedalus__
hiiiiiiiiiii :)

let me try to understand.

you have a neat website with a cool cms that helps your content and graphics developers deliver content.

but the problem is that it is hosted on a free host and the unsightly advertisements are ruining the flow?

so you would like help to remove the advertisements?

i have two very loud thoughts about this..

one, thats probably a violation of the terms of service (ouch)

two, just cop the fifteen dollars for hosting!!!!!!!!!!

you can find hosting for a buck 99 a month

if i wanted to smoke one less cigarette a day, i would be able to afford hosting with the money saved.

awaiting your response, truly yours,
daedalus

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:43 pm
by Starblaster1234
Well no, the thing is that we are already paying for a host, but they don't have such a pretty CMS, and we'd like to use it. I'm not trying to steal it or find the cheap way out. Just trying to view it through a different site without the advertisements.

EDIT: It doesn't violate the ToS either...so HA! (just read it...it says nothing about it...a 1 paragraph ToS)

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:52 pm
by daedalus__
oh well thats different. are the ads inserted through javascript? you could just navigate the dom and set the containers to be hidden. that way you wont have to use an iframe.

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:53 pm
by Starblaster1234
Yeah...I believe they are using an iframe (whatever that is) actually...

I navigated through firebug and deleted it, but I need the php to do that when it calls the page.

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:54 pm
by daedalus__
can i see the page?

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:59 pm
by Starblaster1234
heh, nevermind...I figured it out.

I parsed though using strpos and this function this guy wrote strposnth (found the nth string position), then I just displayed the code from the next </center> point on to the end :D

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 9:59 pm
by daedalus__
wuh?? i wanna see!

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 10:20 pm
by Starblaster1234
Posting it in a second...just finishing up the code for it

EDIT: Read 'em and weep

Code: Select all

<?php
function strposnth($haystack, $needle, $nth=1, $insenstive=0)
{
    //if its case insenstive, convert strings into lower case
    if ($insenstive) {
        $haystack=strtolower($haystack);
        $needle=strtolower($needle);
    }
    //count number of occurances
    $count=substr_count($haystack,$needle);
   
    //first check if the needle exists in the haystack, return false if it does not
    //also check if asked nth is within the count, return false if it doesnt
    if ($count<1 || $nth > $count) return false;
 
   
    //run a loop to nth number of accurance
    for($i=0,$pos=0,$len=0;$i<$nth;$i++)
    {   
        //get the position of needle in haystack
        //provide starting point 0 for first time ($pos=0, $len=0)
        //provide starting point as position + length of needle for next time
        $pos=strpos($haystack,$needle,$pos+$len);
 
        //check the length of needle to specify in strpos
        //do this only first time
        if ($i==0) $len=strlen($needle);
     }
   
    //return the number
    return $pos;
}
 
 
if(isset($_GET["page"])){
$page = $_GET["page"];
}
 
$url = '{URL}'; // <!-- s:P --><img src=\"{SMILIES_PATH}/icon_razz.gif\" alt=\":P\" title=\"Razz\" /><!-- s:P --> Not showing you the url haha
$needle = '<center>';
$needle2 = '</center>';
$contents = file_get_contents($url);
$pos = strposnth($contents, $needle, 1, 1);
$pos2 = strposnth($contents, $needle2, 1, 1);
$pos3 = strposnth($contents, $needle, 1, 1);
$pos4 = strposnth($contents, $needle2, 2, 1);
if($pos !== false) {
echo substr($contents, 0, $pos);
echo substr($contents, $pos2, $pos4);
 
} else {
echo 'not found';
}
 
?>

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 10:26 pm
by daedalus__
oh i see what you are doing. good solution :)

i wanted to see it in action ):<

haha

yeah i like it.

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 10:28 pm
by Starblaster1234
ooo...fancy new problem. You're allowed to see it now haha.

Main page

Code: Select all

http://silenteternity.org
Target page

Code: Select all

http://silenteternity.page.tl/
My links won't work since they're being displayed on the page and not just called by the frameset. Any ideas?

I have one but I want to hear what you have to say first.

(get on MSN :P)

Re: A selective version of HTML's frameset

Posted: Fri Nov 27, 2009 11:21 pm
by daedalus__
im gonna have to help with this in a while like in either a few hours or tomorrow. girlfriend is home from work now and she wants me to spend time with her. :roll:

yeah the links work but they do link to the other domain. icky. im wondering if you can't just use that nifty function to populate the page on the .org domain with data rather than putting it into an iframe.

thats kind of what i thought you were doing in the first place.