Irfani Firdausy Live Journal

Category: PHP

PHP Programming

Using Grep to Find Security Vulnerabilities in PHP code

Finding all security vulnerabilities in a piece of code may be hard as it requires in depth analysis of what the code does. However, simple security vulnerabilities follow certain code style patterns that are easier to find with simple search tools.

Read this article to learn how you can find certain types of security vulnerabilities very quickly using the grep program. Continue reading

Nice collaboration with 960 gs

akhirnya saya menyelesaikan cash management user interface.
terima kasih kepada adobe photoshop, 960 grid system, jquery dan tentu php

Continue reading

Cek Rekomendasi Browser dengan PHP

Kasusnya adalah ketika web developer memakai html 5, maka untuk browser-browser jadul pasti banyak yang error dan tidak sesuai dengan harapan. Dan kita sebagai developer tentunya akan jadi pusing dengan mikirin masalah cross browser, apalagi dikejar deadline juga apalagi yang desain user interface adalah kita sendiri. Continue reading

Why is it better to develop in PHP with classes (OOP)?

Some developers code their PHP projects writing classes of objects.

Others also write classes but do it just because they see others doing it without being able to explain why classes are a good thing.

Others do not write classes but reuse other people code written in the form of classes.

Others completely refuse to write or reuse other developer classes because they do not see much point in doing it.

Read this article to learn why it is better to develop your PHP projects based on object classes.

You may also learn how to convert your global code based classes into properly written classes that you can reuse in multiple projects besides other benefits of using Object Oriented Programming in PHP.

Continue reading

How to Hotlink-protect images using .htaccess

If your running apache server, you can do what you need by configuring your .htaccess file.

You would do something like this to prevent hotlinking of images –

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?*$ [NC]
RewriteRule \.(gif¦jpg¦js¦css)$ – [F]

replace with your domain name and only your domain will be allowed to access files appeneded by .gif .jpg .js or .css

you can add other allowed domaine with extra lines e.g. –

RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://(www\.)?*$ [NC]
RewriteRule \.(gif¦jpg¦js¦css)$ – [F]

Konversi Angka ke Huruf

Script ini berguna jika kita mau membuat konversi angka ke huruf

// by
function ctword($x) {
$x = abs($x);
$number = array(“”, “satu”, “dua”, “tiga”, “empat”, “lima”,
“enam”, “tujuh”, “delapan”, “sembilan”, “sepuluh”, “sebelas”);
$temp = “”;

if ($x <12) {
$temp = ” “. $number[$x];
} else if ($x <20) {
$temp = ctword($x – 10). ” belas”;
} else if ($x <100) {
$temp = ctword($x/10).” puluh”. ctword($x % 10);
} else if ($x <200) {
$temp = ” seratus” . ctword($x – 100);
} else if ($x <1000) {
$temp = ctword($x/100) . ” ratus” . ctword($x % 100);
} else if ($x <2000) {
$temp = ” seribu” . ctword($x – 1000);
} else if ($x <1000000) {
$temp = ctword($x/1000) . ” ribu” . ctword($x % 1000);
} else if ($x <1000000000) {
$temp = ctword($x/1000000) . ” juta” . ctword($x % 1000000);
} else if ($x <1000000000000) {
$temp = ctword($x/1000000000) . ” milyar” . ctword(fmod($x,1000000000));
} else if ($x <1000000000000000) {
$temp = ctword($x/1000000000000) . ” trilyun” . ctword(fmod($x,1000000000000));
return $temp;
function terbilang($x,$style=4,$strcomma=”,”) {
if($x<0) {
$result = “minus “. trim(ctword($x));
} else {
if ($arrcount==1){
$result = trim(ctword($x));
}else if ($arrcount>1){
$result = trim(ctword($arrnum[0])) . ” koma ” . trim(ctword($arrnum[1]));
switch ($style) {
case 1: //1=uppercase  dan
$result = strtoupper($result);
case 2: //2= lowercase
$result = strtolower($result);
case 3: //3= uppercase on first letter for each word
$result = ucwords($result);
default: //4= uppercase on first letter
$result = ucfirst($result);
return $result;
<form  method=”post”>
Masukkan Angka <input name=”input” type=”text” id=”input” value=”<?=$_POST[‘input’]?>”/>
<input name=”Show” type=”submit” id=”Show” value=”Show” />
<? if (isset($_POST[‘Show’]))
$input = trim($_POST[‘input’]);

$hasil = terbilang($input,$style=4,$strcomma=”,”);
echo “Terbilang : “. $hasil;

Mengambil beberapa kata dari sebuah kalimat

Terkadang kita ingin mengambil beberapa kata awalan dari sebuah kalimat atau berita.

//programmed by

function get_kata($kalimat,$batasan)
$get_kata = explode(" ",strip_tags($kalimat));
$jumlah = count($get_kata);
if ($jumlah > $batasan )
for ($i=0; $i<$batasan; $i++)
echo "$get_kata[$i] ";

else if($jumlah <= $batasan )
for ($i=0; $i<$jumlah; $i++)
echo "$get_kata[$i] ";


$kalimat= "<p>pagi ini saya bangun jam 5.30 <br> terus sholat, terus mandi terus berangkat ke kantor</p>";

© 2017

Theme by Anders NorenUp ↑