here we go. Create a snippet called ’wrapssi’and here is the coide for the snippet:
<?php
$wurl1 = $wurl;
$wurl1 .= "/index.php";
if ($_SESSION['webUser']) {
$cpgpwd=$_SESSION['webValid'];
$wurl .= "/index_etomite.php?parm=";
$wurl .= base64_decode($_SESSION['webUser'] ) ;
$wurl .="|" ;
$wurl .= $_SESSION['webEmail'] ;
$wurl .="|" ;
$wurl .= $_SESSION['webValid'];
$wurl .="|" ;
$wurl .= $wurl1 ;
}
$wrapped = "<IFRAME id='myframe'";
$wrapped .= "SRC='".$wurl."'";
$wrapped .= "scrolling='no' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' style='overflow:visible; width:100%; display:none'></iframe>";
return $wrapped;
?>
next in your template add the following code (only to avoid double scrollbars) towards the end of the HEAD section:
<script type="text/javascript">
/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/
//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]
//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"
var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers
function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}
function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}
function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}
function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}
if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller
</script>
Call the application like:
[!wrapssi?wurl=http://yoursite.com/smf!]
Final step is to have a special index_etomite.php script which goes into the root directory of SMF.
Here is the code for that script:
<?php
require "smf_api.php";
$reqVar = '_' . $_SERVER['REQUEST_METHOD'];
$form_vars = $$reqVar;
$parm = $form_vars['parm'] ;
$url = explode("|", $parm);
$f_username = $url[0];
$f_usermail = $url[1];
$f_userpw = $url[2] ;
$f_pwd = base64_decode($f_userpw);
if ($f_username != ""){
if ($f_pwd == ""){
$f_pwd = ranpass() ;
}
$sql= "SELECT passwordSalt FROM $smf_settings[db_prefix]members WHERE memberName = '$f_username' LIMIT 1";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
if ($num_rows < 1){
// Insert the new user
$adding = smf_registerMember($f_username,$f_usermail,$f_pwd) ;
} else {
// update password
$password = sha1(strtolower($f_username) . $f_pwd);
$sql= "update $smf_settings[db_prefix]members set passwd='$password' WHERE memberName = '$f_username' ";
$result = mysql_query($sql);
}
}
$whereto = "./index.php" ;
$cookok = smf_setLoginCookie(3600, $f_username,$f_pwd, false) ;
if (!$cookok) {
}
$loginok = smf_authenticateUser() ;
if (!$loginok) {
}
Header ("Location: $whereto");
exit ;
function ranpass($len = "8"){
$pass = NULL;
for($i=0; $i<$len; $i++) {
$char = chr(rand(48,122));
while (!ereg("[a-zA-Z0-9]", $char)){
if($char == $lchar) continue;
$char = chr(rand(48,90));
}
$pass .= $char;
$lchar = $char;
}
return $pass;
}
?>
Basically all you need in combination with my snippet special index_etomite.php scripts.
Those i have for the afore mentioned applications.
Enjoy this solution.