1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
| <?php
function limitatexto( $texto, $limite )
{
if( strlen($texto)>$limite )
{
$texto = substr( $texto,0,$limite );
}
return $texto;
}
function mostrarTemplate($tema, $variables)
{
//var_dump($variables);
extract($variables);
eval("?>".$tema."<?");
}
function parsearTags($mensaje)
{
$mensaje = str_replace("[citar]", "<blockquote><hr width='100%' size='2'>", $mensaje);
$mensaje = str_replace("[/citar]", "<hr width='100%' size='2'></blockquote>", $mensaje);
return $mensaje;
}
// funcion para validar email
function ValidaMail($pMail) {
if (ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@+([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$", $pMail ) ) {
return true;
} else {
echo "You Must Insert a Valid Email Address"; exit();
}
}
// minimo de carateres
function minimo($contenido) {
if (strlen($contenido) < 3) {
echo "You Must Insert at least 3 chars.";include('footer.php'); exit();
} else {
// echo "todo bien...";
return $contenido;
}
}
function minimopass($contenido) {
if (strlen($contenido) < 6) {
echo "You Must Insert at least 6 chars in password field.";include('footer.php'); exit();
} else {
// echo "todo bien...";
return $contenido;
}
}
// funcion para sanitizar variables
function limpiar($mensaje)
{
$mensaje = htmlentities(stripslashes(trim($mensaje)));
$mensaje = str_replace("'"," ",$mensaje);
$mensaje = str_replace(";"," ",$mensaje);
$mensaje = str_replace("$"," ",$mensaje);
return $mensaje;
}
function shout($nombre_usuario){
if (ereg("^[a-zA-Z0-9\-_]{3,20}$", $nombre_usuario)) {
// echo "El campo $nombre_usuario es correcto<br>";
return $nombre_usuario;
} else {
echo "The Field $nombre_usuario is not valid<br>";include('footer.php');
exit();
}
}
// universal cleaner function
function uc($mensaje)
{
if (ereg("^[a-zA-Z0-9\-_]{3,20}$", $mensaje)) {
// echo "El campo $mensaje es correcto<br>";
$mensaje = htmlentities(stripslashes(strtolower(trim($mensaje))));
$mensaje = str_replace("'"," ",$mensaje);
$mensaje = str_replace(";"," ",$mensaje);
$mensaje = str_replace("$"," ",$mensaje);
return $mensaje;
} else {
echo "The Field $mensaje is not Valid<br>";include('footer.php');
exit();
}
}
//funcion para añadir smylies
function caretos($texto,$ruta)
{
$i="<img src=\"$ruta/";
$i_="\" >";
$texto=str_replace(":)",$i."icon_smile.gif".$i_,$texto);
$texto=str_replace(":D",$i."icon_biggrin.gif".$i_,$texto);
$texto=str_replace("^^",$i."icon_cheesygrin.gif".$i_,$texto);
$texto=str_replace("xD",$i."icon_lol.gif".$i_,$texto);
$texto=str_replace("XD",$i."icon_lol.gif".$i_,$texto);
$texto=str_replace(":|",$i."icon_neutral.gif".$i_,$texto);
$texto=str_replace(":(",$i."icon_sad.gif".$i_,$texto);
$texto=str_replace(":'(",$i."icon_cry.gif".$i_,$texto);
$texto=str_replace(":O",$i."icon_surprised.gif".$i_,$texto);
$texto=str_replace("B)",$i."icon_cool.gif".$i_,$texto);
$texto=str_replace("8|",$i."icon_rolleyes.gif".$i_,$texto);
$texto=str_replace("O_O",$i."icon_eek.gif".$i_,$texto);
$texto=str_replace(":P",$i."icon_razz.gif".$i_,$texto);
$texto=str_replace(":?",$i."icon_confused.gif".$i_,$texto);
$texto=str_replace("^:@",$i."icon_evil.gif".$i_,$texto);
$texto=str_replace("^_-",$i."icon_frown.gif".$i_,$texto);
$texto=str_replace("!(",$i."icon_mad.gif".$i_,$texto);
$texto=str_replace("^)",$i."icon_twisted.gif".$i_,$texto);
$texto=str_replace(";)",$i."icon_wink.gif".$i_,$texto);
$texto=str_replace(":B",$i."drool.gif".$i_,$texto);
return $texto;
}
// ip real
function getRealIP()
{
if( $_SERVER['HTTP_X_FORWARDED_FOR'] != '' )
{
$client_ip =
( !empty($_SERVER['REMOTE_ADDR']) ) ?
$_SERVER['REMOTE_ADDR']
:
( ( !empty($_ENV['REMOTE_ADDR']) ) ?
$_ENV['REMOTE_ADDR']
:
"unknown" );
// los proxys van añadiendo al final de esta cabecera
// las direcciones ip que van "ocultando". Para localizar la ip real
// del usuario se comienza a mirar por el principio hasta encontrar
// una dirección ip que no sea del rango privado. En caso de no
// encontrarse ninguna se toma como valor el REMOTE_ADDR
$entries = split('[, ]', $_SERVER['HTTP_X_FORWARDED_FOR']);
reset($entries);
while (list(, $entry) = each($entries))
{
$entry = trim($entry);
if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list) )
{
// http://www.faqs.org/rfcs/rfc1918.html
$private_ip = array(
'/^0\./',
'/^127\.0\.0\.1/',
'/^192\.168\..*/',
'/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/',
'/^10\..*/');
$found_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
if ($client_ip != $found_ip)
{
$client_ip = $found_ip;
break;
}
}
}
}
else
{
$client_ip =
( !empty($_SERVER['REMOTE_ADDR']) ) ?
$_SERVER['REMOTE_ADDR']
:
( ( !empty($_ENV['REMOTE_ADDR']) ) ?
$_ENV['REMOTE_ADDR']
:
"unknown" );
}
return $client_ip;
}
?> |