ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Multipath, diffrent method (Wishlist)
Multipath, diffrent method // Wishlistgnu32Apr 7, 2005, 6:26am
Hello all
I want to use a diffrent multipath script for the Multipaths im currently hosting ,as they are unbelivably sluggish. I am using the multipath from Iceflare.net , which "downloads" the objects and then sends them to AW, not sure if that made sense, instead of just redirecting, which is why its sluggish. I could edit the script to redirect instead, but i am not a PHP expert and do not know what to do about it. I also tried the following multipath scripts, which either don't work or are similar: Andras perl Multipath PHP Multipath from Tengel Please help me on this, i seriously need to replace the current multipaths >_< -Gnu32 steve eApr 7, 2005, 12:26pm
Here's one I asked for in the worldbuilders newsgroup a while back, it
worked fine for me and I was able to customize it alot, It has all the nifty features of denying access outside of AW and also even limiting it to your own world! Here it is, I will post the version I use which removes all the security checking features following this, I don't require them due to the fact I password all my objects. // BEGIN PHP SCRIPT // <?php // modify those local path variables to your taste $localpath="/home/andras/rhapsody/"; // special objects only for those worlds $commonpath="/var/www/html/arts/"; // my general objects used in Storage2 $awpath="http://objects.activeworlds.com/aw/"; // common objects from AW // specify your world names you allow access $myworldname1="storage"; $myworldname2="rhapsody"; // check for illegal use (if you don't want to do that, remove the code between the lines) //------------------------------------------------------------------------- // First check on user agent (Active Worlds Browser - for the old browser, ActiveWorlds/3.60 for the new ones): $agent=$_SERVER['HTTP_USER_AGENT']; if (!isset($agent)) { // no user agent - we hate it! header('HTTP/1.1 403 Forbidden'); exit(); } if (!strstr($agent,"Active")) { // it is not an AW browser - kick him out!! header('HTTP/1.1 403 Forbidden'); exit(); } // Now check on the referer to prevent someone else using our path in a different world // WARNING! It will effectively disable anyone with an old browser to see the objects in your world // since it doesn't sent the referer to the OP host!! $refer=$_SERVER['HTTP_REFERER']; if (!isset($refer)) { // no referer - we hate it! header('HTTP/1.1 403 Forbidden'); exit(); } if (!strpos($refer,$myworldname1)&&!strpos($refer,$myworldname2)) { // bad referer - we hate it! header('HTTP/1.1 403 Forbidden'); exit(); } //------------------------------------------------------------------------- // now check the requested files: $rqname=substr(strstr($_SERVER['REQUEST_URI'],basename(__FILE__)),strlen(basename(__FILE__))+1); $filename=$localpath . $rqname; if (!file_exists($filename)) { $filename=$commonpath . $rqname; if (!file_exists($filename)) { $filename=$awpath . $rqname; header("Location: $filename"); # Redirect it to AW's OP exit (); } } $headers = getallheaders(); if(isset($headers["If-Modified-Since"])) { # $since = $_GET['If-Modified-Since']; # if ($since) // check if the modification time is more recent $currentModified = filemtime($filename); $rqtime=strtotime($headers["If-Modified-Since"]); if ($currentmodified<$rqtime) { // send "Not modified" header back header('HTTP/1.1 304 Not Modified'); exit(); } } // check the extension to set the proper mime type if (strpos($rqname,".zip")) { $ctype="application/zip"; } else { if (strpos($rqname,".jpg")) { $ctype="image/jpeg"; } else $ctype="application/download"; } $handle = fopen($filename, "rb"); header("Content-type: " . $ctype); header("Content-Length: " . filesize($filename)); fpassthru($handle); exit (); ?> // END PHP SCRIPT // steve eApr 7, 2005, 12:29pm
Modified version I use, does not have any security features and only
uses one local directory, not two.. lithium delusion.initrd.com # cat multi-op.php <?php $localpath="/var/www/delusion.initrd.com/"; $awpath="http://objects.activeworlds.com/megapath/"; $rqname=substr(strstr($_SERVER['REQUEST_URI'],basename(__FILE__)),strlen(basename(__FILE__))+1); $filename=$localpath . $rqname; if (!file_exists($filename)) { $filename=$awpath . $rqname; header("Location: $filename"); exit (); } $headers = getallheaders(); if(isset($headers["If-Modified-Since"])) { $currentModified = filemtime($filename); $rqtime=strtotime($headers["If-Modified-Since"]); if ($currentmodified<$rqtime) { header('HTTP/1.1 304 Not Modified'); exit(); } } if (strpos($rqname,".zip")) { $ctype="application/zip"; } else { if (strpos($rqname,".jpg")) { $ctype="image/jpeg"; } else $ctype="application/download"; } $handle = fopen($filename, "rb"); header("Content-type: " . $ctype); header("Content-Length: " . filesize($filename)); fpassthru($handle); exit (); ?> lithium delusion.initrd.com # gnu32Apr 8, 2005, 1:13am
Ive changed the code around to fit more OPs, but it only gets objects
from the 4th OP (Even when the same objects exist on the first 3), it seems like it goes straight for the 4th one: <?php $op1="<snip>"; $op2="<snip>"; $op3="<snip>/"; $op4="<snip>"; $rqname=substr(strstr($_SERVER['REQUEST_URI'],basename(__FILE__)),strlen(basename(__FILE__))+1); $filename=$op1 . $rqname; if (!file_exists($filename)) { $filename=$op2 . $rqname; if (!file_exists($filename)) { $filename=$op3 . $rqname; if (!file_exists($filename)) { $filename=$op4 . $rqname; header("Location: $filename"); exit (); } } } <snip> [View Quote] lady nighthawkApr 8, 2005, 1:50am
Might the problem be in the <snip>/ (backslash) ... either the others don't
have it, or they all should maybe have it? LNH -- [View Quote] lord fettApr 8, 2005, 2:03am
Here is the one I use:
<?PHP $aPaths = array ( "someplace.com/op" , "anotherplace.com/op" , "http://host.activeworlds.com/megapath" , "http://objects.activeworlds.com/aw" ); $fIn=$fOut=$IsZip=0; // this block is only needed if AW examines the HTTP header! if ($Content = strrchr ($QUERY_STRING, '.')) { if (stristr ($Content, ".zip")) Header ("Content-Type: application/zip"); else Header ("Content-type: image/jpeg"); } $Namepos = strrpos ($QUERY_STRING, '/'); $Filepath = substr ($QUERY_STRING, 0, $Namepos+1); $Filename = substr ($QUERY_STRING, $Namepos+1); Header( "Content-Disposition: attachment; filename=".$Filename ); $Firsttry = -1; if ($Filename[0] == '~') { $Firsttry = intval (substr($Filename,1,2))-1; $Filename = substr($Filename, 3); if ($Firsttry >= 0) if ($fIn = at fopen ($aPaths[$Firsttry].$Filepath.$Filename, "rb")) { fpassthru ($fIn); // no fclose, fpassthru() closes the file exit; } } $Anz = sizeof ($aPaths); for ($i=0; $i<$Anz; $i++) if ($i != $Firsttry) if ($fIn = at fopen ($aPaths[$i].$Filepath.$Filename, "rb")) { fpassthru ($fIn); // no fclose, fpassthru() closes the file exit; } ?> [View Quote] strike rapierApr 10, 2005, 11:51pm
Sweet jesus woman, use one that doesnt need Superglobals.
-- - Mark Randall http://zetech.swehli.com [View Quote] lord fettApr 11, 2005, 3:49am
Andras made me that script and it has worked every time without any
problems. Never knew there were so many versions of the multipath script until now. [View Quote] lady nighthawkApr 11, 2005, 5:45am
Strike what script are you referring to, can you post a sample or email it
to me? I'd like to multipath a couple of my worlds with megapath and aw, etc. Thanks :o} LNH -- [View Quote] gnu32Apr 19, 2005, 7:31pm
Just bringing this up again because the multipath i am using from Lord
Fett is just starting to be very unreliable. Before i start preparing to ditch Multipath, any more script variations out there? X_X [View Quote] |