mirror of
https://github.com/nidebr/as-stats-gui.git
synced 2025-02-20 11:23:18 +08:00
save work
This commit is contained in:
parent
3f8e4c738d
commit
abc5af687d
@ -2,6 +2,12 @@ db:
|
||||
daystatsfile:
|
||||
path: '/data/asstats/asstats/asstats_day.txt'
|
||||
|
||||
topinterval:
|
||||
month:
|
||||
hours: '720' # 30x24h
|
||||
statsfile: '/data/asstats/asstats/asstats_month.txt'
|
||||
label: '30 days'
|
||||
|
||||
config:
|
||||
knownlinksfile: '/data/asstats/conf/knownlinks'
|
||||
asinfofile: 'ressources/asinfo.txt'
|
||||
|
@ -21,12 +21,12 @@ class ConfigApplication
|
||||
|
||||
public static function getRelease()
|
||||
{
|
||||
return self::getConfig()['application']['release'];
|
||||
return self::getConfig()['application']['release'];
|
||||
}
|
||||
|
||||
public static function getDebug()
|
||||
{
|
||||
return self::getConfig()['application']['debug'];
|
||||
return self::getConfig()['application']['debug'];
|
||||
}
|
||||
|
||||
public static function getControllerRootDirectory()
|
||||
@ -36,48 +36,57 @@ class ConfigApplication
|
||||
|
||||
public static function getTwigPathDirectory()
|
||||
{
|
||||
return self::getRootPathApp().''.self::getConfig()['application']['twig']['path'];
|
||||
return self::getRootPathApp().''.self::getConfig()['application']['twig']['path'];
|
||||
}
|
||||
|
||||
public static function getTwigTimezone()
|
||||
{
|
||||
return self::getConfig()['application']['twig']['timezone'];
|
||||
return self::getConfig()['application']['twig']['timezone'];
|
||||
}
|
||||
|
||||
public static function getLocale()
|
||||
{
|
||||
return self::getConfig()['application']['locale'];
|
||||
return self::getConfig()['application']['locale'];
|
||||
}
|
||||
|
||||
public static function getASStatsFilePath()
|
||||
{
|
||||
return self::getRootPathApp().''.self::getConfig()['application']['asstats_file'];
|
||||
return self::getRootPathApp().''.self::getConfig()['application']['asstats_file'];
|
||||
}
|
||||
|
||||
public static function getConfigASStats()
|
||||
{
|
||||
$input_yaml = file_get_contents(self::getASStatsFilePath());
|
||||
$output = Yaml::parse($input_yaml);
|
||||
return $output;
|
||||
$input_yaml = file_get_contents(self::getASStatsFilePath());
|
||||
$output = Yaml::parse($input_yaml);
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function getDbFile()
|
||||
{
|
||||
return self::getConfigASStats()['db'];
|
||||
return self::getConfigASStats()['db'];
|
||||
}
|
||||
|
||||
public static function getKnowlinksFile()
|
||||
{
|
||||
return self::getConfigASStats()['config']['knownlinksfile'];
|
||||
return self::getConfigASStats()['config']['knownlinksfile'];
|
||||
}
|
||||
|
||||
public static function getASInfoFile()
|
||||
{
|
||||
return self::getRootPathApp().''.self::getConfigASStats()['config']['asinfofile'];
|
||||
return self::getRootPathApp().''.self::getConfigASStats()['config']['asinfofile'];
|
||||
}
|
||||
|
||||
public static function getCustomLinks()
|
||||
{
|
||||
return self::getConfigASStats()['customlinks'];
|
||||
return self::getConfigASStats()['customlinks'];
|
||||
}
|
||||
|
||||
public static function getTopInterval()
|
||||
{
|
||||
if ( !empty(self::getConfigASStats()['topinterval']) ) {
|
||||
return self::getConfigASStats()['topinterval'];
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,14 @@ class DbsProvider
|
||||
$db[$key] = $val;
|
||||
$db[$key]['driver'] = 'pdo_sqlite';
|
||||
}
|
||||
|
||||
|
||||
$dbs = ConfigApplication::getTopInterval();
|
||||
foreach ($dbs as $key => $val)
|
||||
{
|
||||
$db[$key."statsfile"]['path'] = $val['statsfile'];
|
||||
$db[$key."statsfile"]['driver'] = 'pdo_sqlite';
|
||||
}
|
||||
|
||||
return $db;
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,13 @@ class BaseController
|
||||
global $prog, $app;
|
||||
$this->data['version'] = ConfigApplication::getRelease();
|
||||
$this->db = $app['table.sql'];
|
||||
|
||||
// Top Interval
|
||||
$topinterval = ConfigApplication::getTopInterval();
|
||||
if ( $topinterval ) {
|
||||
foreach ($topinterval as $interval) {
|
||||
$this->data['topinterval'][] = $interval;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Controllers;
|
||||
use Application\ConfigApplication as ConfigApplication;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class Func
|
||||
{
|
||||
@ -105,4 +106,22 @@ class Func
|
||||
|
||||
return join(" | ", $htmllinks);
|
||||
}
|
||||
|
||||
public function getRouteName(Request $request)
|
||||
{
|
||||
$dpagename = $request->get('_route');
|
||||
$active_top = $dpagename == "index" ? "active": "";
|
||||
$active_searchas = $dpagename == "history" ? "active" : "";
|
||||
$active_searchasset = $dpagename == "asset" ? "active" : "";
|
||||
$active_ix = $dpagename == "ix" ? "active" : "";
|
||||
|
||||
$return = [
|
||||
'active_top' => $active_top,
|
||||
'active_searchas' => $active_searchas,
|
||||
'active_searchasset' => $active_searchasset,
|
||||
'active_ix' => $active_ix,
|
||||
];
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace Controllers;
|
||||
use Silex\Application;
|
||||
use DDesrosiers\SilexAnnotations\Annotations as SLX;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Controllers\Func;
|
||||
|
||||
/**
|
||||
@ -12,10 +13,11 @@ class Index extends BaseController
|
||||
{
|
||||
/**
|
||||
* @SLX\Route(
|
||||
* @SLX\Request(method="GET", uri="")
|
||||
* @SLX\Request(method="GET", uri=""),
|
||||
* @SLX\Bind(routeName="index")
|
||||
* )
|
||||
*/
|
||||
public function index(Application $app)
|
||||
public function index(Request $request, Application $app)
|
||||
{
|
||||
$topas = $this->db->GetASStatsTop('5','daystatsfile', array());
|
||||
|
||||
@ -30,6 +32,8 @@ class Index extends BaseController
|
||||
$this->data['customlinks'][$as] = Func::getCustomLinks($as);
|
||||
}
|
||||
|
||||
$this->data['active_page'] = Func::getRouteName($request);
|
||||
|
||||
return $app['twig']->render('pages/index.html.twig', $this->data);
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,22 @@
|
||||
</div>
|
||||
<div class="collapse navbar-collapse pull-left" id="navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="dropdown active"><a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Top AS <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="index.php?numhours=24">Top AS - 24 hours</a></li>
|
||||
<li><a href="index.php?numhours=720">Top AS - 30 days</a></li>
|
||||
<li><a href="index.php?numhours=2160">Top AS - 3 months</a></li>
|
||||
<li><a href="index.php?numhours=8760">Top AS - year</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="history.php">View AS</a></li>
|
||||
<li><a href="asset.php">View AS-SET</a></li>
|
||||
<li><a href="ix.php">View IX Stats</a></li>
|
||||
{% if topinterval is defined %}
|
||||
<li class="dropdown {{ active_page.active_top }}">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Top AS <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="{{ path('index') }}">Top AS - 24 hours</a></li>
|
||||
{% for top in topinterval %}
|
||||
<li><a href="{{ path('index', {'numhours': top.hours }) }}">Top AS - {{ top.label }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
{% else %}
|
||||
<li><a href="{{ path('index') }}">Top AS</a></li>
|
||||
{% endif %}
|
||||
<li class="{{ active_page.active_searchas }}"><a href="{{ path('history') }}">View AS</a></li>
|
||||
<li class="{{ active_page.active_searchasset }}"><a href="asset.php">View AS-SET</a></li>
|
||||
<li class="{{ active_page.active_ix }}"><a href="ix.php">View IX Stats</a></li>
|
||||
</ul>
|
||||
<form class="navbar-form navbar-left" role="search">
|
||||
<div class="input-group">
|
||||
|
Loading…
x
Reference in New Issue
Block a user