8 isset(
$user) or require
$_SERVER[
'DOCUMENT_ROOT'] .
'/page/404.php';
10 if (!($row = Wrong\Database\Controller::find($_GET[
'id'],
'id', $_GET[
'table']))) {
11 exit(
'<script>errorToast("Ошибка!");</script>');
16 <div
class=
"modal fade p-0" id=
"<?= $basename ?>" tabindex=
"-1" data-backdrop=
"static">
17 <div
class=
"modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable w-100 mw-100 h-100 p-0 m-0" style=
"max-width: 100%;max-height:100%;" role=
"document">
18 <div
class=
"modal-content w-100 h-100 rounded-0 border-0">
19 <div
class=
"bg-secondary modal-header py-0 text-white rounded-0 border-0 pl-1 pr-0 align-items-center">
20 <h6
class=
"modal-title"><?= $row->file ?><small style=
"top:-3px;left:5px;position:relative;"><span
class=
"badge badge-light badge-pill slide-in-elliptic-left-fwd" style=
"padding:3px 6px 2px 6px;font-weight:300;">Изменён: <span
id=
"last-modified"><?= date(
'Y-m-d H:i:s', filemtime(
$_SERVER[
'DOCUMENT_ROOT'] . $row->file)) ?></span></span></small></h6>
21 <div
class=
"btn-group h-100">
22 <a
id=
"edit-code-help" class=
"btn btn-info px-3 py-0 rounded-0 d-flex align-items-center" href=
"#" data-trigger=
"focus" tabindex=
"0" data-placement=
"bottom" data-html=
"true" data-title=
"<i class='fa fa-keyboard-o mr-2'></i>Сочетания клавиш" data-content=
"<div class='m-0 mt-2 w-100 text-nowrap'>
23 <div class='m-0 small'>
24 <div class='d-flex justify-content-between pb-1'><div class='pr-5'>Сохранить:</div><kbd>Ctrl + S</kbd></div>
25 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Автодополнения:</div><kbd>Ctrl + Space</kbd></div>
26 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Развернуть:</div><kbd>F11</kbd></div>
27 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Свернуть:</div><kbd>Esc</kbd></div>
28 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>К закрывающему тегу:</div><kbd>Ctrl + J</kbd></div>
29 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Поиск:</div><kbd>Alt + F</kbd></div>
30 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Следующий результат:</div><kbd>Enter</kbd></div>
31 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Заменить:</div><kbd>Shift + Ctrl + F</kbd></div>
32 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Заменить всё:</div><kbd>Shift + Ctrl + R</kbd></div>
33 <div class='d-flex justify-content-between py-1 border-top'><div class='pr-5'>Закомментировать:</div><kbd>Ctrl + /</kbd></div>
35 </div>"><i
class=
"fa fa-question-circle"></i></a>
36 <a
class=
"btn btn-primary px-3 py-0 rounded-0 d-flex align-items-center" data-dismiss=
"modal" href=
"#"><i
class=
"fa fa-close"></i></a>
40 <div
class=
"modal-body p-0" style=
"background:#0f0f0f;">
41 <form
id=
"edit-code-form" action=
"<?= Wrong\Models\Actions::find(43)->request ?>" class=
"h-100">
42 <input type=
"hidden" name=
"id" value=
"<?= $row->id ?>">
43 <input type=
"hidden" name=
"table" value=
"<?= $_GET['table'] ?>">
44 <textarea
id=
"code" name=
"code" style=
"width:100%;display:none;"><?= htmlentities(file_get_contents(
$_SERVER[
'DOCUMENT_ROOT'] . $row->file)) ?></textarea>
47 <div
class=
"border-0 m-0 p-0 rounded-0" <?= !
$user->access()->action(
'/api/action/edit-code') ?
'hidden' :
'' ?>>
48 <button style=
"display:none;" form=
"edit-code-form" type=
"submit" class=
"btn btn-sm btn-block btn-success rounded-0 border-0">Сохранить и закрыть</button>
53 $(
'#edit-code-help').click(
function(e) {
55 if ($(
this).is(
'.active')) {
56 $(
this).popover(
'hide');
58 $(
this).popover(
'show');
61 $(
'#edit-code-help').on(
'hidden.bs.popover',
function(e) {
62 $(
'#edit-code-help').removeClass(
'active btn-success').addClass(
'btn-info');
64 $(
'#edit-code-help').on(
'shown.bs.popover',
function() {
65 $(
'#edit-code-help').addClass(
'active btn-success').removeClass(
'btn-info');
67 $(
'#<?= $basename ?>').on(
'shown.bs.modal', () => {
69 loadLibs(<?= Wrong\Html\Get::pathArrayJSON([
'/assets/system/css/codemirror.min.css']) ?>, <?= Wrong\Html\Get::pathArrayJSON([
'/assets/system/js/codemirror.min.js']) ?>,
'CodeMirror')
73 var editor = CodeMirror.fromTextArea($(
'#<?= $basename ?> #code')[0], {
76 styleActiveLine:
true,
78 "Ctrl-Space":
"autocomplete",
80 cm.setOption(
"fullScreen", !cm.getOption(
"fullScreen"));
83 if (cm.getOption(
"fullScreen")) cm.setOption(
"fullScreen",
false);
85 "Ctrl-J":
"toMatchingTag",
86 "Alt-F":
"findPersistent"
88 mode:
"application/x-httpd-php",
91 autoCloseBrackets:
true,
94 gutters: [
"CodeMirror-linenumbers",
"CodeMirror-foldgutter",
"breakpoints"],
95 highlightSelectionMatches: {
97 annotateScrollbar:
true
106 editor.setOption(
"theme",
'abcdef');
107 editor.on(
"gutterClick",
function(cm, n) {
108 var info = cm.lineInfo(n);
109 cm.setGutterMarker(n,
"breakpoints", info.gutterMarkers ?
null : makeMarker());
112 function makeMarker() {
113 var marker = document.createElement(
"div");
114 marker.style.color =
"#822";
115 marker.style.marginLeft =
"-8px";
116 marker.innerHTML =
"●";
120 $(
'#<?= $basename ?> [type=submit]').slideDown();
122 $(
"#<?= $basename ?> form").submit(
function(e) {
123 let origin = e.originalEvent;
125 lockSubmit($(
"#<?= $basename ?> button[form=edit-code-form]"));
129 url: $(
this).attr(
"action"),
130 data: $(
this).serialize(),
138 if (response.error) {
139 errorToast(response.error);
142 $(
'.dataTable').DataTable().ajax.reload(
null,
false);
143 $(
'.toast').toast(
'hide');
144 if (response.modified) {
145 $(
'#last-modified').html(response.modified);
146 $(
'#last-modified').parent().removeClass(
'slide-in-elliptic-left-fwd');
147 $(
'#last-modified').parent().addClass(
'blink-1');
149 $(
'#last-modified').parent().removeClass(
'blink-1');
152 successToast(response.message, 2000);
154 $(
"#<?= $basename ?>").modal(
"hide");
158 unlockSubmit($(
"#<?= $basename ?> button[form=edit-code-form]"));
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']
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit