/** * The ping method modified to use our enclosure method over WordPress' */ function do_all_pings() { global $wpdb; // Do pingbacks while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); pingback($ping->post_content, $ping->ID); } # Do enclosures if enabled, and if doing enclosures, use our custom method if (get_option('pod_disable_enclose') != 'yes') { // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_encloseme';", $enclosure->ID)); $this->do_enclose($enclosure->post_content, $enclosure->ID); } } // Do Trackbacks $trackbacks = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE to_ping <> '' AND post_status = 'publish'"); if (is_array($trackbacks)) { foreach ($trackbacks as $trackback) { do_trackbacks($trackback); } } //Do Update Services/Generic Pings generic_ping(); }
function wp_insert_post($postarr = array()) { global $wpdb, $allowedtags; // export array as variables extract($postarr); $post_name = sanitize_title($post_title); $post_author = (int) $post_author; // Make sure we set a valid category if (0 == count($post_category) || !is_array($post_category)) { $post_category = array(get_option('default_category')); } $post_cat = $post_category[0]; if (empty($post_date)) { $post_date = current_time('mysql'); } // Make sure we have a good gmt date: if (empty($post_date_gmt)) { $post_date_gmt = get_gmt_from_date($post_date); } if (empty($comment_status)) { $comment_status = get_settings('default_comment_status'); } if (empty($ping_status)) { $ping_status = get_settings('default_ping_status'); } if (empty($post_parent)) { $post_parent = 0; } if ('publish' == $post_status) { $post_name_check = $wpdb->get_var("SELECT post_name FROM {$wpdb->posts} WHERE post_name = '{$post_name}' AND post_status = 'publish' AND ID != '{$post_ID}' LIMIT 1"); if ($post_name_check) { $suffix = 2; while ($post_name_check) { $alt_post_name = $post_name . "-{$suffix}"; $post_name_check = $wpdb->get_var("SELECT post_name FROM {$wpdb->posts} WHERE post_name = '{$alt_post_name}' AND post_status = 'publish' AND ID != '{$post_ID}' LIMIT 1"); $suffix++; } $post_name = $alt_post_name; } } $sql = "INSERT INTO {$wpdb->posts} \n\t\t(post_author, post_date, post_date_gmt, post_modified, post_modified_gmt, post_content, post_title, post_excerpt, post_category, post_status, post_name, comment_status, ping_status, post_parent) \n\t\tVALUES ('{$post_author}', '{$post_date}', '{$post_date_gmt}', '{$post_date}', '{$post_date_gmt}', '{$post_content}', '{$post_title}', '{$post_excerpt}', '{$post_cat}', '{$post_status}', '{$post_name}', '{$comment_status}', '{$ping_status}', '{$post_parent}')"; $result = $wpdb->query($sql); $post_ID = $wpdb->insert_id; // Set GUID $wpdb->query("UPDATE {$wpdb->posts} SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '{$post_ID}'"); wp_set_post_cats('', $post_ID, $post_category); if ($post_status == 'publish') { do_action('publish_post', $post_ID); } pingback($content, $post_ID); // Return insert_id if we got a good result, otherwise return zero. return $result ? $post_ID : 0; }
function execute_all_pings() { global $wpdb; // Do pingbacks while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); pingback($ping->post_content, $ping->ID); echo "Pingback: {$ping->post_title} : {$ping->ID}<br/>"; } // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); do_enclose($enclosure->post_content, $enclosure->ID); echo "Enclosure: {$enclosure->post_title} : {$enclosure->ID}<br/>"; } // Do Trackbacks while ($trackback = $wpdb->get_row("SELECT ID FROM {$wpdb->posts} WHERE TRIM(to_ping) != '' AND post_status != 'draft' LIMIT 1")) { echo "Trackback : {$trackback->ID}<br/>"; do_trackbacks($trackback->ID); } }
function mweditpost($params) { // ($postid, $user, $pass, $content, $publish) $xpostid = $params->getParam(0); $xuser = $params->getParam(1); $xpass = $params->getParam(2); $xcontent = $params->getParam(3); $xpublish = $params->getParam(4); $ID = intval($xpostid->scalarval()); $username = $xuser->scalarval(); $password = $xpass->scalarval(); $contentstruct = php_xmlrpc_decode($xcontent); $postarr['post_status'] = $xpublish->scalarval() ? 'publish' : 'draft'; // Check login if (user_pass_ok($username, $password)) { $postdata = wp_get_single_post($ID, ARRAY_A); if (!$postdata) { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 2, "No such post '{$ID}'."); } $userdata = get_userdatabylogin($username); if ($userdata->user_level < 1) { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 1, 'Sorry, level 0 users can not edit posts'); } if ($userdata->ID != $postdata['post_author'] && $userdata->user_level != 10) { $authordata = get_userdata($postdata['post_author']); if ($userdata->user_level <= $authordata->user_level) { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 1, 'Sorry, you do not have the right to edit this post'); } } $postarr['ID'] = $ID; if (array_key_exists('title', $contentstruct)) { $postarr['post_title'] = $contentstruct['title']; logIO('O', $contentstruct['title']); } if (array_key_exists('description', $contentstruct)) { $postarr['post_content'] = format_to_post($contentstruct['description']); logIO('O', $contentstruct['description']); } if (array_key_exists('mt_excerpt', $contentstruct)) { $postarr['post_excerpt'] = $contentstruct['mt_excerpt']; } if (array_key_exists('mt_text_more', $contentstruct)) { if (trim(format_to_post($contentstruct['mt_text_more']))) { $postarr['post_content'] .= "\n<!--more-->\n" . format_to_post($contentstruct['mt_text_more']); } } if (array_key_exists('mt_allow_comments', $contentstruct)) { $postarr['comment_status'] = $contentstruct['mt_allow_comments'] ? 'open' : 'closed'; } if (array_key_exists('mt_allow_pings', $contentstruct)) { $postarr['ping_status'] = $contentstruct['mt_allow_pings'] ? 'open' : 'closed'; } if (!empty($contentstruct['dateCreated'])) { $dateCreated = preg_split('/([+\\-Z])/', $contentstruct['dateCreated'], -1, PREG_SPLIT_DELIM_CAPTURE); if (count($dateCreated) == 3) { $dateCreated[2] = str_replace(':', '', $dateCreated[2]); } if ($dateCreated[1] == '+') { $dateoffset = intval($dateCreated[2]) * 36; } else { if ($dateCreated[1] == '-') { $dateoffset = -intval($dateCreated[2]) * 36; } else { $dateoffset = 0; } } $dateCreated = iso8601_decode($dateCreated[0], 1) - $dateoffset + get_settings('time_difference') * 3600; } else { $dateCreated = current_time('timestamp', 0); } $postarr['post_date'] = date('Y-m-d H:i:s', $dateCreated); $postarr['post_category'] = array(); if (array_key_exists('categories', $contentstruct) && is_array($contentstruct['categories'])) { foreach ($contentstruct['categories'] as $cat) { $postarr['post_category'][] = get_cat_ID(mb_conv($cat), 'EUC-JP', 'auto'); } } else { $postarr['post_category'][] = $GLOBALS['post_default_category']; } $post_ID = wp_update_post($postarr); if (!$post_ID) { return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 2, 'For some strange yet very annoying reason, your entry could not be posted.'); } if (empty($GLOBALS['blog_ID'])) { $GLOBALS['blog_ID'] = 1; } pingWeblogs($GLOBALS['blog_ID']); pingback($postarr['post_content'], $post_ID); if (array_key_exists('mt_tb_ping_urls', $contentstruct)) { trackback_url_list($content_struct['mt_tb_ping_urls'], $post_ID); } logIO('O', "(MW) Edited ! ID: {$post_ID}"); $myResp = new xmlrpcval(true, 'boolean'); return new xmlrpcresp($myResp); } else { logIO('O', "(MW) Wrong username/password combination <b>{$username} / {$password}</b>"); return new xmlrpcresp(0, $GLOBALS['xmlrpcerruser'] + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password)); } }
/** * Perform all pingbacks, enclosures, trackbacks, and send to pingback services. * * @since 2.1.0 * @uses $wpdb */ function do_all_pings() { global $wpdb; // Do pingbacks while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { $mid = $wpdb->get_var("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme' LIMIT 1"); do_action('delete_postmeta', $mid); $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_id = %d", $mid)); do_action('deleted_postmeta', $mid); pingback($ping->post_content, $ping->ID); } // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { $mid = $wpdb->get_var($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_encloseme'", $enclosure->ID)); do_action('delete_postmeta', $mid); $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_id = %d", $mid)); do_action('deleted_postmeta', $mid); do_enclose($enclosure->post_content, $enclosure->ID); } // Do Trackbacks $trackbacks = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE to_ping <> '' AND post_status = 'publish'"); if (is_array($trackbacks)) { foreach ($trackbacks as $trackback) { do_trackbacks($trackback); } } //Do Update Services/Generic Pings generic_ping(); }
$location = 'post.php'; } header('Location: ' . $location); $postObject->assignCategories($post_category); // are we going from draft/private to published? if (($prev_status == 'draft' || $prev_status == 'private') && $post_status == 'publish') { if (get_settings('use_geo_positions') && $post_latf != null && $post_lonf != null) { pingGeoUrl(); } pingWeblogs(); pingBlogs(); } // end if moving from draft/private to published if ($post_status == 'publish') { if ($post_pingback) { pingback($postObject->getVar('post_content', 'e'), $post_ID); } do_action('publish_post', $post_ID); do_trackback($postObject, $useutf8); } // Meta Stuff if ($meta) { foreach ($meta as $key => $value) { update_meta($key, $value['key'], $value['value']); } } if ($deletemeta) { foreach ($deletemeta as $key => $value) { delete_meta($key); } }
function do_all_pings() { global $wpdb; // Do pingbacks while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); pingback($ping->post_content, $ping->ID); } // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); do_enclose($enclosure->post_content, $enclosure->ID); } // Do Trackbacks $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); if ( is_array($trackbacks) ) { foreach ( $trackbacks as $trackback ) do_trackbacks($trackback->ID); } //Do Update Services/Generic Pings generic_ping(); }
/** * Copy of WP's "generic_ping". * Uses another function to send the actual XML-RPC messages. * @param string $post_title Title of the post * @param integer $post_type Future post or current post */ function mbpoPingServices($post_title, $post_type) { global $wpdb; $this->already_pinged = array(); $this->_post_type = $post_type; if (strpos($post_title, '~#') !== false) { $post_id_title = explode('~#', $post_title); $this->_post_title = $post_id_title[1]; $this->_post_url = get_permalink($post_id_title[0]); } else { $this->_post_title = $post_title; $this->_post_url = ''; } if ($this->mbpo_wp_version >= 2.1) { // Do pingbacks $ping = $this->__mpoGetPingbackPost(); $this->__mpoDeletePingBack($ping->ID); pingback($ping->post_content, $ping->ID); // Do Enclosures $enclosure = $this->__mpoGetEnclosurePost(); $this->__mpoDeleteEnclosure($enclosure->ID); do_enclose($enclosure->post_content, $enclosure->ID); // Do Trackbacks $trackbacks = $this->__mpoGetTrackbacks(); if (is_array($trackbacks)) { foreach ($trackbacks as $trackback) { do_trackbacks($trackback->ID); } } } $services = get_option('mbp_ping_sites'); $services = preg_replace("|(\\s)+|", '$1', $services); $services = trim($services); if ('' != $services) { set_time_limit(300); $services = explode("\n", $services); foreach ($services as $service) { $this->mbpoSendXmlrpc($service); } } unset($this->already_pinged); set_time_limit(60); }
/** * Perform all pingbacks, enclosures, trackbacks, and send to pingback services. * * @since 2.1.0 * * @global wpdb $wpdb WordPress database abstraction object. */ function do_all_pings() { global $wpdb; // Do pingbacks while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { delete_metadata_by_mid('post', $ping->meta_id); pingback($ping->post_content, $ping->ID); } // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { delete_metadata_by_mid('post', $enclosure->meta_id); do_enclose($enclosure->post_content, $enclosure->ID); } // Do Trackbacks $trackbacks = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE to_ping <> '' AND post_status = 'publish'"); if (is_array($trackbacks)) { foreach ($trackbacks as $trackback) { do_trackbacks($trackback); } } //Do Update Services/Generic Pings generic_ping(); }
function mweditpost($params) { // ($postid, $user, $pass, $content, $publish) global $xmlrpcerruser; $xpostid = $params->getParam(0); $xuser = $params->getParam(1); $xpass = $params->getParam(2); $xcontent = $params->getParam(3); $xpublish = $params->getParam(4); $ID = $xpostid->scalarval(); $username = $xuser->scalarval(); $password = $xpass->scalarval(); $contentstruct = xmlrpc_decode1($xcontent); $postdata = wp_get_single_post($ID); if (!$postdata) { return new xmlrpcresp(0, $xmlrpcerruser + 2, "No such post {$ID}."); } $userdata = get_userdatabylogin($username); $user_ID = $userdata->ID; $user_level = $userdata->user_level; $post_author_ID = $postdata->post_author; $post_authordata = get_userdata($post_author_ID); if ($user_ID != $post_author_ID && $user_level <= $post_authordata->user_level) { return new xmlrpcresp(0, $xmlrpcerruser + 1, "Sorry, you do not have the right to edit this post."); } // Check login if (user_pass_ok($username, $password)) { if ($user_level < 1) { return new xmlrpcresp(0, $xmlrpcerruser + 1, "Sorry, level 0 users cannot edit posts"); } extract($postdata); $post_title = $contentstruct['title']; $post_content = format_to_post($contentstruct['description']); $catnames = $contentstruct['categories']; logIO("O", "Cat Count" . count($catnames)); foreach ($catnames as $cat) { $post_category[] = get_cat_ID($cat); } $post_excerpt = $contentstruct['mt_excerpt']; $post_more = $contentstruct['mt_text_more']; $post_status = $xpublish->scalarval() ? 'publish' : 'draft'; if ($post_more) { $post_content = $post_content . "\n<!--more-->\n" . $post_more; } $comment_status = 1 == $contentstruct['mt_allow_comments'] ? 'open' : 'closed'; $ping_status = $contentstruct['mt_allow_pings'] ? 'open' : 'closed'; $time_difference = get_settings("time_difference"); $dateCreated = $contentstruct['dateCreated']; $dateCreated = $dateCreated ? iso8601_decode($contentstruct['dateCreated']) : time() + $time_difference * 3600; $post_date = date("Y-m-d H:i:s", $dateCreated); // We've got all the data -- post it: $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date'); $newpost_ID = wp_update_post($newpost); if (!$newpost_ID) { return new xmlrpcresp(0, $xmlrpcerruser + 2, "For some strange yet very annoying reason, your entry could not be posted."); } if (!isset($blog_ID)) { $blog_ID = 1; } if (isset($sleep_after_edit) && $sleep_after_edit > 0) { sleep($sleep_after_edit); } pingWeblogs($blog_ID); pingCafelog($cafelogID, $post_title, $post_ID); pingBlogs($blog_ID); pingback($content, $post_ID); trackback_url_list($content_struct['mt_tb_ping_urls'], $post_ID); logIO("O", "(MW) Edited ! ID: {$post_ID}"); $myResp = new xmlrpcval($ID, "string"); return new xmlrpcresp($myResp); } else { logIO("O", "(MW) Wrong username/password combination <b>{$username} / {$password}</b>"); return new xmlrpcresp(0, $xmlrpcerruser + 3, 'Wrong username/password combination ' . $username . ' / ' . starify($password)); } }
function wp_mail_receive() { global $xoopsDB, $wpdb, $wp_id, $siteurl; require_once ABSPATH . WPINC . '/class-pop3.php'; timer_start(); $use_cache = 1; $time_difference = get_settings('time_difference'); // Get Server Time Zone // If Server Time Zone is not collect, Please comment out following line; $server_timezone = date("O"); // echo "Server TimeZone is ".date('O')."<br />"; // If Server Time Zone is not collect, Please uncomment following line and set collect timezone value; // $server_timezone = "+0900"; //This is a sample value for JST+0900 $server_timezone = $server_timezone / 100; $weblog_timezone = $server_timezone + $time_difference; error_reporting(2037); $pop3 = new POP3(); if (!$pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) { echo "Ooops {$pop3->ERROR} <br />\n"; return; } $Count = $pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass')); if (!$Count || $Count == -1) { echo "<h1>Login Failed: {$pop3->ERROR}</h1>\n"; $pop3->quit(); return; } // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT! // register_shutdown_function($pop3->quit()); for ($iCount = 1; $iCount <= $Count; $iCount++) { $MsgOne = $pop3->get($iCount); if (!$MsgOne || gettype($MsgOne) != 'array') { echo "oops, {$pop3->ERROR}<br />\n"; $pop3->quit(); return; } $content = ''; $content_type = ''; $boundary = ''; $att_boundary = ''; $hatt_boundary = ''; $bodysignal = 0; $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); while (list($lineNum, $line) = each($MsgOne)) { if (strlen($line) < 3) { $bodysignal = 1; } if ($bodysignal) { $content .= $line; } else { if (preg_match('/Content-Type: /i', $line)) { $content_type = trim($line); $content_type = substr($content_type, 14, strlen($content_type) - 14); $content_type = explode(';', $content_type); $content_type = strtolower($content_type[0]); } if ($content_type == 'multipart/mixed' && preg_match('/boundary="/', $line) && $att_boundary == '') { $att_boundary = trim($line); $att_boundary = explode('"', $att_boundary); $att_boundary = $att_boundary[1]; } if ($content_type == 'multipart/alternative' && preg_match('/boundary="/', $line) && $boundary == '') { $boundary = trim($line); $boundary = explode('"', $boundary); $boundary = $boundary[1]; } if ($content_type == 'multipart/related' && preg_match('/boundary="/', $line) && $hatt_boundary == '') { $hatt_boundary = trim($line); $hatt_boundary = explode('"', $hatt_boundary); $hatt_boundary = $hatt_boundary[1]; } if (preg_match('/Subject: /', $line)) { $subject = trim($line); $subject = substr($subject, 9, strlen($subject) - 9); if (function_exists('mb_decode_mimeheader')) { $subject1 = mb_decode_mimeheader($subject); if ($subject != $subject) { $sub_charset = mb_internal_encoding(); } else { $sub_charset = "auto"; } $subject = $subject1; } if (get_settings('use_phoneemail')) { $subject = explode(get_settings('phoneemail_separator'), $subject); $subject = trim($subject[0]); } } if (preg_match('/Date: /', $line)) { // of the form '20 Mar 2002 20:32:37' $ddate = trim($line); $ddate = str_replace('Date: ', '', $ddate); if (strpos($ddate, ',')) { $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate))); } $date_arr = explode(' ', $ddate); $date_time = explode(':', $date_arr[3]); $ddate_H = $date_time[0]; $ddate_i = $date_time[1]; $ddate_s = $date_time[2]; $ddate_m = $date_arr[1]; $ddate_d = $date_arr[0]; $ddate_Y = $date_arr[2]; $mail_timezone = trim(ereg_replace("\\([^)]*\\)", "", $date_arr[4])) / 100; // echo "Email TimeZone is {$date_arr[4]}<br />"; $mail_time_difference = $weblog_timezone - $mail_timezone; for ($i = 0; $i < 12; $i++) { if ($ddate_m == $dmonths[$i]) { $ddate_m = $i + 1; } } $ddate_U = mktime($ddate_H, $ddate_i, $ddate_s, $ddate_m, $ddate_d, $ddate_Y); $ddate_U = $ddate_U + $mai_time_difference * 3600; $post_date = date('Y-m-d H:i:s', $ddate_U); } } } if (!ereg(get_settings('subjectprefix'), $subject)) { continue; } $charset = ""; $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $ddate_today = time() + $time_difference * 3600; $ddate_difference_days = ($ddate_today - $ddate_U) / 86400; // starts buffering the output if ($ddate_difference_days > 14) { echo "Too old<br />\n"; continue; } if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) { $userpassstring = ''; echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n"; echo "<p><b>{$iCount}</b></p><p><b>Subject: </b>{$subject}</p>\n"; $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject)); $attachment = false; if ($att_boundary != "") { $contents = explode('--' . $att_boundary, $content); $content = $contents[1]; $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $content = explode("\r\n\r\n", $content, 2); $content = $content[1]; } if ($hatt_boundary != "") { $contents = explode('--' . $hatt_boundary, $content); $content = $contents[1]; if (preg_match('/Content-Type: multipart\\/alternative\\;[^"]*"([^"]*)"/i', $content, $matches)) { $boundary = trim($matches[0]); $boundary = explode('"', $boundary); $boundary = $boundary[1]; $content = explode('--' . $boundary, $content); $content = $content[2]; } $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $content = explode('Content-Transfer-Encoding: quoted-printable', $content); $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>'); } else { if ($boundary != "") { $content = explode('--' . $boundary, $content); $content = $content[2]; if (preg_match('/Content-Type: multipart\\/related\\;[^"]*"([^"]*)"/i', $content, $matches)) { $hatt_boundary = trim($matches[0]); $hatt_boundary = explode('"', $hatt_boundary); $hatt_boundary = $hatt_boundary[1]; $contents = explode('--' . $hatt_boundary, $content); $content = $contents[1]; } $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $content = explode('Content-Transfer-Encoding: quoted-printable', $content); $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>'); } } $content = trim($content); echo "<p><b>Content-type:</b> {$content_type}, <b>boundary:</b> {$boundary}</p>\n"; echo "<p><b>att_boundary:</b> {$att_boundary}, <b>hatt_boundary:</b> {$hatt_boundary}</p>\n"; echo "<p><b>charset:<b>{$charset}</p>\n"; // echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>'; $btpos = strpos($content, get_settings('bodyterminator')); if ($btpos) { $content = substr($content, 0, $btpos); } $content = trim($content); $blah = explode("\n", preg_replace("/^[\n\r\\s]*/", "", strip_tags($content))); $firstline = preg_replace("/[\n\r]/", "", $blah[0]); $secondline = $blah[1]; if (get_settings('use_phoneemail')) { $btpos = strpos($firstline, get_settings('phoneemail_separator')); if ($btpos) { $userpassstring = trim(substr($firstline, 0, $btpos)); $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content))); $btpos = strpos($content, get_settings('phoneemail_separator')); if ($btpos) { $userpassstring = trim(substr($content, 0, $btpos)); $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content))); } } $contentfirstline = $blah[1]; } else { $userpassstring = strip_tags($firstline); $contentfirstline = ''; } $flat = 999.0; $flon = 999.0; $secondlineParts = explode(':', strip_tags($secondline)); if (strncmp($secondlineParts[0], "POS", 3) == 0) { echo "Found POS:<br>\n"; // echo "Second parts is:".$secondlineParts[1]; // the second line is the postion listing line $secLineParts = explode(',', $secondlineParts[1]); $flatStr = $secLineParts[0]; $flonStr = $secLineParts[1]; // echo "String are ".$flatStr.$flonStr; $flat = floatval($secLineParts[0]); $flon = floatval($secLineParts[1]); // echo "values are ".$flat." and ".$flon; // ok remove that position... we should not have it in the final output $content = str_replace($secondline, '', $content); } $blah = explode(':', $userpassstring); $user_login = $blah[0]; $user_pass = $blah[1]; $content = $contentfirstline . str_replace($firstline, '', $content); $content = trim($content); // Please uncomment following line, only if you want to check user and password. // echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>"; if ($xoopsDB) { $sql = "SELECT ID, user_level FROM {$wpdb->users[$wp_id]} WHERE user_login='******' ORDER BY ID DESC LIMIT 1"; $result = $wpdb->get_row($sql); if (!$result) { echo "<p><b>Wrong login</b></p></div>\n"; continue; } else { $sql = "SELECT * FROM " . $xoopsDB->prefix('users') . " WHERE uname='" . trim($user_login) . "' AND pass='******' ORDER BY uid DESC LIMIT 1"; $result1 = $wpdb->get_row($sql); if (!$result1) { echo "<p><b>Wrong password.</b></p></div>\n"; continue; } } } else { $sql = "SELECT ID, user_level FROM {$wpdb->users[$wp_id]} WHERE user_login='******' AND user_pass='******' ORDER BY ID DESC LIMIT 1"; $result = $wpdb->get_row($sql); if (!$result) { echo "<p><b>Wrong login or password.</b></p></div>\n"; continue; } } $user_level = $result->user_level; $post_author = $result->ID; if ($user_level > 0) { $post_title = xmlrpc_getposttitle($content); if ($post_title == '') { $post_title = $subject; } $post_category = get_settings('default_category'); if (preg_match('/<category>(.+?)<\\/category>/is', $content, $matchcat)) { $post_category = xmlrpc_getpostcategory($content); } if ($post_category == '') { $post_category = get_settings('default_post_category'); } if (function_exists('mb_convert_encoding')) { echo "Subject : " . mb_convert_encoding($subject, $blog_charset, $sub_charset) . " <br />\n"; } else { echo "Subject : " . $subject . " <br />\n"; } echo "Category : {$post_category} <br />\n"; if (!get_settings('emailtestonly')) { // Attaching Image Files Save if ($att_boundary != "") { $attachment = wp_getattach($contents[2], trim($user_login), 1); } if ($boundary != "" && $hatt_boundary != "") { for ($i = 2; $i < count($contents); $i++) { $hattachment = wp_getattach($contents[$i], trim($user_login), 0); if ($hattachment) { if (preg_match("/Content-Id: \\<([^\\>]*)>/i", $contents[$i], $matches)) { $content = preg_replace("/(cid:" . preg_quote($matches[1]) . ")/", "{$siteurl}/attach/" . $hattachment, $content); } } } } if ($boundary != "") { $content = preg_replace("/\\=[\r\n]/", "", $content); $content = preg_replace("/[\r\n]/", " ", $content); } $content = preg_replace("|\n([^\n])|", " \$1", $content); if ($charset == "" || trim($charset == "ISO-2022-JP")) { $charset = "JIS"; } if (trim($charset) == "Shift_JIS") { $charset = "SJIS"; } $content = preg_replace("/\\=([0-9a-fA-F]{2,2})/e", "pack('c',base_convert('\\1',16,10))", $content); if (function_exists('mb_convert_encoding')) { $content = addslashes(mb_convert_encoding(trim($content), $blog_charset, $charset)); $post_title = addslashes(trim(mb_convert_encoding($post_title, $blog_charset, $sub_charset))); } else { $content = addslashes(trim($content)); $post_title = addslashes(trim($post_title)); } // If we find an attachment, add it to the post if ($attachment) { if (file_exists("attach/thumb-" . $attachment)) { $content = "<a href=\"" . $siteurl . "/attach/" . $attachment . "\"><img style=\"float: left;\" hspace=\"6\" src = \"" . $siteurl . "/attach/thumb-" . $attachment . "\" alt=\"moblog\" ></a>" . $content . "<br clear=left>"; } else { $content = "<a href=\"" . $siteurl . "/attach/" . $attachment . "\"><img style=\"float: left;\" hspace=\"6\" src = \"" . $siteurl . "/attach/" . $attachment . "\" alt=\"moblog\" ></a>" . $content . "<br clear=left>"; } } if ($flat > 500) { $sql = "INSERT INTO {$wpdb->posts[$wp_id]} (post_author, post_date, post_content, post_title, post_category) VALUES ({$post_author}, '{$post_date}', '{$content}', '{$post_title}', {$post_category})"; } else { $sql = "INSERT INTO {$wpdb->posts[$wp_id]} (post_author, post_date, post_content, post_title, post_category, post_lat, post_lon) VALUES ({$post_author}, '{$post_date}', '{$content}', '{$post_title}', {$post_category}, {$flat}, {$flon})"; } $result = $wpdb->query($sql); $post_ID = $wpdb->insert_id; echo "Post ID = {$post_ID}<br />\n"; if (isset($sleep_after_edit) && $sleep_after_edit > 0) { sleep($sleep_after_edit); } $blog_ID = 1; if ($flat < 500) { pingGeoUrl($post_ID); } // Double check it's not there already $exists = $wpdb->get_row("SELECT * FROM {$wpdb->post2cat[$wp_id]} WHERE post_id = {$post_ID} AND category_id = {$post_category}"); if (!$exists && $result) { $wpdb->query("\n\t\t\t\t\t\tINSERT INTO {$wpdb->post2cat[$wp_id]}\n\t\t\t\t\t\t(post_id, category_id)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t({$post_ID}, {$post_category})\n\t\t\t\t\t\t"); } pingWeblogs($blog_ID); pingBlogs($blog_ID); pingback($content, $post_ID); do_action('publish_post', $post_ID); do_action('publish_phone', $post_ID); } echo "\n<p><b>Posted title:</b> {$post_title}<br />\n"; echo "<b>Posted content:</b><br /><pre>" . $content . "</pre></p>\n"; if (!$pop3->delete($iCount)) { echo "<p>Oops " . $pop3->ERROR . "</p></div>\n"; $pop3->reset(); return; } else { echo "<p>Mission complete, message <strong>{$iCount}</strong> deleted.</p>\n"; } } else { echo "<p><strong>Level 0 users can\\'t post.</strong></p>\n"; } echo "</div>\n"; } } $pop3->quit(); timer_stop($output_debugging_info); return; }
/** * Copy of WP's "generic_ping". * Uses another function to send the actual XML-RPC messages. * @param string $post_title Title of the post * @param integer $post_type Future post or current post */ function mbpoPingServices($post_title, $post_type) { global $wpdb; $this->already_pinged = array(); $this->_post_type = $post_type; if (strpos($post_title, '~#') !== false) { $post_id_title = explode('~#', $post_title); $this->_post_title = $post_id_title[1]; $this->_post_url = get_permalink($post_id_title[0]); } else { $this->_post_title = $post_title; $this->_post_url = ''; } if ($this->mbpo_wp_version >= 2.1) { // Do pingbacks while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); pingback($ping->post_content, $ping->ID); } // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); do_enclose($enclosure->post_content, $enclosure->ID); } // Do Trackbacks $trackbacks = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'"); if (is_array($trackbacks)) { foreach ($trackbacks as $trackback) { do_trackbacks($trackback->ID); } } } $services = get_settings('ping_sites'); $services = preg_replace("|(\\s)+|", '$1', $services); $services = trim($services); if ('' != $services) { set_time_limit(300); $services = explode("\n", $services); foreach ($services as $service) { $this->mbpoSendXmlrpc($service); } } unset($this->already_pinged); set_time_limit(60); }
/** * Processes an item: parses and filters * @param $feed object Feed database object * @param $item object SimplePie_Item object * @return true si lo procesó */ function processItem(&$feed, &$item, $feedurl) { global $wpdb, $realcount; trigger_error(sprintf(__('Processing item %1s', WPeMatico::TEXTDOMAIN), $item->get_title()), E_USER_NOTICE); // First exclude filters if ($this->exclude_filters($this->current_item, $this->campaign, $feed, $item)) { return -1; } //********** Do parses contents and titles $this->current_item = $this->Item_parsers($this->current_item, $this->campaign, $feed, $item, $realcount, $feedurl); if ($this->current_item == -1) { return -1; } // Item date $itemdate = $item->get_date('U'); if ($this->campaign['campaign_feeddate'] && ($itemdate > $this->campaign['lastrun'] && $itemdate < current_time('timestamp', 1))) { $this->current_item['date'] = $itemdate; trigger_error(__('Assigning original date to post.', WPeMatico::TEXTDOMAIN), E_USER_NOTICE); } else { $this->current_item['date'] = null; trigger_error(__('Original date out of range. Assigning current date to post.', WPeMatico::TEXTDOMAIN), E_USER_NOTICE); } // Primero proceso las categorias si las hay y las nuevas las agrego al final del array $this->current_item['categories'] = (array) $this->campaign['campaign_categories']; if ($this->campaign['campaign_autocats']) { if ($autocats = $item->get_categories()) { trigger_error(__('Assigning Auto Categories.', WPeMatico::TEXTDOMAIN), E_USER_NOTICE); foreach ($autocats as $id => $catego) { $catname = $catego->term; if (!empty($catname)) { //$this->current_item['categories'][] = wp_create_category($catname); //Si ya existe devuelve el ID existente // wp_insert_category(array('cat_name' => $catname)); // $term = term_exists($catname, 'category'); if ($term !== 0 && $term !== null) { // ya existe trigger_error(__('Category exist: ', WPeMatico::TEXTDOMAIN) . $catname, E_USER_NOTICE); } else { //si no existe la creo trigger_error(__('Adding Category: ', WPeMatico::TEXTDOMAIN) . $catname, E_USER_NOTICE); $arg = array('description' => __("Auto Added by WPeMatico", WPeMatico::TEXTDOMAIN), 'parent' => "0"); $term = wp_insert_term($catname, "category", $arg); } $this->current_item['categories'][] = $term['term_id']; } } } } $this->current_item['posttype'] = $this->campaign['campaign_posttype']; $this->current_item['allowpings'] = $this->campaign['campaign_allowpings']; $this->current_item['commentstatus'] = $this->campaign['campaign_commentstatus']; $this->current_item['customposttype'] = $this->campaign['campaign_customposttype']; //********** Do filters $this->current_item = $this->Item_filters($this->current_item, $this->campaign, $feed, $item); //ACA ARMO EL ARRAY DE IMAGENES Y MODIFICO EL CONTENT QUE APUNTEN BIEN $this->current_item = $this->Item_images($this->current_item, $this->campaign, $feed, $item); // Meta $this->current_item['meta'] = array('wpe_campaignid' => $this->campaign_id, 'wpe_feed' => $feed->feed_url, 'wpe_sourcepermalink' => $this->getReadUrl($item->get_permalink())); if ($this->cfg['nonstatic']) { $this->current_item['images'] = NoNStatic::img1s($this->current_item, $this->campaign, $item); } $this->current_item = $this->Item_parseimg($this->current_item, $this->campaign, $feed, $item); if ($this->cfg['nonstatic']) { $this->current_item = NoNStatic::metaf($this->current_item, $this->campaign, $feed, $item); } // escape the content ?? //$this->current_item['content'] = $wpdb->escape($this->current_item['content']); if ($this->cfg['nonstatic']) { $this->current_item['campaign_tags'] = $this->current_item['tags']; } // Create post $postid = $this->insertPost($this->current_item['title'], $this->current_item['content'], $this->current_item['date'], $this->current_item['categories'], $this->current_item['posttype'], $this->current_item['author'], $this->current_item['allowpings'], $this->current_item['commentstatus'], $this->current_item['meta'], $this->current_item['customposttype'], $this->current_item['images'], $this->current_item['campaign_tags']); // Attaching images uploaded to created post in media library if (!$this->campaign['campaign_cancel_imgcache']) { if (($this->cfg['imgcache'] || $this->campaign['campaign_imgcache']) && $this->cfg['imgattach']) { if (is_array($this->current_item['images'])) { if (sizeof($this->current_item['images'])) { // Si hay alguna imagen trigger_error(__('Attaching images', WPeMatico::TEXTDOMAIN) . ": " . sizeof($this->current_item['images']), E_USER_NOTICE); $custom_imagecount = 0; if (!empty($this->current_item['nofeatimg'])) { $custom_imagecount = 1; trigger_error('<strong>' . __('Skip Featured Image.', WPeMatico::TEXTDOMAIN) . '</strong>', E_USER_NOTICE); } foreach ($this->current_item['images'] as $imagen_src) { $attachid = $this->insertfileasattach($imagen_src, $postid); if ($custom_imagecount == 0 && $this->cfg['featuredimg']) { trigger_error(__('Featured Image Into Post.', WPeMatico::TEXTDOMAIN), E_USER_NOTICE); set_post_thumbnail($postid, $attachid); //add_post_meta($postid, '_thumbnail_id', $attachid); $custom_imagecount++; } } } } } } // If pingback/trackbacks if ($this->campaign['campaign_allowpings']) { trigger_error(__('Processing item pingbacks', WPeMatico::TEXTDOMAIN), E_USER_NOTICE); require_once ABSPATH . WPINC . '/comment.php'; pingback($this->current_item['content'], $postid); } }
function mw_editPost($args) { global $wpdb, $post_default_category; $this->escape($args); $post_ID = $args[0]; $user_login = $args[1]; $user_pass = $args[2]; $content_struct = $args[3]; $publish = $args[4]; if (!$this->login_pass_ok($user_login, $user_pass)) { return $this->error; } $user_data = get_userdatabylogin($user_login); if (!user_can_edit_post($user_data->ID, $post_ID)) { return new IXR_Error(401, 'Sorry, you can not edit this post.'); } $postdata = wp_get_single_post($post_ID, ARRAY_A); extract($postdata); $this->escape($postdata); $post_title = $content_struct['title']; $post_content = apply_filters('content_save_pre', $content_struct['description']); $catnames = $content_struct['categories']; $post_category = array(); if (is_array($catnames)) { foreach ($catnames as $cat) { $post_category[] = get_cat_ID($cat); } } $post_excerpt = $content_struct['mt_excerpt']; $post_more = $content_struct['mt_text_more']; $post_status = $publish ? 'publish' : 'draft'; if ($post_more) { $post_content = $post_content . "\n<!--more-->\n" . $post_more; } $to_ping = $content_struct['mt_tb_ping_urls']; $comment_status = empty($content_struct['mt_allow_comments']) ? get_settings('default_comment_status') : $content_struct['mt_allow_comments']; $ping_status = empty($content_struct['mt_allow_pings']) ? get_settings('default_ping_status') : $content_struct['mt_allow_pings']; // Do some timestamp voodoo $dateCreatedd = $content_struct['dateCreated']; if (!empty($dateCreatedd)) { $dateCreated = $dateCreatedd->getIso(); $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); $post_date_gmt = iso8601_to_datetime($dateCreated, GMT); } else { $post_date = $postdata['post_date']; $post_date_gmt = $postdata['post_date_gmt']; } // We've got all the data -- post it: $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping'); $result = wp_update_post($newpost); if (!$result) { return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.'); } logIO('O', "(MW) Edited ! ID: {$post_ID}"); // FIXME: do we pingback always? pingback($content, $post_ID); // trackback_url_list($content_struct['mt_tb_ping_urls'], $post_ID); if ('publish' == $post_status) { if ($post_pingback) { pingback($content, $post_ID); } do_enclose($content, $post_ID); do_trackbacks($post_ID); do_action('publish_post', $post_ID); } do_action('edit_post', $post_ID); return true; }
/** * Processes an item * * @param $campaign object Campaign database object * @param $feed object Feed database object * @param $item object SimplePie_Item object */ function processItem(&$campaign, &$feed, &$item) { global $wpdb; $this->log('Processing item'); // Item content // We can limit words by feed source's request via get_feedmeta($feed->id, 'string_limit'); // That way we can appease some people, but still have something more than one sentance for // feeds that don't mind. $content = $this->parseItemContent($campaign, $feed, $item); $content = strip_tags($content, '<img>'); $content = $this->string_limit_words($content, $this->get_feedmeta($feed->id, 'string_limit')); // Item date if ($campaign->feeddate && ($item->get_date('U') > current_time('timestamp', 1) - $campaign->frequency && $item->get_date('U') < current_time('timestamp', 1))) { $date = $item->get_date('U'); } else { $date = null; } $hash = $this->getItemHash($item); $test = $wpdb->get_var("SELECT post_id FROM " . $this->db['campaign_post'] . "\n \t\tWHERE hash ='" . $hash . "'"); // This post is already in here. if ($test) { return false; } // Categories $categories = $this->getCampaignData($campaign->id, 'categories'); $author_id = $this->processAuthor($item); // Meta $meta = array('wpo_campaignid' => $campaign->id, 'wpo_feedid' => $feed->id, 'wpo_sourcepermalink' => $item->get_permalink(), 'wpo_author' => $author_id); // Create post $post_id = $this->insertPost($wpdb->escape($item->get_title()), $wpdb->escape($content), $date, $categories, $campaign->posttype, $this->feeduser, $campaign->allowpings, $campaign->comment_status, $meta); // Save post to wpo table // if it fails delete post. This will help with preventing duplicate entries. $test = $wpdb->query(WPOTools::insertQuery($this->db['campaign_post'], array('campaign_id' => $campaign->id, 'feed_id' => $feed->id, 'post_id' => $post_id, 'hash' => $hash))); if (null == $wpdb->insert_id || !$wpdb->insert_id || 0 == $wpdb->insert_id || !$test) { // for testing only //error_log( wp_delete_post($post_id, true); return false; } // If pingback/trackbacks if ($campaign->dopingbacks) { $this->log('Processing item pingbacks'); require_once ABSPATH . WPINC . '/comment.php'; pingback($content, $postid); } return true; }
/** * Processes an item * * @param $campaign object Campaign database object * @param $feed object Feed database object * @param $item object SimplePie_Item object */ function processItem(&$campaign, &$feed, &$item) { global $wpdb; $this->log('Processing item'); // Item content $content = $this->parseItemContent($campaign, $feed, $item); // Item date // if($campaign->feeddate && ($item->get_date('U') > (current_time('timestamp', 1) - $campaign->frequency) && $item->get_date('U') < current_time('timestamp', 1))) if ($item->get_date('U') < current_time('timestamp', 1)) { $date = $item->get_date('U'); } else { $date = null; } // Categories $categories = $this->getCampaignData($campaign->id, 'categories'); // Meta $meta = array('wpo_campaignid' => $campaign->id, 'wpo_feedid' => $feed->id, 'wpo_sourcepermalink' => $item->get_permalink()); // Create post $postid = $this->insertPost($wpdb->escape($item->get_title()), $wpdb->escape($content), $date, $categories, $campaign->posttype, $campaign->authorid, $campaign->allowpings, $campaign->comment_status, $meta); // If pingback/trackbacks if ($campaign->dopingbacks) { $this->log('Processing item pingbacks'); require_once ABSPATH . WPINC . '/comment.php'; pingback($content, $postid); } // Save post to log database $wpdb->query(WPOTools::insertQuery($this->db['campaign_post'], array('campaign_id' => $campaign->id, 'feed_id' => $feed->id, 'post_id' => $postid, 'hash' => $this->getItemHash($item)))); }
<?php require_once '../wp-config.php'; // Do pingbacks while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); pingback($ping->post_content, $ping->ID); } // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';"); do_enclose($enclosure->post_content, $enclosure->ID); } // Do Trackbacks $trackbacks = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status != 'draft'"); if (is_array($trackbacks)) { foreach ($trackbacks as $trackback) { do_trackbacks($trackback->ID); } }
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)); } }
function wp_mail_receive() { global $wpdb, $wp_pop3, $img_target; require_once ABSPATH . WPINC . '/class-pop3.php'; timer_start(); $use_cache = 1; $time_difference = get_settings('time_difference'); $blog_charset = get_settings('blog_charset'); error_reporting(2037); $wp_pop3 = new POP3(); if (!$wp_pop3->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) { echo "Ooops {$wp_pop3->ERROR} <br />\n"; return; } $mail_count = $wp_pop3->login(get_settings('mailserver_login'), get_settings('mailserver_pass')); if ($mail_count == false) { if (!$wp_pop3->FP) { echo "Oooops Login Failed: {$wp_pop3->ERROR}<br />\n"; } else { echo "No Message<br />\n"; $wp_pop3->quit(); } return; } // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT! register_shutdown_function('wp_mail_quit'); for ($mail_num = 1; $mail_num <= $mail_count; $mail_num++) { $MsgOne = $wp_pop3->get($mail_num); if (!$MsgOne || gettype($MsgOne) != 'array') { echo "oops, {$wp_pop3->ERROR}<br />\n"; $wp_pop3->quit(); return; } $content = ''; $content_type = ''; $boundary = ''; $att_boundary = ''; $hatt_boundary = ''; $bodysignal = 0; $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); while (list($lineNum, $line) = each($MsgOne)) { if (strlen($line) < 3) { $bodysignal = 1; } if ($bodysignal) { $content .= $line; } else { if (preg_match('/^Content-Type:\\s+(.*?)\\;/i', $line, $match)) { $content_type = $match[1]; $content_type = strtolower($match[1]); } if ($content_type == 'multipart/mixed' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $att_boundary == '') { $att_boundary = trim($match[1]); } if ($content_type == 'multipart/alternative' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $boundary == '') { $boundary = trim($match[1]); } if ($content_type == 'multipart/related' && preg_match('/boundary=(?:")?([^;"\\s\\n]*?)(?:")?\\s*(?:$|;)/', $line, $match) && $hatt_boundary == '') { $hatt_boundary = trim($match[1]); } if (preg_match('/Subject: /', $line)) { $subject = trim($line); $subject = substr($subject, 9, strlen($subject) - 9); if (function_exists('mb_decode_mimeheader')) { $subject1 = mb_decode_mimeheader($subject); if ($subject != $subject) { $sub_charset = mb_internal_encoding(); } else { $sub_charset = "auto"; } $subject = $subject1; } if (get_settings('use_phoneemail')) { $subject = explode(get_settings('phoneemail_separator'), $subject); $subject = trim($subject[0]); } } if (preg_match('/Date: /', $line)) { // of the form '20 Mar 2002 20:32:37' $ddate = trim($line); $ddate = str_replace('Date: ', '', $ddate); if (strpos($ddate, ',')) { $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate))); } $ddate_U = strtotime($ddate) + $time_difference * 3600; $post_date = date('Y-m-d H:i:s', $ddate_U); } } } if (!ereg(get_settings('subjectprefix'), $subject)) { continue; } $charset = ""; $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $ddate_today = time() + $time_difference * 3600; $ddate_difference_days = ($ddate_today - $ddate_U) / 86400; if ($ddate_difference_days > 14) { echo "Too old<br />\n"; continue; } if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) { $userpassstring = ''; echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n"; echo "<p><b>{$mail_num}</b></p><p><b>Subject: </b>{$subject}</p>\n"; $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject)); $attachment = false; if ($att_boundary) { $contents = explode('--' . $att_boundary, $content); $content = $contents[1]; $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $content = explode("\r\n\r\n", $content, 2); $content = $content[1]; } if ($hatt_boundary) { $contents = explode('--' . $hatt_boundary, $content); $content = $contents[1]; if (preg_match('/Content-Type: multipart\\/alternative\\;\\s*boundary\\=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)"/i', $content, $matches)) { $boundary = trim($matches[1]); $content = explode('--' . $boundary, $content); $content = $content[2]; } $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $content = explode('Content-Transfer-Encoding: quoted-printable', $content); $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>'); } else { if ($boundary) { $content = explode('--' . $boundary, $content); $content = $content[2]; if (preg_match('/Content-Type: multipart\\/related\\;\\s*boundary=(?:")?([^";\\s\\n]*?)(?:")?\\s*(?:;|\\n|$)/i', $content, $matches)) { $hatt_boundary = trim($matches[1]); $contents = explode('--' . $hatt_boundary, $content); $content = $contents[1]; } $ncharset = preg_match("/charset=\"?([^\"]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $content = explode('Content-Transfer-Encoding: quoted-printable', $content); $content = strip_tags($content[1], '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td>'); } } $content = trim($content); echo "<p><b>Content-type:</b> {$content_type}, <b>boundary:</b> {$boundary}</p>\n"; echo "<p><b>att_boundary:</b> {$att_boundary}, <b>hatt_boundary:</b> {$hatt_boundary}</p>\n"; echo "<p><b>charset:</b>{$charset}, <b>BLOG charset:</b>{$blog_charset}</p>\n"; // echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>'; if ($charset == "" || trim(strtoupper($charset)) == "ISO-2022-JP") { $charset = "JIS"; } if (trim(strtoupper($charset)) == "SHIFT_JIS") { $charset = "SJIS"; } $btpos = strpos($content, get_settings('bodyterminator')); if ($btpos) { $content = substr($content, 0, $btpos); } $content = trim($content); $blah = explode("\n", preg_replace("/^[\n\r\\s]*/", "", strip_tags($content))); $firstline = preg_replace("/[\n\r]/", "", $blah[0]); $secondline = $blah[1]; if (get_settings('use_phoneemail')) { echo "<p><b>Use Phone Mail:</b> Yes</p>\n"; $btpos = strpos($firstline, get_settings('phoneemail_separator')); if ($btpos) { $userpassstring = trim(substr($firstline, 0, $btpos)); $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content))); $btpos = strpos($content, get_settings('phoneemail_separator')); if ($btpos) { $userpassstring = trim(substr($content, 0, $btpos)); $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content))); } } $contentfirstline = $blah[1]; } else { echo "<p><b>Use Phone Mail:</b> No</p>\n"; $userpassstring = strip_tags($firstline); $contentfirstline = ''; } $flat = 999.0; $flon = 999.0; $secondlineParts = explode(':', strip_tags($secondline)); if (strncmp($secondlineParts[0], "POS", 3) == 0) { echo "Found POS:<br />\n"; // echo "Second parts is:".$secondlineParts[1]; // the second line is the postion listing line $secLineParts = explode(',', $secondlineParts[1]); $flatStr = $secLineParts[0]; $flonStr = $secLineParts[1]; // echo "String are ".$flatStr.$flonStr; $flat = floatval($secLineParts[0]); $flon = floatval($secLineParts[1]); // echo "values are ".$flat." and ".$flon; // ok remove that position... we should not have it in the final output $content = str_replace($secondline, '', $content); } $blah = explode(':', $userpassstring); $user_login = $blah[0]; $user_pass = $blah[1]; $user_login = mb_conv(trim($user_login), $blog_charset, $charset); $content = $contentfirstline . str_replace($firstline, '', $content); $content = trim($content); // Please uncomment following line, only if you want to check user and password. // echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>"; echo "<p><b>Login:</b> {$user_login}, <b>Pass:</b> *********</p>"; if (!user_pass_ok($user_login, $user_pass)) { echo "<p><b>Error: Wrong Login.</b></p></div>\n"; continue; } $userdata = get_userdatabylogin($user_login); $user_level = $userdata->user_level; $post_author = $userdata->ID; if ($user_level > 0) { $post_title = xmlrpc_getposttitle($content); if ($post_title == '') { $post_title = $subject; } echo "Subject : " . mb_conv($post_title, $blog_charset, $sub_charset) . " <br />\n"; $post_category = get_settings('default_category'); if (preg_match('/<category>(.+?)<\\/category>/is', $content, $matchcat)) { $post_category = xmlrpc_getpostcategory($content); } if (empty($post_category)) { $post_category = get_settings('default_post_category'); } echo "Category : {$post_category} <br />\n"; $post_category = explode(',', $post_category); if (!get_settings('emailtestonly')) { // Attaching Image Files Save if ($att_boundary != "") { $attachment = wp_getattach($contents[2], "user-" . trim($post_author), 1); } if ($boundary != "" && $hatt_boundary != "") { for ($i = 2; $i < count($contents); $i++) { $hattachment = wp_getattach($contents[$i], "user-" . trim($post_author), 0); if ($hattachment) { if (preg_match("/Content-Id: \\<([^\\>]*)>/i", $contents[$i], $matches)) { $content = preg_replace("/(cid:" . preg_quote($matches[1]) . ")/", get_settings('fileupload_url') . '/' . $hattachment, $content); } } } } if ($boundary != "") { $content = preg_replace("/\\=[\r\n]/", "", $content); $content = preg_replace("/[\r\n]/", " ", $content); } $content = preg_replace("|\n([^\n])|", " \$1", $content); $content = preg_replace("/\\=([0-9a-fA-F]{2,2})/e", "pack('c',base_convert('\\1',16,10))", $content); $content = mb_conv(trim($content), $blog_charset, $charset); // If we find an attachment, add it to the post if ($attachment) { if (isset($img_target) && $img_target) { $img_target = ' target="' . $img_target . '"'; } else { $img_target = ''; } if (file_exists(get_settings('fileupload_realpath') . "/thumb-" . $attachment)) { $content = "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src = \"" . get_settings('fileupload_url') . '/thumb-' . rawurlencode($attachment) . "\" alt=\"" . $attachment . "\" title=\"" . $attachment . "\" /></a>" . $content . "<br clear=\"left\" />"; } else { $content = "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src = \"" . get_settings('fileupload_url') . '/' . rawurlencode($attachment) . "\" alt=\"" . $attachment . "\" title=\"" . $attachment . "\" /></a>" . $content . "<br clear=\"left\" />"; } } $postHandler =& wp_handler('Post'); $postObject =& $postHandler->create(); $postObject->setVar('post_content', $content); $postObject->setVar('post_title', trim(mb_conv($post_title, $blog_charset, $sub_charset))); $postObject->setVar('post_date', $post_date); $postObject->setVar('post_author', $post_author); $postObject->setVar('post_category', $post_category[0]); $postObject->setVar('post_name', sanitize_title($post_title)); if ($flat < 500) { $postObject->setVar('post_lat', $flat); $postObject->setVar('post_lon', $flon); } if (!$postHandler->insert($postObject, true)) { echo "<b>Error: Insert New Post</b><br />"; } $post_ID = $postObject->getVar('ID'); echo "Post ID = {$post_ID}<br />\n"; $postObject->assignCategories($post_category); do_action('publish_post', $post_ID); do_action('publish_phone', $post_ID); if ($flat < 500) { pingGeoUrl($post_ID); } $blog_ID = 1; pingWeblogs($blog_ID); pingBlogs($blog_ID); pingback($content, $post_ID); } echo "\n<p><b>Posted title:</b> {$post_title}<br />\n"; echo "<b>Posted content:</b><br /><pre>" . $content . "</pre></p>\n"; if (!$wp_pop3->delete($mail_num)) { echo "<p>Oops " . $wp_pop3->ERROR . "</p></div>\n"; $wp_pop3->reset(); return; } else { echo "<p>Mission complete, message <strong>{$mail_num}</strong> deleted.</p>\n"; } } else { echo "<p><strong>Level 0 users can\\'t post.</strong></p>\n"; } echo "</div>\n"; } } $wp_pop3->quit(); timer_stop($output_debugging_info); return; }
function wp_mail_receive() { global $img_target; require_once wp_base() . '/wp-includes/class-pop3.php'; timer_start(); $use_cache = 1; $time_difference = get_settings('time_difference'); error_reporting(2037); $GLOBALS['wp_pop3'] = new POP3(); if (!$GLOBALS['wp_pop3']->connect(get_settings('mailserver_url'), get_settings('mailserver_port'))) { echo "Ooops {$GLOBALS['wp_pop3']}->ERROR <br />\n"; return; } $mail_count = $GLOBALS['wp_pop3']->login(get_settings('mailserver_login'), get_settings('mailserver_pass')); if ($mail_count == false) { if (!$GLOBALS['wp_pop3']->FP) { echo "Oooops Login Failed: {$wp_pop3->ERROR}<br />\n"; } else { echo "No Message<br />\n"; $GLOBALS['wp_pop3']->quit(); } return; } // ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT! register_shutdown_function('wp_mail_quit'); for ($mail_num = 1; $mail_num <= $mail_count; $mail_num++) { $MsgOne = $GLOBALS['wp_pop3']->get($mail_num); if (!$MsgOne || gettype($MsgOne) != 'array') { echo "oops, {$GLOBALS['wp_pop3']}->ERROR<br />\n"; $GLOBALS['wp_pop3']->quit(); return; } $content = ''; $content_type = ''; $boundary = ''; $alt_boundary = ''; $emb_boundary = ''; $dmonths = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); $mailMsg = ''; while (list($lineNum, $line) = each($MsgOne)) { $mailMsg .= $line; } $mailParts = parse_msg($mailMsg); if (!empty($mailParts['header']['date'])) { $ddate = trim($mailParts['header']['date'][0]); if (strpos($ddate, ',')) { $ddate = trim(substr($ddate, strpos($ddate, ',') + 1, strlen($ddate))); } $ddate_U = strtotime($ddate) + $time_difference * 3600; $post_date = date('Y-m-d H:i:s', $ddate_U); } if (!empty($mailParts['header']['subject'])) { $subject = trim($mailParts['header']['subject'][0]); if (function_exists('mb_decode_mimeheader')) { $subject1 = mb_decode_mimeheader($subject); if ($subject1 != $subject) { $sub_charset = mb_internal_encoding(); } else { $sub_charset = "auto"; } $subject = $subject1; } if (get_settings('use_phoneemail')) { $subject = explode(get_settings('phoneemail_separator'), $subject); $subject = trim($subject[0]); } } if (!ereg(get_settings('subjectprefix'), $subject)) { continue; } $charset = ""; $ncharset = preg_match("/\\s?charset=\"?([A-Za-z0-9\\-]*)\"?/i", $content, $matches); if ($ncharset) { $charset = $matches[1]; } $ddate_today = time() + $time_difference * 3600; $ddate_difference_days = ($ddate_today - $ddate_U) / 86400; if ($ddate_difference_days > 14) { echo "Too old<br />\n"; continue; } if (preg_match('/' . get_settings('subjectprefix') . '/', $subject)) { $userpassstring = ''; echo "<div style=\"border: 1px dashed #999; padding: 10px; margin: 10px;\">\n"; echo "<p><b>{$mail_num}</b></p><p><b>Subject: </b>{$subject}</p>\n"; $subject = trim(str_replace(get_settings('subjectprefix'), '', $subject)); $attaches = array(); if ($mailParts['type'] == 'multipart') { if ($mailParts['subtype'] == 'mixed') { for ($i = 1; $i < count($mailParts['body']); $i++) { $attaches[] = array('type' => 'mix', 'body' => $mailParts['body'][$i]); } if (!is_array($mailParts['body'][0]['body'])) { $content = $mailParts['body'][0]['body']; $charset = $mailParts['body'][0]['charset']; $encoding = $mailParts['body'][0]['encodings']; $content = convert_content($content, $charest, $encoding); } else { $mailParts = $mailParts['body'][0]; } } if ($mailParts['type'] == 'multipart' && $mailParts['subtype'] == 'related') { if ($mailParts['body'][0]['type'] == 'multipart' && $mailParts['body'][0]['subtype'] == 'alternative') { $content = $mailParts['body'][0]['body'][1]['body']; $charset = $mailParts['body'][0]['body'][1]['charset']; $encoding = $mailParts['body'][0]['body'][1]['encodings']; $content = convert_content($content, $charest, $encoding); } else { $content = $mailParts['body'][0]['body']; $charset = $mailParts['body'][0]['charset']; $encoding = $mailParts['body'][0]['encodings']; $content = convert_content($content, $charest, $encoding); } $content = preg_replace('/(\\<.*?\\>)/es', 'str_replace(array("\\n","\\r"), array(" ", " "), "\\1")', $content); $content = preg_replace('/\\<head\\>.*\\<\\/head\\>/is', '', $content); $content = preg_replace('/(\\<body\\s*[^\\>]*\\>)\\s*\\<br\\s*\\/*\\>\\s*/is', '\\1', $content); $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td><category><title>'); $content = preg_replace('!(</div>|</p>)([^\\r\\n])!i', "\\1\n\\2", $content); for ($i = 1; $i < count($mailParts['body']); $i++) { $attaches[] = array('type' => 'relate', 'body' => $mailParts['body'][$i], 'id' => preg_replace('/<(.*)>/', '$1', $mailParts['body'][$i]['header']['content-id'][0])); } } if ($mailParts['type'] == 'multipart' && $mailParts['subtype'] == 'alternative') { if ($mailParts['body'][1]['type'] == 'multipart' && $mailParts['body'][1]['subtype'] == 'related') { $content = $mailParts['body'][1]['body'][0]['body']; $charset = $mailParts['body'][1]['body'][0]['charset']; $encoding = $mailParts['body'][1]['body'][0]['encodings']; $content = convert_content($content, $charest, $encoding); for ($i = 1; $i < count($mailParts['body'][1]['body']); $i++) { $attaches[] = array('type' => 'relate', 'body' => $mailParts['body'][1]['body'][$i], 'id' => preg_replace('/<(.*)>/', '$1', $mailParts['body'][1]['body'][$i]['header']['content-id'][0])); } } else { $content = $mailParts['body'][1]['body']; $charset = $mailParts['body'][1]['charset']; $encoding = $mailParts['body'][1]['encodings']; $content = convert_content($content, $charest, $encoding); } $content = preg_replace('/(\\<[^\\>]*\\>)/es', 'str_replace(array("\\n","\\r"), array(" ", " "), "\\1")', $content); $content = preg_replace('/\\<head\\>.*\\<\\/head\\>/is', '', $content); $content = preg_replace('/(\\<body\\s*[^\\>]*\\>)\\s*\\<br\\s*\\/*\\>\\s*/is', '\\1', $content); $content = strip_tags($content, '<img><p><br><i><b><u><em><strong><strike><font><span><div><dl><dt><dd><ol><ul><li>,<table><tr><td><category><title>'); $content = preg_replace('!(</div>|</p>)([^\\r\\n])!i', "\\1\n\\2", $content); } } else { $content = $mailParts['body']; $charset = $mailParts['charset']; $encoding = $mailParts['encodings']; $content = convert_content($content, $charest, $encoding); } $content = trim($content); echo "<p><b>Content-type:</b> {$content_type}, <b>boundary:</b> {$boundary}</p>\n"; echo "<p><b>alt_boundary:</b> {$alt_boundary}, <b>emb_boundary:</b> {$emb_boundary}</p>\n"; echo "<p><b>charset:</b>{$charset}, <b>BLOG charset:</b>" . $GLOBALS['blog_charset'] . "</p>\n"; // echo "<p><b>Raw content:</b><br /><pre>".$content.'</pre></p>'; if ($charset == "" || trim(strtoupper($charset)) == "ISO-2022-JP") { $charset = "JIS"; } if (trim(strtoupper($charset)) == "SHIFT_JIS") { $charset = "SJIS"; } $btpos = strpos($content, get_settings('bodyterminator')); if ($btpos) { $content = substr($content, 0, $btpos); } $content = trim($content); $blah = explode("\n", preg_replace("/^[\n\r\\s]*/", "", strip_tags($content))); $firstline = preg_replace("/[\n\r]/", "", $blah[0]); $secondline = $blah[1]; if (get_settings('use_phoneemail')) { echo "<p><b>Use Phone Mail:</b> Yes</p>\n"; $btpos = strpos($firstline, get_settings('phoneemail_separator')); if ($btpos) { $userpassstring = trim(substr($firstline, 0, $btpos)); $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content))); $btpos = strpos($content, get_settings('phoneemail_separator')); if ($btpos) { $userpassstring = trim(substr($content, 0, $btpos)); $content = trim(substr($content, $btpos + strlen(get_settings('phoneemail_separator')), strlen($content))); } } $contentfirstline = $blah[1]; } else { echo "<p><b>Use Phone Mail:</b> No</p>\n"; $userpassstring = strip_tags($firstline); $contentfirstline = ''; } $flat = 999.0; $flon = 999.0; $secondlineParts = explode(':', strip_tags($secondline)); if (strncmp($secondlineParts[0], "POS", 3) == 0) { echo "Found POS:<br />\n"; // echo "Second parts is:".$secondlineParts[1]; // the second line is the postion listing line $secLineParts = explode(',', $secondlineParts[1]); $flatStr = $secLineParts[0]; $flonStr = $secLineParts[1]; // echo "String are ".$flatStr.$flonStr; $flat = floatval($secLineParts[0]); $flon = floatval($secLineParts[1]); // echo "values are ".$flat." and ".$flon; // ok remove that position... we should not have it in the final output $content = str_replace($secondline, '', $content); } $blah = explode(':', $userpassstring); $user_login = trim($blah[0]); $user_pass = $blah[1]; $content = $contentfirstline . str_replace($firstline, '', $content); $content = trim($content); // Please uncomment following line, only if you want to check user and password. // echo "<p><b>Login:</b> $user_login, <b>Pass:</b> $user_pass</p>"; echo "<p><b>Login:</b> {$user_login}, <b>Pass:</b> *********</p>"; if (!user_pass_ok($user_login, $user_pass)) { echo "<p><b>Error: Wrong Login.</b></p></div>\n"; continue; } $userdata = get_userdatabylogin($user_login); $user_level = $userdata->user_level; $post_author = $userdata->ID; if ($user_level > 0) { $post_title = xmlrpc_getposttitle($content); if ($post_title == '') { $post_title = $subject; } echo "Subject : " . mb_conv($post_title, $GLOBALS['blog_charset'], $sub_charset) . " <br />\n"; $post_category = get_settings('default_category'); if (preg_match('/<category>(.+?)<\\/category>/is', $content, $matchcat)) { $post_category = xmlrpc_getpostcategory($content); $content = xmlrpc_removepostdata($content); } if (empty($post_category)) { $post_category = get_settings('default_post_category'); } echo "Category : {$post_category} <br />\n"; $post_category = explode(',', $post_category); if (!get_settings('emailtestonly')) { $content = preg_replace('|\\n([^\\n])|', " \$1", trim($content)); $content_before = ""; $content_after = ""; for ($i = 0; $i < count($attaches); $i++) { $create_thumbs = $attaches[$i]['type'] == 'mix' ? 1 : 0; list($file_name, $is_img, $orig_name) = wp_getattach($attaches[$i]['body'], "user-" . trim($post_author), $create_thumbs); if ($file_name) { if ($attaches[$i]['type'] == 'relate') { $content = preg_replace("/cid:" . preg_quote($attaches[$i]['id']) . "/", get_settings('fileupload_url') . '/' . $file_name, $content); } else { if (isset($img_target) && $img_target) { $img_target = ' target="' . $img_target . '"'; } else { $img_target = ''; } if ($is_img) { if (file_exists(get_settings('fileupload_realpath') . "/thumb-" . $file_name)) { $content_before .= "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($file_name) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src=\"" . get_settings('fileupload_url') . '/thumb-' . rawurlencode($file_name) . "\" alt=\"" . $orig_name . "\" title=\"" . $orig_name . "\" /></a>"; } else { $content_before .= "<a href=\"" . get_settings('fileupload_url') . '/' . rawurlencode($file_name) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src=\"" . get_settings('fileupload_url') . '/' . rawurlencode($file_name) . "\" alt=\"" . $orig_name . "\" title=\"" . $orig_name . "\" /></a>"; } } else { $content_after .= "<a href=\"" . wp_siteurl() . "/wp-download.php?from=" . rawurlencode($file_name) . "&fname=" . urlencode($orig_name) . "\"" . $img_target . "><img style=\"float: left;\" hspace=\"6\" src=\"" . wp_siteurl() . "/wp-images/file.gif\" alt=\"" . $orig_name . "\" title=\"" . $orig_name . "\" />" . $orig_name . "</a>"; } } } } $content = $content_before . $content . "<br clear=\"left\" />" . $content_after; $postHandler =& wp_handler('Post'); $postObject =& $postHandler->create(); $postObject->setVar('post_content', $content, true); $postObject->setVar('post_title', trim(mb_conv($post_title, $GLOBALS['blog_charset'], $sub_charset)), true); $postObject->setVar('post_date', $post_date, true); $postObject->setVar('post_author', $post_author, true); $postObject->setVar('post_category', $post_category[0], true); $postObject->setVar('post_name', sanitize_title($post_title), true); if ($flat < 500) { $postObject->setVar('post_lat', $flat, true); $postObject->setVar('post_lon', $flon, true); } $postObject->setVar('post_status', get_settings('default_post_status'), true); $postObject->setVar('ping_status', get_settings('default_ping_status'), true); $postObject->setVar('comment_status', get_settings('default_comment_status'), true); if (!$postHandler->insert($postObject, true)) { echo "<b>Error: Insert New Post</b><br />"; } $post_ID = $postObject->getVar('ID'); echo "Post ID = {$post_ID}<br />\n"; $postObject->assignCategories($post_category, true); do_action('publish_post', $post_ID); do_action('publish_phone', $post_ID); if ($flat < 500) { pingGeoUrl($post_ID); } $blog_ID = 1; pingWeblogs($blog_ID); pingback($content, $post_ID); } echo "\n<p><b>Posted title:</b> {$post_title}<br />\n"; echo "<b>Posted content:</b><br /><pre>" . $content . "</pre></p>\n"; if (!$GLOBALS['wp_pop3']->delete($mail_num)) { echo "<p>Oops " . $GLOBALS['wp_pop3']->ERROR . "</p></div>\n"; $GLOBALS['wp_pop3']->reset(); return; } else { echo "<p>Mission complete, message <strong>{$mail_num}</strong> deleted.</p>\n"; } } else { echo "<p><strong>Level 0 users can\\'t post.</strong></p>\n"; } echo "</div>\n"; } } $GLOBALS['wp_pop3']->quit(); timer_stop($GLOBALS['wp_mail_debug']); return; }
$post_ID = $wpdb->insert_id; echo "The result is: " . $result; if (isset($sleep_after_edit) && $sleep_after_edit > 0) { sleep($sleep_after_edit); } $blog_ID = 1; if ($flat < 500) { pingGeoUrl($post_ID); } // HACK HACK HACK this next line is commented out because I don't know what the word-press replacement // is. right now it's undefined and does not work //rss_update($blog_ID); pingWeblogs($blog_ID); // pingCafelog($cafelogID, $post_title, $post_ID); pingBlogs($blog_ID); pingback($content, $post_ID); #delete successful email, mark for deletion actually if ($result > 0) { imap_delete($mbox, $iCount); echo "deleted successfully"; } else { die("error deleting message"); } } echo "\n<p><b>Posted title:</b> {$post_title}<br />"; echo "\n<b>Posted content:</b><br /><pre>" . $content . '</pre></p>'; # Added to make category work # if (!$post_categories) { $post_categories[] = 1; }
/** * Perform all pingbacks, enclosures, trackbacks, and send to pingback services. * * @since 2.1.0 * @uses $wpdb */ function do_all_pings() { global $wpdb; // Do pingbacks while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); pingback($ping->post_content, $ping->ID); } // Do Enclosures while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_encloseme';", $enclosure->ID)); do_enclose($enclosure->post_content, $enclosure->ID); } // Do Trackbacks $trackbacks = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE to_ping <> '' AND post_status = 'publish'"); if (is_array($trackbacks)) { foreach ($trackbacks as $trackback) { do_trackbacks($trackback); } } }