Home > PHP

PHP Archive

Zend_XmlRpc_Request_Http で更新pingの受信

  • 2007-11-26 (月)
  • PHP

すごいね。Zend Framework !

下記を記述するだけで、weblogUpdates.ping を受信できちゃう。あとは、データをそれなりに加工してSQL等に保存すればいいのだ。

require_once 'Zend/XmlRpc/Request/Http.php';
$request = new Zend_XmlRpc_Request_Http();

$method = $request->getMethod();
if ($method != "weblogUpdates.ping"
    AND $method != "weblogUpdates.extendedPing") :
    exit();
endif;

$params = array();
$params = $request->getParams();
if (!$params[0] OR !$params[1]) :
    exit();
endif;

require_once 'Zend/Uri.php';
if (!Zend_Uri::check($params[1])) :
    exit();
endif;

$result["method"]    = $method;
$result["title"]         = htmlspecialchars($params[0]);
$result["url"]           = $params[1];
$result["userAgent"] = htmlspecialchars($_SERVER["HTTP_USER_AGENT"]);
$result["params"]     = serialize($params);

$otherUrlArray = array();
foreach ($params as $param) :
    if (Zend_Uri::check($param) AND $param != $result["url"]) :
        $otherUrlArray[] = $param;
    endif;
endforeach;
if (count($otherUrlArray) > 0) :
    $result["otherUrl"] = implode(", ", $otherUrlArray);
else :
    $result["otherUrl"] = null;
endif;

//最後にSQLなどで $result を保存!

browscap の設定

  • 2007-11-18 (日)
  • PHP

browscap は デフォルトで PHP に設定されていないため、自分でインストールする。

# cd /etc/httpd/conf
# wget http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI

# mv stream.asp?PHP_BrowsCapINI browscap.ini
または
# mv php_browscap.ini browscap.ini

# vi /etc/php.ini
[browscap]
browscap = /etc/httpd/conf/browscap.ini ← 追記

# /etc/rc.d/init.d/httpd restart ← 再起動

※使用方法
<?php
$browser = get_browser(null, true); //第2引数 “true” で、配列を返す。

Home > PHP

Links
Search
Feeds

Page Top