1
0
Fork 0
mirror of https://github.com/yunluo/gdk.git synced 2024-05-13 11:46:57 +02:00

更新量太大,不一一叙说

This commit is contained in:
云落 2020-02-06 18:51:43 +08:00
parent b0164a2fb6
commit f3a8f8f61c
21 changed files with 277 additions and 421 deletions

View file

@ -25,12 +25,13 @@ function gdk_enqueue_script_frontend() {
wp_enqueue_script('code_prettify_js', GDK_BASE_URL.'assets/js/prettify.min.js', array('jquery'), GDK_PLUGIN_VER, true);
wp_enqueue_script('fancybox_js', GDK_BASE_URL.'assets/js/fancybox.min.js', array('jquery'), GDK_PLUGIN_VER, true);
wp_enqueue_script('lazyload_js', GDK_BASE_URL.'assets/js/lazyload.min.js', array('jquery'), GDK_PLUGIN_VER, true);
wp_enqueue_script('sweetalert_js','https://cdn.jsdelivr.net/npm/sweetalert@2.0.0/dist/sweetalert.min.js', [], GDK_PLUGIN_VER, true);
wp_enqueue_script('sweetalert_js','https://cdn.jsdelivr.net/combine/npm/sweetalert@2.0.0,npm/qrious@4.0.2', [], GDK_PLUGIN_VER, true);
wp_enqueue_script('gdk_js', GDK_BASE_URL.'assets/js/gdk.js', array('jquery'), GDK_PLUGIN_VER, true);
wp_localize_script('gdk_js', 'ajax', [
'url'=> admin_url('admin-ajax.php'),
'pass_nonce' => wp_create_nonce('pass_nonce'),
'pay_points' => wp_create_nonce('pay_points')
'pay_points' => wp_create_nonce('pay_points'),
'check_pay_points' => wp_create_nonce('check_pay_points')
]);

View file

@ -13,4 +13,5 @@ body.compensate-for-scrollbar{overflow:hidden}.fancybox-active{height:auto}.fanc
.info{background-color:#e4f0f5;border-color:#3d7e9a}
.success{background-color:#ebf8e1;border-color:#4d9f0c}
.error{background-color:#ffe7e8;border-color:#e66465}
.swal-footer {text-align: center !important;}
.swal-footer {text-align: center !important;}
.swal-button {background-color: #9b4dca !important;}.swal-button:hover {background-color: #54397E !important;}

View file

@ -74,20 +74,21 @@ var money = $("#money").val(),
/**检查服务器是否有订单 */
function checkpayjs(a, b) { //ID订单号
var ajax_data = {
action: 'checkpayjs',
check_pay_points: ajax.check_pay_points,
action: 'check_pay_points',
id: a,
orderid: b,
orderid: b
};
$.post(ajax.url, ajax_data,
function(c) {
if (c == '1') {
if (c == '200') {
swal("支付成功!", "为了方便您后续再次查看,建议您输入您的常用邮箱作为提取码", "info", {
dangerMode: true,
closeOnClickOutside: false,
content: "input",
})
.then((d) => {
getcontent(a);
gdk_getcontent(a);
addcode(a, `${d}`);
}); //ok
} else {
@ -109,14 +110,15 @@ var money = $("#money").val(),
$.post(ajax.url, ajax_data,
function(d) {
if (d !== '400') {
console.log(d);
var f = document.createElement("img"),
e = d.split('|');
f.id = 'pqrious';
console.log(e[3]);
swal("支付金额:" + e[0] + "元", {
content: f,
closeOnClickOutside: false,
button: "支付已完成",
button: ""+e[2]+"支付已完成",
})
.then((value) => {
checkpayjs(c, e[1]);/**用户id,订单号 */
@ -127,7 +129,7 @@ var money = $("#money").val(),
value: e[3]
});
}else{
swal("充值发生错误", "哦嚯,好像发生了什么错误", "error");
swal("充值发生错误", "哦嚯,好像发生了什么错误,二维码加载失败", "error");
}
});
}

View file

@ -30,7 +30,7 @@ function checkpayjs(a, b) { //ID订单号
content: "input",
})
.then((d) => {
getcontent(a);
gdk_getcontent(a);
addcode(a, `${d}`);
}); //ok
} else {
@ -87,9 +87,9 @@ function payway(a, b) { //id,money
}
function getcontent(a) {
function gdk_getcontent(a) {
var ajax_data = {
action: 'getcontent',
action: 'gdk_getcontent',
id: a
};
$.post(ajax.url, ajax_data,
@ -103,7 +103,7 @@ function getcontent(a) {
function checkcode(a, b) {
var ajax_data = {
action: 'check_code',
action: 'gdk_check_code',
id: a,
code: b
};
@ -111,7 +111,7 @@ function checkcode(a, b) {
function(c) {
if (c == 1) {
localStorage.setItem('ID:'+a,b);
getcontent(a);
gdk_getcontent(a);
} else {
swal("Write something here:", {
content: "input",

View file

@ -1,6 +1,6 @@
<?php
class Payjs
class GDK_Payjs
{
private $mchid;
private $key;

View file

@ -2,7 +2,7 @@
function wp_clean_up_page(){
function gdk_clean_up_page(){
?>
<div class="wrap">

View file

@ -1,6 +1,6 @@
<?php
/**
* Points Table class
* GDK_Points Table class
*/
// WP_List_Table is not loaded automatically so we need to load it in our application
@ -8,7 +8,7 @@ if ( !class_exists( 'WP_List_Table' ) ) {
require_once (ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
}
class Points_List_Table extends WP_List_Table {
class GDK_Points_List_Table extends WP_List_Table {
/**
* Prepare the items for the table to process
*
@ -108,7 +108,7 @@ class Points_List_Table extends WP_List_Table {
*/
private function table_data() {
$data = [];
$data = Points::get_points( null, null, null, ARRAY_A );
$data = GDK_Points::get_points( null, null, null, ARRAY_A );
return $data;
}
@ -180,9 +180,9 @@ class Points_List_Table extends WP_List_Table {
/**
* Points Admin class
* GDK_Points Admin class
*/
class Points_Admin {
class GDK_Points_Admin {
public static function init () {
add_action( 'admin_notices', [ __CLASS__, 'admin_notices' ] );
@ -210,15 +210,15 @@ class Points_Admin {
$sdata = trim($_POST['psearch']);
if(preg_match('/E20/', $sdata)){//order id
global $wpdb;
$point_id = $wpdb->get_row("SELECT point_id FROM " . Points_Database::points_get_table( "users" ) . " WHERE description = '{$sdata}'", ARRAY_A )['point_id'];
$points = Points::get_point( $point_id );
$point_id = $wpdb->get_row("SELECT point_id FROM " . GDK_Points_Database::points_get_table( "users" ) . " WHERE description = '{$sdata}'", ARRAY_A )['point_id'];
$points = GDK_Points::get_point( $point_id );
}elseif(filter_var($sdata, FILTER_VALIDATE_EMAIL)){//email
$user = get_user_by( 'email', $sdata );
$points = Points::get_points_by_user( $user->ID );
$k[] = '<div style="margin-bottom:10px;">用户ID'.$user->ID.' &nbsp;&nbsp;总金币为:'.Points::get_user_total_points( $user->ID ).'</div>';
$points = GDK_Points::get_points_by_user( $user->ID );
$k[] = '<div style="margin-bottom:10px;">用户ID'.$user->ID.' &nbsp;&nbsp;总金币为:'.GDK_Points::get_user_total_points( $user->ID ).'</div>';
}else{//userid
$points = Points::get_points_by_user( $sdata );
$k[] = '<div style="margin-bottom:10px;">用户ID'.$sdata.' &nbsp;&nbsp;总金币为:'.Points::get_user_total_points( $sdata ).'</div>';
$points = GDK_Points::get_points_by_user( $sdata );
$k[] = '<div style="margin-bottom:10px;">用户ID'.$sdata.' &nbsp;&nbsp;总金币为:'.GDK_Points::get_user_total_points( $sdata ).'</div>';
}
if(is_array($points)){
foreach ( $points as $point ) {
@ -233,7 +233,7 @@ class Points_Admin {
if ( isset( $_POST['save'] ) && isset( $_POST['action'] ) ) {
if ( $_POST['action'] == "edit" ) {
$point_id = isset($_POST['point_id'])?intval( $_POST['point_id'] ) : null;
$points = Points::get_point( $point_id );
$points = GDK_Points::get_point( $point_id );
$data = array();
if ( isset( $_POST['user_mail'] ) ) {
$data['user_mail'] = $_POST['user_mail'];
@ -255,7 +255,7 @@ class Points_Admin {
}
if ( $points ) { // 编辑金币
Points::update_points($point_id, $data);
GDK_Points::update_points($point_id, $data);
} else { // 增加金币
if ( isset( $_POST['user_mail'] ) ) {//如果输入邮箱的话
$usermail = $data['user_mail'];
@ -269,8 +269,8 @@ class Points_Admin {
$userid = $data['user_id'];
$username = $user->display_name;
}
Points::set_points($_POST['points'], $userid, $data);
$message = '<div class="emailcontent" style="width:100%;max-width:720px;text-align:left;margin:0 auto;padding-top:80px;padding-bottom:20px"><div class="emailtitle"><h1 style="color:#fff;background:#51a0e3;line-height:70px;font-size:24px;font-weight:400;padding-left:40px;margin:0">金币金额调整通知</h1><div class="emailtext" style="background:#fff;padding:20px 32px 40px"><div style="padding:0;font-weight:700;color:#6e6e6e;font-size:16px">尊敬的'.$username.',您好!</div><p style="color:#6e6e6e;font-size:13px;line-height:24px">您的金币金额被管理员调整,请查收!</p><table cellpadding="0" cellspacing="0" border="0" style="width:100%;border-top:1px solid #eee;border-left:1px solid #eee;color:#6e6e6e;font-size:16px;font-weight:normal"><thead><tr><th colspan="2" style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center;background:#f8f8f8">您的金币详细情况</th></tr></thead><tbody><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center;width:100px">用户名</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.$username.'</td></tr><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center">调整金币</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.$_POST['points'].'</td></tr><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center">金币总额</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.Points::get_user_total_points($userid, 'accepted' ).'</td></tr></tbody></table><p style="color:#6e6e6e;font-size:13px;line-height:24px">如果您的金币金额有异常,请您在第一时间和我们取得联系哦,联系邮箱:'.get_bloginfo('admin_email').'</p></div><div class="emailad" style="margin-top:4px"><a href="'.home_url().'"><img src="http://reg.163.com/images/secmail/adv.png" alt="" style="margin:auto;width:100%;max-width:700px;height:auto"></a></div></div></div>';
GDK_Points::set_points($_POST['points'], $userid, $data);
$message = '<div class="emailcontent" style="width:100%;max-width:720px;text-align:left;margin:0 auto;padding-top:80px;padding-bottom:20px"><div class="emailtitle"><h1 style="color:#fff;background:#51a0e3;line-height:70px;font-size:24px;font-weight:400;padding-left:40px;margin:0">金币金额调整通知</h1><div class="emailtext" style="background:#fff;padding:20px 32px 40px"><div style="padding:0;font-weight:700;color:#6e6e6e;font-size:16px">尊敬的'.$username.',您好!</div><p style="color:#6e6e6e;font-size:13px;line-height:24px">您的金币金额被管理员调整,请查收!</p><table cellpadding="0" cellspacing="0" border="0" style="width:100%;border-top:1px solid #eee;border-left:1px solid #eee;color:#6e6e6e;font-size:16px;font-weight:normal"><thead><tr><th colspan="2" style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center;background:#f8f8f8">您的金币详细情况</th></tr></thead><tbody><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center;width:100px">用户名</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.$username.'</td></tr><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center">调整金币</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.$_POST['points'].'</td></tr><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center">金币总额</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.GDK_Points::get_user_total_points($userid, 'accepted' ).'</td></tr></tbody></table><p style="color:#6e6e6e;font-size:13px;line-height:24px">如果您的金币金额有异常,请您在第一时间和我们取得联系哦,联系邮箱:'.get_bloginfo('admin_email').'</p></div><div class="emailad" style="margin-top:4px"><a href="'.home_url().'"><img src="http://reg.163.com/images/secmail/adv.png" alt="" style="margin:auto;width:100%;max-width:700px;height:auto"></a></div></div></div>';
$headers = "Content-Type:text/html;charset=UTF-8\n";
wp_mail( $usermail , 'Hi,'.$username.',金币账户金额增加通知!', $message ,$headers);
}
@ -291,9 +291,9 @@ class Points_Admin {
case 'delete' :
if ( $_GET['point_id'] !== null ) {
if ( current_user_can( 'administrator' ) ) {
Points::remove_points( $_GET['point_id'] );
GDK_Points::remove_points( $_GET['point_id'] );
global $wpdb;
$wcu_sql = "DELETE FROM " . Points_Database::points_get_table( "users" ) . " WHERE status = 'removed'";
$wcu_sql = "DELETE FROM " . GDK_Points_Database::points_get_table( "users" ) . " WHERE status = 'removed'";
$wpdb->query($wcu_sql);
$alert= "金币已删除";
}
@ -311,7 +311,7 @@ class Points_Admin {
$cancel_url = remove_query_arg( 'point_id', remove_query_arg( 'action', $current_url ) );
$current_url = remove_query_arg( 'point_id', $current_url );
$current_url = remove_query_arg( 'action', $current_url );
$exampleListTable = new Points_List_Table();
$exampleListTable = new GDK_Points_List_Table();
$exampleListTable->prepare_items();
?>
<div class="wrap">
@ -343,7 +343,7 @@ class Points_Admin {
$saved = false; // temporal
if ( $point_id !== null ) {
$points = Points::get_point( $point_id );
$points = GDK_Points::get_point( $point_id );
if ( $points !== null ) {
$user_id = $points->user_id;

View file

@ -2,7 +2,7 @@
/**
* class-points-shortcodes.php
*/
class Points_Shortcodes {
class GDK_Points_Shortcodes {
/**
* Add shortcodes.
*/
@ -24,10 +24,10 @@ class Points_Shortcodes {
);
extract( $options );
$output = "";
$pointsusers = Points::get_users();
$pointsusers = GDK_Points::get_users();
if ( sizeof( $pointsusers )>0 ) {
foreach ( $pointsusers as $pointsuser ) {
$total = Points::get_user_total_points( $pointsuser );
$total = GDK_Points::get_user_total_points( $pointsuser );
$output .='<div class="points-user">';
$output .= '<span style="font-weight:bold;width:100%;" class="points-user-username">';
$output .= get_user_meta ( $pointsuser, 'nickname', true );
@ -52,7 +52,7 @@ class Points_Shortcodes {
$id = get_current_user_id();
}
if ( $id !== 0 ) {
$points = Points::get_user_total_points( $id, 'accepted' );
$points = GDK_Points::get_user_total_points( $id, 'accepted' );
$output .= $points;
}
return $output;
@ -64,7 +64,7 @@ public static function pay($atts, $content = null) {
global $wpdb;
$user_id = get_current_user_id();
$description = get_the_ID();
$result = $wpdb->get_row("SELECT description FROM " . Points_Database::points_get_table("users") . " WHERE user_id=" . $user_id . " AND description=" . $description . " AND status='accepted' LIMIT 0, 3;", ARRAY_A )['description']; //验证是否支付
$result = $wpdb->get_row("SELECT description FROM " . GDK_Points_Database::points_get_table("users") . " WHERE user_id=" . $user_id . " AND description=" . $description . " AND status='accepted' LIMIT 0, 3;", ARRAY_A )['description']; //验证是否支付
extract(shortcode_atts(['point' => "10"], $atts));
$notice = '';
$pay_content = get_post_meta($description, 'pay_content', true);
@ -79,21 +79,21 @@ public static function pay($atts, $content = null) {
$notice.= $content;
$notice.= '</div>';
} else {
if (Points::get_user_total_points($user_id, 'accepted') < $point) {
if (GDK_Points::get_user_total_points($user_id, 'accepted') < $point) {
$notice.= '<div class="alert alert-info"">';
$notice.= '<p style="color:red;">本段内容需要支付 ' . $point . '金币查看</p>';
$notice.= '<p style="color:red;">您当前拥有 <em><strong>' . Points::get_user_total_points($user_id, 'accepted') . '</strong></em> 金币,您的金币不足,请充值</p>';
$notice.= '<p style="color:red;">您当前拥有 <em><strong>' . GDK_Points::get_user_total_points($user_id, 'accepted') . '</strong></em> 金币,您的金币不足,请充值</p>';
$notice.= '<p><a class="lhb" href="' . get_permalink(gdk_page_id('chongzhi')) . '" target="_blank" rel="nofollow" data-original-title="立即充值" title="">立即充值</a></p>';
$notice.= '</div>';
} else {
$notice.= '<div id="pay_notice" class="alert alert-info"">';
$notice.= '<p style="color:red;">本段内容需要付费查看,您当前拥有 <em><strong>' . Points::get_user_total_points($user_id, 'accepted') . '</strong></em> 金币</p>';
$notice.= '<p style="color:red;">本段内容需要付费查看,您当前拥有 <em><strong>' . GDK_Points::get_user_total_points($user_id, 'accepted') . '</strong></em> 金币</p>';
$notice.= '<p><a class="lhb" style="cursor: pointer;" onclick="pay_point();">点击购买</a></p>';
$notice.= '</div>';
$notice.= '<p id="pay_success"></p>';
echo '<script type="text/javascript">
function pay_point() {
ajax.post("' . admin_url('admin-ajax.php') . '", "action=pay_buy&point=' . $point . '&userid=' . $user_id . '&id=' . $description . '", function(n) {
ajax.post("' . admin_url('admin-ajax.php') . '", "action=gdk_pay_buy&point=' . $point . '&userid=' . $user_id . '&id=' . $description . '", function(n) {
null != n && (document.getElementById("pay_notice").style.display = "none", document.getElementById("pay_success").innerHTML = "<div class=\"alert alert-info\">" + n + "</div>");
});
}</script>';
@ -137,7 +137,7 @@ function pay_point() {
global $wp_query;
$curauth = $wp_query->get_queried_object();
$user_id = $curauth->ID;
$points = Points::get_points_by_user( $user_id );
$points = GDK_Points::get_points_by_user( $user_id );
$output = '<table class="points_user_points_table">' .
'<tr>' .
'<th>日期时间' .
@ -171,4 +171,4 @@ function pay_point() {
return $output;
}
}
Points_Shortcodes::init();
GDK_Points_Shortcodes::init();

View file

@ -1,9 +1,9 @@
<?php
/**
* Points_Database class
* GDK_Points_Database class
*/
class Points_Database {
class GDK_Points_Database {
public static $prefix = "points_";
public static function points_get_table( $table ) {
global $wpdb;
@ -19,9 +19,9 @@ class Points_Database {
/**
* Points class
* GDK_Points class
*/
class Points {
class GDK_Points {
public static function get_points_by_user ( $user_id, $limit = null, $order_by = null, $order = null, $output = OBJECT, $offset = 0 ) {
global $wpdb;
@ -39,7 +39,7 @@ class Points {
$order_str = " " . $order;
}
$result = $wpdb->get_results('SELECT * FROM ' . Points_Database::points_get_table( 'users' ) . " WHERE user_id = '$user_id'" . $order_by_str . $order_str . $limit_str, $output );
$result = $wpdb->get_results('SELECT * FROM ' . GDK_Points_Database::points_get_table( 'users' ) . " WHERE user_id = '$user_id'" . $order_by_str . $order_str . $limit_str, $output );
return $result;
}
@ -53,7 +53,7 @@ class Points {
if ( $status !== null ) {
$where_status = " AND status = '" . $status . "'";
}
$points = $wpdb->get_row("SELECT SUM(points) as total FROM " . Points_Database::points_get_table( "users" ) . " WHERE user_id = '$user_id' " . $where_status);
$points = $wpdb->get_row("SELECT SUM(points) as total FROM " . GDK_Points_Database::points_get_table( "users" ) . " WHERE user_id = '$user_id' " . $where_status);
if ( $points && ( $points->total !== NULL ) ) {
$result = $points->total;
@ -68,7 +68,7 @@ class Points {
if ( $status !== null ) {
$where_status = " WHERE status = '" . $status . "'";
}
$points = $wpdb->get_results("SELECT SUM(points) as total, user_id FROM " . Points_Database::points_get_table( "users" ) . $where_status . " GROUP BY user_id");
$points = $wpdb->get_results("SELECT SUM(points) as total, user_id FROM " . GDK_Points_Database::points_get_table( "users" ) . $where_status . " GROUP BY user_id");
return $points;
}
@ -81,7 +81,7 @@ class Points {
public static function get_users() {
global $wpdb;
$users_id = $wpdb->get_results("SELECT user_id FROM " . Points_Database::points_get_table( "users" ) . " GROUP BY user_id");
$users_id = $wpdb->get_results("SELECT user_id FROM " . GDK_Points_Database::points_get_table( "users" ) . " GROUP BY user_id");
$result = array();
if ( sizeof( $users_id ) > 0 ) {
@ -122,7 +122,7 @@ class Points {
}
$values['user_id'] = $user_id;
$rows_affected = $wpdb->insert( Points_Database::points_get_table("users"), $values );
$rows_affected = $wpdb->insert( GDK_Points_Database::points_get_table("users"), $values );
return $rows_affected;
}
@ -152,7 +152,7 @@ class Points {
$order_str = " " . $order;
}
$result = $wpdb->get_results("SELECT * FROM " . Points_Database::points_get_table( "users" ) . $where_str . $order_by_str . $order_str . $limit_str, $output );
$result = $wpdb->get_results("SELECT * FROM " . GDK_Points_Database::points_get_table( "users" ) . $where_str . $order_by_str . $order_str . $limit_str, $output );
return $result;
}
@ -165,7 +165,7 @@ class Points {
if ( isset( $point_id ) && ( $point_id !== null ) ) {
$points_id_str = " WHERE point_id = " . (int)$point_id;
$result = $wpdb->get_row("SELECT * FROM " . Points_Database::points_get_table( "users" ) . $points_id_str );
$result = $wpdb->get_row("SELECT * FROM " . GDK_Points_Database::points_get_table( "users" ) . $points_id_str );
}
return $result;
@ -177,7 +177,7 @@ class Points {
$values = array();
$values['status'] = 'removed';
$rows_affected = $wpdb->update( Points_Database::points_get_table("users"), $values , array( 'point_id' => $point_id ) );
$rows_affected = $wpdb->update( GDK_Points_Database::points_get_table("users"), $values , array( 'point_id' => $point_id ) );
if ( !$rows_affected ) {
$rows_affected = null;
@ -218,7 +218,7 @@ class Points {
$values['ipv6'] = $info['ipv6'];
}
$rows_affected = $wpdb->update( Points_Database::points_get_table("users"), $values , array( 'point_id' => $point_id ) );
$rows_affected = $wpdb->update( GDK_Points_Database::points_get_table("users"), $values , array( 'point_id' => $point_id ) );
if ( !$rows_affected ) { // insert
$rows_affected = null;

View file

@ -6,7 +6,7 @@ include 'class-points-admin.php';
include 'class-points-shortcodes.php';
class Points_Class {
class GDK_Points_Class {
private static $notices = [];
public static function init() {
add_action( 'init', [ __CLASS__, 'wp_init' ] );
@ -14,7 +14,7 @@ class Points_Class {
}
public static function wp_init() {
Points_Admin::init();
GDK_Points_Admin::init();
}
/**
@ -33,7 +33,7 @@ class Points_Class {
}
// create tables
$points_users_table = Points_Database::points_get_table("users");
$points_users_table = GDK_Points_Database::points_get_table("users");
if ( $wpdb->get_var( "SHOW TABLES LIKE '$points_users_table'" ) != $points_users_table ) {
$queries[] = "CREATE TABLE $points_users_table (
point_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
@ -56,4 +56,4 @@ class Points_Class {
}
}
}
Points_Class::init();
GDK_Points_Class::init();

View file

@ -380,6 +380,12 @@ $gdk_options = [
'id' => 'gdk_compress',
'type' => 'checkbox'
],
[
'name' => '文章目录',
'desc' => '启用 【开启后,将在文章页显示一个文章目录】',
'id' => 'gdk_article_list',
'type' => 'checkbox'
],
[
'name' => '侧边栏缓存',
'desc' => '启用 【开启后,将会自动缓存小工具,如果想禁止缓存某个小工具,可以去小工具页面排除】',
@ -401,6 +407,12 @@ $gdk_options = [
],
'std' => '0'
],
[
'name' => '支付宝支付通道',
'desc' => '启用 【开启后,将增加支付宝支付方式,支付宝通道需要到payjs申请开通,如果开通的话,建议使用支付宝,因为费率便宜】',
'id' => 'gdk_payjs_alipay',
'type' => 'checkbox'
],
[
'name' => '金币和RMB兑换关系',
'desc' => '请输入兑换关系默认1RMB=10金币请慎重选择一旦设置好后面不能修改的,本选项仅对会员金币支付生效,游客免登陆支持不受影响',

View file

@ -9,7 +9,7 @@
$current_theme = wp_get_theme();
$gdk_default_options = [];
$gdk_options = [];
$gdk_options = array();
include('options-config.php');
$gdk_current_options = get_option('gdk_options_setup');
@ -162,7 +162,7 @@ switch ( $type ) {
?>
<div class="panel" id="panel_data">
<table class="form-table">
<?php echo wp_clean_up_page();?>
<?php echo gdk_clean_up_page();?>
</table>
</div>
<div class="panel" id="panel_about">
@ -344,9 +344,9 @@ jQuery(function ($) {
function(a) {
a = $.trim(a);
if (a == '200') {
alert("测试成功", "您的SMTP邮箱邮件发送已成功,Enjoy it");
alert("测试成功,您的SMTP邮箱邮件发送已成功,Enjoy it");
}else{
swal("测试失败", "您的SMTP邮箱邮件响应失败,请重试", "error");
alert("测试失败,您的SMTP邮箱邮件响应失败,请重试");
}
});
});

View file

@ -29,17 +29,17 @@ function gdk_pasteup_imag() {
global $post;
$post_ID = $post->ID;
$wp_upload_dir = wp_upload_dir();
$file = $_FILES["imageFile"];
$result=array ("success"=>false,"message"=>"Null");
if (in_array($file["type"],array ("image/gif","image/jpeg","image/pjpeg","image/png"))) {
if ($file["error"]>0) {
$result['message']="error";
$file = $_FILES['imageFile'];
$result=array ('success'=>false,'message'=>'Null');
if (in_array($file['type'],array ('image/gif','image/jpeg','image/pjpeg','image/png'))) {
if ($file['error']>0) {
$result['message']='error';
} else {
$file_name = md5_file($file["tmp_name"]).str_replace("image/",".",$file["type"]);//img name
$file_url = $wp_upload_dir['url']."/".$file_name;
$file_path = $wp_upload_dir['path']."/".$file_name;
$file_name = md5_file($file['tmp_name']).str_replace('image/','.',$file['type']);//img name
$file_url = $wp_upload_dir['url'].'/'.$file_name;
$file_path = $wp_upload_dir['path'].'/'.$file_name;
if (!file_exists($file_path)) {
move_uploaded_file($file["tmp_name"],$file_path);
move_uploaded_file($file['tmp_name'],$file_path);
$attachment = [
'guid' => $wp_upload_dir['url'] . '/' . basename( $file_path ),
'post_mime_type' => $file['type'],
@ -57,7 +57,7 @@ function gdk_pasteup_imag() {
$result['message'] = $file_url;
}
} else {
$result['message'] = "400";
$result['message'] = '400';
}
echo(json_encode($result));
exit();
@ -83,254 +83,37 @@ function gdk_pass_view() {
add_action('wp_ajax_nopriv_gdk_pass_view', 'gdk_pass_view');
add_action('wp_ajax_gdk_pass_view', 'gdk_pass_view');
//密码可见end
//在线充值
//在线积分充值
function pay_points() {
if( !isset( $_POST['pay_points'] ) || !wp_verify_nonce($_POST['pay_points'], 'pay_points') ) exit('400');
if (!isset($_POST['money']) || !isset($_POST['way'])) exit('400');
if (isset($_POST['id']) && $_POST['action'] == 'pay_points') {
$config = [
'mchid' => gdk_option('gdk_payjs_id'), // 配置商户号
'key' => gdk_option('gdk_payjs_key'), // 配置通信密钥
];
// 初始化
$payjs = new Payjs($config);
$data = [
'body' => '积分充值', // 订单标题
'attach' => $_POST['id'], // 订单备注
'out_trade_no' => gdk_order_id(), // 订单号
'total_fee' => intval($_POST['money'])*100, // 金额,单位:分
'notify_url' => GDK_BASE_URL.'/public/push.php',
'hide' => '1'
];
$result['money'] = intval($_POST['money']);//rmb金额
$result['trade_no'] = $data['out_trade_no'];
if( $_POST['way'] == 'alipay' ) {
$data['type'] = 'alipay';
$result['way'] = '支付宝';
} else {
$result['way'] = '微信';
}
if(gdk_is_mobile()) {
$rst = $payjs->cashier($data);//手机使用
$result['img'] = $rst;
} else {
$rst = $payjs->native($data);//电脑使用
$result['img'] = $rst['code_url'];
}
exit(implode('|',$result));
if (!isset($_POST['money']) || !isset($_POST['way'])) exit('400');//无脑输出400错误
if (isset($_POST['id'])) {
payjs_action('积分充值',$_POST['id']);
}
}
add_action( 'wp_ajax_pay_points', 'pay_points' );
add_action( 'wp_ajax_nopriv_pay_points', 'pay_points' );
//检查积分充值
function check_pay_points(){
if( !isset( $_POST['check_pay_points'] ) || !wp_verify_nonce($_POST['check_pay_points'], 'check_pay_points') ) exit('400');
if (!isset($_POST['id']) || !isset($_POST['orderid'])) exit('400');//无脑输出400错误
if ( $_POST['action'] == 'check_pay_points') {
if(gdk_check( $_POST['orderid'] , $_POST['id'])){
exit('200');
}else{
exit('400');
}
}
}
add_action( 'wp_ajax_check_pay_points', 'check_pay_points' );
add_action( 'wp_ajax_nopriv_check_pay_points', 'check_pay_points' );
/**END */
//weauth自动登录
function bind_email_check(){
$mail = isset($_POST['email']) ? $_POST['email'] : false;
if($mail && $_POST['action'] == 'bind_email_check'){
$user_id = email_exists( $email );
if ($user_id) {
exit(1);
}
}
}
add_action( 'wp_ajax_bind_email_check', 'bind_email_check' );
add_action( 'wp_ajax_nopriv_bind_email_check', 'bind_email_check' );
//weauth自动登录
function weauth_oauth_login(){
$key = isset($_POST['spam']) ? $_POST['spam'] : false;
$mail = isset($_POST['email']) ? $_POST['email'] : false;
if($key && $_POST['action'] == 'weauth_oauth_login'){
$user_id = get_transient($key.'ok');
if ($user_id != 0) {
wp_set_auth_cookie($user_id,true);
if($mail && !empty($mail) && is_email($mail)){
wp_update_user( array( 'ID' => $user_id, 'user_email' => $mail ) );
}
exit(wp_unique_id());
}
}
}
add_action( 'wp_ajax_weauth_oauth_login', 'weauth_oauth_login' );
add_action( 'wp_ajax_nopriv_weauth_oauth_login', 'weauth_oauth_login' );
//付费可见
function pay_buy(){
if (isset($_POST['point']) && isset($_POST['userid']) &&isset($_POST['id']) && $_POST['action'] == 'pay_buy') {
Points::set_points( -$_POST['point'],
$_POST['userid'],
array(
'description' => $_POST['id'],
'status' => get_option( 'points-points_status', 'accepted' )
)
);//扣除金币
$pay_content = get_post_meta($_POST['id'], 'pay_content', true);
exit($pay_content);
}
}
add_action( 'wp_ajax_pay_buy', 'pay_buy' );
add_action( 'wp_ajax_nopriv_pay_buy', 'pay_buy' );
/*免登陆购买开始*/
//获取加密内容
function getcontent() {
$id = $_POST["id"];
$action = $_POST["action"];
if ( isset($id) && $_POST['action'] == 'getcontent') {
$pay_content = get_post_meta($id, 'gdk_pay_content', true);
exit($pay_content);
}
}
add_action( 'wp_ajax_getcontent', 'getcontent' );
add_action( 'wp_ajax_nopriv_getcontent', 'getcontent' );
///提取码检测
function check_code() {
$id = $_POST['id'];
$code = $_POST['code'];
if (isset($code) && isset($id) && $_POST['action'] == 'check_code') {
$pay_log = get_post_meta($id, 'pay_log', true);
//购买记录数据
$pay_arr = explode(",", $pay_log);
if(in_array($code,$pay_arr)) {
exit('1');
} else {
exit('0');
}
}
}
add_action( 'wp_ajax_check_code', 'check_code' );
add_action( 'wp_ajax_nopriv_check_code', 'check_code' );
//在线充值
function payjs_view(){
$id = $_POST['id'];
$money = $_POST['money'];
$way = $_POST['way'];
if (isset($id) && isset($money) && isset($way) && $_POST['action'] == 'payjs_view') {
$config = [
'mchid' => gdk_option('gdk_payjs_id'), // 配置商户号
'key' => gdk_option('gdk_payjs_key'), // 配置通信密钥
];
// 初始化
$payjs = new Payjs($config);
$data = [
'body' => '在线付费查看', // 订单标题
'attach' => 'P'.$id,
'out_trade_no' => gdk_order_id(), // 订单号
'total_fee' => intval($money)*100, // 金额,单位:分
'notify_url' => GDK_BASE_URL.'/public/push.php',
'hide' => '1'
];
if($way == 1) $data['type'] = 'alipay';
$result_money = intval($money);
$result_trade_no = $data['out_trade_no'];
if(gdk_is_mobile()){
$rst = $payjs->cashier($data);//手机使用
$result_img = $rst;
}else{
$rst = $payjs->native($data);//电脑使用
$result_img = $rst['code_url'];
}
$result = $result_money.'|'. $result_img.'|'. $result_trade_no;
}
exit($result);
}
add_action( 'wp_ajax_payjs_view', 'payjs_view' );
add_action( 'wp_ajax_nopriv_payjs_view', 'payjs_view' );
function checkpayjs(){
$id = $_POST['id'];
$orderid = $_POST['orderid'];
if (isset($id) && isset($orderid) && $_POST['action'] == 'checkpayjs') {
$sid = get_transient('P'.$id);
if(strpos($sid,'E20') !== false && $orderid == $sid){
exit('1');//OK
}else{
exit('0');//no
}
}
}
add_action( 'wp_ajax_checkpayjs', 'checkpayjs' );
add_action( 'wp_ajax_nopriv_checkpayjs', 'checkpayjs' );
function addcode(){
$id = $_POST['id'];
$code = $_POST['code'];
if (isset($id) && isset($code) && $_POST['action'] == 'addcode') {
$pay_log = get_post_meta($id, 'pay_log', true);//购买记录数据
if(empty($pay_log)){
add_post_meta($id, 'pay_log', $code, true);
}else{
update_post_meta($id, 'pay_log', $pay_log.','.$code);
}
$pay_log = get_post_meta($id, 'pay_log', true);//购买记录数据
$pay_arr = explode(",", $pay_log);
if(in_array($code,$pay_arr)){
exit('1');//OK
}else{
exit('0');//NO
}
}
}
add_action( 'wp_ajax_addcode', 'addcode' );
add_action( 'wp_ajax_nopriv_addcode', 'addcode' );
/*免登陆购买结束*/
//检查付款情况
function payrest(){
if (isset($_POST['check_trade_no']) && $_POST['action'] == 'payrest') {
if (gdk_check($_POST['check_trade_no'])) {
exit('1');
} else {
exit('0');
}
}
}
add_action( 'wp_ajax_payrest', 'payrest' );
add_action( 'wp_ajax_nopriv_payrest', 'payrest' );
//ajax生成登录二维码
function weauth_qr_gen(){
if (isset($_POST['wastart']) && $_POST['action'] == 'weauth_qr_gen') {
if (!empty($_POST['wastart'])) {
$rest = implode("|", get_weauth_qr());
exit($rest);
}
}
}
add_action( 'wp_ajax_weauth_qr_gen', 'weauth_qr_gen' );
add_action( 'wp_ajax_nopriv_weauth_qr_gen', 'weauth_qr_gen' );
//检查登录状况
function weauth_check(){
if (isset($_POST['sk']) && $_POST['action'] == 'weauth_check') {
$rest = substr($_POST['sk'],-16);//key
$weauth_cache = get_transient($rest.'ok');
if (!empty($weauth_cache)) {
exit($rest);//key
}
}
}
add_action( 'wp_ajax_weauth_check', 'weauth_check' );
add_action( 'wp_ajax_nopriv_weauth_check', 'weauth_check' );

View file

@ -960,7 +960,7 @@ function gdk_order_id(){
//获取云落的远程通知加入缓存1天一次
function get_Yunluo_Notice(){
function gdk_get_Yunluo_Notice(){
$Yunluo_Notice = get_transient('Yunluo_Notice');
if(false === $Yunluo_Notice){
$Yunluo_Notice = wp_remote_get('https://u.gitcafe.net/api/notice.txt')['body'];
@ -977,7 +977,7 @@ function get_Yunluo_Notice(){
function gdk_page_id( $pagephp ) {
global $wpdb;
$pagephp = esc_sql($pagephp);
$pageid = $wpdb->get_row("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE `meta_value` = 'pages/{$pagephp}.php'", ARRAY_A) ['post_id'];
$pageid = $wpdb->get_row("SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE `meta_value` = 'pages/{$pagephp}.php'", ARRAY_A)['post_id'];
return $pageid;
}
@ -989,12 +989,12 @@ function gdk_check( $d , $u = null) {
if ( isset( $u ) && ( $u !== null ) ) {
$userid = " AND `user_id` = '" . $u . "'";
}
$result = $wpdb->query("SELECT `point_id` FROM " . Points_Database::points_get_table("users") . $des . $userid . " AND `status` = 'accepted' LIMIT 3", ARRAY_A);
return $result;//0=无订单结果1=有订单结果,>1均为异常数据
$result = $wpdb->query("SELECT `point_id` FROM " . GDK_Points_Database::points_get_table("users") . $des . $userid . " AND `status` = 'accepted' LIMIT 3", ARRAY_A);
return $result;//0=无订单结果1=有订单结果,>1均为异常重复入库数据
}
//导航单页函数
function get_the_link_items($id = null) {
function gdk_get_the_link_items($id = null) {
$bookmarks = get_bookmarks('orderby=date&category=' . $id);
$output = '';
if (!empty($bookmarks)) {
@ -1007,20 +1007,78 @@ function get_the_link_items($id = null) {
return $output;
}
function get_link_items() {
function gdk_get_link_items() {
$linkcats = get_terms('link_category', 'orderby=count&hide_empty=1&exclude=' . gdk_option('gdk_linkpage_cat'));
if (!empty($linkcats)) {
foreach ($linkcats as $linkcat) {
$result.= '<h2 class="link_title">' . $linkcat->name . '</h2>';
if ($linkcat->description) $result.= '<div class="link_description">' . $linkcat->description . '</div>';
$result.= get_the_link_items($linkcat->term_id);
$result.= gdk_get_the_link_items($linkcat->term_id);
}
} else {
$result = get_the_link_items();
$result = gdk_get_the_link_items();
}
return $result;
}
/*
* Payjs支付操作函数
* 订单标题
* 订单备注
* $_POST['money'] = 提交的金额,$_POST['way'] = 支付方式,支付宝为alipay,不设置默认微信,
*/
function payjs_action($body,$attach){
$config = [
'mchid' => gdk_option('gdk_payjs_id'), // 配置商户号
'key' => gdk_option('gdk_payjs_key'), // 配置通信密钥
];
// 初始化
$payjs = new GDK_Payjs($config);
$data = [
'body' => $body, // 订单标题
'attach' => $attach, // 订单备注
'out_trade_no' => gdk_order_id(),// 订单号
'total_fee' => intval($_POST['money'])*100,// 金额,单位:分
'notify_url' => GDK_BASE_URL.'/public/notify.php',//异步通知文件
'hide' => '1'
];
$result['money'] = intval($_POST['money']);//RMB金额
$result['trade_no'] = $data['out_trade_no'];
if( $_POST['way'] == 'alipay' ) {
$data['type'] = 'alipay';
$result['way'] = '支付宝';
} else {
$result['way'] = '微信';
}
if(gdk_is_mobile()) {
$rst = $payjs->cashier($data);//手机使用收银台
$result['img'] = $rst;
} else {
$rst = $payjs->native($data);//电脑使用扫码
$result['img'] = $rst['code_url'];
}
exit(implode('|',$result));//以字符串形式返回并停止运行
}
//接受payjs支付结果推送
function payjs_notify() {
// 配置通信参数
$config = [
'mchid' => gdk_option('gdk_payjs_id'), // 配置商户号
'key' => gdk_option('gdk_payjs_key'), // 配置通信密钥
];
$payjs = new GDK_Payjs($config);
$data = $payjs->notify();//需要做签名性检查
// 对返回码判断
if($data['return_code'] == 1) {
echo 'success';
return $data;
} else {
exit($data['return_msg']);
}
}
//充值按钮
function buy_points(){
@ -1031,6 +1089,7 @@ function buy_points(){
<form id="pay_fancybox" name="pay_form" style="display: none; width: 100%; max-width: 500px;" class="pure-form">
<h2 class="mb-3">积分充值</h2>
<p>请在下面输入充值金额以及支付工具,微信支付宝都可以,如果下面选项中有支付宝一般建议支付宝</p>
<p class="alert info">本站支付比例为: 1 RMB = '.gdk_option('gdk_rate').'金币</p></blockquote>
<label for="money">支付金额</label>
<input name="money" id="money" min="1" value="2" type="number" required>
<br /><label for="pay_way">支付方式</label>';
@ -1038,14 +1097,14 @@ function buy_points(){
$result .= '
<label><input name="pay_way" type="radio" value = "alipay" checked/> 支付宝</label> &nbsp;&nbsp;&nbsp;&nbsp;<label><input name="pay_way" type="radio" value = "wechat" /> 微信</label>';
}else{
$result .= '<br /><label> 微信</label>';
$result .= '<br /><label><input name="pay_way" type="radio" value = "wechat" checked/> 微信</label>';
}
$result .= '
<p class="mb-0 text-right">
<input data-fancybox-close type="button" id="submit_pay" data-action="pay_points" data-id="'.get_current_user_id().'" class="pure-button pure-button-primary" value="提交">
</p>
</form>';
wp_enqueue_script('qrious', 'https://cdn.bootcss.com/qrious/4.0.2/qrious.min.js', array('jquery'), GDK_PLUGIN_VER, true);
//wp_enqueue_script('qrious', 'https://cdn.bootcss.com/qrious/4.0.2/qrious.min.js', array('jquery'), GDK_PLUGIN_VER, true);
}else{// no login
$result = '<div class=\'alert info\'>本页面需要您登录才可以操作,请先 <a target="_blank" href="'.esc_url( wp_login_url( get_permalink() ) ).'">点击登录</a> 或者<a href="'.esc_url( wp_registration_url() ).'">立即注册</a></div>';

View file

@ -554,7 +554,7 @@ function gdk_points_columns($columns) {
}
function gdk_points_value($value, $column_name, $user_id) {
if ($column_name == 'points') {
$jinbi = Points::get_user_total_points($user_id, 'accepted');
$jinbi = GDK_Points::get_user_total_points($user_id, 'accepted');
if ($jinbi != "") {
$ret = $jinbi;
return $ret;
@ -656,10 +656,10 @@ function gdk_comment_add_at($comment_text, $comment = '') {
add_filter('comment_text', 'gdk_comment_add_at', 20, 2);
//搜索结果排除所有页面
function search_filter_page($query) {
function gdk_search_filter_page($query) {
if ($query->is_search && !$query->is_admin) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts', 'search_filter_page');
add_filter('pre_get_posts', 'gdk_search_filter_page');

View file

@ -1,7 +1,7 @@
<?php
add_theme_support('title-tag');
if (!function_exists('nc_filter_document_title_separator')):
add_filter('document_title_separator', 'nc_filter_document_title_separator', 10, 1);
add_filter('document_title_parts', 'nc_filter_document_title_parts', 10, 1);

View file

@ -240,7 +240,7 @@ function weauth_oauth_init(){
add_action('init','weauth_oauth_init');
//GET自动登录
function weauth_oauth_login(){
function gdk_weauth_oauth_login(){
$key = isset($_GET['spam']) ? $_GET['spam'] : false;
if ($key) {
$user_id = get_transient($key.'ok');
@ -249,4 +249,4 @@ function weauth_oauth_login(){
}
}
}
add_action('init', 'weauth_oauth_login');
add_action('init', 'gdk_weauth_oauth_login');

View file

@ -13,31 +13,31 @@ function gdk_potin() {
add_shortcode('gdk_potin_btn', 'gdk_potin');
//添加钮Download
function DownloadUrl($atts, $content = null) {
function gdk_DownloadUrl($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://'
) , $atts));
return '<a class="dl" href="' . $href . '" target="_blank" rel="nofollow"><i class="fa fa-cloud-download"></i>' . $content . '</a>';
}
add_shortcode("dl", "DownloadUrl");
add_shortcode("dl", "gdk_DownloadUrl");
//添加钮git
function GithubUrl($atts, $content = null) {
function gdk_GithubUrl($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://'
) , $atts));
return '<a class="dl" href="' . $href . '" target="_blank" rel="nofollow"><i class="fa fa-github-alt"></i>' . $content . '</a>';
}
add_shortcode('gt', 'GithubUrl');
add_shortcode('gt', 'gdk_GithubUrl');
//添加钮Demo
function DemoUrl($atts, $content = null) {
function gdk_DemoUrl($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://'
) , $atts));
return '<a class="dl" href="' . $href . '" target="_blank" rel="nofollow"><i class="fa fa-external-link"></i>' . $content . '</a>';
}
add_shortcode('dm', 'DemoUrl');
add_shortcode('dm', 'gdk_DemoUrl');
//使用短代码添加回复后可见内容开始
function reply_to_read($atts, $content = null) {
function gdk_reply_to_read($atts, $content = null) {
extract(shortcode_atts(array(
"notice" => '<blockquote><center><p class="reply-to-read" style="color: blue;">注意:本段内容须成功“<a href="' . get_permalink() . '#respond" title="回复本文">回复本文</a>”后“<a href="javascript:window.location.reload();" title="刷新本页">刷新本页</a>”方可查看!</p></center></blockquote>'
) , $atts));
@ -67,49 +67,49 @@ function reply_to_read($atts, $content = null) {
return $notice;
}
}
add_shortcode('reply', 'reply_to_read');
add_shortcode('reply', 'gdk_reply_to_read');
//绿色提醒框
function toz($atts, $content = null) {
function gdk_toz($atts, $content = null) {
return '<div id="sc_notice">' . $content . '</div>';
}
add_shortcode('v_notice', 'toz');
add_shortcode('v_notice', 'gdk_toz');
//红色提醒框
function toa($atts, $content = null) {
function gdk_toa($atts, $content = null) {
return '<div id="sc_error">' . $content . '</div>';
}
add_shortcode('v_error', 'toa');
add_shortcode('v_error', 'gdk_toa');
//黄色提醒框
function toc($atts, $content = null) {
function gdk_toc($atts, $content = null) {
return '<div id="sc_warn">' . $content . '</div>';
}
add_shortcode('v_warn', 'toc');
add_shortcode('v_warn', 'gdk_toc');
//灰色提醒框
function tob($atts, $content = null) {
function gdk_tob($atts, $content = null) {
return '<div id="sc_tips">' . $content . '</div>';
}
add_shortcode('v_tips', 'tob');
add_shortcode('v_tips', 'gdk_tob');
//蓝色提醒框
function tod($atts, $content = null) {
function gdk_tod($atts, $content = null) {
return '<div id="sc_blue">' . $content . '</div>';
}
add_shortcode('v_blue', 'tod');
add_shortcode('v_blue', 'gdk_tod');
//蓝边文本框
function toe($atts, $content = null) {
function gdk_toe($atts, $content = null) {
return '<div class="sc_act">' . $content . '</div>';
}
add_shortcode('v_act', 'toe');
add_shortcode('v_act', 'gdk_toe');
//灵魂按钮
function tom($atts, $content = null) {
function gdk_tom($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://'
) , $atts));
return '<a class="lhb" href="' . $href . '" target="_blank" rel="nofollow">' . $content . '</a>';
}
add_shortcode('lhb', 'tom');
add_shortcode('lhb', 'gdk_tom');
//添加视频按钮
function too($atts, $content = null) {
function gdk_too($atts, $content = null) {
extract(shortcode_atts(array(
"play" => '0'
) , $atts));
@ -120,9 +120,9 @@ function too($atts, $content = null) {
return '<video style="width:100%;" src="' . $content . '" controls preload autoplay >您的浏览器不支持HTML5的 video 标签,无法为您播放!</video>';
}
}
add_shortcode('video', 'too');
add_shortcode('video', 'gdk_too');
//添加音频按钮
function tkk($atts, $content = null) {
function gdk_tkk($atts, $content = null) {
extract(shortcode_atts(array(
"play" => '0'
) , $atts));
@ -133,9 +133,9 @@ function tkk($atts, $content = null) {
return '<audio style="width:100%;" src="' . $content . '" controls autoplay loop>您的浏览器不支持 audio 标签。</audio>';
}
}
add_shortcode('audio', 'tkk');
add_shortcode('audio', 'gdk_tkk');
//弹窗下载
function ton($atts, $content = null) {
function gdk_ton($atts, $content = null) {
extract(shortcode_atts(array(
"href" => 'http://',
"filename" => '',
@ -144,7 +144,7 @@ function ton($atts, $content = null) {
) , $atts));
return '<a class="lhb" id="showdiv" href="#fancydlbox" >文件下载</a><div id="fancydlbox" style="cursor:default;display:none;width:800px;"><div class="part" style="padding:20px 0;"><h2>下载声明:</h2> <div class="fancydlads" align="left"><p>' . gdk_option('gdk_fancydlcp') . '</p></div></div><div class="part" style="padding:20px 0;"><h2>文件信息:</h2> <div class="dlnotice" align="left"><p>文件名称:' . $filename . '<br />文件大小:' . $filesize . '<br />发布日期:' . get_the_modified_time('Y年n月j日') . '</p></div></div><div class="part" id="download_button_part"><a id="download_button" target="_blank" href="' . $href . '"><span></span>' . $filedown . '</a> </div><div class="part" style="padding:20px 0;"><div class="moredl" style="text-align:center;">[更多地址] : ' . $content . '</div></div><div class="dlfooter">' . gdk_option('gdk_fancydlad') . '</div></div>';
}
add_shortcode('fanctdl', 'ton');
add_shortcode('fanctdl', 'gdk_ton');
//代码演示短代码
function gdk_demo($atts, $content = null) {
return '<a class="lhb" href="' . get_permalink(gdk_page_id('demo')) . '?pid=' . get_the_ID() . '" target="_blank" rel="nofollow">' . $content . '</a>';
@ -157,32 +157,32 @@ function gdk_download($atts, $content = null) {
add_shortcode('download', 'gdk_download');
//为WordPress添加展开收缩功能
function xcollapse($atts, $content = null) {
function gdk_xcollapse($atts, $content = null) {
extract(shortcode_atts(array(
"title" => ""
) , $atts));
return '<div style="margin: 0.5em 0;"><div class="xControl"><a href="javascript:void(0)" class="collapseButton xButton"><i class="fa fa-plus-square" ></i> ' . $title . '</a><div style="clear: both;"></div></div><div class="xContent" style="display: none;">' . $content . '</div></div>';
}
add_shortcode('collapse', 'xcollapse');
add_shortcode('collapse', 'gdk_xcollapse');
//简单的下载面板
function xdltable($atts, $content = null) {
function gdk_xdltable($atts, $content = null) {
extract(shortcode_atts(array(
"file" => "",
"size" => ""
) , $atts));
return '<table class="dltable"><tbody><tr><td style="background-color:#F9F9F9;" rowspan="3"><p>文件下载</p></td><td><i class="fa fa-list-alt"></i>&nbsp;&nbsp;文件名称:' . $file . '</td><td><i class="fa fa-th-large"></i>&nbsp;&nbsp;文件大小:' . $size . '</td></tr><tr><td colspan="2"><i class="fa fa-volume-up"></i>&nbsp;&nbsp;下载声明:' . gdk_option('gdk_dltable_b') . '</td></tr><tr><td colspan="2"><i class="fa fa-download"></i>&nbsp;&nbsp;下载地址:' . $content . '</td></tr></tbody></table>';
}
add_shortcode('dltable', 'xdltable');
add_shortcode('dltable', 'gdk_xdltable');
//网易云音乐
function music163($atts, $content = null) {
function gdk_music163($atts, $content = null) {
extract(shortcode_atts(array(
"play" => "1"
) , $atts));
return '<iframe style="width:100%;max-height:86px;" frameborder="no" border="0" marginwidth="0" marginheight="0" src="http://music.163.com/outchain/player?type=2&id=' . $content . '&auto=' . $play . '&height=66"></iframe>';
}
add_shortcode('netmusic', 'music163');
add_shortcode('netmusic', 'gdk_music163');
//登录可见
function login_to_read($atts, $content = null) {
function gdk_login_to_read($atts, $content = null) {
$logina = '<a target="_blank" href="' . esc_url(wp_login_url(get_permalink())) . '">登录</a>';
extract(shortcode_atts(array(
"notice" => '<blockquote><center><p class="reply-to-read" style="color: blue;">注意:本段内容须“' . $logina . '”后方可查看!</p></center></blockquote>'
@ -193,10 +193,10 @@ function login_to_read($atts, $content = null) {
}
return $notice;
}
add_shortcode('vip', 'login_to_read');
add_shortcode('vip', 'gdk_login_to_read');
// 部分内容输入密码可见
function e_secret($atts, $content = null) {
function gdk_e_secret($atts, $content = null) {
extract(shortcode_atts(array('wx' => null) , $atts));
$pid = get_the_ID();
add_post_meta($pid, '_pass_content', $content, true) or update_post_meta($pid, '_pass_content', $content);
@ -204,10 +204,10 @@ function e_secret($atts, $content = null) {
return '<div class="pass_viewbox"><input id="pass_view" type="text"> <input id="start_view" data-action="gdk_pass_view" data-id="'.$pid.'" type="button" value="提交"></div>';
}
add_shortcode('secret', 'e_secret');
add_shortcode('secret', 'gdk_e_secret');
// 支持文章和页面运行PHP代码id
function php_include($attr) {
function gdk_php_include($attr) {
$file = $attr['file'];
$upload_dir = wp_upload_dir();
$folder = $upload_dir['basedir'] . '/php-content' . "/{$file}.php";
@ -215,7 +215,7 @@ function php_include($attr) {
include $folder;
return ob_get_clean();
}
add_shortcode('phpcode', 'php_include');
add_shortcode('phpcode', 'gdk_php_include');
//给文章加内链短代码
function gdk_insert_posts($atts, $content = null) {
@ -267,7 +267,7 @@ function gdk_list_shortcode_handler($atts, $content = '') {
add_shortcode('list', 'gdk_list_shortcode_handler');
//表格短代码
function table_shortcode_handler( $atts, $content='' ) {
function gdk_table_shortcode_handler( $atts, $content='' ) {
extract( shortcode_atts( ['width' => '100%'], $atts ) );
$output = '';
$content = trim($content);
@ -302,7 +302,7 @@ function table_shortcode_handler( $atts, $content='' ) {
return $output;
}
add_shortcode( 'table', 'table_shortcode_handler' );
add_shortcode( 'table', 'gdk_table_shortcode_handler' );
add_shortcode('youku', function( $atts, $content='') {
extract( shortcode_atts( array(

View file

@ -158,7 +158,7 @@ function my_users_columns($columns) {
}
function output_my_users_columns($value, $column_name, $user_id) {
if ($column_name == 'points') {
$jinbi = Points::get_user_total_points($user_id, POINTS_STATUS_ACCEPTED);
$jinbi = GDK_Points::get_user_total_points($user_id, POINTS_STATUS_ACCEPTED);
if ($jinbi != "") {
$ret = $jinbi;
return $ret;

44
public/notify.php Normal file
View file

@ -0,0 +1,44 @@
<?php
/**
* 支付推送服务消息接收文件
*/
require( '../../../../wp-load.php' );
/* Payjs支付通知开始 */
$data = payjs_notify();//获取payjs支付成功的信息
$money = $data['total_fee']/100; //交易金额
$userid = $data['attach']; //交易标题
$orderid = $data['out_trade_no']; //订单ID
error_log('Payjs pay ok, Order_ID:'.$orderid.', Order_Title:'.$userid.', Money:'.$money);//输出到日志
if(in_string($userid,'PP')){//免登陆支付,插入缓存,然后直接停止推出
set_transient($userid, $orderid, 30);
exit;
}
if(gdk_check($data['out_trade_no']) !== 0) exit('Repeat push');//在入库前,数据库不应该有同样的订单号
if( empty($userid) || empty($money) )exit('data null');//阻止某些极少数空值的
/* payjs支付通知结束 */
$user = get_user_by( 'id', $userid );
$point_number = $money * gdk_option('gdk_rate');
$headers = "Content-Type:text/html;charset=UTF-8\n";
$mail_title = '尊敬的'.$user->display_name.',您好!';
$mail_cotent = '<p>您的金币充值已成功到账,请查收!</p><p>金币充值金额为:'.$user->display_name.'</p><p>如果您的金币金额有异常,请您在第一时间和我们取得联系哦,联系邮箱:'.get_bloginfo('admin_email').'</p>';
$message = mail_temp($mail_title,$mail_cotent,home_url(),get_bloginfo('name'));
GDK_Points::set_points($point_number, $userid, array('description' => $orderid , 'status' => 'accepted'));
//增加金币金币
wp_mail( $user->user_email , 'Hi,'.$user->display_name.',充值成功到账通知!', $message, $headers);
$mail_admin_cotent = '<p>充值订单</p><p>用户ID'.$userid.'</p><p>用户名:'.$user->display_name.'</p><p>金额'.$money.'元</p>';
$admin_notice = mail_temp('站长你好',$mail_admin_cotent,home_url(),get_bloginfo('name'));
wp_mail( get_bloginfo('admin_email') , '【收款成功】网站充值订单已完成',$admin_notice, $headers);
//more
?>

View file

@ -1,46 +0,0 @@
<?php
/**
* 支付推送服务消息接收文件
*/
require( '../../../../wp-load.php' );
/* Payjs支付通知开始 */
if(gdk_option('gdk_pay_way')=='gdk_payjs_ok'){
// 配置通信参数
$config = [
'mchid' => gdk_option('gdk_payjs_id'), // 配置商户号
'key' => gdk_option('gdk_payjs_secret'), // 配置通信密钥
];
$payjs = new Payjs($config);
$data = $payjs->notify();//
//需要做唯一性检查
//
if($data['return_code'] == 1){
echo 'success';
$amount = $data['total_fee']/100; //交易金额
$userid = $data['attach']; //交易标题
$YZid = $data['out_trade_no']; //有赞支付ID
error_log('Payjs pay ok, Order_ID:'.$YZid.', User_ID:'.$userid.', Amount:'.$amount);//输出到日志
}
}
if(strpos($data['attach'],'P') !== false){//免登陆支付
set_transient($userid, $YZid, 30);
exit;
}
if(gdk_check($data['out_trade_no']) != 0) exit('Repeat push');
/* payjs支付通知结束 */
if( empty($userid) || empty($amount) )exit('数据为空');//阻止某些极少数空值的
$user = get_user_by( 'id', $userid );
$point_number = $amount * gdk_option('gdk_chongzhi_dh');
$message = '<div class="emailcontent" style="width:100%;max-width:720px;text-align:left;margin:0 auto;padding-top:80px;padding-bottom:20px"><div class="emailtitle"><h1 style="color:#fff;background:#51a0e3;line-height:70px;font-size:24px;font-weight:400;padding-left:40px;margin:0">充值到账通知</h1><div class="emailtext" style="background:#fff;padding:20px 32px 40px"><div style="padding:0;font-weight:700;color:#6e6e6e;font-size:16px">尊敬的'.$user->display_name.',您好!</div><p style="color:#6e6e6e;font-size:13px;line-height:24px">您的金币充值已成功到账,请查收!</p><table cellpadding="0" cellspacing="0" border="0" style="width:100%;border-top:1px solid #eee;border-left:1px solid #eee;color:#6e6e6e;font-size:16px;font-weight:normal"><thead><tr><th colspan="2" style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center;background:#f8f8f8">您的金币详细情况</th></tr></thead><tbody><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center;width:100px">用户名</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.$user->display_name.'</td></tr><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center">充值金币</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.$point_number.'</td></tr><tr><td style="padding:10px 0;border-right:1px solid #eee;border-bottom:1px solid #eee;text-align:center">金币总额</td><td style="padding:10px 20px 10px 30px;border-right:1px solid #eee;border-bottom:1px solid #eee;line-height:30px">'.Points::get_user_total_points($userid, POINTS_STATUS_ACCEPTED ).'</td></tr></tbody></table><p style="color:#6e6e6e;font-size:13px;line-height:24px">如果您的金币金额有异常,请您在第一时间和我们取得联系哦,联系邮箱:'.get_bloginfo('admin_email').'</p></div><div class="emailad" style="margin-top:4px"><a href="'.home_url().'"><img src="http://reg.163.com/images/secmail/adv.png" style="margin:auto;width:100%;max-width:700px;height:auto"></a></div></div></div>';
$headers = "Content-Type:text/html;charset=UTF-8\n";
Points::set_points($point_number, $userid, array('description' => $YZid , 'status' => 'accepted'));//增加金币金币
wp_mail( $user->user_email , 'Hi,'.$user->display_name.',充值成功到账通知!', $message, $headers);
wp_mail( get_bloginfo('admin_email') , '【收款成功】网站充值订单已完成','充值订单:用户ID'.$userid.'/金额'.$amount.'元');
//more
?>