Exemplo n.º 1
0
            }
            ?>
">
									<td><?php 
            echo $arr['url'];
            ?>
</td>
									<td>
										<?php 
            if ($arr['target_users']) {
                $levels = explode(',', $arr['target_users']);
                if ($levels && count($levels)) {
                    foreach ($levels as $val) {
                        echo '<div class="level-type-list">';
                        if ($val != 'reg' && $val != 'unreg' && $val != 'all') {
                            $temp_data = ihc_get_level_by_id($val);
                            echo $temp_data['name'], '<br/>';
                        } else {
                            echo $val;
                        }
                        echo '</div>';
                    }
                }
            }
            ?>
									</td>
									<td style="color: #21759b; font-weight:bold;">
										<?php 
            if ($arr['redirect'] != -1) {
                echo get_the_title($arr['redirect']);
            } else {
Exemplo n.º 2
0
                            if (isset($time_arr['expire_time'])) {
                                $is_expired_class = $current_time > strtotime($time_arr['expire_time']) ? 'ihc-expired-level' : '';
                            }
                            ?>
			    						   									<div class="level-type-list <?php 
                            echo $is_expired_class;
                            ?>
"><?php 
                            echo $temp_data['name'];
                            ?>
</div>
			    						   									<?php 
                        }
                    }
                } else {
                    $temp_data = ihc_get_level_by_id($user_levels);
                    $time_arr = ihc_get_start_expire_date_for_user_level($user->data->ID, $user_levels);
                    $is_expired_class = '';
                    if (isset($time_arr['expire_time'])) {
                        $is_expired_class = $current_time > strtotime($time_arr['expire_time']) ? 'ihc-expired-level' : '';
                    }
                    echo '<div class="level-type-list ' . $is_expired_class . '">' . $temp_data['name'] . '</div>';
                }
            }
            ?>
			    						   			</td>
			    						   			<td>
			    						   				<div id="user-<?php 
            echo $user->data->ID;
            ?>
-status">
Exemplo n.º 3
0
     //Log the entire HTTP response if debug is switched on.
     if ($debug) {
         error_log(date('[Y-m-d H:i e] ') . "HTTP request of validation request:" . curl_getinfo($ch, CURLINFO_HEADER_OUT) . " for IPN payload: {$req}" . PHP_EOL, 3, $log_file);
         error_log(date('[Y-m-d H:i e] ') . "HTTP response of validation request: {$res}" . PHP_EOL, 3, $log_file);
     }
     curl_close($ch);
 }
 // Inspect IPN validation result and act accordingly
 // Split response headers and payload, a better way for strcmp
 $tokens = explode("\r\n\r\n", trim($res));
 $res = trim(end($tokens));
 if (strcmp($res, "VERIFIED") == 0) {
     if (isset($_POST['custom'])) {
         $data = stripslashes($_POST['custom']);
         $data = json_decode($data, true);
         $level_data = ihc_get_level_by_id($data['level_id']);
         //getting details about current level
     }
     if (isset($_POST['payment_status'])) {
         switch ($_POST['payment_status']) {
             case 'Processed':
             case 'Completed':
                 //payment made, put the right expire time
                 $approved = TRUE;
                 if (get_option('ihc_paypal_email') != $_POST['receiver_email']) {
                     $approved = FALSE;
                 }
                 if ($_POST['mc_gross'] != $level_data['price']) {
                     $approved = FALSE;
                 }
                 if ($_POST['mc_currency'] != get_option('ihc_currency')) {
        private function handle_levels_assign($request_levels)
        {
            /*  
             * insert into db when user was start using this level, 
             * if it's free level will assign the expire date, 
             * if not paypal ipn will set the expire time
             * @param string with all level ids separated by comma
             * @return none
             */
            if ($request_levels != -1 && $request_levels !== FALSE) {
                $current_levels = explode(',', $request_levels);
                if (count($current_levels)) {
                    $old_levels = get_user_meta($this->user_id, 'ihc_user_levels', true);
                    foreach ($current_levels as $lid) {
                        if (strpos($old_levels, $lid) === FALSE) {
                            //we got a new level to assign
                            $level_data = ihc_get_level_by_id($lid);
                            //getting details about current level
                            $current_time = time();
                            if (empty($level_data['access_type'])) {
                                $level_data['access_type'] = 'unlimited';
                            }
                            //set start time
                            if ($level_data['access_type'] == 'date_interval' && !empty($level_data['access_interval_start'])) {
                                $start_time = $level_data['access_interval_start'];
                            } else {
                                $start_time = $current_time;
                            }
                            //set end time
                            if ($this->is_public && $level_data['payment_type'] != 'free') {
                                //end time will be expired, updated when payment
                                $end_time = '0000-00-00 00:00:00';
                            } else {
                                //it's admin or free so we set the correct expire time
                                switch ($level_data['access_type']) {
                                    case 'unlimited':
                                        $end_time = strtotime('+10 years', $current_time);
                                        //unlimited will be ten years
                                        break;
                                    case 'limited':
                                        if (!empty($level_data['access_limited_time_type']) && !empty($level_data['access_limited_time_value'])) {
                                            $multiply = ihc_get_multiply_time_value($level_data['access_limited_time_type']);
                                            $end_time = $current_time + $multiply * $level_data['access_limited_time_value'];
                                        }
                                        break;
                                    case 'date_interval':
                                        if (!empty($level_data['access_interval_end'])) {
                                            $end_time = $level_data['access_interval_end'];
                                        }
                                        break;
                                    case 'regular_period':
                                        if (!empty($level_data['access_regular_time_type']) && !empty($level_data['access_regular_time_value'])) {
                                            $multiply = ihc_get_multiply_time_value($level_data['access_regular_time_type']);
                                            $end_time = $current_time + $multiply * $level_data['access_regular_time_value'];
                                        }
                                        break;
                                }
                                $end_time = date('Y-m-d H:i:s', $end_time);
                            }
                            $update_time = date('Y-m-d H:i:s', $current_time);
                            $start_time = date('Y-m-d H:i:s', $start_time);
                            global $wpdb;
                            $table = $wpdb->prefix . 'ihc_user_levels';
                            $exists = $wpdb->get_row('SELECT * FROM ' . $table . ' WHERE user_id="' . $this->user_id . '" AND level_id="' . $lid . '";');
                            if (!empty($exists)) {
                                $wpdb->query('DELETE FROM ' . $table . ' WHERE user_id="' . $this->user_id . '" AND level_id="' . $lid . '";');
                                //assure that pair user_id - level_id entry is not exists
                            }
                            $wpdb->query('INSERT INTO ' . $table . '
												VALUES(null, "' . $this->user_id . '", "' . $lid . '", "' . $start_time . '", "' . $update_time . '", "' . $end_time . '", 1);');
                        }
                    }
                }
            }
        }