Skip to content

Instantly share code, notes, and snippets.

View subodhghulaxe's full-sized avatar

Subodh Ghulaxe subodhghulaxe

View GitHub Profile
@subodhghulaxe
subodhghulaxe / creditcardvalidation.php
Created March 4, 2015 11:00
Validate credit card number in PHP
<?php
error_reporting(E_ALL);
/**
* Validate credit card number
* Returns true if $ccNum is in the proper credit card format.
*
* @param string $ccNum credit card number to validate
* @param string|array $type if $type is set to 'fast', it validates the data against the major credit cards’ numbering formats.
* If $type is set to 'all', it validates the data against with all the credit card types.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@subodhghulaxe
subodhghulaxe / fileuploadphp.php
Created February 20, 2015 08:31
Secure file upload function in PHP
<?php
/**
* ex. $file = $_FILES['profile_pic']
* $file_size in
* $allowed_mime_types = array(
* 'jpg' => 'image/jpeg',
* 'png' => 'image/png',
* 'gif' => 'image/gif',
* );
* $new_upload_folder = '/var/www/prroject_name/uploads/' (note the backslash)
@subodhghulaxe
subodhghulaxe / php-debug-function.php
Last active August 29, 2015 14:04
PHP debug function
<?php
/** Debug function */
function db($data) {
$backtrace = debug_backtrace();
$caller = array_shift($backtrace);
echo '<br><pre style="color:#B99AFF;">##### <span style="color:green;">'.$caller['file'].'</span> <span style="color:red;">Line: '.$caller['line']. '</span> #####<br><span style="color:blue;">';
if( !empty($data) ) { print_r( $data ); } else { print_r("Empty variable.<br>"); }
echo '</span>######################################################</pre><br>';
}
@subodhghulaxe
subodhghulaxe / last_names.php
Created December 27, 2013 16:04
List of last names as php array
<?php
$last_names = array(
'Abbott',
'Acevedo',
'Acosta',
'Adams',
'Adkins',
'Aguilar',
'Aguirre',
'Albert',
@subodhghulaxe
subodhghulaxe / last_names.php
Created December 27, 2013 16:04
List of last names as php array
<?php
$last_names = array(
'Abbott',
'Acevedo',
'Acosta',
'Adams',
'Adkins',
'Aguilar',
'Aguirre',
'Albert',
@subodhghulaxe
subodhghulaxe / last_names.php
Last active September 30, 2022 00:57
List of last names in php array
<?php
$last_names = array(
'Abbott',
'Acevedo',
'Acosta',
'Adams',
'Adkins',
'Aguilar',
'Aguirre',
'Albert',