@ 2018-09-21T11:59:21Z <?php
/*******************
**Kaga Akatsuki**
********************/
require_once 'core/init.php';
if (!$user) {
header('Location: /');
}
if (isset($_POST['ac'])) {
$ac = $_POST['ac'];
//switch ($ac) {
// case 'create':
if ($ac == 'create') {
$title_create_note = trim(htmlentities($db->real_escape_string(@$_POST['title_create_note'])));
$body_create_note = htmlentities($db->real_escape_string(@$_POST['body_create_note']));
$show_alert = "<script>$('#formCreateNote .alert').removeClass('hidden');</script>";
$hide_alert = "<script>$('#formCreateNote .alert').addClass('hidden');</script>";
$success_alert = "<script>$('#formCreateNote .alert').attr('class', 'alert alert-success');</script>";
$sql_create_note = "INSERT INTO notes VALUES (
'',
'{$data_user['id_user']}',
'{$title_create_note}',
'{$body_create_note}',
'{$date_current}',
'{$date_current}'
)";
$db->query($sql_create_note);
echo $show_alert.$success_alert." Tạo note thành công
<script>
location.href = '/index.php?ac=edit_note&&id=".$db->insert_id()."';
</script>
";
//break;
} elseif ($ac == 'edit') {
// case 'edit':
$title_edit_note = $db->real_escape_string(@$_POST['title_edit_note']);
$body_edit_note = $db->real_escape_string(@$_POST['body_edit_note']);
$id_edit_note = $db->real_escape_string(@$_POST['id_edit_note']);
$title_edit_note = trim(htmlentities($title_edit_note));
$body_edit_note = htmlentities($body_edit_note);
$id_edit_note = trim(htmlentities($id_edit_note));
$show_alert = "<script>$('#formEditNote .alert').removeClass('hidden');</script>";
$hide_alert = "<script>$('#formEditNote .alert').addClass('hidden');</script>";
$success_alert = "<script>$('#formEditNote .alert').attr('class', 'alert alert-success');</script>";
$sql_check_id_exist = "SELECT id_note, user_id FROM notes WHERE user_id = '$data_user[id_user]' AND id_note = '$id_edit_note'";
if ($db->num_rows($sql_check_id_exist)) {
$sql_edit_note = "UPDATE notes SET
body = '$body_edit_note',
title = '$title_edit_note',
date_edited = '$date_current'
WHERE user_id = '$data_user[id_user]' AND id_note = '$id_edit_note'
";
$db->query($sql_edit_note);
$db->close();
echo $show_alert.$success_alert." Đã chỉnh sửa note
<script>
location.reload();
</script>
";
} else {
echo $show_alert.'Bạn đã cố tình sửa chữa ID note, nhưng rất tiếc ID note này không tồn tại hoặc không thuộc quyền sở hữu của bạn.';
}
// break;
} elseif ($ac == 'delete') {
// case 'delete' :
$id_edit_note = $db->real_escape_string(@$_POST['id_edit_note']);
$id_edit_note = trim(htmlentities($id_edit_note));
$show_alert = "<script>$('#modalDeleteNote .alert').removeClass('hidden');</script>";
$hide_alert = "<script>$('#modalDeleteNote .alert').addClass('hidden');</script>";
$success_alert = "<script>$('#modalDeleteNote .alert').attr('class', 'alert alert-success');</script>";
$sql_check_id_exist = "SELECT id_note, user_id FROM notes WHERE user_id = '$data_user[id_user]' AND id_note = '$id_edit_note'";
if ($db->num_rows($sql_check_id_exist)) {
$sql_delete_note = "DELETE FROM notes WHERE user_id = '$data_user[id_user]' AND id_note = '$id_edit_note'";
$db->query($sql_delete_note);
$db->close();
echo $show_alert.$success_alert." Xoá note thành công.
<script>
location.href = 'index.php';
</script>
";
} else {
echo $show_alert.'Bạn đã cố tình sửa chữa ID note, nhưng rất tiếc ID note này không tồn tại hoặc không thuộc quyền sở hữu của bạn.';
}
/* break;
default:
break;*/
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.2.10 0.083 0.008 14.53 7.2.9 0.103 0.006 14.26 7.2.8 0.094 0.007 14.16 7.2.7 0.080 0.002 14.62 7.2.6 0.075 0.012 14.77 7.2.5 0.081 0.006 14.78 7.2.4 0.094 0.005 14.72 7.2.3 0.087 0.007 14.75 7.2.2 0.085 0.011 14.73 7.2.1 0.075 0.009 14.77 7.2.0 0.071 0.013 14.45 7.1.22 0.077 0.003 13.49 7.1.21 0.072 0.008 13.53 7.1.20 0.158 0.008 13.64 7.1.19 0.080 0.005 13.53 7.1.18 0.084 0.007 13.47 7.1.17 0.110 0.008 13.78 7.1.16 0.096 0.006 13.72 7.1.15 0.088 0.006 13.43 7.1.14 0.071 0.005 13.61 7.1.13 0.083 0.006 13.83 7.1.12 0.079 0.009 13.41 7.1.11 0.080 0.010 13.50 7.1.10 0.093 0.005 13.56 7.1.9 0.072 0.008 13.62 7.1.8 0.070 0.006 13.70 7.1.7 0.075 0.005 13.46 7.1.6 0.111 0.005 31.61 7.1.5 0.109 0.010 31.82 7.1.4 0.142 0.008 31.55 7.1.3 0.089 0.007 31.80 7.1.2 0.139 0.008 31.63 7.1.1 0.075 0.007 13.59 7.1.0 0.078 0.005 13.30 5.6.38 0.013 0.004 14.31
preferences:dark mode live preview
145.35 ms | 1394 KiB | 7 Q