NOTICE: Moved to Git Repo with another version. Will keep it updated there!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() | |
{ | |
if ( $.browser.msie ){ | |
if($.browser.version == '6.0') | |
{ $('html').addClass('ie6'); | |
} | |
else if($.browser.version == '7.0') | |
{ $('html').addClass('ie7'); | |
} | |
else if($.browser.version == '8.0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get current URL but without the filename. | |
var currentUrl = window.location.href; | |
currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/')+1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inArray(needle, haystack) { | |
var length = haystack.length; | |
for(var i = 0; i < length; i++) { | |
if(haystack[i] == needle) return true; | |
} | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- your_table: The table to modify | |
-- id: The id field/column to reset | |
SET @num := 0; | |
UPDATE your_table SET id = @num := (@num+1); | |
ALTER TABLE your_table AUTO_INCREMENT =1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------------------------------------------------------+ | |
| Resize Image with crop or without crop and | |
| return resource | |
+------------------------------------------------------*/ | |
function resize_image($file, $w, $h, $crop=FALSE) { | |
list($width, $height) = getimagesize($file); | |
$r = $width / $height; | |
if ($crop) { | |
if ($width > $height) { | |
$width = ceil($width-($width*($r-$w/$h))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------------------------------------------------------+ | |
| Provide image resource, border color and thickness to | |
| add border to the resource. | |
+------------------------------------------------------*/ | |
function drawBorder(&$img, &$color, $thickness = 1) { | |
$x1 = 0; | |
$y1 = 0; | |
$x2 = ImageSX($img) - 1; | |
$y2 = ImageSY($img) - 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove the directory and its content (all files and subdirectories). | |
* @param string $dir the directory name | |
*/ | |
function rmrf($dir) { | |
foreach (glob($dir) as $file) { | |
if (is_dir($file)) { | |
rmrf("$file/*"); | |
rmdir($file); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function match_wildcard( $wildcard_pattern, $haystack ) { | |
$regex = str_replace( | |
array("\*", "\?"), // wildcard chars | |
array('.*','.'), // regexp chars | |
preg_quote($wildcard_pattern) | |
); | |
return preg_match('/^'.$regex.'$/is', $haystack); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Picks one random jpg/jpeg/png format image from the specified directory. | |
* @param string $dir Images directory path. | |
* @param boolean $realPath True to return real path of the image. | |
* @return string Path to one random image. | |
*/ | |
function getRandomImg ( $dir, $realPath = false ) { | |
$dir = rtrim($dir, '/'); // Just in case if there is any trailing slash. | |
$images = glob($dir . '/*.{jpg,jpeg,png}', GLOB_BRACE); |
OlderNewer