add action logging
This commit is contained in:
45
index.php
45
index.php
@@ -18,24 +18,35 @@ if (!empty($idcko)){
|
||||
if ($stmt1->num_rows() < 1) {
|
||||
die("Nonexistent link");
|
||||
}
|
||||
while ($stmt1->fetch()) {
|
||||
$stmt2 = $mysqli->prepare("SELECT `Content` FROM Content WHERE `ContentID` = ?");
|
||||
$stmt2->bind_param("s", $contentid);
|
||||
$stmt2->bind_result ($content);
|
||||
$stmt2->execute();
|
||||
$stmt2->store_result();
|
||||
if ($stmt2->num_rows() < 1) {
|
||||
die("Faulty link");
|
||||
}
|
||||
while ($stmt2->fetch()) {
|
||||
$action = "Success";
|
||||
$stmt3 = $mysqli->prepare("INSERT INTO Logs (`Action`, `LinkID`, `ContentID`, `Datetime`, `Nickname`, `IP`) VALUES (?, ?, ?, ?, ?, ?);");
|
||||
$stmt3->bind_param('ssssss', $action, $idcko, $contentid, $curdate, $nickname, $ipcka);
|
||||
$stmt3->execute();
|
||||
$stmt3->store_result();
|
||||
echo $content;
|
||||
}
|
||||
if (empty($_POST['action'])){
|
||||
while ($stmt1->fetch()) {
|
||||
$stmt2 = $mysqli->prepare("SELECT `Content` FROM Content WHERE `ContentID` = ?");
|
||||
$stmt2->bind_param("s", $contentid);
|
||||
$stmt2->bind_result ($content);
|
||||
$stmt2->execute();
|
||||
$stmt2->store_result();
|
||||
if ($stmt2->num_rows() < 1) {
|
||||
die("Faulty link");
|
||||
}
|
||||
while ($stmt2->fetch()) {
|
||||
$action = "Page view";
|
||||
$stmt3 = $mysqli->prepare("INSERT INTO Logs (`Action`, `LinkID`, `ContentID`, `Datetime`, `Nickname`, `IP`) VALUES (?, ?, ?, ?, ?, ?);");
|
||||
$stmt3->bind_param('ssssss', $action, $idcko, $contentid, $curdate, $nickname, $ipcka);
|
||||
$stmt3->execute();
|
||||
$stmt3->store_result();
|
||||
$content = str_replace("__LINK_ID__",$idcko,$content);
|
||||
echo $content;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
$action = $_POST['action'];
|
||||
$extrainfo = $_POST['extrainfo'];
|
||||
$stmt4 = $mysqli->prepare("INSERT INTO Logs (`Action`, `ExtraInfo`, `LinkID`, `ContentID`, `Datetime`, `Nickname`, `IP`) VALUES (?, ?, ?, ?, ?, ?);");
|
||||
$stmt4->bind_param('sssssss', $action, $extrainfo, $idcko, $contentid, $curdate, $nickname, $ipcka);
|
||||
$stmt4->execute();
|
||||
$stmt4->store_result();
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
Reference in New Issue
Block a user