Guest User

Untitled

a guest
Oct 21st, 2025
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.31 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for SourceGuardian Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. function zyx_add_wp_enqueue()
  15. {
  16. wp_enqueue_style('zyx_style_css', ZY_ZAUTHS_DIR_URL . 'core/assets/css/style.min.css', [], time());
  17. wp_enqueue_script('zyx_script_js', ZY_ZAUTHS_DIR_URL . 'core/assets/js/main.min.js', ['jquery'], Plugin_Version_zyx_aut('Version'));
  18. }
  19.  
  20. function zyx_get_product_write_aut()
  21. {
  22. if (!is_admin() && !!current_user_can('manage_options')) {
  23. return false;
  24. }
  25.  
  26. global $wpdb;
  27.  
  28. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  29. $term = (isset($_POST['term']) ? sanitize_text_field($_POST['term']) : '');
  30.  
  31. if (!empty($term)) {
  32. $search_term = (!empty($term) ? $wpdb->esc_like($term) : '');
  33.  
  34. if (!empty($search_term)) {
  35. $query = $wpdb->get_results($wpdb->prepare("\n" . ' SELECT domain ' . "\n" . ' FROM ' . $wpdb->prefix . 'product_aut ' . "\n" . ' WHERE domain LIKE \'%%%s%%\'' . "\n" . ' ORDER BY domain ASC' . "\n" . ' LIMIT 25' . "\n" . ' ', $search_term), ARRAY_A);
  36. }
  37. else {
  38. $query = $wpdb->get_results('SELECT domain FROM ' . $wpdb->prefix . 'product_aut ORDER BY domain ASC LIMIT 25', ARRAY_A);
  39. }
  40. if (!is_wp_error($query) && !empty($query)) {
  41. foreach ($query as $domain_info) {
  42. $options[$domain_info['domain']] = $domain_info['domain'];
  43. }
  44. }
  45. else {
  46. $options = '';
  47. }
  48.  
  49. return $options;
  50. }
  51. }
  52. }
  53.  
  54. function zyx_custom_product_setup()
  55. {
  56. $product_name = (!!zyx_auth('product_display_name') ? zyx_auth('product_display_name') : '产品');
  57. $product_rewrite_slug = (!!zyx_auth('product_rewrite_slug') ? zyx_auth('product_rewrite_slug') : 'product');
  58. $product_category_rewrite_slug = '';
  59. $product_tag_rewrite_slug = '';
  60. register_post_type('product', [
  61. 'labels' => ['name' => $product_name, 'singular_name' => $product_name, 'menu_name' => $product_name, 'all_items' => '所有' . $product_name, 'add_new' => '添加新' . $product_name, 'add_new_item' => '添加新' . $product_name, 'edit_item' => '编辑' . $product_name, 'new_item' => '新' . $product_name, 'view_item' => '查看' . $product_name, 'search_items' => '搜索' . $product_name, 'not_found' => '未找到' . $product_name, 'not_found_in_trash' => '回收站中未找到' . $product_name],
  62. 'public' => true,
  63. 'has_archive' => true,
  64. 'menu_icon' => 'dashicons-cart',
  65. 'show_in_rest' => true,
  66. 'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'comments', 'author'],
  67. 'rewrite' => ['slug' => $product_rewrite_slug]
  68. ]);
  69. register_taxonomy('product_category', 'product', [
  70. 'hierarchical' => true,
  71. 'labels' => ['name' => $product_name . '分类', 'singular_name' => $product_name . '分类', 'search_items' => '搜索' . $product_name . '分类', 'all_items' => '所有' . $product_name . '分类', 'parent_item' => '父级' . $product_name . '分类', 'parent_item_colon' => '父级' . $product_name . '分类:', 'edit_item' => '编辑' . $product_name . '分类', 'update_item' => '更新' . $product_name . '分类', 'add_new_item' => '添加新' . $product_name . '分类', 'new_item_name' => '新' . $product_name . '分类名称', 'menu_name' => $product_name . '分类'],
  72. 'show_ui' => true,
  73. 'show_admin_column' => true,
  74. 'query_var' => false,
  75. 'show_in_rest' => true,
  76. 'rewrite' => false,
  77. 'public' => false,
  78. 'publicly_queryable' => false
  79. ]);
  80. register_taxonomy('product_tag', 'product', [
  81. 'hierarchical' => false,
  82. 'labels' => ['name' => $product_name . '标签', 'singular_name' => $product_name . '标签', 'search_items' => '搜索' . $product_name . '标签', 'all_items' => '所有' . $product_name . '标签', 'edit_item' => '编辑' . $product_name . '标签', 'update_item' => '更新' . $product_name . '标签', 'add_new_item' => '添加新' . $product_name . '标签', 'new_item_name' => '新' . $product_name . '标签名称', 'menu_name' => $product_name . '标签'],
  83. 'show_ui' => true,
  84. 'show_admin_column' => true,
  85. 'query_var' => false,
  86. 'show_in_rest' => true,
  87. 'rewrite' => false,
  88. 'public' => false,
  89. 'publicly_queryable' => false
  90. ]);
  91. }
  92.  
  93. function zyx_admin_product_posts_columns($columns)
  94. {
  95. $order = (isset($_REQUEST['order']) && ('desc' == $_REQUEST['order']) ? 'asc' : 'desc');
  96.  
  97. if (isset($columns['cb'])) {
  98. $add_columns['cb'] = $columns['cb'];
  99. unset($columns['cb']);
  100. }
  101.  
  102. if (isset($columns['title'])) {
  103. $add_columns['title'] = $columns['title'];
  104. unset($columns['title']);
  105. }
  106.  
  107. if (isset($columns['author'])) {
  108. $add_columns['author'] = $columns['author'];
  109. unset($columns['author']);
  110. }
  111.  
  112. $add_columns['all_count'] = '<a href="' . add_query_arg(['orderby' => 'views', 'order' => $order]) . '"><span>阅读</span></a>';
  113. $add_columns['assets'] = '<span>下载记录</span>';
  114. $add_columns['aut_price'] = '<span>购买价格</span>';
  115. $add_columns['aut_data'] = '<span>授权验证方式</span>';
  116. return array_merge($add_columns, $columns);
  117. }
  118.  
  119. function zyx_admin_product_posts_custom_column($column_name, $posts_id)
  120. {
  121. $product_shop_options = get_post_meta($posts_id, 'product_shop_options', true);
  122. $product_parameter_options = get_post_meta($posts_id, 'product_parameter_options', true);
  123.  
  124. switch ($column_name) {
  125. case 'aut_data':
  126. $type = '';
  127.  
  128. switch (isset($product_shop_options['verify'])) {
  129. case 'domain':
  130. $type = '授权码+域名验证';
  131. break;
  132. case 'ip':
  133. $type = '授权码+IP验证';
  134. break;
  135. default:
  136. $type = '未知验证方式(配置缺失)';
  137. break;
  138. }
  139.  
  140. echo '<div style="font-size: 12px;">' . $type . '</div>';
  141. break;
  142. case 'aut_price':
  143. $btns = $product_shop_options['zyx_btns'];
  144. $getapp = '';
  145.  
  146. if ($btns) {
  147. foreach ($btns as $bv) {
  148. $getapp = zyx_aut_get_pay_name($btns, $product_shop_options['authpay']);
  149. }
  150. }
  151.  
  152. echo $getapp;
  153. break;
  154. case 'all_count':
  155. $views = _cut_count((string) get_post_meta($posts_id, 'views', true));
  156. echo '<div style="font-size: 12px;">阅读 ' . $views . '</div>';
  157. break;
  158. case 'assets':
  159. $data = '<div style="font-size: 12px;">购买数量 ' . zyxpay_get_product($posts_id) . '</div>';
  160. $data .= zyxpay_get_paydown_log_admin_link('post', $posts_id, 'px12', $con = '[查看下载记录]');
  161. echo $data;
  162. break;
  163. }
  164. }
  165.  
  166. function zyx_aut_get_pay_name($type, $authpay)
  167. {
  168. $user_id = get_current_user_id();
  169. $name = ['y' => '月卡授权', 'j' => '季卡授权', 'm' => '年卡授权', 'g' => '永久授权'];
  170. $uservip = zib_get_user_vip_level($user_id);
  171. $n = '';
  172.  
  173. foreach ($type as $l => $bv) {
  174. if ($uservip == 2) {
  175. $pay = $authpay[$bv . '_2vip'];
  176. }
  177. else if ($uservip == 1) {
  178. $pay = $authpay[$bv . '_1vip'];
  179. }
  180. else {
  181. $pay = $authpay[$bv . '_pay'];
  182. }
  183.  
  184. $_class = ($l == '0' ? ' active' : '');
  185. $n .= (isset($name[$bv]) ? $name[$bv] . ': ¥' . $pay . '<br>' : '还没有配置好');
  186. }
  187.  
  188. return $n;
  189. }
  190.  
  191. function zyx_post_thumbnail($size = '', $class = 'fit-cover', $show_url = false, $post = NULL)
  192. {
  193. if (!$size) {
  194. $size = zi_pz('thumb_postfirstimg_size');
  195. }
  196.  
  197. if (!is_object($post)) {
  198. $post = get_post($post);
  199. }
  200.  
  201. $cache_url = wp_cache_get($post->ID, 'post_thumbnail_url_' . $size, true);
  202.  
  203. if (false === $cache_url) {
  204. $img_url = '';
  205. $post_thumbnail_id = get_post_thumbnail_id($post->ID);
  206.  
  207. if ($post_thumbnail_id) {
  208. $image_src = zib_get_attachment_image_src($post_thumbnail_id, $size);
  209. $img_url = (isset($image_src[0]) ? $image_src[0] : '');
  210. }
  211.  
  212. if (!$img_url) {
  213. $product_parameter_options = get_post_meta($post->ID, 'product_parameter_options', true);
  214. $img_url = $product_parameter_options['thumbnail_url'];
  215. }
  216. if (!$img_url && zi_pz('thumb_postfirstimg_s', true)) {
  217. $post_img_urls = zib_get_post_img_urls($post);
  218. $img_url = (isset($post_img_urls[0]) ? $post_img_urls[0] : '');
  219. if ($img_url && ($size && ('full' !== $size))) {
  220. $img_id = zib_get_image_id($img_url);
  221.  
  222. if ($img_id) {
  223. $img = wp_get_attachment_image_src($img_id, $size);
  224.  
  225. if (isset($img[0])) {
  226. $img_url = $img[0];
  227. }
  228. }
  229. }
  230. }
  231.  
  232. wp_cache_set($post->ID, $img_url, 'post_thumbnail_url_' . $size);
  233. }
  234. else {
  235. $img_url = ('no' == $cache_url ? '' : $cache_url);
  236. }
  237.  
  238. if ($show_url) {
  239. return $img_url;
  240. }
  241.  
  242. $lazy_thumb = zib_get_lazy_thumb();
  243. $r_attr = '';
  244. $alt = $post->post_title . zib_get_delimiter_blog_name();
  245.  
  246. if (!$img_url) {
  247. $img_url = zib_get_spare_thumb();
  248. $r_attr = ' data-thumb="default"';
  249. }
  250.  
  251. if (zib_is_lazy('lazy_posts_thumb')) {
  252. return sprintf('<img' . $r_attr . ' src="%s" data-src="%s" alt="%s" class="lazyload ' . $class . '">', $lazy_thumb, $img_url, $alt);
  253. }
  254. else {
  255. return sprintf('<img' . $r_attr . ' src="%s" alt="%s" class="' . $class . '">', $img_url, $alt);
  256. }
  257. }
  258.  
  259. function zyx_posts_related($related_title = '相关阅读', $limit = 6, $orderby = 'views')
  260. {
  261. global $post;
  262. $thumb_s = zyx_auth('post_related_type') == 'img';
  263. $categorys = get_the_terms($post, 'category');
  264. $topics = get_the_terms($post, 'topics');
  265. $tags = get_the_terms($post, 'post_tag');
  266. $posts_args = ['showposts' => $limit, 'ignore_sticky_posts' => 1, 'post_type' => 'product', 'post_status' => 'publish', 'order' => 'DESC', 'no_found_rows' => true];
  267. $posts_args = zib_query_orderby_filter($orderby, $posts_args);
  268. $posts_lits = '';
  269. $new_query = new WP_Query($posts_args);
  270.  
  271. while ($new_query->have_posts()) {
  272. $new_query->the_post();
  273.  
  274. if (zyx_auth('post_related_type') == 'list') {
  275. $posts_lits .= zib_posts_mini_while(['echo' => false, 'show_number' => false]);
  276. continue;
  277. }
  278.  
  279. if ($thumb_s) {
  280. $title = get_the_title() . get_the_subtitle(false);
  281. $time_ago = zib_get_time_ago(get_the_time('Y-m-d H:i:s'));
  282. $info = '<item>' . $time_ago . '</item><item class="pull-right">' . zib_get_svg('view') . ' ' . get_post_view_count($before = '', $after = '') . '</item>';
  283. $img = zyx_post_thumbnail('', 'fit-cover', true);
  284. $img = ($img ? $img : zib_get_spare_thumb());
  285. $card = [
  286. 'type' => 'style-3',
  287. 'class' => 'mb10',
  288. 'img' => $img,
  289. 'alt' => $title,
  290. 'link' => ['url' => get_permalink(), 'target' => ''],
  291. 'text1' => $title,
  292. 'text2' => zib_str_cut($title, 0, 45, '...'),
  293. 'text3' => $info,
  294. 'lazy' => true,
  295. 'height_scale' => 70
  296. ];
  297. $posts_lits .= '<div class="swiper-slide mr10">';
  298. $posts_lits .= zib_graphic_card($card);
  299. $posts_lits .= '</div>';
  300. continue;
  301. }
  302.  
  303. $posts_lits .= '<li><a class="icon-circle" href="' . get_permalink() . '">' . get_the_title() . get_the_subtitle() . '</a></li>';
  304. }
  305.  
  306. wp_reset_query();
  307. wp_reset_postdata();
  308. $html = '<div class="theme-box relates' . ($thumb_s ? ' relates-thumb' : '') . '">' . "\n" . ' <div class="box-body notop">' . "\n" . ' <div class="title-theme">' . $related_title . '</div>' . "\n" . ' </div>';
  309. $html .= '<div class="zib-widget">';
  310. $html .= ($thumb_s ? '<div class="swiper-container swiper-scroll"><div class="swiper-wrapper">' : '<ul class="no-thumb">');
  311.  
  312. if (!$posts_lits) {
  313. $html .= '<li>暂无相关文章</li>';
  314. }
  315. else {
  316. $html .= $posts_lits;
  317. }
  318.  
  319. $html .= ($thumb_s ? '</div><div class="swiper-button-prev"></div><div class="swiper-button-next"></div></div>' : '</ul>');
  320. $html .= '</div></div>';
  321. return $html;
  322. }
  323.  
  324. function get_user_ip()
  325. {
  326. if (getenv('HTTP_X_REAL_IP')) {
  327. $ip = getenv('HTTP_X_REAL_IP');
  328. }
  329. else if (getenv('HTTP_X_FORWARDED_FOR')) {
  330. $ips = explode(',', getenv('HTTP_X_FORWARDED_FOR'));
  331. $ip = trim($ips[0]);
  332. }
  333. else if (getenv('REMOTE_ADDR')) {
  334. $ip = getenv('REMOTE_ADDR');
  335. }
  336. else {
  337. $ip = 'UNKNOWN';
  338. }
  339.  
  340. return $ip;
  341. }
  342.  
  343. function zyx_get_qq_user_type()
  344. {
  345. $user = wp_get_current_user();
  346. $u = zyx_auth('qq-user');
  347. $flag = false;
  348. if (in_array('administrator', $user->roles) || in_array($user->ID, $u ? $u : [])) {
  349. $flag = true;
  350. }
  351.  
  352. return $flag;
  353. }
  354.  
  355. function zyx_ip_die($msg = '', $t = '')
  356. {
  357. if (!$t) {
  358. $t = (get_current_user_id() ? '绑定失败' : '登录失败');
  359. }
  360.  
  361. $con = '<h4 class="c-red box-body separator mb30">' . $t . '</h4>';
  362. $con .= '<div class="mb20 muted-box text-left" style=" max-width: 600px; margin: auto; ">' . $msg . '</div>';
  363. $args = ['img' => ZIB_TEMPLATE_DIRECTORY_URI . '/img/null-user.svg', 'title' => $t . zib_get_delimiter_blog_name()];
  364. zyx_die_page($con, $args);
  365. }
  366.  
  367. function zyx_die_page($message = '', $args = [])
  368. {
  369. $img = '<img src="' . ZIB_TEMPLATE_DIRECTORY_URI . '/img/404.svg">';
  370.  
  371. if (isset($args['img'])) {
  372. $img = ($args['img'] ? '<img src="' . $args['img'] . '">' : '');
  373. }
  374.  
  375. if (isset($args['title'])) {
  376. $GLOBALS['new_title'] = $args['title'];
  377. add_filter('echo_seo_title', '__return_true');
  378. }
  379.  
  380. get_header();
  381. echo ' <main class="container flex ac">' . "\n" . ' <div class="f404 flex1">' . "\n" . ' ';
  382. echo $img . '<div class="f404-msg mt20">' . $message . '</div>';
  383. echo ' </div>' . "\n" . ' </main>' . "\n" . ' ';
  384. get_footer();
  385. exit();
  386. }
  387.  
  388. function zyx_product_mistake_page()
  389. {
  390. $html = "\n" . ' <div class="plate-tab zib-widget">' . "\n" . ' <div class="text-center mb10" style="padding:60px 0;">' . "\n" . ' <img style="width:280px;opacity: .7;" src="/wp-content/themes/zibll/img/null-order.svg">' . "\n" . ' <p style="margin-top:10px;" class="em09 muted-3-color separator">暂无商品数据</p>' . "\n" . ' <div class="text-center em09 mt20">' . "\n" . ' <p>';
  391.  
  392. if (!current_user_can('administrator')) {
  393. $html .= '<a href="javascript:;" class="signin-loader but jb-blue padding-lg">暂无商品,请联系管理员!</a>';
  394. }
  395. else {
  396. $html .= '<a target="_blank" href="' . add_query_arg('post_type', 'product', admin_url('post-new.php')) . '" class="signup-loader but jb-yellow padding-lg">立即添加商品</a>';
  397. }
  398.  
  399. $html .= '</p>' . "\n" . ' </div></div>' . "\n" . ' </div>';
  400. return zib_get_ajax_ajaxpager_one_centent($html);
  401. }
  402.  
  403. function zyx_product_advance_page($post_id)
  404. {
  405. $zyx_advance = zyx_advance($post_id);
  406. $product_shop_options = get_post_meta($post_id, 'product_shop_options', true);
  407. $html = "\n" . ' <div class="plate-tab zib-widget">' . "\n" . ' <div class="text-center mb10" style="padding:60px 0;">' . "\n" . ' <img style="width:280px;opacity: .7;" src="/wp-content/themes/zibll/img/null-set.svg">' . "\n" . ' <p style="margin-top:10px;" class="em09 muted-3-color separator">产品将于 <spen class="c-red">' . $zyx_advance['end_time'] . '</spen> 发布 请耐心等待!</p>' . "\n" . ' <div class="text-center em09 mt20">' . "\n" . ' <p>';
  408.  
  409. if ($product_shop_options['download_qun_url']['url']) {
  410. $html .= '<a class="signin-loader but jb-blue padding-lg" target="' . $product_shop_options['download_qun_url']['target'] . '" href="' . $product_shop_options['download_qun_url']['url'] . '">加入正版群</a>';
  411. }
  412.  
  413. $html .= '</p>' . "\n" . ' </div></div>' . "\n" . ' </div>';
  414. return zib_get_ajax_ajaxpager_one_centent($html);
  415. }
  416.  
  417. function zyx_product_aut_manage_page()
  418. {
  419. $html = "\n" . ' <div class="plate-tab zib-widget">' . "\n" . ' <div class="text-center mb10" style="padding:60px 0;">' . "\n" . ' <img style="width:280px;opacity: .7;" src="/wp-content/themes/zibll/img/null-set.svg">' . "\n" . ' <p style="margin-top:10px;" class="em09 muted-3-color separator">暂无权限</p>' . "\n" . ' <div class="text-center em09 mt20">' . "\n" . ' <p>';
  420. $html .= '<a href="javascript:;" class="signin-loader but jb-blue padding-lg">无权访问此页面 请先成为开发者并发布产品</a>';
  421. $html .= '</p>' . "\n" . ' </div></div>' . "\n" . ' </div>';
  422. return zib_get_ajax_ajaxpager_one_centent($html);
  423. }
  424.  
  425. function zyx_product_activity($post_id)
  426. {
  427. $checkLimitedTimeOffer = checkLimitedTimeOffer($post_id);
  428.  
  429. if (!$checkLimitedTimeOffer) {
  430. return NULL;
  431. }
  432. if (empty($checkLimitedTimeOffer['end_time']) || (empty($checkLimitedTimeOffer['title']) && empty($checkLimitedTimeOffer['description']))) {
  433. return NULL;
  434. }
  435.  
  436. $new_time = current_time('Y-m-d H:i:s');
  437. $end_time = date('m/d/Y H:i:s', strtotime($checkLimitedTimeOffer['end_time']));
  438. $html = '<div class="countdown-activity flex jc">';
  439. $html .= '<div class="activity-content flex ac">';
  440. $html .= (!empty($checkLimitedTimeOffer['title']) ? '<div class="activity-title mr10">' . $checkLimitedTimeOffer['title'] . '</div>' : '');
  441. $html .= (!empty($checkLimitedTimeOffer['description']) ? '<div class="activity-desc">' . $checkLimitedTimeOffer['description'] . '</div>' : '');
  442. $html .= '</div>';
  443. $html .= '<div class="countdown-content badg jb-yellow radius flex jc">';
  444. $html .= '<div class="countdown-desc">活动倒计时</div>';
  445. $html .= '<div class="countdown-time flex0 em09-sm badg jb-vip2 radius" data-over-text="活动已结束" data-newtime="' . $new_time . '" data-countdown="' . $end_time . '">';
  446. $html .= 'X天X小时X分X秒';
  447. $html .= '</div>';
  448. $html .= '</div>';
  449. $html .= '</div>';
  450. return $html;
  451. }
  452.  
  453. function zyx_product_advance($post_id)
  454. {
  455. $zyx_advance = zyx_advance($post_id);
  456.  
  457. if (!$zyx_advance) {
  458. return NULL;
  459. }
  460. if (empty($zyx_advance['end_time']) || (empty($zyx_advance['title']) && empty($zyx_advance['description']))) {
  461. return NULL;
  462. }
  463.  
  464. $new_time = current_time('Y-m-d H:i:s');
  465. $end_time = date('m/d/Y H:i:s', strtotime($zyx_advance['end_time']));
  466. $html = '<div class="countdown-activity flex jc">';
  467. $html .= '<div class="activity-content flex ac">';
  468. $html .= (!empty($zyx_advance['title']) ? '<div class="activity-title mr10">' . $zyx_advance['title'] . '</div>' : '');
  469. $html .= (!empty($zyx_advance['description']) ? '<div class="activity-desc">' . $zyx_advance['description'] . '</div>' : '');
  470. $html .= '</div>';
  471. $html .= '<div class="countdown-content badg jb-yellow radius flex jc">';
  472. $html .= '<div class="countdown-desc">预售倒计时</div>';
  473. $html .= '<div class="countdown-time flex0 em09-sm badg jb-vip2 radius" data-over-text="预售已结束" data-newtime="' . $new_time . '" data-countdown="' . $end_time . '">';
  474. $html .= 'X天X小时X分X秒';
  475. $html .= '</div>';
  476. $html .= '</div>';
  477. $html .= '</div>';
  478. return $html;
  479. }
  480.  
  481. function zyxpay_updata_pay_down_mate($post_id, $down_id, $paid)
  482. {
  483. $user_id = get_current_user_id();
  484. $order_date = zyx_product_order_date($user_id, $post_id);
  485. $user_log_data = ['order_num' => !empty($order_date[0]['pay_num']) ? $order_date[0]['pay_num'] : '', 'post_id' => $post_id, 'down_id' => $down_id];
  486. zyxpay_updata_user_down_log($user_id, $user_log_data);
  487. $poat_log_data = ['order_num' => !empty($order_date[0]['pay_num']) ? $order_date[0]['pay_num'] : '', 'user_id' => $user_id, 'down_id' => $down_id];
  488. zyxpay_updata_post_down_log($post_id, $poat_log_data);
  489. }
  490.  
  491. function zyx_get_remote_ip_addr()
  492. {
  493. if (getenv('HTTP_X_REAL_IP')) {
  494. $ip = getenv('HTTP_X_REAL_IP');
  495. }
  496. else if (getenv('HTTP_X_FORWARDED_FOR')) {
  497. $ips = explode(',', getenv('HTTP_X_FORWARDED_FOR'));
  498. $ip = trim($ips[0]);
  499. }
  500. else if (getenv('REMOTE_ADDR')) {
  501. $ip = getenv('REMOTE_ADDR');
  502. }
  503. else {
  504. $ip = '';
  505. }
  506.  
  507. return $ip;
  508. }
  509.  
  510. function zyxpay_updata_user_down_log($user_id, $data)
  511. {
  512. $max = (int) _pz('pay_type_option', 0, 'down_user_log');
  513.  
  514. if (!$max) {
  515. return false;
  516. }
  517.  
  518. $defaults = ['paid_type' => '', 'order_num' => '', 'post_id' => '', 'down_id' => '', 'time' => current_time('Y-m-d H:i'), 'ip' => zyx_get_remote_ip_addr()];
  519. $data = wp_parse_args($data, $defaults);
  520.  
  521. if (!$data['post_id']) {
  522. return false;
  523. }
  524.  
  525. $meta_key = 'pay_product_down_log';
  526. $record = zib_get_user_meta($user_id, $meta_key, true);
  527. if (!$record || !is_array($record)) {
  528. $record = [];
  529. }
  530.  
  531. $record = array_slice($record, 0, $max - 1, true);
  532. $new_record = array_merge([$data], $record);
  533. return zib_update_user_meta($user_id, $meta_key, $new_record);
  534. }
  535.  
  536. function zyxpay_updata_post_down_log($post_id, $data)
  537. {
  538. $max = (int) _pz('pay_type_option', 0, 'down_post_log');
  539.  
  540. if (!$max) {
  541. return false;
  542. }
  543.  
  544. $defaults = ['paid_type' => '', 'order_num' => '', 'user_id' => '', 'down_id' => '', 'time' => current_time('Y-m-d H:i'), 'ip' => zyx_get_remote_ip_addr()];
  545. $data = wp_parse_args($data, $defaults);
  546. $meta_key = 'pay_product_down_log';
  547. $record = zib_get_post_meta($post_id, $meta_key, true);
  548. if (!$record || !is_array($record)) {
  549. $record = [];
  550. }
  551.  
  552. $record = array_slice($record, 0, $max - 1, true);
  553. $new_record = array_merge([$data], $record);
  554. return zib_update_post_meta($post_id, $meta_key, $new_record);
  555. }
  556.  
  557. if (!defined('ABSPATH')) {
  558. exit();
  559. }
  560.  
  561. $include_once = ['zyx-update', 'zyx-log', 'zyx-sql', 'zyx-msg', 'zyx-ajax', 'zyx-tool', 'zyx-modal', 'zyx-class', 'zyx-link', 'zyx-posts', 'zyx-search', 'zyx-statistics', 'zyx-rewrites', 'auth/zyx-page', 'auth/zyx-auth', 'auth/zyx-admin', 'acting/zyx-tab', 'acting/zyx-pay', 'acting/zyx-ajax', 'card/zyx-cardamom', 'card/cardamom-ajax', 'card/zyx-promo', 'api/zyx-detection', 'api/zyx-anncmnt', 'api/zyx-aut', 'api/zyx-update', 'api/zyx-api', 'api/zyx-promo', 'user/side', 'user/report', 'user/query', 'user/page', 'help/zyx-help', 'widgets/functions'];
  562.  
  563. foreach ($include_once as $inc) {
  564. include $inc . '.php';
  565. }
  566. zyxauth::init();
  567. add_action('wp_enqueue_scripts', 'zyx_add_wp_enqueue');
  568. add_filter('wp_sitemaps_add_provider', function($provider, $name) {
  569. return $name == 'taxonomies' ? false : $provider;
  570. }, 10, 2);
  571.  
  572. if (!function_exists('is_current_page_aut')) {
  573. function is_current_page_aut()
  574. {
  575. $current_path = $_SERVER['REQUEST_URI'];
  576. $current_path = rtrim($current_path, '/');
  577.  
  578. if ($current_path === '/aut') {
  579. return true;
  580. }
  581.  
  582. return false;
  583. }
  584. }
  585.  
  586. add_action('init', 'zyx_custom_product_setup');
  587. add_filter('manage_product_posts_columns', 'zyx_admin_product_posts_columns');
  588. add_action('manage_product_posts_custom_column', 'zyx_admin_product_posts_custom_column', 11, 2);
  589. add_action('zyxpay_download_before', 'zyxpay_updata_pay_down_mate', 10, 3);
  590.  
  591. ?>
Advertisement
Add Comment
Please, Sign In to add comment