= \''.$this_adv_date.'\' ) ) AND advertising_main.adv_id=\''.$id.'\' ORDER BY advertising_day.adv_id ASC '; $res = mysql_query($sql); $num = @mysql_num_rows($res); if($num) { $row = mysql_fetch_assoc($res); $alocated_coin = $row['coin_alocated']; $q = 'SELECT COUNT(*) as count FROM advertising_click WHERE date=\''.$this_adv_date.'\' AND adv_id=\''.$row['adv_id'].'\' '; $r = mysql_query($q); $n = @mysql_num_rows($r); if($n) { $o = mysql_fetch_assoc($r); $click_count = $o['count']; } else { $click_count = 0; } synch_coin_member($row['membershipid']); $q = 'SELECT coin_member FROM adm_membership WHERE membershipid=\''.$row['membershipid'].'\' '; $r = mysql_query($q); $n = @mysql_num_rows($r); if($n) { $o = mysql_fetch_assoc($r); $free_coin = $o['coin_member']; } else { $free_coin = 0; } if( $alocated_coin > $click_count && $free_coin > 0 ) { //$sql = 'INSERT INTO coin_purchased SET membershipid=\''.$row['membershipid'].'\', coin=\'1\', description=\'Biaya klik iklan #ID: '.$id.' : '.$row['adv_url'].'\', reffid=\'0\' '; //@mysql_query($sql); use_poin($row['membershipid'], 1, 'Biaya klik iklan #ID: '.$id.' : '.$row['adv_url'].'', 0); $sql = 'INSERT INTO advertising_click SET adv_id=\''.$id.'\', date=\''.$this_adv_date.'\', time=\''.date('H:i:s').'\', ip=\''.$user_ip.'\' '; @mysql_query($sql); $row['adv_url'] = str_replace('http://', '' , $row['adv_url']); header('location: http://'.$row['adv_url'].''); } } } ?>