Пример #1
0
 public static function set_captcha_session($code = '')
 {
     if (empty($code)) {
         $code = random(1000, 9999);
     }
     $expire = strtotime('+30 seconds', strtotime(SB_Core::get_current_datetime()));
     $captcha = array('code' => $code, 'expire' => $expire);
     $_SESSION['sb_captcha'] = json_encode($captcha);
 }
Пример #2
0
    public static function select_birthday($args = array())
    {
        $lang = isset($args['language']) ? $args['language'] : 'en';
        $birthday = isset($args['value']) ? $args['value'] : strtotime(SB_Core::get_current_datetime());
        $birth_day = intval(date('d', $birthday));
        $birth_month = intval(date('m', $birthday));
        $birth_year = intval(date('Y', $birthday));
        $year_max = intval(date('Y')) - 13;
        $year_min = $year_max - 150;
        ?>
        <?php 
        if ('vi' == $lang) {
            ?>
            <select class="user-birth-day" name="user_birth_day" autocomplete="off">
                <?php 
            for ($i = 1; $i <= 31; $i++) {
                ?>
                    <option value="<?php 
                echo $i;
                ?>
" <?php 
                selected($birth_day, $i);
                ?>
><?php 
                printf('%02s', $i);
                ?>
</option>
                <?php 
            }
            ?>
            </select>
            <span class="sep">/</span>
            <select class="user-birth-month" name="user_birth_month" autocomplete="off">
                <?php 
            for ($i = 1; $i <= 12; $i++) {
                ?>
                    <option value="<?php 
                echo $i;
                ?>
" <?php 
                selected($birth_month, $i);
                ?>
><?php 
                printf('%02s', $i);
                ?>
</option>
                <?php 
            }
            ?>
            </select>
            <span class="sep">/</span>
            <select class="user-birth-year" name="user_birth_year" autocomplete="off">
                <?php 
            for ($i = $year_max; $i >= $year_min; $i--) {
                ?>
                    <option value="<?php 
                echo $i;
                ?>
" <?php 
                selected($birth_year, $i);
                ?>
><?php 
                echo $i;
                ?>
</option>
                <?php 
            }
            ?>
                <?php 
            if ($birth_year < $year_min || $birth_year > $year_max) {
                ?>
                    <option value="<?php 
                echo $birth_year;
                ?>
" selected><?php 
                echo $birth_year;
                ?>
</option>
                <?php 
            }
            ?>
            </select>
        <?php 
        } else {
            ?>
            <select class="user-birth-year" name="user_birth_year" autocomplete="off">
                <?php 
            for ($i = $year_max; $i >= $year_min; $i--) {
                ?>
                    <option value="<?php 
                echo $i;
                ?>
" <?php 
                selected($birth_year, $i);
                ?>
><?php 
                echo $i;
                ?>
</option>
                <?php 
            }
            ?>
                <?php 
            if ($birth_year < $year_min || $birth_year > $year_max) {
                ?>
                    <option value="<?php 
                echo $birth_year;
                ?>
" selected><?php 
                echo $birth_year;
                ?>
</option>
                <?php 
            }
            ?>
            </select>
            <span class="sep">/</span>
            <select class="user-birth-month" name="user_birth_month" autocomplete="off">
                <?php 
            for ($i = 1; $i <= 12; $i++) {
                ?>
                    <option value="<?php 
                echo $i;
                ?>
" <?php 
                selected($birth_month, $i);
                ?>
><?php 
                printf('%02s', $i);
                ?>
</option>
                <?php 
            }
            ?>
            </select>
            <span class="sep">/</span>
            <select class="user-birth-day" name="user_birth_day" autocomplete="off">
                <?php 
            for ($i = 1; $i <= 31; $i++) {
                ?>
                    <option value="<?php 
                echo $i;
                ?>
" <?php 
                selected($birth_day, $i);
                ?>
><?php 
                printf('%02s', $i);
                ?>
</option>
                <?php 
            }
            ?>
            </select>
        <?php 
        }
        ?>
        <?php 
    }
Пример #3
0
function sb_core_captcha_reload_ajax_callback()
{
    $len = isset($_POST['len']) ? $_POST['len'] : 4;
    $code = SB_PHP::random_string_number($len);
    SB_Core::set_captcha_session($code);
    $url = SB_Core::get_captcha_url();
    $url = add_query_arg(array('code' => strtotime(SB_Core::get_current_datetime())), $url);
    echo $url;
    die;
}
Пример #4
0
 public static function get_birthday_timestamp($user_id)
 {
     $birthday = SB_User::get_meta($user_id, 'birthday');
     if (empty($birthday)) {
         $birthday = SB_Core::get_current_datetime();
         $birthday = strtotime($birthday);
     }
     return $birthday;
 }
Пример #5
0
 public static function select_birthday($args = array())
 {
     $lang = isset($args['language']) ? $args['language'] : 'en';
     $birthday = isset($args['value']) ? $args['value'] : strtotime(SB_Core::get_current_datetime());
     $birth_day = intval(date('d', $birthday));
     $birth_month = intval(date('m', $birthday));
     $birth_year = intval(date('Y', $birthday));
     $sep = isset($args['sep']) ? $args['sep'] : '<span class="sep">/</span>';
     $year_max = intval(date('Y')) - 13;
     $year_min = $year_max - 150;
     $all_option_day = '<option value="0">' . __('Choose day', 'sb-core') . '</option>';
     for ($i = 1; $i <= 31; $i++) {
         $all_option_day .= self::get_option(array('text' => sprintf('%02d', $i), 'value' => $i, 'selected' => $birth_day));
     }
     $all_option_month = '<option value="0">' . __('Choose month', 'sb-core') . '</option>';
     for ($i = 1; $i <= 12; $i++) {
         $all_option_month .= self::get_option(array('text' => sprintf('%02d', $i), 'value' => $i, 'selected' => $birth_month));
     }
     $all_option_year = '<option value="0">' . __('Choose year', 'sb-core') . '</option>';
     for ($i = $year_max; $i >= $year_min; $i--) {
         $all_option_year .= self::get_option(array('text' => sprintf('%02d', $i), 'value' => $i, 'selected' => $birth_year));
     }
     if ($birth_year < $year_min || $birth_year > $year_max) {
         $all_option_year .= self::get_option(array('text' => $birth_year, 'value' => $birth_year, 'selected' => $birth_year));
     }
     $args['before'] = '';
     if ('vi' == $lang) {
         $args['all_option'] = $all_option_day;
         self::select($args);
         echo $sep;
         $args['all_option'] = $all_option_month;
         self::select($args);
         echo $sep;
         $args['all_option'] = $all_option_year;
         self::select($args);
     } else {
         $args['all_option'] = $all_option_year;
         self::select($args);
         echo $sep;
         $args['all_option'] = $all_option_month;
         self::select($args);
         echo $sep;
         $args['all_option'] = $all_option_day;
         self::select($args);
     }
 }