3 * Simply stores all pingbacks in the database.
5 require_once __DIR__ . '/../data/config.php';
6 require_once 'stapibas/autoloader.php';
8 $db = new PDO($dbdsn, $dbuser, $dbpass);
11 implements \PEAR2\Services\Pingback\Server\Callback\IStorage,
12 \PEAR2\Services\Pingback\Server\Callback\ILink
14 public function __construct(PDO $db)
19 public function storePingback(
20 $target, $source, $sourceBody, \HTTP_Request2_Response $res
22 $stmt = $this->db->prepare(
23 'INSERT INTO pingbacks'
24 . ' (p_source, p_target, p_time, p_client_ip, p_client_agent, p_client_referer)'
25 . ' VALUES(:source, :target, NOW(), :ip, :agent, :referer)'
31 ':ip' => isset($_SERVER['REMOTE_ADDR'])
32 ? $_SERVER['REMOTE_ADDR'] : '',
33 ':agent' => isset($_SERVER['HTTP_USER_AGENT'])
34 ? $_SERVER['HTTP_USER_AGENT'] : '',
35 ':referer' => isset($_SERVER['HTTP_REFERER'])
36 ? $_SERVER['HTTP_REFERER'] : '',
42 * Verifies that a link from $source to $target exists.
44 * @param string $target Target URI that should be linked in $source
45 * @param string $source Pingback source URI that should link to target
46 * @param string $sourceBody Content of $source URI
47 * @param object $res HTTP response from fetching $source
49 * @return boolean True if $source links to $target
51 * @throws Exception When something fatally fails
53 public function verifyLinkExists(
54 $target, $source, $sourceBody, \HTTP_Request2_Response $res
61 implements \PEAR2\Services\Pingback\Server\Callback\IStorage
63 public function storePingback(
64 $target, $source, $sourceBody, \HTTP_Request2_Response $res
69 "A pingback just came in, for\n"
70 . '> ' . $target . "\n"
72 . '> ' . $source . "\n"
73 . "\n\nLove, stapibas",
74 "From: stapibas <server@cweiske.de>"
79 $s = new \PEAR2\Services\Pingback\Server();
80 $s->addCallback(new PingbackStorage($db));
81 $s->addCallback(new PingbackMailer());