protected function authenticateUser($username, $password) { $url = $_REQUEST['blog_url']; if ('http://' != substr($url, 0, 7)) { $url = 'http://' . $url; } if (!preg_match('|http://[a-zA-Z-_]{1,}\\.\\w{1,}|', $url)) { throw new Exception("Invalid URL address `{$url}'."); } $blog_url = parse_url($url); $path = $blog_url['path'] . '/xmlrpc.php'; $blog = new mtclient($username, $password, $blog_url['host'], $path); $blogs = $blog->getUsersBlogs(); if (!is_array($blogs)) { $path = $blog_url['path'] . '/xmlrpc.cgi'; $blog = new mtclient($username, $password, $blog_url['host'], $path); $blogs = $blog->getUsersBlogs(); if (!is_array($blogs)) { $path = $blog_url['path']; $blog = new mtclient($username, $password, $blog_url['host'], $path); $blogs = $blog->getUsersBlogs(); } } if (!is_array($blogs)) { throw new Exception("Could not connect to blog URL `{$url}'."); } $ticket = $this->generateRandomTicket(); $this->storeSessionData($ticket, array($username, $password, $blog_url['host'], $path, $blogs)); return $ticket; }
$path = $config['plugins'][$_REQUEST['p']]['path']; $mt = new mtclient($config['plugins'][$_REQUEST['p']]['username'], $config['plugins'][$_REQUEST['p']]['password'], $host, $path); } // Handle a request to delete an entry before loading the others if (isset($_POST['delete_entry']) && strlen($_POST['delete_entry'])) { $del = $_POST['delete_entry']; $good = $mt->deletePost($del, true); if (!$good) { echo "<script language=\"JavaScript\" type=\"text/javascript\">\n"; echo "<!--\n"; echo "alert('Can\\'t delete that post - you might not have permission to do so.');\n"; echo "// -->\n"; echo "</script>\n"; } } $blogs = $mt->getUsersBlogs(); $entries = $mt->getRecentPosts($blogs[$_REQUEST['b']]['blogid'], 15); // Now list out the entries available if (is_array($entries) && sizeof($entries)) { foreach ($entries as $e => $entry) { $post_id = urlencode(isset($entry['postId']) ? $entry['postId'] : $entry['postid']); $title = $entry['title']; if ($title == '') { preg_match('/^<title>(.*)<\\/title>/sUi', $entry['content'], $title); $title = $title[1]; } $title = preg_replace('/(<[^>]*>)/is', '', $title); $title = htmlspecialchars($title); $title_short = substr($title, 0, 45) . (strlen($title) > 45 ? '...' : ''); if ($title_short == '') { $title_short = 'No Title (Created: ' . $entry['dateCreated'] . ')';