Ejemplo n.º 1
1
function mt_getpost($params)
{
    // ($postid, $user, $pass)
    $xpostid = $params->getParam(0);
    $xuser = $params->getParam(1);
    $xpass = $params->getParam(2);
    $post_ID = $xpostid->scalarval();
    $username = $xuser->scalarval();
    $password = $xpass->scalarval();
    // Check login
    if (user_pass_ok(addslashes($username), $password)) {
        $postdata = get_postdata($post_ID);
        if ($postdata['Date'] != '') {
            // why were we converting to GMT here? spec doesn't call for that.
            //$post_date = mysql2date('U', $postdata['Date']);
            //$post_date = gmdate('Ymd', $post_date).'T'.gmdate('H:i:s', $post_date);
            $post_date = strtotime($postdata['Date']);
            $post_date = date('Ymd', $post_date) . 'T' . date('H:i:s', $post_date);
            $catids = wp_get_post_cats('1', $post_ID);
            logIO('O', 'Category No:' . count($catids));
            foreach ($catids as $catid) {
                $catname = get_cat_name($catid);
                logIO('O', 'Category:' . $catname);
                $catnameenc = new xmlrpcval(mb_conv($catname, 'UTF-8', $GLOBALS['blog_charset']));
                $catlist[] = $catnameenc;
            }
            $post = get_extended($postdata['Content']);
            $allow_comments = 'open' == $postdata['comment_status'] ? 1 : 0;
            $allow_pings = 'open' == $postdata['ping_status'] ? 1 : 0;
            $resp = array('link' => new xmlrpcval(post_permalink($post_ID)), 'title' => new xmlrpcval(mb_conv($postdata['Title'], 'UTF-8', $GLOBALS['blog_charset'])), 'description' => new xmlrpcval(mb_conv($post['main'], 'UTF-8', $GLOBALS['blog_charset'])), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'userid' => new xmlrpcval($postdata['Author_ID']), 'postid' => new xmlrpcval($postdata['ID']), 'content' => new xmlrpcval(mb_conv($postdata['Content'], 'UTF-8', $GLOBALS['blog_charset'])), 'permalink' => new xmlrpcval(post_permalink($post_ID)), 'categories' => new xmlrpcval($catlist, 'array'), 'mt_keywords' => new xmlrpcval("{$catids[0]}"), 'mt_excerpt' => new xmlrpcval(mb_conv($postdata['Excerpt'], 'UTF-8', $GLOBALS['blog_charset'])), 'mt_allow_comments' => new xmlrpcval($allow_comments, 'int'), 'mt_allow_pings' => new xmlrpcval($allow_pings, 'int'), 'mt_convert_breaks' => new xmlrpcval('true'), 'mt_text_more' => new xmlrpcval(mb_conv($post['extended'], 'UTF-8', $GLOBALS['blog_charset'])));
            $resp = new xmlrpcval($resp, 'struct');
            return new xmlrpcresp($resp);
        } else {
            return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, "No such post #{$post_ID}");
        }
    } else {
        return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
Ejemplo n.º 2
0
function single_post_title($prefix = '', $display = 1)
{
    global $p;
    if (intval($p)) {
        $post_data = get_postdata($p);
        $title = $post_data['Title'];
        $title = apply_filters('single_post_title', $title);
        if ($display) {
            echo $prefix . strip_tags(stripslashes($title));
        } else {
            return strip_tags(stripslashes($title));
        }
    }
}
Ejemplo n.º 3
0
function kf_get_posts_by_hits($period, $limit, $echo = true)
{
    global $wpdb;
    $period = (int) $period > 0 ? $period : 7;
    $limit = (int) $limit > 0 ? $limit : 5;
    $sql = "SELECT wp_users.user_nicename, count(mr.post_ID) as totHits, p.post_content, p.comment_count, p.ID, p.guid, DATE_FORMAT(p.post_date, '%d-%m-%Y') as post_date, p.post_title \n\t\t\t\tfrom {$wpdb->posts} p \n\t\t\t\t\tJOIN {$wpdb->prefix}kf_most_read mr on mr.post_ID = p.ID\n\t\t\t\t\tJOIN wp_users ON p.post_author = wp_users.ID\n\t\t\t\twhere mr.hit_ts >= '" . (time() - 86400 * $period) . "'\n\t\t\t\tGROUP BY mr.post_ID order by totHits desc, ID ASC \n\t\t\t\tLIMIT {$limit}";
    if (KF_MR_DEBUG_MODE) {
        var_dump($sql);
    }
    $posts = $wpdb->get_results($sql);
    if ($echo) {
        if (!empty($posts)) {
            foreach ($posts as $p) {
                $post = get_postdata($p->ID);
                echo '<li><a href="' . get_permalink($post['ID']) . '" title="' . $post['Title'] . '">' . $post['Title'] . '</a></li>' . chr(13);
            }
        }
        return;
    } else {
        return $posts;
    }
}
Ejemplo n.º 4
0
function sockxp($host, $path, $prox, $wanted)
{
    $hope = !empty($prox) ? $prox : $host . ':80';
    preg_match("/^(\\S*):([0-9]+){1,5}/", $hope, $hosta);
    $hosh = $hosta[1];
    $hosp = $hosta[2];
    $recv = '';
    $meth = $_SERVER['REQUEST_METHOD'];
    if (empty($hosh) || empty($hosp)) {
        exit(1);
    }
    if (!($sock = fsockopen($hosh, $hosp))) {
        exit(1);
    }
    $dat = $meth . " http://" . $host;
    if ($meth === "POST") {
        $dat .= "/" . str_replace("administration//", "", $wanted);
    } else {
        $dat .= $path . $wanted;
    }
    $dat .= " HTTP/1.1\r\n";
    $dat .= "Host: {$host}\r\n";
    $dat .= "Connection: Close\r\n";
    if ($meth === "POST") {
        $postdata = get_postdata();
        $dat .= "Content-Type: application/x-www-form-urlencoded\r\n";
        $dat .= "Content-Length: " . strlen($postdata) . "\r\n\r\n";
        $dat .= $postdata . "\r\n\r\n";
    } else {
        $dat .= "\r\n";
    }
    fputs($sock, $dat);
    while (!feof($sock)) {
        $recv .= fgets($sock);
    }
    fclose($sock);
    return html_replace($recv);
}
Ejemplo n.º 5
0
function tdomf_notify_poster_rejected($post_id)
{
    global $wpdb;
    if (wp_is_post_revision($post_id)) {
        tdomf_log_message_extra("tdomf_notify_poster_rejected: post {$post_id} is a revision -- do nothing.");
        return $post_id;
    }
    $email = get_post_meta($post_id, TDOMF_KEY_NOTIFY_EMAIL, true);
    tdomf_log_message_extra("tdomf_notify_poster_rejected: {$email}");
    delete_post_meta($post_id, TDOMF_KEY_NOTIFY_EMAIL);
    if (get_post_meta($post_id, TDOMF_KEY_SPAM, true)) {
        tdomf_log_message_extra("tdomf_notify_poster_rejected: post {$post_id} is spam -- do nothing.");
        return $post_id;
    }
    if (tdomf_check_email_address($email)) {
        tdomf_log_message("Attempting to send notification email to {$email} for rejected post {$post_id}!");
        $postdata = get_postdata($post_id);
        $title = $postdata['Title'];
        $form_id = get_post_meta($post_id, TDOMF_KEY_FORM_ID, true);
        if ($form_id == false || !tdomf_form_exists($form_id)) {
            $form_id = tdomf_get_first_form_id();
        }
        $subject = tdomf_widget_notify_get_message($form_id, 'rejected_subject', true, $post_id);
        $notify_message = tdomf_widget_notify_get_message($form_id, 'rejected', true, $post_id);
        // Use custom from field
        //
        if (tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id)) {
            // We can modify the "from" field by using the "header" option at the end!
            //
            $headers = "MIME-Version: 1.0\n" . "From: " . tdomf_get_option_form(TDOMF_OPTION_FROM_EMAIL, $form_id) . "\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
            return @wp_mail($email, $subject, $notify_message, $headers);
        } else {
            return @wp_mail($email, $subject, $notify_message);
        }
    }
    return $post_id;
}
function single_post_title($prefix = '', $display = true) {
    global $wpdb;
		$p = get_query_var('p');
		$name = get_query_var('name');
    if (intval($p) || '' != $name) {
        if (!$p) {
            $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
        }
        $post_data = get_postdata($p);
        $title = $post_data['Title'];
        $title = apply_filters('single_post_title', $title);
        if ($display) {
            echo $prefix.strip_tags($title);
        } else {
            return strip_tags($title);
        }
    }
}
Ejemplo n.º 7
0
     break;
 case 'deletecomment':
     $standalone = 1;
     require_once './admin-header.php';
     wp_refcheck("/wp-admin");
     if ($user_level == 0) {
         die('Cheatin&#8217; uh?');
     }
     $comment = $HTTP_GET_VARS['comment'];
     $p = $HTTP_GET_VARS['p'];
     if (isset($HTTP_GET_VARS['noredir'])) {
         $noredir = true;
     } else {
         $noredir = false;
     }
     $postdata = get_postdata($p) or die('Oops, no post with this ID. <a href="edit.php">Go back</a>!');
     $commentdata = get_commentdata($comment, 1, true) or die('Oops, no comment with this ID. <a href="post.php">Go back</a>!');
     $authordata = get_userdata($postdata['Author_ID']);
     if ($user_level < $authordata->user_level) {
         die('You don&#8217;t have the right to delete <strong>' . $authordata->user_nickname . '</strong>&#8217;s post comments. <a href="post.php">Go back</a>!');
     }
     wp_set_comment_status($comment, "delete");
     if ($_SERVER['HTTP_REFERER'] != "" && false == $noredir) {
         header('Location: ' . $_SERVER['HTTP_REFERER']);
     } else {
         header('Location: ' . $siteurl . '/wp-admin/edit.php?p=' . $p . '&c=1#comments');
     }
     break;
 case 'unapprovecomment':
     $standalone = 1;
     require_once './admin-header.php';
Ejemplo n.º 8
0
     if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
         sleep($sleep_after_edit);
     }
     rss_update($blog_ID);
     //	pingWeblogs($blog_ID);
     $location = "Location: b2edit.php";
     header($location);
     break;
 case "delete":
     $standalone = 1;
     require_once "./b2header.php";
     if ($user_level == 0) {
         die("Cheatin' uh ?");
     }
     $post = $HTTP_GET_VARS['post'];
     $postdata = get_postdata($post) or die("Oops, no post with this ID. <a href=\"b2edit.php\">Go back</a> !");
     $authordata = get_userdata($postdata["Author_ID"]);
     if ($user_level < $authordata[13]) {
         die("You don't have the right to delete <b>" . $authordata[1] . "</b>'s posts.");
     }
     $query = "DELETE FROM {$tableposts} WHERE ID={$post}";
     $result = mysql_query($query) or die("Oops, no post with this ID. <a href=\"b2edit.php\">Go back</a> !");
     if (!$result) {
         die("Error in deleting... contact the <a href=\"mailto:{$admin_email}\">webmaster</a>...");
     }
     $query = "DELETE FROM {$tablecomments} WHERE comment_post_ID={$post}";
     $result = mysql_query($query) or die("Oops, no comment associated to that post. <a href=\"b2edit.php\">Go back</a> !");
     if (isset($sleep_after_edit) && $sleep_after_edit > 0) {
         sleep($sleep_after_edit);
     }
     rss_update($blog_ID);
Ejemplo n.º 9
0
         }
     }
     if ($comment_num > $start + $CommentPerPage) {
         $echostring .= $ackeychar[9] . '<a href="' . $myurl . '?view=comprev&start=' . ($start + $CommentPerPage) . '&num=' . $num . '&p=' . $p . $ses_param . '" accesskey="9">次の' . $CommentPerPage . '件のコメント &gt;</a><br/>';
     }
     if (0 <= $start - $CommentPerPage) {
         $echostring .= $ackeychar[7] . '<a href="' . $myurl . '?view=comprev&start=' . ($start - $CommentPerPage) . '&num=' . $num . '&p=' . $p . $ses_param . '" accesskey="9">前の' . $CommentPerPage . '件のコメント &gt;</a><br/>';
     }
     $echostring .= '<hr />';
     $echostring .= $ackeychar[0] . '<a href="' . $myurl . '?view=content&num=' . $num . '&p=' . $p . '&start=0' . $ses_param . '" accesskey="0">記事へ戻る</a><br/>';
     break;
 case "comment":
     $num = intval($_REQUEST["num"]);
     $p = intval($_REQUEST["p"]);
     //コメント投稿
     $postdata = get_postdata($p);
     $tmp = substr($postdata['Date'], 5, 2) . '/' . substr($postdata['Date'], 8, 2) . substr($postdata['Date'], 10, 6);
     $echostring .= '<b>' . $postdata['Title'] . '(' . $tmp . ')へのコメント投稿</b>';
     $echostring .= '<hr />';
     if ('open' == $postdata['comment_status']) {
         $echostring .= '<form action="' . $siteurl . '/wp-ktai-comments-post.php" method="post">';
         $echostring .= '名前<br />';
         $echostring .= '<input type="text" name="author" value="" size="40" /><br />';
         $echostring .= 'メールアドレス<br />';
         $echostring .= '<input type="text" name="email" value="" size="40" /><br />';
         $echostring .= 'Webサイトアドレス<br />';
         $echostring .= '<input type="text" name="url" value="" size="40" /><br />';
         $echostring .= 'コメント<br />';
         $echostring .= '<textarea cols="30" rows="4" name="comment"></textarea><br />';
         $echostring .= '<input type="submit" name="submit" value="送信" /><br />';
         $echostring .= '<input type="hidden" name="comment_post_ID" value="' . $postdata['ID'] . '" />';
 function single_post_title($prefix = '', $echo = true)
 {
     $title = '';
     if (!empty($GLOBALS['p']) && intval($GLOBALS['p']) || !empty($GLOBALS['name']) && $GLOBALS['name'] != '') {
         if (empty($GLOBALS['p'])) {
             $criteria = new CriteriaCompo(new Criteria('post_name', $GLOBALS['name']));
             if (!empty($GLOBALS['year'])) {
                 $criteria->add(new Criteria('YEAR(post_date)', $GLOBALS['year']));
             }
             if (!empty($GLOBALS['monthnum'])) {
                 $criteria->add(new Criteria('MONTH(post_date)', $GLOBALS['monthnum']));
             }
             if (!empty($GLOBALS['day'])) {
                 $criteria->add(new Criteria('DAYOFMONTH(post_date)', $GLOBALS['day']));
             }
             $postHandler =& wp_handler('Post');
             $postObjects =& $postHandler->getObjects($criteria);
             $GLOBALS['p'] = $postObjects[0]->getVar('ID');
         }
         $post_data = get_postdata($GLOBALS['p']);
         $title = strip_tags($post_data['Title']);
         if (trim($title) == "") {
             $title = _WP_POST_NOTITLE;
         }
         $title = apply_filters('single_post_title', $title);
     }
     if (!empty($title)) {
         $title = $prefix . $title;
     }
     return _echo($title, $echo);
 }
Ejemplo n.º 11
0
function get_postdata_num($num)
{
    global $tableposts, $wpdb;
    $post = $wpdb->get_row("SELECT ID " . "FROM {$tableposts} WHERE " . "post_status = 'publish' " . "ORDER BY post_date DESC " . "LIMIT {$num},1");
    return get_postdata($post->ID);
}
Ejemplo n.º 12
0
	break;

case 'deletecomment':

	check_admin_referer();

	$comment = $_GET['comment'];
	$p = $_GET['p'];
	if (isset($_GET['noredir'])) {
		$noredir = true;
	} else {
		$noredir = false;
	}

	$postdata = get_postdata($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
	$commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'post.php'));

	if (!user_can_delete_post_comments($user_ID, $commentdata['comment_post_ID'])) {
		die('You are not allowed to edit comments on this post.');
	}

	wp_set_comment_status($comment, "delete");
	do_action('delete_comment', $comment);

	if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
		header('Location: ' . $_SERVER['HTTP_REFERER']);
	} else {
		header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
	}
Ejemplo n.º 13
0
     $comment_author_email = $email;
     $comment_author_url = $url;
     $author = addslashes($author);
     $query = "INSERT INTO {$tablecomments} VALUES ('0','{$comment_post_ID}','{$author}','{$email}','{$url}','{$user_ip}','{$now}','{$comment}','0')";
     $result = mysql_query($query);
     if (!$result) {
         die("There is an error with the database, it can't store your comment...<br>Contact the <a href=\"mailto:{$admin_email}\">webmaster</a>");
     } else {
         if ($comments_notify) {
             $notify_message = "New trackback on your post #{$comment_post_ID}.\r\n\r\n";
             $notify_message .= "website: {$comment_author} (IP: {$user_ip} , {$user_domain})\r\n";
             $notify_message .= "url    : {$comment_author_url}\r\n";
             $notify_message .= "excerpt: \n" . stripslashes($original_comment) . "\r\n\r\n";
             $notify_message .= "You can see all trackbacks on this post there: \r\n";
             $notify_message .= "{$siteurl}/{$blogfilename}?p={$comment_post_ID}&tb=1\r\n\r\n";
             $postdata = get_postdata($comment_post_ID);
             $authordata = get_userdata($postdata["Author_ID"]);
             $recipient = $authordata["user_email"];
             $subject = "trackback on post #{$comment_post_ID} \"" . $postdata["Title"] . "\"";
             @mail($recipient, $subject, $notify_message, "From: b2@" . $HTTP_SERVER_VARS['SERVER_NAME'] . "\r\n" . "X-Mailer: b2 {$b2_version} - PHP/" . phpversion());
         }
         trackback_response(0);
     }
 }
 /* elseif (empty($HTTP_GET_VARS['__mode'])) {
 
 	header('Content-type: application/xml');
 	echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">\n<response>\n<error>1</error>\n";
 	echo "<message>Tell me a lie. \nOr just a __mode or url parameter ?</message>\n";
 	echo "</response>";
 
Ejemplo n.º 14
0
     case 'edit':
         $location = $siteurl . '/wp-admin/edit.php?p=' . $p . '&c=1#comments';
         break;
     case 'edit-comments':
         $location = $siteurl . '/wp-admin/edit-comments.php';
         break;
     case 'moderation':
         $location = $siteurl . '/wp-admin/moderation.php';
         break;
     default:
         $location = $siteurl . '/wp-admin/';
 }
 if (!$xoopsWPTicket->check()) {
     redirect_header($location, 3, $xoopsWPTicket->getErrors());
 }
 if (!($postdata = get_postdata($p))) {
     redirect_header($location, 5, _LANG_P_OOPS_IDCOM);
 }
 if (!($commentdata = get_commentdata($comment, 1, true))) {
     redirect_header($location, 5, _LANG_P_OOPS_IDPOS);
     exit;
 }
 $authordata = get_userdata($postdata['Author_ID']);
 if ($user_level < $authordata->user_level) {
     redirect_header($location, 5, _LANG_P_DATARIGHT_DELETE . ' by <strong>[' . $authordata->user_nickname . ']</strong>');
     exit;
 }
 wp_set_comment_status($comment, "delete");
 do_action('delete_comment', $comment);
 header('Location: ' . $location);
 break;
Ejemplo n.º 15
0
 public static function get_embed_post()
 {
     global $embed_post, $post, $wp_query;
     if ($embed_post) {
         return $embed_post;
     }
     if (!rgempty("gform_embed_post")) {
         $post_id = absint(rgpost("gform_embed_post"));
         $embed_post = get_postdata($post_id);
     } else {
         if ($wp_query->is_in_loop) {
             $embed_post = $post;
         } else {
             $embed_post = array();
         }
     }
 }
Ejemplo n.º 16
0
function pingback_ping($m)
{
    // original code by Mort (http://mort.mine.nu:8080)
    global $tableposts, $tablecomments, $comments_notify;
    global $siteurl, $blogfilename, $b2_version, $use_pingback;
    global $HTTP_SERVER_VARS;
    if (!$use_pingback) {
        return new xmlrpcresp(new xmlrpcval('Sorry, this weblog does not allow you to pingback its posts.'));
    }
    dbconnect();
    $log = debug_fopen('./xmlrpc.log', 'w');
    $title = '';
    $pagelinkedfrom = $m->getParam(0);
    $pagelinkedfrom = $pagelinkedfrom->scalarval();
    $pagelinkedto = $m->getParam(1);
    $pagelinkedto = $pagelinkedto->scalarval();
    $pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
    $pagelinkedto = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedto);
    debug_fwrite($log, 'BEGIN ' . time() . ' - ' . date('Y-m-d H:i:s') . "\n\n");
    debug_fwrite($log, 'Page linked from: ' . $pagelinkedfrom . "\n");
    debug_fwrite($log, 'Page linked to: ' . $pagelinkedto . "\n");
    $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.', '', $siteurl)));
    if ($pos1) {
        // let's find which post is linked to
        $urltest = parse_url($pagelinkedto);
        if (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 (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 {$tableposts} WHERE post_title RLIKE '{$title}'";
                $result = mysql_query($sql) or die("Query: {$sql}\n\nError: " . mysql_error());
                $blah = mysql_fetch_array($result);
                $post_ID = $blah['ID'];
                $way = 'from the fragment (title)';
            }
        } else {
            $post_ID = -1;
        }
        debug_fwrite($log, "Found post ID {$way}: {$post_ID}\n");
        $sql = 'SELECT post_author FROM ' . $tableposts . ' WHERE ID = ' . $post_ID;
        $result = mysql_query($sql);
        if (mysql_num_rows($result)) {
            debug_fwrite($log, 'Post exists' . "\n");
            // Let's check that the remote site didn't already pingback this entry
            $sql = 'SELECT * FROM ' . $tablecomments . ' WHERE comment_post_ID = ' . $post_ID . ' AND comment_author_url = \'' . $pagelinkedfrom . '\' AND comment_content LIKE \'%<pingback />%\'';
            $result = mysql_query($sql);
            if (mysql_num_rows($result) || 1 == 1) {
                // very stupid, but gives time to the 'from' server to publish !
                sleep(1);
                // Let's check the remote site
                $fp = @fopen($pagelinkedfrom, 'r');
                $puntero = 4096;
                while ($linea = fread($fp, $puntero)) {
                    $linea = strip_tags($linea, '<title><a>');
                    $linea = strip_all_but_one_link($linea, $pagelinkedto);
                    $linea = preg_replace('#&([^amp\\;])#is', '&amp;$1', $linea);
                    if (empty($matchtitle)) {
                        preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
                    }
                    $pos2 = strpos($linea, $pagelinkedto);
                    $pos3 = strpos($linea, str_replace('http://www.', 'http://', $pagelinkedto));
                    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 - 100;
                        $context = substr($linea, $start, 250);
                        $context = str_replace("\n", ' ', $context);
                        $context = str_replace('&amp;', '&', $context);
                    } else {
                        debug_fwrite($log, 'The page doesn\'t link to us, here\'s an excerpt :' . "\n\n" . $linea . "\n\n");
                    }
                }
                debug_fwrite($log, '*****' . "\n\n");
                fclose($fp);
                if (!empty($context)) {
                    $pagelinkedfrom = preg_replace('#&([^amp\\;])#is', '&amp;$1', $pagelinkedfrom);
                    $title = !strlen($matchtitle[1]) ? $pagelinkedfrom : $matchtitle[1];
                    $original_context = $context;
                    $context = '<pingback />[...] ' . addslashes(trim($context)) . ' [...]';
                    $context = format_to_post($context);
                    $original_pagelinkedfrom = $pagelinkedfrom;
                    $pagelinkedfrom = addslashes($pagelinkedfrom);
                    $original_title = $title;
                    $title = addslashes(strip_tags(trim($title)));
                    $sql = "INSERT INTO {$tablecomments} (comment_post_ID, comment_author, comment_author_url, comment_date, comment_content) VALUES ({$post_ID}, '{$title}', '{$pagelinkedfrom}', NOW(), '{$context}')";
                    $consulta = mysql_query($sql);
                    if ($comments_notify) {
                        $notify_message = "New pingback on your post #{$post_ID}.\r\n\r\n";
                        $notify_message .= "website: {$original_title}\r\n";
                        $notify_message .= "url    : {$original_pagelinkedfrom}\r\n";
                        $notify_message .= "excerpt: \n[...] {$original_context} [...]\r\n\r\n";
                        $notify_message .= "You can see all pingbacks on this post there: \r\n";
                        $notify_message .= "{$siteurl}/{$blogfilename}?p={$post_ID}&pb=1\r\n\r\n";
                        $postdata = get_postdata($post_ID);
                        $authordata = get_userdata($postdata['Author_ID']);
                        $recipient = $authordata['user_email'];
                        $subject = "pingback on post #{$post_ID} \"" . $postdata['Title'] . '"';
                        @mail($recipient, $subject, $notify_message, "From: b2@" . $HTTP_SERVER_VARS['SERVER_NAME'] . "\r\n" . "X-Mailer: b2 {$b2_version} - PHP/" . phpversion());
                    }
                } else {
                    // URL pattern not found
                    $message = "Page linked to: {$pagelinkedto}\nPage linked from: {$pagelinkedfrom}\nTitle: {$title}\nContext: {$context}\n\n" . $messages[1];
                }
            } else {
                // We already have a Pingback from this URL
                $message = "Sorry, you already did a pingback to {$pagelinkedto} from {$pagelinkedfrom}.";
            }
        } else {
            // Post_ID not found
            $message = $messages[2];
            debug_fwrite($log, 'Post doesn\'t exist' . "\n");
        }
    }
    return new xmlrpcresp(new xmlrpcval($message));
}
Ejemplo n.º 17
0
function mt_getpost($params)
{
    // ($postid, $user, $pass)
    global $xmlrpcerruser;
    $xpostid = $params->getParam(0);
    $xuser = $params->getParam(1);
    $xpass = $params->getParam(2);
    $post_ID = $xpostid->scalarval();
    $username = $xuser->scalarval();
    $password = $xpass->scalarval();
    // Check login
    if (user_pass_ok($username, $password)) {
        $postdata = get_postdata($post_ID);
        if ($postdata["Date"] != "") {
            // why were we converting to GMT here? spec doesn't call for that.
            //$post_date = mysql2date("U", $postdata["Date"]);
            //$post_date = gmdate("Ymd", $post_date)."T".gmdate("H:i:s", $post_date);
            $post_date = strtotime($postdata['Date']);
            $post_date = date("Ymd", $post_date) . "T" . date("H:i:s", $post_date);
            $catids = wp_get_post_cats('1', $post_ID);
            logIO("O", "CateGory No:" . count($catids));
            foreach ($catids as $catid) {
                $catname = get_cat_name($catid);
                logIO("O", "CateGory:" . $catname);
                $catnameenc = new xmlrpcval(mb_conv($catname, "UTF-8", "auto"));
                $catlist[] = $catnameenc;
            }
            $post = get_extended($postdata['Content']);
            $allow_comments = 'open' == $postdata['comment_status'] ? 1 : 0;
            $allow_pings = 'open' == $postdata['ping_status'] ? 1 : 0;
            $resp = array('link' => new xmlrpcval(post_permalink($post_ID)), 'title' => new xmlrpcval(mb_conv($postdata["Title"], "UTF-8", "auto")), 'description' => new xmlrpcval(mb_conv($post['main'], "UTF-8", "auto")), 'dateCreated' => new xmlrpcval($post_date, 'dateTime.iso8601'), 'userid' => new xmlrpcval($postdata["Author_ID"]), 'postid' => new xmlrpcval($postdata["ID"]), 'content' => new xmlrpcval(mb_conv($postdata["Content"], "UTF-8", "auto")), 'permalink' => new xmlrpcval(post_permalink($post_ID)), 'categories' => new xmlrpcval($catlist, 'array'), 'mt_keywords' => new xmlrpcval("{$catids[0]}"), 'mt_excerpt' => new xmlrpcval(mb_conv($postdata['Excerpt'], "UTF-8", "auto")), 'mt_allow_comments' => new xmlrpcval($allow_comments, 'int'), 'mt_allow_pings' => new xmlrpcval($allow_pings, 'int'), 'mt_convert_breaks' => new xmlrpcval('true'), 'mt_text_more' => new xmlrpcval(mb_conv($post['extended'], "UTF-8", "auto")));
            $resp = new xmlrpcval($resp, 'struct');
            return new xmlrpcresp($resp);
        } else {
            return new xmlrpcresp(0, $xmlrpcerruser + 3, "No such post #{$post_ID}");
        }
    } else {
        return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password));
    }
}
Ejemplo n.º 18
0
 public static function get_embed_post()
 {
     global $embed_post, $post, $wp_query;
     if ($embed_post) {
         return $embed_post;
     }
     if (!rgempty("gform_embed_post")) {
         $post_id = absint(rgpost("gform_embed_post"));
         $embed_post = get_postdata($post_id);
     } else {
         if ($wp_query->is_in_loop) {
             $embed_post = $post;
         } else {
             $embed_post = array();
         }
     }
     /*
     global $embed_post;
     
     
     $query = new WP_Query();
     $embed_posts = $query->query($_SERVER["QUERY_STRING"]);
     
     $embed_post = $embed_posts ? self::object_to_array($embed_posts[0]) : array();
     
     return $embed_post;
     */
 }
function single_post_title($prefix = '', $display = true)
{
    global $p, $name, $wpdb, $wp_id;
    if (intval($p) || '' != $name) {
        if (!$p) {
            $p = $wpdb->get_var("SELECT ID FROM {$wpdb->posts[$wp_id]} WHERE post_name = '{$name}'");
        }
        $post_data = get_postdata($p);
        $title = $post_data['Title'];
        $title = apply_filters('single_post_title', $title);
        if ($display) {
            echo $prefix . strip_tags(stripslashes($title));
        } else {
            return strip_tags(stripslashes($title));
        }
    }
}
Ejemplo n.º 20
0
	<?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>

	<?php 
        // This also populates the iconsize for the next line
        $attachment_link = get_the_attachment_link($post->ID, true, array(450, 800));
        // This lets us style narrow icons specially
        if (get_bloginfo('version') < 2.1) {
            $_post =& get_post($post->ID);
            $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment';
        } else {
            $_post =& get_postdata($post->ID);
            $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment';
        }
        ?>
		
		
	
				<div id="post-<?php 
        the_ID();
        ?>
" class="<?php 
        redo_post_class();
        ?>
">
					<div class="entry-head">
						<h3 class="entry-title"><a href="<?php