コード例 #1
0
 $insert_sql .= "TRUNCATE TABLE {$f2blog_table};\r\n";
 $i = 0;
 $query = "select *,a.id as id from " . $_SESSION['s_dbPrefix'] . "articles as a inner join " . $_SESSION['s_dbPrefix'] . "articles_text as b on a.id=b.article_id inner join " . $_SESSION['s_dbPrefix'] . "users as c on a.user_id=c.id inner join " . $_SESSION['s_dbPrefix'] . "article_categories_link as d on a.id=d.article_id order by a.id";
 $result = mysql_query($query);
 //or die(mysql_error());
 $error = mysql_error();
 while ($arr_result = mysql_fetch_array($result)) {
     $arr_result['status'] = $arr_result['status'] > 1 ? 0 : 1;
     $arr_result['date'] = convertdate($arr_result['date']);
     $insert_field = array();
     $insert_value = array();
     foreach ($arr_fields as $key => $value) {
         $insert_field[] = $key;
         if ($key == "logContent") {
             //格式化内容
             $insert_value[] = convert_content($arr_result['text']);
         } else {
             $insert_value[] = encode($arr_result[$value]);
         }
     }
     $insert_sql .= "INSERT INTO {$f2blog_table}(" . implode(",", $insert_field) . ",isComment,isTrackback) VALUES('" . implode("','", $insert_value) . "','1','1');\r\n";
     //是否分卷
     if (strlen($insert_sql) >= $_SESSION['s_dbSize'] * 1000) {
         $p++;
         $msg = write_file($insert_sql, $filename);
         //写入分卷文件
         $insert_sql = "";
     }
     $i++;
 }
 $result_blog = $error ? $error : $i;
コード例 #2
0
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) . "&amp;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;
}
コード例 #3
0
 $result = mysql_query($query);
 //or die(mysql_error());
 $error = mysql_error();
 while ($arr_result = mysql_fetch_array($result)) {
     $arr_result['post_status'] = $arr_result['post_status'] == "publish" ? 1 : 0;
     if ($arr_result['post_category'] == 0) {
         $arr_result['post_category'] = 1;
     }
     $arr_result['post_date'] = strtotime($arr_result['post_date']);
     $insert_field = array();
     $insert_value = array();
     foreach ($arr_fields as $key => $value) {
         $insert_field[] = $key;
         if ($key == "logContent") {
             //格式化内容
             $insert_value[] = convert_content($arr_result['post_content']);
         } else {
             $insert_value[] = encode($arr_result[$value]);
         }
     }
     //取得类别
     $catequery = "select category_id from " . $_SESSION['s_dbPrefix'] . "post2cat where post_id='" . $arr_result['ID'] . "'";
     $cateresult = mysql_query($catequery);
     //or die(mysql_error());
     $arr_cate = mysql_fetch_array($cateresult);
     $cateId = $arr_cate['category_id'];
     //取得标签
     $tags = "";
     $tags_query = mysql_query("select tag_id from " . $_SESSION['s_dbPrefix'] . "post2tag where post_id='" . $arr_result['ID'] . "'");
     while ($tags_result = mysql_fetch_array($tags_query)) {
         $tags_name = mysql_query("select tag from " . $_SESSION['s_dbPrefix'] . "tags where tag_ID='" . $tags_result['tag_id'] . "'");
コード例 #4
0
     $arr_result['tags'] = $tags;
     $insert_field = array();
     $insert_value = array();
     foreach ($arr_fields as $key => $value) {
         $insert_field[] = $key;
         if ($key == "logContent") {
             //格式化内容
             $descript_content = $arr_result['description'];
             $logscontent = $arr_result['content'];
             if (!empty($descript_content)) {
                 if (strpos(";" . $logscontent, $descript_content) > 0) {
                     $logscontent = str_replace($descript_content, "", $logscontent);
                 }
                 $logscontent = $descript_content . "[separator]" . $logscontent;
             }
             $insert_value[] = convert_content($logscontent);
         } else {
             $insert_value[] = encode($arr_result[$value]);
         }
     }
     $insert_sql .= "INSERT INTO {$f2blog_table}(" . implode(",", $insert_field) . ",isComment,isTrackback) VALUES('" . implode("','", $insert_value) . "','1','1');\r\n";
     //是否分卷
     if (strlen($insert_sql) >= $_SESSION['s_dbSize'] * 1000) {
         $p++;
         $msg = write_file($insert_sql, $filename);
         //写入分卷文件
         $insert_sql = "";
     }
     $i++;
 }
 $result_blog = $error ? $error : $i;
コード例 #5
0
 $insert_sql .= "TRUNCATE TABLE {$f2blog_table};\r\n";
 $i = 0;
 $query = "select * from t3_" . $_SESSION['s_dbPrefix'] . " order by no";
 $result = mysql_query($query);
 //or die(mysql_error());
 $error = mysql_error();
 while ($arr_result = mysql_fetch_array($result)) {
     $arr_result['is_public'] = $arr_result['is_public'] > 0 ? 1 : 0;
     $arr_result['category'] = $arr_result['category2'] == 0 ? $arr_result['category1'] : $arr_category[$arr_result['category2'] . $arr_result['category1']];
     $insert_field = array();
     $insert_value = array();
     foreach ($arr_fields as $key => $value) {
         $insert_field[] = $key;
         if ($key == "logContent") {
             //格式化内容
             $insert_value[] = convert_content($arr_result['body']);
         } else {
             $insert_value[] = encode($arr_result[$value]);
         }
     }
     $insert_sql .= "INSERT INTO {$f2blog_table}(" . implode(",", $insert_field) . ") VALUES('" . implode("','", $insert_value) . "');\r\n";
     //是否分卷
     if (strlen($insert_sql) >= $_SESSION['s_dbSize'] * 1000) {
         $p++;
         $msg = write_file($insert_sql, $filename);
         //写入分卷文件
         $insert_sql = "";
     }
     $i++;
 }
 $result_blog = $error ? $error : $i;