while ($row = mysql_fetch_array($res)) { // Convert retrieved data into UTF-8. $row = convert_to_utf8($row); $link = 'http://' . $_SERVER['HTTP_HOST'] . $cfg['root_path'] . 'article.php?id=' . $row['id']; // Generate "rdf:li" list in <items> $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n"; // Generate each <item> $item .= '<item rdf:about="' . $link . '">' . "\n" . '<title>' . htmlspecialchars($row['name']) . "</title>\n" . '<link>' . $link . "</link>\n"; // Just replace "<foo>" tag code into <foo> // -- this looks better in NetNewsWire RSS Viewer. $row['comment'] = str_replace("./resources/", 'http://' . $_SERVER['HTTP_HOST'] . $cfg['root_path'] . 'resources/', $row['comment']); // Convert Text to XHTML if (file_exists($cd . '/include/user_include/plugins/plg_markdown.inc.php')) { include_once $cd . '/include/user_include/plugins/plg_markdown.inc.php'; $FKMM_markdown = new FKMM_markdown(); $row['comment'] = $FKMM_markdown->convert($row['comment']); } // Trim "comment" data for description $description = htmlspecialchars(mb_substr(strip_tags($row['comment']), 0, 120, 'UTF-8')) . '...'; // This is for "content module" $content_encoded = '<![CDATA[' . "\n" . $row['comment'] . "\n" . ']]>'; $tz = tz(); $item .= '<dc:date>' . $row['date'] . $tz . "</dc:date>\n" . '<description>' . $description . "</description>\n" . '<content:encoded>' . "\n" . $content_encoded . "\n" . '</content:encoded>' . "\n" . "</item>\n"; } } // Generate Date SQL $tz = tz(); if (!mysql_query(isset($d_sql))) { $d_sql = "SELECT DATE_FORMAT(`date`, '%Y-%m-%dT%T') as `date` " . "FROM `{$log_table}` " . "WHERE `draft` = '0' ORDER BY `date` desc LIMIT 1"; $d_res = mysql_query($d_sql); $row = mysql_fetch_array($d_res);
/** * Article Box */ function display_article_box($row) { global $cfg, $lang, $cd, $session_status, $id, $admin_dir, $article_addition; // Permanent Link if (empty($id)) { $permalink = '<a href="' . $cd . '/article.php?id=' . $row['id'] . '" title="' . $lang['permalink_title_1'] . htmlspecialchars(strip_tags($row['name'])) . $lang['permalink_title_2'] . '" rel="Bookmark">Permalink</a> '; $read_more = '<p class="read-more"><a href="' . $cd . '/article.php?id=' . $row['id'] . '" title="' . $row['name'] . '">' . $lang['more'] . '</a></p>'; $row['comment'] = preg_replace('/<!-- ?more ?-->.*<!-- ?\\/more ?-->/is', $read_more, $row['comment']); $row['comment'] = preg_replace('/<!-- ?more ?-->.*/is', $read_more, $row['comment']); } else { $permalink = ''; } if (file_exists($cd . '/include/user_include/plugins/plg_isbn.inc.php')) { include_once $cd . '/include/user_include/plugins/plg_isbn.inc.php'; $FKMM_isbn = new FKMM_isbn(); $row['comment'] = $FKMM_isbn->convert_isbn($row['comment']); } // Convert Text to XHTML if (file_exists($cd . '/include/user_include/plugins/plg_markdown.inc.php')) { include_once $cd . '/include/user_include/plugins/plg_markdown.inc.php'; $FKMM_markdown = new FKMM_markdown(); $row['comment'] = $FKMM_markdown->convert($row['comment']); } else { $row['comment'] = xhtml_auto_markup($row['comment']); } // Convert Enclosure if (file_exists($cd . '/rss/include/P_BLOG_RSS.class.php')) { include_once $cd . '/rss/include/P_BLOG_RSS.class.php'; $p_rss = new P_BLOG_RSS(); $row['comment'] = $p_rss->convertEnclosure($row['comment']); } $row['comment'] = preg_replace('/src="\\./', 'src="' . $cd, $row['comment']); // Smiley $row = smiley($row); // Article title if ($row['href'] == "http://") { $article_title = $row['name']; } else { $article_title = '<a href="' . $row['href'] . '">' . $row['name'] . "</a>\n"; } // Time format if ($cfg['show_date_title'] == 'yes') { switch ($cfg['date_style']) { case '1': $df = 'Y/m/d'; break; case '2': $df = 'M d, Y'; break; default: $df = 'Y-m-d'; break; } $row['date'] = date($df . ' G:i:s', strtotime($row['date'])); $row['mod'] = date($df . ' G:i:s', strtotime($row['mod'])); } if ($row['date'] != $row['mod']) { $row['date'] = date('G:i:s', strtotime($row['date'])); $mod_str = ', ' . $lang['mod'] . ' @ ' . $row['mod']; } else { $row['date'] = date('G:i:s', strtotime($row['date'])); $mod_str = ''; } // Category $category_title = $lang['cat_title_1'] . $row['category'] . $lang['cat_title_2']; $category = '<a href="' . $cd . '/category.php?k=' . urlencode($row['category']) . '" title="' . $category_title . '">' . $row['category'] . '</a>'; // Show date time if ($cfg['show_date_time'] == 'yes') { $date_time = '<div class="date">' . $lang['post'] . ' @ ' . $row['date'] . ' ' . $mod_str . ' | ' . $category . "</div>\n"; } else { $date_time = ''; } // Show e-mail link if ($cfg['use_email_link'] == 'yes') { $via_email_title = $lang['via_email_title_1'] . htmlspecialchars(strip_tags($row['name'])) . $lang['via_email_title_2']; $email_link = '<a href="' . $cd . '/var/feedback/index.php?id=feedback&a_id=' . $row['id'] . '" title="' . $via_email_title . '">Email</a>'; } else { $email_link = ''; } // Show comment link if ($cfg['use_comment_link'] == 'yes' && @file_exists('./forum/index.php')) { switch ($cfg['comment_style']) { case '2': $comment = post_comment(); // "Comment" style break; case '1': $comment = post_comment_forum(); // "Forum" style break; default: $comment = post_comment(); break; } } else { $comment = ''; } // Show trackbacks if ($cfg['trackback'] == 'on') { $trackback = display_trackback($row); } else { $trackback = ''; } // Show "Modify or Delete" button when Admin mode. if ($session_status == 'on') { if ($row['draft'] == '1') { $update_target = 'draft_update'; } else { $update_target = 'update'; } $admin_button = <<<EOD <form action="{$cd}/{$admin_dir}/{$update_target}.php" method="post"> <div class="submit-button"> <input type="hidden" name="id" value="{$row['id']}" /> <input type="hidden" name="mode" value="log" /> <input type="hidden" name="post_username" value="" /> <input type="hidden" name="post_password" value="" /> <input type="submit" tabindex="1" accesskey="m" value="{$lang['mod_del']}" /> </div> </form> EOD; } else { $admin_button = ''; } // Article footer if (!empty($id)) { // When Permalink if ($email_link != '') { $email_link = <<<EOD <div class="a-footer"> {$email_link} </div> EOD; } else { $email_link = ''; } $article_footer = <<<EOD {$email_link}{$article_addition} {$trackback} {$comment} {$admin_button} EOD; } else { // When Index $article_footer = <<<EOD <div class="a-footer"> {$permalink}{$email_link} {$trackback} {$comment}{$admin_button} </div> EOD; } //////////////// Presentation! ///////////////// $article_box = <<<EOD <div class="section"> <h3 class="article-title">{$article_title}</h3> {$date_time}<div class="comment"> {$row['comment']} </div> {$article_footer} </div><!-- End .section --> EOD; return $article_box; }
function send_trackback() { global $cd, $cfg, $lang, $id, $send_tb_result, $log_table; ////////////////// Sending Trackback Ping //////////////////// if (!empty($_POST['send_ping_uri']) && !empty($_POST['encode']) && $_POST['send_ping_uri'] != 'http://') { $ping_uri = $_POST['send_ping_uri']; $encode = $_POST['encode']; $query = 'SELECT `name`, `comment` FROM `' . $log_table . "` WHERE `id` = '" . $id . "'"; $tb_res = mysql_query($query); $tb_row = mysql_fetch_array($tb_res); switch ($encode) { case 'EUC-JP': $tb_row['name'] = mb_convert_encoding($tb_row['name'], 'EUC-JP', $cfg['mysql_lang']); $tb_row['comment'] = mb_convert_encoding($tb_row['comment'], 'EUC-JP', $cfg['mysql_lang']); break; case 'SJIS': $tb_row['name'] = mb_convert_encoding($tb_row['name'], 'SJIS', $cfg['mysql_lang']); $tb_row['comment'] = mb_convert_encoding($tb_row['comment'], 'SJIS', $cfg['mysql_lang']); break; default: if ($cfg['mysql_lang'] == 'UTF-8') { break; } else { $tb_row['name'] = mb_convert_encoding($tb_row['name'], 'UTF-8', $cfg['mysql_lang']); $tb_row['comment'] = mb_convert_encoding($tb_row['comment'], 'UTF-8', $cfg['mysql_lang']); } break; } $article_url = 'http://' . $_SERVER['HTTP_HOST'] . $cfg['root_path'] . 'article.php?id=' . $id; $article_title = $tb_row['name']; // trim the posted strings // Convert Text to XHTML if (file_exists($cd . '/include/user_include/plugins/plg_markdown.inc.php')) { include_once $cd . '/include/user_include/plugins/plg_markdown.inc.php'; $FKMM_markdown = new FKMM_markdown(); $tb_row['comment'] = $FKMM_markdown->convert($tb_row['comment']); } $article_excerpt = mb_substr(strip_tags($tb_row['comment']), 0, 100, $encode) . '...'; // send Ping to the target URI $target_uri = parse_url($ping_uri); if (!isset($target_uri['port'])) { $target_uri['port'] = 80; } if (isset($target_uri['query'])) { $target_uri['query'] = '?' . $target_uri['query']; } else { $target_uri['query'] = ''; } if (isset($target_uri['user'], $target_uri['pass'])) { $auth = 'Authorization: Basic ' . base64_encode($target_uri['user'] . ':' . $target_uri['pass']) . "\r\n"; } else { $auth = ''; } $para['url'] = $article_url; $para['title'] = $article_title; $para['excerpt'] = $article_excerpt; $para['blog_name'] = $cfg['blog_title']; while (list($key, $val) = each($para)) { $paras[] = $key . '=' . urlencode($val); } $data = join("&", $paras); // prepare the post value $post = 'POST ' . $target_uri['path'] . $target_uri['query'] . " HTTP/1.1\r\n" . 'Host: ' . $target_uri['host'] . "\r\n" . 'User-Agent: P_BLOG' . "\r\n" . $auth . 'Content-Type: application/x-www-form-urlencoded' . "\r\n" . 'Content-Length: ' . strlen($data) . "\r\n\r\n" . $data . "\r\n"; $fs = fsockopen($target_uri['host'], $target_uri['port']); if (!$fs) { return "Socket error!"; $status = "<tr>\n" . '<td class="trackback-to">' . $ping_uri . "</td>\n" . '<td class="trackback-status">Error</td>' . "\n</tr>\n"; } else { fputs($fs, $post); // send data... $res = fread($fs, 1024); // ...and get response // Read XML responses to check error if (preg_match('/<error>1<\\/error>/', $res)) { $msg = '<span class="red">' . $lang['tb_ping_error'] . '</span>'; } elseif (preg_match('/<error>0<\\/error>/', $res)) { $msg = $lang['tb_ping_ok']; } else { $msg = $lang['tb_ping_no_res']; } // if sending Ping is success... $status = "<tr>\n" . '<td>' . $ping_uri . "</td>\n" . '<td>' . $msg . '</td>' . "\n</tr>\n"; } } else { $status = "<tr>\n" . '<td>Trackback Ping : ' . $lang['none'] . '</td>' . "\n" . '<td>-</td>' . "\n</tr>\n"; } ////////////////// Sending Weblog Update Ping //////////////////// if (!empty($_POST['send_update_ping']) && $_POST['send_update_ping'] == 'yes') { $status2 = ''; $ping_server_list = explode(",\r\n", stripslashes(trim($cfg['ping_server_list']))); foreach ($ping_server_list as $ping_target) { $target_uri = parse_url($ping_target); $fp = fsockopen($target_uri['host'], 80, $errno, $errstr, 30); if (!$fp) { return 'Socket error!'; } else { // prepare XML-RPC request $req_xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<methodCall>' . '<methodName>weblogUpdates.ping</methodName>' . '<params>' . '<param>' . '<value>' . htmlspecialchars($cfg['blog_title']) . '</value>' . '</param>' . '<param>' . '<value>' . 'http://' . $_SERVER['HTTP_HOST'] . $cfg['root_path'] . 'index.php</value>' . '</param>' . '</params>' . '</methodCall>'; // prepare the post value $post_ping = 'POST ' . $ping_target . " HTTP/1.1\r\n" . 'Host: ' . $_SERVER['HTTP_HOST'] . "\r\n" . 'User-Agent: P_BLOG XML-RPC' . "\r\n" . 'Content-Type: text/xml' . "\r\n" . 'Content-Length: ' . strlen($req_xml) . "\r\n\r\n" . $req_xml . "\r\n"; fputs($fp, $post_ping); // send data... $ping_res = fread($fp, 4096); // ...and get response // Read XML responses to check error if (preg_match('/<boolean>1<\\/boolean>/', $ping_res)) { $ping_msg = '<span class="red">' . $lang['tb_ping_error'] . '</span>'; } elseif (preg_match('/<boolean>0<\\/boolean>/', $ping_res)) { if (preg_match('/Thanks for your ping/', $ping_res)) { $ping_msg = 'Thanks for your ping.'; } elseif (preg_match('/Thanks for the ping/', $ping_res)) { $ping_msg = 'Thanks for the ping.'; } else { $ping_msg = $lang['tb_ping_ok']; } } else { $ping_msg = '-'; } // if receiving Ping response is success... $status2 .= "<tr>\n" . '<td>' . $ping_target . "</td>\n" . '<td>' . $ping_msg . '</td>' . "\n</tr>\n"; } } $status2 .= ''; } else { $status2 = ''; } // show results $send_tb_result = <<<EOD <table summary="Trackbacks" class="colored"> <tr><th class="trackback-to">Sent Ping to</th><th class="trackbac-status">{$lang['tb_response']}</th></tr> {$status} {$status2} </table> <br /> EOD; return $send_tb_result; }
function display_var_contents() { global $cd, $cfg, $lang, $plugin; include_plugin($mode = ''); $contents = ''; if (isset($_GET['id'])) { $id = sanitize($_GET['id']); $id = str_replace('/', '', $id); if (file_exists('./contents/' . $id . '.inc.php')) { //foo.inc.php include_once './contents/' . $id . '.inc.php'; } elseif (file_exists('./contents/' . $id . '.php')) { //foo.php include_once './contents/' . $id . '.php'; } elseif (file_exists('./contents/' . $id . '.inc')) { //foo.inc $rfp = fopen(stripslashes('./contents/' . $id . '.inc'), "rb"); $contents .= @fread($rfp, filesize('./contents/' . $id . '.inc')); } elseif (file_exists('./contents/' . $id . '.html')) { //foo.html $rfp = fopen(stripslashes('./contents/' . $id . '.html'), "rb"); $contents .= @fread($rfp, filesize('./contents/' . $id . '.html')); } elseif (file_exists('./contents/' . $id . '.txt')) { //foo.txt $contents .= "<pre>\n"; $rfp = fopen(stripslashes('./contents/' . $id . '.txt'), "rb"); $contents .= @fread($rfp, filesize('./contents/' . $id . '.txt')); $contents .= "</pre>\n"; } elseif (file_exists('./contents/' . $id . '.text')) { //foo.txt $rfp = fopen(stripslashes('./contents/' . $id . '.text'), "rb"); $text = @fread($rfp, filesize('./contents/' . $id . '.text')); if (file_exists($cd . '/include/user_include/plugins/plg_markdown.inc.php')) { include_once $cd . '/include/user_include/plugins/plg_markdown.inc.php'; $FKMM_markdown = new FKMM_markdown(); $contents .= $FKMM_markdown->convert($text); } else { $contents .= $text; } } else { $contents .= "\n" . '<h2 class="cate-title">' . $lang['no_matches'] . "</h2>\n"; } } elseif (file_exists('./contents/default.inc.php')) { //default.inc.php include_once './contents/default.inc.php'; } elseif (file_exists("./contents/default.php")) { //default.php include_once "./contents/default.php"; } elseif (file_exists("./contents/default.inc")) { //default.inc $rfp = fopen(stripslashes('./contents/default.inc'), "rb"); $contents .= @fread($rfp, filesize('./contents/default.inc')); } elseif (file_exists("./contents/default.html")) { //default.html $rfp = fopen(stripslashes('./contents/default.html'), "rb"); $contents .= @fread($rfp, filesize('./contents/default.html')); } elseif (file_exists("./contents/default.txt")) { //default.txt $contents .= "<pre>\n"; $rfp = fopen(stripslashes('./contents/default.txt'), "rb"); $contents .= @fread($rfp, filesize('./contents/default.txt')); $contents .= "</pre>\n"; } elseif (file_exists("./contents/default.text")) { //default.text $rfp = fopen(stripslashes('./contents/default.text'), "rb"); $text = @fread($rfp, filesize('./contents/default.text')); if (file_exists($cd . '/include/user_include/plugins/plg_markdown.inc.php')) { include_once $cd . '/include/user_include/plugins/plg_markdown.inc.php'; $FKMM_markdown = new FKMM_markdown(); $contents .= $FKMM_markdown->convert($text); } else { $contents .= $text; } } elseif (!file_exists("./contents/default.inc.php") && !file_exists("./contents/default.php") && !file_exists("./contents/default.inc") && !file_exists("./contents/default.html") && !file_exists("./contents/default.txt") && !file_exists("./contents/default.text")) { $contents .= '<h2>Please set the default page.</h2>'; } else { $contents .= '<h2>ERROR.</h2>'; } $contents .= ''; return $contents; }