[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2010 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 = @unserialize($core->blog->settings->pings->pings_uris); |
---|
| 19 | if (!$pings_uris) { |
---|
| 20 | $pings_uris = array(); |
---|
| 21 | } |
---|
| 22 | |
---|
| 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(); |
---|
| 28 | |
---|
| 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 | } |
---|
| 34 | |
---|
| 35 | $core->blog->settings->addNamespace('pings'); |
---|
| 36 | $core->blog->settings->pings->put('pings_active',!empty($_POST['pings_active']),null,null,true,true); |
---|
| 37 | $core->blog->settings->pings->put('pings_uris',serialize($pings_uris),null,null,true,true); |
---|
| 38 | http::redirect($p_url.'&up=1'); |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | catch (Exception $e) |
---|
| 42 | { |
---|
| 43 | $core->error->add($e->getMessage()); |
---|
| 44 | } |
---|
| 45 | ?> |
---|
| 46 | <html> |
---|
| 47 | <head> |
---|
| 48 | <title><?php echo __('Pings'); ?></title> |
---|
| 49 | </head> |
---|
| 50 | |
---|
| 51 | <body> |
---|
| 52 | <?php |
---|
| 53 | echo '<h2>'.__('Pings configuration').'</h2>'; |
---|
| 54 | |
---|
| 55 | if (!empty($_GET['up'])) { |
---|
| 56 | echo '<p class="message">'.__('Settings have been successfully updated.').'</p>'; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | echo |
---|
| 60 | '<form action="'.$p_url.'" method="post">'. |
---|
[94] | 61 | '<p><label for="pings_active" class="classic">'.form::checkbox('pings_active',1,$core->blog->settings->pings->pings_active).' '. |
---|
[0] | 62 | __('Activate pings extension').'</label></p>'; |
---|
| 63 | |
---|
[124] | 64 | $i = 0; |
---|
[0] | 65 | foreach ($pings_uris as $n => $u) |
---|
| 66 | { |
---|
| 67 | echo |
---|
[124] | 68 | '<p><label for="pings_srv_name-'.$i.'" class="classic">'.__('Service name:').' '. |
---|
| 69 | form::field(array('pings_srv_name[]','pings_srv_name-'.$i),20,128,html::escapeHTML($n)).'</label> '. |
---|
| 70 | '<label for="pings_srv_uri-'.$i.'" class="classic">'.__('Service URI:').' '. |
---|
| 71 | form::field(array('pings_srv_uri[]','pings_srv_uri-'.$i),40,255,html::escapeHTML($u)).'</label>'; |
---|
[0] | 72 | |
---|
| 73 | if (!empty($_GET['test'])) |
---|
| 74 | { |
---|
| 75 | try { |
---|
| 76 | pingsAPI::doPings($u,'Example site','http://example.com'); |
---|
| 77 | echo ' <img src="images/check-on.png" alt="ok" />'; |
---|
| 78 | } catch (Exception $e) { |
---|
| 79 | echo ' <img src="images/check-off.png" alt="'.__('error').'" /> '.$e->getMessage(); |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | echo '</p>'; |
---|
[124] | 84 | $i++; |
---|
[0] | 85 | } |
---|
| 86 | |
---|
| 87 | echo |
---|
[94] | 88 | '<p><label for="pings_srv_name2" class="classic">'.__('Service name:').' '. |
---|
| 89 | form::field(array('pings_srv_name[]','pings_srv_name2'),20,128).'</label> '. |
---|
| 90 | '<label for="pings_srv_uri2" class="classic">'.__('Service URI:').' '. |
---|
| 91 | form::field(array('pings_srv_uri[]','pings_srv_uri2'),40,255).'</label>'. |
---|
[0] | 92 | '</p>'. |
---|
| 93 | |
---|
[217] | 94 | '<p><input type="submit" value="'.__('Save').'" />'. |
---|
[0] | 95 | $core->formNonce().'</p>'. |
---|
| 96 | '</form>'; |
---|
| 97 | |
---|
| 98 | echo '<p><a href="'.$p_url.'&test=1">'.__('Test ping services').'</a></p>'; |
---|
| 99 | ?> |
---|
| 100 | </body> |
---|
| 101 | </html> |
---|