[ Index ]
 

Code source de GeekLog 1.4.1

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/public_html/ -> trackback.php (source)

   1  <?php
   2  
   3  /* Reminder: always indent with 4 spaces (no tabs). */
   4  // +---------------------------------------------------------------------------+
   5  // | Geeklog 1.3                                                               |
   6  // +---------------------------------------------------------------------------+
   7  // | trackback.php                                                             |
   8  // |                                                                           |
   9  // | Handle trackback pings for stories and plugins.                           |
  10  // +---------------------------------------------------------------------------+
  11  // | Copyright (C) 2005 by the following authors:                              |
  12  // |                                                                           |
  13  // | Author: Dirk Haun - dirk AT haun-online DOT de                            |
  14  // +---------------------------------------------------------------------------+
  15  // |                                                                           |
  16  // | This program is free software; you can redistribute it and/or             |
  17  // | modify it under the terms of the GNU General Public License               |
  18  // | as published by the Free Software Foundation; either version 2            |
  19  // | of the License, or (at your option) any later version.                    |
  20  // |                                                                           |
  21  // | This program is distributed in the hope that it will be useful,           |
  22  // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  23  // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
  24  // | GNU General Public License for more details.                              |
  25  // |                                                                           |
  26  // | You should have received a copy of the GNU General Public License         |
  27  // | along with this program; if not, write to the Free Software Foundation,   |
  28  // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
  29  // |                                                                           |
  30  // +---------------------------------------------------------------------------+
  31  // 
  32  // $Id: trackback.php,v 1.9 2005/12/17 16:34:28 dhaun Exp $
  33  
  34  require_once  ('lib-common.php');
  35  require_once ($_CONF['path_system'] . 'lib-trackback.php');
  36  
  37  // Note: Error messages are hard-coded in English since there is no way of
  38  // knowing which language the sender of the trackback ping may prefer.
  39  $TRB_ERROR = array (
  40      'not_enabled'       => 'Trackback not enabled.',
  41      'illegal_request'   => 'Illegal request.',
  42      'no_access'         => 'You do not have access to this entry.'
  43  );
  44  
  45  if (!$_CONF['trackback_enabled']) {
  46      TRB_sendTrackbackResponse (1, $TRB_ERROR['not_enabled']);
  47      exit;
  48  }
  49  
  50  if (isset ($_SERVER['REQUEST_METHOD'])) {
  51      // Trackbacks are only allowed as POST requests
  52      if ($_SERVER['REQUEST_METHOD'] != 'POST') {
  53          header ('Allow: POST');
  54          COM_displayMessageAndAbort (75, '', 405, 'Method Not Allowed');
  55      }
  56  }
  57  
  58  COM_setArgNames (array ('id', 'type'));
  59  $id = COM_applyFilter (COM_getArgument ('id'));
  60  $type = COM_applyFilter (COM_getArgument ('type'));
  61  
  62  if (empty ($id)) {
  63      TRB_sendTrackbackResponse (1, $TRB_ERROR['illegal_request']);
  64      exit;
  65  }
  66  
  67  if (empty ($type)) {
  68      $type = 'article';
  69  }
  70  
  71  if ($type == 'article') {
  72      // check if they have access to this story
  73      $sid = addslashes ($id);
  74      $result = DB_query("SELECT trackbackcode FROM {$_TABLES['stories']} WHERE (sid = '$sid') AND (date <= NOW()) AND (draft_flag = 0)" . COM_getPermSql ('AND') . COM_getTopicSql ('AND'));
  75      if (DB_numRows ($result) == 1) {
  76          $A = DB_fetchArray ($result);
  77          if ($A['trackbackcode'] == 0) {
  78              TRB_handleTrackbackPing ($id, $type);
  79          } else {
  80              TRB_sendTrackbackResponse (1, $TRB_ERROR['no_access']);
  81          }
  82      } else {
  83          TRB_sendTrackbackResponse (1, $TRB_ERROR['no_access']);
  84      }
  85  } else if (PLG_handlePingComment ($type, $id, 'acceptByID') === true) {
  86      TRB_handleTrackbackPing ($id, $type);
  87  } else {
  88      TRB_sendTrackbackResponse (1, $TRB_ERROR['no_access']);
  89  }
  90  
  91  // no output here
  92  
  93  ?>


Généré le : Wed Nov 21 12:27:40 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics