You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. require_once('../ajax_asm.php');
  3. function verbose( $ok=1,$info=""){
  4. // failure to upload throws 400 error
  5. if( $ok==0 ){
  6. http_response_code(400);
  7. };
  8. die(json_encode(["ok"=>$ok, "info"=>$info]));
  9. };
  10. if( $CUser->Data['id'] > 1 ){
  11. if( empty( $_FILES ) || $_FILES['db_file']['error'] ){
  12. verbose( 0, "Failed to move uploaded file.[" . $_FILES['db_file']['error'] . "]" );
  13. };
  14. $filePath = $SYSPath . 'lib/controller/data';
  15. if( !file_exists( $filePath ) ){
  16. if( !mkdir($filePath, 0777, true ) ){
  17. verbose( 0, "Failed to create $filePath" );
  18. };
  19. };
  20. if( file_exists( $_FILES['db_file']['tmp_name'] ) ){
  21. $MD5 = md5_file( $_FILES['db_file']['tmp_name'] );
  22. $TArr = explode( '.', $_FILES['db_file']['name'] );
  23. $EXT = 'db';
  24. $FNAME = $MD5 . '.' . $EXT;
  25. copy( $_FILES['db_file']['tmp_name'], $filePath . '/' . $FNAME );
  26. @unlink( $_FILES['db_file']['tmp_name'] );
  27. $RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db');
  28. $PARAM = $MD5;
  29. $QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES(1,129,0,'{$PARAM}')";
  30. $RBASE->Query( $QS, false );
  31. verbose( 1, "ALL IS OK" );
  32. };
  33. } else {
  34. verbose( 0, 'Access Denied!' );
  35. };
  36. ?>