Exemplo n.º 1
0
         header("Location: " . _HTML_ROOT_PATH . "/?page=links");
     }
     exit;
     break;
 case 'add_category':
     $category_name = $_REQUEST['category_name'];
     $sql = "insert into tbl_links_categories_list (category_caption, category_type, status) values ('" . mysql_real_escape_string($category_name) . "', '', 0)";
     mysql_query($sql);
     $id = mysql_insert_id();
     $sql = "update tbl_links_categories_list set category_name='category_" . mysql_real_escape_string($id) . "' where id='" . mysql_real_escape_string($id) . "'";
     mysql_query($sql);
     echo $id;
     exit;
     break;
 case 'add_costs':
     $timezone_shift = get_current_timezone_shift();
     $date_range = explode(' - ', trim($_REQUEST['date_range']));
     $date_start = $date_range[0];
     $date_end = $date_range[1];
     $source_name = $_REQUEST['source_name'];
     $campaign_name = $_REQUEST['campaign_name'];
     $ads_name = $_REQUEST['ads_name'];
     $costs_value = trim(str_replace(',', '.', $_REQUEST['costs_value']));
     $costs_value = convert_to_usd($_REQUEST['currency_code'], $costs_value);
     if ($date_start == '' || $date_end == '' || $source_name == '' || $costs_value == '') {
         exit;
     }
     $date_start = date2mysql($date_start);
     $date_end = date2mysql($date_end);
     $where = '';
     if ($campaign_name != '') {
function get_sales($from, $to, $days, $month)
{
    $timezone_shift = get_current_timezone_shift();
    $sql = "SELECT *, `cnv`.`date_add` as `date` \n        FROM `tbl_conversions` `cnv` \n        LEFT JOIN `tbl_clicks` `clc` ON `cnv`.`subid` = `clc`.`subid`  \n        WHERE (`cnv`.`status` = 0 or `cnv`.`status` = 1)\n            AND CONVERT_TZ(`cnv`.`date_add`, '+00:00', '" . _str($timezone_shift) . "') BETWEEN STR_TO_DATE('" . _str($from) . " 00:00:00', '%Y-%m-%d %H:%i:%s') \n            AND STR_TO_DATE('" . _str($to) . " 23:59:59', '%Y-%m-%d %H:%i:%s') \n        ORDER BY `cnv`.`date_add` ASC";
    $r = mysql_query($sql);
    if (mysql_num_rows($r) == 0) {
        return false;
    }
    $data = array();
    $return = array();
    while ($f = mysql_fetch_assoc($r)) {
        $data[] = $f;
    }
    foreach ($data as $row) {
        if ($row['source_name'] == '') {
            $row['source_name'] = '_';
        }
        foreach ($days as $day) {
            $d = !$month ? date('d.m', strtotime($day)) : $day;
            if ($d == date(!$month ? 'd.m' : 'm.Y', strtotime($row['date']))) {
                $return[$row['source_name']][$d]++;
            }
        }
    }
    return $return;
}
function get_excel_report($date)
{
    $timezone_shift = get_current_timezone_shift();
    $sql = "select tbl_offers.offer_name, CONVERT_TZ(tbl_clicks.date_add, '+00:00', '" . _str($timezone_shift) . "') as date_add, tbl_clicks.user_ip, tbl_clicks.user_agent, tbl_clicks.user_os, tbl_clicks.user_platform, tbl_clicks.user_browser, tbl_clicks.country, tbl_clicks.subid, tbl_clicks.source_name, tbl_clicks.campaign_name, tbl_clicks.ads_name, tbl_clicks.referer, tbl_clicks.conversion_price_main from tbl_clicks left join tbl_offers on tbl_offers.id=tbl_clicks.out_id where CONVERT_TZ(tbl_clicks.date_add, '+00:00', '" . _str($timezone_shift) . "') BETWEEN '" . mysql_real_escape_string($date) . " 00:00:00' AND '" . mysql_real_escape_string($date) . " 23:59:59'";
    $result = db_query($sql);
    $arr_data = array();
    while ($row = mysql_fetch_assoc($result)) {
        $arr_data[] = $row;
    }
    return $arr_data;
}