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 */ | |
$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 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 */ | |
// 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 */ | |
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 */ | |
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 */ | |
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 */ | |
$to = '[email protected]'; | |
$subject = 'Test Email'; | |
$body = 'Body of your message here. You can use HTML tags also, e.g. <br><b>Bold</b>'; | |
$headers = 'From: John Smith'."\r\n"; | |
$headers .= 'Reply-To: [email protected]'."\r\n"; | |
$headers .= 'Return-Path: [email protected]'."\r\n"; | |
$headers .= 'X-Mailer: PHP5'."\n"; | |
$headers .= 'MIME-Version: 1.0'."\n"; |
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(); ?>'); | |
?> |
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 |
OlderNewer