rendered paste body/*
Shorten posts
*/
function short ( $text, $ending, $fchar, $echar ) {
$text = (strlen ($text) > $echar) ? trim(substr( $text, $fchar, $echar )) . $ending : $text . $ending;
$text = clean( $text );
return $text;
}
/*
Get the users real ip
*/
function get_real_ip()
{
$ip = FALSE;
if( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) $ip = $_SERVER['HTTP_CLIENT_IP'];
if( !empty($_SERVER['HTTP_X_FORWARDED_FOR'] ) )
{
$ips = explode( ", ", $_SERVER['HTTP_X_FORWARDED_FOR'] );
if( $ip )
{
array_unshift( $ips, $ip );
$ip = FALSE;
}
for( $i = 0; $i < count( $ips ); $i++ )
{
if( !preg_match( "/^(10|172\.16|192\.168)\./i", $ips[$i] ) )
{
if( version_compare(phpversion(), "5.0.0", ">=" ) )
{
if( ip2long( $ips[$i] ) != FALSE )
{
$ip = $ips[$i];
break;
}
}
else
{
if( ip2long( $ips[$i] ) != - 1 )
{
$ip = $ips[$i];
break;
}
}
}
}
}
return ( $ip ? $ip : $_SERVER['REMOTE_ADDR'] );
}
/*
Clean strings
*/
function clean($string)
{
if(get_magic_quotes_gpc())
{
$string = stripslashes($string);
}
elseif(!get_magic_quotes_gpc())
{
$string = addslashes(trim($string));
}
$string = escapeshellcmd($string);
$string = strip_tags($string);
$string = htmlspecialchars($string);
$string = ereg_replace("[^A-Za-z0-9/-/_/+]", "", $string );
return $string;
}