Some usefull functions there
Function to get the user IP, since one single technique doesn't always work
PHP Code:
function get_IP() {
if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip_address = $_SERVER["REMOTE_ADDR"];
} else {
$ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
if(strpos($ip_address, ',') !== false) {
$ip_address = explode(',', $ip_address);
$ip_address = $ip_address[0];
}
return $ip_address;
}
Or this one I got from another site, I don't remember where, it treats a string as if it is included by include();
Only downside is that you can't declare functions since it's already inside a function.
PHP Code:
function phpWrapper($content) {
global $page;
ob_start();
$content = str_replace('<'.'?php','<'.'?',$content);
eval('?'.'>'.trim($content).'<'.'?');
$content = ob_get_contents();
ob_end_clean();
return $content;
}
Or a function to echo a string and immediatly echo it without delay
PHP Code:
function _echo($echo) {
echo $echo;
flush();
ob_flush();
}
This one transforms a filename into a clean string, to be used as a title or whatever (for example, go_go_gadget.exe becomes "Go go gadget"
PHP Code:
function get_filetotitle($title) {
$title = strip_path($title);
$title = str_replace('_',' ',$title);
$title = substr($title, 0, strrpos($title, '.'));
$bits = explode(' ',$title);
foreach ($bits AS $bit) {
$return .= capitalize_firstchar($bit);
}
return $return;
}
function capitalize_firstchar($string) {
return strtoupper(substr($string,0,1)).substr($string,1);
}
__________________