Esempio n. 1
0
    function showCallsTab() {

        $this->getHistory();

        if ($this->calls) {
            $chapter=sprintf(_("Call Statistics"));
            $this->showChapter($chapter);

            $calltime=normalizeTime($this->duration);

            print "
            <tr>
              <td class=cell>";
                if ($this->cdrtool_address) {
                    print "<a href=$this->cdrtool_address target=cdrtool>";
                    print _("Summary");
                    print "</a>";
                } else {
                    print _("Usage Data");
                }
                print "
              </td>
              <td class=cell>";
              printf (_("%s calls /  %s /  %s / %.2f %s"), $this->calls, $calltime,$this->trafficPrint,$this->price,$this->currency);
              print "

              </td>
            </tr>
            ";

            print "
            <tr>
              <td>";
                print _("First / Last Call");
                print "
              </td>
              <td>
                $this->firstCall / $this->lastCall
              </td>
            </tr>
            ";
        }

        if ($this->enable_thor) {
            $cdr_source   = 'sipthor';
        } else {
            $cdr_source   = 'sip_trace';
        }

        if (count($this->calls_received)) {
            $chapter=sprintf(_("Incoming"));
            $this->showChapter($chapter);

            $j=0;
            print "<table class='table table-striped table-condensed'>";
            foreach (array_keys($this->calls_received) as $call) {
                $j++;

                $uri         = $this->calls_received[$call]['remoteParty'];
                $media="";
                foreach ($this->calls_received[$call]['media'] as $m) {
                     $media.="$m,";
                }
                $media=quoted_printable_decode($media);
                $media=rtrim($media,",");

                $duration    = normalizeTime($this->calls_received[$call]['duration']);
                $dialURI     = $this->PhoneDialURL($uri) ;
                $htmlDate    = $this->colorizeDate($this->calls_received[$call]['startTime']);
                $htmlURI     = $this->htmlURI($uri);
                $urlURI      = urlencode($this->normalizeURI($uri));

                $sessionId    = urlencode($this->calls_received[$call]['sessionId']);
                $fromTag      = urlencode($this->calls_received[$call]['fromTag']);
                $toTag        = urlencode($this->calls_received[$call]['toTag']);
                $proxyIP      = urlencode($this->calls_received[$call]['proxyIP']);
                $trace_link   = "<a href=\"javascript:void(null);\" onClick=\"return window.open('sip_trace.phtml?cdr_source=$cdr_source&callid=$sessionId&fromtag=$fromTag&totag=$toTag&proxyIP=$proxyIP', 'Server Logs',
                'toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1000,height=600')\">Server Logs</a>";

                if (!$this->calls_received[$call]['duration']) {
                    $htmlURI = "<font color=red>$htmlURI</font>";
                }

                $rr=floor($j/2);
                $mod=$j-$rr*2;

                if ($mod ==0) {
                    $_class='odd';
                } else {
                    $_class='even';
                }

                print "
                <tr class=$_class>
                <td width=175>$htmlDate</td>
                <td width=12><nobr>$dialURI</nobr></td>
                <td style='text-align:right' width=60>$duration</td>
                <td><nobr>$htmlURI ($media)</nobr></td>
                ";
                print "<td width=40><nobr>$trace_link</nobr></td>";
                print "<td width=19><a href=$this->url&tab=contacts&task=add&uri=$urlURI&search_text=$urlURI>$this->phonebook_img</a></td>";
                print "</td>
                </tr>
                ";
            }
            print "</table>";
        }

        if (count($this->calls_placed)) {
            $chapter=sprintf(_("Outgoing"));
            $this->showChapter($chapter);

            $j=0;

            print "<table class='table table-striped table-condensed'>";
            foreach (array_keys($this->calls_placed) as $call) {
                $j++;

                if ($this->calls_placed[$call]['to'] == "sip:".$this->voicemail['Account'] ) {
                    continue;
                }

                $uri = $this->calls_placed[$call]['remoteParty'];
                $media = "";
                foreach ($this->calls_placed[$call]['media'] as $m) {
                     $media.="$m,";
                }
                $media=rtrim($media,",");
                $price       = $this->calls_placed[$call]['price'];
                $status      = $this->calls_placed[$call]['status'];
                $rateinfo    = $this->calls_placed[$call]['rateInfo'];
                $duration    = normalizeTime($this->calls_placed[$call]['duration']);
                $dialURI     = $this->PhoneDialURL($uri) ;
                $htmlDate    = $this->colorizeDate($this->calls_placed[$call]['startTime']);
                $stopTime    = $this->calls_placed[$call]['stopTime'];
                $htmlURI     = $this->htmlURI($uri);
                $urlURI      = urlencode($this->normalizeURI($uri));

                $sessionId    = urlencode($this->calls_placed[$call]['sessionId']);
                $fromTag      = urlencode($this->calls_placed[$call]['fromTag']);
                $toTag        = urlencode($this->calls_placed[$call]['toTag']);
                $proxyIP      = urlencode($this->calls_placed[$call]['proxyIP']);
                $trace_link   = "<a href=\"javascript:void(null);\" onClick=\"return window.open('sip_trace.phtml?cdr_source=$cdr_source&callid=$sessionId&fromtag=$fromTag&totag=$toTag&proxyIP=$proxyIP', 'Server Logs',
                'toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1000,height=600')\">Server Logs</a>";

                if ($price) {
                    $price_print =sprintf(" (%s %s)",$price,$this->currency);
                } else {
                    $price_print = '';
                }

                $rr=floor($j/2);
                $mod=$j-$rr*2;

                if ($mod ==0) {
                    $_class='odd';
                } else {
                    $_class='even';
                }
                if (!$stopTime) {
                    $duration = _('In progress');
                }

                print "
                <tr class=$_class>
                <td width=175>$htmlDate</td>
                <td width=12><nobr>$dialURI<nobr></td>
                <td style='text-align:right' width=75>$duration</td>
                <td ><nobr>$htmlURI ($media) $price_print</nobr></td>
                ";

                print "<td width=40><nobr>$trace_link</nobr></td>";
                print "<td width=19><a href=$this->url&tab=contacts&task=add&uri=$urlURI&search_text=$urlURI>$this->phonebook_img</a></td>";
                print "</td>
                </tr>
                ";
            }
            print "</table>";
        }

    }
<?php

define('ROOT', '../private_html/');
require_once ROOT . 'config.php';
require_once ROOT . 'includes/database.php';
require_once ROOT . 'includes/func.php';
$baseEpoch = normalizeTime();
$minimum = strtotime('-30 minutes', $baseEpoch);
$master_db_handle->exec('UPDATE Plugin set ServerCount30 = 0');
$statement = $master_db_handle->prepare('UPDATE Plugin dest, (SELECT
            Plugin,
            COUNT(*) AS Count
        FROM ServerPlugin
        LEFT OUTER JOIN Server ON Server.ID = ServerPlugin.Server
        WHERE Updated >= ?
        GROUP BY Plugin) src
SET dest.ServerCount30 = src.Count where dest.ID = src.Plugin');
$statement->execute(array($minimum));
Esempio n. 3
0
/**
 * Loads all of the plugins from the database
 *
 * @return Plugin[]
 */
function loadPlugins($order = PLUGIN_ORDER_POPULARITY, $limit = -1, $start = -1)
{
    global $cachedPlugins;
    $db_handle = get_slave_db_handle();
    $ret = array();
    switch ($order) {
        case PLUGIN_ORDER_ALPHABETICAL:
            $query = 'SELECT ID, Parent, Name, Author, Hidden, GlobalHits, Created, Rank, LastRank, LastRankChange, LastUpdated, ServerCount30 FROM Plugin WHERE Parent = -1 ORDER BY Name ASC';
            break;
        case PLUGIN_ORDER_POPULARITY:
            $query = 'SELECT Plugin.ID, Parent, Name, Author, Hidden, GlobalHits, Created, Rank, LastRank, LastRankChange, LastUpdated, ServerCount30 FROM Plugin WHERE LastUpdated >= ? AND Plugin.Parent = -1 AND Rank > 0 ORDER BY Rank ASC';
            break;
        case PLUGIN_ORDER_RANDOM:
            $query = 'SELECT ID, Parent, Name, Author, Hidden, GlobalHits, Created, Rank, LastRank, LastRankChange, LastUpdated, ServerCount30 FROM Plugin WHERE Parent = -1 ORDER BY RAND()';
            break;
        case PLUGIN_ORDER_RANDOM_TOP100:
            $query = 'SELECT ID, Parent, Name, Author, Hidden, GlobalHits, Created, Rank, LastRank, LastRankChange, LastUpdated, ServerCount30 FROM Plugin WHERE Parent = -1 AND Rank > 0 AND Rank <= 100 ORDER BY RAND()';
            break;
        case PLUGIN_ORDER_SERVERCOUNT30:
            $query = 'SELECT ID, Parent, Name, Author, Hidden, GlobalHits, Created, Rank, LastRank, LastRankChange, LastUpdated, ServerCount30 FROM Plugin WHERE Parent = -1 ORDER BY ServerCount30 ASC';
            break;
        default:
            error_log('Unimplemented loadPlugins () order => ' . $order);
            exit('Unimplemented loadPlugins () order => ' . $order);
    }
    if ($start != -1 && is_numeric($start)) {
        $query .= ' LIMIT ' . $start . ',' . $limit;
    } else {
        if ($limit != -1 && is_numeric($limit)) {
            $query .= ' LIMIT ' . $limit;
        }
    }
    $statement = $db_handle->prepare($query);
    $statement->execute(array(normalizeTime() - SECONDS_IN_DAY));
    while ($row = $statement->fetch()) {
        $plugin = resolvePlugin($row);
        $cachedPlugins[$plugin->getID()] = $plugin;
        $ret[] = $plugin;
    }
    return $ret;
}
Esempio n. 4
0
require_once ROOT . 'config.php';
require_once ROOT . 'includes/database.php';
require_once ROOT . 'includes/func.php';
// array of plugin objects
$plugins = array();
// array of plugin server counts (1d)
$counts = array();
// count servers
foreach (loadPlugins(PLUGIN_ORDER_SERVERCOUNT30) as $plugin) {
    if ($plugin->isHidden()) {
        continue;
    }
    $plugins[$plugin->getID()] = $plugin;
    $counts[$plugin->getID()] = $plugin->getServerCount();
}
// sort the plugins
arsort($counts);
$rank = 0;
$lastChange = normalizeTime();
foreach ($counts as $pluginId => $count) {
    $plugin = $plugins[$pluginId];
    $newRank = ++$rank;
    // did their rank change ?
    if ($newRank != $plugin->getRank()) {
        $plugin->setLastRankChange($lastChange);
    }
    $plugin->setLastRank($plugin->getRank());
    $plugin->setRank($newRank);
    $plugin->save();
    echo sprintf('%d: %s%s', $rank, $plugin->getName(), PHP_EOL);
}
Esempio n. 5
0
define('ROOT', './');
session_start();
require_once ROOT . '../private_html/config.php';
require_once ROOT . '../private_html/includes/database.php';
require_once ROOT . '../private_html/includes/func.php';
/// Templating
$page_title = 'MCStats :: Homepage';
$container_class = 'container';
send_header();
$plugin = loadPluginByID(GLOBAL_PLUGIN_ID);
$graph = $plugin->getOrCreateGraph('Global Statistics');
$serverCount = number_format($plugin->getTimelineCustomLast($graph->getColumnID('Servers'), $graph));
$playerCount = number_format($plugin->getTimelineCustomLast($graph->getColumnID('Players'), $graph));
$statement = get_slave_db_handle()->prepare('SELECT COUNT(*) FROM Plugin where LastUpdated >= ?');
$statement->execute(array(normalizeTime() - SECONDS_IN_DAY));
$row = $statement->fetch();
$pluginCount = $row ? $row[0] : 0;
echo <<<END

<script type="text/javascript">
    \$(document).ready(function() {
        \$("#players-popover").popover();
    });
</script>


<div class="row-fluid">
    <div class="col-xs-12">
        <h1 style="margin-bottom:10px; font-size:57px;">Glorious plugin stats!</h1>
        <p>MCStats / Plugin Metrics is the de facto statistical engine for Minecraft, actively used by over <b>{$pluginCount}</b> plugins.</p>
Esempio n. 6
0
 /**
  * @return
  */
 public function getServerCount()
 {
     if ($this->serverCount == -1) {
         $this->serverCount = $this->countServersLastUpdated(normalizeTime() - SECONDS_IN_DAY);
     }
     return $this->serverCount;
 }