Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
anas-araid committed Oct 11, 2018
1 parent 3b5731e commit 3b064ea
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
36 changes: 19 additions & 17 deletions core/checkPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@
</form>

<?php
$_SESSION['warning'] = true;
if(isset($_POST['password'])){
include 'core/functions.php';
$password = text_filter_encrypt($_POST["password"]);
// caserma
if ($password == 'b65959845f63d31058e1319f724bcaff'){
$_SESSION['include'] = 'core/reports.php';
echo "
<script>
flatAlert('Accesso eseguito con successo', '', 'success', 'index.php');
</script>";
}else{
echo "
<script>
flatAlert('Password errata', '', 'error', 'index.php');
</script>";
}
if (!$error_message) {
$_SESSION['warning'] = true;
if(isset($_POST['password'])){
include 'core/functions.php';
$password = text_filter_encrypt($_POST["password"]);
// caserma
if ($password == 'b65959845f63d31058e1319f724bcaff'){
$_SESSION['include'] = 'core/reports.php';
echo "
<script>
flatAlert('Accesso eseguito con successo', '', 'success', 'index.php');
</script>";
}else{
echo "
<script>
flatAlert('Password errata', '', 'error', 'index.php');
</script>";
}
}
}

?>
3 changes: 1 addition & 2 deletions core/dbConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
$error_message = false;
try{
$db_conn = @mysqli_connect($db_host, $db_user, $db_pass, $db_name);

if ($db_conn==null)
throw new exception (mysqli_connect_error(). ' Error n.'. mysqli_connect_errno());
throw new exception (mysqli_connect_error(). ' Error n.'. mysqli_connect_errno());
} catch (Exception $e){
$error_message = true;
$message = $e->getMessage();
Expand Down
20 changes: 12 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// error_reporting per togliere il notice quando non trova isLogged
error_reporting(0);
include "core/dbConnection.php";
if (isset($_GET['back'])) {
$_SESSION['include'] = 'core/reports.php';
$_SESSION['search'] = null;
Expand All @@ -27,13 +28,6 @@
}
}catch(Exception $e){
}
include "core/dbConnection.php";
if ($error_message) {
echo "
<script>
flatAlert('Accesso', 'Impossibile connettersi al database', 'error', 'index.php');
</script>";
}
?>
</head>
<body>
Expand Down Expand Up @@ -74,7 +68,17 @@
</section>
<section class="mdl-cell mdl-cell--middle mdl-cell--9-col">
<div class="mdl-card mdl-shadow--8dp style-card" style="width:100%">
<?php include $_SESSION['include'] ?>
<?php
if ($error_message) {
echo "
<script>
window.onload = function(){
flatAlertClose('Accesso', 'Impossibile connettersi al database', 'error');
}
</script>";
}
include $_SESSION['include'];
?>
</div>
</section>
</div>
Expand Down
13 changes: 13 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ function flatAlert(titolo, testo, icona, url){
}
});
}
function flatAlertClose(titolo, testo, icona){
swal({
title: titolo,
text: testo,
icon: icona,
}).then(azione => {
if (azione){
window.close();
}else{
window.close();
}
});
}
function alertDeleteReport(id){
swal(
{
Expand Down

0 comments on commit 3b064ea

Please sign in to comment.