function tin_new_user_notification($user_id, $plaintext_pass = '') { $user = get_userdata($user_id); $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('您的站点「%s」有新用户注册 :'), $blogname) . "<br></br>"; $message .= sprintf(__('用户名: %s'), $user->user_login) . "<br>"; $message .= sprintf(__('E-mail: %s'), $user->user_email) . "<br>"; @tin_basic_mail('', get_option('admin_email'), sprintf(__('[%s] 有新用户注册'), $blogname), $message); if (empty($plaintext_pass)) { return; } $message = sprintf(__('用户名: %s'), $user->user_login) . "<br>"; $message .= sprintf(__('密码: %s'), $plaintext_pass) . "<br>"; $message .= tin_get_user_url('profile', $user->ID) . "<br>"; @tin_basic_mail('', $user->user_email, sprintf(__('[%s] 您的注册用户名和密码'), $blogname), $message); }
function create_the_order() { $redirect = 0; $success = 0; $msg = ''; $order_note = ''; $order_id = 0; if (!wp_verify_nonce(trim($_POST['wp_nonce']), 'order-nonce')) { $msg = 'NonceIsInvalid'; } else { $price = product_smallest_price($_POST['product_id']); // 获取折扣后总价 $cost = $price[5] * $_POST['order_quantity']; // 获取使用优惠码后总价 $promote_support = get_post_meta($_POST['product_id'], 'product_promote_code_support', true); if ($promote_support == 1 && !empty($_POST['promote_code'])) { $cost_promoted = update_promote_code_total_price($_POST['promote_code'], $cost, 0); $order_note = json_encode(array('promote_code' => $_POST['promote_code'])); } else { $cost_promoted = $cost; } $currency = get_post_meta($_POST['product_id'], 'pay_currency', true); $current_user = wp_get_current_user(); $uid = $current_user->ID; if ($currency == 0) { // 使用积分直接支付 // 获取用户当前积分并判断是否足够消费 $credit = (int) get_user_meta($uid, 'tin_credit', true); if ($credit < $cost) { // 积分不足 $msg = '积分不足,立即<a href="' . tin_get_user_url('credit') . '" target="_blank">充值积分</a>'; } else { // 插入数据库记录 $insert = insert_order($_POST['product_id'], $_POST['order_name'], $price[5], $_POST['order_quantity'], $cost, 4, $order_note, $uid, $_POST['receive_name'], $_POST['receive_email'], $_POST['receive_address'], $_POST['receive_zip'], $_POST['receive_phone'], $_POST['receive_mobile'], $_POST['order_msg']); if ($insert) { // 扣除积分//发送站内信 update_tin_credit($uid, $cost, 'cut', 'tin_credit', '下载资源消费' . $cost . '积分'); // 更新已消费积分 if (get_user_meta($uid, 'tin_credit_void', true)) { $void = get_user_meta($uid, 'tin_credit_void', true); $void = $void + $cost; update_user_meta($uid, 'tin_credit_void', $void); } else { add_user_meta($uid, 'tin_credit_void', $cost, true); } // 给资源发布者添加积分并更新积分消息记录 $author = get_post_field('post_author', $_POST['product_id']); update_tin_credit($author, $cost, 'add', 'tin_credit', sprintf(__('你发布收费商品资源《%1$s》被其他用户购买,获得售价%2$s积分', 'tinection'), get_post_field('post_title', $_POST['product_id']), $cost)); //出售获得积分 // 更新资源购买次数与剩余数量 update_success_order_product($_POST['product_id'], $_POST['order_quantity']); // 发送邮件 $to = $_POST['receive_email']; $dl_links = get_post_meta($_POST['product_id'], 'product_download_links', true); $pay_content = get_post_meta($_POST['product_id'], 'product_pay_content', true); // 如果包含付费可见下载链接则附加链接内容至邮件 if (!empty($dl_links) || !empty($pay_content)) { $title = '你在' . get_bloginfo('name') . '购买的内容'; $content = '<p>你在' . get_bloginfo('name') . '使用积分购买了以下内容:</p>'; $content .= deal_pay_dl_content($dl_links); $content .= '<p style="margin-top:10px;">' . $pay_content . '</p><p>感谢你的来访与支持,祝生活愉快!</p>'; } else { $title = '感谢你在' . get_bloginfo('name') . '使用积分付费购买资源'; $content = '<p>你在' . get_bloginfo('name') . '使用积分付费购买资源' . $_POST['order_name'] . '</p><p>支付已成功,扣除了你' . $cost . '积分。</p><p>感谢你的来访与支持,祝生活愉快!</p>'; } $type = '积分商城'; tin_basic_mail('', $to, $title, $content, $type); $msg = '购买成功,已扣除' . $cost . '积分'; $success = 1; } else { $msg = '创建订单失败,请重新再试'; } } } else { // 现金支付方式,首先插入数据库订单记录 $insert = insert_order($_POST['product_id'], $_POST['order_name'], $price[5], $_POST['order_quantity'], $cost_promoted, 1, $order_note, $uid, $_POST['receive_name'], $_POST['receive_email'], $_POST['receive_address'], $_POST['receive_zip'], $_POST['receive_phone'], $_POST['receive_mobile'], $_POST['order_msg']); if ($insert) { $redirect = 1; $success = 1; $order_id = $insert; if (!empty($_POST['receive_email'])) { store_email_template($order_id, '', $_POST['receive_email']); } } else { $msg = '创建订单失败,请重新再试'; } } } $return = array('success' => $success, 'msg' => $msg, 'redirect' => $redirect, 'order_id' => $order_id); echo json_encode($return); exit; }
function tin_saledl_confirm_buy() { $sid = $_POST['sid']; $pid = $_POST['pid']; $uid = $_POST['uid']; $saledl = get_post_meta($pid, 'tin_saledl', true); $saledlarray = explode(',', $saledl); $sidarray = explode('_', $sid); $sidarray[1] = isset($sidarray[1]) ? (int) $sidarray[1] : 1; $key = $sidarray[1] - 1; $saledlsinglearray = explode('|', $saledlarray[$key]); $saledlsinglearray[2] = isset($saledlsinglearray[2]) ? (int) $saledlsinglearray[2] : 0; $price = $saledlsinglearray[2]; $credit = (int) get_user_meta($uid, 'tin_credit', true); if ($price <= $credit) { //查看是否购买防止重扣 $hasbuy = get_tin_meta('buy_post_sdl', $uid); $hasbuyarray = explode(',', $hasbuy); if (!in_array($sid, $hasbuyarray)) { //扣除积分//发送站内信 update_tin_credit($uid, $price, 'cut', 'tin_credit', '下载资源消费' . $price . '积分'); //更新已消费积分 if (get_user_meta($uid, 'tin_credit_void', true)) { $void = get_user_meta($uid, 'tin_credit_void', true); $void = $void + $price; update_user_meta($uid, 'tin_credit_void', $void); } else { add_user_meta($uid, 'tin_credit_void', $price, true); } //给资源发布者添加积分并更新积分消息记录 tin_resource_dl_add_credit($uid, $pid, $sid); //默认下载奖励积分 $author = get_post_field('post_author', $pid); update_tin_credit($author, $price, 'add', 'tin_credit', sprintf(__('你发布的文章《%1$s》中收费资源被其他用户下载,获得售价%2$s积分', 'tinection'), get_post_field('post_title', $pid), $price)); //出售获得积分 //添加用户已下载资源 if (empty($hasbuy)) { update_tin_meta('buy_post_sdl', $sid, $uid); } else { $hasbuy .= ',' . $sid; update_tin_meta('buy_post_sdl', $hasbuy, $uid); } //更新资源购买次数 $sourcemetakey = 'post_sdl_' . $sidarray[1]; $sales = get_tin_meta($sourcemetakey, $pid) ? (int) get_tin_meta($sourcemetakey, $pid) : 0; $sales++; update_tin_meta($sourcemetakey, $sales, $pid); //发送邮件 $user_info = get_userdata($uid); $to = $user_info->user_email; $title = '你在' . get_bloginfo('name') . '购买的内容'; $saledlsinglearray[0] = isset($saledlsinglearray[0]) ? $saledlsinglearray[0] : ''; $saledlsinglearray[1] = isset($saledlsinglearray[1]) ? $saledlsinglearray[1] : ''; $saledlsinglearray[3] = isset($saledlsinglearray[3]) ? $saledlsinglearray[3] : ''; $content = '<p>你在' . get_bloginfo('name') . '使用积分下载了以下内容:</p><p>' . $saledlsinglearray[0] . '</p><p>下载链接:<a href="' . $saledlsinglearray[1] . '" title="' . $saledlsinglearray[0] . '" target="_blank">' . $saledlsinglearray[1] . '</a></p><p>下载密码:' . $saledlsinglearray[3] . '</p><p>感谢你的来访与支持,祝生活愉快!</p>'; $type = '付费下载'; tin_basic_mail('', $to, $title, $content, $type); $success = 1; $credit = $credit - $price; } else { $success = 2; } } else { $success = 0; } $return = array('success' => $success, 'price' => $price, 'credit' => $credit); $return = json_encode($return); echo $return; exit; }
function tin_newsletter_unsubscribe() { $email = $_POST['email']; $tin_dlusers = get_tin_meta('tin_dlusers') ? get_tin_meta('tin_dlusers') : ''; $tin_dlusers_array = explode(',', $tin_dlusers); $tin_dlusers_search = array_search($email, $tin_dlusers_array); $tin_subscribers = get_tin_meta('tin_subscribers') ? get_tin_meta('tin_subscribers') : ''; $tin_subscribers_array = explode(',', $tin_subscribers); $tin_subscribers_search = array_search($email, $tin_subscribers_array); $newssuffix = ot_get_option('page_newsletter', 'newsletter'); if (stripos($newssuffix, '?') === false) { $newspage = get_bloginfo('url') . '/' . $newssuffix . '?action=unsubscribe'; } else { $newspage = get_bloginfo('url') . '/' . $newssuffix . '&action=unsubscribe'; } if ($tin_dlusers_search != '' || $tin_subscribers_search != '') { $meta_key = 'unsubscribe_' . $email; $meta_value = md5(mt_rand(0, 1000)); update_tin_meta($meta_key, $meta_value); $title = get_bloginfo('name') . '邮件周刊确认退订'; $type = '邮件退订'; $url = $newspage . '&email=' . $email . '&nonce=' . $meta_value; $content = '<p>请点击以下链接完成退订!</p><p><a href="' . $url . '" target="_blank">' . $url . '</a></p>'; tin_basic_mail('', $email, $title, $content, $type); $msg = '请查收你的邮件并点击邮件内链接完成退订!'; } else { $msg = '你目前没有订阅该栏目!'; } $msg_arr = array('msg' => $msg); $msg_json = json_encode($msg_arr); echo $msg_json; exit; }