//***********************************
function createRandomPassword()
{
$chars = "1234567890QAZWSXEDCRFVTGBYHNUJMIKOLPaqzwsxedcrfvtgbyhnujmikolp";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
do
{
$num = rand() % strlen($chars);
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
while (strlen($pass)!=15);
return $pass;
}
.
lunes, 21 de julio de 2014
MGFLOTAS insertar records con NULL
<?
$texto="
INSERT INTO `records` VALUES (8725194, 32, '38.2821632', '-0.7180091', '165', '2014-07-21', '07:08:20', '0', '12', '0', '1', '28', '382821632', '-7180091', '09:07:46', '0', '0', '0', 9);
INSERT INTO `records` VALUES (8725195, 32, '38.2823232', '-0.7176723', '165', '2014-07-21', '07:09:18', '0', '12', '0', '0', '2', '382823232', '-7176723', '09:07:46', '0', '0', '0', 9);
INSERT INTO `records` VALUES (8725196, 32, '38.2823232', '-0.7176723', '165', '2014-07-21', '07:09:19', '0', '13', '0', '1', '0', '382823232', '-7176723', '09:07:46', '0', '0', '0', 9);
INSERT INTO `records` VALUES (8725197, 32, '38.2823232', '-0.7176723', '165', '2014-07-21', '07:09:23', '0', '13', '0', '0', '0', '382823232', '-7176723', '09:07:46', '0', '0', '0', 9);
";
$vector=explode(";",$texto);
for ($i=0;$i<sizeof($vector);$i++)
{
$vector2=explode(",",$vector[$i]);
echo "INSERT INTO `records` VALUES (null";
for ($j=1;$j<sizeof($vector2);$j++)
{
echo ",".$vector2[$j];
}
echo ";<br>";
}
?>
.
$texto="
INSERT INTO `records` VALUES (8725194, 32, '38.2821632', '-0.7180091', '165', '2014-07-21', '07:08:20', '0', '12', '0', '1', '28', '382821632', '-7180091', '09:07:46', '0', '0', '0', 9);
INSERT INTO `records` VALUES (8725195, 32, '38.2823232', '-0.7176723', '165', '2014-07-21', '07:09:18', '0', '12', '0', '0', '2', '382823232', '-7176723', '09:07:46', '0', '0', '0', 9);
INSERT INTO `records` VALUES (8725196, 32, '38.2823232', '-0.7176723', '165', '2014-07-21', '07:09:19', '0', '13', '0', '1', '0', '382823232', '-7176723', '09:07:46', '0', '0', '0', 9);
INSERT INTO `records` VALUES (8725197, 32, '38.2823232', '-0.7176723', '165', '2014-07-21', '07:09:23', '0', '13', '0', '0', '0', '382823232', '-7176723', '09:07:46', '0', '0', '0', 9);
";
$vector=explode(";",$texto);
for ($i=0;$i<sizeof($vector);$i++)
{
$vector2=explode(",",$vector[$i]);
echo "INSERT INTO `records` VALUES (null";
for ($j=1;$j<sizeof($vector2);$j++)
{
echo ",".$vector2[$j];
}
echo ";<br>";
}
?>
.
jueves, 17 de julio de 2014
Evitar la inyeccion SQL
// Evitamos la inyeccion SQL
// Modificamos las variables pasadas por GET
foreach( $_GET as $variable => $valor )
{
$_GET[$variable]=str_replace("'", "",$_GET[$variable]);
$_GET[$variable]=str_replace("\"", "",$_GET[$variable]);
$_GET[$variable]=str_replace("`", "",$_GET[$variable]);
$_GET[$variable]=str_replace("´", "",$_GET[$variable]);
}
// Modificamos las variables pasadas por POST
foreach( $_POST as $variable => $valor )
{
$_POST[$variable]=str_replace("'","",$_POST[$variable]);
$_POST[$variable]=str_replace("\"","",$_POST[$variable]);
$_POST[$variable]=str_replace("`","",$_POST[$variable]);
$_POST[$variable]=str_replace("´","",$_POST[$variable]);
}
.
// Modificamos las variables pasadas por GET
foreach( $_GET as $variable => $valor )
{
$_GET[$variable]=str_replace("'", "",$_GET[$variable]);
$_GET[$variable]=str_replace("\"", "",$_GET[$variable]);
$_GET[$variable]=str_replace("`", "",$_GET[$variable]);
$_GET[$variable]=str_replace("´", "",$_GET[$variable]);
}
// Modificamos las variables pasadas por POST
foreach( $_POST as $variable => $valor )
{
$_POST[$variable]=str_replace("'","",$_POST[$variable]);
$_POST[$variable]=str_replace("\"","",$_POST[$variable]);
$_POST[$variable]=str_replace("`","",$_POST[$variable]);
$_POST[$variable]=str_replace("´","",$_POST[$variable]);
}
.
Suscribirse a:
Entradas (Atom)
Archivo del blog
-
▼
2014
(13)
- ► septiembre (2)