Example #1
0
    function get_report_count_last_month(&$out_array)
    {
        if (!$this->state) {
            return false;
        }
        $time = $this->get_last_30_days();
        $query = 'SELECT DAY(import_time) as day, COUNT(*) as count
			FROM pony_report
			WHERE (import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL ' . $time . ' SECOND))
			GROUP BY DAY(import_time)';
        $result = mysql_query($query, $this->db_link);
        if (!$result) {
            $this->state = false;
        } else {
            while ($row = mysql_fetch_assoc($result)) {
                $out_array[intval($row['day'])] = $row['count'];
            }
            return true;
        }
        return false;
    }
Example #2
0
function smarty_assign_common_vars($smarty, $pony_db)
{
    $pony_db->lock_all_tables();
    $offset_url = $pony_db->get_multi_option('offset_url', 6);
    $url_password_stats = array();
    $pony_db->get_url_password_stats($url_password_stats, $offset_url[0]);
    if (!isset($url_password_stats['ftp'])) {
        $url_password_stats['ftp'] = '0';
    }
    if (!isset($url_password_stats['ssh'])) {
        $url_password_stats['ssh'] = '0';
    }
    if (!isset($url_password_stats['http'])) {
        $url_password_stats['http'] = '0';
    }
    if (!isset($url_password_stats['https'])) {
        $url_password_stats['https'] = '0';
    }
    if (!isset($url_password_stats['rdp'])) {
        $url_password_stats['rdp'] = '0';
    }
    $url_password_stats['ftp'] += $offset_url[1];
    $url_password_stats['ssh'] += $offset_url[2];
    $url_password_stats['http'] += $offset_url[3];
    $url_password_stats['https'] += $offset_url[4];
    $url_password_stats['rdp'] += $offset_url[5];
    $pony_db->set_multi_option('offset_url', array($pony_db->get_auto_value(CPONY_FTP_TABLE), $url_password_stats['ftp'], $url_password_stats['ssh'], $url_password_stats['http'], $url_password_stats['https'], $url_password_stats['rdp']));
    $smarty->assign('total_ftp_items_count', $url_password_stats['ftp']);
    $smarty->assign('total_http_items_count', strval(intval($url_password_stats['http']) + intval($url_password_stats['https'])));
    $smarty->assign('total_cert_items_count', $pony_db->get_table_row_count(CPONY_CERT_TABLE));
    $smarty->assign('total_wallet_items_count', $pony_db->get_table_row_count(CPONY_WALLET_TABLE));
    $smarty->assign('total_email_items_count', $pony_db->get_table_row_count(CPONY_EMAIL_TABLE));
    $smarty->assign('total_email_smtp_items_count', $pony_db->get_table_row_count(CPONY_EMAIL_TABLE, "WHERE protocol='smtp'"));
    $smarty->assign('total_ssh_items_count', $url_password_stats['ssh']);
    $smarty->assign('total_rdp_items_count', $url_password_stats['rdp']);
    $smarty->assign('total_reports_count', $pony_db->get_table_row_count(CPONY_REPORT_TABLE));
    $report_sum = $pony_db->get_multi_option('data_sum', 2);
    $total_reports_size = $report_sum[1] + $pony_db->get_report_sum('', $report_sum[0]);
    $pony_db->set_multi_option('data_sum', array($pony_db->get_auto_value(CPONY_REPORT_DATA_TABLE), $total_reports_size));
    $smarty->assign('total_reports_size', $total_reports_size);
    $offset_report_duplicates = $pony_db->get_multi_option('offset_report_duplicates', 2);
    $report_duplicates = $offset_report_duplicates[1] + $pony_db->get_duplicate_report_count($offset_report_duplicates[0]);
    $smarty->assign('report_duplicates', $report_duplicates);
    $pony_db->set_multi_option('offset_report_duplicates', array($pony_db->get_auto_value(CPONY_LOG_TABLE), $report_duplicates));
    $offset_nonparsed_reports = $pony_db->get_multi_option('offset_nonparsed_reports_stats', 2);
    $total_nonparsed_reports = $offset_nonparsed_reports[1] + $pony_db->get_table_row_count(CPONY_REPORT_TABLE, "WHERE report_id>='" . mysql_real_escape_string($offset_nonparsed_reports[0]) . "' AND parsed='0'");
    $smarty->assign('total_nonparsed_reports', $total_nonparsed_reports);
    $pony_db->set_multi_option('offset_nonparsed_reports_stats', array($pony_db->get_auto_value(CPONY_REPORT_TABLE), $total_nonparsed_reports));
    $offset_nonparsed_reports_sum = $pony_db->get_multi_option('offset_nonparsed_reports_sum', 2);
    $total_nonparsed_reports_sum = $offset_nonparsed_reports_sum[1] + $pony_db->get_report_sum_linked("WHERE parsed='0'", $offset_nonparsed_reports_sum[0]);
    $smarty->assign('total_nonparsed_report_size', $total_nonparsed_reports_sum);
    $pony_db->set_multi_option('offset_nonparsed_reports_sum', array($pony_db->get_auto_value(CPONY_REPORT_TABLE), $total_nonparsed_reports_sum));
    $smarty->assign('total_nonparsed_report_size', $total_nonparsed_reports_sum);
    $smarty->assign('total_ftp_table_size', $pony_db->get_table_size(CPONY_FTP_TABLE));
    $smarty->assign('total_report_table_size', $pony_db->get_table_size(CPONY_REPORT_TABLE) + $pony_db->get_table_size(CPONY_REPORT_DATA_TABLE));
    $smarty->assign('total_log_table_size', $pony_db->get_table_size(CPONY_LOG_TABLE));
    $smarty->assign('total_cert_table_size', $pony_db->get_table_size(CPONY_CERT_TABLE));
    $smarty->assign('total_wallet_table_size', $pony_db->get_table_size(CPONY_WALLET_TABLE));
    $smarty->assign('total_email_table_size', $pony_db->get_table_size(CPONY_EMAIL_TABLE));
    $offset_log_events_count = $pony_db->get_multi_option('offset_log_events_count', 2);
    $log_events_count = $offset_log_events_count[1] + $pony_db->get_table_row_count(CPONY_LOG_TABLE, "WHERE log_id>='" . mysql_real_escape_string($offset_log_events_count[0]) . "' AND (log_source<>'" . mysql_real_escape_string(CLOG_SOURCE_LOGIN) . "')");
    $smarty->assign('log_events_count', $log_events_count);
    $pony_db->set_multi_option('offset_log_events_count', array($pony_db->get_auto_value(CPONY_LOG_TABLE), $log_events_count));
    $smarty->assign('server_time', mysql_now_date());
    $smarty->assign('db_size', $pony_db->get_db_size());
    $offset_ftp = $pony_db->get_multi_option('offset_ftp_last', 3);
    list($offset_ftp[0], $new_ftp_last_24_hours) = $pony_db->get_offset_value_count('WHERE ftp_id>=\'' . mysql_real_escape_string($offset_ftp[0]) . '\' AND (url_type=\'ftp\' OR url_type=\'ssh\') AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 1 DAY)', 'ftp_id', CPONY_FTP_TABLE);
    list($offset_ftp[1], $new_ftp_last_hour) = $pony_db->get_offset_value_count('WHERE ftp_id>=\'' . mysql_real_escape_string($offset_ftp[1]) . '\' AND (url_type=\'ftp\' OR url_type=\'ssh\') AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 1 HOUR)', 'ftp_id', CPONY_FTP_TABLE);
    list($offset_ftp[2], $new_ftp_last_10_minutes) = $pony_db->get_offset_value_count('WHERE ftp_id>=\'' . mysql_real_escape_string($offset_ftp[2]) . '\' AND (url_type=\'ftp\' OR url_type=\'ssh\') AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 10 MINUTE)', 'ftp_id', CPONY_FTP_TABLE);
    $smarty->assign('new_ftp_last_24_hours', $new_ftp_last_24_hours);
    $smarty->assign('new_ftp_last_hour', $new_ftp_last_hour);
    $smarty->assign('new_ftp_last_10_minutes', $new_ftp_last_10_minutes);
    $pony_db->set_multi_option('offset_ftp_last', array($offset_ftp[0], $offset_ftp[1], $offset_ftp[2]));
    $offset_http = $pony_db->get_multi_option('offset_http_last', 3);
    list($offset_http[0], $new_http_last_24_hours) = $pony_db->get_offset_value_count('WHERE ftp_id>=\'' . mysql_real_escape_string($offset_http[0]) . '\' AND (url_type=\'http\' OR url_type=\'https\') AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 1 DAY)', 'ftp_id', CPONY_FTP_TABLE);
    list($offset_http[1], $new_http_last_hour) = $pony_db->get_offset_value_count('WHERE ftp_id>=\'' . mysql_real_escape_string($offset_http[1]) . '\' AND (url_type=\'http\' OR url_type=\'https\') AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 1 HOUR)', 'ftp_id', CPONY_FTP_TABLE);
    list($offset_http[2], $new_http_last_10_minutes) = $pony_db->get_offset_value_count('WHERE ftp_id>=\'' . mysql_real_escape_string($offset_http[2]) . '\' AND (url_type=\'http\' OR url_type=\'https\') AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 10 MINUTE)', 'ftp_id', CPONY_FTP_TABLE);
    $smarty->assign('new_http_last_24_hours', $new_http_last_24_hours);
    $smarty->assign('new_http_last_hour', $new_http_last_hour);
    $smarty->assign('new_http_last_10_minutes', $new_http_last_10_minutes);
    $pony_db->set_multi_option('offset_http_last', array($offset_http[0], $offset_http[1], $offset_http[2]));
    $offset_reports = $pony_db->get_multi_option('offset_reports_last', 3);
    list($offset_reports[0], $new_reports_last_24_hours) = $pony_db->get_offset_value_count('WHERE report_id>=\'' . mysql_real_escape_string($offset_reports[0]) . '\' AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 1 DAY)', 'report_id', CPONY_REPORT_TABLE);
    list($offset_reports[1], $new_reports_last_hour) = $pony_db->get_offset_value_count('WHERE report_id>=\'' . mysql_real_escape_string($offset_reports[1]) . '\' AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 1 HOUR)', 'report_id', CPONY_REPORT_TABLE);
    list($offset_reports[2], $new_reports_last_10_minutes) = $pony_db->get_offset_value_count('WHERE report_id>=\'' . mysql_real_escape_string($offset_reports[2]) . '\' AND import_time >= DATE_SUB(\'' . mysql_real_escape_string(mysql_now_date()) . '\',INTERVAL 10 MINUTE)', 'report_id', CPONY_REPORT_TABLE);
    $smarty->assign('new_reports_last_24_hours', $new_reports_last_24_hours);
    $smarty->assign('new_reports_last_hour', $new_reports_last_hour);
    $smarty->assign('new_reports_last_10_minutes', $new_reports_last_10_minutes);
    $pony_db->set_multi_option('offset_reports_last', array($offset_reports[0], $offset_reports[1], $offset_reports[2]));
    $cert_last_import = $pony_db->get_last_cert_date();
    if ($cert_last_import !== false) {
        $smarty->assign('cert_last_import', $cert_last_import);
    }
    $wallet_last_import = $pony_db->get_last_wallet_date();
    if ($wallet_last_import !== false) {
        $smarty->assign('wallet_last_import', $wallet_last_import);
    }
    $pony_db->unlock_all_tables();
}