| 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_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; | 
|---|
| 20 |            | 
|---|
| 21 |           $rsp = $o->query('weblogUpdates.ping',$site_name,$site_url); | 
|---|
| 22 |            | 
|---|
| 23 |           if (isset($rsp['flerror']) && $rsp['flerror']) { | 
|---|
| 24 |                throw new Exception($rsp['message']); | 
|---|
| 25 |           } | 
|---|
| 26 |            | 
|---|
| 27 |           return true; | 
|---|
| 28 |      } | 
|---|
| 29 | } | 
|---|
| 30 |  | 
|---|
| 31 | class pingsBehaviors | 
|---|
| 32 | { | 
|---|
| 33 |      public static function pingJS() | 
|---|
| 34 |      { | 
|---|
| 35 |           $res = | 
|---|
| 36 |           "<script type=\"text/javascript\">\n//<![CDATA[\n". | 
|---|
| 37 |           dcPage::jsVar('dotclear.msg.check_all',__('Check all'))."\n". | 
|---|
| 38 |           "</script>\n".dcPage::jsLoad('index.php?pf=pings/post.js'); | 
|---|
| 39 |            | 
|---|
| 40 |           return $res; | 
|---|
| 41 |      } | 
|---|
| 42 |       | 
|---|
| 43 |      public static function pingsForm($post) | 
|---|
| 44 |      { | 
|---|
| 45 |           $core =& $GLOBALS['core']; | 
|---|
| 46 |           if (!$core->blog->settings->pings->pings_active) { | 
|---|
| 47 |                return; | 
|---|
| 48 |           } | 
|---|
| 49 |            | 
|---|
| 50 |           $pings_uris = @unserialize($core->blog->settings->pings->pings_uris); | 
|---|
| 51 |           if (empty($pings_uris) || !is_array($pings_uris)) { | 
|---|
| 52 |                return; | 
|---|
| 53 |           } | 
|---|
| 54 |            | 
|---|
| 55 |           if (!empty($_POST['pings_do']) && is_array($_POST['pings_do'])) { | 
|---|
| 56 |                $pings_do = $_POST['pings_do']; | 
|---|
| 57 |           } else { | 
|---|
| 58 |                $pings_do = array(); | 
|---|
| 59 |           } | 
|---|
| 60 |            | 
|---|
| 61 |           echo '<h3 class="ping-services">'.__('Pings:').'</h3>'; | 
|---|
| 62 |           foreach ($pings_uris as $k => $v) | 
|---|
| 63 |           { | 
|---|
| 64 |                echo | 
|---|
| 65 |                '<p class="ping-services"><label for="pings_do" class="classic">'. | 
|---|
| 66 |                form::checkbox(array('pings_do[]','pings_do'),html::escapeHTML($v),in_array($v,$pings_do)).' '. | 
|---|
| 67 |                html::escapeHTML($k).'</label></p>'; | 
|---|
| 68 |           } | 
|---|
| 69 |      } | 
|---|
| 70 |       | 
|---|
| 71 |      public static function doPings($cur,$post_id) | 
|---|
| 72 |      { | 
|---|
| 73 |           if (empty($_POST['pings_do']) || !is_array($_POST['pings_do'])) { | 
|---|
| 74 |                return; | 
|---|
| 75 |           } | 
|---|
| 76 |            | 
|---|
| 77 |           $core =& $GLOBALS['core']; | 
|---|
| 78 |           if (!$core->blog->settings->pings->pings_active) { | 
|---|
| 79 |                return; | 
|---|
| 80 |           } | 
|---|
| 81 |            | 
|---|
| 82 |           $pings_uris = @unserialize($core->blog->settings->pings->pings_uris); | 
|---|
| 83 |           if (empty($pings_uris) || !is_array($pings_uris)) { | 
|---|
| 84 |                return; | 
|---|
| 85 |           } | 
|---|
| 86 |            | 
|---|
| 87 |           foreach ($_POST['pings_do'] as $uri) | 
|---|
| 88 |           { | 
|---|
| 89 |                if (in_array($uri,$pings_uris)) { | 
|---|
| 90 |                     try { | 
|---|
| 91 |                          pingsAPI::doPings($uri,$core->blog->name,$core->blog->url); | 
|---|
| 92 |                     } catch (Exception $e) {} | 
|---|
| 93 |                } | 
|---|
| 94 |           } | 
|---|
| 95 |      } | 
|---|
| 96 | } | 
|---|
| 97 | ?> | 
|---|