Ejemplo n.º 1
0
function ihc_save_level()
{
    if (isset($_REQUEST['ihc_save_level'])) {
        if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
            $option_name = 'ihc_levels';
            $data = get_option($option_name);
            $arr = array('name' => '', 'payment_type' => '', 'price' => '', 'label' => '', 'description' => '', 'price_text' => '', 'order' => '', 'access_type' => 'unlimited', 'access_limited_time_type' => 'D', 'access_limited_time_value' => '', 'access_interval_start' => '', 'access_interval_end' => '', 'access_regular_time_type' => 'D', 'access_regular_time_value' => '', 'billing_type' => '', 'billing_limit_num' => '2');
            foreach ($arr as $k => $v) {
                if (isset($_REQUEST[$k])) {
                    $arr[$k] = $_REQUEST[$k];
                }
            }
            //if it's not regular period type of level ... force billing_type to be bl_onetime
            if (isset($arr['access_type']) && $arr['access_type'] != 'regular_period') {
                $arr['billing_type'] = 'bl_onetime';
            }
            if ($data !== FALSE) {
                if (isset($_REQUEST['level_id']) && $_REQUEST['level_id'] != '') {
                    //update level
                    $id = $_REQUEST['level_id'];
                } else {
                    end($data);
                    $id = key($data);
                    $id++;
                }
                $check = ihc_array_value_exists($data, $_REQUEST['name'], 'name');
                if ($check && $check != $id) {
                    return;
                }
                $data[$id] = $arr;
                update_option($option_name, $data);
            } else {
                //create the first level
                $data[] = $arr;
                add_option($option_name, $data);
            }
        }
    }
}
 private function check_captcha()
 {
     if ($this->type == 'create' && $this->captcha) {
         //check if capcha key is set
         $captcha_key = get_option('ihc_recaptcha_public');
         if (!$captcha_key) {
             $captcha = ihc_array_value_exists($this->register_fields, 'recaptcha', 'name');
             unset($this->register_fields[$captcha]);
             return;
         }
         $captcha = ihc_array_value_exists($this->register_fields, 'recaptcha', 'name');
         if ($captcha && $this->register_fields[$captcha]['display']) {
             $captha_err = get_option('ihc_register_err_recaptcha');
             unset($this->register_fields[$captcha]);
             if (isset($_REQUEST['g-recaptcha-response'])) {
                 $secret = get_option('ihc_recaptcha_private');
                 if ($secret) {
                     include_once IHC_PATH . 'classes/ReCaptcha/ReCaptcha.php';
                     $recaptcha = new ReCaptcha($secret);
                     $resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
                     if (!$resp->isSuccess()) {
                         $this->errors[] = $captha_err;
                     }
                 } else {
                     $this->errors[] = $captha_err;
                 }
             } else {
                 $this->errors[] = $captha_err;
             }
         }
     }
 }
Ejemplo n.º 3
0
function ihc_save_block_urls()
{
    if (isset($_REQUEST['ihc_save_block_url'])) {
        foreach (array('ihc_block_url_entire', 'ihc_block_url_word') as $val) {
            if (isset($_REQUEST[$val . '-url']) && $_REQUEST[$val . '-url']) {
                $data = get_option($val);
                if ($data) {
                    $key = ihc_array_value_exists($data, $_REQUEST[$val . '-url'], 'url');
                    if (!$key) {
                        $key = end(array_keys($data)) + 1;
                    }
                } else {
                    $key = 1;
                }
                $data[$key] = array('url' => $_REQUEST[$val . '-url'], 'redirect' => $_REQUEST[$val . '-redirect'], 'target_users' => $_REQUEST[$val . '-target_users']);
                update_option($val, $data);
            }
        }
    }
}
Ejemplo n.º 4
0
            //it's expired
            return 1;
        }
    }
    return 0;
}
function ihc_block_url($url, $current_user)
{
    if (!$current_user) {
        $current_user = ihc_get_user_type();
    }
    if ($current_user == 'admin') {
        return;
    }
    //admin can view anything
    $redirect_link = false;
    $data = get_option('ihc_block_url_entire');
    if ($data) {
        //////////////////////// BLOCK URL
        $key = ihc_array_value_exists($data, $url, 'url');
        if ($key) {
            $target_users = explode(',', $data[$key]['target_users']);
            $block = ihc_test_if_must_block('block', $current_user, $target_users);
            //test if user must be block
            if ($block) {
                if ($data[$key]['redirect'] && $data[$key]['redirect'] != -1) {
                    $redirect_link = get_permalink($data[$key]['redirect']);
                } else {
                    //redirect home
                    $redirect_link = get_home_url();
                }
            }
        }
    }
    $data = get_option('ihc_block_url_word');
    if ($data) {
        ///////////////// BLOCK IF URL CONTAINS A SPECIFIED WORD
        foreach ($data as $k => $arr) {
            if (strpos($url, $arr['url']) !== FALSE) {
                //$arr['url'] is the word we search in current url
                $target_users = explode(',', $arr['target_users']);
                $block = ihc_test_if_must_block('block', $current_user, $target_users);
                if ($block) {
                    //test if user must be block
                    if ($arr['redirect'] && $arr['redirect'] != -1) {
                        $redirect_link = get_permalink($arr['redirect']);
                    } else {
                        //redirect home
                        $redirect_link = get_home_url();
                    }
                    break;
                }
            }
        }