| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
|---|
| 7 | # Licensed under the GPL version 2.0 license. |
|---|
| 8 | # See LICENSE file or |
|---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|---|
| 10 | # |
|---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
|---|
| 12 | if (!defined('DC_CONTEXT_ADMIN')) {return;} |
|---|
| 13 | |
|---|
| 14 | dcPage::checkSuper(); |
|---|
| 15 | |
|---|
| 16 | try |
|---|
| 17 | { |
|---|
| 18 | $pings_uris = $core->blog->settings->pings->pings_uris; |
|---|
| 19 | if (!$pings_uris) { |
|---|
| 20 | $pings_uris = array(); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | if (isset($_POST['pings_srv_name'])) { |
|---|
| 24 | $pings_srv_name = is_array($_POST['pings_srv_name']) ? $_POST['pings_srv_name'] : array(); |
|---|
| 25 | $pings_srv_uri = is_array($_POST['pings_srv_uri']) ? $_POST['pings_srv_uri'] : array(); |
|---|
| 26 | $pings_uris = array(); |
|---|
| 27 | |
|---|
| 28 | foreach ($pings_srv_name as $k => $v) { |
|---|
| 29 | if (trim($v) && trim($pings_srv_uri[$k])) { |
|---|
| 30 | $pings_uris[trim($v)] = trim($pings_srv_uri[$k]); |
|---|
| 31 | } |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | $core->blog->settings->addNamespace('pings'); |
|---|
| 35 | // Settings for all blogs |
|---|
| 36 | $core->blog->settings->pings->put('pings_active', !empty($_POST['pings_active']), null, null, true, true); |
|---|
| 37 | $core->blog->settings->pings->put('pings_uris', $pings_uris, null, null, true, true); |
|---|
| 38 | // Settings for current blog only |
|---|
| 39 | $core->blog->settings->pings->put('pings_auto', !empty($_POST['pings_auto']), null, null, true, false); |
|---|
| 40 | |
|---|
| 41 | dcPage::addSuccessNotice(__('Settings have been successfully updated.')); |
|---|
| 42 | http::redirect($p_url); |
|---|
| 43 | } |
|---|
| 44 | } catch (Exception $e) { |
|---|
| 45 | $core->error->add($e->getMessage()); |
|---|
| 46 | } |
|---|
| 47 | ?> |
|---|
| 48 | <html> |
|---|
| 49 | <head> |
|---|
| 50 | <title><?php echo __('Pings'); ?></title> |
|---|
| 51 | </head> |
|---|
| 52 | |
|---|
| 53 | <body> |
|---|
| 54 | <?php |
|---|
| 55 | |
|---|
| 56 | echo dcPage::breadcrumb( |
|---|
| 57 | array( |
|---|
| 58 | __('Plugins') => '', |
|---|
| 59 | __('Pings configuration') => '' |
|---|
| 60 | )); |
|---|
| 61 | |
|---|
| 62 | echo |
|---|
| 63 | '<form action="' . $p_url . '" method="post">' . |
|---|
| 64 | '<p><label for="pings_active" class="classic">' . form::checkbox('pings_active', 1, $core->blog->settings->pings->pings_active) . |
|---|
| 65 | __('Activate pings extension') . '</label></p>'; |
|---|
| 66 | |
|---|
| 67 | $i = 0; |
|---|
| 68 | foreach ($pings_uris as $n => $u) { |
|---|
| 69 | echo |
|---|
| 70 | '<p><label for="pings_srv_name-' . $i . '" class="classic">' . __('Service name:') . '</label> ' . |
|---|
| 71 | form::field(array('pings_srv_name[]', 'pings_srv_name-' . $i), 20, 128, html::escapeHTML($n)) . ' ' . |
|---|
| 72 | '<label for="pings_srv_uri-' . $i . '" class="classic">' . __('Service URI:') . '</label> ' . |
|---|
| 73 | form::url(array('pings_srv_uri[]', 'pings_srv_uri-' . $i), array( |
|---|
| 74 | 'size' => 40, |
|---|
| 75 | 'default' => html::escapeHTML($u) |
|---|
| 76 | )); |
|---|
| 77 | |
|---|
| 78 | if (!empty($_GET['test'])) { |
|---|
| 79 | try { |
|---|
| 80 | pingsAPI::doPings($u, 'Example site', 'http://example.com'); |
|---|
| 81 | echo ' <img src="images/check-on.png" alt="OK" />'; |
|---|
| 82 | } catch (Exception $e) { |
|---|
| 83 | echo ' <img src="images/check-off.png" alt="' . __('Error') . '" /> ' . $e->getMessage(); |
|---|
| 84 | } |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | echo '</p>'; |
|---|
| 88 | $i++; |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | echo |
|---|
| 92 | '<p><label for="pings_srv_name2" class="classic">' . __('Service name:') . '</label> ' . |
|---|
| 93 | form::field(array('pings_srv_name[]', 'pings_srv_name2'), 20, 128) . ' ' . |
|---|
| 94 | '<label for="pings_srv_uri2" class="classic">' . __('Service URI:') . '</label> ' . |
|---|
| 95 | form::url(array('pings_srv_uri[]', 'pings_srv_uri2'), 40) . |
|---|
| 96 | '</p>' . |
|---|
| 97 | |
|---|
| 98 | '<p><label for="pings_auto" class="classic">' . form::checkbox('pings_auto', 1, $core->blog->settings->pings->pings_auto) . |
|---|
| 99 | __('Auto pings all services on first publication of entry (current blog only)') . '</label></p>' . |
|---|
| 100 | |
|---|
| 101 | '<p><input type="submit" value="' . __('Save') . '" />' . |
|---|
| 102 | $core->formNonce() . '</p>' . |
|---|
| 103 | '</form>'; |
|---|
| 104 | |
|---|
| 105 | echo '<p><a class="button" href="' . $p_url . '&test=1">' . __('Test ping services') . '</a></p>'; |
|---|
| 106 | ?> |
|---|
| 107 | |
|---|
| 108 | <?php dcPage::helpBlock('pings');?> |
|---|
| 109 | |
|---|
| 110 | </body> |
|---|
| 111 | </html> |
|---|