This file contains hidden or 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 | |
file_put_contents("Tmpfile.zip", file_get_contents("http://someurl/file.zip")); |
This file contains hidden or 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 | |
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ | |
//If AJAX Request Then | |
}else{ | |
//something else | |
} |
This file contains hidden or 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 | |
/********************** | |
*@filename - path to the image | |
*@tmpname - temporary path to thumbnail | |
*@xmax - max width | |
*@ymax - max height | |
*/ | |
function resize_image($filename, $tmpname, $xmax, $ymax) | |
{ |
This file contains hidden or 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 | |
function makeClickableLinks($text) { | |
$text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)', | |
'<a href="\1">\1</a>', $text); | |
$text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)', | |
'\1<a href="http://\2">\2</a>', $text); | |
$text = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})', | |
'<a href="mailto:\1">\1</a>', $text); | |
return $text; |
This file contains hidden or 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 | |
if (!preg_match("/^(http|ftp):/", $_POST['url'])) { | |
$_POST['url'] = 'http://'.$_POST['url']; | |
} |
This file contains hidden or 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 | |
/********************** | |
*@file - path to zip file | |
*@destination - destination directory for unzipped files | |
*/ | |
function unzip_file($file, $destination){ | |
// create object | |
$zip = new ZipArchive() ; | |
// open archive | |
if ($zip->open($file) !== TRUE) { |
This file contains hidden or 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 | |
// Original PHP code by Chirp Internet: www.chirp.com.au | |
// Please acknowledge use of this code by including this header. | |
function myTruncate($string, $limit, $break=".", $pad="...") { | |
// return with no change if string is shorter than $limit | |
if(strlen($string) <= $limit) | |
return $string; | |
// is $break present between $limit and the end of the string? | |
if(false !== ($breakpoint = strpos($string, $break, $limit))) { |
This file contains hidden or 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 | |
/****************** | |
*@email - Email address to show gravatar for | |
*@size - size of gravatar | |
*@default - URL of default gravatar to use | |
*@rating - rating of Gravatar(G, PG, R, X) | |
*/ | |
function show_gravatar($email, $size, $default, $rating) | |
{ | |
echo '<img src="http://www.gravatar.com/avatar.php?gravatar_id='.md5($email). |
This file contains hidden or 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 | |
similar_text($string1, $string2, $percent); | |
//$percent will have the percentage of similarity |
This file contains hidden or 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 | |
function getCloud( $data = array(), $minFontSize = 12, $maxFontSize = 30 ) | |
{ | |
$minimumCount = min($data); | |
$maximumCount = max($data); | |
$spread = $maximumCount - $minimumCount; | |
$cloudHTML = ''; | |
$cloudTags = array(); |
NewerOlder