/** * Generates statistics page for the given period * * @param iMSCP_pTemplate $tpl template engine instance * @return void */ function generatePage($tpl) { if (isset($_GET['month']) && isset($_GET['year'])) { $year = intval($_GET['year']); $month = intval($_GET['month']); } else { if (isset($_POST['month']) && isset($_POST['year'])) { $year = intval($_POST['year']); $month = intval($_POST['month']); } else { $month = date('m'); $year = date('y'); } } $stmt = exec_query('SELECT traff_time FROM server_traffic ORDER BY traff_time ASC LIMIT 1'); if ($stmt->rowCount()) { $row = $stmt->fetchRow(PDO::FETCH_ASSOC); $numberYears = date('y') - date('y', $row['traff_time']); $numberYears = $numberYears ? $numberYears + 1 : 1; } else { $numberYears = 1; } generateMonthsAndYearsHtmlList($tpl, $month, $year, $numberYears); $stmt = exec_query('SELECT bytes_in FROM server_traffic WHERE traff_time BETWEEN ? AND ? LIMIT 1', array(getFirstDayOfMonth($month, $year), getLastDayOfMonth($month, $year))); if ($stmt->rowCount()) { if ($month == date('m') && $year == date('y')) { $curday = date('j'); } else { $curday = date('j', getLastDayOfMonth($month, $year)); } $all = array_fill(0, 8, 0); for ($day = 1; $day <= $curday; $day++) { $beginDate = mktime(0, 0, 0, $month, $day, $year); $endDate = mktime(23, 59, 59, $month, $day, $year); list($webIn, $webOut, $smtpIn, $smtpOut, $popIn, $popOut, $otherIn, $otherOut, $allIn, $allOut) = _getServerTraffic($beginDate, $endDate); $tpl->assign(array('DAY' => tohtml($day), 'YEAR' => tohtml($year), 'MONTH' => tohtml($month), 'WEB_IN' => tohtml(bytesHuman($webIn)), 'WEB_OUT' => tohtml(bytesHuman($webOut)), 'SMTP_IN' => tohtml(bytesHuman($smtpIn)), 'SMTP_OUT' => tohtml(bytesHuman($smtpOut)), 'POP_IN' => tohtml(bytesHuman($popIn)), 'POP_OUT' => tohtml(bytesHuman($popOut)), 'OTHER_IN' => tohtml(bytesHuman($otherIn)), 'OTHER_OUT' => tohtml(bytesHuman($otherOut)), 'ALL_IN' => tohtml(bytesHuman($allIn)), 'ALL_OUT' => tohtml(bytesHuman($allOut)), 'ALL' => tohtml(bytesHuman($allIn + $allOut)), 'DAY_STATS_QSTRING' => tohtml("year={$year}&month={$month}&day={$day}", 'htmlAttr'))); $all[0] += $webIn; $all[1] += $webOut; $all[2] += $smtpIn; $all[3] += $smtpOut; $all[4] += $popIn; $all[5] += $popOut; $all[6] += $allIn; $all[7] += $allOut; $tpl->parse('DAY_SERVER_STATISTICS_BLOCK', '.day_server_statistics_block'); } $allOtherIn = $all[6] - ($all[0] + $all[2] + $all[4]); $allOtherOut = $all[7] - ($all[1] + $all[3] + $all[5]); $tpl->assign(array('WEB_IN_ALL' => tohtml(bytesHuman($all[0])), 'WEB_OUT_ALL' => tohtml(bytesHuman($all[1])), 'SMTP_IN_ALL' => tohtml(bytesHuman($all[2])), 'SMTP_OUT_ALL' => tohtml(bytesHuman($all[3])), 'POP_IN_ALL' => tohtml(bytesHuman($all[4])), 'POP_OUT_ALL' => tohtml(bytesHuman($all[5])), 'OTHER_IN_ALL' => tohtml(bytesHuman($allOtherIn)), 'OTHER_OUT_ALL' => tohtml(bytesHuman($allOtherOut)), 'ALL_IN_ALL' => tohtml(bytesHuman($all[6])), 'ALL_OUT_ALL' => tohtml(bytesHuman($all[7])), 'ALL_ALL' => tohtml(bytesHuman($all[6] + $all[7])))); } else { set_page_message(tr('No statistics found for the given period. Try another period.'), 'static_info'); $tpl->assign('SERVER_STATISTICS_BLOCK', ''); } }
/** * Generate statistics for the given period * * @param iMSCP_pTemplate $tpl Template engine instance * @return void */ function generatePage($tpl) { $domainId = get_user_domain_id($_SESSION['user_id']); if (isset($_POST['month']) && isset($_POST['year'])) { $year = intval($_POST['year']); $month = intval($_POST['month']); } else { if (isset($_GET['month']) && isset($_GET['year'])) { $month = intval($_GET['month']); $year = intval($_GET['year']); } else { $month = date('m'); $year = date('Y'); } } $stmt = exec_query('SELECT dtraff_time FROM domain_traffic WHERE domain_id = ? ORDER BY dtraff_time ASC LIMIT 1', $domainId); if ($stmt->rowCount()) { $row = $stmt->fetchRow(PDO::FETCH_ASSOC); $numberYears = date('y') - date('y', $row['dtraff_time']); $numberYears = $numberYears ? $numberYears + 1 : 1; } else { $numberYears = 1; } generateMonthsAndYearsHtmlList($tpl, $month, $year, $numberYears); $stmt = exec_query('SELECT domain_id FROM domain_traffic WHERE domain_id = ? AND dtraff_time >= ? AND dtraff_time <= ? LIMIT 1', array($domainId, getFirstDayOfMonth($month, $year), getLastDayOfMonth($month, $year))); if ($stmt->rowCount()) { $requestedPeriod = getLastDayOfMonth($month, $year); $toDay = $requestedPeriod < time() ? date('j', $requestedPeriod) : date('j'); $all = array_fill(0, 8, 0); $dateFormat = iMSCP_Registry::get('config')->DATE_FORMAT; for ($fromDay = 1; $fromDay <= $toDay; $fromDay++) { $beginTime = mktime(0, 0, 0, $month, $fromDay, $year); $endTime = mktime(23, 59, 59, $month, $fromDay, $year); list($webTraffic, $ftpTraffic, $smtpTraffic, $popTraffic) = _getUserTraffic($domainId, $beginTime, $endTime); $tpl->assign(array('DATE' => tohtml(date($dateFormat, strtotime($year . '-' . $month . '-' . $fromDay))), 'WEB_TRAFF' => tohtml(bytesHuman($webTraffic)), 'FTP_TRAFF' => tohtml(bytesHuman($ftpTraffic)), 'SMTP_TRAFF' => tohtml(bytesHuman($smtpTraffic)), 'POP_TRAFF' => tohtml(bytesHuman($popTraffic)), 'SUM_TRAFF' => tohtml(bytesHuman($webTraffic + $ftpTraffic + $smtpTraffic + $popTraffic)))); $all[0] += $webTraffic; $all[1] += $ftpTraffic; $all[2] += $smtpTraffic; $all[3] += $popTraffic; $tpl->parse('TRAFFIC_TABLE_ITEM', '.traffic_table_item'); } $tpl->assign(array('WEB_ALL' => tohtml(bytesHuman($all[0])), 'FTP_ALL' => tohtml(bytesHuman($all[1])), 'SMTP_ALL' => tohtml(bytesHuman($all[2])), 'POP_ALL' => tohtml(bytesHuman($all[3])), 'SUM_ALL' => tohtml(bytesHuman(array_sum($all))))); } else { set_page_message(tr('No statistics found for the given period. Try another period.'), 'static_info'); $tpl->assign('STATISTICS_BLOCK', ''); } }
/** * Generates page * * @param iMSCP_pTemplate $tpl Template instance engine * @param int $domainId Domain unique identifier * @return void */ function admin_generatePage($tpl, $domainId) { $stmt = exec_query('SELECT domain_admin_id FROM domain WHERE domain_id = ?', $domainId); if (!$stmt->rowCount()) { showBadRequestErrorPage(); } $domainAdminId = $stmt->fields['domain_admin_id']; $domainProperties = get_domain_default_props($domainAdminId); // Domain IP address info $stmt = exec_query("SELECT ip_number FROM server_ips WHERE ip_id = ?", $domainProperties['domain_ip_id']); if (!$stmt->rowCount()) { $domainIpAddr = tr('Not found.'); } else { $domainIpAddr = $stmt->fields['ip_number']; } $domainStatus = $domainProperties['domain_status']; // Domain status if ($domainStatus == 'ok' || $domainStatus == 'disabled' || $domainStatus == 'todelete' || $domainStatus == 'toadd' || $domainStatus == 'torestore' || $domainStatus == 'tochange' || $domainStatus == 'toenable' || $domainStatus == 'todisable') { $domainStatus = '<span style="color:green">' . tohtml(translate_dmn_status($domainStatus)) . '</span>'; } else { $domainStatus = '<b><font size="3" color="red">' . $domainStatus . "</font></b>"; } // Get total domain traffic usage in bytes $query = "\n\t\tSELECT\n\t\t\tIFNULL(SUM(dtraff_web), 0) AS dtraff_web, IFNULL(SUM(dtraff_ftp), 0) AS dtraff_ftp,\n\t\t\tIFNULL(SUM(dtraff_mail), 0) AS dtraff_mail, IFNULL(SUM(dtraff_pop), 0) AS dtraff_pop\n\t\tFROM\n\t\t\tdomain_traffic\n\t\tWHERE\n\t\t\tdomain_id = ?\n\t\tAND\n\t\t\tdtraff_time BETWEEN ? AND ?\n\t"; $stmt = exec_query($query, array($domainProperties['domain_id'], getFirstDayOfMonth(), getLastDayOfMonth())); if ($stmt->rowCount()) { $trafficUsageBytes = $stmt->fields['dtraff_web'] + $stmt->fields['dtraff_ftp'] + $stmt->fields['dtraff_mail'] + $stmt->fields['dtraff_pop']; } else { $trafficUsageBytes = 0; } // Get limits in bytes $trafficLimitBytes = $domainProperties['domain_traffic_limit'] * 1048576; $diskspaceLimitBytes = $domainProperties['domain_disk_limit'] * 1048576; // Get usages in percent $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes); $diskspaceUsagePercent = make_usage_vals($domainProperties['domain_disk_usage'], $diskspaceLimitBytes); // Get Email quota info list($quota, $quotaLimit) = admin_gen_mail_quota_limit_mgs($domainAdminId); # Features $tpl->assign(array('DOMAIN_ID' => $domainId, 'VL_DOMAIN_NAME' => tohtml(decode_idna($domainProperties['domain_name'])), 'VL_DOMAIN_IP' => tohtml($domainIpAddr), 'VL_STATUS' => $domainStatus, 'VL_PHP_SUPP' => translate_limit_value($domainProperties['domain_php']), 'VL_PHP_EDITOR_SUPP' => translate_limit_value($domainProperties['phpini_perm_system']), 'VL_CGI_SUPP' => translate_limit_value($domainProperties['domain_cgi']), 'VL_DNS_SUPP' => translate_limit_value($domainProperties['domain_dns']), 'VL_EXT_MAIL_SUPP' => translate_limit_value($domainProperties['domain_external_mail']), 'VL_SOFTWARE_SUPP' => translate_limit_value($domainProperties['domain_software_allowed']), 'VL_BACKUP_SUP' => translate_limit_value($domainProperties['allowbackup']), 'VL_TRAFFIC_PERCENT' => $trafficUsagePercent, 'VL_TRAFFIC_USED' => bytesHuman($trafficUsageBytes), 'VL_TRAFFIC_LIMIT' => bytesHuman($trafficLimitBytes), 'VL_DISK_PERCENT' => $diskspaceUsagePercent, 'VL_DISK_USED' => bytesHuman($domainProperties['domain_disk_usage']), 'VL_DISK_LIMIT' => bytesHuman($diskspaceLimitBytes), 'VL_MAIL_ACCOUNTS_USED' => get_domain_running_mail_acc_cnt($domainId), 'VL_MAIL_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_mailacc_limit']), 'VL_MAIL_QUOTA_USED' => $quota, 'VL_MAIL_QUOTA_LIMIT' => $domainProperties['domain_mailacc_limit'] != '-1' ? $quotaLimit : tr('Disabled'), 'VL_FTP_ACCOUNTS_USED' => get_customer_running_ftp_acc_cnt($domainAdminId), 'VL_FTP_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_ftpacc_limit']), 'VL_SQL_DB_ACCOUNTS_USED' => get_domain_running_sqld_acc_cnt($domainId), 'VL_SQL_DB_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqld_limit']), 'VL_SQL_USER_ACCOUNTS_USED' => get_domain_running_sqlu_acc_cnt($domainId), 'VL_SQL_USER_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_sqlu_limit']), 'VL_SUBDOM_ACCOUNTS_USED' => get_domain_running_sub_cnt($domainId), 'VL_SUBDOM_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_subd_limit']), 'VL_DOMALIAS_ACCOUNTS_USED' => get_domain_running_als_cnt($domainId), 'VL_DOMALIAS_ACCOUNTS_LIMIT' => translate_limit_value($domainProperties['domain_alias_limit']))); }
function grab_timeframe() { if (BTAuth::user()->getPref('time_predefined') == 'today' or BTAuth::user()->getPref('time_from') != '') { $time['from'] = mktime(0, 0, 0, date('m', time()), date('d', time()), date('Y', time())); $time['to'] = mktime(23, 59, 59, date('m', time()), date('d', time()), date('Y', time())); } if (BTAuth::user()->getPref('time_predefined') == 'yesterday') { $time['from'] = mktime(0, 0, 0, date('m', time() - 86400), date('d', time() - 86400), date('Y', time() - 86400)); $time['to'] = mktime(23, 59, 59, date('m', time() - 86400), date('d', time() - 86400), date('Y', time() - 86400)); } if (BTAuth::user()->getPref('time_predefined') == 'last7') { $time['from'] = mktime(0, 0, 0, date('m', time() - 86400 * 7), date('d', time() - 86400 * 7), date('Y', time() - 86400 * 7)); $time['to'] = mktime(23, 59, 59, date('m', time()), date('d', time()), date('Y', time())); } if (BTAuth::user()->getPref('time_predefined') == 'last14') { $time['from'] = mktime(0, 0, 0, date('m', time() - 86400 * 14), date('d', time() - 86400 * 14), date('Y', time() - 86400 * 14)); $time['to'] = mktime(23, 59, 59, date('m', time()), date('d', time()), date('Y', time())); } if (BTAuth::user()->getPref('time_predefined') == 'last30') { $time['from'] = mktime(0, 0, 0, date('m', time() - 86400 * 30), date('d', time() - 86400 * 30), date('Y', time() - 86400 * 30)); $time['to'] = mktime(23, 59, 59, date('m', time()), date('d', time()), date('Y', time())); } if (BTAuth::user()->getPref('time_predefined') == 'thismonth') { $time['from'] = mktime(0, 0, 0, date('m', time()), 1, date('Y', time())); $time['to'] = mktime(23, 59, 59, date('m', time()), date('d', time()), date('Y', time())); } if (BTAuth::user()->getPref('time_predefined') == 'lastmonth') { $time['from'] = mktime(0, 0, 0, date('m', time() - 2629743), 1, date('Y', time() - 2629743)); $time['to'] = mktime(23, 59, 59, date('m', time() - 2629743), getLastDayOfMonth(date('m', time() - 2629743), date('Y', time() - 2629743)), date('Y', time() - 2629743)); } if (BTAuth::user()->getPref('time_predefined') == '') { $time['from'] = BTAuth::user()->getPref('time_from'); $time['to'] = BTAuth::user()->getPref('time_to'); } $time['time_predefined'] = BTAuth::user()->getPref('time_predefined'); return $time; }
echo 'todate = "' . date('m/d/Y', mktime(23, 59, 59, date('m', time() - 2629743), getLastDayOfMonth(date('m', time() - 2629743), date('Y', time() - 2629743)), date('Y', time() - 2629743))) . '";'; ?> } if($('#time_predefined').val() == 'thisyear') { <?php echo 'fromdate = "' . date('m/d/Y', mktime(0, 0, 0, 1, 1, date('Y', time()))) . '";'; echo 'todate = "' . date('m/d/Y', mktime(23, 59, 59, date('m', time()), date('d', time()), date('Y', time()))) . '";'; ?> } if($('#time_predefined').val() == 'lastyear') { <?php echo 'fromdate = "' . date('m/d/Y', mktime(0, 0, 0, 1, 1, date('Y', time() - 31556926))) . '";'; echo 'todate = "' . date('m/d/Y', mktime(0, 0, 0, 12, getLastDayOfMonth(date('m', time() - 31556926), date('Y', time() - 31556926)), date('Y', time() - 31556926))) . '";'; ?> } if($('#time_predefined').val() == 'alltime') { <?php echo 'fromdate = "' . date('m/d/Y', mktime(0, 0, 0, 1, 1, 2000)) . '";'; echo 'todate = "' . date('m/d/Y', mktime(23, 59, 59, date('m', time()), date('d', time()), date('Y', time()))) . '";'; ?> } $('#from').val(fromdate); $('#to').val(todate); }
function runBreakdown($user_pref) { $database = DB::getInstance(); $db = $database->getConnection(); //grab time $time = grab_timeframe(); //get breakdown pref $mysql['user_id'] = $db->real_escape_string($_SESSION['user_id']); $user_sql = "\n\t\t\tSELECT\n\t\t\t\tuser_time_register,\n\t\t\t\tuser_pref_breakdown,\n\t\t\t\tuser_pref_chart,\n\t\t\t\tuser_pref_show\n\t\t\tFROM\n\t\t\t\t202_users\n\t\t\t\tLEFT JOIN 202_users_pref USING (user_id) \n\t\t\tWHERE\n\t\t\t\t202_users.user_id='" . $mysql['user_id'] . "'"; $user_result = _mysqli_query($user_sql); //($user_sql); $user_row = $user_result->fetch_assoc(); if ($user_row['user_pref_show'] == 'all') { $click_flitered = ''; } if ($user_row['user_pref_show'] == 'real') { $click_filtered = " AND click_filtered='0' "; } if ($user_row['user_pref_show'] == 'filtered') { $click_filtered = " AND click_filtered='1' "; } if ($user_row['user_pref_show'] == 'filtered_bot') { $click_filtered = " AND click_bot='1' "; } if ($user_row['user_pref_show'] == 'leads') { $click_filtered = " AND click_lead='1' "; } //breakdown should be hour, day, month, or year. $breakdown = $user_row['user_pref_breakdown']; $pref_chart = $user_row['user_pref_chart']; //first delete old report $breakdown_sql = "\n\t\t\tDELETE\n\t\t\tFROM 202_sort_breakdowns\n\t\t\tWHERE user_id='" . $mysql['user_id'] . "'\n\t\t"; $breakdown_result = _mysqli_query($breakdown_sql); //($breakdown_sql); //find where to start from. $start = $time['from']; $end = $time['to']; //make sure the start isn't past this users registration time, and likewise, make sure END isn't past today, else theses will try to grab reports for dates that do not exists slowing down mysql doing reports for nothing. if ($user_row['user_time_register'] > $start) { $start = $user_row['user_time_register']; } if (time() < $end) { $end = time(); } $x = 0; while ($end > $start) { if ($breakdown == 'hour') { $from = mktime(date('G', $end), 0, 0, date('m', $end), date('d', $end), date('y', $end)); $to = mktime(date('G', $end), 59, 59, date('m', $end), date('d', $end), date('y', $end)); $end = $end - 3600; } elseif ($breakdown == 'day') { $from = mktime(0, 0, 0, date('m', $end), date('d', $end), date('y', $end)); $to = mktime(23, 59, 59, date('m', $end), date('d', $end), date('y', $end)); $end = $end - 86400; } elseif ($breakdown == 'month') { $from = mktime(0, 0, 0, date('m', $end), 1, date('y', $end)); $to = mktime(23, 59, 59, date('m', $end), @getLastDayOfMonth(date('m', $end)), date('y', $end)); $end = $end - 2629743; } elseif ($breakdown == 'year') { $from = mktime(0, 0, 0, 1, 1, date('y', $end)); $to = mktime(23, 59, 59, @getLastDayOfMonth(date('m', $end)), 1, 12, date('y', $end)); $end = $end - 31556926; } $mysql['from'] = $db->real_escape_string($from); $mysql['to'] = $db->real_escape_string($to); //build query $command = "\n\t\t\tSELECT\n\t\t\tCOUNT(*) AS clicks,\n\t\t\t\tAVG(2c.click_cpc) AS avg_cpc,\n\t\t\t\tSUM(2cr.click_out) AS click_throughs,\n\t\t\t\tSUM(2c.click_lead) AS leads,\n\t\t\t\tSUM(2c.click_payout*2c.click_lead) AS income\n\t\t\tFROM\n\t\t\t\t202_clicks AS 2c\n\t\t\t\tLEFT JOIN 202_clicks_record AS 2cr ON 2cr.click_id = 2c.click_id\n\t\t"; $db_table = "2c"; $pref_time = false; if ($user_pref == true) { $pref_adv = true; $command = $command . "\n\t\t\t\tLEFT JOIN 202_clicks_advance AS 2ca ON (2ca.click_id = 2c.click_id)\n\t\t\t\tLEFT JOIN 202_clicks_site AS 2cs ON (2cs.click_id = 2c.click_id)\n\t\t\t"; } else { $pref_adv = false; } $command = $command . "\n\t\t\tLEFT JOIN 202_aff_campaigns AS 2ac ON (2c.aff_campaign_id = 2ac.aff_campaign_id)\n\t\t\tLEFT JOIN 202_aff_networks AS 2an ON (2an.aff_network_id = 2ac.aff_network_id)\n\t\t"; $pref_show = false; $pref_order = "\n\t\t\tAND (2c.click_alp = '1' OR (2ac.aff_campaign_deleted='0' AND 2an.aff_network_deleted='0'))\n\t\t\t{$click_filtered}\n\t\t\tAND 2c.click_time > " . $mysql['from'] . "\n\t\t\tAND 2c.click_time <= " . $mysql['to'] . "\n\t\t"; $offset = false; $pref_limit = false; $count = false; $query = query($command, $db_table, $pref_time, $pref_adv, $pref_show, $pref_order, $offset, $pref_limit, $count); $click_sql = $query['click_sql']; global $memcacheWorking, $memcache; if (!user_cache_time($mysql['user_id'])) { $click_result = _mysqli_query($click_sql); //($click_sql); $click_row = $click_result->fetch_assoc(); } else { if ($memcacheWorking) { $getCache = $memcache->get(md5($click_sql . systemHash())); if ($getCache) { $click_row = unserialize($getCache); } else { $click_result = _mysqli_query($click_sql); $fetchArray = $click_result->fetch_assoc(); $setCache = $memcache->set(md5($click_sql . systemHash()), serialize($fetchArray), false, user_cache_time($mysql['user_id'])); $click_row = $fetchArray; } } else { $click_result = _mysqli_query($click_sql); //($click_sql); $click_row = $click_result->fetch_assoc(); } } //for AVG Payouts $payouts_sql = "\n\t\t\tSELECT\n\t\t\t\tSUM(2c.click_payout) AS payout\n\t\t\tFROM 202_clicks AS 2c\n\t\t\tWHERE 2c.click_lead='1'\n\t\t\tAND 2c.click_time > " . $mysql['from'] . "\n\t\t\tAND 2c.click_time <= " . $mysql['to'] . "\n\t\t"; $payout_result = _mysqli_query($payouts_sql); //($breakdown_sql); $payout_row = $payout_result->fetch_assoc(); //get the stats $clicks = 0; $clicks = $click_row['clicks']; $total_clicks = $total_clicks + $clicks; //click throughs $click_throughs = $click_row['click_throughs']; $total_click_throughs = $total_click_throughs + $click_throughs; //LP CTR $ctr = @round($click_throughs / $clicks * 100, 2); $total_ctr = @round($total_click_throughs / $total_clicks * 100, 2); //avg cpc and cost $avg_cpc = 0; $avg_cpc = $click_row['avg_cpc']; $cost = 0; $cost = $clicks * $avg_cpc; $total_cost = $total_cost + $cost; $total_avg_cpc = @round($total_cost / $total_clicks, 5); //leads $leads = 0; $leads = $click_row['leads']; $total_leads = $total_leads + $leads; //signup ratio $su_ratio - 0; $su_ratio = @round($leads / $clicks * 100, 2); $total_su_ratio = @round($total_leads / $total_clicks * 100, 2); $payout = 0; //current payout if ($click_row['leads'] > 0) { $payout = $payout_row['payout'] / $leads; } //income $income = 0; $income = $click_row['income']; $total_income = $total_income + $income; //grab the EPC $epc = 0; $epc = @round($income / $clicks, 2); $total_epc = @round($total_income / $total_clicks, 2); //net income $net = 0; $net = $income - $cost; $total_net = $total_income - $total_cost; //roi $roi = 0; $roi = @round($net / $cost * 100); $total_roi = @round($total_net / $total_cost); //html escape vars $mysql['clicks'] = $db->real_escape_string($clicks); $mysql['click_throughs'] = $db->real_escape_string($click_throughs); $mysql['ctr'] = $db->real_escape_string($ctr); $mysql['leads'] = $db->real_escape_string($leads); $mysql['su_ratio'] = $db->real_escape_string($su_ratio); $mysql['payout'] = $db->real_escape_string($payout); $mysql['epc'] = $db->real_escape_string($epc); $mysql['avg_cpc'] = $db->real_escape_string($avg_cpc); $mysql['income'] = $db->real_escape_string($income); $mysql['cost'] = $db->real_escape_string($cost); $mysql['net'] = $db->real_escape_string($net); $mysql['roi'] = $db->real_escape_string($roi); //insert chart $sort_breakdown_sql = "\n\t\t\tINSERT INTO\n\t\t\t\t202_sort_breakdowns\n\t\t\tSET\n\t\t\t\tsort_breakdown_from='" . $mysql['from'] . "',\n\t\t\t\tsort_breakdown_to='" . $mysql['to'] . "',\n\t\t\t\tuser_id='" . $mysql['user_id'] . "',\n\t\t\t\tsort_breakdown_clicks='" . $mysql['clicks'] . "',\n\t\t\t\tsort_breakdown_click_throughs='" . $mysql['click_throughs'] . "',\n\t\t\t\tsort_breakdown_ctr='" . $mysql['ctr'] . "',\n\t\t\t\tsort_breakdown_leads='" . $mysql['leads'] . "',\n\t\t\t\tsort_breakdown_su_ratio='" . $mysql['su_ratio'] . "',\n\t\t\t\tsort_breakdown_payout='" . $mysql['payout'] . "',\n\t\t\t\tsort_breakdown_epc='" . $mysql['epc'] . "',\n\t\t\t\tsort_breakdown_avg_cpc='" . $mysql['avg_cpc'] . "',\n\t\t\t\tsort_breakdown_income='" . $mysql['income'] . "',\n\t\t\t\tsort_breakdown_cost='" . $mysql['cost'] . "',\n\t\t\t\tsort_breakdown_net='" . $mysql['net'] . "',\n\t\t\t\tsort_breakdown_roi='" . $mysql['roi'] . "'\n\t\t"; $sort_breakdown_result = _mysqli_query($sort_breakdown_sql); //($sort_breakdown_sql); } $breakdown_sql = "\n\t\tSELECT *\n\t\tFROM 202_sort_breakdowns\n\t\tWHERE user_id='" . $mysql['user_id'] . "'\n\t"; $breakdown_result = _mysqli_query($breakdown_sql); //($breakdown_sql); $chartWidth = $_POST['chartWidth']; $chartHeight = 180; //find where to start from. $start = $time['from']; $end = $time['to']; //make sure the start isn't past this users registration time, and likewise, make sure END isn't past today, else theses will try to grab reports for dates that do not exists slowing down mysql doing reports for nothing. if ($user_row['user_time_register'] > $start) { $start = $user_row['user_time_register']; } if (time() < $end) { $end = time(); } //cacluate the skip $x = 0; while ($start < $end) { if ($breakdown == 'hour') { $start = $start + 3600; } elseif ($breakdown == 'day') { $start = $start + 86400; } elseif ($breakdown == 'month') { $start = $start + 2629743; } elseif ($breakdown == 'year') { $start = $start + 31556926; } $x++; } $skip = 0; if ($breakdown == hour) { while ($x > 9) { $skip++; $x = $x - 9; } } else { while ($x > 14) { $skip++; $x = $x - 14; } } /* THIS IS A NET INCOME BAR GRAPH */ if ($pref_chart == 'profitloss') { //start the PHP multi-dimensional array and create the region titles $chart['chart_data'][0][0] = ""; $chart['chart_data'][1][0] = "Income"; $chart['chart_data'][2][0] = "Cost"; $chart['chart_data'][3][0] = "Net"; //extract the data from the query result one row at a time for ($i = 0; $i < $breakdown_result->num_rows; $i++) { $breakdown_result->field_seek($breakdown_result->current_field); //determine which column in the PHP array the current data belongs to $row = $breakdown_result->fetch_assoc(); $col = $row['sort_breakdown_from']; //populate the PHP array with the Year title $date = $row['sort_breakdown_from']; $date = date_chart($breakdown, $date); $chart['chart_data'][0][$col] = $date; //populate the PHP array with the revenue data $chart['chart_data'][1][$col] = $row['sort_breakdown_income']; $chart['chart_data'][2][$col] = $row['sort_breakdown_cost']; $chart['chart_data'][3][$col] = $row['sort_breakdown_net']; } $chart['series_color'] = array("70CF40", "CF4040", "409CCF", "000000"); $chart['series_gap'] = array('set_gap' => 40, 'bar_gap' => -35); $chart['chart_grid_h'] = array('alpha' => 20, 'color' => "000000", 'thickness' => 1, 'type' => "solid"); $chart['axis_value'] = array('bold' => false, 'size' => 10); $chart['axis_category'] = array('skip' => $skip, 'bold' => false, 'size' => 10); $chart['legend_label'] = array('bold' => true, 'size' => 12); $chart['chart_pref'] = array('line_thickness' => 1, 'point_shape' => "none", 'fill_shape' => true); $chart['chart_rect'] = array('x' => 40, 'y' => 20, 'width' => $chartWidth - 60, 'height' => $chartHeight); $chart['chart_transition'] = array('type' => "scale", 'delay' => 0.5, 'duration' => 0.5, 'order' => "series"); } else { //start the PHP multi-dimensional array and create the region titles $chart['chart_data'][0][0] = ""; if ($pref_chart == 'clicks') { $chart['chart_data'][1][0] = "Clicks"; } elseif ($pref_chart == 'leads') { $chart['chart_data'][1][0] = "Leads"; } elseif ($pref_chart == 'su_ratio') { $chart['chart_data'][1][0] = "Signup Ratio"; } elseif ($pref_chart == 'payout') { $chart['chart_data'][1][0] = "Payout"; } elseif ($pref_chart == 'epc') { $chart['chart_data'][1][0] = "EPC"; } elseif ($pref_chart == 'cpc') { $chart['chart_data'][1][0] = "Avg CPC"; } elseif ($pref_chart == 'income') { $chart['chart_data'][1][0] = "Income"; } elseif ($pref_chart == 'cost') { $chart['chart_data'][1][0] = "Cost"; } elseif ($pref_chart == 'net') { $chart['chart_data'][1][0] = "Net"; } elseif ($pref_chart == 'roi') { $chart['chart_data'][1][0] = "ROI"; } //extract the data from the query result one row at a time for ($i = 0; $i < $breakdown_result->num_rows; $i++) { $breakdown_result->field_seek($breakdown_result->current_field); //determine which column in the PHP array the current data belongs to $row = $breakdown_result->fetch_assoc(); $col = $row['sort_breakdown_from']; //populate the PHP array with the Year title $date = $row['sort_breakdown_from']; $date = date_chart($breakdown, $date); $chart['chart_data'][0][$col] = $date; //populate the PHP array with the revenue data if ($pref_chart == 'clicks') { $chart['chart_data'][1][$col] = $row['sort_breakdown_clicks']; } elseif ($pref_chart == 'leads') { $chart['chart_data'][1][$col] = $row['sort_breakdown_leads']; } elseif ($pref_chart == 'su_ratio') { $chart['chart_data'][1][$col] = $row['sort_breakdown_su_ratio']; } elseif ($pref_chart == 'payout') { $chart['chart_data'][1][$col] = $row['sort_breakdown_payout']; } elseif ($pref_chart == 'epc') { $chart['chart_data'][1][$col] = $row['sort_breakdown_epc']; } elseif ($pref_chart == 'cpc') { $chart['chart_data'][1][$col] = $row['sort_breakdown_avg_cpc']; } elseif ($pref_chart == 'income') { $chart['chart_data'][1][$col] = $row['sort_breakdown_income']; } elseif ($pref_chart == 'cost') { $chart['chart_data'][1][$col] = $row['sort_breakdown_cost']; } elseif ($pref_chart == 'net') { $chart['chart_data'][1][$col] = $row['sort_breakdown_net']; } elseif ($pref_chart == 'roi') { $chart['chart_data'][1][$col] = $row['sort_breakdown_roi']; } } //$chart[ 'series_color' ] = array ( "003399"); $chart['series_color'] = array("000000"); $chart['chart_type'] = "Line"; //$chart[ 'chart_transition' ] = array ( 'type'=>"dissolve", 'delay'=>.5, 'duration'=>.5, 'order'=>"series" ); $chart['chart_grid_h'] = array('alpha' => 20, 'color' => "000000", 'thickness' => 1, 'type' => "solid"); } $chart['chart_pref'] = array('line_thickness' => 1, 'point_shape' => "circle", 'fill_shape' => false); $chart['axis_value'] = array('bold' => false, 'size' => 10); $chart['axis_category'] = array('skip' => $skip, 'bold' => false, 'size' => 10); $chart['legend_label'] = array('bold' => true, 'size' => 12); $chart['chart_rect'] = array('x' => 40, 'y' => 20, 'width' => $chartWidth, 'height' => $chartHeight); showChart($chart, $chartWidth, $chartHeight + 40); ?> <div style="padding: 3px 0px;"></div><?php }
/** * Generate page * * @param iMSCP_pTemplate $tpl Template engine instance * @param int $userId User unique identifier * @return void */ function generatePage($tpl, $userId) { $stmt = exec_query(' SELECT admin_name, domain_id FROM admin INNER JOIN domain ON(domain_admin_id = admin_id) WHERE admin_id = ? ', $userId); if (!$stmt->rowCount()) { showBadRequestErrorPage(); } $row = $stmt->fetchRow(PDO::FETCH_ASSOC); $domainId = $row['domain_id']; $adminName = decode_idna($row['admin_name']); if (isset($_POST['month']) && isset($_POST['year'])) { $year = intval($_POST['year']); $month = intval($_POST['month']); } else { $month = date('m'); $year = date('y'); } $stmt = exec_query('SELECT dtraff_time FROM domain_traffic WHERE domain_id = ? ORDER BY dtraff_time ASC LIMIT 1', $domainId); if ($stmt->rowCount()) { $row = $stmt->fetchRow(PDO::FETCH_ASSOC); $numberYears = date('y') - date('y', $row['dtraff_time']); $numberYears = $numberYears ? $numberYears + 1 : 1; } else { $numberYears = 1; } generateMonthsAndYearsHtmlList($tpl, $month, $year, $numberYears); $stmt = exec_query('SELECT domain_id FROM domain_traffic WHERE domain_id = ? AND dtraff_time BETWEEN ? AND ? LIMIT 1', array($domainId, getFirstDayOfMonth($month, $year), getLastDayOfMonth($month, $year))); if ($stmt->rowCount()) { $requestedPeriod = getLastDayOfMonth($month, $year); $toDay = $requestedPeriod < time() ? date('j', $requestedPeriod) : date('j'); $all = array_fill(0, 8, 0); $dateFormat = iMSCP_Registry::get('config')->DATE_FORMAT; for ($fromDay = 1; $fromDay <= $toDay; $fromDay++) { $beginTime = mktime(0, 0, 0, $month, $fromDay, $year); $endTime = mktime(23, 59, 59, $month, $fromDay, $year); list($webTraffic, $ftpTraffic, $smtpTraffic, $popTraffic) = _getUserTraffic($domainId, $beginTime, $endTime); $tpl->assign(array('DATE' => date($dateFormat, strtotime($year . '-' . $month . '-' . $fromDay)), 'WEB_TRAFFIC' => tohtml(bytesHuman($webTraffic)), 'FTP_TRAFFIC' => tohtml(bytesHuman($ftpTraffic)), 'SMTP_TRAFFIC' => tohtml(bytesHuman($smtpTraffic)), 'POP3_TRAFFIC' => tohtml(bytesHuman($popTraffic)), 'ALL_TRAFFIC' => tohtml(bytesHuman($webTraffic + $ftpTraffic + $smtpTraffic + $popTraffic)))); $all[0] += $webTraffic; $all[1] += $ftpTraffic; $all[2] += $smtpTraffic; $all[3] += $popTraffic; $tpl->parse('TRAFFIC_TABLE_ITEM', '.traffic_table_item'); } $tpl->assign(array('USER_ID' => tohtml($userId), 'USERNAME' => tohtml($adminName), 'ALL_WEB_TRAFFIC' => tohtml(bytesHuman($all[0])), 'ALL_FTP_TRAFFIC' => tohtml(bytesHuman($all[1])), 'ALL_SMTP_TRAFFIC' => tohtml(bytesHuman($all[2])), 'ALL_POP3_TRAFFIC' => tohtml(bytesHuman($all[3])), 'ALL_ALL_TRAFFIC' => tohtml(bytesHuman(array_sum($all))))); } else { set_page_message(tr('No statistics found for the given period. Try another period.'), 'static_info'); $tpl->assign(array('USERNAME' => tohtml($adminName), 'USER_ID' => tohtml($userId), 'RESELLER_USER_STATISTICS_DETAIL_BLOCK' => '')); } }
<?php /* This files fetchesThis file fetches transaction data from the database based on a start and end Month/Year and returns the data back as a JSON object that can be used to render a grid view. */ require_once "include_files.php"; header('Content-Type: application/json'); //$_GET["month"] //$_GET["year"] $monthFrom = intval($_GET["monthFrom"]); $monthTo = intval($_GET["monthTo"]); $yearFrom = intval($_GET["yearFrom"]); $yearTo = intval($_GET["yearTo"]); $fromDate = $yearFrom . str_pad($monthFrom, 2, "0", STR_PAD_LEFT) . "01"; $toDate = $yearTo . str_pad($monthTo, 2, "0", STR_PAD_LEFT) . getLastDayOfMonth($monthTo, $yearTo); $rows = array(); $total = 0; $inTotal = 0; $outTotal = 0; $pageNumber = is_null($_GET["page"]) ? 1 : $_GET["page"]; $page = $pageNumber - 1; $recordsPerPage = is_null($_GET["rp"]) ? 10 : $_GET["rp"]; $offset = $page * $recordsPerPage; $sortName = is_null($_GET["sortname"]) ? "tdate" : $_GET["sortname"]; $sortOrder = is_null($_GET["sortorder"]) ? "desc" : $_GET["sortorder"]; $searchQuery = is_null($_GET["query"]) ? null : trim($_GET["query"]); $searchQueryType = is_null($_GET["qtype"]) ? null : $_GET["qtype"]; $searchCondition = ""; if (!(is_null($searchQuery) || empty($searchQuery)) && !(is_null($searchQueryType) || empty($searchQueryType))) { $searchCondition = $searchQueryType . " LIKE '%" . $searchQuery . "%'"; }
public function setTableDefinition() { parent::setTableDefinition(); $this->setTableName('company'); # override the not null and not blank properties for the createdby column in the BaseEntity $this->hasColumn('createdby', 'integer', 11, array('default' => NULL)); $this->hasColumn('refno', 'string', 15); $this->hasColumn('name', 'string', 255, array('notblank' => true)); $this->hasColumn('appname', 'string', 255); $this->hasColumn('headertype', 'integer', null, array('default' => 0)); $this->hasColumn('slogan', 'string', 255); $this->hasColumn('username', 'string', 255); $this->hasColumn('abbrv', 'string', 255); $this->hasColumn('status', 'integer', null, array('default' => NULL)); $this->hasColumn('contactperson', 'string', 255); $this->hasColumn('email', 'string', 255); $this->hasColumn('phone', 'string', 15); $this->hasColumn('country', 'string', 2, array('default' => 'UG')); $this->hasColumn('addressline1', 'string', 255); $this->hasColumn('addressline2', 'string', 255); $this->hasColumn('city', 'string', 255); $this->hasColumn('postalcode', 'string', 10); $this->hasColumn('industrycode', 'string', 15); $this->hasColumn('description', 'string', 1000); $this->hasColumn('remarks', 'string', 255); $this->hasColumn('yearstart', 'date', null, array('default' => getFirstDayOfMonth(1, date('Y')))); $this->hasColumn('yearend', 'date', null, array('default' => getLastDayOfMonth(12, date('Y')))); $this->hasColumn('ipsubnets', 'string', 255); $this->hasColumn('hoursinday', 'string', 50, array('default' => HOURS_IN_DAY)); $this->hasColumn('openinghour', 'string', 50, array('default' => '08:00 AM')); $this->hasColumn('closinghour', 'string', 50, array('default' => '05:00 PM')); $this->hasColumn('lunchduration', 'string', 50, array('default' => DEFAULT_LUNCH_DURATION)); $this->hasColumn('payspaye', 'string', 50, array('default' => 1)); $this->hasColumn('paysnssf', 'string', 50, array('default' => 1)); $this->hasColumn('nssfemployeerate', 'string', 50, array('default' => DEFAULT_NSSF_EMP)); $this->hasColumn('nssfcompanyrate', 'string', 50, array('default' => DEFAULT_NSSF_COM)); $this->hasColumn('workingdays', 'string', 50); $this->hasColumn('maxhoursperday', 'string', 50, array('default' => HOURS_IN_DAY)); $this->hasColumn('maxhoursperweek', 'string', 50, array('default' => HOURS_IN_WEEK)); $this->hasColumn('defaultuserid', 'integer', null, array('default' => NULL)); $this->hasColumn('dateapproved', 'date', null, array('default' => NULL)); $this->hasColumn('approvedbyid', 'integer', null, array('default' => NULL)); $this->hasColumn('isinvited', 'integer', null, array('default' => NULL)); $this->hasColumn('invitedbyid', 'integer', null); $this->hasColumn('hasacceptedinvite', 'integer', null, array('default' => 0)); $this->hasColumn('dateinvited', 'date'); $this->hasColumn('startdate', 'date', null, array('default' => NULL)); $this->hasColumn('enddate', 'date', null, array('default' => NULL)); $this->hasColumn('layout', 'string', 25, array('default' => getDefaultLayout())); $this->hasColumn('topbar', 'string', 25, array('default' => getDefaultTopBar())); $this->hasColumn('sidebar', 'string', 25, array('default' => getDefaultSideBar())); $this->hasColumn('colortheme', 'string', 25, array('default' => getDefaultTheme())); $this->hasColumn('showsidebar', 'string', 25, array('default' => getDefaultShowSideBar())); $this->hasColumn('logo', 'string', 255); $this->hasColumn('defaultadminname', 'string', 255, array('default' => getDefaultAdminName())); $this->hasColumn('defaultadminemail', 'string', 255, array('default' => getDefaultAdminEmail())); $this->hasColumn('currencysymbol', 'string', 15, array('default' => getCountryCurrencySymbol())); $this->hasColumn('currencycode', 'string', 15, array('default' => getCountryCurrencyCode())); $this->hasColumn('currencydecimalplaces', 'string', 15, array('default' => getCurrencyDecimalPlaces())); $this->hasColumn('numberdecimalplaces', 'string', 15, array('default' => getNumberDecimalPlaces())); $this->hasColumn('countryisocode', 'string', 15, array('default' => getCountryCode())); $this->hasColumn('phonemaxlength', 'string', 15, array('default' => getMaxPhoneLength())); $this->hasColumn('phoneminlength', 'string', 15, array('default' => getMinPhoneLength())); $this->hasColumn('nationalidminlength', 'string', 15, array('default' => getNationalIDMaxLength())); $this->hasColumn('nationalidmaxlength', 'string', 15, array('default' => getNationalIDMinLength())); $this->hasColumn('countryphonecode', 'string', 15, array('default' => getDefaultPhoneCode())); $this->hasColumn('timezone', 'string', 255, array('default' => getTimeZine())); }
// determine default dates - start/end based on interval day/week/month // start will be at 00:00 at the beginning of the day/week/month // end will be at 23:59 at the end of day // $date[0] = year, 1 = month, 2 = day $date = explode('-', $vars['date']); switch ($vars['interval']) { case 'day': $start_date = $end_date = $vars['date']; break; case 'week': // need to adjust start_date to be the beginning of the week $start_ts = strtotime($vars['date']); $start_ts -= date("w", $start_ts) * 60 * 60 * 24; $end_ts = $start_ts + 6 * 60 * 60 * 24; $start_date = date('Y-m-d', $start_ts); $end_date = date('Y-m-d', $end_ts); break; case 'month': default: $start_date = $date[0] . '-' . $date[1] . '-1'; $end_date = $date[0] . '-' . $date[1] . '-' . getLastDayOfMonth($date[1], $date[0]); break; } // start/end date echo '<div class="mbm">' . elgg_echo('event_calendar:start_date') . "<br>"; echo elgg_view('input/date', array('name' => 'start_date', 'value' => $start_date, 'style' => 'width: 120px')); echo '</div>'; echo '<div class="mbl">' . elgg_echo('event_calendar:end_date') . "<br>"; echo elgg_view('input/date', array('name' => 'end_date', 'value' => $end_date, 'style' => 'width: 120px;')); echo '</div>'; echo elgg_view('input/submit', array('value' => elgg_echo('event_calendar:export')));
function event_calendar_generate_listing_params($page_type, $container_guid, $original_start_date, $display_mode, $filter, $region = '-') { $event_calendar_listing_format = elgg_get_plugin_setting('listing_format', 'event_calendar'); $event_calendar_spots_display = trim(elgg_get_plugin_setting('spots_display', 'event_calendar')); $event_calendar_first_date = trim(elgg_get_plugin_setting('first_date', 'event_calendar')); $event_calendar_last_date = trim(elgg_get_plugin_setting('last_date', 'event_calendar')); if (!$original_start_date) { $original_start_date = date('Y-m-d'); } if ($event_calendar_first_date && $original_start_date < $event_calendar_first_date) { $original_start_date = $event_calendar_first_date; } if ($event_calendar_last_date && $original_start_date > $event_calendar_last_date) { $original_start_date = $event_calendar_first_date; } if ($event_calendar_listing_format == 'paged') { $start_ts = strtotime($original_start_date); $start_date = $original_start_date; if ($event_calendar_last_date) { $end_ts = strtotime($event_calendar_last_date); } else { // set to a large number $end_ts = 2000000000; } $mode = 'paged'; } else { // the default interval is one month $day = 60 * 60 * 24; $week = 7 * $day; $month = 31 * $day; $mode = trim($display_mode); if (!$mode) { $mode = 'month'; } if ($mode == "day") { $start_date = $original_start_date; $end_date = $start_date; $start_ts = strtotime($start_date); $end_ts = strtotime($end_date) + $day - 1; } else { if ($mode == "week") { // need to adjust start_date to be the beginning of the week $start_ts = strtotime($original_start_date); $start_ts -= date("w", $start_ts) * $day; $end_ts = $start_ts + 6 * $day; $start_date = date('Y-m-d', $start_ts); $end_date = date('Y-m-d', $end_ts); } else { $start_ts = strtotime($original_start_date); $month = date('m', $start_ts); $year = date('Y', $start_ts); $start_date = $year . '-' . $month . '-1'; $end_date = $year . '-' . $month . '-' . getLastDayOfMonth($month, $year); } } if ($event_calendar_first_date && $start_date < $event_calendar_first_date) { $start_date = $event_calendar_first_date; } if ($event_calendar_last_date && $end_date > $event_calendar_last_date) { $end_date = $event_calendar_last_date; } $start_ts = strtotime($start_date); if ($mode == "day") { $end_ts = strtotime($end_date) + $day - 1; $subtitle = elgg_echo('event_calendar:day_label') . ': ' . date('j F Y', strtotime($start_date)); } else { if ($mode == "week") { // KJ - fix for end date bug //$end_ts = $start_ts + 6*$day; $end_ts = $start_ts + 7 * $day; $subtitle = elgg_echo('event_calendar:week_label') . ': ' . date('j F', $start_ts) . ' - ' . date('j F Y', $end_ts); } else { // KJ - fix for end date bug //$end_ts = strtotime($end_date); $end_ts = strtotime($end_date) + 24 * 60 * 60 - 1; $subtitle = date('F Y', $start_ts); } } } $current_user_guid = elgg_get_logged_in_user_guid(); $access_status = elgg_get_ignore_access(); if ($page_type == 'owner') { $container = get_entity($container_guid); if (elgg_instanceof($container, 'user')) { $auth_token = get_input('auth_token'); if ($auth_token) { $secret_key = event_calendar_get_secret_key(); if ($secret_key && $auth_token === sha1($container->username . $secret_key)) { elgg_set_ignore_access(TRUE); } } if ($container->canEdit()) { $user_guid = $container_guid; $group_guid = 0; } else { register_error('event_calendar:owner:permissions_error'); forward(); exit; } } else { register_error('event_calendar:owner:permissions_error'); forward(); exit; } } else { $user_guid = $current_user_guid; $group_guid = $container_guid; } $offset = get_input('offset'); $limit = get_input('limit', 15); if ($event_calendar_spots_display == 'yes') { if (!$filter) { $filter = 'open'; } } else { if (!$filter) { $filter = 'all'; } } if ($filter == 'all') { $count = event_calendar_get_events_between($start_ts, $end_ts, true, $limit, $offset, $container_guid, $region); $events = event_calendar_get_events_between($start_ts, $end_ts, false, $limit, $offset, $container_guid, $region); } else { if ($filter == 'open') { $count = event_calendar_get_open_events_between($start_ts, $end_ts, true, $limit, $offset, $container_guid, $region); $events = event_calendar_get_open_events_between($start_ts, $end_ts, false, $limit, $offset, $container_guid, $region); } else { if ($filter == 'friends') { $count = event_calendar_get_events_for_friends_between($start_ts, $end_ts, true, $limit, $offset, $user_guid, $container_guid, $region); $events = event_calendar_get_events_for_friends_between($start_ts, $end_ts, false, $limit, $offset, $user_guid, $container_guid, $region); } else { if ($filter == 'mine') { $count = event_calendar_get_events_for_user_between2($start_ts, $end_ts, true, $limit, $offset, $user_guid, $container_guid, $region); $events = event_calendar_get_events_for_user_between2($start_ts, $end_ts, false, $limit, $offset, $user_guid, $container_guid, $region); } } } } $vars = array('original_start_date' => $original_start_date, 'start_date' => $start_date, 'end_date' => $end_date, 'first_date' => $event_calendar_first_date, 'last_date' => $event_calendar_last_date, 'mode' => $mode, 'events' => $events, 'count' => $count, 'offset' => $offset, 'limit' => $limit, 'group_guid' => $group_guid, 'filter' => $filter, 'region' => $region, 'listing_format' => $event_calendar_listing_format); $content = elgg_view('event_calendar/show_events', $vars); if ($page_type == 'owner') { $filter_override = ''; } else { $filter_override = elgg_view('event_calendar/filter_menu', $vars); } if ($event_calendar_listing_format == 'paged') { $title = elgg_echo('event_calendar:upcoming_events_title'); } else { if ($page_type == 'group') { $title = elgg_echo('event_calendar:group') . ' (' . $subtitle . ')'; } else { $title = elgg_echo('event_calendar:listing_title:' . $filter) . ' (' . $subtitle . ')'; } } $params = array('title' => $title, 'content' => $content, 'filter_override' => $filter_override); elgg_set_ignore_access($access_status); return $params; }
/** * Generates server traffic bar * * @param iMSCP_pTemplate $tpl iMSCP_pTemplate instance * @return void */ function admin_generateServerTrafficInfo($tpl) { $cfg = iMSCP_Registry::get('config'); $trafficLimitBytes = intval($cfg['SERVER_TRAFFIC_LIMIT']) * 1048576; $trafficWarningBytes = intval($cfg['SERVER_TRAFFIC_WARN']) * 1048576; if (!$trafficWarningBytes) { $trafficWarningBytes = $trafficLimitBytes; } // Get server traffic usage value in bytes for the current month $stmt = exec_query(' SELECT IFNULL((SUM(bytes_in) + SUM(bytes_out)), 0) AS serverTrafficUsage FROM server_traffic WHERE traff_time BETWEEN ? AND ? ', array(getFirstDayOfMonth(), getLastDayOfMonth())); if ($stmt->rowCount()) { $row = $stmt->fetchRow(); $trafficUsageBytes = $row['serverTrafficUsage']; } else { $trafficUsageBytes = 0; } // Get traffic usage in percent $trafficUsagePercent = make_usage_vals($trafficUsageBytes, $trafficLimitBytes); if ($trafficLimitBytes) { $trafficMessage = tr('%1$s%% [%2$s of %3$s]', $trafficUsagePercent, bytesHuman($trafficUsageBytes), bytesHuman($trafficLimitBytes)); } else { $trafficMessage = tr('%1$s%% [%2$s of unlimited]', $trafficUsagePercent, bytesHuman($trafficUsageBytes)); } // Warning message about traffic if ($trafficUsageBytes && ($trafficWarningBytes && $trafficUsageBytes > $trafficWarningBytes || $trafficLimitBytes && $trafficUsageBytes > $trafficLimitBytes)) { set_page_message(tr('You are exceeding the monthly server traffic limit.'), 'static_warning'); } $tpl->assign(array('TRAFFIC_WARNING' => $trafficMessage, 'TRAFFIC_PERCENT' => $trafficUsagePercent)); }
function runBreakdown($user_pref) { //grab time $time = grab_timeframe(); //get breakdown pref $mysql['user_id'] = mysql_real_escape_string($_SESSION['user_id']); $user_sql = "SELECT \tuser_time_register,\n\t\t\t\t\t\t\t\tuser_pref_breakdown,\n\t\t\t\t\t\t\t\tuser_pref_chart,\n\t\t\t\t\t\t\t\tuser_pref_show\n\t\t\t\t\t FROM 202_users LEFT JOIN 202_users_pref USING (user_id)\n\t\t\t\t\t WHERE 202_users.user_id='" . $mysql['user_id'] . "'"; $user_result = _mysql_query($user_sql); //($user_sql); $user_row = mysql_fetch_assoc($user_result); if ($user_row['user_pref_show'] == 'all') { $click_flitered = ''; } if ($user_row['user_pref_show'] == 'real') { $click_filtered = " AND click_filtered='0' "; } if ($user_row['user_pref_show'] == 'filtered') { $click_filtered = " AND click_filtered='1' "; } if ($user_row['user_pref_show'] == 'leads') { $click_filtered = " AND click_lead='1' "; } //breakdown should be hour, day, month, or year. $breakdown = $user_row['user_pref_breakdown']; $pref_chart = $user_row['user_pref_chart']; //first delete old report $breakdown_sql = "DELETE FROM 202_sort_breakdowns WHERE user_id='" . $mysql['user_id'] . "'"; $breakdown_result = _mysql_query($breakdown_sql); //($breakdown_sql); //find where to start from. $start = $time['from']; $end = $time['to']; //make sure the start isn't past this users registration time, and likewise, make sure END isn't past today, else theses will try to grab reports for dates that do not exists slowing down mysql doing reports for nothing. if ($user_row['user_time_register'] > $start) { $start = $user_row['user_time_register']; } if (time() < $end) { $end = time(); } $x = 0; while ($end > $start) { if ($breakdown == 'hour' || empty($breakdown)) { $from = mktime(date('G', $end), 0, 0, date('m', $end), date('d', $end), date('y', $end)); $to = mktime(date('G', $end), 59, 59, date('m', $end), date('d', $end), date('y', $end)); $end = $end - 3600; } elseif ($breakdown == 'day') { $from = mktime(0, 0, 0, date('m', $end), date('d', $end), date('y', $end)); $to = mktime(23, 59, 59, date('m', $end), date('d', $end), date('y', $end)); $end = $end - 86400; } elseif ($breakdown == 'month') { $from = mktime(0, 0, 0, date('m', $end), 1, date('y', $end)); $to = mktime(23, 59, 59, date('m', $end), @getLastDayOfMonth(date('m', $end)), date('y', $end)); $end = $end - 2629743; } elseif ($breakdown == 'year') { $from = mktime(0, 0, 0, 1, 1, date('y', $end)); $to = mktime(23, 59, 59, @getLastDayOfMonth(date('m', $end)), 1, 12, date('y', $end)); $end = $end - 31556926; } $mysql['from'] = mysql_real_escape_string($from); $mysql['to'] = mysql_real_escape_string($to); //build query $command = "SELECT COUNT(*) AS clicks, AVG(click_cpc) AS avg_cpc, SUM(click_lead) AS leads, SUM(click_lead * click_payout) AS income FROM 202_clicks "; $db_table = "202_clicks"; $pref_time = false; if ($user_pref == true) { $pref_adv = true; $command = $command . " LEFT JOIN 202_clicks_advance USING (click_id) LEFT JOIN 202_clicks_site USING (click_id) "; } else { $pref_adv = false; } $command = $command . " LEFT JOIN 202_aff_campaigns ON (202_clicks.aff_campaign_id = 202_aff_campaigns.aff_campaign_id) LEFT JOIN 202_aff_networks USING (aff_network_id)"; $pref_show = false; $pref_order = " AND (click_alp = '1' OR (aff_campaign_deleted='0' AND aff_network_deleted='0')) {$click_filtered} AND click_time > " . $mysql['from'] . " AND click_time <= " . $mysql['to']; $offset = false; $pref_limit = false; $count = false; $query = query($command, $db_table, $pref_time, $pref_adv, $pref_show, $pref_order, $offset, $pref_limit, $count); $click_sql = $query['click_sql']; $click_result = _mysql_query($click_sql); //($click_sql); $click_row = mysql_fetch_assoc($click_result); //get the stats $clicks = 0; $clicks = $click_row['clicks']; $total_clicks = $total_clicks + $clicks; //avg cpc and cost $avg_cpc = 0; $avg_cpc = $click_row['avg_cpc']; $cost = 0; $cost = $clicks * $avg_cpc; $total_cost = $total_cost + $cost; $total_avg_cpc = @round($total_cost / $total_clicks, 5); //leads $leads = 0; $leads = $click_row['leads']; $total_leads = $total_leads + $leads; //signup ratio $su_ratio - 0; $su_ratio = @round($leads / $clicks * 100, 2); $total_su_ratio = @round($total_leads / $total_clicks * 100, 2); //were not using payout //current payout //$payout = 0; //$payout = $info_row['aff_campaign_payout']; //income $income = 0; $income = $click_row['income']; $total_income = $total_income + $income; //grab the EPC $epc = 0; $epc = @round($income / $clicks, 2); $total_epc = @round($total_income / $total_clicks, 2); //net income $net = 0; $net = $income - $cost; $total_net = $total_income - $total_cost; //roi $roi = 0; $roi = @round($net / $cost * 100); $total_roi = @round($total_net / $total_cost); //html escape vars $mysql['clicks'] = mysql_real_escape_string($clicks); $mysql['leads'] = mysql_real_escape_string($leads); $mysql['su_ratio'] = mysql_real_escape_string($su_ratio); $mysql['epc'] = mysql_real_escape_string($epc); $mysql['avg_cpc'] = mysql_real_escape_string($avg_cpc); $mysql['income'] = mysql_real_escape_string($income); $mysql['cost'] = mysql_real_escape_string($cost); $mysql['net'] = mysql_real_escape_string($net); $mysql['roi'] = mysql_real_escape_string($roi); //insert chart $sort_breakdown_sql = "INSERT INTO 202_sort_breakdowns\n\t\t\t\t\t\t\t SET \t sort_breakdown_from='" . $mysql['from'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_to='" . $mysql['to'] . "',\n\t\t\t\t\t\t\t\t\t\t user_id='" . $mysql['user_id'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_clicks='" . $mysql['clicks'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_leads='" . $mysql['leads'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_su_ratio='" . $mysql['su_ratio'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_payout='" . $mysql['sort_breakdown_payout'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_epc='" . $mysql['epc'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_avg_cpc='" . $mysql['avg_cpc'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_income='" . $mysql['income'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_cost='" . $mysql['cost'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_net='" . $mysql['net'] . "',\n\t\t\t\t\t\t\t\t\t\t sort_breakdown_roi='" . $mysql['roi'] . "'"; $sort_breakdown_result = _mysql_query($sort_breakdown_sql); //($sort_breakdown_sql); } $breakdown_sql = "SELECT * FROM 202_sort_breakdowns WHERE user_id='" . $mysql['user_id'] . "'"; $breakdown_result = _mysql_query($breakdown_sql); //($breakdown_sql); $chartWidth = $_POST['chartWidth']; $chartHeight = 180; //find where to start from. $start = $time['from']; $end = $time['to']; //echo date('-r',$start) . '<br/>'. date('-r',$end); //make sure the start isn't past this users registration time, and likewise, make sure END isn't past today, else theses will try to grab reports for dates that do not exists slowing down mysql doing reports for nothing. if ($user_row['user_time_register'] > $start) { $start = $user_row['user_time_register']; } if (time() < $end) { $end = time(); } //cacluate the skip $x = 0; while ($start < $end) { if ($breakdown == 'hour' || empty($breakdown)) { $start = $start + 3600; } elseif ($breakdown == 'day') { $start = $start + 86400; } elseif ($breakdown == 'month') { $start = $start + 2629743; } elseif ($breakdown == 'year') { $start = $start + 31556926; } $x++; } $skip = 0; if ($breakdown == hour) { while ($x > 9) { $skip++; $x = $x - 9; } } else { while ($x > 14) { $skip++; $x = $x - 14; } } /* THIS IS A NET INCOME BAR GRAPH */ if ($pref_chart == 'profitloss') { //start the PHP multi-dimensional array and create the region titles $chart['chart_data'][0][0] = ""; $chart['chart_data'][1][0] = "Income"; $chart['chart_data'][2][0] = "Cost"; $chart['chart_data'][3][0] = "Net"; //extract the data from the query result one row at a time for ($i = 0; $i < mysql_num_rows($breakdown_result); $i++) { //determine which column in the PHP array the current data belongs to $col = mysql_result($breakdown_result, $i, "sort_breakdown_from"); //populate the PHP array with the Year title $date = mysql_result($breakdown_result, $i, "sort_breakdown_from"); $date = date_chart($breakdown, $date); $chart['chart_data'][0][$col] = $date; //populate the PHP array with the revenue data $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_income"); $chart['chart_data'][2][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_cost"); $chart['chart_data'][3][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_net"); } $chart['series_color'] = array("70CF40", "CF4040", "409CCF", "000000"); $chart['series_gap'] = array('set_gap' => 40, 'bar_gap' => -35); $chart['chart_grid_h'] = array('alpha' => 20, 'color' => "000000", 'thickness' => 1, 'type' => "dashed"); $chart['axis_value'] = array('bold' => false, 'size' => 10); $chart['axis_category'] = array('skip' => $skip, 'bold' => false, 'size' => 10); $chart['legend_label'] = array('bold' => true, 'size' => 12); $chart['chart_pref'] = array('line_thickness' => 1, 'point_shape' => "none", 'fill_shape' => true); $chart['chart_rect'] = array('x' => 40, 'y' => 20, 'width' => $chartWidth - 60, 'height' => $chartHeight); $chart['chart_transition'] = array('type' => "scale", 'delay' => 0.5, 'duration' => 0.5, 'order' => "series"); } else { //start the PHP multi-dimensional array and create the region titles $chart['chart_data'][0][0] = ""; if ($pref_chart == 'clicks') { $chart['chart_data'][1][0] = "Clicks"; } elseif ($pref_chart == 'leads') { $chart['chart_data'][1][0] = "Leads"; } elseif ($pref_chart == 'su_ratio') { $chart['chart_data'][1][0] = "Signup Ratio"; } elseif ($pref_chart == 'payout') { $chart['chart_data'][1][0] = "Payout"; } elseif ($pref_chart == 'epc') { $chart['chart_data'][1][0] = "EPC"; } elseif ($pref_chart == 'cpc') { $chart['chart_data'][1][0] = "Avg CPC"; } elseif ($pref_chart == 'income') { $chart['chart_data'][1][0] = "Income"; } elseif ($pref_chart == 'cost') { $chart['chart_data'][1][0] = "Cost"; } elseif ($pref_chart == 'net') { $chart['chart_data'][1][0] = "Net"; } elseif ($pref_chart == 'roi') { $chart['chart_data'][1][0] = "ROI"; } //extract the data from the query result one row at a time for ($i = 0; $i < mysql_num_rows($breakdown_result); $i++) { //determine which column in the PHP array the current data belongs to $col = mysql_result($breakdown_result, $i, "sort_breakdown_from"); //populate the PHP array with the Year title $date = mysql_result($breakdown_result, $i, "sort_breakdown_from"); $date = date_chart($breakdown, $date); $chart['chart_data'][0][$col] = $date; //populate the PHP array with the revenue data if ($pref_chart == 'clicks') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_clicks"); } elseif ($pref_chart == 'leads') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_leads"); } elseif ($pref_chart == 'su_ratio') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_su_ratio"); } elseif ($pref_chart == 'payout') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_payout"); } elseif ($pref_chart == 'epc') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_epc"); } elseif ($pref_chart == 'cpc') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_avg_cpc"); } elseif ($pref_chart == 'income') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_income"); } elseif ($pref_chart == 'cost') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_cost"); } elseif ($pref_chart == 'net') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_net"); } elseif ($pref_chart == 'roi') { $chart['chart_data'][1][$col] = mysql_result($breakdown_result, $i, "sort_breakdown_roi"); } } //$chart[ 'series_color' ] = array ( "003399"); $chart['series_color'] = array("000000"); $chart['chart_type'] = "Line"; //$chart[ 'chart_transition' ] = array ( 'type'=>"dissolve", 'delay'=>.5, 'duration'=>.5, 'order'=>"series" ); $chart['chart_grid_h'] = array('alpha' => 20, 'color' => "000000", 'thickness' => 1, 'type' => "dashed"); } $chart['chart_pref'] = array('line_thickness' => 1, 'point_shape' => "circle", 'fill_shape' => false); $chart['axis_value'] = array('bold' => false, 'size' => 10); $chart['axis_category'] = array('skip' => $skip, 'bold' => false, 'size' => 10); $chart['legend_label'] = array('bold' => true, 'size' => 12); $chart['chart_rect'] = array('x' => 40, 'y' => 20, 'width' => $chartWidth - 60, 'height' => $chartHeight); showChart($chart, $chartWidth - 20, $chartHeight + 40); ?> <div style="padding: 3px 0px;"></div><?php }
public function init() { parent::init(); $current_timestamp = strtotime('now'); $now_iso = date('Y-m-d H:i:s', $current_timestamp); $this->view->now_iso = $now_iso; //debugMessage('now '.$now_iso.'-'.$current_timestamp); $onehourago_timestamp = strtotime('-1 hour'); $onehourago_iso = date('Y-m-d H:i:s', $onehourago_timestamp); $this->view->onehourago_iso = $onehourago_iso; $this->view->onehourago_timestamp = $onehourago_timestamp; // debugMessage('now '.$onehourago_iso.'-'.$onehourago_timestamp); $sixhourago_timestamp = strtotime('-6 hour'); $sixhourago_iso = date('Y-m-d H:i:s', $sixhourago_timestamp); $this->view->sixhourago_iso = $sixhourago_iso; $this->view->sixhourago_timestamp = $sixhourago_timestamp; $twelvehourago_timestamp = strtotime('-12 hour'); $twelvehourago_iso = date('Y-m-d H:i:s', $twelvehourago_timestamp); $this->view->twelvehourago_timestamp = $twelvehourago_timestamp; $this->view->twelvehourago_iso = $twelvehourago_iso; // debugMessage($logged_today_sql); $today_iso = date('Y-m-d'); $today = changeMySQLDateToPageFormat($today_iso); $this->view->today_iso = $today_iso; //debugMessage('today '.$today_iso); $today_iso_short = date('M j', $current_timestamp); $yestday_iso = date('Y-m-d', strtotime('1 day ago')); $yestday = changeMySQLDateToPageFormat($yestday_iso); $this->view->yestday_iso = $yestday_iso; //debugMessage('yesterday '.$yestday_iso); $yestday_iso_short = date('M j', strtotime($yestday_iso)); $weekday = date("N"); // monday of week $mondaythisweek_iso = date('Y-m-d', strtotime('monday this week')); $mondaythisweek = changeMySQLDateToPageFormat($mondaythisweek_iso); if ($weekday == 1) { $mondaythisweek_iso = $today_iso; $mondaythisweek = $today; } if ($weekday == 7) { $mondaythisweek_iso = date('Y-m-d', strtotime('monday last week')); $mondaythisweek = changeMySQLDateToPageFormat($mondaythisweek_iso); } $this->view->mondaythisweek_iso = $mondaythisweek_iso; //debugMessage('monday this week '.$mondaythisweek_iso); // sunday of week $sundaythisweek_iso = date('Y-m-d', strtotime('sunday this week')); $sundaythisweek = changeMySQLDateToPageFormat($sundaythisweek_iso); if ($weekday == 1) { $sundaythisweek_iso = date('Y-m-d', strtotime('today + 7 days')); $sundaythisweek = changeMySQLDateToPageFormat($sundaythisweek_iso); } if ($weekday == 7) { $sundaythisweek_iso = $today_iso; $sundaythisweek = $today; } $this->view->sundaythisweek_iso = $sundaythisweek_iso; // debugMessage('sunday this week '.$sundaythisweek_iso); // monday last week $mondaylastweek_iso = date('Y-m-d', strtotime('-7 days', strtotime($mondaythisweek_iso))); //debugMessage('monday last week '.$mondaylastweek_iso); $this->view->mondaylastweek_iso = $mondaylastweek_iso; // sunday last week $sundaylastweek_iso = date('Y-m-d', strtotime('-7 days', strtotime($sundaythisweek_iso))); // debugMessage('sunday last week '.$sundaylastweek_iso); $this->view->sundaylastweek_iso = $sundaylastweek_iso; // firstday this month $firstdayofthismonth_iso = getFirstDayOfCurrentMonth(); //debugMessage('1st day this month '.$firstdayofthismonth_iso); $this->view->firstdayofthismonth_iso = $firstdayofthismonth_iso; // lastday this month $lastdayofthismonth_iso = getLastDayOfCurrentMonth(); //debugMessage('last day this month '.$lastdayofthismonth_iso); $this->view->lastdayofthismonth_iso = $lastdayofthismonth_iso; // firstday last month $firstdayoflastmonth_iso = getFirstDayOfMonth(date('m') - 1, date('Y')); //debugMessage('1st day last month '.$firstdayoflastmonth_iso); $this->view->firstdayoflastmonth_iso = $firstdayoflastmonth_iso; // lastday last month $lastdayoflastmonth_iso = getLastDayOfMonth(date('m') - 1, date('Y')); //debugMessage('last day last month '.$lastdayoflastmonth_iso); $this->view->lastdayoflastmonth_iso = $lastdayoflastmonth_iso; // firstday 2 month ago $firstdayof2monthago_iso = getFirstDayOfMonth(date('m') - 2, date('Y')); //debugMessage('1st day 2 month ago '.$firstdayof2monthago_iso); $this->view->firstdayof2monthago_iso = $firstdayof2monthago_iso; // lastday 2 month ago $lastdayof2monthago_iso = getLastDayOfMonth(date('m') - 2, date('Y')); //debugMessage('last day last month '.$lastdayof2monthago_iso); $this->view->lastdayof2monthago_iso = $lastdayof2monthago_iso; // firstday 3 month ago $firstdayof3monthago_iso = getFirstDayOfMonth(date('m') - 3, date('Y')); //debugMessage('1st day 3 month ago '.$firstdayof3monthago_iso); $this->view->firstdayof3monthago_iso = $firstdayof3monthago_iso; // lastday 3 month ago $lastdayof3monthago_iso = getLastDayOfMonth(date('m') - 3, date('Y')); //debugMessage('last day last month '.$lastdayof3monthago_iso); $this->view->lastdayof3monthago_iso = $lastdayof3monthago_iso; // firstday this year $firstdayofyear_iso = getFirstDayOfMonth(1, date('Y')); //debugMessage('1st day this year '.$firstdayofyear_iso); $this->view->firstdayofyear_iso = $firstdayofyear_iso; // lastday this year $lastdayofyear_iso = getLastDayOfMonth(12, date('Y')); //debugMessage('last day this year '.$lastdayofyear_iso); $this->view->lastdayofyear_iso = $lastdayofyear_iso; // first day of month one year ago $startofmonth_oneyearago = getFirstDayOfMonth(date('m', strtotime('1 year ago')), date('Y', strtotime('1 year ago'))); $this->view->startofmonth_oneyearago = $startofmonth_oneyearago; $firstsystemday_iso = '2013-01-01'; $this->view->firstsystemday_iso = $firstsystemday_iso; }
$line = fgets($fp, 1024); eregi('<B>([0-9]*)</B>', $line, $out); $visits = $out[1]; do { $line = fgets($fp, 1024); // Finds the KBytes using regular expressions } while (!feof($fp) && !eregi('Total KBytes', $line, $out)); $line = fgets($fp, 1024); eregi('<B>([0-9]*)</B>', $line, $out); $kbytes = $out[1]; do { $line = fgets($fp, 1024); // Finds the Sites using regular expressions } while (!feof($fp) && !eregi('Unique Sites', $line, $out)); $line = fgets($fp, 1024); eregi('<B>([0-9]*)</B>', $line, $out); $sites = $out[1]; fclose($fp); } echo "{$monthn} {$year} {$hits} {$files} {$sites} {$kbytes} " . getFirstDayOfMonth($yearmonth, $year) . ' ' . getLastDayOfMonth($yearmonth, $year) . " {$pages} {$visits}\n"; //echo "$monthn $year\n"; $yearmonth--; if ($yearmonth == 0) { $yearmonth = 12; $year--; } // Year goes backwards until 2000 if ($year == 2000) { break; } }
define('DEFAULT_REGULAR_LEAVE_DAYS', 21); define('DEFAULT_SICK_LEAVE_DAYS', 4); define('HOURS_IN_DAY', 8); define('HOURS_IN_WEEK', 40); define('DEFAULT_WORKING_DAYS', '1,2,3,4,5'); define('DEFAULT_COMPANYID', 1); define('PAYEID', 2); define('NSSFID', 3); define('ADVANCE', 5); define('TPID', 9); define('DEFAULT_NSSF_EMP', 5); define('DEFAULT_NSSF_COM', 10); define('DEFAULT_LUNCH_DURATION', 1); define('DEFAULT_APPNAME_CHARS', 12); define('YEAR_START', getFirstDayOfMonth(1, date('Y'))); define('YEAR_END', getLastDayOfMonth(12, date('Y'))); function companiesRequireApproval() { $config = Zend_Registry::get("config"); return $config->system->approvalrequired == 'on' || $config->system->approvalrequired == '1' ? true : false; } function getDefaultCharsForAppName() { $config = Zend_Registry::get("config"); return $config->system->appnamechars; } function getTrialDays() { $config = Zend_Registry::get("config"); return $config->system->daysoftrial; }
$message = ""; if ($calType == $ACTION_TYPE_CALENDAR_DAY) { $startDate = standardSQLDateFromSeconds(getDayStartFromSeconds($calTime)); $endDate = standardSQLDateFromSeconds(getDayEndFromSeconds($calTime)); $message = "day"; } else { if ($calType == $ACTION_TYPE_CALENDAR_WEEK) { $firstDayOfWeek = getFirstMondayOfWeek($calTime); $lastDayOfWeek = getLastSundayOfWeek($calTime); $startDate = standardSQLDateFromSeconds(getDayStartFromSeconds($firstDayOfWeek)); $endDate = standardSQLDateFromSeconds(getDayEndFromSeconds($lastDayOfWeek)); $message = "week"; } else { if ($calType == $ACTION_TYPE_CALENDAR_MONTH) { $firstDayOfMonth = getFirstDayOfMonth($calTime); $lastDayOfMonth = getLastDayOfMonth($calTime); $startDate = standardSQLDateFromSeconds(getDayStartFromSeconds($firstDayOfMonth)); $endDate = standardSQLDateFromSeconds(getDayEndFromSeconds($lastDayOfMonth)); $message = "month"; } else { echo '{ "status":"error", "message":"invalid type" }'; return; } } } if ($calOption == $ACTION_TYPE_CALENDAR_OPTION_SELF && $ACTION_VALUE_USER_ID > 0) { $calOption = ' and shifts.user_id="' . $ACTION_VALUE_USER_ID . '" '; } else { $calOption = ''; } $query = 'select shifts.id, parent_id, user_id, time_begin, time_end, name, username from shifts left outer join users on shifts.user_id=users.id' . ' where shifts.parent_id!=0 ' . $calOption . ' and shifts.time_begin between "' . $startDate . '" and "' . $endDate . '" order by shifts.time_begin asc';