function webmaster_module($core) { $module = $core->get['m'] ? $core->get['m'] : null; $id = $core->post['id'] ? (int) $core->post['id'] : ($core->get['id'] ? (int) $core->get['id'] : 0); $page = $core->get['page'] > 0 ? (int) $core->get['page'] : 1; $message = $core->get['message'] ? $core->get['message'] : null; switch ($module) { case 'offers': require_once PATH_LIB . 'offers.php'; offers($core); case 'referal': $sh = 30; $st = $sh * ($page - 1); $users = $core->db->field("SELECT COUNT(*) FROM " . DB_USER . " WHERE user_ref = '" . $core->user->id . "'"); $user = $users ? $core->db->data("SELECT * FROM " . DB_USER . " WHERE user_ref = '" . $core->user->id . "' ORDER BY user_name ASC LIMIT {$st}, {$sh}") : array(); $core->mainline->add($core->lang['referal_h'], $core->url('m', 'referal')); $core->header(); $core->tpl->load('body', 'referal'); $core->tpl->vars('body', array('title' => $core->lang['referal_h'], 'text' => $core->text->lines(sprintf($core->lang['referal_t'], $core->user->id)), 'nousers' => $core->lang['referal_no'], 'name' => $core->lang['user'], 'pages' => pages($core->url('m', 'referal'), $users, $sh, $page), 'shown' => $users ? sprintf($core->lang['shown'], $st + 1, min($st + $sh, $users), $users) : '')); if (count($user)) { foreach ($user as &$i) { $core->tpl->block('body', 'user', array('name' => $i['user_name'], 'cash' => rur($i['user_got']), 'flwa' => (int) $i['user_flwa'])); } } else { $core->tpl->block('body', 'nouser'); } $core->tpl->output('body'); $core->footer(); $core->_die(); case 'lead': $where = array("wm_id = '" . $core->user->id . "'"); if (isset($core->get['d']) && $core->get['d']) { $d = date2form(form2date($core->get['d'])); $ds = strtotime($d . ' 00:00:00'); $de = strtotime($d . ' 23:59:59'); $where[] = " order_time BETWEEN '{$ds}' AND '{$de}' "; } else { $d = false; } if (isset($core->get['o']) && $core->get['o']) { $o = (int) $core->get['o']; $where[] = " offer_id = '{$o}' "; } else { $o = false; } if (isset($core->get['f']) && $core->get['f']) { $f = (int) $core->get['f']; $where[] = " flow_id = '{$f}' "; } else { $f = false; } if (isset($core->get['w']) && $core->get['w']) { $w = (int) $core->get['w']; $where[] = " site_id = '{$w}' "; } else { $w = false; } if (isset($core->get['s']) && ($s = $core->get['s'])) { switch ($s) { case 'w': $where[] = " order_webstat < 5 "; break; case 'c': $where[] = " order_webstat IN ( 5, 12 ) "; break; case 'a': $where[] = " order_webstat BETWEEN 6 AND 11 "; break; default: $s = false; } } else { $s = false; } $where = implode(' AND ', $where); $sh = 30; $st = ($page - 1) * $sh; $orders = $core->db->field("SELECT COUNT(*) FROM " . DB_ORDER . " WHERE {$where}"); $order = $orders ? $core->db->data("SELECT * FROM " . DB_ORDER . " WHERE {$where} ORDER BY order_id DESC LIMIT {$st}, {$sh}") : array(); $flow = $core->db->icol("SELECT flow_id, flow_name FROM " . DB_FLOW . " WHERE user_id = '" . $core->user->id . "' " . ($o ? " AND offer_id = '{$o}' " : '') . " ORDER BY flow_name ASC"); $offer = $core->wmsale->get('offers'); $sids = $core->db->col("SELECT DISTINCT site_id FROM " . DB_ORDER . " WHERE wm_id = '" . $core->user->id . "'"); $site = array(); foreach ($sids as $ss) { $site[$ss] = $core->wmsale->get('site', $ss, 'site_url'); } $core->mainline->add($core->lang['stats_lead']); $core->header(); $core->tpl->load('body', 'lead'); if (!defined('WORKFACE')) { $core->tpl->block('body', 'help'); } $core->tpl->vars('body', array('nostats' => $core->lang['nostats'], 'date' => $core->lang['date'], 'flow' => $core->lang['flow'], 'offer' => $core->lang['offer'], 'status' => $core->lang['status'], 'show' => $core->lang['show'], 'site' => $core->lang['site'], 'space' => $core->lang['stat_spaces'], 'calls' => $core->lang['order_calls_sh'], 'reason' => $core->lang['comment'], 'd' => $d, 'u_stat' => $core->url('m', 'stats'), 'stat' => $core->lang['stats_date'], 'pages' => pages($core->url('m', 'lead?') . ($f ? 'f=' . $f . '&' : '') . ($d ? 'd=' . $d . '&' : '') . ($s ? 's=' . $s . '&' : '') . ($o ? 'o=' . $o : '') . ($w ? 'w=' . $w : ''), $orders, $sh, $page), 'shown' => sprintf($core->lang['shown'], $st + 1, min($st + $sh, $orders), $orders))); foreach ($offer as $of => $n) { $core->tpl->block('body', 'offer', array('name' => $n, 'value' => $of, 'select' => $of == $o ? 'selected="selected"' : '')); } foreach ($flow as $fl => $n) { $core->tpl->block('body', 'flow', array('name' => $n, 'value' => $fl, 'select' => $fl == $f ? 'selected="selected"' : '')); } foreach ($site as $sl => $n) { $core->tpl->block('body', 'site', array('name' => $n, 'value' => $sl, 'select' => $sl == $w ? 'selected="selected"' : '')); } foreach ($core->lang['stat_status'] as $st => $n) { $core->tpl->block('body', 'status', array('name' => $n, 'value' => $st, 'select' => $st == $s ? 'selected="selected"' : '')); } if ($orders) { foreach ($order as $r) { $core->tpl->block('body', 'order', array('offer' => $offer[$r['offer_id']], 'site' => $core->wmsale->get('site', $r['site_id'], 'site_url'), 'space' => $core->wmsale->get('site', $r['space_id'], 'site_url'), 'flow' => $flow[$r['flow_id']], 'ip' => int2ip($r['order_ip']), 'country' => $r['order_country'] ? $r['order_country'] : 'zz', 'time' => smartdate($r['order_time']), 'stid' => $r['order_webstat'] < 6 || $r['order_webstat'] == 12 ? $r['order_webstat'] : 10, 'status' => $r['order_webstat'] < 6 || $r['order_webstat'] == 12 ? $core->lang['statuso'][$r['order_webstat']] : $core->lang['statusok'], 'calls' => $r['order_calls'], 'reason' => $r['order_reason'] ? $core->lang['reasono'][$r['order_reason']] : ($r['order_webstat'] == 5 || $r['order_webstat'] == 12 ? $r['order_comment'] ? sprintf($core->lang['noreason_comment'], $r['order_comment']) : $core->lang['noreason'] : ($r['order_check'] ? $core->lang['stat_check'] : ($r['order_webstat'] < 5 && $r['order_comment'] ? sprintf($core->lang['noreason_comment'], $r['order_comment']) : ''))), 'utm_id' => $core->lang['stat_srcsm'][$r['utm_id']], 'utm_cn' => $r['utm_cn'], 'utm_src' => $r['utm_src'])); } } else { $core->tpl->block('body', 'nostat'); } $core->tpl->output('body'); $core->footer(); $core->_die(); case 'stats': $today = date('Ymd'); $week1 = date('Ymd', strtotime('-1 week')); extract(params($core, array('to' => 'date', 'from' => 'date', 'o', 'f'))); if (!$to || $to > $today) { $to = $today; } if ($from > $to) { $from = $to; } if (!$from) { $from = $week1; } list($offer, $flow, $stats) = webmaster_clicks($core, $core->user->id, $from, $to, $f, $o); $csv = $core->get['show'] == 'csv' ? 1 : 0; $core->mainline->add($core->lang['stats_h']); if ($csv) { header('Content-type: text/csv'); header('Content-disposition: attachment;filename=stats.csv'); } else { $core->header(); } if ($csv) { $core->tpl->load('body', 'csv-stats'); } else { $core->tpl->load('body', 'stats'); } if (!defined('WORKFACE')) { $core->tpl->block('body', 'help'); } $core->tpl->vars('body', array('nostats' => $core->lang['nostats'], 'date' => $core->lang['date'], 'wait' => $core->lang['stat_wait'], 'accept' => $core->lang['stat_accept'], 'cancel' => $core->lang['stat_cancel'], 'spaces' => $core->lang['stat_spaces'], 'clicks' => $core->lang['stat_clicks'], 'unique' => $core->lang['stat_unique'], 'flow' => $core->lang['flow'], 'offer' => $core->lang['offer'], 'show' => $core->lang['show'], 'from' => date2form($from), 'to' => date2form($to), 'u_csv' => $core->url('m', 'stats?show=csv&from=') . date2form($from) . '&to=' . date2form($to) . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : ''))); foreach ($offer as $of => $n) { $core->tpl->block('body', 'offer', array('name' => $n, 'value' => $of, 'select' => $of == $o ? 'selected="selected"' : '')); } foreach ($flow as $fl => $n) { $core->tpl->block('body', 'flow', array('name' => $n, 'value' => $fl, 'select' => $fl == $f ? 'selected="selected"' : '')); } if ($stats) { foreach ($stats as $d => &$s) { $cl = max($s['unique'], $s['suni']); $core->tpl->block('body', 'stat', array('date' => date2form($d), 'cr' => $cl ? sprintf("%0.2f", $s['ca'] / $cl * 100) : 0, 'epc' => $cl ? rur($s['sa'] / $cl) : '-', 'epcr' => $cl ? sprintf("%0.2f", $s['sa'] / $cl) : '-', 'spaces' => (int) $s['spaces'], 'suni' => (int) $s['suni'], 'clicks' => (int) $s['clicks'], 'unique' => (int) $s['unique'], 'ca' => (int) $s['ca'], 'sa' => rur($s['sa']), 'sar' => (int) $s['sa'], 'ua' => $core->url('m', 'lead') . '?d=' . date2form($d) . '&s=a', 'cw' => (int) $s['cw'], 'sw' => rur($s['sw']), 'swr' => (int) $s['sw'], 'uw' => $core->url('m', 'lead') . '?d=' . date2form($d) . '&s=w', 'cc' => (int) $s['cc'], 'sc' => rur($s['sc']), 'scr' => (int) $s['sc'], 'uc' => $core->url('m', 'lead') . '?d=' . date2form($d) . '&s=c')); } unset($d, $s, $stats); } else { $core->tpl->block('body', 'nostat'); } $core->tpl->output('body', $csv ? 'windows-1251' : false); if (!$csv) { $core->footer(); } $core->_die(); case 'sources': $today = date('Ymd'); $week1 = date('Ymd', strtotime('-2 week')); extract(params($core, array('to' => 'date', 'from' => 'date', 'o', 'f', 'c', 'q', 'g', 'a', 'fi'))); if (!$to || $to > $today) { $to = $today; } if ($from > $to) { $from = $to; } if (!$from) { $from = $week1; } if (!$c) { $c = 10; } if ($core->user->level) { $core->tpl->block('body', 'alls'); $all = $a ? true : false; } else { $all = false; } list($offer, $flow, $stats) = webmaster_sources($core, $core->user->id, $from, $to, $o, $f, $g, $q, $c, $all, $fi); $gv = $g ? 'utm_src' : 'utm_cn'; $og = $g ? 0 : 1; $csv = $core->get['show'] == 'csv' ? 1 : 0; $bls = $core->db->data("SELECT * FROM " . DB_BL . " WHERE user_id = '" . $core->user->id . "'"); $bl = array(); foreach ($bls as $b) { $bl[$b['bl_type']][$b['bl_utm']][$b['bl_item']] = $b['bl_id']; } $core->mainline->add($core->lang['stats_src']); if ($csv) { header('Content-type: text/csv'); header('Content-disposition: attachment;filename=sources.csv'); } else { $core->header(); } if ($csv) { $core->tpl->load('body', 'csv-sources'); } else { $core->tpl->load('body', 'sources'); } if (!defined('WORKFACE')) { $core->tpl->block('body', 'help'); } $core->tpl->vars('body', array('nostats' => $core->lang['nostats'], 'type' => $core->lang['type'], 'today' => $core->lang['today'], 'source' => $core->lang['source'], 'showall' => $core->lang['showall'], 'all' => $all ? 'checked="checked"' : '', 'wait' => $core->lang['stat_wait'], 'accept' => $core->lang['stat_accept'], 'cancel' => $core->lang['stat_cancel'], 'spaces' => $core->lang['stat_spaces'], 'clicks' => $core->lang['stat_clicks'], 'unique' => $core->lang['stat_unique'], 'total' => $core->lang['total'], 'flow' => $core->lang['flow'], 'offer' => $core->lang['offer'], 'show' => $core->lang['show'], 'help' => $core->lang['help'], 'helptext' => $core->lang['stat_help'], 'from' => date2form($from), 'to' => date2form($to), 'u_today' => $core->url('m', 'sources?from=') . date('Y-m-d') . '&to=' . date('Y-m-d') . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : '') . ($q ? '&q=' . $q : '') . ($g ? '&g=' . $g : '') . ($c ? '&c=' . $c : '') . ($all ? '&a=' . $all : ''), 'u_csv' => $core->url('m', 'sources?show=csv&from=') . date2form($from) . '&to=' . date2form($to) . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : '') . ($q ? '&q=' . $q : '') . ($g ? '&g=' . $g : '') . ($c ? '&c=' . $c : '') . ($all ? '&a=' . $all : ''))); foreach ($offer as $of => $n) { $core->tpl->block('body', 'offer', array('name' => $n, 'value' => $of, 'select' => $of == $o ? 'selected="selected"' : '')); } foreach ($flow as $fl => $n) { $core->tpl->block('body', 'flow', array('name' => $n, 'value' => $fl, 'select' => $fl == $f ? 'selected="selected"' : '')); } foreach ($core->lang['stat_group'] as $gr => $n) { $core->tpl->block('body', 'group', array('name' => $n, 'value' => $gr, 'select' => $gr == $g ? 'selected="selected"' : '')); } foreach ($core->lang['stat_srcs'] as $sr => $n) { if ($sr) { $core->tpl->block('body', 'source', array('name' => $n, 'value' => $sr, 'select' => $sr == $q ? 'selected="selected"' : '')); } } foreach ($core->lang['stat_cutoff'] as $cc => $n) { $core->tpl->block('body', 'cutoff', array('name' => $n, 'value' => $cc, 'select' => $cc == $c ? 'selected="selected"' : '')); } if ($stats) { if ($g == 0) { $mids = array(); foreach ($stats as &$s) { if ($s['network'] == 1) { $mids[] = $s['source']; } } $mban = $mids ? $core->db->icol("SELECT img_mg, img_block FROM " . DB_IMAGE . " WHERE img_mg IN ( " . implode(',', $mids) . " )") : array(); } else { $mban = array(); } foreach ($stats as $d => &$s) { list($id, $src) = explode(':', $d); $inbl = $bl[$g][$id][$src]; $tc = max((int) $s['spaces'], (int) $s['clicks'], (int) $s['unique']); $ts = $s['ct'] / $tc * 1000; $cls = $inbl ? 'grey' : ($tc > 100 ? $ts < 1 ? 'red' : ($ts < 10 ? 'yellow' : '') : ''); $core->tpl->block('body', 'stat', array('u' => $core->url('m', 'sources?from=') . date2form($from) . '&to=' . date2form($to) . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : '') . ($og ? '&g=' . $og : '') . '&q=' . $id . '&c=1' . ($all ? '&a=' . $all : '') . '&fi=' . $src, 'id' => $core->lang['stat_srcs'][$id], 'src' => $src, 'class' => $cls, 'block' => isset($mban[$src]) ? $mban[$src] ? 'isbad' : 'isok' : '', 'spaces' => (int) $s['spaces'], 'suni' => (int) $s['suni'], 'clicks' => (int) $s['clicks'], 'unique' => (int) $s['unique'], 'ca' => (int) $s['ca'], 'cw' => (int) $s['cw'], 'cc' => (int) $s['cc'], 'ct' => (int) $s['ct'], 'bli' => $inbl ? $inbl : $g . '_' . $id . '_' . strtr($src, '.', '_'), 'blc' => $inbl ? 'decline red' : 'accept green', 'blu' => $inbl ? $core->url('a', 'bl-del', $inbl) . '?' : $core->url('a', 'bl-add', 0) . '?i=' . $src . '&u=' . $id . '&t=' . $g, 'blt' => $inbl ? $core->lang['bl_del'] : $core->lang['bl_add'])); } unset($d, $s, $stats); } else { $core->tpl->block('body', 'nostat'); } $core->tpl->output('body', $csv ? 'windows-1251' : false); if (!$csv) { $core->footer(); } $core->_die(); case 'target': switch ($message) { case 'ok': $core->info('info', 'done_add'); break; case 'save': $core->info('info', 'done_edit'); break; case 'del': $core->info('info', 'done_del'); break; case 'access': $core->info('error', 'access_denied'); break; } if ($id) { $tg = $core->db->row("SELECT * FROM " . DB_TARGET . " WHERE target_id = '{$id}' LIMIT 1"); if ($tg['user_id'] != $core->user->id) { $core->go($core->url('mm', 'target', 'access')); } $types = array(); foreach ($core->lang['stat_tartype'] as $v => $n) { $types[] = array('name' => $n, 'value' => $v, 'select' => $v == $tg['target_type']); } $core->mainline->add($core->lang['stats_target'], $core->url('m', 'target')); $core->mainline->add($tg['target_name']); $core->header(); $title = $core->lang['target_edit_h']; $action = $core->url('a', 'target-edit', $id); $method = 'post'; $field = array(array('type' => 'line', 'value' => $core->text->lines($core->lang['target_edit_t'])), array('type' => 'text', 'length' => 100, 'name' => 'name', 'head' => $core->lang['name'], 'value' => $tg['target_name']), array('type' => 'select', 'name' => 'type', 'head' => $core->lang['type'], 'value' => $types)); $button = array(array('type' => 'submit', 'value' => $core->lang['save'])); $core->form('targetedit', $action, $method, $title, $field, $button); $core->footer(); $core->_die(); } $today = date('Ymd'); $week1 = date('Ymd', strtotime('-2 week')); extract(params($core, array('to' => 'date', 'from' => 'date', 'o', 'f'))); if (!$to || $to > $today) { $to = $today; } if ($from > $to) { $from = $to; } if (!$from) { $from = $week1; } list($offer, $flow, $stats) = webmaster_target($core, $core->user->id, $from, $to, $o, $f); $csv = $core->get['show'] == 'csv' ? 1 : 0; $core->mainline->add($core->lang['stats_target']); if ($csv) { header('Content-type: text/csv'); header('Content-disposition: attachment;filename=target.csv'); } else { $core->header(); } if ($csv) { $core->tpl->load('body', 'csv-target'); } else { $core->tpl->load('body', 'target'); } $core->tpl->vars('body', array('nostats' => $core->lang['nostats'], 'type' => $core->lang['type'], 'today' => $core->lang['today'], 'target' => $core->lang['target'], 'wait' => $core->lang['stat_wait'], 'accept' => $core->lang['stat_accept'], 'cancel' => $core->lang['stat_cancel'], 'spaces' => $core->lang['stat_spaces'], 'clicks' => $core->lang['stat_clicks'], 'unique' => $core->lang['stat_unique'], 'total' => $core->lang['total'], 'flow' => $core->lang['flow'], 'offer' => $core->lang['offer'], 'show' => $core->lang['show'], 'help' => $core->lang['help'], 'helptext' => $core->lang['stat_help'], 'confirm' => $core->lang['confirm'], 'from' => date2form($from), 'to' => date2form($to), 'u_add' => $core->url('a', 'target-add', 0), 'u_today' => $core->url('m', 'target?from=') . date('Y-m-d') . '&to=' . date('Y-m-d') . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : ''), 'u_csv' => $core->url('m', 'target?show=csv&from=') . date2form($from) . '&to=' . date2form($to) . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : ''))); foreach ($offer as $of => $n) { $core->tpl->block('body', 'offer', array('name' => $n, 'value' => $of, 'select' => $of == $o ? 'selected="selected"' : '')); } foreach ($flow as $fl => $n) { $core->tpl->block('body', 'flow', array('name' => $n, 'value' => $fl, 'select' => $fl == $f ? 'selected="selected"' : '')); } if ($stats) { foreach ($stats as $d => &$s) { $tc = max((int) $s['spaces'], (int) $s['clicks'], (int) $s['unique']); $ts = $tc ? $s['ct'] / $tc * 1000 : 0; $cls = $inbl ? 'grey' : ($tc > 100 ? $ts < 1 ? 'red' : ($ts < 10 ? 'yellow' : '') : ''); $core->tpl->block('body', 'stat', array('id' => $d, 'class' => $cls, 'name' => $s['name'], 'type' => (int) $s['type'], 'spaces' => (int) $s['space'], 'suni' => (int) $s['suni'], 'clicks' => (int) $s['clicks'], 'unique' => (int) $s['unique'], 'ca' => (int) $s['ca'], 'cw' => (int) $s['cw'], 'cc' => (int) $s['cc'], 'ct' => (int) $s['ct'], 'edit' => $core->url('i', 'target', $d), 'del' => $core->url('a', 'target-del', $d))); } unset($d, $s, $stats); } else { $core->tpl->block('body', 'nostat'); } $core->tpl->output('body', $csv ? 'windows-1251' : false); if (!$csv) { $core->footer(); } $core->_die(); case 'flowstat': $today = date('Ymd'); $week1 = date('Ymd', strtotime('-2 week')); $yest = strtotime('-1 day'); extract(params($core, array('to' => 'date', 'from' => 'date'))); if (!$to || $to > $today) { $to = $today; } if ($from > $to) { $from = $to; } if (!$from) { $from = $week1; } $stats = webmaster_flowstat($core, $core->user->id, $from, $to); $csv = $core->get['show'] == 'csv' ? 1 : 0; $core->mainline->add($core->lang['stats_flow']); if ($csv) { header('Content-type: text/csv'); header('Content-disposition: attachment;filename=flowstat.csv'); } else { $core->header(); } if ($csv) { $core->tpl->load('body', 'csv-flowstat'); } else { $core->tpl->load('body', 'flowstat'); } $core->tpl->vars('body', array('nostats' => $core->lang['nostats'], 'type' => $core->lang['type'], 'today' => $core->lang['today'], 'yesterday' => $core->lang['yesterday'], 'target' => $core->lang['target'], 'wait' => $core->lang['stat_wait'], 'accept' => $core->lang['stat_accept'], 'cancel' => $core->lang['stat_cancel'], 'spaces' => $core->lang['stat_spaces'], 'clicks' => $core->lang['stat_clicks'], 'unique' => $core->lang['stat_unique'], 'total' => $core->lang['total'], 'flow' => $core->lang['flow'], 'offer' => $core->lang['offer'], 'show' => $core->lang['show'], 'help' => $core->lang['help'], 'helptext' => $core->lang['stat_help'], 'confirm' => $core->lang['confirm'], 'from' => date2form($from), 'to' => date2form($to), 'u_today' => $core->url('m', 'flowstat?from=') . date('Y-m-d') . '&to=' . date('Y-m-d') . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : ''), 'u_yesterday' => $core->url('m', 'flowstat?from=') . date('Y-m-d', $yest) . '&to=' . date('Y-m-d', $yest) . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : ''), 'u_csv' => $core->url('m', 'flowstat?show=csv&from=') . date2form($from) . '&to=' . date2form($to) . ($o ? '&o=' . $o : '') . ($f ? '&f=' . $f : ''))); if ($stats) { foreach ($stats as $d => &$s) { $tc = max((int) $s['spaces'], (int) $s['clicks'], (int) $s['unique']); $ts = $tc ? $s['ct'] / $tc * 1000 : 0; $cls = $tc > 100 ? $ts < 1 ? 'red' : ($ts < 10 ? 'yellow' : '') : ''; $core->tpl->block('body', 'stat', array('class' => $cls, 'offer' => $s['offer'], 'flow' => $s['flow'], 'type' => (int) $s['type'], 'spaces' => (int) $s['space'], 'suni' => (int) $s['suni'], 'clicks' => (int) $s['clicks'], 'unique' => (int) $s['unique'], 'ca' => (int) $s['ca'], 'cw' => (int) $s['cw'], 'cc' => (int) $s['cc'], 'ct' => (int) $s['ct'])); } unset($d, $s, $stats); } else { $core->tpl->block('body', 'nostat'); } $core->tpl->output('body', $csv ? 'windows-1251' : false); if (!$csv) { $core->footer(); } $core->_die(); case 'bl': $bls = $core->db->data("SELECT * FROM " . DB_BL . " WHERE user_id = '" . $core->user->id . "' ORDER BY bl_type DESC, bl_utm ASC, bl_item ASC"); $bl = array(1 => array(), 0 => array()); foreach ($bls as $b) { $bl[$b['bl_type']][$b['bl_utm']][$b['bl_item']] = $b['bl_id']; } $core->mainline->add($core->lang['black_list']); $core->header(); $core->tpl->load('body', 'bl'); foreach ($bl as $blti => $blt) { $core->tpl->block('body', 'type', array('name' => $core->lang['bl_type'][$blti], 'url' => $core->url('a', 'bl-load', $blti))); if ($blt) { foreach ($blt as $blui => $blu) { $core->tpl->block('body', 'type.utm', array('name' => $core->lang['stat_srcs'][$blui], 'url' => $core->url('a', 'bl-load', $blti) . '?u=' . $blui)); foreach ($blu as $i => $v) { $core->tpl->block('body', 'type.utm.item', array('id' => $i, 'bli' => $v, 'blu' => $core->url('a', 'bl-del', $v) . '?', 'blt' => $core->lang['bl_del'])); } } } else { $core->tpl->block('body', 'type.no'); } } $core->tpl->output('body'); $core->footer(); $core->_die(); // Parked domains // Parked domains case 'domain': switch ($message) { case 'ok': $core->info('info', 'done_add'); break; case 'del': $core->info('info', 'done_del'); break; case 'check': $core->info('info', 'done_domain_check'); break; case 'error': $core->info('error', 'error_domain_check'); break; case 'access': $core->info('error', 'access_denied'); break; } $core->mainline->add($core->lang['menu_domain'], $core->url('m', 'domain')); $core->header(); $core->tpl->load('body', 'domain'); $core->tpl->vars('body', array('text' => $core->text->lines($core->lang['domain_t']), 'u_add' => $core->url('a', 'dmn-add', 0), 'url' => $core->lang['domain'], 'status' => $core->lang['status'], 'action' => $core->lang['action'], 'check' => $core->lang['domain_check'], 'del' => $core->lang['del'], 'confirm' => $core->lang['confirm'], 'nodomain' => $core->lang['nodomain'])); $domain = $core->db->data("SELECT * FROM " . DB_DOMAIN . " WHERE user_id = '" . $core->user->id . "' ORDER BY dom_status ASC, dom_url ASC"); if (count($domain)) { foreach ($domain as $d) { $core->tpl->block('body', 'domain', array('url' => $d['dom_url'], 'stclass' => $d['dom_status'] ? 'isok' : 'wait', 'status' => $d['dom_status'] ? $core->lang['dom_ok'] : $core->lang['dom_wait'], 'check' => $core->url('a', 'dmn-check', $d['dom_id']), 'del' => $core->url('a', 'dmn-del', $d['dom_id']))); } } else { $core->tpl->block('body', 'nodoms'); } $core->tpl->output('body'); $core->footer(); $core->_die(); // WorkFlow // WorkFlow default: case 'flow': switch ($message) { case 'ok': $core->info('info', 'done_flow_ok'); break; case 'save': $core->info('info', 'done_flow_save'); break; case 'del': $core->info('info', 'done_flow_del'); break; case 'error': $core->info('error', 'error_flow'); break; case 'access': $core->info('error', 'access_denied'); break; } if ($id) { $flow = $core->db->row("SELECT * FROM " . DB_FLOW . " WHERE flow_id = '{$id}' LIMIT 1"); if ($flow['user_id'] != $core->user->id) { $core->go($core->url('mm', '', 'access')); } $sitel = $core->wmsale->get('lands', $flow['offer_id']); $sites = array(); foreach ($sitel as $k => $v) { $sites[] = array('name' => $v['site_url'], 'value' => $v['site_id'], 'select' => $v['site_id'] == $flow['flow_site']); } $spacl = $core->wmsale->get('space', $flow['offer_id']); $space = array(array('name' => '—', 'value' => 0)); foreach ($spacl as $k => $v) { $space[] = array('name' => $v['site_url'], 'value' => $v['site_id'], 'select' => $v['site_id'] == $flow['flow_space']); } $core->mainline->add($core->lang['menu_flow'], $core->url('m', 'flow')); $core->mainline->add($flow['flow_name']); $core->header(); $title = $core->lang['flow_edit_h']; $action = $core->url('a', 'flow-edit', $id); $method = 'post'; $field = array(array('type' => 'line', 'value' => $core->text->lines($core->lang['flow_edit_t'])), array('type' => 'text', 'length' => 100, 'name' => 'name', 'head' => $core->lang['name'], 'descr' => $core->lang['flow_name_d'], 'value' => $flow['flow_name']), array('type' => 'select', 'name' => 'site', 'head' => $core->lang['flow_land'], 'value' => $sites), array('type' => 'select', 'name' => 'space', 'head' => $core->lang['flow_space'], 'value' => $space), array('type' => 'checkbox', 'name' => 'cb', 'head' => $core->lang['flow_comeback'], 'checked' => $flow['flow_cb']), array('type' => 'checkbox', 'name' => 'param', 'head' => $core->lang['flow_param'], 'checked' => $flow['flow_param']), array('type' => 'text', 'length' => 200, 'name' => 'url', 'head' => $core->lang['flow_url'], 'descr' => $core->lang['flow_url_d'], 'value' => $flow['flow_url']), array('type' => 'text', 'length' => 200, 'name' => 'pbu', 'head' => $core->lang['flow_pbu'], 'descr' => $core->lang['flow_pbu_d'], 'value' => $flow['flow_pbu'])); $button = array(array('type' => 'submit', 'value' => $core->lang['save'])); $core->form('flowedit', $action, $method, $title, $field, $button); $core->footer(); $core->_die(); } $flows = $core->db->data("SELECT * FROM " . DB_FLOW . " WHERE user_id = '" . $core->user->id . "' ORDER BY flow_id DESC"); $flow = array(); foreach ($flows as $f) { $flow[$f['offer_id']][] = $f; } $redmn = $core->wmsale->get('domain', $core->user->id); $core->mainline->add($core->lang['menu_flow'], $core->url('m', 'flow')); $core->header(); $core->tpl->load('body', 'flows'); $core->tpl->vars('body', array('text' => $core->text->lines($core->lang['flows_text']), 'flow_site' => $core->text->lines($core->lang['flow_site']), 'flow_cb' => $core->lang['flow_comeback'], 'flow_sub' => $core->text->lines($core->lang['flow_sub']), 'flow_ajax' => $core->url('a', 'flow-ajax', 0), 'flow_tgt' => $core->url('a', 'flow-target', 0), 'flow_rd' => BASEURL, 'u_stats' => $core->url('m', 'stats'), 'u_flowstat' => $core->url('m', 'flowstat'), 'u_lead' => $core->url('m', 'lead'), 'u_sources' => $core->url('m', 'sources'), 'u_domain' => $core->url('m', 'domain'), 'u_target' => $core->url('m', 'target'), 'name' => $core->lang['name'], 'action' => $core->lang['action'], 'total' => $core->lang['total'], 'offer' => $core->lang['offer'], 'stats' => $core->lang['stats'], 'url' => $core->lang['site'], 'partner' => $core->lang['flow_partner_url'], 'edit' => $core->lang['settings'], 'del' => $core->lang['del'], 'confirm' => $core->lang['flow_confirm'])); if ($flow) { foreach ($flow as $o => $fl) { $offer = $core->wmsale->get('offer', $o); $lands = $core->wmsale->get('lands', $o); $space = $core->wmsale->get('space', $o); $core->tpl->block('body', 'offer', array('id' => $offer['offer_id'], 'name' => $offer['offer_name'], 'url' => $core->url('i', 'offers', $o), 'stats' => $core->url('m', 'stats') . '?o=' . $o, 'add' => $core->url('a', 'flow-add', $o))); if ($lands) { foreach ($lands as &$ss) { $core->tpl->block('body', 'offer.site', array('id' => $ss['site_id'], 'url' => $ss['site_url'], 'epc' => sprintf("%0.2f", $offer['offer_wm'] * $ss['site_convert']), 'cr' => sprintf("%0.2f", $ss['site_convert'] * 100))); } } unset($ss); if ($space) { $core->tpl->block('body', 'offer.subsite', array()); foreach ($space as &$ss) { $core->tpl->block('body', 'offer.subsite.s', array('id' => $ss['site_id'], 'url' => $ss['site_url'], 'epc' => sprintf("%0.2f", $offer['offer_wm'] * $ss['site_convert']), 'cr' => sprintf("%0.2f", $ss['site_convert'] * 100))); } unset($ss); } if ($redmn) { $core->tpl->block('body', 'offer.redmn', array()); foreach ($redmn as &$redm) { $core->tpl->block('body', 'offer.redmn.s', array('url' => $redm)); } unset($redm); } foreach ($fl as $f) { $core->tpl->block('body', 'offer.flow', array('id' => $f['flow_id'], 'name' => $search ? $search->highlight($f['flow_name']) : $f['flow_name'], 'site' => $f['flow_site'], 'space' => $f['flow_space'], 'cb' => $f['flow_cb'], 'param' => $f['flow_param'], 'url' => $f['flow_url'], 'pbu' => $f['flow_pbu'], 'offer' => $offer[$f['offer_id']], 'cr' => sprintf("%0.2f", $f['flow_convert'] * 100), 'epc' => rur($f['flow_epc']), 'total' => $f['flow_total'], 'edit' => $core->url('i', 'flow', $f['flow_id']), 'del' => $core->url('a', 'flow-del', $f['flow_id']), 'stats' => $core->url('m', 'stats') . '?f=' . $f['flow_id'], 'u_offer' => $core->url('m', 'stats') . '?o=' . $f['offer_id'])); } } unset($f, $flows); } else { $core->tpl->block('body', 'noflow'); } $core->tpl->output('body'); $core->footer(); $core->_die(); } return false; }
function api_wm_stats($core, $user) { $today = date('Ymd'); $week1 = date('Ymd', strtotime('-1 week')); extract(params($core, array('to' => 'date', 'from' => 'date', 'offer', 'flow'))); if (!$to || $to > $today) { $to = $today; } if ($from > $to) { $from = $to; } if (!$from) { $from = $week1; } require_once PATH . 'lib/webmaster.php'; list($offer, $flow, $stats) = webmaster_clicks($core, $user, $from, $to, $flow, $offer); return $stats; }