Skip to content

Instantly share code, notes, and snippets.

View crishnakh's full-sized avatar
💻
Ey! Listen!

Francisco Gálvez crishnakh

💻
Ey! Listen!
View GitHub Profile
@crishnakh
crishnakh / gist:4479801
Last active September 15, 2020 10:47
Copy function to protect SQL injection in PHP.
<?php
function clear($input)
{
global $link;
if(get_magic_quotes_gpc())
{
//Remove slashes that were used to escape characters in post.
$input = stripslashes($input);
}
//Remove ALL HTML tags to prevent XSS and abuse of the system.
<script type="text/javascript">
var unavailableDates = ["11-1-2013","12-1-2013","13-1-2013"];
function unavailable(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if ($.inArray(dmy, unavailableDates) < 0) {
return [true,"","Book Now"];
} else {
return [false,"","Booked Out"];
}
@crishnakh
crishnakh / gist:4518055
Created January 12, 2013 13:13
Resta fechas en PHP Formato YYYY-MM-DD
<?php
function restafechas($startDate,$endDate){
list($year, $month, $day) = explode("-", $startDate);
$startDate = mktime(0, 0, 0, $month, $day, $year);
list($year, $month, $day) = explode("-", $endDate);
$endDate = mktime(0, 0, 0, $month, $day, $year);
$totalDays = ($endDate - $startDate)/(60 * 60 * 24);
@crishnakh
crishnakh / gist:4526417
Created January 13, 2013 21:59
"This allows you to get contents of any div with ID tag. $matches[0] returns with parent div tag $matches[1] returns with out parent div tag" from http://snipplr.com/view/15302/
<?php
preg_match('/\<div id\=[\"]{0,1}ad_content[\"]{0,1}\>(.*?)\<\/div\>/s', $content['content_body'], $matches);
$content['content_body'] = $matches[1];
?>
@crishnakh
crishnakh / gist:4615185
Created January 23, 2013 22:42
Save time with SELECT, UPDATE, DELETE queries with PHP Functions. Based on http://www.evoluted.net/thinktank/web-development/time-saving-database-functions
<?php
/*
DATA ARRAY EXAMPLE
$form_data = array(
'first_name' => $first_name,
'last_name' => $last_name,
'email' => $email,
'address1' => $address1,
'address2' => $address2,
'address3' => $address3,
@crishnakh
crishnakh / gist:4648032
Created January 27, 2013 11:52 — forked from anonymous/gist:4648031
Check email function
<?php
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!preg_match("/^[^@]{1,64}@[^@]{1,255}$/", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
<?php
function createDateRangeArray($strDateFrom,$strDateTo)
{
// takes two dates formatted as YYYY-MM-DD and creates an
// inclusive array of the dates between the from and to dates.
// could test validity of dates here but I'm already doing
// that in the main script
$aryRange=array();
@crishnakh
crishnakh / gist:5115488
Created March 8, 2013 10:08
SQL OsCommerce all zones in one files, contribution somewhere in oscommerce.com. Some ; corrected
INSERT INTO zones (zone_id, zone_country_id, zone_code, zone_name) VALUES
(1, 1, 'BDS', 'Badakhshan'),
(2, 1, 'BDG', 'Badghis'),
(3, 1, 'BGL', 'Baghlan'),
(4, 1, 'BAL', 'Balkh'),
(5, 1, 'BAM', 'Bamian'),
(6, 1, 'FRA', 'Farah'),
(7, 1, 'FYB', 'Faryab'),
(8, 1, 'GHA', 'Ghazni'),
(9, 1, 'GHO', 'Ghowr'),
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
# Remove silence from mp3
/usr/bin/sox input.mp3 output.mp3 silence -l 1 0.3 5% -1 2.0 5%
# Remove noise and silence in a single command