[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 | { |
---|
[3159] | 18 | $pings_uris = $core->blog->settings->pings->pings_uris; |
---|
[0] | 19 | if (!$pings_uris) { |
---|
| 20 | $pings_uris = array(); |
---|
| 21 | } |
---|
[2566] | 22 | |
---|
[0] | 23 | if (isset($_POST['pings_srv_name'])) |
---|
| 24 | { |
---|
| 25 | $pings_srv_name = is_array($_POST['pings_srv_name']) ? $_POST['pings_srv_name'] : array(); |
---|
| 26 | $pings_srv_uri = is_array($_POST['pings_srv_uri']) ? $_POST['pings_srv_uri'] : array(); |
---|
| 27 | $pings_uris = array(); |
---|
[2566] | 28 | |
---|
[0] | 29 | foreach ($pings_srv_name as $k => $v) { |
---|
| 30 | if (trim($v) && trim($pings_srv_uri[$k])) { |
---|
| 31 | $pings_uris[trim($v)] = trim($pings_srv_uri[$k]); |
---|
| 32 | } |
---|
| 33 | } |
---|
[2566] | 34 | |
---|
[0] | 35 | $core->blog->settings->addNamespace('pings'); |
---|
| 36 | $core->blog->settings->pings->put('pings_active',!empty($_POST['pings_active']),null,null,true,true); |
---|
[3159] | 37 | $core->blog->settings->pings->put('pings_uris',$pings_uris,null,null,true,true); |
---|
[2256] | 38 | dcPage::addSuccessNotice(__('Settings have been successfully updated.')); |
---|
| 39 | http::redirect($p_url); |
---|
[0] | 40 | } |
---|
| 41 | } |
---|
| 42 | catch (Exception $e) |
---|
| 43 | { |
---|
| 44 | $core->error->add($e->getMessage()); |
---|
| 45 | } |
---|
| 46 | ?> |
---|
| 47 | <html> |
---|
| 48 | <head> |
---|
| 49 | <title><?php echo __('Pings'); ?></title> |
---|
| 50 | </head> |
---|
| 51 | |
---|
| 52 | <body> |
---|
| 53 | <?php |
---|
[1339] | 54 | |
---|
[1358] | 55 | echo dcPage::breadcrumb( |
---|
[1339] | 56 | array( |
---|
| 57 | __('Plugins') => '', |
---|
[2166] | 58 | __('Pings configuration') => '' |
---|
[1339] | 59 | )); |
---|
[0] | 60 | |
---|
| 61 | echo |
---|
| 62 | '<form action="'.$p_url.'" method="post">'. |
---|
[1930] | 63 | '<p><label for="pings_active" class="classic">'.form::checkbox('pings_active',1,$core->blog->settings->pings->pings_active). |
---|
| 64 | __('Activate pings extension').'</label></p>'; |
---|
[0] | 65 | |
---|
[124] | 66 | $i = 0; |
---|
[0] | 67 | foreach ($pings_uris as $n => $u) |
---|
| 68 | { |
---|
| 69 | echo |
---|
[1454] | 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::field(array('pings_srv_uri[]','pings_srv_uri-'.$i),40,255,html::escapeHTML($u)); |
---|
[2566] | 74 | |
---|
[0] | 75 | if (!empty($_GET['test'])) |
---|
| 76 | { |
---|
| 77 | try { |
---|
| 78 | pingsAPI::doPings($u,'Example site','http://example.com'); |
---|
[1454] | 79 | echo ' <img src="images/check-on.png" alt="OK" />'; |
---|
[0] | 80 | } catch (Exception $e) { |
---|
[1454] | 81 | echo ' <img src="images/check-off.png" alt="'.__('Error').'" /> '.$e->getMessage(); |
---|
[0] | 82 | } |
---|
| 83 | } |
---|
[2566] | 84 | |
---|
[0] | 85 | echo '</p>'; |
---|
[124] | 86 | $i++; |
---|
[0] | 87 | } |
---|
| 88 | |
---|
| 89 | echo |
---|
[1454] | 90 | '<p><label for="pings_srv_name2" class="classic">'.__('Service name:').'</label> '. |
---|
| 91 | form::field(array('pings_srv_name[]','pings_srv_name2'),20,128).' '. |
---|
| 92 | '<label for="pings_srv_uri2" class="classic">'.__('Service URI:').'</label> '. |
---|
| 93 | form::field(array('pings_srv_uri[]','pings_srv_uri2'),40,255). |
---|
[0] | 94 | '</p>'. |
---|
| 95 | |
---|
[217] | 96 | '<p><input type="submit" value="'.__('Save').'" />'. |
---|
[0] | 97 | $core->formNonce().'</p>'. |
---|
| 98 | '</form>'; |
---|
| 99 | |
---|
[1454] | 100 | echo '<p><a class="button" href="'.$p_url.'&test=1">'.__('Test ping services').'</a></p>'; |
---|
[0] | 101 | ?> |
---|
[2322] | 102 | |
---|
| 103 | <?php dcPage::helpBlock('pings'); ?> |
---|
| 104 | |
---|
[0] | 105 | </body> |
---|
[2566] | 106 | </html> |
---|