import-model.php
См. документацию.
1 <?php
2 
3 /**
4  * @file
5  * @brief окно импорта модели
6  */
7 
8 isset($user) or require $_SERVER['DOCUMENT_ROOT'] . '/page/404.php';
9 
10 ?>
11 <div class="modal fade" id="<?= $basename ?>" tabindex="-1" data-backdrop="static" data-keyboard="false">
12  <div class="modal-dialog modal-dialog-centered" role="document">
13  <div class="modal-content">
14  <div class="modal-header">
15  <h5 class="modal-title">Импорт модели</h5>
16  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
17  <span aria-hidden="true">&times;</span>
18  </button>
19  </div>
20  <div class="modal-body pt-2">
21  <form action="<?= Wrong\Models\Actions::find(38)->request ?>">
22  <div class="input-group input-group-sm">
23  <div class="custom-file">
24  <input type="file" name="file" accept="application/zip" class="custom-file-input" id="input-file">
25  <label class="custom-file-label" for="input-file">Выбрать .zip файл импорта</label>
26  </div>
27  </div>
28  <button type="submit" class="btn btn-sm btn-block btn-success mt-3">Импорт</button>
29  </form>
30  </div>
31  </div>
32  </div>
33  <script>
34  $("#input-file").change(function() {
35  $(this).next().html($("#input-file")[0].files[0]?.name || 'Выбрать .zip файл импорта');
36  });
37  $("#<?= $basename ?> form").submit(function(e) {
38  lockSubmit($("#<?= $basename ?> form [type=submit]"));
39  e.preventDefault();
40  let formData = new FormData();
41  formData.append('file', $("#input-file")[0].files[0]);
42  formData.append('CSRF', window.CSRF);
43  $.ajax({
44  type: "POST",
45  url: $(this).attr("action"),
46  cache: false,
47  contentType: false,
48  processData: false,
49  data: formData,
50  dataType: "json",
51  statusCode: {
52  404: errorToast,
53  403: errorToast
54  }
55  })
56  .done(response => {
57  if (response.error) {
58  errorToast(response.error);
59  return;
60  }
61  $('.dataTable').DataTable().ajax.reload(null, false);
62  $('.toast').toast('hide');
63  successToast(response.message);
64  $("#<?= $basename ?>").modal("hide");
65  if (location.pathname != response.location) {
66  setTimeout(() => {
67  location.href = response.location;
68  }, 1000);
69  }
70  })
71  .always(() => {
72  unlockSubmit($("#<?= $basename ?> form [type=submit]"));
73  });
74  });
75  </script>
76 </div>
$user
Definition: from-user.php:38
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
Definition: from-user.php:36