Subversion Repositories computer_asset_manager_v1

Rev

Rev 17 | Rev 20 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 18
Line 48... Line 48...
48
      $filename = preg_replace( "/($replace_char)+/", $replace_char, $filename );
48
      $filename = preg_replace( "/($replace_char)+/", $replace_char, $filename );
49
   return $filename;
49
   return $filename;
50
}
50
}
51
 
51
 
52
 
52
 
53
$date = $_GET['report_date'];
53
$date = $_REQUEST['report_date'];
54
$client = $_GET['client'];
54
$client = $_REQUEST['client'];
55
$hostname = $_GET['hostname'];
55
$hostname = $_REQUEST['hostname'];
56
$serial = $_GET['serialnumber'];
56
$serial = isset( $_REQUEST['serialnumber'] ) ? $_REQUEST['serialnumber'] : '';
57
$report = $_GET['report'];
57
$report = $_FILES['report'];
58
 
58
 
59
/* test data
59
/* test data
60
$client = 'Roome Land Surveying';
60
$client = 'Roome Land Surveying';
61
$hostname = 'router.roome.local';
61
$hostname = 'router.roome.local';
62
$date = '"2016-03-31 01:25:04"';
62
$date = '"2016-03-31 01:25:04"';
Line 69... Line 69...
69
$date = preg_replace( '/(")/', '', $date );
69
$date = preg_replace( '/(")/', '', $date );
70
// make sure we can parse it
70
// make sure we can parse it
71
$date = strtotime( $date );
71
$date = strtotime( $date );
72
if ( empty( $date ) ) { // we couldn't parse the date
72
if ( empty( $date ) ) { // we couldn't parse the date
73
   // grab the original
73
   // grab the original
74
   $date = $_GET['report_date'];
74
   $date = $_REQUEST['report_date'];
75
   print "Unable to parse date [$date]";
75
   print "Unable to parse date [$date]";
76
   // set it to empty so we won't do any work.
76
   // set it to empty so we won't do any work.
77
   $date = '';
77
   $date = '';
78
}
78
}
79
 
79
 
-
 
80
file_put_contents( STORAGE_PATH . '/report.log', print_r( $report, true ) );
80
if ( empty( $date ) or empty( $client ) or empty( $hostname ) or empty( $report ) ) {
81
if ( empty( $date ) or empty( $client ) or empty( $hostname ) or empty( $report ) ) {
81
   print( "You must pass a date, client, hostname and report. The values read were\n" );
82
   print( "You must pass a date, client, hostname and report. The values read were\n<br />" );
82
   print "Date=[$date]\nClient=[$client]\nHostname=[$hostname]\n";
83
   print "Date=[$date]\n<br />Client=[$client]\n<br />Hostname=[$hostname]\n<br />";
-
 
84
   print "Report is\n<br /><pre>";
-
 
85
   print_r( $report );
-
 
86
   print "</pre>\n";
83
} else { // we have the requireds
87
} else { // we have the requireds
84
   if ( empty( $serial ) ) $serial = '';
88
   if ( empty( $serial ) ) $serial = '';
85
   /* Figure out a file name for it */
89
   /* Figure out a file name for it */
86
   $filename = STORAGE_PATH . '/' . 
90
   $filename = STORAGE_PATH . '/' . 
87
               sanitize_filename( 
91
               sanitize_filename( 
Line 89... Line 93...
89
                  array( date('Y-m-d H:i:s', $date ),
93
                  array( date('Y-m-d H:i:s', $date ),
90
                  $client,
94
                  $client,
91
                  $hostname,
95
                  $hostname,
92
                  $serial ) ) ) . 
96
                  $serial ) ) ) . 
93
                  '.yaml';
97
                  '.yaml';
-
 
98
                  
94
   if ( file_put_contents( $filename, $report ) ) {
99
   if ( move_uploaded_file( $report['tmp_name'], $filename ) ) {
95
      touch ( $filename, $date );
100
      touch ( $filename, $date );
96
      print( $report );
101
      print( $report['size'] );
97
   } else {
102
   } else {
98
      print( "Could not save file [$filename]" );
103
      print( "Could not save file [$filename]" );
99
   }
104
   }
100
}
105
}
101
 
106