function tiny_convert($url) { return file_get_contents("http://tinyurl.com/api-create.php?url=" . $url); }
//example
tiny_convert('tuo_url');
PHP free source code Community
function tiny_convert($url) { return file_get_contents("http://tinyurl.com/api-create.php?url=" . $url); }
//example
tiny_convert('tuo_url');
<?php
function zodiac($DOB){
$DOB = date("m-d", strtotime($DOB));
list($month,$day) = explode("-",$DOB);
if(($month == 3 || $month == 4) && ($day > 22 || $day < 21)){
$zodiac = "Aries";
}
elseif(($month == 4 || $month == 5) && ($day > 22 || $day < 22)){
$zodiac = "Taurus";
}
elseif(($month == 5 || $month == 6) && ($day > 23 || $day < 22)){
$zodiac = "Gemini";
}
elseif(($month == 6 || $month == 7) && ($day > 23 || $day < 23)){
$zodiac = "Cancer";
}
elseif(($month == 7 || $month == 8) && ($day > 24 || $day < 22)){
$zodiac = "Leo";
}
elseif(($month == 8 || $month == 9) && ($day > 23 || $day < 24)){
$zodiac = "Virgo";
}
elseif(($month == 9 || $month == 10) && ($day > 25 || $day < 24)){
$zodiac = "Libra";
}
elseif(($month == 10 || $month == 11) && ($day > 25 || $day < 23)){
$zodiac = "Scorpio";
}
elseif(($month == 11 || $month == 12) && ($day > 24 || $day < 23)){
$zodiac = "Sagittarius";
}
elseif(($month == 12 || $month == 1) && ($day > 24 || $day < 21)){
$zodiac = "Cpricorn";
}
elseif(($month == 1 || $month == 2) && ($day > 22 || $day < 20)){
$zodiac = "Aquarius";
}
elseif(($month == 2 || $month == 3) && ($day > 21 || $day < 21)){
$zodiac = "Pisces";
}
return $zodiac;
}
echo zodiac('1986-07-22'); //Valid strtotime date
?>
<html>
<head>
<title>DNSBL Lookup Tool - IP Blacklist Check Script</title>
</head>
<body>
<form action="" method="get">
<input type="text" value="" name="ip" />
<input type="submit" value="LOOKUP" />
</form>
<?php
/***************************************************************************************
This is a simple PHP script to lookup for blacklisted IP against multiple DNSBLs at once.
You are free to use the script, modify it, and/or redistribute the files as you wish.
Homepage: http://dnsbllookup.com
****************************************************************************************/
function dnsbllookup($ip){
$dnsbl_lookup=array("dnsbl-1.uceprotect.net","dnsbl-2.uceprotect.net","dnsbl-3.uceprotect.net","dnsbl.dronebl.org","dnsbl.sorbs.net","zen.spamhaus.org"); // Add your preferred list of DNSBL's
if($ip){
$reverse_ip = implode(".", array_reverse(explode(".", $ip)));
foreach($dnsbl_lookup as $host){
if(checkdnsrr($reverse_ip.".".$host.".", "A")){
$listed .= $reverse_ip.'.'.$host.' <font color="red">Listed</font><br />';
}
}
}
if($listed){
return $listed;
}else{
return '"A" record was not found';
}
}
$ip=$_GET['ip'];
if(isset($_GET['ip']) && $_GET['ip']!=null){
if(filter_var($ip,FILTER_VALIDATE_IP)){
echo dnsbllookup($ip);
}else{
echo "Please enter a valid IP";
}
}
?>
</body>
</html>
Ever see those sections on websites where some links are bigger than
others? This is that! Simply passs an associative array of strings, and
"weight", then echo the result. <?php
function gettaCloud( $data = array(), $minFontSize = 12, $maxFontSize = 30 )
{
$minimumCount = min($data);
$maximumCount = max($data);
$spread = $maximumCount - $minimumCount;
$cloudHTML = '';
$cloudTags = array();
$spread == 0 && $spread = 1;
foreach( $data as $tag => $count )
{
$size = $minFontSize + ( $count - $minimumCount )
* ( $maxFontSize - $minFontSize ) / $spread;
$cloudTags[] = '<a style="font-size: ' . floor( $size ) . 'px'
. '" class="tag_cloud" href="#" title="\'' . $tag .
'\' returned a count of ' . $count . '">'
. htmlspecialchars( stripslashes( $tag ) ) . '</a>';
}
return join( "\n", $cloudTags ) . "\n";
} //Usage Example
$arr = Array('Actionscript' => 35, 'Adobe' => 22, 'Array' => 44, 'Background' => 43,
'Blur' => 18, 'Canvas' => 33, 'Class' => 15, 'Color Palette' => 11, 'Crop' => 42,
'Delimiter' => 13, 'Depth' => 34, 'Design' => 8, 'Encode' => 12, 'Encryption' => 30,
'Extract' => 28, 'Filters' => 42);
echo gettaCloud($arr, 12, 36);
?>
<?php
class Twitter{
protected $twitURL = 'http://api.twitter.com/1/';
protected $xml;
protected $tweets = array(), $twitterArr = array();
protected $pversion = "1.0.0";
public function pversion(){
return $this->pversion;
}
public function loadTimeline($user, $max = 20){
$this->twitURL .= 'statuses/user_timeline.xml?screen_name='.$user.'&count='.$max;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->twitURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$this->xml = curl_exec($ch);
return $this;
}
public function getTweets(){
$this->twitterArr = $this->getTimelineArray();
$tweets = array();
foreach($this->twitterArr->status as $status){
$tweets[$status->created_at->__toString()] = $status->text->__toString();
}
return $tweets;
}
public function getTimelineArray(){
return simplexml_load_string($this->xml);
}
public function formatTweet($tweet){
$tweet = preg_replace("/(http(.+?))( |$)/","<a href=\"$0\">$1</a>$3", $tweet);
$tweet = preg_replace("/#(.+?)(\h|\W|$)/", "<a href=\"https://twitter.com/i/#!/search/?q=%23$1&src=hash\">#$1</a>$2", $tweet);
$tweet = preg_replace("/@(.+?)(\h|\W|$)/", "<a href=\"http://twitter.com/#!/$1\">@$1</a>$2", $tweet);
return $tweet;
}
} //Usage Example
$twitter = new Twitter();
$feed = $twitter->loadTimeline("insertusername")->getTweets();
foreach($feed as $time => $message){
echo "<div class='tweet'>".$twitter->formatTweet($message)."<br />At: ".$time."</div>";
}
?>
<?php
function lat_long_dist($lat1, $long1, $lat2, $long2){
$pi = pi();
$x = sin($lat1 * $pi/180) *
sin($lat2 * $pi/180) +
cos($lat1 * $pi/180) *
cos($lat2 * $pi/180) *
cos(($long2 * $pi/180) - ($long1 * $pi/180));
$x = atan((sqrt(1 - pow($x, 2))) / $x);
return (1.852 * 60.0 * (($x/$pi) * 180)) / 1.609344;
}
echo lat_long_dist(56.34342, 49.324523, 57.49544, 47.421524);
<?php
function birthday($birthday){
$age = strtotime($birthday);
if($age === false){
return false;
}
list($y1,$m1,$d1) = explode("-",date("Y-m-d",$age));
$now = strtotime("now");
list($y2,$m2,$d2) = explode("-",date("Y-m-d",$now));
$age = $y2 - $y1;
if((int)($m2.$d2) < (int)($m1.$d1))
$age -= 1;
return $age;
}
echo birthday('1986-07-22');
?>
<html>
<head>
<title>Ascii</title>
<style>
#CAPTCHA{
font-size:1px;
line-height:1px;
}
</style>
</head>
<body>
<?php
// Get the fonts for the CAPTCHA
$fonts = glob( 'examples/CAPTCHA/fonts/*');
// Build a String
$string = md5(rand(0,5000));
// Get the first 4 letters and place it in an array
$string = substr($string,0,4);
$letters = str_split($string);
// Set the CAPTCHA Height
$ih = 60;
// Set the CAPTCHA Width
$iw = 130;
// Set the Font size
$fs = 25;
// Create an image
$image = imagecreatetruecolor($iw,$ih);
// Set a default background color
$white = imagecolorallocate($image, 255, 255, 255);
// Add the background color to the image
imagefilledrectangle($image, 0, 0, $iw, $ih, $white);
// Set minimum letter y position
$y_min = ($ih / 2) + ($fs / 3) - 10;
// Set maximum letter y position
$y_max = ($ih / 2) + ($fs / 3) + 10;
// Set the letter starting point
$x = $fs;
// Set i to zero
$i = 0;
// Loop through each letter
foreach($letters as $letter){
// Set the angle of the letter random from -45 and 45
$angle = rand(-45, 45);
// Set a random y position of the letter using using the above min and max
$y = rand($y_min, $y_max);
// check to see if this is first letter, yes then skip next line otherwise,
// add font size to x to move letter to the right
if($i != 0)
$x += $fs;
// Set the color of the letter
$font_color = imagecolorallocate($image, rand(50,200), rand(50,200), rand(50,200));
// Choose a random font from our list of fonts
$rand = array_rand($fonts);
// Add letter to the image
imagettftext($image, $fs, $angle, $x, $y, $font_color, $fonts[$rand], $letter);
// Incrament $i
$i++;
}
// Finally build the image!
$black = imagecolorallocate($image, 0, 0, 0);
// Build the ASCII image
echo '<div id="CAPTCHA">';
for($h=0;$h<$ih;$h++){
for($w=0;$w<=$iw;$w++){
$rgb = imagecolorat($image, $w, $h);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
if($w == $iw){
echo '<br />';
}else{
echo '<span style="color:rgb('.$r.','.$g.','.$b.');">#</span>';
}
}
}
echo '</div>';
//End ASCII Image Build
$_SESSION['CAPTCHA'] = $string;
?>
<p>
Image String:
<?php echo $_SESSION['CAPTCHA']; ?>
</p>
</body>
</html>