Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - дٳŦ٭

#311
Pues mete los id's de los nombres de tus archivos a una matriz, con explode cortas los id's, con sort() las ordenas y por último tomas el 0 (el primero).

How To Sort Files Of A Directory using Php
http://www.trap17.com/index.php/Sort-Files-Directory-Php_t36366.html

sort
http://www.php.net/sort

Se te agradecerá que cuando hayas encontrado la solución la postees aquí  ;)

Suerte
#312
PHP / NST Web Based Anti-DoS v0.1
6 Junio 2009, 07:15 AM
Código (php) [Seleccionar]
<?
/*
/************************************************************
/                                                                                                       
/           NST Anti Denial of Service Script  v 0.1                                           
/                                                                                                       
/                                                                                                       
/                                                                                                       
/             Author: Link   < link07@gmail.com >                             
/                                                                                                       
/              ..::[N]eo [S]ecurity [T]eam::..                                         
/                                                                                                         
/              http://www.neosecurityteam.net   
/
/                   Date:  October - 2006               
/                                                                                                         
/                                                                                                         
/*************************************************************


     This script will prevent Dos and DDos attacks using request flood
     of http packets, that causes your server to excecute to much connections
     with the database and execute tha php interpreter a lot of times in a few
     seconds, all you have to do to install this is include it in a script that
     all your scripts use , an script for the database connection for example
     and create three empty txt files on the same folder with write and read
     permissions: log.txt , bans.txt , counter.txt
     This script will ban users using the .htaccess file, so dont forget to put
     this is script on the same folder as the .htaccess file as well
     It is very configurable just modify the parameters indicated below , to
     asign how sctrict the script will act. 

*/

$data = "";

$ban = "";

$visits = 1;

$error = 0;

$ahora = date("Y-n-j H:i:s");

$safemode = 0;

$new = "";

$flooder =0;

$registered = 0;

$wwwdir = "/home/neosecur/public_html/";

$ahora = date("Y-n-j H:i:s");

if(!$file = @fopen($wwwdir."log.txt","r"))

$error = 1;

while (!@feof($file))

{

$data .= @fgets($file);

}

$visitor = explode("\n",$data);

$i=0;

while($visitor[$i])

{

$iptime = explode("@",$visitor[$i]);

if ($_SERVER['REMOTE_ADDR'] == $iptime[0])

{



$tiempo = strtotime($ahora) - $iptime[1];

if ($tiempo <= 1)  // this line controls the acces of an ip, only one request during the number of seconds you replace here

{

$safemode = 1;


$flooder = 1;

}


$iptime[1]=strtotime($ahora);





$registered = 1;

}

$new .=$iptime[0]."@".$iptime[1]."\n";

$i++;

}


if (!$registered)

$new.=$_SERVER['REMOTE_ADDR']."@".strtotime($ahora)."\n";



if (!@fclose($file))

$error = 1;



if(!$file = @fopen($wwwdir."log.txt","wt"))

$error = 1;



@fwrite($file,$new);

if (!@fclose($file))

$error = 1;



if (!$fcount = @fopen($wwwdir."counter.txt","rt"))

$error = 1;

$vst = @fgets($fcount);

$count = explode("@",$vst);

if (strtotime($ahora) == $count[1])

{

$visits = $count[0] + 1;

$count[0] = $visits;

}

else

{

$count[0] = 1;

$count[1] = strtotime($ahora);

}

if (!@fclose($fcount))

$error = 1;



$new = $count[0]."@".$count[1];



if (!$fcount = @fopen($wwwdir."counter.txt","wt"))

$error = 1;



@fwrite($fcount,$new);



if (!@fclose($fcount))

$error = 1;




$new = "";

$registered = 0;



if ($visits > 4) // this line controls visits during a second, it is used to prevent ddos attacks you can modify this depending on the capacity of your server

{

$safemode = 1;

if ($flooder)

{

if (!$fban = @fopen($wwwdir."bans.txt","rt")) $error = 1;

while (!@feof($fban))

{

$ban .= @fgets($fban);

}

$ips = explode ("\n",$ban);

$i=0;

while ($ips[$i])

{

if ($_SERVER['REMOTE_ADDR'] == $ips[$i])

$registered = 1;

$i++;

$new .=$ips[$i];

}

if (!@fclose($fban)) $error = 1;



if (!$registered)

{

if (!$fban = @fopen($wwwdir."bans.txt","wt")) $error = 1;

$new .=$_SERVER['REMOTE_ADDR']."\n";

@fwrite($fban,$new);

if (!@fclose($fban)) $error = 1;

}

else

{

if (!$fht = @fopen($wwwdir.".htaccess","rt"))

$error = 1;

$cont = "";
$cont2 = "";
$eob = 0;
while (!@feof($fht))

{

$a = @fgets($fht);

if ($eob)
$cont2.=$a;
else
{
if ($a == "</Limit>\r\n" or $a == "</Limit>" or $a == "</Limit>\n")
{
$eob = 1;
$cont2.=$a;
}
else
$cont.=$a;
}

}



if (!@fclose($fht))

$error = 1;

if (!$fht = @fopen($wwwdir.".htaccess","wt"))

$error = 1;


$cont .= "Deny from ".$_SERVER['REMOTE_ADDR']."\n";
$cont .= $cont2;

@fwrite($fht,$cont);

if (!@fclose($fht))

$error = 1;

}

}


}


if ($error)

{

echo "ocurrio un error inesperado por favor trata actualizando de nuevo o vuelve en un rato. Gracias por tu comprensión.";

exit(0);

}

if($safemode)

{

echo '<META HTTP-EQUIV="Refresh" CONTENT="2;URL=">';

exit(0);

}



// if no restrictions have been activated , the content of the web will be displayed normally
//echo "contenido";
?>
#313
PHP / Re: Obtener la MAC
5 Junio 2009, 00:41 AM
Cita de: Nakp en  4 Junio 2009, 22:02 PM
Para eso se ejecuta arp con shell_exec()

Citar
Código (php) [Seleccionar]
// Get the arp executable path
$location = `which arp`;
// Execute the arp command and store the output in $arpTable
$arpTable = `$location`;

http://es.wikipedia.org/wiki/Address_Resolution_Protocol

;)

OK, no lo veo en el código.  :huh: (la función...).

No, no es desafiarme.. naaaaa... que va, solo que no veo la función.
#314
PHP / Re: Obtener la MAC
4 Junio 2009, 20:12 PM
[quote author=nsigned link=topic=257012.msg1246626#msg1246626 date=1244138700]
Bueno buscando encontre esto:

Código (php) [Seleccionar]

<?
function returnMacAddress() {
// This code is under the GNU Public Licence
// Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
// Tested only on linux, please report bugs

// WARNING: the commands 'which' and 'arp' should be executable
// by the apache user; on most linux boxes the default configuration
// should work fine

// Get the arp executable path
$location = `which arp`;
// Execute the arp command and store the output in $arpTable
$arpTable = `$location`;
// Split the output so every line is an entry of the $arpSplitted array
$arpSplitted = split("\n",$arpTable);
// Get the remote ip address (the ip address of the client, the browser)
$remoteIp = $GLOBALS['REMOTE_ADDR'];
// Cicle the array to find the match with the remote ip address
foreach ($arpSplitted as $value) {
// Split every arp line, this is done in case the format of the arp
// command output is a bit different than expected
$valueSplitted = split(" ",$value);
foreach ($valueSplitted as $spLine) {
if (preg_match("/$remoteIp/",$spLine)) {
$ipFound = true;
}
// The ip address has been found, now rescan all the string
// to get the mac address
if ($ipFound) {
// Rescan all the string, in case the mac address, in the string
// returned by arp, comes before the ip address
// (you know, Murphy's laws)
reset($valueSplitted);
foreach ($valueSplitted as $spLine) {
if (preg_match("/[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f][:-]".
"[0-9a-f][0-9a-f]/i",$spLine)) {
return $spLine;
}
}
}
$ipFound = false;
}
}
return false;
}
?>


Pero necesitas tener un servidor dedicado donde puedas activar shell_exec(). Creo que lo mismo pasa para otros scripts...  :-\

Saludos
[/quote]

Donde usas shell_exec???
#315
PHP / Re: Comillas en PHP
4 Junio 2009, 17:20 PM
Cita de: Nakp en  3 Junio 2009, 04:48 AM
uy el señor moderador de bugs a nivel web viene a confirmarnos el rendimiento

(F) :xD

aaaaa mmmmiiiii qqqquuuueee mmmmeeee cccooonffffiiirrrmmmeee eeesstttaaaa (viva el albur mexicano xD)
#316
PHP / Re: Obtener la MAC
4 Junio 2009, 17:19 PM
mmm sí... php es de lado server. Busca algo hecho en java (no js), seguro hay pero es violar la privacidad...
#317
PHP / Re: Pequeños trucos en PHP
4 Junio 2009, 17:15 PM
Cita de: Dacan en 25 Enero 2009, 23:19 PM
Es para poner slashes del tipo (\) y se usa:

Código (php) [Seleccionar]
echo addslashes__recursive($tuvariable);

Aunque en ese código ya esta siendo utilizada en todas las superglobales.

Saludos, Dacan  :D

Exactirijillo xD, así es, con eso se cepilla todo lo que entra y sale a través del server/php. Aunque si tienes las magic quotes te va a poner tripe \ xD tons le cambié algo...

Código (php) [Seleccionar]

//----------------------------------------------+
// We claer all traffic of our server |
//----------------------------------------------+
// This function I extrac of SMF system fourum, cleared all " and ' in traffic server
function addslashes__recursive($var){
if (!is_array($var))
return addslashes($var);
$new_var = array();
foreach ($var as $k => $v)$new_var[addslashes($k)]=addslashes__recursive($v);
return $new_var;
}
//If the magic quotes are disable, aplicate the function, else, do not nothing
if(get_magic_quotes_gpc()==0){
$_POST=addslashes__recursive($_POST);
$_GET=addslashes__recursive($_GET);
$_REQUEST=addslashes__recursive($_REQUEST);
$_SERVER=addslashes__recursive($_SERVER);
$_COOKIE=addslashes__recursive($_COOKIE);
}


Y pues entrado en tema... les regalo otra!:

Código (php) [Seleccionar]

// With this function, we are clear the html chars to entity ascii
function clear_chars($var){
if(!is_array($var)){
return htmlspecialchars($var);
}
else{
$new_var = array();
foreach ($var as $k => $v){
$new_var[htmlspecialchars($k)]=clear_chars($v);
return $new_var;
}
}
}
if($_POST) $_POST=clear_chars($_POST);
if($_GET) $_GET=clear_chars($_GET);
if($_REQUEST) $_REQUEST=clear_chars($_REQUEST);
if($_SERVER) $_SERVER=clear_chars($_SERVER);
if($_COOKIE) $_COOKIE=clear_chars($_COOKIE);


Suerte
#318
PHP / Re: Web Services en PHP
2 Junio 2009, 00:18 AM
Cita de: memosky en  1 Junio 2009, 23:37 PM
es que creo el xml pero como invoco el servicio web services para ser recogido esta información que se genero a traves de php a xml, como llamo al web services esoo

Con un arreglo de métodos y parámetros, vas a consumir de X tecnologia hacia PHP?
#319
PHP / Re: error al hacer una variable
1 Junio 2009, 00:05 AM
Cita de: LightHades en 30 Mayo 2009, 13:45 PM
no me ha servid pero e terminado por enviar el contenido del archivo mediante formulario y funciona bien
otra cosa
se puede hacer que  cada x tiempo se abra un archivo y se imprima en una pagina?? seria mezclando javascript y php creo, pero no se como hacerlo

Con ajax  ;)
#320
PHP / Re: Web Services en PHP
1 Junio 2009, 00:04 AM
Cita de: memosky en 30 Mayo 2009, 03:03 AM
Saludos como estan....tengo una duda grande, he tratado por todos los medios tratar de mandar información a traves de php a un Web Services mandando datos de un formulario y estos recogido en php y tranformandolos en un xml, lo malo es que no me funciona el web service que tiene el cliente, posiblemente no se como se hace.. por eso necesito ayuda solamente necesito mandar la información xml al web service nada mas no quiero recuperar datos de el...solo envio

gracias

Y la duda... ¿es?.