Nov 17, 2010
looking back...
Nov 5, 2010
Howto: use your iPhone as webcam in Linux (without WebcamStudio)
I found a nice little app on the AppStore called iWebCamera which sounded like it could do just the trick! according to their website, iWebCamera could stream the images/video from you iPhone's camera to your computer. The catch here of course, is that you need their "driver" software installed on the computer. This is all fine..if you're on a Mac or Windows machine. Linux users aren't completely left out though, as the very handy "WebcamStudio" does support iWebCamera. However, the problem is that the current version (0.56 at the time of writing) doesn't support v4l2 (which I needed for skype compatibility)
*note; v4l2 support in WebcamStudio is coming in the next release. You're welcome to wait until it comes out. I did it this way because I didn't need the extra features WebCam studio.
let's get started after the break!
Oct 27, 2010
Tab Completion for Dhiraagu WebSMS Script
This script has been working perfectly for me since the day I wrote it. However, the problem was that my "directory" file had started to grow a little out of proportion, and I started having trouble remembering all the aliases I put in it. So I wanted to enable custom tab completions on the script.
Enter this tiny bit of code.
All you have to do is insert the following at the end of your bashrc file (usually in ~/.bashrc)
complete -F _bdwsmscomplete websms _bdwsmscomplete() { local CUR PRE OPTS CONTACTS local WSMSDIR="$HOME/.wsmsdir" #change accordingly CUR="${COMP_WORDS[COMP_CWORD]}" PRE="${COMP_WORDS[COMP_CWORD-1]}" OPTS="-h -v -s -d -u -p -n" CONTACTS="$(cut -f1 -d',' ${WSMSDIR})" if [[ ${CUR} = -* ]] then COMPREPLY=($(compgen -W "${OPTS}" -- ${CUR})) return 0 fi case ${PRE} in -n) COMPREPLY=($(compgen -W "${CONTACTS}" -- ${CUR})) return 0 ;; websms*) COMPREPLY=($(compgen -W "-n" -- ${CUR})) return 0 ;; esac return 0 }
If everything went well, you should be able to hit the [TAB] key while at the -n option and it'll automatically try to fill in the name of your contact.Enjoy!
P.S You'll need to re-open the terminal.
Oct 17, 2010
RELEASE - Thaana Keyboard for iPhone is now LIVE
It's here! So much for my "teaser campaign"..
If you have an iOS4+ (firmware 4.0 and above) device and you're jailbroken, you can now enjoy typing stuff (including emails,sms's,contacts,etc...) in Dhivehi, right from your phone. (yes...you can SMS other iPhones and some Android phones in thaana - see here and here on how to install thaana font on android)
Head on over to Cydia and put http://www.m0bi.com/cydia in your sources list.
Add the m0bi repo to your cydia sources,refresh and install the package from the package list. If you're a complete n00b and have no idea how to do that, follow this guide here on how to add cydia sources.
Hit the jump for a screenshot tour on how to enable the new keyboard.
So once you have the m0bi repo setup, tap on it and you'll be able to see all the packages from the repo. Look for iThaanaKB or Thaana (Phonetic) Keyboard in the list. tap..install... And follow the picture story below.
We are releasing this under the terms of GNULesser
Enjoy!
Many thanks and respect to kennyTM,fabkk2002 and all the other guys who helped out. Wouldn't have been possible without the work you guys put into it. And thanks once again to ap0 for the support and hosting.
Oct 16, 2010
iPhone Thaana Keyboard (Coming Soon)
Bringing the iPhone (I know you have one) a little close to home. Here is a little teaser for those of you interested.
Keey an eye out here, and don't forget to add http://www.m0bi.com/cydia to your cydia sources. (No this is NOT being developed by eLL M0bile's people in Malaysia. They had nothing to do with this.)
Oct 10, 2010
Dear eLL Mobile (and others)
Sep 29, 2010
Blog theme up for grabs.
It relies heavily on fancybox and jQuery so you'll need to add those. Also uses syntaxhighlighter. If you look closely you'll find that there's a very rough, custom brush for syntaxhighlighter in here that's used for chordpro highlighting.
Enjoy.
Download Template Here
Sep 22, 2010
Dhivehi for alQuran on iPhone is now LIVE!
grab it while it's fresh boys... in relation to my previous post here, Afxal an I have finally managed to push through the bundle to the public. Now this process is a wheeeeeeee hweeeeeeenee weeensy teeeeenee tiny bit risky so if you're very very unsure about it let somebody else help you out in installing.
Well there it is folks. Add http://m0bi.com/cydia to your cydia sources and enjoy!
As always, the release is issued under the terms of GNULesser license agreement.
Sep 21, 2010
Overhauling again
SO! welcome to the new layout. I've made some changes and optimized things a bit and added a few nice features like adding automatic lightboxing to all pictures. Now it hardly uses any images to do the layout, and also relies heavily on jQuery. I'm quite pleased with how this one came out. I wanted to phase out as much of the distractions as possible and make it as clean and elegant as I could.
Do let me know if something is broken though :)
Sep 20, 2010
iPhone Dhivehi Quran Translation
After much hacking away at the iPhone's file system over the last two days, I've finally managed to get Unicode thaana stuff to display properly on the iPhone iOS 4.x
THE BAD NEWS is that people using older 2G iphones running 3.x firmware are still outta luck on the unicode front. I'm working on it though...
anyway as a by product of the aforementioned success, I've managed to put together a little hack that'll add the Dhivehi translation of the Quran (as found on http://presidencymaldives.gov.mv/quran ) into the alQuran app from alMubin.com
the package will be available from afxals cydia repo at m0bi.com/cydia so just add that up and you'll be good to go. also depends on afxals thaana package for iOS, and erica utilities. Also you'll need to have alQuran installed. *if you needed me to tell you that then....well...what the hell..?*
here are some screenshots of it in action! (I KNOW that the text appears on the wrong side...I CAN fix it I just chose not to for reasons of...elegance lets say)
on the licensing side, since this will inevitably "mix" with non-free code, I am releasing it under GNULesser/LGPL
Now if you're curious on how I got the "dhivehi" to appear on the keyboard selection popup ... well let's just say I'm working on it.
Sep 11, 2010
Experimental Thaana Spell-checking with Hunspell
[NOTE: I am aware that this feature is available in "Xiosis Scribe", however their approach to this appears to be somewhat lacking and IMHO disappointing. Also, the closed source nature of their system pisses me of]
I decided to try and implement this by building a custom dictionary for hunspell. This approach has several advantages too great to be ignored. a) it eliminates the need to write the spell-check engine from the ground up. b) It provides immediate integration into software like openoffice and firefox (and potentially even MSWord) to name a few. Of course there is the risk that it might not be able to handle dhivehi's "rules" - but as I always say if the Arabs and the Hebrews can do it - and it has been done - then so can we.
So I used the scripts I wrote for The Radheef project to generate words, and wrote a simple affix file to munch it down with. Using a dictionary comprising of all the "headwords" in the Radheef, and this affix file I was able to obtain some promising results - enough to convince me that it just may be possible to achieve reasonable results using Hunspell.
and the saga continues...
The contents of the Affix file |
The test file to run the spell check on |
We give hunspell a chance to process it... |
and this is the resulting output ("misspelled" words with their suggestions) |
I hope I got the attention of some talented young out there and hope that you take an interest in this.
Sep 9, 2010
Get rid of MV Boli on Windows 7/Vista/Xp
Sadly though, MV Boli remains to haunt us.
FORTUNATELY though, it appears to be a relatively simple task to rid ourselves of this menace!
WARNING: Always make a backup of your registry before editing it.
The fix involves changing out two registry keys. I'm not entirely sure if changing the first one is absolutely necessary, but we'll do it anyway for good measure.
in the start menu search bar, type "regedit" and open it. (XP users type regedit in the Run dialog)
Once in the registry editor navigate to
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
Here you'll see a listing for a bunch of fonts. Scroll down until you find the name of your REPLACEMENT font (eg MV Faseyha). Double click this, and copy the value. Now scroll to where it says "MV Boli", double click it and paste the value you just copied into the dialog box. Click ok. Also make a note of the NAME of the replacement font. Choose the replacement font wisely. It has to be a good unicode font. I recommend MV Faseyha, Faruma or one of the fonts from the Iyyu or Elaaf family of fonts.
Now navigate over to
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes]from here find the key "MV Boli", double click it and change the value to the name of the replacement font exactly as it was in the previous list (without the "(open type)" bit) eg. "MV Faseyha","MV Iyyu Formal" etc...
save and exit. Then restart your system. Boli should be replaced now.
IF you're feeling super lazy, I've put together a small registry patch file that should do the work for you. However I do not recommend using this as the font file name and stuff may differ between systems.
Download HERE
thanks apo and ÎĦΣçҜәѓ™ for the help testing this out.
Dict Database for Dhivehi Radheef Update
by minor I mean a complete overhaul - I had to rewrite the entire conversion script because of the recent "hard drive crash". I've managed to fix the "number reversal" problem, and also changed the formatting a little. Also included in the dictionary now are additional information about the words like "kan ithuru","nan ithuru" and so on....
Otherwise everything is pretty much the same. Installation instructions can be found on the previous post HERE
updated files are here:
RAW zip: http://dl.dropbox.com/u/5385653/radheef/dict-radheef.zip
deb : http://dl.dropbox.com/u/5385653/radheef/dict-radheef1-03.deb
Sep 6, 2010
Zekr: Changing Translation Display Font
(This article also titled: getting rid of or changing MV Boli font in Zekr) - that DAMNED boli font!
in Zekr, goto Tools->Options and select "View" from the side column. From here click the add (+) button to add a new setting key and call it "trans_dv_fontName" and click OK. You can now change the value assigned to this key and add "MV Faseyha" (or any other font you like).
You can also add "trans_dv_fontSize" to specify the size of the translation text.
On a side note, if you want the Quranic text to display nicely, download and install the me_quran font from http://arabicfonts.wikispaces.com/
Sep 4, 2010
ADSL Usage checker update
I added a few more options like the ability to customize the output string, check for updates, and so on and so forth. Here's the updated script. It's a bit lengthy...
#!/bin/bash ################################################## # Ugly Dirty yet functional script to check ADSL # usage statistics for Dhiraagu subscribers. # # type ./dslusage -h for options # # This script is provided as is, without liabilities # or guarantee. # # 2010 KudaNai - http://kudanai.blogspot.com #------------------------------------------------- username= #your login name password= #your password here package_allowance=20 #must be specified version=0.2 #End of configuration section. PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" fmtstring="DSL Usage:\tGBUSEDGb / GBALLOWGb ( GBLEFTGb remaining)" #Default format string function pusage() { echo -e "\tUSEAGE: ${0}" cat ${0} | tail -n 23 | sed "s/#//g;s/VERSION/${version}/g" exit } function error() { echo -e "ERROR: $1\n" if [ -z $2 ];then pusage;fi exit } function checkupdate() { if [ -z $(which curl) ];then error "This functionality requires cURL. Please install it and try again" 1;fi local ver=$(curl --silent http://dl.dropbox.com/u/5385653/ddslcheck/ver) if [ $(expr ${ver} \> ${version}) -eq 1 ] then echo "A newer version ${ver} is available online." else echo "You are probably using the latest version." fi } while getopts 'vVUhu:p:f:' OPTION do case $OPTION in u) username=${OPTARG};; p) password=${OPTARG};; a) package_allowance=${OPTARG};; v) fmtstring="Dhiraagu ADSL Usage Details as on\n`date`\n\nCustomer:\tSUBSCRIBER (USERID)\nPackage:\tPACKAGE_NAME\nusage period:\tBILLING_START to BILLING_END (BILLING_CYCLE)\n\nDSL Usage:\tGBUSEDGb / GBALLOWGb ( GBLEFTGb remaining)";; V) cat $0 | tail -n 5 | sed "s/#//g;s/VERSION/${version}/g";exit;; f) fmtstring=${OPTARG};; U) checkupdate;exit;; h) pusage;; ?) pusage;; esac done if [ -z $(which img2txt) ]; then error "You need to install caca-utils before proceeding" 1;exit;fi if [ -z $(which wget) ];then error "You don't have wget installed...seriously?" 1;exit;fi if [[ -z ${username} || -z ${password} || -z ${package_allowance} ]]; then error "You need to specify username and password";fi cd /tmp # ---------------here on down everything is done inside temp wget --quiet --no-cache --post-data "web_user=${username}&web_pass=${password}" -p http://dsl.dhivehinet.net.mv/login.php if [ ! -f "dsl.dhivehinet.net.mv/comparision_graph.php" ];then error "Invalid username/password" 1;fi OIFS="{$IFS}"; IFS=$'\n' count=0 for LINE in $(sed -n 's/.*"#000080" size="2">\([^<]*\).*/\1/p' dsl.dhivehinet.net.mv/topframe.php;sed -n 's/.*through \(.*\) to \([^<]*\)<.*/\1\n\2/p' dsl.dhivehinet.net.mv/comparision_tpl.php) do ARR[${count}]=$LINE ((count++)) done IFS="${OIFS}" gstring=$(img2txt -H 400 -W 4 -d none -f ansi dsl.dhivehinet.net.mv/comparision_graph.php) gtotal=$(echo "${gstring}" | grep 44 | wc -l) gused=$(echo "${gstring}" | grep 43 | wc -l) gbused=$(echo "scale=3;${gused} / ${gtotal} * ${package_allowance}" | bc -l) gbleft=$(echo "scale=3;${package_allowance} - ${gbused}" | bc -l) echo -e "${fmtstring}" | sed "s/SUBSCRIBER/${ARR[0]}/g;s/USERID/${ARR[1]}/g;s/PACKAGE_NAME/${ARR[2]}/g;s/BILLING_CYCLE/${ARR[3]}/g;s/BILLING_START/${ARR[4]}/g;s/BILLING_END/${ARR[5]}/g;s/GBUSED/${gbused}/g;s/GBLEFT/${gbleft}/g;s/GBALLOW/${package_allowance}/g;" rm -r dsl.dhivehinet.net.mv # #OPTIONS: # -a Specify package allowance for limited connections. # -f Define custom format string. # -h Print this help. # -p Specify password. # -u Specify username. # -U Check for updates. # -v Verbose output. Print more details. # -V print version information and exit. # #FORMATTING: # The format string can by anything containing any of the following # special variables which will be substituted with appropriate values. # use \n,\t for newlines and tabs. # # SUBSCRIBER,USERID,PACKAGE_NAME,BILLING_CYCLE # BILLING_START,BILLING_END,GBUSED,GBLEFT,GBALLOW # # Dhiraagu DSLUsage checker # 2010 - KudaNai [ http://kudanai.blogspot.com ] # vVERSION #
Aug 26, 2010
Dhivehi Quran Translation now available for Zekr and Tanzil.info
Ramazan Mubarik fellow bretheren. It gives me great pleasure to (sort of) formally announce the release of the Zekr Quranic study tool with Dhivehi localization and translation packs.
I'm also happy to announce that www.tanzil.info now hosts the Dhivehi translation of the Holy Quran for everybody to enjoy, free of charge.
This has been part of a MOSS initiative, and I'd like to thank everybody who worked on the project with me. Particularly Mohamed Malik, Bunyameen and Sobah.
As of version 1.0 of Zekr, you can select "Dhivehi" as a display language under tools->options.
INSTALLATION is a simple three step process.
1. Download and install Zekr from www.zekr.org
2. Download the translation pack (see
3. Run Zekr. goto Tools->add->translation and select the zip file you just downloaded.
you can now select the translation under view->translation.
*note: if you encounter a "could not find Java VM" error, make sure you have a recent version of Java installed on your system. Download Java from http://www.java.com/en/download/
If you find any errors, please send an email to kudanai [yetu] gm[ail] dotu [comu]
you can find full details and installation instructions in this months MOSS magazine.
Zekr website
Aug 1, 2010
Hard-Drive Crash!!!
and it doesn't make things easier that I actually saw this one coming and did make a backup, only to discover that my backup drive was also faulty.
Well...it's going to take me a while to get back up on my feet again. I'm probably going to have to re-do all my little projects and stuff...
DAMNIT ALL TO HELL!!!
Jul 30, 2010
Eco Fashion and Maldives
And in our Spring lineup, we have this lovely number.
Made entirely of plastic bags for the Environment day exhibition held at A.Dh Hangnaameedhoo Madhrasa by two students; Reesh (9th Grade) and Iffath (10th Grade)
This sort of thing hardly ever gets the exposure it deserves.
Jul 28, 2010
Grab Dhiraagu ADSL usage from the terminal
Anybody who even occasionally stumbles on my blog should know full well by now that I have some personal beef with Dhiraagu. It's not that they suck..per se. It's just that I feel that they could, as a company, do much better.
Having said that, not having plain-text data available on the ADSL usage page (which incidentally has been trapped in a time-freeze-bubble since the 1960's) is just plain stupid on the part of whoever designed it. No matter though, where there is a will, there will be a way.
Previously I used to do it like this; Simply grabbing the graph image from the concerned page and popping it into eog so I can have a look.
wget --post-data "web_user=${username}&web_pass=${password}" -p http://dsl.dhivehinet.net.mv/login.php;eog ./dsl.dhivehinet.net.mv/comparision_graph.php;rm -r ./dsl.dhivehinet.net.mv
substitute ${username},${password} and eog as necessary.
But that wasn't enough..what If I wanted something in Conky or something to that effect? That would be a lot more convenient than having to look at that fart of a graph they have up there. So I came up with this simple solution.
SIMPLE but NOT ELEGANT... this is ugly, but it gets the job done.
#!/bin/bash #simple "hack" to grab and decode the ADSL usage #graph from Dhiraagu. No magic going on here. #require caca-utils (img2text) # #2010 KudaNai - http://kudanai.blogspot.com #------------------------------------------------- username= #your username password= #your password package_allowance=20 #your_package allowance cd /tmp wget --quiet --post-data "web_user=${username}&web_pass=${password}" \ -p http://dsl.dhivehinet.net.mv/login.php gstring=$(img2txt -H 400 -W 4 -d none -f ansi dsl.dhivehinet.net.mv/comparision_graph.php) #yes...gstring gtotal=$(echo "${gstring}" | grep 44 | wc -l) #blue colored line gused=$(echo "${gstring}" | grep 43 | wc -l) #yellow colored line gbused=$(echo "scale=3;${gused} / ${gtotal} * ${package_allowance}" | bc -l) gbleft=$(echo "scale=3;${package_allowance} - ${gbused}" | bc -l) echo "used: \t${gbused} Gb\nleft:\t${gbleft}Gb\nAllow: \t${package_allowance}Gb" rm -r dsl.dhivehinet.net.mv
Jul 25, 2010
Guitar Chords: Ey Hithaa
If you think the Original was good, you should hear the new one :)
Enjoy.
{t:Ey hithaa} {st:Out of Doors (Feat. Luba)} {c:Intro chords A#m, D#m , F } {c:Or play with Capo on 1st - Am,Dm,E} [A#m]Beyvafaa heydhen vaanvee, [A#m]roohu beynunvaa araamu dh[D#m]eefaa eyhith[F]aa, eyhi[A#m]thaa [A#m]Beynumeehey aniyaadheyn, [A#m]meyge vindhah fun araamu dh[D#m]eefa, eyhith[F]aa, eyhi[A#m]tha [A#m]Loabi veynee karunaigaa [A#m]thehmanee hey dhen mih[D#m]aaru heefaa, eyhit[F]haa, eyhi[A#m]tha [A#m]Loabi mee veyn libey th[D#m]oofaanakee hey, eyhi[F]thaa, eyhi[A#m]thaa {c:Interlude Riff} [A#m]Neydheme dhaaimee vey[D#m]naa mi hoonaa eyhi[Fm]thaa, eyhi[A#m]thaa [A#m]Ashigen mee loabeegaa, [A#m]hadhahaa veyneh libey engeyhey, ey hi[F]thaa, eyhi[A#m]thaa [A#m]Roohu loabin hehvaalaa [A#m]jaadhuvee hoonun ufaan[D#m]udhenhey ey hi[F]thaa, eyhi[A#m]thaa [A#m]Ishqugaa, dhen mivee beyk[D#m]aaruvaan hey... ey hi[F]thaa, eyhi[A#m]thaa Beyvafaa heydhen vaanvee, roohu beynunvaa araamu dheefaa eyhithaa Beynumeehey aniyaadheyn, meyge vindhah fun araamu dheefa, eyhithaa..eyhithaa
And here is a youtube video of the original song.
Jul 21, 2010
DICT database for Dhivehi Radheef
Anyway I've put it all together in a neat little deb file for you kids to install. It should tell you all the dependencies and stuff. Grab it..install it..voila.
Setup
at this time, you'll need to setup a DICT server on your local machine (or intranet..however you wanna roll) if you're installing from the deb, it should grab all the necessities for you, and all you have to do is point gnome-dictionary to the local DICT server.
do do this, go to edit->preferences and click "add". Enter whatever in the fields except hostname. HOSTNAME: 127.0.0.1 and that's it.
for you hardcore types.
http://ubuntuforums.org/showthread.php?t=145949
deb package : debian-all http://dl.dropbox.com/u/5385653/radheef/dict-radheef1-02.deb
no deb : http://dl.dropbox.com/u/5385653/radheef/dict-radheef.zip
Jul 16, 2010
Overhaulin'
Expect a few things to break in the meanwhile. Sorry about that..
Jul 5, 2010
To boldly go where I never thought I'd go...
The choice has been made though... there is no turning back.
Jun 22, 2010
Dhiraagu webSMS Conduit
I posted a simple bash script a long time ago to try and ease the process of sending webSMS's. While the age when everybody around here was messing around with the service is long gone, I have personally found the service to be quite useful (it's free after all!), and still occasionally mess around with it. The script works through and through and has served it's purpose well over the ages. The problem however, was that it still required the exchange of a (relatively) large amount of data between the client (me) and the server(Dhiraagu). While this is inconsequential on a regular broadband connection, it is a problem on my rather expensive mobile data connection.
Thus, out of this particular need, and after a brief spurt of late night coding (4:00 am - 4:15am?) the following PHP script was born. It is to live on my hosted server, and there act as a "Conduit" between myself and Dhiraagu. As you can see, it is, more or less, a "port" of the original Bash script to PHP...and I hope the PHP gods won't rain thunder and rocks on my head for the horrible job I did of it.
An unexpected upshot of this however, is that it allows me to use it over SSL which I suppose is always a good thing.
Anyways...here be the thing.
Enjoy.
<?php
/*....
PHP script to act as a go-between for Dhiraagu websms
to minimize data-exchange. Ideally for use over a
mobile network.
just upload the php file to some place that supports
php_curl and make a standard GET request to the file
with the follwing parameters:
user,pass,num,msg,<cookie>
where cookie is optional, and is the session string of
an existing session.
The Script returns a JSON encoded status message.
*/
$old_error_handler = set_error_handler("myErrorHandler");
$SessionData=array(
'status' => 'OK',
'count' => NULL,
'cookie' => NULL,
'retries' => 0,
);
function terminate_now() {
global $SessionData;
echo json_encode($SessionData)."\n";
exit(1);
}
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
global $SessionData;
if (!(error_reporting() & $errno)) {
return;
}
switch ($errno) {
case E_USER_ERROR:
$SessionData['status']="ERR: ".$errstr;
terminate_now();
break;
case E_USER_WARNING:
$SessionData['status']="WARN: ".$errstr;
break;
default:
$SessionData['status']="ERRUNKWN: ".$errstr;
terminate_now();
break;
}
return true;
}
function make_curl_request($url,$post_params,$useCookie) {
global $SessionData;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_AUTOREFERER,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_params);
curl_setopt($ch,CURLOPT_COOKIESESSION,1);
if($useCookie) {
curl_setopt($ch,CURLOPT_COOKIE,'Dhi='.$SessionData['cookie']);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function login()
{
global $SessionData;
$username=$_GET['user'];
$password=$_GET['pass'];
$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl',
'username='.urlencode($username).'&password='.urlencode($password),FALSE);
if(preg_match('/^Set-Cookie: Dhi=(.*?);/m', $return, $cookie_out)) {
$SessionData['cookie']=$cookie_out[1];
//CHECK DAILY QUOTA
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
if(($SessionData['count']=$msg_count[1])<1){ trigger_error('You have Reached your Daily Quota',E_USER_ERROR); } else { sendsms(); } } return true; } else { trigger_error('Invalid Username andor Password',E_USER_ERROR); return false; } } function sendsms() { global $SessionData; $number=$_GET['num']; $message=$_GET['msg']; if(strlen($message) > 140) {
trigger_error('Message Truncated',E_USER_WARNING);
$message=substr($message,0,140);
}
$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl',
'mobilenumber='.urlencode($number).'&message='.urlencode($message),TRUE);
//VALIDATE THE RETURN STUFF
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
$SessionData['count']=$msg_count[1];
} else {
if(($SessionData['retries']++)>3){
trigger_error('maximum number of retries exceeded',E_USER_ERROR);
}
login();
}
}
if (isset($_GET['user']) && isset($_GET['pass']) && isset($_GET['msg']) && isset($_GET['num'])) {
if(preg_match("/^7[4-9][0-9]{5}$/",$_GET['num'],$number)){
$_GET['num']=$number[0];
} else {
trigger_error('Invalid Number Format',E_USER_ERROR);
}
} else {
trigger_error('Insufficiant Arguments',E_USER_ERROR);
}
if(isset($_GET['cookie'])){
$SessionData['cookie']=$_GET['cookie'];
sendsms();
} else {
login();
}
terminate_now();
?>
Dhiraagu webSMS Conduit
I posted a simple bash script a long time ago to try and ease the process of sending webSMS's. While the age when everybody around here was messing around with the service is long gone, I have personally found the service to be quite useful (it's free after all!), and still occasionally mess around with it. The script works through and through and has served it's purpose well over the ages. The problem however, was that it still required the exchange of a (relatively) large amount of data between the client (me) and the server(Dhiraagu). While this is inconsequential on a regular broadband connection, it is a problem on my rather expensive mobile data connection.
Thus, out of this particular need, and after a brief spurt of late night coding (4:00 am - 4:15am?) the following PHP script was born. It is to live on my hosted server, and there act as a "Conduit" between myself and Dhiraagu. As you can see, it is, more or less, a "port" of the original Bash script to PHP...and I hope the PHP gods won't rain thunder and rocks on my head for the horrible job I did of it.
An unexpected upshot of this however, is that it allows me to use it over SSL which I suppose is always a good thing.
Anyways...here be the thing.
Enjoy.
<?php
/*....
PHP script to act as a go-between for Dhiraagu websms
to minimize data-exchange. Ideally for use over a
mobile network.
just upload the php file to some place that supports
php_curl and make a standard GET request to the file
with the follwing parameters:
user,pass,num,msg,<cookie>
where cookie is optional, and is the session string of
an existing session.
The Script returns a JSON encoded status message.
*/
$old_error_handler = set_error_handler("myErrorHandler");
$SessionData=array(
'status' => 'OK',
'count' => NULL,
'cookie' => NULL,
'retries' => 0,
);
function terminate_now() {
global $SessionData;
echo json_encode($SessionData)."\n";
exit(1);
}
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
global $SessionData;
if (!(error_reporting() & $errno)) {
return;
}
switch ($errno) {
case E_USER_ERROR:
$SessionData['status']="ERR: ".$errstr;
terminate_now();
break;
case E_USER_WARNING:
$SessionData['status']="WARN: ".$errstr;
break;
default:
$SessionData['status']="ERRUNKWN: ".$errstr;
terminate_now();
break;
}
return true;
}
function make_curl_request($url,$post_params,$useCookie) {
global $SessionData;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_AUTOREFERER,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_params);
curl_setopt($ch,CURLOPT_COOKIESESSION,1);
if($useCookie) {
curl_setopt($ch,CURLOPT_COOKIE,'Dhi='.$SessionData['cookie']);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
function login()
{
global $SessionData;
$username=$_GET['user'];
$password=$_GET['pass'];
$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl',
'username='.urlencode($username).'&password='.urlencode($password),FALSE);
if(preg_match('/^Set-Cookie: Dhi=(.*?);/m', $return, $cookie_out)) {
$SessionData['cookie']=$cookie_out[1];
//CHECK DAILY QUOTA
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
if(($SessionData['count']=$msg_count[1])<1){ trigger_error('You have Reached your Daily Quota',E_USER_ERROR); } else { sendsms(); } } return true; } else { trigger_error('Invalid Username andor Password',E_USER_ERROR); return false; } } function sendsms() { global $SessionData; $number=$_GET['num']; $message=$_GET['msg']; if(strlen($message) > 140) {
trigger_error('Message Truncated',E_USER_WARNING);
$message=substr($message,0,140);
}
$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl',
'mobilenumber='.urlencode($number).'&message='.urlencode($message),TRUE);
//VALIDATE THE RETURN STUFF
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
$SessionData['count']=$msg_count[1];
} else {
if(($SessionData['retries']++)>3){
trigger_error('maximum number of retries exceeded',E_USER_ERROR);
}
login();
}
}
if (isset($_GET['user']) && isset($_GET['pass']) && isset($_GET['msg']) && isset($_GET['num'])) {
if(preg_match("/^7[4-9][0-9]{5}$/",$_GET['num'],$number)){
$_GET['num']=$number[0];
} else {
trigger_error('Invalid Number Format',E_USER_ERROR);
}
} else {
trigger_error('Insufficiant Arguments',E_USER_ERROR);
}
if(isset($_GET['cookie'])){
$SessionData['cookie']=$_GET['cookie'];
sendsms();
} else {
login();
}
terminate_now();
?>
Jun 12, 2010
Bulk responding to facebook wallposts
Here's the dilema though, I can't be bothered to spend all the time going through the wall, clicking on links..responding blah blah. What I'd like to do, is respond to all of them in bulk. So here's my solution...
1.download all wallposts to a csv file
2.edit said csv file and add responses to those posts that i want to respond to
3.send off said responses.
How-to after the jump
May 10, 2010
If I'm going down...
and It's working... as you can see (yes I know this is a little vain, but I'm rather proud of my achievement)