Jump to content


Wrapper


  • You cannot reply to this topic
76 replies to this topic

#31 Dean

    Loves Etomite Forums!

  • Admin
  • 4,744 posts
  • Gender:Male

Posted 12 August 2005 - 06:18 AM

I think you are missing the concept of Snippets

What you need to do is go into your manager, and then to the Resources section

Choose add a New Snippet.

Paste the Snippet code into the big white box, and give it a name at the top (Wrapper)

Then edit the document you want the wrapper snippet on, and type in the editor [[Wrapper?wurl=http://www.mylinkgoeshere.com]]

And that should be it :D

#32 mark301

    Etomite Forum Newbie

  • Member
  • 34 posts

Posted 12 August 2005 - 01:40 PM

Let me clarify what I'm after: I've got quite a few documents I'd like wrapped, and I don't want to create another page for each just containing "[[Wrapper?...]]". What the existing Wrapper code does is return the contents of the Wrapper snippet - i.e. the html for an iframe wrapping my pre-existing content

I'd like Wrapper to use a generic wrapping page template and return a url to that template wrapping my document, like this:

<a href="[[Wrapper?wurl=http://mypage.com\1.htm]]"></a> should return me something like this<a href="http://mypage.com\wrapper.htm?url=1.htm"></a>

<a href="[[Wrapper?wurl=http://mypage.com\2.htm]]"></a> should return me something like this<a href="http://mypage.com\wrapper.htm?url=2.htm"></a>

If I could use PHP in a page, the wrapping template would be something like this:
[[Wrapper?wurl=<?php $_GET['url']?>]]


#33 Jelmer

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,173 posts

Posted 12 August 2005 - 04:32 PM

I'd say you'd have to have:
- A page with only [[Wrapper]] on it (e.g. wrapper.html)
- A slightly modified Wrapper snippet that gets it's $wurl like this:
$wurl = isset($wurl) ? $wurl : "http://www.mydefaultsite.com";
- Links to the page like this: http://www.yoursite.com/wrapper.html?wurl=...rapthispage.com

Didn't test it, but it should work.

Edit: Hmm with register_globals set to "off" this won't work of course. You could use this PHP instead:
$wurl = $_GET['wurl'];
if ($wurl == "") { $wurl = "http://www.mydefaultsite.com"; }

Please note that this code doesn't check for potential security hazards. It'll include allmost everything into your site...

Edited by Jelmer, 12 August 2005 - 05:37 PM.


#34 mark301

    Etomite Forum Newbie

  • Member
  • 34 posts

Posted 12 August 2005 - 06:45 PM

Bingo!

Jelmer, I thank you...

...I think :) That is indeed quite a security hole, dang!

#35 Guest_clubvibe_*

  • Guests

Posted 15 August 2005 - 12:17 PM

i'd like to implant jelmers mod into the wrapper code. but i don't fully understand where to put it.

Here is the code:

# With most gratitude to Jason Murphy (Jason407) for making the Mambo original;) 
# 
# Wrapper - Etomite v0.6 
# 
# Adapted for Etomite by: John Maats - john-at-pn.nl 
# 
# Usage: 
#    Set defaults and use [ [Wrapper] ] inside your content 
# 
# or call it with variables (example): 
#    [ [wrapper?wurl=http://etomite.com&wname=Etomite] ] 
# 
# Variable list: 
#  $wurl      = "http://etomite.com";  // What would you like to show? 
#  $wname     = "<b>Etomite</b>";          // Name to show 
#  $wshowname = "0";                       // show the name? 1 yes, 0 no 
#  $wwidth    = "700";                    // width , recommended 100% 
#  $wheight   = "600";                     // height, recommended 600 
#  $wscroll   = "auto";                    // auto, yes or no scrollbars visible 
#  $wauto     = "1";                       // auto resize 1 yes, 0 no 
#  $wframe    = "1";                       // show 1, hide 0 iframe borders 
#  $wlink     = "0";                       // show direct link 1 yes, 0 no 
#  $wwtext    = "Click here";              // Text for direct link 
# 
# If variable is not set, snippet will choose following defaults 

// your defaults, oh Master! 
$durl      = "http://etomite.com"; 
$dname     = "<b>Etomite</b>"; 
$dshowname = "0"; 
$dwidth    = "710"; 
$dheight   = "600"; 
$dscroll   = "auto"; 
$dauto     = "0"; 
$dframe    = "0"; 
$dlink     = "0"; 
$dwtext    = ""; 

// No need to change stuff underneath... 
// set defaults... 
$wrapped =""; 
if (!isset($wurl)) {$wurl = $durl; } 
if (!isset($wheight)) {$wheight = $dheight; } 
if (!isset($wwidth)) {$wwidth = $dwidth; } 
if (!isset($wscroll)) {$wscroll = $dscroll; } 
if (!isset($wframe)) {$wframe = $dframe; } 
if (!isset($wname)) {$wname = $dname; } 
if (!isset($wshowname)) {$wshowname = $dshowname; } 
if (!isset($wlink)) {$wlink = $dlink; } 
if (!isset($wwtext)) {$wwtext = $dwtext; } 

// check for http:// in url                                                   ********SOMEWHERE HERE ????***********
                                                                                      ********SOMEWHERE HERE ????***********
if (!(eregi("http://", $wurl) || (eregi("https://",$wurl)))) {    ********SOMEWHERE HERE ????***********
    $wurl = "http://".$wurl;                                                ********SOMEWHERE HERE ????***********
} 
// need resize? 
if ($wauto == "1"){ 
    $xload = "iFrameHeight()"; 
    $wrapped .= "<script language=\"JavaScript\">"; 
    $wrapped .= "function iFrameHeight() {"; 
    $wrapped .= "  var h = 0;"; 
    $wrapped .= "  if(document.getElementById && !(document.all))"; 
    $wrapped .= "  {"; 
    $wrapped .= "    h = document.getElementById('blockrandom').contentDocument.height;"; 
    $wrapped .= "    document.getElementById('blockrandom').style.height = h + 60 + 'px';"; 
    $wrapped .= "  }"; 
    $wrapped .= "  else if(document.all)"; 
    $wrapped .= "  {"; 
    $wrapped .= "    h = document.frames('blockrandom').document.body.scrollHeight;"; 
    $wrapped .= "    document.all.blockrandom.style.height = h + 20 + 'px';"; 
    $wrapped .= "  }"; 
    $wrapped .= "}"; 
    $wrapped .= "</script>"; 
} else { 
    $xload = ""; 
} 
$wrapped .= "<script language=\"JavaScript\">"; 
$wrapped .= "function blockError(){return true;}"; 
$wrapped .= "window.onerror = blockError;"; 
$wrapped .= "</script>"; 
$wrapped .= "<IFRAME id=\"blockrandom\""; 
$wrapped .= "onLoad=\"".$xload."\""; 
$wrapped .= "SRC=\"".$wurl."\""; 
$wrapped .= "width=\"".$wwidth."\" height=\"".$wheight."\" align=top scrolling=".$wscroll." frameborder=".$wframe.">Sorry, your Browser does NOT SUPPORT IFRAME.<br>You may want to Upgrade your Browser.<br><a href=\"".$wurl."\" target=\"_blank\">Click Here to see the page that was supposed to load.</a>".$wurl."</IFRAME>"; 
$wrapped .= "<div align=\"center\">"; 

// need to show name? 
if ($wshowname == "1") { 
    $wrapped .= $wname; 
} 
$wrapped .= "<br>"; 
// need to show link? 
if ($wlink == "1") { 
    $wrapped .= "<a href=\"".$wurl."\" target=\"_blank\">[".$wwtext."]</a></div>"; 
} 
return $wrapped;

now where do i have to put his:

$wurl = $_GET['wurl'];
if ($wurl == "") { $wurl = "http://www.mydefaultsite.com"; }

pardon my noob skills...

i'll explain why i want to use it:

i would like to use this url= http://www.knvb.nl/clubs_comp/?action=team...amDescription=9

with the wrapper. but it won't allow me to. As far as I understood this little Jelmer hack should do the trick, isn't it?

Edited by clubvibe, 15 August 2005 - 12:21 PM.


#36 Jelmer

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,173 posts

Posted 15 August 2005 - 12:31 PM

I'd put it right above these lines:
// No need to change stuff underneath... 
// set defaults... 
$wrapped ="";


#37 Guest_clubvibe_*

  • Guests

Posted 15 August 2005 - 12:48 PM

i did as you said,

(...)
$dlink     = "0"; 
$dwtext    = "";
$wurl = $_GET['wurl'];
if ($wurl == "") { $wurl = "http://www.google.com"; } 

// No need to change stuff underneath... 
// set defaults...

set it as above every wrapper element turns in to the default (google) page.

so

[[wrapper?wurl=http://www.knvb.nl/clubs_comp/?action=teamDetails&ClubName=Zoetermeer,%20FC&NotationDescription=Mannen%20beker%20reserve%20zondag%20poule&LevelDescription=Groep%207&CompetitionType=B1600&ClassLevel=27&RegionCode=KNVB-DISTRICT-WEST2&Pool=10&TeamDescription&wname=FCZ 9 Uitslagen]]

and also
[[wrapper?wurl=http://www.zoetermeer9.nl/fczoetermeer/statistieken.php&wname=Statistieken]]

become google.com

(it doens't matter if i set the url between " ")

become google

#38 Jelmer

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,173 posts

Posted 15 August 2005 - 01:01 PM

Yes, if you're planning to use only a few documents in the wrapper you can just use the normal Wrapper snippet, skip the extra lines. Then put [[Wrapper?wurl=blabla]] in your page and it should work.

This mod is used to make links to a single file with the URL to wrap included. I think you don't need it...

#39 Guest_clubvibe_*

  • Guests

Posted 15 August 2005 - 01:12 PM

without your mod this code works:

[[wrapper?wurl=http://www.zoetermeer9.nl/fczoetermeer/statistieken.php&wname=Statistieken]]

but this one won't:

[[wrapper?wurl=http://www.knvb.nl/clubs_comp/?action=teamDetails&ClubName=Zoetermeer,%20FC&NotationDescription=Mannen%20beker%20reserve%20zondag%20poule&LevelDescription=Groep%207&CompetitionType=B1600&ClassLevel=27&RegionCode=KNVB-DISTRICT-WEST2&Pool=10&TeamDescription&wname=FCZ 9 Uitslagen]]

page not found is the result (in a browser this url works just fine)

I tought your code was the answer to this problem.

and in a certain way it is. i experimented a bit and if i change the deafult page (i had google remember) in to this url : http://www.knvb.nl/clubs_comp/?action=team...TeamDescription

the wapper works.... but still all my pages ar this default page.

(check at http://www.zoetermeer9.nl/site)

Edited by clubvibe, 15 August 2005 - 01:13 PM.


#40 Jelmer

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,173 posts

Posted 15 August 2005 - 02:40 PM

ok i think you should use the original snippet and set $durl to your KNVB page.

#41 Guest_clubvibe_*

  • Guests

Posted 15 August 2005 - 08:38 PM

ok... but if I do so I can only use 1 page like the KNVB site (the default one).
----let me check----

As i tought everything work fine, but i can only use one KNVB site..

this is very weird... if I set the knvb site to the default it loads, but if I set it as a variable it won't work :S

Isn't there any solution?

I figured out why wrapper fails.. in the url: www.knvb.nl/clubs_comp/?action=teamDetails&ClubName=Zoetermeer,%20FC&NotationDescription=Mannen%20beker%20reserve%20zondag%20poule&LevelDescription=Groep%207&CompetitionType=B1600&ClassLevel=27&RegionCode=KNVB-DISTRICT-WEST2&Pool=10&TeamDescription

wrapper tries to read the questionmark (for more variables) isn't there anywhy to get round the questionmark? like a code that ignores the questionmark in the wurl? or only apply to 1 question mark (the first one) in the whole wrapper-request?

Edited by clubvibe, 15 August 2005 - 09:00 PM.


#42 Jelmer

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,173 posts

Posted 15 August 2005 - 09:08 PM

It won't work as a variable because the URL is a dynamic URL itself I think. There's no way you can pass this URL along to a script.

Anyone's :2c: ?

#43 Guest_clubvibe_*

  • Guests

Posted 15 August 2005 - 09:16 PM

i kind a solved it by making an iframe manualy. without wrapper that is. Works just fine... i think i just use this till wrapper has a 'support- dynamic-url-feature'.

just for the record, the manual code:
<script language="JavaScript">
function blockError(){return true;}
window.onerror = blockError; 
</script><iframe align="top" src="http://www.knvb.nl/clubs_comp/?action=teamDetails&ClubName=Zoetermeer,%20FC&NotationDescription=Mannen%20beker%20reserve%20zondag%20poule&LevelDescription=Groep%207&CompetitionType=B1600&ClassLevel=27&RegionCode=KNVB-DISTRICT-WEST2&Pool=10&TeamDescription" frameborder="no" width="600" height="600" />

Edited by clubvibe, 15 August 2005 - 09:19 PM.


#44 Jelmer

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,173 posts

Posted 15 August 2005 - 10:42 PM

Ok now for something completely different.

Since my site is almost finished I'm currently trying to make it XHTML1.1 compliant. I'll all work out, but the Wrapper snippet is a nightmare.

One of the things is dat it doesn't recognize the <iframe > tag nor any of it's attributes src, id etc etc. What's wrong with this code?

If anyone has made the entire snippet XHTML1.1 compliant I'd love to have it.

Regards.

Edit: Never mind, I threw out everything I didn't need, validates now...

Edited by Jelmer, 15 August 2005 - 10:51 PM.


#45 mark301

    Etomite Forum Newbie

  • Member
  • 34 posts

Posted 16 August 2005 - 01:46 AM

Just FYI, instead of <iframe>, XHTML 1.1 uses <object...>, just be sure to set the content type to "text/html". Look up the syntax for how to do it, it works well, though, in IE & FF. I just finished moving my site to XHTML 1.1 & updating all the snippets I use.

<object type="text/html" data="pagetobeiframed.htm">Sorry, your browser does not support Object elements.  Please use the link above to open it in a separate window</object>


#46 koeniman

    Likes Etomite Forums!

  • Member
  • PipPip
  • 215 posts

Posted 19 August 2005 - 02:51 PM

Hi,

This wrapper snippet works great. The only problem i have is that jou have to set the height, or scrollbars appear (or not but then a part is missing)
Isn't there an other way to include? The onlything (sofar:-) i use it 4 is to include a poll/survey, since there is no snippet available for this.

You can see what i mean on My Webpage


...and Safari for ex. doesn't support iFrames

Greets
Koen

edit: link removed by dean

Edited by Dean, 19 August 2005 - 03:44 PM.


#47 Jelmer

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,173 posts

Posted 19 August 2005 - 03:34 PM

Koen, some people on this forum could be offended by the sort of poll you're showing on your site. I don't think it's a wise choice putting it here...

#48 Dean

    Loves Etomite Forums!

  • Admin
  • 4,744 posts
  • Gender:Male

Posted 19 August 2005 - 03:44 PM

I agree - link removed.

#49 koeniman

    Likes Etomite Forums!

  • Member
  • PipPip
  • 215 posts

Posted 19 August 2005 - 04:18 PM

Hey guys, prob. right but... it was for testing purposes.

so anyway, made it a bit less r&r and more heu ... (nerdisch? :-)
Here is the url: My Censored Webpage

Now that's seatled: Can anybody help me on this? Inlude diffrently or having wrapper to work without the iFrame (not supported by all browsers incl. Safari)

Greets
Koen

#50 mark301

    Etomite Forum Newbie

  • Member
  • 34 posts

Posted 19 August 2005 - 07:18 PM

Here's my XHTML 1.1 valid version, with 2 modifications:
-I commented out the following 2 lines as I don't need them & didn't want to fix them:
// check for http:// in url
/*if (!(eregi("http://", $wurl) || (eregi("https://",$wurl)))) {
  $wurl = "http://".$wurl;
}*/
//$wrapped .= "onLoad='".$xload."' ";


Here's the goods:
#
# Wrapper - Etomite v0.6
#
# Adapted for Etomite by: John Maats - john-at-pn.nl
# Upgraded to XHTML 1.1 compliance by Mark301
#
# Usage:
#    Set defaults and use [ [Wrapper] ] inside your content
#
# or call it with variables (example):
#    [ [wrapper?wurl=http://etomite.com&wname=Etomite] ]
#
# Variable list:
#  $wurl      = "http://etomite.com";  // What would you like to show?
#  $wname     = "<b>Etomite</b>";          // Name to show
#  $wshowname = "1";                       // show the name? 1 yes, 0 no
#  $wwidth    = "100%";                    // width , recommended 100%
#  $wheight   = "600";                     // height, recommended 600
#  $wscroll   = "auto";                    // auto, yes or no scrollbars visible
#  $wauto     = "1";                       // auto resize 1 yes, 0 no
#  $wframe    = "thin black inset";        // css styling for the border
#  $wlink     = "1";                       // show direct link 1 yes, 0 no
#  $wwtext    = "Click here";              // Text for direct link
#
# If variable is not set, snippet will choose following defaults

// your defaults, oh Master!
$durl      = "http://etomite.com";
$dname     = "";
$dshowname = "1";
$dwidth    = "100%";
$dheight   = "600px";
$dscroll   = "auto";
$dauto     = "1";
$dframe    = "1";
$dlink     = "1";
$dwtext    = "Click here to open in new window!";

// No need to change stuff underneath...
// set defaults...
$wrapped ="";
if (!isset($wurl)) {$wurl = $durl; }
if(isset($_SESSION['wrapthisurl'])){$wurl=$_SESSION['wrapthisurl'];}
if (!isset($wheight)) {$wheight = $dheight; }
if (!isset($wwidth)) {$wwidth = $dwidth; }
if (!isset($wscroll)) {$wscroll = $dscroll; }
if (!isset($wframe)) {$wframe = $dframe; }
if (!isset($wname)) {$wname = $dname; }
if (!isset($wshowname)) {$wshowname = $dshowname; }
if (!isset($wlink)) {$wlink = $dlink; }
if (!isset($wwtext)) {$wwtext = $dwtext; }


// check for http:// in url
/*if (!(eregi("http://", $wurl) || (eregi("https://",$wurl)))) {
  $wurl = "http://".$wurl;
}*/

// need resize?
if ($wauto == "1"){
  $xload = "iFrameHeight()";
  $wrapped .= "<script type='text/javascript'>\n";
  $wrapped .= "function iFrameHeight() {";
  $wrapped .= "  var h = 0;";
  $wrapped .= "  if(document.getElementById && !(document.all))";
  $wrapped .= "  {";
  $wrapped .= "    h = document.getElementById('blockrandom').contentDocument.height;";
  $wrapped .= "    document.getElementById('blockrandom').style.height = h + 60 + 'px';";
  $wrapped .= "  }";
  $wrapped .= "  else if(document.all)";
  $wrapped .= "  {";
  $wrapped .= "    h = document.frames('blockrandom').document.body.scrollHeight;";
  $wrapped .= "    document.all.blockrandom.style.height = h + 20 + 'px';";
  $wrapped .= "  }";
  $wrapped .= "}";
  $wrapped .= "</script>\n";
} else {
  $xload = "";
}
$wrapped .= "<script type='text/javascript'>\n";
$wrapped .= "function blockError(){return true;}";
$wrapped .= "window.onerror = blockError;";
$wrapped .= "</script>\n";
$wrapped .= "<object class='blockrandom' type='text/html' ";
//$wrapped .= "onLoad='".$xload."' ";
$wrapped .= "data='".$wurl."' ";
$wrapped .= "style='width:" . $wwidth . "; height:" . $wheight . "; vertical-align:top; overflow:".$wscroll."; border:" . $wframe . ";'>\nSorry, your Browser does NOT SUPPORT IFRAME.<br/>\nYou may want to Upgrade your Browser.<br/>\n<a href='".$wurl."' {{targetBlank}}>Click Here to see the page that was supposed to load.</a>\n</object>\n";
$wrapped .= "<div style='text-align:center;'>\n";

// need to show name?
if ($wshowname == "1") {
  $wrapped .= $wname;
}
$wrapped .= "<br/>\n";
// need to show link?
if ($wlink == "1") {
  $wrapped .= "<a href='".$wurl."' {{targetBlank}}>[".$wwtext."]</a>\n</div>\n";
}
return $wrapped;






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users