<!-- put in the images you lazy bastards --> <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); include_once 'db.php'; include 'newaverages.php'; $db = new DB(); $company_id = $_GET['company_id']; $sql = "\n SELECT *\n FROM Companies\n WHERE company_id = {$company_id}"; $results = $db->execute($sql); $company_info = $results->fetch_assoc(); $averages = getAverages($company_id); ?> <!doctype html> <html lang="en"> <head> <link rel="stylesheet" href="style.css"> </head> <body> <?php include 'header.php'; ?> <h1><?php
/** * Board Stats block, shows count of users online names * * @param mixed[] $parameters * 'averages' => Will calculate the daily average (posts, topics, registrations, etc) * @param int $id - not used in this block * @param boolean $return_parameters if true returns the configuration options for the block */ function sp_boardStats($parameters, $id, $return_parameters = false) { global $scripturl, $modSettings, $txt; $block_parameters = array('averages' => 'check'); if ($return_parameters) { return $block_parameters; } $averages = !empty($parameters['averages']) ? 1 : 0; loadLanguage('Stats'); // Basic totals are easy $totals = ssi_boardStats('array'); // Get the averages from the activity log, its the most recent snapshot if ($averages) { require_once SUBSDIR . '/Stats.subs.php'; $averages = getAverages(); // The number of days the forum has been up... $total_days_up = ceil((time() - strtotime($averages['date'])) / (60 * 60 * 24)); $totals += array('average_members' => comma_format(round($averages['registers'] / $total_days_up, 2)), 'average_posts' => comma_format(round($averages['posts'] / $total_days_up, 2)), 'average_topics' => comma_format(round($averages['topics'] / $total_days_up, 2)), 'average_online' => comma_format(round($averages['most_on'] / $total_days_up, 2))); } echo ' <ul class="sp_list"> <li ', sp_embed_class('portalstats'), '>', $txt['total_members'], ': <a href="', $scripturl . '?action=memberlist">', comma_format($totals['members']), '</a></li> <li ', sp_embed_class('portalstats'), '>', $txt['total_posts'], ': ', comma_format($totals['posts']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['total_topics'], ': ', comma_format($totals['topics']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['total_cats'], ': ', comma_format($totals['categories']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['total_boards'], ': ', comma_format($totals['boards']), '</li> <li ', sp_embed_class('portalstats'), '>', $txt['most_online'], ': ', comma_format($modSettings['mostOnline']), '</li> </ul>'; // And the averages if required if ($averages) { echo ' <hr /> <ul class="sp_list"> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_posts'], ': ', comma_format($totals['average_posts']), '</li> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_topics'], ': ', comma_format($totals['average_topics']), '</li> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_members'], ': ', comma_format($totals['average_members']), '</li> <li ', sp_embed_class('portalaverages'), '>', $txt['sp-average_online'], ': ', comma_format($totals['average_online']), '</li> </ul>'; } }
/** * Load some general statistics of the forum */ public function loadGeneralStatistics() { global $scripturl, $modSettings, $context; require_once SUBSDIR . '/Boards.subs.php'; // Get averages... $averages = getAverages(); // This would be the amount of time the forum has been up... in days... $total_days_up = ceil((time() - strtotime($averages['date'])) / (60 * 60 * 24)); $date = strftime('%Y-%m-%d', forum_time(false)); // General forum stats $context['general_statistics']['left'] = array('total_members' => allowedTo('view_mlist') ? '<a href="' . $scripturl . '?action=memberlist">' . comma_format($modSettings['totalMembers']) . '</a>' : comma_format($modSettings['totalMembers']), 'total_posts' => comma_format($modSettings['totalMessages']), 'total_topics' => comma_format($modSettings['totalTopics']), 'total_cats' => comma_format(numCategories()), 'users_online' => comma_format(onlineCount()), 'most_online' => array('number' => comma_format($modSettings['mostOnline']), 'date' => standardTime($modSettings['mostDate'])), 'users_online_today' => comma_format(mostOnline($date))); if (!empty($modSettings['hitStats'])) { $context['general_statistics']['left'] += array('num_hits' => comma_format($averages['hits'], 0)); } $context['general_statistics']['right'] = array('average_members' => comma_format(round($averages['registers'] / $total_days_up, 2)), 'average_posts' => comma_format(round($averages['posts'] / $total_days_up, 2)), 'average_topics' => comma_format(round($averages['topics'] / $total_days_up, 2)), 'total_boards' => comma_format(countBoards('all', array('include_redirects' => false))), 'latest_member' => &$context['common_stats']['latest_member'], 'average_online' => comma_format(round($averages['most_on'] / $total_days_up, 2)), 'emails_sent' => comma_format(round($averages['email'] / $total_days_up, 2))); if (!empty($modSettings['hitStats'])) { $context['general_statistics']['right'] += array('average_hits' => comma_format(round($averages['hits'] / $total_days_up, 2))); } }
<?php include 'initialize.php'; include 'payload.php'; include 'newaverages.php'; $db = new DB(); $search = isset($_GET['search']) ? $_GET['search'] : null; if ($search === '') { $sql = "SELECT * FROM Companies"; } else { $sql = "SELECT * FROM Companies WHERE Name LIKE '%{$search}%'"; } $results = $db->execute($sql); Payload::$values = []; while ($row = $results->fetch_assoc()) { $avg = getAverages($row['company_id']); $a = []; $a['Name'] = $row['Name']; $a['Industry'] = $row['Industry']; $a['Website'] = $row['Website']; $a['Logo'] = $row['Logo']; $a['Id'] = $row['company_id']; $a['Average'] = $avg['Average']; // print_r($a); array_push(Payload::$values, $a); } $payload = json_encode(Payload::$values); ?> <!DOCTYPE html> <html>
<?php error_reporting(E_ALL); ini_set('display_errors', 'on'); include 'initialize.php'; include 'newaverages.php'; $db = new DB(); $sql = "SELECT company_id FROM Companies"; $results = $db->execute($sql); // while ($row = $results->fetch_assoc()) { // $result = getAverages($row['company_id']); // print_r($result); // } print_r(getAverages(1));