bymt_txt_share(); ?> </div> <?php } ?> </div> <?php } ?> <?php if (bymt_c('txtcopyright') && !wp_is_mobile()) { ?> <div class="post-copyright"> <div id="author-avatar"><?php echo bymt_avatar(get_the_author_meta('email'), '42'); ?> </div> <div id="copy-info"> <span id="copy-arrow"><span></span></span> <?php if (bymt_c('txtcopyright')) { $custom = get_post_custom(get_the_ID()); if (isset($custom['copyright'])) { $custom_value = $custom['copyright']; } ?> <?php if (empty($custom_value)) { ?> <p><strong>版权声明:</strong>本文由( <?php
?> <a href="<?php echo esc_url(get_option('siteurl')) . '/wp-admin/profile.php'; ?> " class="welcome"> <?php global $current_user; get_currentuserinfo(); echo bymt_avatar($current_user->user_email, 45) . " 欢迎回来," . $current_user->display_name . "!"; ?> </a> <?php } else { if (isset($_COOKIE['comment_author_' . COOKIEHASH]) || isset($_COOKIE['comment_author_email_' . COOKIEHASH]) || isset($_COOKIE['comment_author_url_' . COOKIEHASH])) { $lastuser = esc_attr($_COOKIE['comment_author_' . COOKIEHASH]); $lastava = bymt_avatar($_COOKIE['comment_author_email_' . COOKIEHASH], 45); $lasturl = esc_url($_COOKIE['comment_author_url_' . COOKIEHASH]); echo "<a href=\"" . $lasturl . "\" rel=\"nofollow\" class=\"welcome\" >" . $lastava . " 欢迎回来," . $lastuser . "</a>!"; } else { echo bymt_refurl(); } } ?> </i> <?php } ?> </div> </div> <div class="line"></div> <div id="mobile-nav">
function widget($args, $instance) { extract($args); ?> <div class="widget" id="widget_user"> <?php global $user_ID, $user_identity, $user_email, $user_login; get_currentuserinfo(); if (!$user_ID) { ?> <h3>用户登录</h3> <form id="loginform" action="<?php echo get_option('siteurl'); ?> /wp-login.php" method="post"> <p><label><i class="icon-user"></i> 用户名:<input class="login_in" type="text" name="log" id="log" value="" size="12" /></label></p> <p><label><i class="icon-key"></i> 密 码:<input class="login_in" type="password" name="pwd" id="pwd" value="" size="12" /></label></p> <p class="login_p"><label>记住我 <input type="checkbox" name="rememberme" value="forever" /></label><input class="login_btn" type="submit" name="submit" value="登陆" /> </p> <p><input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?> "/></p> </form> <?php } else { ?> <h3>快捷管理</h3> <div class="v_avatar"> <?php echo bymt_avatar($user_email, 64); ?> </div> <div class="v_li"> <li><i class="icon-pencil"></i> <a href="<?php bloginfo('url'); ?> /wp-admin/post-new.php" rel="nofollow">撰写文章</a></li> <li><i class="icon-chat-1"></i> <a href="<?php bloginfo('url'); ?> /wp-admin/edit-comments.php" rel="nofollow">管理评论</a></li> <li><i class="icon-gear"></i> <a href="<?php bloginfo('url'); ?> /wp-admin/" rel="nofollow">控制面板</a></li> <li><i class="icon-logout"></i> <a href="<?php bloginfo('url'); ?> /wp-login.php?action=logout&redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']); ?> " rel="nofollow">注销登陆</a></li> </div> <?php } ?> </div> <?php }
function bymt_ajax_comment() { if (isset($_POST['action']) && $_POST['action'] == 'bymt_ajax_comment' && 'POST' == $_SERVER['REQUEST_METHOD']) { global $wpdb; nocache_headers(); $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0; $post = get_post($comment_post_ID); if (empty($post->comment_status)) { do_action('comment_id_not_found', $comment_post_ID); err(__('无效的评论状态')); // 將 exit 改為錯誤提示 } // get_post_status() will get the parent status for attachments. $status = get_post_status($post); $status_obj = get_post_status_object($status); if (!comments_open($comment_post_ID)) { do_action('comment_closed', $comment_post_ID); err(__('评论已关闭!')); // 將 wp_die 改為錯誤提示 } elseif ('trash' == $status) { do_action('comment_on_trash', $comment_post_ID); err(__('无效的评论状态')); // 將 exit 改為錯誤提示 } elseif (!$status_obj->public && !$status_obj->private) { do_action('comment_on_draft', $comment_post_ID); err(__('无效的评论状态')); // 將 exit 改為錯誤提示 } elseif (post_password_required($comment_post_ID)) { do_action('comment_on_password_protected', $comment_post_ID); err(__('受密码保护请先输入密码')); // 將 exit 改為錯誤提示 } else { do_action('pre_comment_on_post', $comment_post_ID); } $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : null; $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : null; $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : null; $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : null; $edit_id = isset($_POST['edit_id']) ? $_POST['edit_id'] : null; // 提取 edit_id // If the user is logged in $user = wp_get_current_user(); if ($user->exists()) { if (empty($user->display_name)) { $user->display_name = $user->user_login; } $comment_author = esc_sql($user->display_name); $comment_author_email = esc_sql($user->user_email); $comment_author_url = esc_sql($user->user_url); if (current_user_can('unfiltered_html')) { if (wp_create_nonce('unfiltered-html-comment_' . $comment_post_ID) != $_POST['_wp_unfiltered_html_comment']) { kses_remove_filters(); // start with a clean slate kses_init_filters(); // set up the filters } } } else { if (get_option('comment_registration') || 'private' == $status) { err(__('您必须先登陆才可以发表评论')); } // 將 wp_die 改為錯誤提示 } $comment_type = ''; if (get_option('require_name_email') && !$user->exists()) { if (6 > strlen($comment_author_email) || '' == $comment_author) { err(__('请填写昵称和邮箱')); } elseif (!is_email($comment_author_email)) { err(__('请填写一个有效的邮箱')); } // 將 wp_die 改為錯誤提示 } if ('' == $comment_content) { err(__('请输入评论内容')); } // 將 wp_die 改為錯誤提示 // 增加: 檢查重覆評論功能 $dupe = "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = '{$comment_post_ID}' AND ( comment_author = '{$comment_author}' "; if ($comment_author_email) { $dupe .= "OR comment_author_email = '{$comment_author_email}' "; } $dupe .= ") AND comment_content = '{$comment_content}' LIMIT 1"; if ($wpdb->get_var($dupe)) { err(__('您已经发布过一条相同的评论!')); } // 增加: 檢查評論太快功能 if ($lasttime = $wpdb->get_var($wpdb->prepare("SELECT comment_date_gmt FROM {$wpdb->comments} WHERE comment_author = %s ORDER BY comment_date DESC LIMIT 1", $comment_author))) { $time_lastcomment = mysql2date('U', $lasttime, false); $time_newcomment = mysql2date('U', current_time('mysql', 1), false); $flood_die = apply_filters('comment_flood_filter', false, $time_lastcomment, $time_newcomment); if ($flood_die) { err(__('请过一会再发表评论')); } } $comment_parent = isset($_POST['comment_parent']) ? absint($_POST['comment_parent']) : 0; $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); // 增加: 檢查評論是否正被編輯, 更新或新建評論 if ($edit_id) { // 判断当前用户是否具有编辑该评论权限 if (current_user_can("edit_comment", $edit_id)) { // 判断当前用户的邮箱是否与评论邮箱相同 if ($current_user->user_email == $comment_author_email) { $comment_id = $commentdata['comment_ID'] = $edit_id; wp_update_comment($commentdata); } else { err(__('您不能修改为他人评论!')); } } else { err(__('您没有权限编辑该评论!')); } } else { $comment_id = wp_new_comment($commentdata); } $comment = get_comment($comment_id); do_action('set_comment_cookies', $comment, $user); $comment_depth = 1; //为评论的 class 属性准备的 $tmp_c = $comment; while ($tmp_c->comment_parent != 0) { $comment_depth++; $tmp_c = get_comment($tmp_c->comment_parent); } //此处非常必要,无此处下面的评论无法输出 by mufeng $GLOBALS['comment'] = $comment; global $depth; //以下是評論式樣, 不含 "回覆". 要用你模板的式樣 copy 覆蓋. ?> <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?> " <?php if ($depth > get_option('thread_comments_depth') && !wp_is_mobile()) { echo ' style="margin-left:0px;"'; } ?> > <div id="div-comment-<?php comment_ID(); ?> " class="comment-body"> <?php $add_below = 'div-comment'; ?> <div class="comment-author vcard gravatar"><?php echo bymt_avatar($comment->comment_author_email); ?> </div> <div class="floor">新楼</div> <div class="commenttext"> <span class="commentid"><?php comment_author_link(); ?> </span> <?php get_author_class($comment->comment_author_email, $comment->comment_author_url); ?> <span class="datetime"><?php bymt_time_diff($time_type = 'comment'); ?> </span> <span class="edit_comment"><?php edit_comment_link('[编辑]'); ?> </span> <div class="comment_text"> <?php if ($comment->comment_approved == '0') { ?> <span style="color:#f00;">您的评论正在等待审核中...</span> <?php comment_text(); ?> <?php } else { ?> <?php comment_text(); ?> <?php } ?> </div> </div> </div> <?php die; //以上是評論式樣, 不含 "回覆". 要用你模板的式樣 copy 覆蓋. } else { return; } }
function bymt_mostactive($limit_num, $time) { if (!($mostactive = get_option('mostactive_' . $limit_num))) { global $wpdb; $noneurl = esc_url(home_url('/')); $my_email = "'" . get_bloginfo('admin_email') . "'"; //排除管理员评论 $counts = $wpdb->get_results("\n\t\t\tSELECT COUNT(comment_author) AS cnt, comment_author, comment_author_url, comment_author_email\n\t\t\tFROM (SELECT * FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts}\n\t\t\tON ({$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID)\n\t\t\tWHERE comment_date > date_sub( NOW(), INTERVAL {$time} )\n\t\t\tAND comment_author_email != {$my_email}\n\t\t\tAND post_password=''\n\t\t\tAND comment_approved='1'\n\t\t\tAND comment_type='') AS tempcmt GROUP BY comment_author_email\n\t\t\tORDER BY cnt DESC LIMIT {$limit_num}\n\t\t"); $mostactive = ''; if (empty($counts)) { $mostactive = '<a style="text-align: center;">暂时还没有</a>'; } else { foreach ($counts as $count) { $c_url = $count->comment_author_url; if ($c_url == '') { $c_url = $noneurl; } $title_alt = $count->comment_author . ' (' . $count->cnt . ' 条评论)'; if ($limit_num == '1') { $mostactive = '<a href="' . $c_url . '" rel="external nofollow" title="' . $title_alt . '">' . $count->comment_author . '</a>'; } else { $mostactive .= '<li><a href="' . $c_url . '" rel="external nofollow" title="' . $title_alt . '">' . bymt_avatar($count->comment_author_email, 36) . '<em>' . $count->comment_author . '</em><strong>+' . $count->cnt . '</strong></a></li>'; } } } update_option('mostactive_' . $limit_num, $mostactive); } if ($limit_num != '1') { $mostactive = "<ul class=\"readers-list\">" . $mostactive . "</ul>"; } echo $mostactive; }
?> <form method="post" id="comment_form"> <div id="input-box"> <div id="real-avatar"> <?php if (is_user_logged_in()) { ?> <?php global $user_email; echo bymt_avatar($user_email, 42); ?> <?php } elseif (isset($_COOKIE['comment_author_email_' . COOKIEHASH])) { ?> <?php echo bymt_avatar($comment_author_email, 42); ?> <?php } else { ?> <?php echo ''; ?> <?php } ?> </div> <div id="author-input"> <p id="welcome"> <?php if (is_user_logged_in()) {