POST & GET opslaan
Ik zocht een script dat elke POST en GET die gedaan waard in een form firmulier opslaat ik heb het al tot zoveer maar hij wil het niet doen :S
Kan iemand helpen aub en jah de db klopt en dit stuk moet in een script dat op elke pagina word geinclude :
Code (php)
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
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
<?php
// GET & POST opslaan in db
if(((count($_POST) > 0 && !isset($_POST['omnilog'])) || ($_POST['omnilog'] == 1 && count($_GET) > 1)) && isset($OMNILOG)) {
$forwardedFor = ($_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['HTTP_CLIENT_IP'];
$forwardedFor = preg_replace('/, .+/','',$forwardedFor);
$postVars = addslashes(var_export($_POST,TRUE));
if($postVars == "array (\n)" || (count($_POST) == 1 && isset($_POST['omnilog'])))
$postVars = "";
$getVars = addslashes(var_export($_GET,TRUE));
if($getVars == "array (\n)")
$getVars = "";
$ip=$_SERVER['REMOTE_ADDR'];
$file=$_SERVER['PHP_SELF'];
mysql_query("INSERT INTO `[omnilog]` (time, login, IP, forwardedFor, file, $_POST, $_GET) VALUES (NOW(),'$user->user', '$ip', '$forwardedFor', '$file', '$postVars','$getVars')");
}
foreach($_POST as $key => $value) {
if(gettype($_POST[$key]) == "array")
foreach($_POST[$key] as $key2 => $value2)
$_POST[$key][$key2] = addslashes($_POST[$key][$key2]);
else
$_POST[$key] = addslashes($_POST[$key]);
}
foreach($_GET as $key => $value) {
if(gettype($_GET[$key]) == "array")
foreach($_GET[$key] as $key2 => $value2)
$_GET[$key][$key2] = addslashes($_GET[$key][$key2]);
else
$_GET[$key] = addslashes($_GET[$key]);
}
foreach($_COOKIE as $key => $value) {
if(gettype($_COOKIE[$key]) == "array")
foreach($_COOKIE[$key] as $key2 => $value2)
$_COOKIE[$key][$key2] = addslashes($_COOKIE[$key][$key2]);
else
$_COOKIE[$key] = addslashes($_COOKIE[$key]);
}
?>
// GET & POST opslaan in db
if(((count($_POST) > 0 && !isset($_POST['omnilog'])) || ($_POST['omnilog'] == 1 && count($_GET) > 1)) && isset($OMNILOG)) {
$forwardedFor = ($_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['HTTP_CLIENT_IP'];
$forwardedFor = preg_replace('/, .+/','',$forwardedFor);
$postVars = addslashes(var_export($_POST,TRUE));
if($postVars == "array (\n)" || (count($_POST) == 1 && isset($_POST['omnilog'])))
$postVars = "";
$getVars = addslashes(var_export($_GET,TRUE));
if($getVars == "array (\n)")
$getVars = "";
$ip=$_SERVER['REMOTE_ADDR'];
$file=$_SERVER['PHP_SELF'];
mysql_query("INSERT INTO `[omnilog]` (time, login, IP, forwardedFor, file, $_POST, $_GET) VALUES (NOW(),'$user->user', '$ip', '$forwardedFor', '$file', '$postVars','$getVars')");
}
foreach($_POST as $key => $value) {
if(gettype($_POST[$key]) == "array")
foreach($_POST[$key] as $key2 => $value2)
$_POST[$key][$key2] = addslashes($_POST[$key][$key2]);
else
$_POST[$key] = addslashes($_POST[$key]);
}
foreach($_GET as $key => $value) {
if(gettype($_GET[$key]) == "array")
foreach($_GET[$key] as $key2 => $value2)
$_GET[$key][$key2] = addslashes($_GET[$key][$key2]);
else
$_GET[$key] = addslashes($_GET[$key]);
}
foreach($_COOKIE as $key => $value) {
if(gettype($_COOKIE[$key]) == "array")
foreach($_COOKIE[$key] as $key2 => $value2)
$_COOKIE[$key][$key2] = addslashes($_COOKIE[$key][$key2]);
else
$_COOKIE[$key] = addslashes($_COOKIE[$key]);
}
?>
Mvg
Ik zou de POST en de GET gewoon serializen en zo opslaan. Als je ze later nodig hebt kun je ze altijd weer deserializen.
maar ik wil dit gewoon in een scriptje zodat elke keer een post of get word uitvoerd dit in db gaat het is voor controle enzo ;)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$sql = "
INSERT INTO tabelnaam
(postveld)
VALUES
('" . mysql_real_escape_string (serialize ($_POST)) . "')
";
if (!mysql_query ($sql)) {
trigger_error (mysql_error ());
}
}
?>
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$sql = "
INSERT INTO tabelnaam
(postveld)
VALUES
('" . mysql_real_escape_string (serialize ($_POST)) . "')
";
if (!mysql_query ($sql)) {
trigger_error (mysql_error ());
}
}
?>