-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
3,772 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* 邮件內容 | ||
*/ | ||
class_exists('Typecho_Widget') or die('This file can not be loaded directly.'); | ||
|
||
$prv_author = $parent['author']; // 被回复者 | ||
$prv_text = nl2br($parent['text']); // 被回复內容 | ||
$post_title = $comment->title; // 文章标题 | ||
$reply_author = $comment->author; // 回复者 | ||
$reply_text = nl2br($comment->text); // 回复內容 | ||
$permalink = $comment->permalink; // 新评论鏈接 | ||
$home_url = $options->siteUrl; // 博客鏈接 | ||
$blogname = $options->title; // 博客名称 | ||
|
||
// 邮件排版在下面, 请自行修改: | ||
$border = 'border-radius:5px'; | ||
$message = " | ||
<div style='background-color:#eef2fa; border:1px solid #d8e3e8; color:#111; padding:0 15px; -moz-$border; -webkit-$border; -khtml-$border; $border;'> | ||
<p>" . $prv_author . ", 您好!</p> | ||
<p>您曾在《" . $post_title . "》的留言:<br/>" | ||
. $prv_text . "</p> | ||
<p>" . $reply_author . " 给您的回复:<br/>" | ||
. $reply_text . "<br/></p> | ||
<p>您可以点击 <a href='" . $permalink . "'>查看回复完整内容</a></p> | ||
<p>欢迎再度光临 <a href='" . $home_url . "'>" . $blogname . "</a></p> | ||
<p>(此邮件由系统自动发出, 请勿回复.)</p> | ||
</div>"; | ||
|
||
// 标题及发件信息 | ||
$subject = '您在 ['. $blogname .'] 的评论有了回复'; | ||
$fromname = '=?UTF-8?B?'. base64_encode($blogname) .'?='; | ||
$from = 'no-reply@'. preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); | ||
|
||
|
||
/* 服务器若没开 mail(), 可使用 SMTP 代发, | ||
* 若要开啟 SMTP 功能, 请修改以下变量. | ||
* 服务器可使用 mail() 的就別改了. | ||
*/ | ||
$smtp_enable = 0; // SMTP 开关( 0:关, 1:开 ), 默认为 0 使用 mail(). | ||
$smtp_auth = true; // SMTP 是否要身份验证, 一般都要. | ||
$smtp_secure = 'ssl'; // 使用 SSL 加密連接, 若沒有 SSL, 留空 ''. | ||
$smtp_host = 'smtp.gmail.com'; // SMTP 服務器. | ||
$smtp_port = 465; // SMTP 服務器端口, 一般为 25, gmail 为 465. | ||
$smtp_username = '[email protected]'; // 用戶名, 一般为邮箱名. | ||
$smtp_password = 'xxxxxxxxxx'; // 登入密码. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* 发送邮件 | ||
*/ | ||
class_exists('Typecho_Widget') or die('This file can not be loaded directly.'); | ||
|
||
class_exists('PHPMailer') or require('AjaxComments/class.phpmailer.php'); | ||
|
||
$phpmailer = new PHPMailer(); | ||
|
||
if ($smtp_enable) { | ||
$phpmailer->IsSMTP(); | ||
$phpmailer->SMTPAuth = $smtp_auth; | ||
$phpmailer->SMTPSecure = $smtp_secure; | ||
$phpmailer->Host = $smtp_host; | ||
$phpmailer->Port = $smtp_port; | ||
$phpmailer->Username = $smtp_username; | ||
$phpmailer->Password = $smtp_password; | ||
} | ||
|
||
$phpmailer->AddAddress($to); | ||
$phpmailer->Body = $message; | ||
$phpmailer->CharSet = 'UTF-8'; | ||
$phpmailer->FromName = $fromname; | ||
$phpmailer->From = $from; | ||
$phpmailer->IsHTML(true); | ||
$phpmailer->Subject = $subject; | ||
$phpmailer->Send(); // 寄出 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<?php | ||
class_exists('Typecho_Widget') or die('This file can not be loaded directly.'); | ||
|
||
$options = Typecho_Widget::widget('Widget_Options'); | ||
$pic_url = $options->pluginUrl .'/AjaxComments/'; | ||
$config = $options->plugin('AjaxComments'); | ||
?> | ||
<script type="text/javascript"> | ||
// <![CDATA[ | ||
// Ajax Comments v1.0.4 for Typecho Threaded Comments - by willin kan - URI: http://kan.willin.org/typecho/ | ||
var | ||
ld_img = '<img src="<?php echo $pic_url; ?>loading.gif" alt=""/> ', | ||
er_img = '<img src="<?php echo $pic_url; ?>no.png" alt=""/> ', | ||
ok_img = '<img src="<?php echo $pic_url; ?>yes.png" alt=""/> ', | ||
htm_1 = '<div id="loading">' + ld_img + '<\/div><div id="error">' + er_img + '<span id="msg"><\/span><\/div>', | ||
htm_2 = '<div class="success">' + ok_img + '提交成功.<\/div>', | ||
htm_3 = '<textarea name="ajaxComment" class="comm_area" cols="100%" rows="4"><\/textarea>', | ||
txt_1 = '必须填写用户名', | ||
txt_2 = '必须填写电子邮箱地址', | ||
txt_3 = '邮箱地址不合法', | ||
txt_4 = '必须填写评论内容', | ||
txt_5 = 'Spam Detected!'; | ||
|
||
//jQuery.noConflict(); | ||
//jQuery(document).ready(function($) { | ||
function ajaxComments(){ | ||
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); | ||
|
||
var | ||
wait_time = <?php echo $options->commentsPostIntervalEnable * $options->commentsPostInterval; ?>, | ||
comments_order = '<?php echo $options->commentsOrder; ?>', | ||
comment_list = '<?php echo $config->_comment_list; ?>', | ||
comments = '<?php echo $config->_comments; if (strpos($config->_comments, " ")) echo ":first"; ?>', | ||
comment_reply = '<?php echo $config->_comment_reply; ?>', | ||
comment_form = '<?php echo $config->_comment_form; ?>', | ||
respond = '<?php echo $config->_respond; ?>', | ||
textarea = '<?php echo $config->_textarea; ?>', | ||
submit_btn = '<?php echo $config->_submit; ?>', | ||
|
||
new_id = '', parent_id = ''; | ||
$(textarea).after(htm_1, htm_3); | ||
$('#loading, #error, .comm_area').hide(); | ||
$(submit_btn).attr('disabled', false); | ||
$msg = $('#msg'); | ||
|
||
click_bind(); | ||
|
||
$(comment_form).submit(function() { // 提交 | ||
$msg.empty(); | ||
$('#error').hide(); | ||
$(submit_btn).attr('disabled', true).fadeTo('slow', 0.5); | ||
|
||
/* 预检 */ | ||
if($(comment_form).find('#author')[0]) { | ||
|
||
if($(comment_form).find('#author').val() == '') { | ||
$msg.text(txt_1); | ||
err_effect(); return false; | ||
} | ||
|
||
if($(comment_form).find('#mail').val() == '') { | ||
$msg.text(txt_2); | ||
err_effect(); return false; | ||
} | ||
|
||
var filter = /^[^@\s<&>]+@([a-z0-9]+\.)+[a-z]{2,4}$/i; | ||
if(!filter.test($(comment_form).find('#mail').val())) { | ||
$msg.text(txt_3); | ||
err_effect(); return false; | ||
} | ||
|
||
if($(comment_form).find('.comm_area').val() != '') { | ||
$msg.text(txt_5); | ||
$('#error').slideDown(); return false; | ||
} | ||
|
||
} | ||
|
||
if($(comment_form).find(textarea).val() == '') { | ||
$msg.text(txt_4); | ||
err_effect(); return false; | ||
} | ||
|
||
$('#loading').show(); | ||
|
||
$.ajax({ | ||
url: $(this).attr('action'), | ||
type: $(this).attr('method'), | ||
data: $(this).serializeArray(), | ||
|
||
success: function(data) { | ||
$('#loading').slideUp(); | ||
|
||
try { | ||
if (!$(comment_list, data).length) { | ||
if (data.indexOf('Error') > -1) { // 返回 Error | ||
$msg.text($('p', data).text()); | ||
} else { | ||
$msg.html(data); | ||
if (data.indexOf('Spam') > -1) {$('#error').slideDown(); return false;} | ||
} | ||
err_effect(); return false; | ||
|
||
} else { | ||
|
||
new_id = $(comment_list, data).html().match(/id=\"?comment-\d+/g).join().match(/\d+/g).sort(function(a,b){return a-b}).pop(); // 找新 id | ||
|
||
data = $('#comment-' + new_id, data).hide(); // 取新评论 | ||
|
||
$('#reply-to-' + new_id, data).before(htm_2); | ||
|
||
if (!$(comment_list).length) $(respond).before('<ol <?php echo strtr( $config->_comment_list, array( "." => "class=\"", "#" => "id=\"")). "\""; ?>><\/ol>'); // 加 ol | ||
|
||
parent_id | ||
? (comments_order == 'DESC' && $('#' + parent_id + ' li').length ? $('#' + parent_id + ' li:first').before(data) : $(respond).before(data), parent_id = '') // 子层 | ||
: $(comment_list+':first').append(data); // 底层 | ||
|
||
$('#comment-' + new_id).fadeIn(); // 显示 | ||
$(comments).length ? (n = parseInt($(comments).text().match(/\d+/)), $(comments).text($(comments).text().replace(n, n + 1))) : 0; // 评论数 | ||
|
||
TypechoComment.cancelReply(); | ||
$(textarea).attr('value', ''); | ||
$(textarea).val(''); | ||
$(comment_reply + ' a, #cancel-comment-reply-link').unbind('click'); click_bind(); // 新评论绑定 | ||
$('#author').length ? countdown() : $(submit_btn).attr('disabled', false).fadeTo('slow', 1); | ||
$body.animate({scrollTop: $('#comment-' + new_id).offset().top - 200}, 500); | ||
|
||
} | ||
} catch (e) { | ||
alert('Error!\n\n' + e); | ||
} | ||
|
||
} // end success() | ||
|
||
}); // end ajax() | ||
|
||
|
||
return false; | ||
|
||
}); // end $(comment_form).submit() | ||
|
||
function click_bind() { // 绑定 | ||
$(comment_reply + ' a').click(function() { // 回复 | ||
$body.animate({scrollTop: $(respond).offset().top - 180}, 400); | ||
h = $(this)[0].href; | ||
parent_id = 'comment-' + h.substring(h.indexOf('replyTo=') + 8, h.indexOf('#')); | ||
$(textarea).focus(); | ||
}); | ||
$('#cancel-comment-reply-link').click(function() { // 取消 | ||
parent_id = ''; | ||
}); | ||
} | ||
|
||
function err_effect() { // 出错 | ||
$('#error').slideDown(); | ||
setTimeout(function() {$(submit_btn).attr('disabled', false).fadeTo('', 1); $('#error').slideUp();}, 3000); | ||
} | ||
|
||
var wait = wait_time, submit_val = $(comment_form).find(submit_btn).val(); | ||
|
||
function countdown() { // 计时 | ||
wait > 0 ? ($(submit_btn).val(wait), wait--, setTimeout(countdown, 1000)) | ||
: ($(submit_btn).val(submit_val).attr('disabled', false).fadeTo('slow', 1), wait = wait_time); | ||
} | ||
}; | ||
//}); // end jQ | ||
// ]]> | ||
</script> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.