Tampilkan postingan dengan label programming. Tampilkan semua postingan
Tampilkan postingan dengan label programming. Tampilkan semua postingan

8 Agu 2011

Automatic refresh webpage / Set time to redirect

When you need your web page automatic refresh in 5 second or any second, use this meta tag. it's a simple code, put it between HEAD tag in your web page.

Overview
This script easy but powerful. Many websites use this scripts to redirect to another page or refresh the same page, for example, my website updates in every 10 minutes and I want to show user my latest content then I put this script to my page and set it refreshs in every 10 minutes.

#Automatic Refresh / Redirect







// content = time (second)
// file_name = name of file you want to refresh or redirect

Read more »

7 Agu 2011

Check Browser JavaScript



#Kode HTML yang simpel ini berguna untuk dipasang di blog atau web anda untuk mengetahui apa browser si pengunjung telah aktif Javascript-nya atau tidak aktif.
semoga berguna...!!!!!!

download :
http://www.indo-code.com/download.php?id-code=841

sumber : www.indo-code.com

Read more »

6 Agu 2011

SHUTDOWN KOMPUTER DARI JAUH – DENGAN SMS

Kisah berikut ini adalah tentang Bunga (nama disamarkan.red) yang suka meninggalkan Komputernya dalam keadaan hidup. Hal ini dilakukannya karena kebiasaan Bunga yang suka mendownload film Box Office terbaru yang berukuran ratusan Mega dengan speed download 2KB/s (nekat). Jadi pengennya si bunga, kalo pas pulang di rumah, film yang didownloadnya udah selesai.

Pada suatu hari, Bunga sedang mendownload film “Crows Zero” (ne film bagus banget, sumpah!!). Persentase download sudah menunjukkan 95%, yang artinya 4 Jam lagi download-an selesai. Tiba-tiba Bunga mendapat panggilan dari Bos-nya untuk memperbaiki saluran air yang mampet dirumahnya. Seperti kebiasaannya, komputer tetap dinyalakannya biar nanti pas pulang Film yang didownloadnya udah selesai. Setelah 3 Jam dirumah bos, akhirnya selesailah pekerjaannya.

“Tapi masih ada 1 Jam lagi” pikir si Bunga didalam hati, “Jalan-jalan dulu ah, biar ntar sampe rumah udah selesai film yang aku download”. Lalu Bunga pun melanjutkan perjalannya ke Warkop beli rokok Surya 16 sambil ngopi-ngopi gitu. 3 Jam berlalu, (maaf, Bunga ini sebenarnya berjenis kelamin laki-laki), dia teringat file yang di downloadnya (dan dia juga teringat kalo dia gak bawa duit buat ngopi). So, dia harus menambah 3 Jam lagi untuk mencuci piring di Warkop. :p

“Wah, komputerku pasti udah selesai ngedownload neh”, yarp, lalu Bunga mengambil HP nya dan mulai mengetikkan SMS dengan pesan “SHUTDOWN”. Dan dirumahnya, komputer Bunga telah mati secara otomatis, dan Bunga pun melanjutkan pekerjaannya sebagai pencuci piring di Warkop. (TAMAT) - adiknya Bunga, si Mawar (nama disamarkan) kena serangan jantung dirumah, kaget pas ngeliat komputer kakaknya mati sendiri. (THE END)

//Article Begin
Skema yang terjadi disini sebelum komputer shutdown sendiri adalah:
HP >sms> MODEM/HP >diteruskan> KOMPUTER >diproses> APLIKASI >perintah> SHUTDOWN

Mari kita bahas satu persatu skema diatas.
Untuk HP sepertinya tidak perlu penjelasan panjang lebar, yang penting dari sisi HP yang digunakan untuk mengirim SMS ada pulsanya ja. :p

MODEM/HP yang menerima SMS
SMS yang diterima disini harus diteruskan ke program (yang nanti kita buat) agar bisa diproses. Sehingga kita membutuhkan aplikasi tambahan yang berfungsi sebagai semacam SMSGateway. Untuk aplikasi ini kita bisa menggunakan GAMMU (www.wammu.eu) untuk menyimpan SMS didalam sebuah database. Yang nantinya Data didalam database inilah yang akan kita proses. (Untuk tutorial GAMMU bisa di googling sendiri ya :p). Modem/HP yang digunakan sebagai penerima SMS disini bebas menggunakan merk apa saja, yang penting kompatibel dengan GAMMU. (cek di www.wammu.eu/phones)

APLIKASI
Bagian ini merupakan inti dari artikel ini, karena kita akan membuat sendiri aplikasi untuk shutdown komputer. Tentu saja disesuaikan dengan database yang digunakan GAMMU. Karena database yang digunakan adalah MySQL, jadi untuk part-1 ini aplikasi yang akan kita buat berbasis web dengan bahasa pemrograman PHP. So let’s coding it...
Php
PHP:

<?php
    
function waitCommand(){
        if(!isset(
$_GET['act'])){
            echo 
"<script type=\"text/javascript\">
                    function runCheck(){
                        document.location=\""
.$_SERVER['PHP_SELF']."\"
                    }
                    </script>"
;
            echo 
"<body onLoad=\"setTimeout ('runCheck()',10000)\">"; //MELAKUKAN PENGECEKKAN SETIAP 10 DETIK
            
$sql = mysql_query("SELECT * FROM `inbox`
                                ORDER BY `inbox`.`UpdatedInDB` DESC
                                LIMIT 0 , 1"
);
                                
$row = mysql_fetch_row($sql);
                                if(
$row[11]=="false"){ //CEK SMS SUDAH DIPROSES ATAU BELUM
                                    
$getkey = explode(" ",$row[8]);    //MENGAMBIL ISI PESAN                
                                    
if(strtoupper($getkey[0])=="SHUTDOWN"){
                                        
system("shutdown -s -t 50");
                                        
$set = mysql_query("UPDATE `inbox` SET `Processed` =  'true' WHERE `inbox`.`ID` =".$row[9].";");
                                    }
                                }
        }
    }
    
waitCommand();
?>




Fungsi dari script diatas adalah untuk melakukan pengecekkan kedalam database, di tabel INBOX. Jika ada pesan masuk dengan keyword “SHUTDOWN” maka script akan memerintahkan komputer untuk melakukan shutdown. Untuk linux kita bisa menggunakan perintah “system(“halt”;)” tapi dengan terlebih dahulu melakukan autentikasi (part berikutnya :p)
Tapi tentu saja, dengan script diatas, komputer kita bisa diShutdown siapa saja jika ada SMS masuk dengan pesan “SHUTDOWN”, sehingga untuk mengatasi hal ini kita perlu melakukan validasi No.HP si pengirim SMS, dimana nomor ini harus berasal dari nomor HP kita sendiri. berikut validasinya dengan mengedit baris ini:
Php
PHP:
<?php             
if(strtoupper($getkey[0])=="SHUTDOWN"){
if(
$getkey[3]=="+628521234567"){ //MASUKKAN NOMOR HP KITA DISINI
        
system("shutdown -s -t 50");
        
$set = mysql_query("UPDATE `inbox` SET `Processed` =  'true' WHERE `inbox`.`ID` =".$row[9].";");
    }
}
 
?>



Agar program yang kita buat ini melakukan pengecekkan terhadap inbox secara realtime, file ini harus dalam keadaan dibuka di browser.

Thx-To: X-Crew – www.ExploreCrew.org and K4PT3N

Read more »

No iframe my page !

berikut adalah cara untuk menghindari halaman kita di iframe oleh orang lain…
seperti yang digunakan oleh twitter

<code>
01<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
02
03<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
04<head><title>test. no iframe-ing this page</test> </head>
05
06<body bgcolor="blue">
07
08<script type="text/javascript">
09//<![CDATA[
10if (window.top !== window.self) {
11        document.write = "";window.top.location = window.self.location;
12        setTimeout(function(){document.body.innerHTML='';},1);
13        window.self.onload=function(evt){document.body.innerHTML='';};
14        }
15//]]>
16</script>
17
18<h1>this is BLUE<br> <? echo $_SERVER["PHP_SELF"] ?> </H1>
19
20</body>
21</html>
</code>

Read more »

Huawei modem unlock calculator

Any time i’ve been using modem (i use huawei e169) for my internet connections. because i like the flexibility and realibility for use on my notebook. but 2 days ago, i was late to pay the bill and my connection was disconnected. i read the bill, and the bill was so high than other provider. i want to move to other provider, but i can’t. because the modem was locked by provider and only can using the sim card from the provider. yes i hear there is any way to unlock the modem, but i must pay at the service. because of that i’m doing some research and looking for the unlock code algorithm used by huawei modem. and i got it and did it in my program. now i can freely use any sim card on my modem. here it is, the source code contains the algorithm or you can use by direct or import it to your own program ;) . hope you enjoy !
<code>
001#!/usr/bin/python
002# -*- coding: utf-8 -*-
003#   This library is free software; you can redistribute it and/or
004#   modify it under the terms of the GNU Lesser General Public
005#   License as published by the Free Software Foundation; either
006#   version 2.1 of the License, or (at your option) any later version.
007#
008#   This library is distributed in the hope that it will be useful,
009#   but WITHOUT ANY WARRANTY; without even the implied warranty of
010#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011#   Lesser General Public License for more details.
012#
013#   You should have received a copy of the GNU Lesser General Public
014#   License along with this library; if not, write to the
015#      Free Software Foundation, Inc.,
016#      59 Temple Place, Suite 330,
017#      Boston, MA  02111-1307  USA
018#
019#   Copyright 2010 Gunslinger_ <yudha.gunslinger@gmail.com>
021
022import hashlib, string
023
024__author__  = "Gunslinger_ <yudha.gunslinger@gmail.com>"
025__date__    = "Tue, 14 Jun 2011 23:22:42 +0700"
026__version__     = "1.0"
027__copyright__   = "Copyright (c) 2010 Gunslinger_"
028
029class huawei_modem_unlocker(object):
030    """
031    Instance variables:
032
033    Imei
034        Imei of the modem will be calculated
035        Default : '0'
036
037    Verbose
038        Display how algorithm working
039        Default : False
040
041    """
042    def __init__(self, imei='0', verbose=False):
043        ''' Huawei modem unlocker class constructor '''
044        self._imei      = imei
045        self._verbose       = verbose
046        self._md5u      = hashlib.md5(str(imei)+str('5e8dd316726b0335')).hexdigest()
047        self._md5f      = hashlib.md5(str(imei)+str('97b7bc6be525ab44')).hexdigest()
048        self._unlock_code   = ''
049        self._flash_code    = ''
050        # verbose formating
051        self._width     = 21
052        self._w         = 10
053        self._header_format     = '%-*s%*s'
054        self._format        = '   %d  | %-*s | %*s  '
055
056    def xor_digits(self, source, counter):
057        ''' Get a value and xoring it during looping iteration '''
058        digits = int('0x0'+source[0+counter:2+counter],16)  ^ \
059             int('0x0'+source[8+counter:8+2+counter],16)    ^ \
060             int('0x0'+source[16+counter:16+2+counter],16)  ^ \
061             int('0x0'+source[24+counter:24+2+counter],16)
062        return digits
063
064    def calc(self):
065        ''' Process calculate with the algorithm (read source code) '''
066        cnt = 0
067        cnt2 = 1
068        if self._verbose:
069            print "="*(self._width+13)
070            print " Iter."+"|"+ " Unlock byte "+"|"+" Flash byte "
071            print "-"*(self._width+13)
072        while cnt < 8:
073            digits_unlock   = self.xor_digits(self._md5u, cnt)
074            digits_flash    = self.xor_digits(self._md5f, cnt)
075            unlock_byte     = string.zfill(hex(digits_unlock)[2:],2)
076            flash_byte  = string.zfill(hex(digits_flash)[2:],2)
077            self._unlock_code = str(self._unlock_code)+str(unlock_byte)
078            self._flash_code  = str(self._flash_code)+str(flash_byte)
079            if self._verbose: print self._format % (int(cnt2), self._width - self._w, self._unlock_code , self._w, self._flash_code)
080            cnt  +=2
081            cnt2 +=1
082        if self._verbose:
083            print "="*(self._width+13)
084            print "\nUNLOCK CODE = %d & %d | %d = %d" % (int('0x0'+self._unlock_code,16), 33554431, 33554432, eval("int('0x0'+self._unlock_code,16) & 33554431 | 33554432"))
085            print "FLASH CODE  = %d & %d | %d = %d\n" % (int('0x0'+self._flash_code,16), 33554431, 33554432, eval("int('0x0'+self._flash_code,16) & 33554431 | 33554432"))
086        self._unlock_code   = int('0x0'+self._unlock_code,16) & 33554431 | 33554432
087        self._flash_code    = int('0x0'+self._flash_code,16) & 33554431 | 33554432
088        return (self._unlock_code, self._flash_code)
089
090    def run(self):
091        ''' Fire it up ! '''
092        self.calc()
093        return (self._unlock_code, self._flash_code)
094
095if __name__ == '__main__':
096    print "\nHuawei modem unlock code calculator v.%s by %s \n" % (__version__, __author__)
097    inpimei = raw_input("Please input modem IMEI : ")
098    cracker = huawei_modem_unlocker(inpimei)
099    a, b    = cracker.run()
100    print "\n-> IMEI     = %s" % (inpimei)
101    print "-> UNLOCK CODE    = %s" % (a)
102    print "-> FLASH CODE = %s" % (b)

</code>
sumber : http://gunslingerc0de.wordpress.com

Read more »

./vM




Detected

Your Browser's JavaScript is: