[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_RC_PATH')) { return; } |
---|
| 13 | |
---|
| 14 | class pingsAPI extends xmlrpcClient |
---|
| 15 | { |
---|
| 16 | public static function doPings($srv_uri,$site_name,$site_url) |
---|
| 17 | { |
---|
| 18 | $o = new self($srv_uri); |
---|
| 19 | $o->timeout = 3; |
---|
[2566] | 20 | |
---|
[0] | 21 | $rsp = $o->query('weblogUpdates.ping',$site_name,$site_url); |
---|
[2566] | 22 | |
---|
[0] | 23 | if (isset($rsp['flerror']) && $rsp['flerror']) { |
---|
| 24 | throw new Exception($rsp['message']); |
---|
| 25 | } |
---|
[2566] | 26 | |
---|
[0] | 27 | return true; |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | class pingsBehaviors |
---|
| 32 | { |
---|
| 33 | public static function pingJS() |
---|
| 34 | { |
---|
[2825] | 35 | global $core; |
---|
| 36 | |
---|
[0] | 37 | $res = |
---|
| 38 | "<script type=\"text/javascript\">\n//<![CDATA[\n". |
---|
| 39 | dcPage::jsVar('dotclear.msg.check_all',__('Check all'))."\n". |
---|
[2825] | 40 | "</script>\n".dcPage::jsLoad($core->adminurl->decode('load.plugin.file',array('pf' => 'pings/post.js'))); |
---|
[2566] | 41 | |
---|
[0] | 42 | return $res; |
---|
| 43 | } |
---|
[2566] | 44 | |
---|
[1398] | 45 | public static function pingsFormItems($main,$sidebar,$post) |
---|
[0] | 46 | { |
---|
| 47 | $core =& $GLOBALS['core']; |
---|
| 48 | if (!$core->blog->settings->pings->pings_active) { |
---|
| 49 | return; |
---|
| 50 | } |
---|
[2566] | 51 | |
---|
[0] | 52 | $pings_uris = @unserialize($core->blog->settings->pings->pings_uris); |
---|
| 53 | if (empty($pings_uris) || !is_array($pings_uris)) { |
---|
| 54 | return; |
---|
| 55 | } |
---|
[2566] | 56 | |
---|
[0] | 57 | if (!empty($_POST['pings_do']) && is_array($_POST['pings_do'])) { |
---|
| 58 | $pings_do = $_POST['pings_do']; |
---|
| 59 | } else { |
---|
| 60 | $pings_do = array(); |
---|
| 61 | } |
---|
[2566] | 62 | |
---|
[1396] | 63 | $item = '<h5 class="ping-services">'.__('Pings').'</h5>'; |
---|
[120] | 64 | $i = 0; |
---|
[0] | 65 | foreach ($pings_uris as $k => $v) |
---|
| 66 | { |
---|
[1392] | 67 | $item .= |
---|
[120] | 68 | '<p class="ping-services"><label for="pings_do-'.$i.'" class="classic">'. |
---|
[1818] | 69 | form::checkbox(array('pings_do[]','pings_do-'.$i),html::escapeHTML($v),in_array($v,$pings_do), 'check-ping-services').' '. |
---|
[0] | 70 | html::escapeHTML($k).'</label></p>'; |
---|
[120] | 71 | $i++; |
---|
[0] | 72 | } |
---|
[1398] | 73 | $sidebar['options-box']['items']['pings']=$item; |
---|
[2566] | 74 | |
---|
[0] | 75 | } |
---|
[2566] | 76 | |
---|
[0] | 77 | public static function doPings($cur,$post_id) |
---|
| 78 | { |
---|
| 79 | if (empty($_POST['pings_do']) || !is_array($_POST['pings_do'])) { |
---|
| 80 | return; |
---|
| 81 | } |
---|
[2566] | 82 | |
---|
[0] | 83 | $core =& $GLOBALS['core']; |
---|
| 84 | if (!$core->blog->settings->pings->pings_active) { |
---|
| 85 | return; |
---|
| 86 | } |
---|
[2566] | 87 | |
---|
[0] | 88 | $pings_uris = @unserialize($core->blog->settings->pings->pings_uris); |
---|
| 89 | if (empty($pings_uris) || !is_array($pings_uris)) { |
---|
| 90 | return; |
---|
| 91 | } |
---|
[2566] | 92 | |
---|
[0] | 93 | foreach ($_POST['pings_do'] as $uri) |
---|
| 94 | { |
---|
| 95 | if (in_array($uri,$pings_uris)) { |
---|
| 96 | try { |
---|
| 97 | pingsAPI::doPings($uri,$core->blog->name,$core->blog->url); |
---|
| 98 | } catch (Exception $e) {} |
---|
| 99 | } |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | } |
---|