403Webshell
Server IP : 185.143.233.238  /  Your IP : 185.215.232.195
Web Server : LiteSpeed
System : Linux saman.shetabanhost.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User : behrakir ( 1361)
PHP Version : 8.1.34
Disable Function : symlink,shell_exec,show_source,exec,popen,system,passthru,proc_open,proc_close,pcntl_exec,mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/behrakir/khanomam.com/wp-content/plugins/wp-score-gamification/includes/front/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/behrakir/khanomam.com/wp-content/plugins/wp-score-gamification/includes/front/ajax.php
<?php

use Avans\data;
use Avans\func;
use Avans\parts\completeProfile;
use Avans\parts\gifts;
use Avans\parts\voucher;
use Avans\user;

include_once AVANS_PATH.'includes/front/ajax_nopriv.php';

function avs_add_score_view_post_types_callback(){

    $user_id = $_POST['user'];
    $post_id = (int)$_POST['id'];


    if(!is_user_logged_in() || !wp_verify_nonce($_POST['nonce'] , "avans_view_post_" . $post_id ) ){
        return;
    }


    $post_type = get_post_type($post_id);
    $settings = AVANS_SETTINGS['score_settings'][$post_type];

    if($post_type == 'page'){
        $settings_page = get_post_meta($post_id,AVANS_PREFIX.'meta_score_page',true);
        $score_page    = isset($settings_page['score']) ? (int)$settings_page['score'] : 0;
        if($score_page > 0){
            $settings = $settings_page;
        }
    }

    $post_viewed = (array)get_user_meta($user_id,AVANS_PREFIX.'post_types_viewed',true);
    $post_type_viewed = (array)get_user_meta($user_id, AVANS_PREFIX.$post_type.'_viewed',true);

    if( in_array( $post_id , $post_viewed) ){
        $permision_get_score = user::is_permision_scorring_postType( $user_id , $post_id );

        if(!$permision_get_score){
            wp_send_json(array(
                'action-status' => 'current user last viewed current post'
            ));
        }
    }


    if ( !user::is_permision_get_score('view-'.$post_type, $user_id) ) return;


    if( !in_array($post_id , $post_viewed) ){
        array_push($post_viewed,$post_id);
    }

    if( !in_array($post_id , $post_type_viewed) ){
        array_push($post_type_viewed,$post_id);
    }

    $details = array(
        array(
            'key' => 'post-id',
            'value' => $post_id
        )
    );


    if($post_type == 'page'){
        $finalscore = user::add_log($user_id,'view-'.$post_type,$details,(int)$settings['score']);
    }else{
        $finalscore = user::add_log($user_id, 'view-'.$post_type, $details);
    }

    if ($finalscore) {
        update_user_meta($user_id, AVANS_PREFIX.'post_types_viewed', $post_viewed);
        update_user_meta($user_id, AVANS_PREFIX.$post_type.'_viewed', $post_type_viewed);
        do_action('avans_after_view_post_type',$user_id,$post_id);
    }

    wp_send_json(array(
        'success' => $finalscore ? true : false,
        'result' => $finalscore ? $finalscore : 'score_is_zero',
    ));
}
add_action(AVANS_AJAX_PREFIX . 'avs_add_score_view_post_types','avs_add_score_view_post_types_callback');




function avs_add_score_daily_visit_callback(){

    if(!wp_verify_nonce( $_POST['nonce'] , "avans_daily_visit")){
        wp_send_json("nonce code is not valid",403);
    }


    if(!is_user_logged_in()){
        return;
    }

    $settings = AVANS_SETTINGS['score_settings']['daily'];
    $user_id = get_current_user_id();

    $time       = avans_date('Y-m-d', time());
    $last_visit = get_user_meta($user_id,AVANS_PREFIX.'last_visit', true);
    
    if($time == $last_visit){
        return;
    }

    if (!user::is_permision_get_score('daily-visit', $user_id)) {
        return;
    }
    
    user::add_log($user_id,'daily-visit');

    $last_visit = update_user_meta($user_id,AVANS_PREFIX.'last_visit', $time);

    wp_send_json([
        'success' => true,
        'show_toast' => true,
    ], 200);

}
add_action(AVANS_AJAX_PREFIX . 'avs_add_score_daily_visit','avs_add_score_daily_visit_callback');





function avs_add_score_view_player_callback(){

    if (!is_user_logged_in()) {
        return;
    }

    $user = wp_get_current_user();
    $score = $_POST['score'];
    $player_id = $_POST['player_id'];

    $details = array(
        array(
            'key' => 'post_id',
            'value' => $_POST['post_id'],
        ),
        array(
            'key' => 'object_id',
            'value' => $_POST['object_id'],
        )
    );
    
    if ($_POST['type'] == 'video') {

        if(!wp_verify_nonce($_POST['nonce'] , "avans_player_video" . $player_id )){
            return;
        }

        $video_viewed = (array)get_user_meta($user->ID, AVANS_PREFIX.'video_viewed', true);
        if (!in_array($player_id, $video_viewed)) {
            array_push($video_viewed, $player_id);
            if (!user::is_permision_get_score('view-video', $user->ID)) {
                return;
            }
            update_user_meta($user->ID, AVANS_PREFIX.'video_viewed', $video_viewed);

            Avans\user::add_log($user->ID,'view-video',$details,(int)$score);

            do_action('avans_after_view_video',$user,$player_id,$video_viewed, $_POST['post_id']);
            
            wp_send_json([
            'success' => true,
        ], 200);
        }
    }

    if ($_POST['type'] == 'sound') {

        if(!wp_verify_nonce($_POST['nonce'] , "avans_player_sound" . $player_id )){
            return;
        }

        $sound_viewed = (array)get_user_meta($user->ID, AVANS_PREFIX.'sound_viewed', true);
        if (!in_array($player_id, $sound_viewed)) {
            array_push($sound_viewed, $player_id);

            if (!user::is_permision_get_score('view-sound', $user->ID)) {
                return;
            }

            update_user_meta($user->ID, AVANS_PREFIX.'sound_viewed', $sound_viewed);

            Avans\user::add_log($user->ID,'view-sound',$details,(int)$score);

            do_action('avans_after_listen_podcasts', $user, $player_id, $sound_viewed, $_POST['post_id']);

            wp_send_json([
            'success' => true,
        ], 200);
        }
    }

}
add_action(AVANS_AJAX_PREFIX . 'avs_add_score_view_player','avs_add_score_view_player_callback');



function avans_search_user_logs_callback(){
    $args = [];

    $args['where'] = true;
    if (isset($_GET['type']) && !empty($_GET['type'])) {
        $args['include']['type'] = $_GET['type'];
    }

    $args['include']['user'] = get_current_user_id();

    if (isset($_GET['from']) && !empty($_GET['from'])) {
        $args['time']['from'] = Avans\func::convert_jalali_to_miladi($_GET['from']);
    }
    if (isset($_GET['to']) && !empty($_GET['to'])) {
        $args['time']['to'] = Avans\func::convert_jalali_to_miladi($_GET['to']);
    }
    if (isset($_GET['page']) && !empty($_GET['page'])) {
        $args['page'] = $_GET['page'];
    }

    $logs = Avans\data::get_logs($args);
    include_once AVANS_PATH.'templates/front/panel/content/sections/reports-main.php';

    die;
}
add_action(AVANS_AJAX_PREFIX . 'avans_search_user_logs','avans_search_user_logs_callback');

function avans_search_gifts_list_callback(){
    $args = [
        'post_type'        => 'avans-gift',
        'posts_per_page'  => 12,
    ];
    if(isset($_GET['page'])){
        $args['paged'] = (int)$_GET['page'];
    }
    $gifts = Avans\data::get_gifts($args);
    include_once AVANS_PATH.'templates/front/panel/content/sections/gift-tabs/all-gift.php';
    die;

}
add_action(AVANS_AJAX_PREFIX . 'avans_search_gifts_list', 'avans_search_gifts_list_callback');

function avans_get_single_page_gift_callback(){
    $id = $_GET['id'];
    include_once AVANS_PATH.'templates/front/panel/content/sections/gift-single.php';
    die;
}
add_action(AVANS_AJAX_PREFIX . 'avans_get_single_page_gift','avans_get_single_page_gift_callback');

function avans_get_gifts_for_user_callback()
{
    $gift_id = sanitize_text_field($_GET['giftid']);

    if(!wp_verify_nonce($_GET['nonce'] , 'avans_get_gift_' . $gift_id)){
        echo "ارتباط با سرور نا معتبر است!";
        die;
        return;
    }

    $option = get_post_meta($gift_id, AVANS_PREFIX.'gift_settings', true);
    $data = Avans\user::add_gift_to_user( (int)$gift_id , (int)get_current_user_id() );
    $created_at = isset($data->create_at) ? strtotime($data->create_at) : '';
    if ($data) {
        include_once AVANS_PATH.'templates/front/panel/content/sections/gift-results.php';
    }
    die;
}
add_action(AVANS_AJAX_PREFIX . 'avans_get_gifts_for_user', 'avans_get_gifts_for_user_callback');

function avans_get_details_badge_callback(){
    $user_id = get_current_user_id();
    $badge_id = (int)$_GET['id'];
    do_action('avans_before_badge_details',$user_id,$badge_id);
    include AVANS_PATH.'templates/front/panel/content/sections/badge-details.php';
    die;
}
add_action(AVANS_AJAX_PREFIX . "avans_get_details_badge","avans_get_details_badge_callback");


function avans_loade_getted_gifts_tab_callback(){
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    $data = Avans\user::get_user_getted_gifts(get_current_user_id(),$page);
    include AVANS_PATH.'templates/front/panel/content/sections/gift-tabs/getted-gift.php';
    die;
}
add_action(AVANS_AJAX_PREFIX . 'avans_loade_getted_gifts_tab','avans_loade_getted_gifts_tab_callback');

function avans_loade_all_gifts_tab_callback()
{
    $gifts = Avans\data::get_gifts();
    include AVANS_PATH.'templates/front/panel/content/sections/gift-tabs/all-gift.php';
    die;
}
add_action(AVANS_AJAX_PREFIX . 'avans_loade_all_gifts_tab', 'avans_loade_all_gifts_tab_callback');

function avans_convert_wallet_callback(){

    if( !wp_verify_nonce( $_POST['nonce'] , "avans_convert_wallet"  ) ){
        wp_send_json([
            'success' => false,
            'message' => 'خطای اعتبارسنجی',
        ]);
    }

    if(isset($_COOKIE['avans_convert_wallet']) ){
        wp_send_json([
            'success' => false,
            'message' => 'امکان درخواست های مکرر در یک بازه زمانی مشخصی وجود ندارد.',
        ]);
    }
    setcookie("avans_convert_wallet" , "1" , time() + 10 , "/");


    $convert = user::convert_wallet(get_current_user_id());
    
    setcookie("avans_convert_wallet" , "1" , time() - 1 , "/");

    wp_send_json([
        'success' => $convert->success,
        'message' => $convert->message,
    ]);
}
add_action(AVANS_AJAX_PREFIX . 'avans_convert_wallet', 'avans_convert_wallet_callback');

function avans_get_prize_spin_wheel_callback(){

    if(!wp_verify_nonce($_POST['nonce'] , "avans_get_prize_spin_wheel_" . $_POST['wheel_id'])){
        wp_send_json(['erorr' => 'nonce is not valid'],403);
    }

    if(!isset($_POST['wheel_id']) || get_post_type($_POST['wheel_id']) != 'avans-spin-wheel'){
        wp_send_json(['erorr' => 'The "wheel_id" parameter is not set or is set incorrectly!'],404);
    }

    wp_send_json([
        'result' => Avans\user::get_prize_spin_wheel(get_current_user_id(),(int)$_POST['wheel_id']),
    ]);

}
add_action(AVANS_AJAX_PREFIX . 'avans_get_prize_spin_wheel','avans_get_prize_spin_wheel_callback');


function avans_get_result_spin_wheel_callback(){
    $data = $_GET['response'];

    $option = [
        'avans_type_gift' => $data['type'],
        'type_prize' => 'spin_wheel'
    ];
    $created_at = strtotime($data->create_at);
    include_once AVANS_PATH.'templates/front/panel/content/sections/gift-results.php';
    die;
}
add_action(AVANS_AJAX_PREFIX . 'avans_get_result_spin_wheel','avans_get_result_spin_wheel_callback');


function avans_get_tickets_for_lottery_callback(){

    if(!wp_verify_nonce($_POST['nonce'] , 'avans_get_lottery_ticket_' . (int)$_POST['lottery_id'])){
        wp_send_json(['erorr' => 'nonce code is not valid'],403);
    }


    if (!isset($_POST['count']) || !isset($_POST['lottery_id'])) {
        wp_send_json(['erorr' => 'The parameters is not set or is set incorrectly!'],404);
    }
    $result = user::get_lottery_tickets($_POST['lottery_id'],$_POST['count'],get_current_user_id());
    
    
    wp_send_json(['success' => $result->success,'message'=>$result->message]);
    
}
add_action(AVANS_AJAX_PREFIX . 'avans_get_tickets_for_lottery','avans_get_tickets_for_lottery_callback');


function avans_check_complete_user_info_callback()
{

    $errors = [
        'fields' => [],
        'avatar' => [],
    ];
    // $settings = AVANS_SETTINGS['panel_settings']['user_complete'];
    $user_id = get_current_user_id();

    unset($_POST['action']);

    $fields = AVANS_SETTINGS['panel_settings']['complete_profile_fields'] ?? [];

    $avatar_field = array_filter($fields , function($item){
        return $item['type'] == 'avatar';
    });
    $avatar_field = array_merge($avatar_field , []);

    foreach($_POST as $index => $value){
        if( is_numeric($index) ){
            $result = completeProfile::validate_data($value , $fields[$index] );
            if(is_wp_error($result)){
                $errors['fields'][$index] = $result->get_error_message();
            }
        }
    }

    if( isset($avatar_field[0]) && !completeProfile::get_avans_avatar_url($user_id) && !isset($_FILES['avatar']) ){
        $errors['avatar'][]  = 'تصویر پروفایل تعیین نشده است!';
    }

    if (count($errors['fields']) > 0 || count($errors['avatar']) > 0) {
        wp_send_json([
            'success' => false,
            'error' => $errors,
        ]);
    }

    if(isset($_FILES['avatar'])){
        if(!empty($_FILES['avatar']['tmp_name'])){
            $upload = completeProfile::update_avatar($user_id, $_FILES['avatar']);
            if (!$upload) {
                $errors['avatar'][]  = 'خطا سرور در بارگزاری تصویر کاربری!';
            }
        }else{
            $errors['avatar'][]  = 'خطا در بارگزاری تصویر کاربری!';
        }
    }
    

    if (count($errors['fields']) > 0 || count($errors['avatar']) > 0) {
        wp_send_json([
            'success' => false,
            'error' => $errors,
        ]);
    }

    $status = completeProfile::set_user_info($user_id , $_POST);
    $score = completeProfile::check_for_apply_score($user_id);


    if ((int)$score > 0) {
        $settings = AVANS_SETTINGS['score_settings']['complete-profile'];
        $unit = func::get_score_label();
        $text = "شما بابت تکمیل و تایید اطلاعات حساب کاربریتان $score $unit گرفتید" ;
        if (!empty($settings['text'])) {
            $text  = str_replace("{score}", $score, $settings['text']);
        }
    }



    wp_send_json([
        'success' => is_object($status) ? true : $status,
        'data' => $status,
        'error' => $errors,
        'score' => $score,
        'text' => isset($text) ? $text : "",
    ]);
}
add_action(AVANS_AJAX_PREFIX . 'avans_check_complete_user_info', 'avans_check_complete_user_info_callback');


function avans_confirm_data_type_user_info_callback(){
    $type = $_POST['type'];
    $code = $_POST['value'];
    $user_id = get_current_user_id();
    $option = [
        'plugin_uri' => AVANS_URI,
    ];


    $valid_type = ['mobile','email'];

    if(!func::is_set($type) || !in_array($type,$valid_type) || !func::is_set($code) || completeProfile::is_validation($user_id,$type)){
        return;
    }

    $status = completeProfile::is_valid_user_code_inserted($user_id,$type,$code);

    $score = completeProfile::check_for_apply_score($user_id);

    if ((int)$score > 0) {
        $settings = AVANS_SETTINGS['score_settings']['complete-profile'];
        $unit = func::get_score_label();
        $text = "شما بابت تکمیل و تایید اطلاعات حساب کاربریتان $score $unit گرفتید" ;
        if (!empty($settings['text'])) {
            $text  = str_replace("{score}", $score, $settings['text']);
        }
    }

    wp_send_json([
        'success' => $status,
        'score' => $score,
        'text' => $text
     ]);

}
add_action(AVANS_AJAX_PREFIX . 'avans_confirm_data_type_user_info', 'avans_confirm_data_type_user_info_callback');



function avans_resend_code_validation_callback(){
    $type = $_POST['type'];
    $user_id = get_current_user_id();

    if(!func::is_set($type)){
        return;
    }

    if(completeProfile::is_validation($user_id,$type)){
        return;
    }

    $status = completeProfile::resend_verification_code($user_id,$type);
    
    wp_send_json([
        'success' => $status,
    ]);

}
add_action(AVANS_AJAX_PREFIX . 'avans_resend_code_validation','avans_resend_code_validation_callback');



function avans_check_voucher_code_callback(){

    if( !isset($_POST['code']) || !wp_verify_nonce( $_POST['nonce'] , "avans_voucher_check_"  .  (int)$_POST['form_id'] ) ){
        wp_send_json_error( 'form_id or code param is not set' , 400 );
    }

    if(!is_user_logged_in()){
       wp_send_json([
            'success' => false,
            'message' => "برای ثبت کد باید ابتدا وارد شوید!",
            'code' =>  1009,
        ]);
    }

    $form_id = (int)sanitize_text_field($_POST['form_id']);    
    $code = sanitize_text_field($_POST['code']);

    $result = voucher::check_voucher_code($form_id , $code);

    if(is_wp_error($result)){
        wp_send_json([
            'success' => false,
            'message' => urldecode($result->get_error_message()),
            'code' =>  $result->get_error_code(),
        ]);
    }

    wp_send_json($result);

}
add_action(AVANS_AJAX_PREFIX . "avans_check_voucher_code" , "avans_check_voucher_code_callback");



function avans_load_all_commision_tab_callback(){
    include AVANS_PATH.'/templates/front/panel/content/sections/referer-commision-logs.php';
    die();
}
add_action(AVANS_AJAX_PREFIX . "avans_load_all_commision_tab","avans_load_all_commision_tab_callback");

function avans_load_all_referer_user_tab_callback(){
    include AVANS_PATH.'/templates/front/panel/content/sections/referer-users-logs.php';
    die();
}
add_action(AVANS_AJAX_PREFIX . "avans_load_all_referer_user_tab","avans_load_all_referer_user_tab_callback");



function avans_save_shipping_info_callback(){
    $data = $_POST['info'];
    $order_id = $_POST['order_id'];
    $errors = false;
    if(!func::is_set($data['name']) || strlen($data['name']) > 300){
       $errors = true; 
    }

    if(!func::is_set($data['lastname']) || strlen($data['lastname']) > 300){
       $errors = true; 
    }

    if(!func::is_set($data['state']) || strlen($data['state']) > 300){
       $errors = true; 
    }

    if(!func::is_set($data['city']) || strlen($data['city']) > 300){
       $errors = true; 
    }

    if(!func::is_set($data['address']) || strlen($data['address']) > 300){
       $errors = true; 
    }

    if(!func::is_set($data['zipcode']) || strlen(func::toEnNumber($data['zipcode'])) != 10){
       $errors = true; 
    }

    if(!func::is_set($data['mobile']) || strlen(func::toEnNumber($data['mobile'])) != 11){
       $errors = true; 
    }

    if($errors){
        wp_send_json([
            'success' => false,
        ]);
    }

    $order = wc_get_order( $order_id );

    // update_post_meta( $order_id, '_billing_first_name', sanitize_text_field($data['name'])  );
    // update_post_meta( $order_id, '_billing_last_name', sanitize_text_field($data['lastname'])  );
    // update_post_meta( $order_id, '_billing_state', sanitize_text_field($data['state'])  );
    // update_post_meta( $order_id, '_billing_city', sanitize_text_field($data['city'])  );
    // update_post_meta( $order_id, '_billing_address_1', sanitize_text_field($data['address'])  );
    // update_post_meta( $order_id, '_billing_postcode', sanitize_text_field($data['zipcode'])  );
    // update_post_meta( $order_id, '_billing_phone', sanitize_text_field($data['mobile'])  );
    // update_post_meta( $order_id ,'_billing_country','IR');
    
    
    $order->set_billing_first_name(sanitize_text_field($data['name']));
    $order->set_billing_last_name(sanitize_text_field($data['lastname']));
    $order->set_billing_state(sanitize_text_field($data['state']));
    $order->set_billing_city(sanitize_text_field($data['city']));
    $order->set_billing_address_1(sanitize_text_field($data['address']));
    $order->set_billing_postcode(sanitize_text_field($data['zipcode']));
    $order->set_billing_phone(sanitize_text_field($data['mobile']));
    $order->set_billing_country('IR');

    $order->save();


    wp_send_json([
        'success' => true,
        'state' => WC()->countries->get_states( 'IR' )[sanitize_text_field($data['state'])],
    ]);
}
add_action(AVANS_AJAX_PREFIX . "avans_save_shipping_info","avans_save_shipping_info_callback");

Youez - 2016 - github.com/yon3zu
LinuXploit