Alfredo's blog

How to install Tomato Shibby in an ASUS RT-N66U router

Recently I flashed Tomato Shibby in an Asus RT-N66U router. To save you a pain and time here is what worked for me.

  • Download the latest Tomato Shibby firmware for the ASUS RT-N66U, file tomato-K26USB-1.28.RT-N5x-MIPSR2-140-AIO-64K.zip, from http://tomato.groov.pl/download/K26RT-N/build5x-140-MultiWAN/Asus%20RT-N...
  • Unzip the .trx file and save it somewhere in your PC
  • Plug the Ethernet cable to LAN 1 of the router and the other end to the Ethernet port on your PC.
  • Turn on the router
  • Open a web browser to 192.168.1.1 and login into the router with user admin and password admin.
  • Unplug the power cable from the router.
  • Place the router in recovery mode: hold the reset button and then plug the power back. Keep the reset button pressed all this time while you wait for the power icon to blink very slowly. It could take 10 seconds for you to see it blinking very slowly.
  • Refresh the browser page (192.168.1.1).
  • Download the ASUS firmware restoration utility from Asus website (https://www.asus.com/us/Networking/RTN66U/HelpDesk_Download/) or install it from the CD included with your router.
  • Run the ASUS firmware restoration utility and start flashing the Tomato .trx file you unzipped. Some people say it will complain that it's incompatible software. Ignore that message if you see it. I didn't see that message.
  • It will take maybe 15+ minutes for the firmware to get installed on the machine. Once the ASUS Firmware restoration is done unplug the ethernet cable from the PC. That seems to make the router reset faster. Leave the router alone until it resets itself. With the ethernet cable plugged in it seemed to take 30+ minutes for the firmware to take. With the ethernet cable unplugged it took maybe 5 minutes (I don't remember , but it was a lot faster).
  • Refresh the browser page and log into Tomato Shibby.

Migrating from ASPTear to MSXML2.ServerXMLHTTP

So I had to migrate some classic ASP code that uses ASPTear to instead use MSXML2.ServerXMLHTTP. ASPTear was used to get some HTML newsletters and email them. The problem was that there were strange characters returned by MSXML2.ServerXMLHTTP for any character above 127. After some digging online, turns out we have to get the data as binary and not as text and then convert the binary data into a string. I also decided to convert characters above 127 into this representation, &#127, to be sure they will display well in the emails. Hopefully this will help someone out there who's also migrating to MSXML2.ServerXMLHTTP.

ASPTear example code:

Dim objTear, myResponse
Dim myURL, Request_POST, Request_GET, strQueryStringOrPostData, strUsername, strPassword

Set objTear = CreateObject("SOFTWING.ASPtear")
myURL = "http://yourwebsite.com"
Request_POST = 1
Request_GET = 2
strQueryStringOrPostData = "&param=value"
strUsername = "theusername"
strPassword = "thepassword"

myResponse = objTear.Retrieve(myURL, Request_GET, strQueryStringOrPostData, strUsername, strPassword)

MSXML2 example code:
So be aware that responseText in MSXML2.ServerXMLHTTP assumes data is ASCII, so chars above 127 come back as 255. To solve that problem get the data using responseBody and then convert binary to a string. Below is an example:

Dim objTear, myResponse,
Dim myURL

Set objTear = CreateObject("MSXML2.ServerXMLHTTP.6.0")
myURL = "http://yourwebsite.com"
objTear.Open "GET", myURL, False
objTear.send ""

' Convert binary result to string.
myResponse = Stream_BinaryToString(objTear.responseBody, "iso-8859-1")

Sub Save2File (sText, sFile)
Dim oStream
Set oStream = CreateObject("ADODB.Stream")
With oStream
.Open
.CharSet = "iso-8859-1"
.WriteText sText
.SaveToFile sFile, 2
End With
Set oStream = Nothing
End Sub

'Code from http://www.motobit.com/tips/detpg_binarytostring/
'Stream_BinaryToString Function
'2003 Antonin Foller, http://www.motobit.com
'Binary - VT_UI1 | VT_ARRAY data To convert To a string
'CharSet - charset of the source binary data - default is "us-ascii"
Function Stream_BinaryToString(Binary, CharSet)
Const adTypeText = 2
Const adTypeBinary = 1

'Create Stream object
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")

'Specify stream type - we want To save text/string data.
BinaryStream.Type = adTypeBinary

'Open the stream And write text/string data To the object
BinaryStream.Open
BinaryStream.Write Binary

'Change stream type To binary
BinaryStream.Position = 0
BinaryStream.Type = adTypeText

'Specify charset For the source text (unicode) data.
If Len(CharSet) > 0 Then
BinaryStream.CharSet = CharSet
Else
BinaryStream.CharSet = "us-ascii"
End If

'Open the stream And get binary data from the object
Stream_BinaryToString = BinaryStream.ReadText
End Function

Using PHP to change file and directory permissions in a web server

Here is a PHP script to recursively change file and directory permissions in your web server. This is useful for Drupal users who have their sites hosted in web hosts that don't allow them to easily do a recursive chmod. This version is based on the one posted at http://drupal.org/node/34028 and is geared towards Drupal users.

This version will change the file and directory permissions to chmod 0555. If you need to change the permissions to something else, like chmod 0755, to work on the files just replace 0555 with 0755 in the script. It will skip the files at the root folder and it will also skip the "sites" directory and its files and sub directories. This is so that you can set those files to have different permissions or not mess up the current permissions they have (some people have "private" directories inside their "sites" directory).

To use the script, place it in your root Drupal folder, where the Drupal files are. Then in your browser visit http://yoursite.com/thisscript.php, where yoursite is the name of your website and thisscript is the name you gave this script. Delete the script from the server when you are done.

<?php
   // code based on http://drupal.org/node/34028
   // this version skips the sites folder
   // pass current directory
   file_fix_directory(dirname(__FILE__));

   function file_fix_directory($dir, $nomask = array('.', '..')) {
      if (is_dir($dir)) {
         if ($dir != dirname(__FILE__)){
            // Try to make each directory 0555 except the root dir and its files
            if (@chmod($dir, 0555)) {
               echo "<p>Made 0555: " . $dir . "</p>";
            }
         }
      }

      if (is_dir($dir) && $handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
            if (!in_array($file, $nomask) && $file[0] != '.') {
               if (is_dir("$dir/$file")) {
                  // skip "sites" folder, its subdirectories, and its files
                  if ($file != "sites"){
                     // Recurse into subdirectories
                     file_fix_directory("$dir/$file", $nomask);
                  }
               }
               else {
                  if ($dir != dirname(__FILE__)){
                     $filename = "$dir/$file";
                     // Try to make each file 0555
                     if (@chmod($filename, 0555)) {
                        echo "<p>Made 0555: " . $filename . "</p>";
                     }
                  }
               }
            }
         } // while

         closedir($handle);
      }
   } // function
?>

Pages

Subscribe to RSS - Alfredo's blog