-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
92 lines (63 loc) · 1.42 KB
/
index.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
require( 'defines.php' );
session_start();
require( 'functions.php' );
require( 'conad.classes.php' );
$infoMsg = "";
$errorMsg = "";
$validUser = ( isset( $_SESSION[ "logged" ] ) && $_SESSION[ "logged" ] === true ) ? true : false ;
if( isset( $_POST["action"] ) ) {
switch( $_POST["action"] ){
//
// LOGIN PAGE
//
case "login":
//
// are we good?
//
$validUser = ( $_POST[ "username" ] == USERNAME ) && ( $_POST[ "password" ] == PASSWORD );
if( !$validUser ){
$errorMsg = "Invalid username or password.";
}else{
$_SESSION[ "logged" ] = true;
$infoMsg = "Welcome!";
}
break;
//
// SUBMIT DATA PAGE
//
case "submit_data":
try{
if( ! $validUser ){
throw new Exception( "Sei brutto perche` non sei loggato." );
}
// check parameters
if(
! isset( $_FILES['file_fattura'] ) ||
! isset( $_FILES['file_ddt'] )
){
throw new Exception( "Hai sbagliato i parametri, minchione." );
}
//
// now let's do the dirty work
//
$conad_exporter = new ConadExporter();
$conad_exporter->getThatDamnTXT();
// ... and die full of joy
exit();
}catch( Exception $e ){
$errorMsg = $e->getMessage() ;
}
break;
//
// unknown action, kill it!
//
default:
dump( 'Mammt!' );
}
}
if( $validUser ) {
include( 'inc/view/form_export.phtml');
}else{
include( 'inc/view/login.phtml');
}