function admin_blog_new() { $message = ""; $this->set("categories", $this->Category->find('list')); if (!empty($this->data)) { $this->Article->create($this->data); $this->Article->validates(); $validationResult = $this->Article->validationErrors; if (empty($validationResult)) { $trackback_urls = trim($this->data['Article']['trackback']); unset($this->data['Article']['trackback']); $this->data['Article']['created'] = date("Y-m-d H:i:s"); $this->data['Article']['type'] = 1; if ($this->Article->save($this->data)) { $message .= "新規記事を保存しました。\n"; } else { $message .= "記事の保存に失敗しました。\n"; } // get information for trackback and ping $blog_name = $this->Setting->getValue('blog.name'); $blog_author = $this->Setting->getValue('blog.author'); $permalink = HOST . $this->base . '/blog/entry/' . $this->data['Article']['url']; $rss_link = HOST . $this->base . '/blog/rss'; // send trackback if (!empty($trackback_urls)) { //load trackback class App::import('Vendor', 'trackback', array('file' => 'trackback.php')); $urls = explode("\n", $trackback_urls); $content = strip_tags($this->data['Article']['content']); $content = mb_substr($content, 0, 100); if (count($urls) > 0) { $trackback = new Trackback($blog_name, $blog_author, Configure::read('App.encoding')); foreach ($urls as $url) { if ($trackback->ping($url, $permalink, $this->data['Article']['title'], $content)) { $message .= "{$url}にトラックバックを送信しました。\n"; } else { $message .= "{$url}にトラックバックは送信できませんでした。\n"; } } } } $pings = explode("\n", $this->Setting->getValue('blog.pings')); if (!empty($pings)) { App::import('Vendor', 'weblog_pinger', array('file' => 'weblog_pinger.php')); App::import('Vendor', 'xmlrpc', array('file' => 'xmlrpc.inc')); foreach ($pings as $url) { if (!empty($url)) { $pinger = new Weblog_Pinger(); $blog_name = urlencode($blog_name); //メジャーな所に送っておく。 $ping_result = $pinger->ping_all(trim($url), $blog_name, $permalink); $this->log("ping result : \n" . var_export($ping_result, true), LOG_DEBUG); $ping_result = $pinger->simplePing(trim($url), $blog_name, $permalink, "", "", $rss_link); $this->log("ping result : \n" . var_export($ping_result, true), LOG_DEBUG); if (!is_array($ping_result)) { $message .= "{$url}にPingを送信しました。<br />\n"; } else { $message .= "{$url}にPing送信に失敗しました。<br />\n"; } } } } $this->Session->write("message", $message); $this->redirect(array('controller' => 'operation', 'action' => 'blog_list')); } } }