auth->makePermissions([ dcAuth::PERMISSION_ADMIN, ])); $s = dcCore::app()->blog->settings->get(basename(__DIR__)); if (!empty($_POST['saveconfig'])) { try { $allowed_ip = []; foreach (explode("\n", $_POST['construction_allowed_ip']) as $ip) { $allowed_ip[] = trim($ip); } $extra_urls = []; foreach (explode(',', $_POST['construction_extra_urls']) as $url) { $extra_urls[] = trim($url); } $s->put('flag', empty($_POST['construction_flag']) ? false : true); $s->put('allowed_ip', json_encode($allowed_ip)); $s->put('title', $_POST['construction_title']); $s->put('message', $_POST['construction_message']); $s->put('extra_urls', json_encode($extra_urls)); dcCore::app()->blog->triggerBlog(); dcAdminNotices::addSuccessNotice( __('Settings successfully updated.') ); dcCore::app()->adminurl->redirect( 'admin.plugin.' . basename(__DIR__) ); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } $nb_rows = count(json_decode($s->get('allowed_ip'), true)); if ($nb_rows < 2) { $nb_rows = 2; } elseif ($nb_rows > 10) { $nb_rows = 10; } $editor = dcCore::app()->auth->getOption('editor'); echo ' ' . __('Construction') . '' . dcPage::jsConfirmClose('opts-forms') . dcCore::app()->callBehavior('adminPostEditor', $editor['xhtml'], 'construction', ['#construction_message'], 'xhtml') . dcPage::jsModuleLoad(basename(__DIR__) . '/js/index.js') . ' ' . dcPage::breadcrumb([ __('Plugins') => '', __('Construction') => '', ]) . dcPage::notices() . '

' . __('Configuration') . '

' . form::checkbox('construction_flag', 1, $s->get('flag')) . '

' . form::textarea('construction_allowed_ip', 20, $nb_rows, html::escapeHTML(implode("\n", json_decode($s->get('allowed_ip'), true)))) . '

' . sprintf(__('Your IP is %s - the allowed IP can view the blog normally.'), (string) http::realIP()) . '

' . form::field('construction_extra_urls', 20, 255, html::escapeHTML(implode(',', json_decode($s->get('extra_urls'), true))), 'maximal') . '

' . __('Presentation') . '

' . form::field('construction_title', 20, 255, html::escapeHTML($s->get('title')), 'maximal') . '

' . form::textarea('construction_message', 40, 10, html::escapeHTML($s->get('message'))) . '

' . form::hidden(['p'], 'construction') . dcCore::app()->formNonce() . '

';