Beispiel #1
0
//Send a HTTP header to disable content type sniffing in browsers which support it.
//Disable caching
header('Cache-Control: no-cache');
header('Pragma: no-cache');
$action = esc_attr($_POST['action']);
//A bit of security
$allowed_actions = array('like', 'unlike', 'click', 'view', 'report');
if (in_array($action, $allowed_actions)) {
    // if(is_user_logged_in())
    $ip_exist = true;
    if (in_array(fun_get_real_ip(), get_post_meta((int) $_POST['id'], 'like_ip', false))) {
        $ip_exist = false;
    }
    if ($action == 'like' && $ip_exist) {
        do_action('like_me', (int) $_POST['id'], fun_get_real_ip());
    }
    if ($action == 'unlike' && $ip_exist) {
        do_action('unlike_me', (int) $_POST['id'], fun_get_real_ip());
    }
    if ($action == 'click') {
        do_action('click_point', (int) $_POST['id'], fun_get_real_ip());
    }
    if ($action == 'view') {
        do_action('view_point', (int) $_POST['id'], fun_get_real_ip());
    }
    if ($action == 'report') {
        do_action('report_issue', (int) $_POST['id'], htmlspecialchars(addslashes($_POST['ras'])) . "|" . fun_get_real_ip());
    }
} else {
    die('-1');
}
Beispiel #2
0
function coupon_meta_inner()
{
    global $post;
    $post_author = get_post_meta($post->ID, 'post_author_override', true);
    $coupon_type = get_post_meta($post->ID, 'coupon_type', true);
    $attachment_image = wp_get_attachment_image_src(get_post_meta($post->ID, 'print_imageid', true));
    ?>
	<script type="text/javascript">	
	//<![CDATA[
	jQuery(document).ready(function() {
	  var formfield;
		// upload printable coupon image
		jQuery('input#upload_image_button').click(function() {
		  formfield = jQuery(this).attr('rel');
			if(wp.media){
				//e.preventDefault();
				// Set options for 1st frame render
				var options = {
					state: 'insert',
					frame: 'post'
				};
	
				frame = wp.media(options).open();
				
				// Tweak views
				frame.menu.get('view').unset('gallery');
				frame.menu.get('view').unset('featured-image');
										
				frame.toolbar.get('view').set({
					insert: {
						style: 'primary',
						text: '<?php 
    _e("Insert", "junkie");
    ?>
',
	
						click: function() {
							var models = frame.state().get('selection'),
								imageID = models.first().attributes.id,
								url = models.first().attributes.url;
								//alert( var_dump(models));
								imgoutput = '<a href="' + url + '" target="_blank"><img width="100px" src="' + url + '" /></a>'; 
								jQuery('#print_url').val(url); // return the image url to the field
								jQuery('input[name=print_imageid]').val(imageID); // return the image url to the field			
								jQuery('#print_url').siblings('.upload_image_preview').slideDown().html(imgoutput); // display the uploaded image thumbnail
							frame.close();
						}
					}
				});
			
			}else{
				
				alert('plz ,update you wordpress to v3.1+ .');
						
			}

			return false;
		});		
		// show the coupon code or upload coupon field based on type select box
		jQuery('select#coupon_meta_dropdown').change(function() {	
			var coupon_type=jQuery(this).find("option:selected").text();
			if (coupon_type == 'Coupon Code') {
				jQuery('tr#ctype-coupon-code').fadeIn('fast');
				jQuery('tr#ctype-printable-coupon').hide();
			} else if (coupon_type == 'Printable Coupon') {
				jQuery('tr#ctype-printable-coupon').fadeIn('fast');
				jQuery('tr#ctype-coupon-code').hide();
			} else if (coupon_type == 'Credit Card') {
				jQuery('tr#ctype-coupon-code').fadeIn('fast');
				jQuery('tr#ctype-printable-coupon').hide();	
			} else {
				jQuery('tr.ctype').hide();
				jQuery('tr.ctype input').removeClass('required invalid');
			}		
		}).change();
		
		jQuery( "#expire_date" ).datepicker({ dateFormat: "yy-mm-dd" });
		
		<?php 
    if ($coupon_type == 'Coupon Code') {
        echo "jQuery('tr#ctype-printable-coupon').hide();jQuery('tr#ctype-coupon-code').show();";
    }
    if ($coupon_type == 'Printable Coupon') {
        echo "jQuery('tr#ctype-printable-coupon').show();jQuery('tr#ctype-coupon-code').hide();";
    }
    if ($coupon_type == 'Promotion') {
        echo "jQuery('tr#ctype-printable-coupon').hide();jQuery('tr#ctype-coupon-code').hide();";
    }
    if ($post_author) {
        echo 'jQuery("#post_author_override option[value=\'' . $post_author . '\']").attr("selected","selected");';
    }
    echo 'jQuery("#coupon_meta_dropdown option[value=\'' . $coupon_type . '\']").attr("selected","selected");';
    ?>
	});	
	//]]>
	</script>
<table class="form-table coupon-meta-table">
		
			<tbody><tr>
				<th style="width:20%"><label for="cp_sys_ad_conf_id">Coupon Info:</label></th>
				<td class="coupon-conf">
					<span>Coupon ID: <font color="#0099CC"><strong><?php 
    echo get_post_meta($post->ID, 'coupon_id', true);
    ?>
</strong></font> &nbsp;&nbsp;</span>
					<span>
                    Views:  <strong>
						<?php 
    $view_point = get_post_meta($post->ID, 'view_point', true);
    if ($view_point == '') {
        $view_point = 0;
    }
    echo $view_point;
    ?>
                        </strong>
					</span> | 
				
					<span>
						Clicks: <strong>
                        <?php 
    $click_point = get_post_meta($post->ID, 'click_point', true);
    if ($click_point == '') {
        $click_point = 0;
    }
    echo $click_point;
    ?>
                        </strong> |
						CTR: <strong>
                        <?php 
    if ($view_point == '') {
        echo '0';
    } else {
        echo round($click_point / $view_point * 100, 2) . "%";
    }
    ?>
                        </strong>
					</span>
				</td>
			</tr>
			<tr>
				<th style="width:20%"><label>Submitted By:</label></th>
				<td >
                <select id="post_author_override" name="post_author_override">
                <?php 
    $args = array('blog_id' => $GLOBALS['blog_id']);
    $blogusers = get_users($args);
    foreach ($blogusers as $user) {
        echo '<option value="' . $user->ID . '">' . $user->display_name . '</li>';
    }
    ?>
                </select>
                
				</td>
			</tr>			
			<tr>
				<th style="width:20%"><label>Coupon Type:</label></th>
				<td>
                <?php 
    $coupon_type = get_terms('coupon_type', 'orderby=count&hide_empty=0');
    //var_dump($coupon_type);
    ?>
				<select id="coupon_meta_dropdown" name="coupon_type" >
                <?php 
    foreach ($coupon_type as $term) {
        echo "<option value='" . $term->name . "' >" . $term->name . "</option>";
    }
    ?>
				</select></td>
			</tr>
			
			<tr class="ctype" id="ctype-coupon-code">
				<th style="width:20%"><label>Coupon Code:</label></th>
				<td><input type="text" value="<?php 
    echo get_post_meta($post->ID, 'coupon_code', true);
    ?>
" class="text required" name="coupon_code"></td>
			</tr>
			
			<tr class="ctype" id="ctype-printable-coupon" style="display: none;">
				<th style="width:20%"><label>Printable Coupon URL:</label></th>
				<td>
					<input type="text" value="<?php 
    echo trim($attachment_image[0]);
    ?>
" class="upload_image_url text" id="print_url" name="print_url" readonly="">
					<input type="button" value="Add Image" rel="print_url" class="upload_button button" id="upload_image_button">							
					<div class="upload_image_preview">
					<?php 
    if (is_array($attachment_image)) {
        echo "<img src='{$attachment_image['0']}' width='100px' />";
    }
    ?>
                    </div>
					<input type="hidden" value="<?php 
    echo get_post_meta($post->ID, 'print_imageid', true);
    ?>
" name="print_imageid" id="imageid" class="hide">
				</td>
			</tr>
			
			<tr>
				<th style="width:20%"><label>Destination URL:</label></th>
				<td><input type="text" value="<?php 
    echo get_post_meta($post->ID, 'coupon_aff_url', true);
    ?>
" class="text" name="coupon_aff_url"></td>
			</tr>
			
			<tr>
				<th style="width:20%"><label>Display URL:</label></th>
				<td><a target="_blank"  href="<?php 
    echo get_permalink($post->ID);
    ?>
"><?php 
    echo get_permalink($post->ID);
    ?>
</a></td>
			</tr>
			
			<tr>
				<th style="width:20%"><label>Expiration Date:</label></th>
				<td><input type="text" value="<?php 
    echo get_post_meta($post->ID, 'expire_date', true);
    ?>
"  name="expire_date" id="expire_date"></td>
			</tr>
			
			<tr>
				<th style="width:20%"><label for="coupon_featured">Featured Coupon:</label></th>
				<td>
            <?php 
    $coupon_featured = get_post_meta($post->ID, 'coupon_featured', true) ? 'checked="checked"' : '';
    ?>
    
			<span class="checkbox-wrap"><input type="checkbox" <?php 
    echo $coupon_featured;
    ?>
 class="checkbox"  value="1" name="coupon_featured"> Show this coupon in the home page slider</span></td>
			</tr>
			
			<tr>
				<th style="width:20%"><label>Submitted from IP:<?php 
    echo get_post_meta($post->ID, 'coupon_ip', true);
    ?>
</label></th>
				<td><?php 
    echo fun_get_real_ip();
    ?>
</td>
			</tr>
			
		</tbody></table>
<?php 
}