Наследование: extends bloggerclient
Пример #1
0
<title>webpad: blogging browse posts</title>
<link rel="stylesheet" href="../../css/files.css" type="text/css" />
<script language="JavaScript" type="text/javascript" src="../../js/tools.js"></script>
<script language="JavaScript" type="text/javascript" src="../../js/plugins.js"></script>
<script language="JavaScript" type="text/javascript" src="blogging.js"></script>
</head>

<body onkeypress="if (event.keyCode==27) { window.close(); }">
<?php 
echo '<a href="../../locations/browse_plugin.php?t=' . $config['plugins'][$_REQUEST['p']]['type'] . '&p=' . $_REQUEST['p'] . '" title="Back to Blog List"><img src="../../images/files_up.gif" width="19" height="18" alt="" border="0" align="absmiddle" />�Back to Blog List</a>' . "\n";
if ($_REQUEST['t'] == 'livejournal') {
    $mt = new bloggerclient($config['plugins'][$_REQUEST['p']]['username'], $config['plugins'][$_REQUEST['p']]['password'], $livejournal_host, $livejournal_path);
} else {
    $host = $config['plugins'][$_REQUEST['p']]['host'];
    $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);
Пример #2
0
 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;
 }
Пример #3
0
/**
 * @return String
 * @param String $str
 * @param String $username
 * @param String $password
 * @param String $host
 * @param String $path
 * @param String $type
 * @desc Saves the string passed in according to the details in the session.
*/
function mt_save($str, $user, $pass, $host, $path, $type)
{
    global $javascript_msg;
    // Split up the post to get the title and content separately
    $div = strpos($str, "\n");
    $title = trim(substr($str, 0, $div));
    $content = substr($str, $div + 1);
    // Construct the new post and update session details
    $the_post = '<title>' . $title . "</title>\n" . $content;
    $_SESSION['filename'] = $title;
    $_SESSION['display_filename'] = $title;
    // Break down the identifier details into its parts
    if (preg_match('/^\\[[^@]*@[^\\]]*\\]$/Ui', $_SESSION['plugin_identifier'])) {
        $at = strpos($_SESSION['plugin_identifier'], '@');
        $entry_id = urldecode(substr($_SESSION['plugin_identifier'], 1, $at - 1));
        if (trim($entry_id) == '') {
            $entry_id = false;
        }
        $feed_id = urldecode(substr($_SESSION['plugin_identifier'], $at + 1, -1));
    } else {
        // Couldn't figure out where to save to
        $javascript_msg = '@Couldn\'t locate the blog to save this post to.';
        return $_SESSION['filename'];
    }
    if ($type == 'livejournal') {
        $mt = new bloggerclient($user, $pass, $host, $path);
    } else {
        $mt = new mtclient($user, $pass, $host, $path);
    }
    // Updating an existing post (editPost)
    if ($entry_id !== false) {
        if ($type == 'livejournal') {
            $done = $mt->editPost($entry_id, $the_post, true);
        } else {
            $done = $mt->editPost($entry_id, $content, $title, true);
        }
        if ($done) {
            $javascript_msg = 'Entry updated successfully.';
        } else {
            $javascript_msg = '@Couldn\'t update your entry.';
        }
        return $_SESSION['filename'];
    } else {
        if ($type == 'livejournal') {
            $done = $mt->newPost($feed_id, $the_post, true);
        } else {
            $done = $mt->newPost($feed_id, $content, $title, true);
        }
        if ($done) {
            $_SESSION['plugin_identifier'] = '[' . urlencode($done) . '@' . urlencode($feed_id) . ']';
            $javascript_msg = 'New entry posted successfully.';
        } else {
            $javascript_msg = '@Couldn\'t post your entry to your blog.';
        }
        return $_SESSION['filename'];
    }
}