Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query = 'select
- id, user_id, campaign_id, image, text, price,
- case
- when teaserstat.view <=> null then 0
- when teaserstat.view >= 0 and teaserstat.view <= 5000 and teaserstat.click = 0 then 1
- when teaserstat.click > 0 then 2
- when teaserstat.view > 5000 then 2
- end as firstord,
- case
- when teaserstat.view is not null and teaserstat.click = 0 then (0.01 * price)
- when teaserstat.view is not null then ((teaserstat.ctr * teaserstat.ctr) * price)
- end as secondord
- from '.$var['base_tab_prefix'].'teasers left join (
- select teaser_id, view, click, ((100/view)*click) as ctr
- from adtram_teasers_stat
- where dataadd = "'.$var['date'].'"
- ) as teaserstat
- on adtram_teasers.id = teaserstat.teaser_id
- where status="2"
- and ban_site not like "%'.$referer_url.'%"
- '.($site[0]['ban_teaser'] != '' ? 'and id not in ('.$site[0]['ban_teaser'].')' : '').'
- '.($good_users_ids != '' ? 'and user_id in ('.$good_users_ids.')' : 'and user_id = "bla-bla"').'
- '.($ban_sections_ids ? 'and section_id not in ('.$ban_sections_ids.')' : '').'
- '.($ipgeobase['region'] != '' ? 'and ban_region not like "%~'.$ipgeobase['region'].'~%"' : '').'
- '.($ipgeobase['country'] != '' ? 'and ban_country not like "%~'.$ipgeobase['country'].'~%"' : '').'
- and ban_hour not like "%~'.date("G", strtotime($var['datetime'])).'~%"
- and ban_week_day not like "%~'.date("w", strtotime($var['datetime'])).'~%"
- and url not like "%'.$referer_url.'%"
- order by firstord asc, secondord desc, last_show asc
- limit '.$mlimit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement