Jump to content

Upside down internet


Recommended Posts

Upside down internet probably won't happen on the FON. I had a tough time working it out on my Linksys even with the SD card. giftrans and jpgflip will cross-compile after that it's a matter of setting up a transparent proxy (I tried a few different ones with limited success) and some iptable rules.

It's probably easier to have the FON redirect traffic through a laptop which serves as the proxy and horsepower/storage for the image flipping.

Link to comment
Share on other sites

Are you using this: http://www.ex-parrot.com/~pete/upside-down-ternet.html

There are websites that do it for you. You just have to forward the users request to the site that flips the page around. :)

I don't have any links at the moment, but a google should find you some. There is also the r-to-l thing to.

edit: working on a strictly PHP version

Link to comment
Share on other sites

It's probably easier to have the FON redirect traffic through a laptop which serves as the proxy and horsepower/storage for the image flipping.

That would be my preferred way of doing it, I doubt that the Fon has the power or storage to process it.

Link to comment
Share on other sites

Based on http://www.ex-parrot.com/~pete/upside-down-ternet.html done in PHP.

Semi working code. Needs a LOT of work and to be cleaned up, but for now just a proof of concept.

Does not seem to work for PNG files, not sure what the restrictions are on mogrify, but I coudl nto get it to flip mine. Gif and Jpgs work fine and flip over. The wget part is a bit of a mess and needs some refining. My PHP skills are not the best either, but this script works for the most part. Feel free to modify it and upload any fixes.


Basicly how it works is you redirect someone to your script, where flipit=somesite.com you want to flip upside down.



The script looks at the part after flipit and downlaods the page and images, then flips them, then displays the page to the user.

(This is really slow and buggy but does not require you to change any conf files or need to have squid running)

How you redirect users on your end is up to you, but thought I'd share what I have so far.

save it as upsidedown.php somewhere in its OWN directory!! NOT THE ROOT DIRECTORY OF YOUR DOMAIN!

ex: /flipit/upsidedown.php

    // 09/29/2009 Program: upsidedown.php
    // DigiP's UpsideDownTernet done in PHP using Mogrify to flip the images!
    //        Idea taken from  "http://www.ex-parrot.com/~pete/upside-down-ternet.html"
    //         -- Strictly a Proof Of Concept --  No need to edit your  /etc/dhcpd.conf or have squid to proxy files.
    //   The script is slow and buggy, so clean up the code for your own purposes! 
    //   This is just a starting point and as is does not work on all sites! ex: googles img tags: <img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276> will
    //   break the page and won't load the images. I'd like to find away to add my sites base name or path to the links,but havent firgured that part out yet.
    //   Does not work if links are written to the absolute path within the page itself, ex:  "http://www.somesite.com/images/image.jpg" vs  "/images/image.jpg"
    //       Redirect a user to your script for every request they make to a webpage, pasting the url they request after the flipit=
    //      ex: http://www.twistedpairrecords.com/upsidedown/sys.php?flipit=somesite.com
    //clear index.html in case some other sites uses .htm or default.htm, etc
    //system("echo  > index.html");
    $url = $_GET["flipit"];
    //     Download the files we need using wget
    //       http://www.twistedpairrecords.com/upsidedown/ is where I am storing my wget files. Change all occurances of this for your own site. 
    //                                  -r -l 1 means recursive, and -l # is how deep you want to dig.
    //system("wget -erobots=off --accept='html,htm,png,css,jpg,gif,swf' -m -r -l 1 –p -E –k -nH ./ $url --user-agent='Upside-Dwnter-Net' $url -do Debug.txt");
    system("wget -erobots=off --accept='html,htm,png,css,jpg,gif,swf' -r -l 1 –p -E –k -nH ./ $url --user-agent='Upside-Dwnter-Net' $url -do Debug.txt");



// Mogrify will allow us to flip all the images upside down. Your site will need this package. If not, install if from source at ImageMagick http://www.imagemagick.org/www/mogrify.html
system("echo  > mogrify.php");

$filename = "mogrify.php";
   function append_file($filename,$newdata) {
//Change ls command below depending on *nix or windows systems 
// system("dir ./ > dir.txt");
system("ls ./ > dir.txt");
    $file_handle = fopen("dir.txt", "r");
        while (!feof($file_handle) ) {
        $line_of_text = fgetcsv($file_handle, 1024);
        //Flip all the images UpSideDown!! This looks in sub folders. Not perfect but it works.
        append_file("mogrify.php","<? \n");
        append_file("mogrify.php","system('mogrify -flip /$line_of_text[0]/*.jpg'); \n");
        append_file("mogrify.php","system('mogrify -flip /$line_of_text[0]/*.gif'); \n");
        append_file("mogrify.php","system('mogrify -flip /$line_of_text[0]/*.png'); \n");
        append_file("mogrify.php","?> \n");

<?php include("./mogrify.php"); ?>

    //Does not seem to be working on PNG files. Not sure if Mogrify can edit them or not.
    // Flip any files in the current directory.
    system("mogrify -flip *.jpg");
    system("mogrify -flip *.gif");
    system("mogrify -flip *.png");


//set our url to change in each html file
$url2 = $_GET["flipit"];
    //Read in the file we want to edit.
    $myFile = "./index.html";
    $fh = fopen($myFile, 'r');
    $theData = fread($fh, filesize($myFile));

//Replace the data we want to change. Obviously change the script to match where you store your wget downlaoded files. DO NOT PLACE THIS SCRIPT IN YOUR ROOT SITE DIRECTORY! IT WILL ERASE YOUR FILES!!
$url3 = "http://www.twistedpairrecords.com/upsidedown/";
$tag = str_replace($url2, $url3, $theData );
    //easier to work with ' instead of "
    $tag1 = str_replace('"', "'", $tag );

$tag2 = str_replace("src='/", "src='http://www.twistedpairrecords.com/upsidedown/", $tag1 );
$tag3 = str_replace("SRC='/", "src='http://www.twistedpairrecords.com/upsidedown/", $tag2 );
$tag4 = str_replace("SRC='",  "src='http://www.twistedpairrecords.com/upsidedown/", $tag3 );
$tag5 = str_replace("src='",  "src='http://www.twistedpairrecords.com/upsidedown/", $tag4 );

//clean up double urls -- don't ask --
$tag6 = str_replace("http://www.twistedpairrecords.com/upsidedown/http://www.twistedpairrecords.com/upsidedown/", "http://www.twistedpairrecords.com/upsidedown/", $tag5 );

//echo $tag6;

 //Write out our changes to a file.
  function write_file($filename,$newdata) {
   }    //Saving to index2.html to debug
   write_file("./index.html", $tag6);

    //Clean Up Files
    header( 'Location: ./' );

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...