Skip to content

Instantly share code, notes, and snippets.

View nawawi's full-sized avatar

Nawawi Jamili nawawi

View GitHub Profile
@nawawi
nawawi / gist:1ca6130c669a9da9dee6
Last active August 29, 2015 14:15
remove sql injecttion
<?php
/* nawawi jamili -- rutweb.com */
function _remove_sql_inject($str) {
// add more pattern
$pat[] = "/'\s+AND\s+extractvalue.*/i";
$pat[] = "/'\s+and\(.*/i";
$pat[] = "/select\s+.*?\s+from.*/i";
$pat[] = "/(rand|user|version|database)\(.*/i";
$pat[] = "/union\(.*/i";
@nawawi
nawawi / gist:19bba9230fcf7e9da96c
Created March 20, 2015 14:55
contoh duit masuk dan keluar
-- function duit masuk simpan dalam sen
-- contoh guna: INSERT INTO `test` (`duit`) VALUES ( duitmasuk('1.20') );
CREATE FUNCTION `duitmasuk`(`num` FLOAT) RETURNS int(11)
DETERMINISTIC
RETURN ( num * 100 )
-- function duit keluar dalam ringgit
-- conth guna: SELECT duitkeluar(duit) as duit FROM `test`
CREATE FUNCTION `duitkeluar`(num INT) RETURNS float
DETERMINISTIC
<?php
$noic="letak no ic";
$p = file_get_contents("https://api-rutweb.rhcloud.com/spr/?ic={$noic}");
$array = json_decode($p);
print_r($array);
@nawawi
nawawi / check_uploaded_file.php
Created May 16, 2015 13:04
Check uploaded file
/**
* Check uploaded file
*
* @param string $file file
* @param int $max_file_length Maximum file length
* @return bool Return TRUE if Ok, FALSE otherwise.
*/
function _check_upload_filename($file, $max_file_length = 260) {
$valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-';
$file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($file) );
@nawawi
nawawi / dump_object
Created May 20, 2015 12:43
dump_object
function dump_object(array) {
var pad_char = ' ', pad_val = 2;
function repeat_char(len, pad_char) {
var str = '';
for (var i = 0; i < len; i++) {
str += pad_char;
}
return str;
};
@nawawi
nawawi / rubber stamp
Created May 26, 2015 19:09
try create rubber stamp / company stamp
<?php
$img = imagecreatetruecolor(200, 200);
// allocate some colors
$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
$green = imagecolorallocate($img, 0, 255, 0);
$blue = imagecolorallocate($img, 0, 0, 255);
$blue1 = imagecolorallocate($img, 102, 104, 230);
@nawawi
nawawi / check_email.php
Created July 6, 2015 17:59
check email
<?php
function _check_email($email, $strict = false) {
if ( filter_var($email, FILTER_VALIDATE_EMAIL) ) {
if ( $strict && function_exists("getmxrr") ) {
list($prefix, $domain) = split("@",$email);
return @getmxrr($domain, $maxhost);
}
return true;
}
return false;
@nawawi
nawawi / database_size.sql
Last active August 29, 2015 14:25
sql syntax calculate size satu database
-- sql syntax calculate size satu database dalam byte
-- replace namadabase kepada real database name
SELECT sum( data_length + index_length ) as size FROM information_schema.TABLES where table_schema = 'namadatabase' GROUP BY table_schema
@nawawi
nawawi / rpm-digital-signature.sh
Last active August 29, 2015 14:26 — forked from fernandoaleman/rpm-digital-signature.sh
How to sign your custom RPM package with GPG key
# How to sign your custom RPM package with GPG key
# Step: 1
# Generate gpg key pair (public key and private key)
#
# You will be prompted with a series of questions about encryption.
# Simply select the default values presented. You will also be asked
# to create a Real Name, Email Address and Comment (comment optional).
#
# If you get the following response:
@nawawi
nawawi / clean-rpmdb.sh
Created August 3, 2015 06:19
clean yum cache and fix rpm database
#!/bin/bash
yum -y clean all
rm -f /var/lib/rpm/__db*
rpm --rebuilddb
yum -y update
exit 0;