Dotclear

source: inc/public/lib.urlhandlers.php @ 3030:1c346de31ad1

Revision 3030:1c346de31ad1, 17.6 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

Add an blog option to disable internal search (404 on ?q= queries, search widget hidden), fixes #1888

RevLine 
[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 -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14class dcUrlHandlers extends urlHandler
15{
16     public $args;
[2566]17
[772]18     public function getURLFor($type,$value='') {
19          $core =& $GLOBALS['core'];
20          $url = $core->callBehavior("publicGetURLFor",$type,$value);
[775]21          if (!$url) {
[776]22               $url = $this->getBase($type);
23               if ($value) {
[779]24                    if ($url) {
25                         $url .= '/';
26                    }
[776]27                    $url .= $value;
[772]28               }
29          }
30          return $url;
31     }
[2566]32
[772]33     public function register($type,$url,$representation,$handler)
34     {
35          $core =& $GLOBALS['core'];
36          $t = new ArrayObject(array($type,$url,$representation,$handler));
37          $core->callBehavior("publicRegisterURL",$t);
38          parent::register($t[0],$t[1],$t[2],$t[3]);
39     }
[2566]40
[0]41     public static function p404()
42     {
43          throw new Exception ("Page not found",404);
44     }
[2566]45
[0]46     public static function default404($args,$type,$e)
47     {
48          if ($e->getCode() != 404) {
49               throw $e;
50          }
51          $_ctx =& $GLOBALS['_ctx'];
52          $core = $GLOBALS['core'];
[2566]53
[0]54          header('Content-Type: text/html; charset=UTF-8');
55          http::head(404,'Not Found');
56          $core->url->type = '404';
57          $_ctx->current_tpl = '404.html';
58          $_ctx->content_type = 'text/html';
[2566]59
[0]60          echo $core->tpl->getData($_ctx->current_tpl);
[2566]61
[0]62          # --BEHAVIOR-- publicAfterDocument
63          $core->callBehavior('publicAfterDocument',$core);
64          exit;
65     }
[2566]66
[0]67     protected static function getPageNumber(&$args)
68     {
69          if (preg_match('#(^|/)page/([0-9]+)$#',$args,$m)) {
70               $n = (integer) $m[2];
71               if ($n > 0) {
72                    $args = preg_replace('#(^|/)page/([0-9]+)$#','',$args);
73                    return $n;
74               }
75          }
[2566]76
[0]77          return false;
78     }
[2566]79
[0]80     protected static function serveDocument($tpl,$content_type='text/html',$http_cache=true,$http_etag=true)
81     {
82          $_ctx =& $GLOBALS['_ctx'];
83          $core =& $GLOBALS['core'];
[2566]84
[0]85          if ($_ctx->nb_entry_per_page === null) {
86               $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page;
87          }
[2577]88          if ($_ctx->nb_entry_first_page === null) {
89               $_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page;
90          }
[2566]91
[0]92          $tpl_file = $core->tpl->getFilePath($tpl);
[2566]93
[0]94          if (!$tpl_file) {
95               throw new Exception('Unable to find template ');
96          }
[2566]97
[0]98          $result = new ArrayObject;
[2566]99
[0]100          $_ctx->current_tpl = $tpl;
101          $_ctx->content_type = $content_type;
102          $_ctx->http_cache = $http_cache;
103          $_ctx->http_etag = $http_etag;
104          $core->callBehavior('urlHandlerBeforeGetData',$_ctx);
[2566]105
[0]106          if ($_ctx->http_cache) {
107               $GLOBALS['mod_files'][] = $tpl_file;
108               http::cache($GLOBALS['mod_files'],$GLOBALS['mod_ts']);
109          }
110
111          header('Content-Type: '.$_ctx->content_type.'; charset=UTF-8');
[2919]112          if ($core->blog->settings->system->prevents_clickjacking) {
113               if ($_ctx->exists('xframeoption')) {
114                    $url = parse_url($_ctx->xframeoption);
115                    header(sprintf('X-Frame-Options: %s', is_array($url)?("ALLOW-FROM ".$url['scheme'].'://'.$url['host']):'SAMEORIGIN'));
116               } else {
117                    // Prevents Clickjacking as far as possible
118                    header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
119               }
[2797]120          }
121
[0]122          $result['content'] = $core->tpl->getData($_ctx->current_tpl);
123          $result['content_type'] = $_ctx->content_type;
124          $result['tpl'] = $_ctx->current_tpl;
125          $result['blogupddt'] = $core->blog->upddt;
[2566]126
[0]127          # --BEHAVIOR-- urlHandlerServeDocument
128          $core->callBehavior('urlHandlerServeDocument',$result);
[2566]129
[0]130          if ($_ctx->http_cache && $_ctx->http_etag) {
131               http::etag($result['content'],http::getSelfURI());
132          }
133          echo $result['content'];
134     }
[2566]135
[0]136     public function getDocument()
137     {
138          $core =& $GLOBALS['core'];
[2566]139
[0]140          $type = $args = '';
[2566]141
[0]142          if ($this->mode == 'path_info')
143          {
144               $part = substr($_SERVER['PATH_INFO'],1);
145          }
146          else
147          {
148               $part = '';
[2566]149
[0]150               $qs = $this->parseQueryString();
[2566]151
[0]152               # Recreates some _GET and _REQUEST pairs
153               if (!empty($qs))
154               {
155                    foreach ($_GET as $k => $v) {
156                         if (isset($_REQUEST[$k])) {
157                              unset($_REQUEST[$k]);
158                         }
159                    }
160                    $_GET = $qs;
161                    $_REQUEST = array_merge($qs,$_REQUEST);
[2566]162
[0]163                    list($k,$v) = each($qs);
164                    if ($v === null) {
165                         $part = $k;
166                         unset($_GET[$k]);
167                         unset($_REQUEST[$k]);
168                    }
169               }
170          }
[2566]171
[0]172          $_SERVER['URL_REQUEST_PART'] = $part;
[2566]173
[0]174          $this->getArgs($part,$type,$this->args);
[2566]175
[0]176          # --BEHAVIOR-- urlHandlerGetArgsDocument
177          $core->callBehavior('urlHandlerGetArgsDocument',$this);
[2566]178
[0]179          if (!$type)
180          {
181               $this->type = 'default';
182               $this->callDefaultHandler($this->args);
183          }
184          else
185          {
186               $this->type = $type;
187               $this->callHandler($type,$this->args);
188          }
189     }
[2566]190
[0]191     public static function home($args)
192     {
193          $n = self::getPageNumber($args);
[2566]194
[0]195          if ($args && !$n)
196          {
[2566]197               # "Then specified URL went unrecognized by all URL handlers and
[0]198               # defaults to the home page, but is not a page number.
199               self::p404();
200          }
201          else
202          {
[2577]203               $_ctx =& $GLOBALS['_ctx'];
[0]204               $core =& $GLOBALS['core'];
[2566]205
[0]206               if ($n) {
207                    $GLOBALS['_page_number'] = $n;
208                    $core->url->type = $n > 1 ? 'default-page' : 'default';
209               }
[2566]210
[0]211               if (empty($_GET['q'])) {
[2577]212                    if ($core->blog->settings->system->nb_post_for_home !== null) {
213                         $_ctx->nb_entry_first_page = $core->blog->settings->system->nb_post_for_home;
214                    }
[0]215                    self::serveDocument('home.html');
216                    $core->blog->publishScheduledEntries();
217               } else {
218                    self::search();
219               }
220          }
221     }
[2566]222
[0]223     public static function search()
224     {
225          $_ctx =& $GLOBALS['_ctx'];
226          $core =& $GLOBALS['core'];
[2566]227
[3030]228          if ($core->blog->settings->system->no_search) {
[2566]229
[3030]230               # Search is disabled for this blog.
231               self::p404();
232
233          } else {
234
235               $core->url->type='search';
236
237               $GLOBALS['_search'] = !empty($_GET['q']) ? rawurldecode($_GET['q']) : '';
238               if ($GLOBALS['_search']) {
239                    $params = new ArrayObject(array('search' => $GLOBALS['_search']));
240                    $core->callBehavior('publicBeforeSearchCount',$params);
241                    $GLOBALS['_search_count'] = $core->blog->getPosts($params,true)->f(0);
242               }
243
244               self::serveDocument('search.html');
[0]245          }
246     }
[2566]247
[0]248     public static function lang($args)
249     {
250          $_ctx =& $GLOBALS['_ctx'];
251          $core =& $GLOBALS['core'];
[2566]252
[0]253          $n = self::getPageNumber($args);
[306]254          $params = new ArrayObject(array(
255               'lang' => $args));
[2566]256
[306]257          $core->callBehavior('publicLangBeforeGetLangs',$params,$args);
[2566]258
[0]259          $_ctx->langs = $core->blog->getLangs($params);
[2566]260
[0]261          if ($_ctx->langs->isEmpty()) {
262               # The specified language does not exist.
263               self::p404();
264          }
265          else
266          {
267               if ($n) {
268                    $GLOBALS['_page_number'] = $n;
269               }
270               $_ctx->cur_lang = $args;
271               self::home(null);
272          }
273     }
[2566]274
[0]275     public static function category($args)
276     {
277          $_ctx =& $GLOBALS['_ctx'];
278          $core =& $GLOBALS['core'];
[2566]279
[0]280          $n = self::getPageNumber($args);
[2566]281
[0]282          if ($args == '' && !$n) {
283               # No category was specified.
284               self::p404();
285          }
286          else
287          {
[306]288               $params = new ArrayObject(array(
289                    'cat_url' => $args,
[1610]290                    'post_type' => 'post',
291                    'without_empty' => false));
[2566]292
[306]293               $core->callBehavior('publicCategoryBeforeGetCategories',$params,$args);
[2566]294
[0]295               $_ctx->categories = $core->blog->getCategories($params);
[2566]296
[0]297               if ($_ctx->categories->isEmpty()) {
298                    # The specified category does no exist.
299                    self::p404();
300               }
301               else
302               {
303                    if ($n) {
304                         $GLOBALS['_page_number'] = $n;
305                    }
306                    self::serveDocument('category.html');
307               }
308          }
309     }
[2566]310
[0]311     public static function archive($args)
312     {
313          $_ctx =& $GLOBALS['_ctx'];
314          $core =& $GLOBALS['core'];
[2566]315
[0]316          $year = $month = $cat_url = null;
317          # Nothing or year and month
318          if ($args == '')
319          {
320               self::serveDocument('archive.html');
321          }
322          elseif (preg_match('|^/([0-9]{4})/([0-9]{2})$|',$args,$m))
323          {
[306]324               $params = new ArrayObject(array(
325                    'year' => $m[1],
326                    'month' => $m[2],
327                    'type' => 'month'));
[2566]328
[306]329               $core->callBehavior('publicArchiveBeforeGetDates',$params,$args);
[2566]330
[0]331               $_ctx->archives = $core->blog->getDates($params);
[2566]332
[0]333               if ($_ctx->archives->isEmpty()) {
334                    # There is no entries for the specified period.
335                    self::p404();
336               }
337               else
338               {
339                    self::serveDocument('archive_month.html');
340               }
341          }
342          else {
343               # The specified URL is not a date.
344               self::p404();
345          }
346     }
[2566]347
[0]348     public static function post($args)
349     {
350          if ($args == '') {
351               # No entry was specified.
352               self::p404();
353          }
354          else
355          {
356               $_ctx =& $GLOBALS['_ctx'];
357               $core =& $GLOBALS['core'];
[2566]358
[0]359               $core->blog->withoutPassword(false);
[2566]360
[306]361               $params = new ArrayObject(array(
362                    'post_url' => $args));
[2566]363
[306]364               $core->callBehavior('publicPostBeforeGetPosts',$params,$args);
365
[0]366               $_ctx->posts = $core->blog->getPosts($params);
[2566]367
[0]368               $_ctx->comment_preview = new ArrayObject();
369               $_ctx->comment_preview['content'] = '';
370               $_ctx->comment_preview['rawcontent'] = '';
371               $_ctx->comment_preview['name'] = '';
372               $_ctx->comment_preview['mail'] = '';
373               $_ctx->comment_preview['site'] = '';
374               $_ctx->comment_preview['preview'] = false;
375               $_ctx->comment_preview['remember'] = false;
[2566]376
[0]377               $core->blog->withoutPassword(true);
[2566]378
[0]379               if ($_ctx->posts->isEmpty())
380               {
381                    # The specified entry does not exist.
382                    self::p404();
383               }
384               else
385               {
386                    $post_id = $_ctx->posts->post_id;
387                    $post_password = $_ctx->posts->post_password;
[2566]388
[0]389                    # Password protected entry
390                    if ($post_password != '' && !$_ctx->preview)
391                    {
392                         # Get passwords cookie
393                         if (isset($_COOKIE['dc_passwd'])) {
[2634]394                              $pwd_cookie = json_decode($_COOKIE['dc_passwd']);
395                              if ($pwd_cookie === NULL) {
396                                   $pwd_cookie = array();
397                              } else {
398                                   $pwd_cookie = (array) $pwd_cookie;
399                              }
[0]400                         } else {
401                              $pwd_cookie = array();
402                         }
[2566]403
[0]404                         # Check for match
[2770]405                         # Note: We must prefix post_id key with '#'' in pwd_cookie array in order to avoid integer conversion
406                         # because MyArray["12345"] is treated as MyArray[12345]
[0]407                         if ((!empty($_POST['password']) && $_POST['password'] == $post_password)
[2770]408                         || (isset($pwd_cookie['#'.$post_id]) && $pwd_cookie['#'.$post_id] == $post_password))
[0]409                         {
[2770]410                              $pwd_cookie['#'.$post_id] = $post_password;
[2634]411                              setcookie('dc_passwd',json_encode($pwd_cookie),0,'/');
[0]412                         }
413                         else
414                         {
415                              self::serveDocument('password-form.html','text/html',false);
416                              return;
417                         }
418                    }
[2566]419
[0]420                    $post_comment =
421                         isset($_POST['c_name']) && isset($_POST['c_mail']) &&
422                         isset($_POST['c_site']) && isset($_POST['c_content']) &&
423                         $_ctx->posts->commentsActive();
[2566]424
[0]425                    # Posting a comment
426                    if ($post_comment)
427                    {
428                         # Spam trap
429                         if (!empty($_POST['f_mail'])) {
430                              http::head(412,'Precondition Failed');
431                              header('Content-Type: text/plain');
432                              echo "So Long, and Thanks For All the Fish";
433                              # Exits immediately the application to preserve the server.
434                              exit;
435                         }
[2566]436
[0]437                         $name = $_POST['c_name'];
438                         $mail = $_POST['c_mail'];
439                         $site = $_POST['c_site'];
440                         $content = $_POST['c_content'];
441                         $preview = !empty($_POST['preview']);
[2566]442
[0]443                         if ($content != '')
444                         {
[2585]445                              # --BEHAVIOR-- publicBeforeCommentTransform
446                              $buffer = $core->callBehavior('publicBeforeCommentTransform',$content);
447                              if ($buffer != '') {
448                                   $content = $buffer;
[0]449                              } else {
[2585]450                                   if ($core->blog->settings->system->wiki_comments) {
451                                        $core->initWikiComment();
452                                   } else {
453                                        $core->initWikiSimpleComment();
454                                   }
455                                   $content = $core->wikiTransform($content);
[0]456                              }
457                              $content = $core->HTMLfilter($content);
458                         }
[2566]459
[0]460                         $_ctx->comment_preview['content'] = $content;
461                         $_ctx->comment_preview['rawcontent'] = $_POST['c_content'];
462                         $_ctx->comment_preview['name'] = $name;
463                         $_ctx->comment_preview['mail'] = $mail;
464                         $_ctx->comment_preview['site'] = $site;
[2566]465
[0]466                         if ($preview)
467                         {
468                              # --BEHAVIOR-- publicBeforeCommentPreview
469                              $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview);
[2566]470
[0]471                              $_ctx->comment_preview['preview'] = true;
472                         }
473                         else
474                         {
475                              # Post the comment
476                              $cur = $core->con->openCursor($core->prefix.'comment');
477                              $cur->comment_author = $name;
478                              $cur->comment_site = html::clean($site);
479                              $cur->comment_email = html::clean($mail);
480                              $cur->comment_content = $content;
481                              $cur->post_id = $_ctx->posts->post_id;
482                              $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1;
483                              $cur->comment_ip = http::realIP();
[2566]484
[0]485                              $redir = $_ctx->posts->getURL();
[303]486                              $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?';
[2566]487
[0]488                              try
489                              {
490                                   if (!text::isEmail($cur->comment_email)) {
491                                        throw new Exception(__('You must provide a valid email address.'));
492                                   }
[2566]493
[0]494                                   # --BEHAVIOR-- publicBeforeCommentCreate
495                                   $core->callBehavior('publicBeforeCommentCreate',$cur);
[2566]496                                   if ($cur->post_id) {
[0]497                                        $comment_id = $core->blog->addComment($cur);
[2566]498
[0]499                                        # --BEHAVIOR-- publicAfterCommentCreate
500                                        $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id);
501                                   }
[2566]502
[0]503                                   if ($cur->comment_status == 1) {
504                                        $redir_arg = 'pub=1';
505                                   } else {
506                                        $redir_arg = 'pub=0';
507                                   }
[2566]508
[0]509                                   header('Location: '.$redir.$redir_arg);
510                              }
511                              catch (Exception $e)
512                              {
513                                   $_ctx->form_error = $e->getMessage();
514                                   $_ctx->form_error;
515                              }
516                         }
517                    }
[2566]518
[0]519                    # The entry
[1674]520                    if ($_ctx->posts->trackbacksActive()) {
521                         header('X-Pingback: '.$core->blog->url.$core->url->getURLFor("xmlrpc",$core->blog->id));
522                    }
[0]523                    self::serveDocument('post.html');
524               }
525          }
526     }
[2566]527
[0]528     public static function preview($args)
529     {
530          $core = $GLOBALS['core'];
531          $_ctx = $GLOBALS['_ctx'];
[2566]532
[0]533          if (!preg_match('#^(.+?)/([0-9a-z]{40})/(.+?)$#',$args,$m)) {
534               # The specified Preview URL is malformed.
535               self::p404();
536          }
537          else
538          {
539               $user_id = $m[1];
540               $user_key = $m[2];
541               $post_url = $m[3];
542               if (!$core->auth->checkUser($user_id,null,$user_key)) {
543                    # The user has no access to the entry.
544                    self::p404();
545               }
546               else
547               {
548                    $_ctx->preview = true;
[2915]549                    if (defined ("DC_ADMIN_URL")) {
550                         $_ctx->xframeoption=DC_ADMIN_URL;
551                    }
[0]552                    self::post($post_url);
553               }
554          }
555     }
[2566]556
[0]557     public static function feed($args)
558     {
559          $type = null;
560          $comments = false;
561          $cat_url = false;
562          $post_id = null;
563          $subtitle = '';
[2566]564
[0]565          $mime = 'application/xml';
[2566]566
[0]567          $_ctx =& $GLOBALS['_ctx'];
568          $core =& $GLOBALS['core'];
[2566]569
[0]570          if (preg_match('!^([a-z]{2}(-[a-z]{2})?)/(.*)$!',$args,$m)) {
[306]571               $params = new ArrayObject(array('lang' => $m[1]));
[2566]572
[0]573               $args = $m[3];
[2566]574
[306]575               $core->callBehavior('publicFeedBeforeGetLangs',$params,$args);
[2566]576
[0]577               $_ctx->langs = $core->blog->getLangs($params);
[2566]578
[0]579               if ($_ctx->langs->isEmpty()) {
580                    # The specified language does not exist.
581                    self::p404();
582                    return;
583               } else {
584                    $_ctx->cur_lang = $m[1];
585               }
586          }
[2566]587
[0]588          if (preg_match('#^rss2/xslt$#',$args,$m))
589          {
590               # RSS XSLT stylesheet
591               self::serveDocument('rss2.xsl','text/xml');
592               return;
593          }
594          elseif (preg_match('#^(atom|rss2)/comments/([0-9]+)$#',$args,$m))
595          {
596               # Post comments feed
597               $type = $m[1];
598               $comments = true;
599               $post_id = (integer) $m[2];
600          }
601          elseif (preg_match('#^(?:category/(.+)/)?(atom|rss2)(/comments)?$#',$args,$m))
602          {
603               # All posts or comments feed
604               $type = $m[2];
605               $comments = !empty($m[3]);
606               if (!empty($m[1])) {
607                    $cat_url = $m[1];
608               }
609          }
610          else
611          {
612               # The specified Feed URL is malformed.
613               self::p404();
614               return;
615          }
[2566]616
[0]617          if ($cat_url)
618          {
[306]619               $params = new ArrayObject(array(
620                    'cat_url' => $cat_url,
621                    'post_type' => 'post'));
[2566]622
[306]623               $core->callBehavior('publicFeedBeforeGetCategories',$params,$args);
[2566]624
[0]625               $_ctx->categories = $core->blog->getCategories($params);
[2566]626
[0]627               if ($_ctx->categories->isEmpty()) {
628                    # The specified category does no exist.
629                    self::p404();
630                    return;
631               }
[2566]632
[0]633               $subtitle = ' - '.$_ctx->categories->cat_title;
634          }
635          elseif ($post_id)
636          {
[306]637               $params = new ArrayObject(array(
638                    'post_id' => $post_id,
639                    'post_type' => ''));
[2566]640
[306]641               $core->callBehavior('publicFeedBeforeGetPosts',$params,$args);
[2566]642
[0]643               $_ctx->posts = $core->blog->getPosts($params);
[2566]644
[0]645               if ($_ctx->posts->isEmpty()) {
646                    # The specified post does not exist.
647                    self::p404();
648                    return;
649               }
[2566]650
[0]651               $subtitle = ' - '.$_ctx->posts->post_title;
652          }
[2566]653
[0]654          $tpl = $type;
655          if ($comments) {
656               $tpl .= '-comments';
657               $_ctx->nb_comment_per_page = $core->blog->settings->system->nb_comment_per_feed;
658          } else {
659               $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_feed;
660               $_ctx->short_feed_items = $core->blog->settings->system->short_feed_items;
661          }
662          $tpl .= '.xml';
[2566]663
[0]664          if ($type == 'atom') {
665               $mime = 'application/atom+xml';
666          }
[2566]667
[0]668          $_ctx->feed_subtitle = $subtitle;
[2566]669
[0]670          header('X-Robots-Tag: '.context::robotsPolicy($core->blog->settings->system->robots_policy,''));
671          self::serveDocument($tpl,$mime);
672          if (!$comments && !$cat_url) {
673               $core->blog->publishScheduledEntries();
674          }
675     }
[2566]676
[0]677     public static function trackback($args)
678     {
679          if (!preg_match('/^[0-9]+$/',$args)) {
680               # The specified trackback URL is not an number
681               self::p404();
682          } else {
683               $tb = new dcTrackback($GLOBALS['core']);
684               $tb->receive($args);
685          }
686     }
[2566]687
[0]688     public static function rsd($args)
689     {
690          $core =& $GLOBALS['core'];
691          http::cache($GLOBALS['mod_files'],$GLOBALS['mod_ts']);
[2566]692
[0]693          header('Content-Type: text/xml; charset=UTF-8');
694          echo
695          '<?xml version="1.0" encoding="UTF-8"?>'."\n".
696          '<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">'."\n".
697          "<service>\n".
698          "  <engineName>Dotclear</engineName>\n".
699          "  <engineLink>http://www.dotclear.org/</engineLink>\n".
700          '  <homePageLink>'.html::escapeHTML($core->blog->url)."</homePageLink>\n";
[2566]701
[0]702          if ($core->blog->settings->system->enable_xmlrpc)
703          {
704               $u = sprintf(DC_XMLRPC_URL,$core->blog->url,$core->blog->id);
[2566]705
[0]706               echo
707               "  <apis>\n".
708               '    <api name="WordPress" blogID="1" preferred="true" apiLink="'.$u.'"/>'."\n".
709               '    <api name="Movable Type" blogID="1" preferred="false" apiLink="'.$u.'"/>'."\n".
710               '    <api name="MetaWeblog" blogID="1" preferred="false" apiLink="'.$u.'"/>'."\n".
711               '    <api name="Blogger" blogID="1" preferred="false" apiLink="'.$u.'"/>'."\n".
712               "  </apis>\n";
713          }
[2566]714
[0]715          echo
716          "</service>\n".
717          "</rsd>\n";
718     }
[2566]719
[0]720     public static function xmlrpc($args)
721     {
722          $core =& $GLOBALS['core'];
723          $blog_id = preg_replace('#^([^/]*).*#','$1',$args);
724          $server = new dcXmlRpc($core,$blog_id);
725          $server->serve();
726     }
727}
Note: See TracBrowser for help on using the repository browser.

Sites map