| 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 = @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 |           dcPage::addSuccessNotice(__('Settings have been successfully updated.')); | 
|---|
| 39 |           http::redirect($p_url); | 
|---|
| 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 | 
|---|
| 54 |  | 
|---|
| 55 | echo dcPage::breadcrumb( | 
|---|
| 56 |      array( | 
|---|
| 57 |           __('Plugins') => '', | 
|---|
| 58 |           __('Pings configuration') => '' | 
|---|
| 59 |      )); | 
|---|
| 60 |  | 
|---|
| 61 | echo | 
|---|
| 62 | '<form action="'.$p_url.'" method="post">'. | 
|---|
| 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>'; | 
|---|
| 65 |  | 
|---|
| 66 | $i = 0; | 
|---|
| 67 | foreach ($pings_uris as $n => $u) | 
|---|
| 68 | { | 
|---|
| 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::field(array('pings_srv_uri[]','pings_srv_uri-'.$i),40,255,html::escapeHTML($u)); | 
|---|
| 74 |  | 
|---|
| 75 |      if (!empty($_GET['test'])) | 
|---|
| 76 |      { | 
|---|
| 77 |           try { | 
|---|
| 78 |                pingsAPI::doPings($u,'Example site','http://example.com'); | 
|---|
| 79 |                echo ' <img src="images/check-on.png" alt="OK" />'; | 
|---|
| 80 |           } catch (Exception $e) { | 
|---|
| 81 |                echo ' <img src="images/check-off.png" alt="'.__('Error').'" /> '.$e->getMessage(); | 
|---|
| 82 |           } | 
|---|
| 83 |      } | 
|---|
| 84 |  | 
|---|
| 85 |      echo '</p>'; | 
|---|
| 86 |      $i++; | 
|---|
| 87 | } | 
|---|
| 88 |  | 
|---|
| 89 | echo | 
|---|
| 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). | 
|---|
| 94 | '</p>'. | 
|---|
| 95 |  | 
|---|
| 96 | '<p><input type="submit" value="'.__('Save').'" />'. | 
|---|
| 97 | $core->formNonce().'</p>'. | 
|---|
| 98 | '</form>'; | 
|---|
| 99 |  | 
|---|
| 100 | echo '<p><a class="button" href="'.$p_url.'&test=1">'.__('Test ping services').'</a></p>'; | 
|---|
| 101 | ?> | 
|---|
| 102 |  | 
|---|
| 103 | <?php dcPage::helpBlock('pings'); ?> | 
|---|
| 104 |  | 
|---|
| 105 | </body> | 
|---|
| 106 | </html> | 
|---|