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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
function getRemoteIPAddress(){ | |
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; | |
return $ip; | |
} | |
/* If your visitor comes from proxy server you have use another function | |
to get a real IP address: */ |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
function getShortUrl($url){ | |
return file_get_contents('http://tinyurl.com/api-create.php?url='.$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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
function convertSecToStr($secs){ | |
$output = ''; | |
if($secs >= 86400) { | |
$days = floor($secs/86400); | |
$secs = $secs%86400; | |
$output = $days.' day'; | |
if($days != 1) $output .= 's'; | |
if($secs > 0) $output .= ', '; |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
// stick your url here | |
header('Location: http://you_address/url.php'); | |
exit; | |
?> |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
$useragent = $_SERVER['HTTP_USER_AGENT']; | |
echo "<b>Your User Agent is</b>: ".$useragent; | |
?> | |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
function highlight($str, $words){ | |
if(!is_array($words) || empty($words) || !is_string($str)){ | |
return false; | |
} | |
$arr_words = implode('|', $words); | |
return preg_replace( | |
'@\b('.$arr_words.')\b@si', | |
'<strong style="background-color:yellow">$1</strong>', |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
// method 1 - substr and mb_substr | |
substr($string, 0, -1); | |
mb_substr($string, 0, -1); | |
// method 2 - substr_replace | |
substr_replace($string, '', -1); | |
// method 3 - rtrim |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
function unzip($location,$new_location){ | |
if(exec("unzip $location",$arr)){ | |
mkdir($new_location); | |
for($i = 1;$i< count($arr);$i++){ | |
$file = trim(preg_replace("~inflating: ~","",$arr[$i])); | |
copy($location."/".$file,$new_location."/".$file); | |
unlink($location."/".$file); | |
} |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
function makeMyUrlFriendly($url){ | |
$output = preg_replace("/\s+/" , "_" , trim($url)); | |
$output = preg_replace("/\W+/" , "" , $output); | |
$output = preg_replace("/_/" , "-" , $output); | |
return strtolower($output); | |
} | |
?> |
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 | |
/* Source: http://www.apphp.com/index.php?snippet=php-get-remote-ip-address */ | |
highlight_string('<?php phpinfo(); ?>'); | |
?> |
OlderNewer