当前位置: 首页>>代码示例>>PHP>>正文


PHP logIO函数代码示例

本文整理汇总了PHP中logIO函数的典型用法代码示例。如果您正苦于以下问题:PHP logIO函数的具体用法?PHP logIO怎么用?PHP logIO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了logIO函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: serialize

 function serialize()
 {
     $this->createPayload();
     logIO("O", $this->payload);
     return $this->payload;
 }
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:6,代码来源:class-xmlrpc.php

示例2: getImages

 /**
  * Method "ngg.getImages"
  * Return the list of all images inside a gallery
  * 
  * @since 1.4
  * 
  * @param array $args Method parameters.
  * 			- int blog_id
  *	    	- string username
  *	    	- string password
  *	    	- int gallery_id 
  * @return array with all images
  */
 function getImages($args)
 {
     global $nggdb;
     require_once dirname(dirname(__FILE__)) . '/admin/functions.php';
     // admin functions
     $this->escape($args);
     $blog_ID = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $gid = (int) $args[3];
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     // Look for the gallery , could we find it ?
     if (!($gallery = nggdb::find_gallery($gid))) {
         return new IXR_Error(404, __('Could not find gallery ' . $gid));
     }
     // Now check if you have the correct capability for this gallery
     if (!nggAdmin::can_manage_this_gallery($gallery->author)) {
         logIO('O', '(NGG) User does not have upload_files capability');
         $this->error = new IXR_Error(401, __('You are not allowed to upload files to this gallery.'));
         return $this->error;
     }
     // get picture values
     $picture_list = $nggdb->get_gallery($gid, 'pid', 'ASC', false);
     return $picture_list;
 }
开发者ID:rtgibbons,项目名称:bya.org,代码行数:40,代码来源:xmlrpc.php

示例3: blogger_getrecentposts

/**
 * blogger.getRecentPosts retieves X most recent posts.
 *
 * This API call is not documented on
 * {@link http://www.blogger.com/developers/api/1_docs/}
 * @see http://www.sixapart.com/developers/xmlrpc/blogger_api/bloggergetrecentposts.html
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 appkey (string): Unique identifier/passcode of the application sending the post.
 *						(See access info {@link http://www.blogger.com/developers/api/1_docs/#access} .)
 *					1 blogid (string): Unique identifier of the blog the post will be added to.
 *						Currently ignored in b2evo, in favor of the category.
 *					2 username (string): Login for a Blogger user who has permission to edit the given
 *						post (either the user who originally created it or an admin of the blog).
 *					3 password (string): Password for said username.
 *					4 numposts (integer): number of posts to retrieve.
 * @return xmlrpcresp XML-RPC Response
 */
function blogger_getrecentposts($m)
{
    global $xmlrpcerruser, $DB;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 2, 3))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET BLOG:
    /**
     * @var Blog
     */
    if (!($Blog =& xmlrpcs_get_Blog($m, 1))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    $numposts = $m->getParam(4);
    $numposts = $numposts->scalarval();
    // Get the posts to display:
    load_class('items/model/_itemlist.class.php', 'ItemList');
    $MainList = new ItemList2($Blog, NULL, NULL, $numposts);
    // Protected and private get checked by statuses_where_clause().
    $statuses = array('published', 'redirected', 'protected', 'private');
    if ($current_User->check_perm('blog_ismember', 'view', false, $Blog->ID)) {
        // These statuses require member status:
        $statuses = array_merge($statuses, array('draft', 'deprecated'));
    }
    logIO('Statuses: ' . implode(', ', $statuses));
    $MainList->set_filters(array('visibility_array' => $statuses, 'order' => 'DESC', 'unit' => 'posts'));
    // Run the query:
    $MainList->query();
    logIO('Items:' . $MainList->result_num_rows);
    $data = array();
    while ($Item =& $MainList->get_item()) {
        logIO('Item:' . $Item->title . ' - Issued: ' . $Item->issue_date . ' - Modified: ' . $Item->datemodified);
        $post_date = mysql2date('U', $Item->issue_date);
        $post_date = gmdate('Ymd', $post_date) . 'T' . gmdate('H:i:s', $post_date);
        $content = '<title>' . $Item->title . '</title>';
        $content .= '<category>' . $Item->main_cat_ID . '</category>';
        $content .= $Item->content;
        // Load Item's creator User:
        $Item->get_creator_User();
        $authorname = $Item->creator_User->get('preferredname');
        $data[] = new xmlrpcval(array('authorName' => new xmlrpcval($authorname), 'userid' => new xmlrpcval($Item->creator_user_ID), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'content' => new xmlrpcval($content), 'postid' => new xmlrpcval($Item->ID)), 'struct');
    }
    $resp = new xmlrpcval($data, 'array');
    logIO('OK.');
    return new xmlrpcresp($resp);
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:70,代码来源:_blogger.api.php

示例4: mt_publishPost

/**
 * mt.publishPost
 *
 * @see http://www.sixapart.com/developers/xmlrpc/movable_type_api/mtpublishpost.html
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 postid (string): Unique identifier of the post to publish
 *					1 username (string): Login for a user who is member of the blog.
 *					2 password (string): Password for said username.
 */
function mt_publishPost($m)
{
    global $localtimenow, $DB;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    logIO('mt_publishPost: Login OK');
    // GET POST:
    /**
     * @var Item
     */
    if (!($edited_Item =& xmlrpcs_get_Item($m, 0))) {
        // Failed, return (last) error:
        return xmlrpcs_resperror();
    }
    if (!$current_User->check_perm('item_post!published', 'edit', false, $edited_Item)) {
        return xmlrpcs_resperror(3);
        // Permission denied
    }
    logIO('mt_publishPost: Permission granted');
    logIO('mt_publishPost: Old post status: ' . $edited_Item->status);
    $edited_Item->set('status', 'published');
    //$edited_Item->set( 'datestart', date('Y-m-d H:i:s', $localtimenow) );
    if ($edited_Item->dbupdate() === false) {
        // Could not update item...
        return xmlrpcs_resperror(99, 'Database error: ' . $DB->last_error);
        // DB error
    }
    logIO('mt_publishPost: Item published.');
    // Execute or schedule notifications & pings:
    logIO('mt_publishPost: Handling notifications...');
    $edited_Item->handle_post_processing(false, false);
    logIO('mt_publishPost: OK.');
    return new xmlrpcresp(new xmlrpcval(1, 'boolean'));
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:50,代码来源:_mt.api.php

示例5: mw_getpost

/**
 * metaweblog.getPost retieves a given post.
 *
 * @see http://www.xmlrpc.com/metaWeblogApi#basicEntrypoints
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 postid (string): Unique identifier of the post
 *					1 username (string): Login for a Blogger user who has permission to edit the given
 *						post (either the user who originally created it or an admin of the blog).
 *					2 password (string): Password for said username.
 * @return xmlrpcresp XML-RPC Response
 */
function mw_getpost($m)
{
    global $xmlrpcerruser;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET POST:
    /**
     * @var Item
     */
    if (!($edited_Item =& xmlrpcs_get_Item($m, 0))) {
        // Failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // CHECK PERMISSION: (we need at least one post/edit status)
    if (!$current_User->check_perm('blog_post_statuses', 1, false, $edited_Item->blog_ID)) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    logIO('Permission granted.');
    $post_date = mysql2date("U", $edited_Item->issue_date);
    $post_date = gmdate("Ymd", $post_date) . "T" . gmdate("H:i:s", $post_date);
    $struct = new xmlrpcval(array('link' => new xmlrpcval($edited_Item->get_permanent_url()), 'title' => new xmlrpcval($edited_Item->title), 'description' => new xmlrpcval($edited_Item->content), 'dateCreated' => new xmlrpcval($post_date, "dateTime.iso8601"), 'userid' => new xmlrpcval($edited_Item->creator_user_ID), 'postid' => new xmlrpcval($edited_Item->ID), 'content' => new xmlrpcval($edited_Item->content), 'permalink' => new xmlrpcval($edited_Item->get_permanent_url()), 'categories' => new xmlrpcval($edited_Item->main_cat_ID)), "struct");
    $resp = $struct;
    logIO('OK.');
    return new xmlrpcresp($resp);
}
开发者ID:LFSF,项目名称:oras,代码行数:45,代码来源:_metaweblog.api.php

示例6: pingback_ping

function pingback_ping($m)
{
    // original code by Mort
    // (http://mort.mine.nu:8080)
    global $wpdb;
    global $wp_version;
    if (!get_settings('use_pingback')) {
        return new xmlrpcresp(new xmlrpcval('Sorry, this weblog does not allow you to pingback its posts.'));
    }
    $title = '';
    $pagelinkedfrom = $m->getParam(0);
    $pagelinkedfrom = $pagelinkedfrom->scalarval();
    $pagelinkedto = $m->getParam(1);
    $pagelinkedto = $pagelinkedto->scalarval();
    $pagelinkedfrom = addslashes(str_replace('&amp;', '&', $pagelinkedfrom));
    $pagelinkedto = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedto);
    $messages = array(htmlentities('Pingback from ' . $pagelinkedfrom . ' to ' . $pagelinkedto . ' registered. Keep the web talking! :-)'), htmlentities("We can't find the URL to the post you are trying to " . "link to in your entry. Please check how you wrote the post's permalink in your entry."), htmlentities("We can't find the post you are trying to link to." . " Please check the post's permalink."));
    $message = $messages[0];
    // Check if the page linked to is in our site
    $pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', wp_siteurl())));
    if ($pos1) {
        // let's find which post is linked to
        $urltest = parse_url($pagelinkedto);
        if ($post_ID = url_to_postid($pagelinkedto)) {
            $way = 'url_to_postid()';
        } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
            // the path defines the post_ID (archives/p/XXXX)
            $blah = explode('/', $match[0]);
            $post_ID = $blah[1];
            $way = 'from the path';
        } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
            // the querystring defines the post_ID (?p=XXXX)
            $blah = explode('=', $match[0]);
            $post_ID = $blah[1];
            $way = 'from the querystring';
        } elseif (isset($urltest['fragment'])) {
            // an #anchor is there, it's either...
            if (intval($urltest['fragment'])) {
                // ...an integer #XXXX (simpliest case)
                $post_ID = $urltest['fragment'];
                $way = 'from the fragment (numeric)';
            } elseif (preg_match('/post-[0-9]+/', $urltest['fragment'])) {
                // ...a post id in the form 'post-###'
                $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
                $way = 'from the fragment (post-###)';
            } elseif (is_string($urltest['fragment'])) {
                // ...or a string #title, a little more complicated
                $title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']);
                $sql = "SELECT ID FROM " . wp_table('posts') . " WHERE post_title RLIKE '" . addslashes($title) . "'";
                $post_ID = $wpdb->get_var($sql) or die("Query: {$sql}\n\nError: ");
                $way = 'from the fragment (title)';
            }
        } else {
            // TODO: Attempt to extract a post ID from the given URL
            $post_ID = -1;
            $way = 'no match';
        }
        logIO('O', "(PB) URI='{$pagelinkedto}' ID='{$post_ID}' Found='{$way}'");
        $sql = "SELECT post_author FROM " . wp_table('posts') . " WHERE ID = {$post_ID}";
        $result = $wpdb->get_results($sql);
        if ($wpdb->num_rows) {
            // Let's check that the remote site didn't already pingback this entry
            $sql = 'SELECT * FROM ' . wp_table('comments') . ' 
				WHERE comment_post_ID = ' . $post_ID . ' 
					AND comment_author_url = \'' . $pagelinkedfrom . '\' 
					AND comment_content LIKE \'%<pingback />%\'';
            $result = $wpdb->get_results($sql);
            if ($wpdb->num_rows || 1 == 1) {
                // very stupid, but gives time to the 'from' server to publish !
                sleep(1);
                // Let's check the remote site
                require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
                $snoopy = new Snoopy();
                if ($snoopy->fetch($pagelinkedfrom)) {
                    $linea = $snoopy->results;
                } else {
                    $linea = '';
                }
                logIO('O', "(PB) CHARSET='" . $GLOBALS['blog_charset']);
                $linea = mb_conv($linea, $GLOBALS['blog_charset'], 'auto');
                // Work around bug in strip_tags():
                $linea = str_replace('<!DOCTYPE', '<DOCTYPE', $linea);
                $linea = strip_tags($linea, '<title><a>');
                $linea = strip_all_but_one_link($linea, $pagelinkedto);
                // I don't think we need this? -- emc3
                if (empty($matchtitle)) {
                    preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
                }
                $pos2 = strpos($linea, $pagelinkedto);
                $pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
                logIO('O', "(PB) POS='{$pos2}, {$pos3}'");
                if (is_integer($pos2) || is_integer($pos3)) {
                    //debug_fwrite($log, 'The page really links to us :)'."\n");
                    $pos4 = is_integer($pos2) ? $pos2 : $pos3;
                    $start = $pos4 - 50;
                    if (function_exists('mb_convert_encoding')) {
                        $tmp1 = mb_strcut($linea, 0, $start, $GLOBALS['blog_charset']);
                    } else {
                        $tmp1 = substr($linea, 0, $start);
                    }
//.........这里部分代码省略.........
开发者ID:nobunobuta,项目名称:xoops_mod_WordPress,代码行数:101,代码来源:xmlrpc.php

示例7: pingback_ping

 function pingback_ping($args)
 {
     global $wpdb, $wp_version;
     $this->escape($args);
     $pagelinkedfrom = $args[0];
     $pagelinkedto = $args[1];
     $title = '';
     $pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
     $pagelinkedto = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedto);
     $error_code = -1;
     // Check if the page linked to is in our site
     $pos1 = strpos($pagelinkedto, str_replace(array('http://www.', 'http://', 'https://www.', 'https://'), '', get_settings('home')));
     if (!$pos1) {
         return new IXR_Error(0, 'Is there no link to us?');
     }
     // let's find which post is linked to
     // FIXME: does url_to_postid() cover all these cases already?
     //        if so, then let's use it and drop the old code.
     $urltest = parse_url($pagelinkedto);
     if ($post_ID = url_to_postid($pagelinkedto)) {
         $way = 'url_to_postid()';
     } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
         // the path defines the post_ID (archives/p/XXXX)
         $blah = explode('/', $match[0]);
         $post_ID = $blah[1];
         $way = 'from the path';
     } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
         // the querystring defines the post_ID (?p=XXXX)
         $blah = explode('=', $match[0]);
         $post_ID = $blah[1];
         $way = 'from the querystring';
     } elseif (isset($urltest['fragment'])) {
         // an #anchor is there, it's either...
         if (intval($urltest['fragment'])) {
             // ...an integer #XXXX (simpliest case)
             $post_ID = $urltest['fragment'];
             $way = 'from the fragment (numeric)';
         } elseif (preg_match('/post-[0-9]+/', $urltest['fragment'])) {
             // ...a post id in the form 'post-###'
             $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
             $way = 'from the fragment (post-###)';
         } elseif (is_string($urltest['fragment'])) {
             // ...or a string #title, a little more complicated
             $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']);
             $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_title RLIKE '{$title}'";
             if (!($post_ID = $wpdb->get_var($sql))) {
                 // returning unknown error '0' is better than die()ing
                 return new IXR_Error(0, '');
             }
             $way = 'from the fragment (title)';
         }
     } else {
         // TODO: Attempt to extract a post ID from the given URL
         return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
     }
     $post_ID = (int) $post_ID;
     logIO("O", "(PB) URI='{$pagelinkedto}' ID='{$post_ID}' Found='{$way}'");
     $post = get_post($post_ID);
     if (!$post) {
         // Post_ID not found
         return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
     }
     if ($post_ID == url_to_postid($pagelinkedfrom)) {
         return new IXR_Error(0, 'The source URI and the target URI cannot both point to the same resource.');
     }
     // Check if pings are on
     if ('closed' == $post->ping_status) {
         return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
     }
     // Let's check that the remote site didn't already pingback this entry
     $result = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = '{$post_ID}' AND comment_author_url = '{$pagelinkedfrom}'");
     if ($wpdb->num_rows) {
         // We already have a Pingback from this URL
         return new IXR_Error(48, 'The pingback has already been registered.');
     }
     // very stupid, but gives time to the 'from' server to publish !
     sleep(1);
     // Let's check the remote site
     $linea = wp_remote_fopen($pagelinkedfrom);
     if (!$linea) {
         return new IXR_Error(16, 'The source URI does not exist.');
     }
     // Work around bug in strip_tags():
     $linea = str_replace('<!DOC', '<DOC', $linea);
     $linea = preg_replace('/[\\s\\r\\n\\t]+/', ' ', $linea);
     // normalize spaces
     $linea = preg_replace("/ <(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $linea);
     preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
     $title = $matchtitle[1];
     if (empty($title)) {
         return new IXR_Error(32, 'We cannot find a title on that page.');
     }
     $linea = strip_tags($linea, '<a>');
     // just keep the tag we need
     $p = explode("\n\n", $linea);
     $sem_regexp_pb = "/(\\/|\\\\|\\*|\\?|\\+|\\.|\\^|\\\$|\\(|\\)|\\[|\\]|\\||\\{|\\})/";
     $sem_regexp_fix = "\\\\\$1";
     $link = preg_replace($sem_regexp_pb, $sem_regexp_fix, $pagelinkedfrom);
     $finished = false;
     foreach ($p as $para) {
//.........这里部分代码省略.........
开发者ID:robertlange81,项目名称:Website,代码行数:101,代码来源:xmlrpc.php

示例8: bloggernewpost

function bloggernewpost($m)
{
    global $xmlrpcerruser;
    // import user errcode value
    global $blog_ID, $cache_userdata, $tableposts, $use_rss, $use_weblogsping, $post_autobr;
    global $post_default_title, $post_default_category;
    global $cafelogID, $sleep_after_edit;
    $err = "";
    dbconnect();
    $username = $m->getParam(2);
    $password = $m->getParam(3);
    $content = $m->getParam(4);
    $username = $username->scalarval();
    $password = $password->scalarval();
    $content = $content->scalarval();
    if (user_pass_ok($username, $password)) {
        $userdata = get_userdatabylogin($username);
        $user_ID = $userdata["ID"];
        $user_level = $userdata["user_level"];
        if ($user_level < 1) {
            return new xmlrpcresp(0, $xmlrpcerruser + 1, "Sorry, level 0 users can not post");
        }
        $post_title = addslashes(xmlrpc_getposttitle($content));
        $post_category = xmlrpc_getpostcategory($content);
        $content = xmlrpc_removepostdata($content);
        $content = format_to_post($content);
        $time_difference = get_settings("time_difference");
        $now = date("Y-m-d H:i:s", time() + $time_difference * 3600);
        $sql = "INSERT INTO {$tableposts} (post_author, post_date, post_content, post_title, post_category) VALUES ('{$user_ID}','{$now}','{$content}','{$post_title}','{$post_category}')";
        $result = mysql_query($sql);
        if (!$result) {
            return new xmlrpcresp(0, $xmlrpcerruser + 2, "For some strange yet very annoying reason, your entry couldn't be posted.");
        }
        $post_ID = mysql_insert_id();
        if (!isset($blog_ID)) {
            $blog_ID = 1;
        }
        if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
            sleep($sleep_after_edit);
        }
        rss_update($blog_ID);
        pingWeblogs($blog_ID);
        pingCafelog($cafelogID, $post_title, $post_ID);
        pingBlogs($blog_ID);
        pingback($content, $post_ID);
        logIO("O", "Posted ! ID: {$post_ID}");
        return new xmlrpcresp(new xmlrpcval("{$post_ID}"));
    } else {
        logIO("O", "Wrong username/password combination <b>{$username} / {$password}</b>");
        return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
开发者ID:ericandrewlewis,项目名称:b2,代码行数:52,代码来源:xmlrpc.php

示例9: mt_getCategoryList

/**
 * mt.getCategoryList
 *
 * @see http://www.sixapart.com/developers/xmlrpc/movable_type_api/mtgetcategorylist.html
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 blogid (string): Unique identifier of the blog to query
 *					1 username (string): Login for a Blogger user who is member of the blog.
 *					2 password (string): Password for said username.
 */
function mt_getCategoryList($m)
{
    logIO("mt_getCategoryList start");
    return _b2_or_mt_get_categories('mt', $m);
}
开发者ID:LFSF,项目名称:oras,代码行数:15,代码来源:_mt.api.php

示例10: bpt_upload

function bpt_upload($args)
{
    try {
        global $wpdb;
        global $wp_xmlrpc_server;
        // Decode arguments
        $blog_ID = (int) $args[0];
        $username = $wpdb->escape($args[1]);
        $password = $wpdb->escape($args[2]);
        $data = $args[3];
        $name = sanitize_file_name($data['name']);
        $type = $data['type'];
        $bits = $data['bits'];
        logIO('O', 'bpt.upload ' . $name . ' ' . strlen($bits) . ' bytes');
        // Check credentials
        if (!($user = $wp_xmlrpc_server->login($username, $password))) {
            logIO('O', 'bpt.upload invalid login');
            return $wp_xmlrpc_server->error;
        }
        do_action('xmlrpc_call', 'metaWeblog.newMediaObject');
        // Check user capabilities
        if (!current_user_can('upload_files')) {
            logIO('O', 'bpt.upload no capability');
            return new IXR_Error(401, __('You are not allowed to upload files to this site.'));
        }
        if ($error = apply_filters('pre_upload_error', false)) {
            return new IXR_Error(500, $error);
        }
        // Find post
        $attached = $wpdb->get_row("SELECT ID, post_parent FROM {$wpdb->posts}" . " WHERE post_title = '{$name}'" . " AND post_type = 'attachment'");
        if (empty($attached)) {
            get_currentuserinfo();
            global $user_ID;
            $upload_dir = wp_upload_dir();
            // Create new draft post
            $post_data = array('post_title' => basename($name, '.gpx'), 'post_content' => '<a href="' . $upload_dir['url'] . '/' . $name . '">' . $name . '</a>', 'post_status' => 'draft', 'post_author' => $user_ID);
            $post_ID = wp_insert_post($post_data);
            logIO('O', 'bpt.upload post=' . $post_ID);
        } else {
            $post_ID = $attached->post_parent;
            wp_delete_attachment($attached->ID);
            logIO('O', 'bpt.upload deleted attachment id=' . $attached->ID . ' post=' . $post_ID);
        }
        // Save file
        $upload = wp_upload_bits($name, NULL, $bits);
        if (!empty($upload['error'])) {
            $error = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);
            logIO('O', 'bpt.upload ' . $error);
            return new IXR_Error(500, $error);
        }
        // Attach file
        $attachment = array('post_title' => $name, 'post_content' => '', 'post_type' => 'attachment', 'post_parent' => $post_ID, 'post_mime_type' => $type, 'guid' => $upload['url']);
        $id = wp_insert_attachment($attachment, $upload['file'], $post_ID);
        wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file']));
        logIO('O', 'bpt.upload attachment=' . $id);
        // Handle upload
        return apply_filters('wp_handle_upload', array('file' => $name, 'url' => $upload['url'], 'type' => $type), 'upload');
    } catch (Exception $e) {
        // What?
        logIO('O', 'bpt.upload exception' . $e->getMessage());
        return new IXR_Error(500, $e->getMessage());
    }
}
开发者ID:an0n981,项目名称:BackPackTrackII,代码行数:63,代码来源:bpt.php

示例11: b2_getposturl

/**
 * b2.getPostURL
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 ? NO LONGER USED (was: blogid (string): Unique identifier of the blog to query)
 *					1 ? (string)
 *					2 username (string): Login for a Blogger user who is member of the blog.
 *					3 password (string): Password for said username.193
 *
 *					4 post_ID (string): Post to query
 * @return xmlrpcresp XML-RPC Response
 */
function b2_getposturl($m)
{
    global $xmlrpcerruser;
    global $siteurl;
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 2, 3))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET POST:
    /**
     * @var Item
     */
    if (!($edited_Item =& xmlrpcs_get_Item($m, 4))) {
        // Failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // CHECK PERMISSION: (we need at least one post/edit status)
    if (!$current_User->check_perm('blog_post_statuses', 1, false, $edited_Item->blog_ID)) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    logIO('Permission granted.');
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($edited_Item->get_permanent_url()));
}
开发者ID:LFSF,项目名称:oras,代码行数:42,代码来源:_b2.api.php

示例12: pingback_ping

	function pingback_ping($args) {
		// original code by Mort (http://mort.mine.nu:8080 -- site seems dead)
		// refactored to return error codes and avoid deep ifififif headaches
		global $wpdb, $wp_version; 

		$pagelinkedfrom = $args[0];
		$pagelinkedto   = $args[1];

		$title = '';

		$pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
		$pagelinkedto   = preg_replace('#&([^amp\;])#is', '&amp;$1', $pagelinkedto);

		$error_code = -1;

		// Check if the page linked to is in our site
		$pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', get_settings('home'))));
		if(!$pos1) {
	  		return new IXR_Error(0, '');
		}


		// let's find which post is linked to
		// FIXME: does url_to_postid() cover all these cases already?
		//        if so, then let's use it and drop the old code.
		$urltest = parse_url($pagelinkedto);
		if ($post_ID = url_to_postid($pagelinkedto)) {
			$way = 'url_to_postid()';
		} elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
			// the path defines the post_ID (archives/p/XXXX)
			$blah = explode('/', $match[0]);
			$post_ID = $blah[1];
			$way = 'from the path';
		} elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
			// the querystring defines the post_ID (?p=XXXX)
			$blah = explode('=', $match[0]);
			$post_ID = $blah[1];
			$way = 'from the querystring';
		} elseif (isset($urltest['fragment'])) {
			// an #anchor is there, it's either...
			if (intval($urltest['fragment'])) {
				// ...an integer #XXXX (simpliest case)
				$post_ID = $urltest['fragment'];
				$way = 'from the fragment (numeric)';
			} elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) {
				// ...a post id in the form 'post-###'
				$post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']);
				$way = 'from the fragment (post-###)';
			} elseif (is_string($urltest['fragment'])) {
				// ...or a string #title, a little more complicated
				$title = preg_replace('/[^a-zA-Z0-9]/', '.', $urltest['fragment']);
				$sql = "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE '$title'";
				if (! ($post_ID = $wpdb->get_var($sql)) ) {
					// returning unknown error '0' is better than die()ing
			  		return new IXR_Error(0, '');
				}
				$way = 'from the fragment (title)';
			}
		} else {
			// TODO: Attempt to extract a post ID from the given URL
	  		return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
		}


		logIO("O","(PB) URI='$pagelinkedto' ID='$post_ID' Found='$way'");

		$sql = 'SELECT post_author FROM '.$wpdb->posts.' WHERE ID = '.$post_ID;
		$result = $wpdb->get_results($sql);

		if (!$wpdb->num_rows) {
			// Post_ID not found
	  		return new IXR_Error(33, 'The specified target URI cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
		}


		// Let's check that the remote site didn't already pingback this entry
		$result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");

		if ($wpdb->num_rows) {
			// We already have a Pingback from this URL
	  		return new IXR_Error(48, 'The pingback has already been registered.');
		}


		// very stupid, but gives time to the 'from' server to publish !
		sleep(1);

		// Let's check the remote site
		$linea = wp_remote_fopen( $pagelinkedfrom );
		if ( !$linea )
	  		return new IXR_Error(16, 'The source URI does not exist.');

		// Work around bug in strip_tags():
		$linea = str_replace('<!DOCTYPE','<DOCTYPE',$linea);
		$linea = strip_tags($linea, '<title><a>');
		$linea = strip_all_but_one_link($linea, $pagelinkedto);
		// I don't think we need this? -- emc3
		//$linea = preg_replace('#&([^amp\;])#is', '&amp;$1', $linea);
		if ( empty($matchtitle) ) {
			preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
//.........这里部分代码省略.........
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:xmlrpc.php

示例13: b2_getposturl

/**
 * b2.getPostURL
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 ? NO LONGER USED (was: blogid (string): Unique identifier of the blog to query)
 *					1 ? (string)
 *					2 username (string): Login for a Blogger user who is member of the blog.
 *					3 password (string): Password for said username.193
 *
 *					4 post_ID (string): Post to query
 * @return xmlrpcresp XML-RPC Response
 */
function b2_getposturl($m)
{
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 2, 3))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET POST:
    /**
     * @var Item
     */
    if (!($edited_Item =& xmlrpcs_get_Item($m, 4))) {
        // Failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // CHECK PERMISSION: (user needs to be able to view the item)
    if (!xmlrpcs_can_view_item($edited_Item, $User)) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($edited_Item->get_permanent_url()));
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:39,代码来源:_b2.api.php

示例14: mw_getpost

/**
 * metaWeblog.getPost retieves a given post.
 *
 * @see http://www.xmlrpc.com/metaWeblogApi#basicEntrypoints
 *
 * @param xmlrpcmsg XML-RPC Message
 *					0 postid (string): Unique identifier of the post
 *					1 username (string): Login for a Blogger user who has permission to edit the given
 *						post (either the user who originally created it or an admin of the blog).
 *					2 password (string): Password for said username.
 * @return xmlrpcresp XML-RPC Response
 */
function mw_getpost($m)
{
    // CHECK LOGIN:
    /**
     * @var User
     */
    if (!($current_User =& xmlrpcs_login($m, 1, 2))) {
        // Login failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // GET POST:
    /**
     * @var Item
     */
    if (!($edited_Item =& xmlrpcs_get_Item($m, 0))) {
        // Failed, return (last) error:
        return xmlrpcs_resperror();
    }
    // CHECK PERMISSION:
    if (!xmlrpcs_can_view_item($edited_Item, $current_User)) {
        // Permission denied
        return xmlrpcs_resperror(3);
        // User error 3
    }
    $item = _wp_mw_get_item_struct($edited_Item);
    logIO('OK.');
    return new xmlrpcresp(new xmlrpcval($item, 'struct'));
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:40,代码来源:_metaweblog.api.php

示例15: execute

 /**
  * Execute a method invoked by the client, checking parameters used
  * @param mixed $m either an xmlrpcmsg obj or a method name
  * @param array $params array with method parameters as php types (if m is method name only)
  * @param array $paramtypes array with xmlrpc types of method parameters (if m is method name only)
  * @return xmlrpcresp
  * @access private
  */
 function execute($m, $params = null, $paramtypes = null)
 {
     if (is_object($m)) {
         $methName = $m->method();
     } else {
         $methName = $m;
     }
     logIO($methName, true);
     $sysCall = $this->allow_system_funcs && strpos($methName, "system.") === 0;
     $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap;
     if (!isset($dmap[$methName]['function'])) {
         // No such method
         logIO('No such method:' . $methName);
         return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['unknown_method'], $GLOBALS['xmlrpcstr']['unknown_method']);
     }
     // Check signature
     if (isset($dmap[$methName]['signature'])) {
         $sig = $dmap[$methName]['signature'];
         if (is_object($m)) {
             list($ok, $errstr) = $this->verifySignature($m, $sig);
         } else {
             list($ok, $errstr) = $this->verifySignature($paramtypes, $sig);
         }
         if (!$ok) {
             // Didn't match.
             logIO('Invalid signature.');
             return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['incorrect_params'], $GLOBALS['xmlrpcstr']['incorrect_params'] . ": {$errstr}");
         }
     }
     $func = $dmap[$methName]['function'];
     // let the 'class::function' syntax be accepted in dispatch maps
     if (is_string($func) && strpos($func, '::')) {
         $func = explode('::', $func);
     }
     // verify that function to be invoked is in fact callable
     if (!is_callable($func)) {
         error_log("XML-RPC: xmlrpc_server::execute: function {$func} registered as method handler is not callable");
         return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method");
     }
     // If debug level is 3, we should catch all errors generated during
     // processing of user function, and log them as part of response
     if ($this->debug > 2) {
         $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler');
     }
     if (is_object($m)) {
         if ($sysCall) {
             $r = call_user_func($func, $this, $m);
         } else {
             $r = call_user_func($func, $m);
         }
         if (!is_a($r, 'xmlrpcresp')) {
             error_log("XML-RPC: xmlrpc_server::execute: function {$func} registered as method handler does not return an xmlrpcresp object");
             if (is_a($r, 'xmlrpcval')) {
                 $r =& new xmlrpcresp($r);
             } else {
                 $r =& new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object");
             }
         }
     } else {
         // call a 'plain php' function
         if ($sysCall) {
             array_unshift($params, $this);
             $r = call_user_func_array($func, $params);
         } else {
             // 3rd API convention for method-handling functions: EPI-style
             if ($this->functions_parameters_type == 'epivals') {
                 $r = call_user_func_array($func, array($methName, $params, $this->user_data));
                 // mimic EPI behaviour: if we get an array that looks like an error, make it
                 // an eror response
                 if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) {
                     $r =& new xmlrpcresp(0, (int) $r['faultCode'], (string) $r['faultString']);
                 } else {
                     // functions using EPI api should NOT return resp objects,
                     // so make sure we encode the return type correctly
                     $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('extension_api')));
                 }
             } else {
                 $r = call_user_func_array($func, $params);
             }
         }
         // the return type can be either an xmlrpcresp object or a plain php value...
         if (!is_a($r, 'xmlrpcresp')) {
             // what should we assume here about automatic encoding of datetimes
             // and php classes instances???
             $r =& new xmlrpcresp(php_xmlrpc_encode($r, array('auto_dates')));
         }
     }
     if ($this->debug > 2) {
         // note: restore the error handler we found before calling the
         // user func, even if it has been changed inside the func itself
         if ($GLOBALS['_xmlrpcs_prev_ehandler']) {
             set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']);
//.........这里部分代码省略.........
开发者ID:LFSF,项目名称:oras,代码行数:101,代码来源:_xmlrpcs.inc.php


注:本文中的logIO函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。