Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Member visit statistics
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 23 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member visit statistics
|
||||
*/
|
||||
class _membervisits extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'membervisits_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Member visit statistics
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$count = NULL;
|
||||
$table = NULL;
|
||||
$start = NULL;
|
||||
$end = NULL;
|
||||
|
||||
$defaults = array( 'start' => \IPS\DateTime::create()->setDate( date('Y'), date('m'), 1 ), 'end' => new \IPS\DateTime );
|
||||
|
||||
if( isset( \IPS\Request::i()->visitDateStart ) AND isset( \IPS\Request::i()->visitDateEnd ) )
|
||||
{
|
||||
$defaults = array( 'start' => \IPS\DateTime::ts( \IPS\Request::i()->visitDateStart ), 'end' => \IPS\DateTime::ts( \IPS\Request::i()->visitDateEnd ) );
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'visits', 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'visit_date', $defaults, TRUE ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
/* Determine start and end time */
|
||||
$startTime = $values['visit_date']['start']->getTimestamp();
|
||||
$endTime = $values['visit_date']['end']->getTimestamp();
|
||||
|
||||
$start = $values['visit_date']['start']->html();
|
||||
$end = $values['visit_date']['end']->html();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Determine start and end time */
|
||||
$startTime = $defaults['start']->getTimestamp();
|
||||
$endTime = $defaults['end']->getTimestamp();
|
||||
|
||||
$start = $defaults['start']->html();
|
||||
$end = $defaults['end']->html();
|
||||
}
|
||||
|
||||
/* Do we have our date ranges? */
|
||||
if( $start AND $end )
|
||||
{
|
||||
/* Get the count */
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', array( 'last_visit BETWEEN ? AND ?', $startTime, $endTime ) )->first();
|
||||
|
||||
/* And now build the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_members', \IPS\Request::i()->url()->setQueryString( array( 'visitDateStart' => $startTime, 'visitDateEnd' => $endTime ) ), array( array( 'last_visit BETWEEN ? AND ?', $startTime, $endTime ) ) );
|
||||
|
||||
$table->include = array( 'name', 'last_visit' );
|
||||
$table->mainColumn = 'name';
|
||||
$table->langPrefix = 'visits_';
|
||||
|
||||
/* Default sort options */
|
||||
$table->sortBy = $table->sortBy ?: 'last_visit';
|
||||
$table->sortDirection = $table->sortDirection ?: 'desc';
|
||||
|
||||
/* Custom parsers */
|
||||
$table->parsers = array(
|
||||
'name' => function( $val, $row )
|
||||
{
|
||||
$member = \IPS\Member::constructFromData( $row );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->userPhoto( $member, 'tiny' ) . ' ' . $member->link();
|
||||
},
|
||||
'last_visit' => function( $val, $row )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->html();
|
||||
},
|
||||
);
|
||||
|
||||
$table->extraHtml = \IPS\Theme::i()->getTemplate( 'stats' )->tableheader( $start, $end, $count );
|
||||
}
|
||||
|
||||
$formHtml = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'stats' ) ), 'visitsFormTemplate' ) );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_stats_membervisits');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'stats' )->membervisits( $formHtml, $count, $table );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief onlineusers
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 23 Mar 2017
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* onlineusers
|
||||
*/
|
||||
class _onlineusers extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'onlineusers_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Online users activity chart
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Show button to adjust settings */
|
||||
\IPS\Output::i()->sidebar['actions']['settings'] = array(
|
||||
'icon' => 'cog',
|
||||
'title' => 'prunesettings',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=stats&controller=onlineusers&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('prunesettings') )
|
||||
);
|
||||
|
||||
/* Determine minimum date */
|
||||
$minimumDate = NULL;
|
||||
|
||||
if( \IPS\Settings::i()->stats_online_users_prune )
|
||||
{
|
||||
$minimumDate = \IPS\DateTime::create()->sub( new \DateInterval( 'P' . \IPS\Settings::i()->stats_online_users_prune . 'D' ) );
|
||||
}
|
||||
|
||||
/* We can't retrieve any stats prior to the new tracking being implemented */
|
||||
try
|
||||
{
|
||||
$oldestLog = \IPS\Db::i()->select( 'MIN(time)', 'core_statistics', array( 'type=?', 'online_users' ) )->first();
|
||||
|
||||
if( !$minimumDate OR $oldestLog < $minimumDate->getTimestamp() )
|
||||
{
|
||||
$minimumDate = \IPS\DateTime::ts( $oldestLog );
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
/* We have nothing tracked, set minimum date to today */
|
||||
$minimumDate = \IPS\DateTime::create();
|
||||
}
|
||||
|
||||
$chart = new \IPS\Helpers\Chart\Callback(
|
||||
\IPS\Http\Url::internal( 'app=core&module=stats&controller=onlineusers' ),
|
||||
array( $this, 'getResults' ),
|
||||
'',
|
||||
array(
|
||||
'isStacked' => TRUE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#10967e', '#ea7963' ),
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
),
|
||||
'AreaChart',
|
||||
'none',
|
||||
array( 'start' => \IPS\DateTime::ts( time() - ( 60 * 60 * 24 * 30 ) ), 'end' => \IPS\DateTime::create() ),
|
||||
'',
|
||||
$minimumDate
|
||||
);
|
||||
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('members'), 'number' );
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('guests'), 'number' );
|
||||
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack('stats_onlineusers_title');
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
|
||||
$chart->showIntervals = FALSE;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_stats_onlineusers');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prune Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'stats_online_users_prune', \IPS\Settings::i()->stats_online_users_prune, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_moderator' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings();
|
||||
\IPS\Session::i()->log( 'acplog__statsonlineusers_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=stats&controller=onlineusers' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('prunesettings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'prunesettings', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the results
|
||||
*
|
||||
* @param \IPS\Helpers\Chart\Callback $chart Chart object
|
||||
* @return array
|
||||
*/
|
||||
public function getResults( $chart )
|
||||
{
|
||||
$where = array( array( 'type=?', 'online_users' ), array( "time>?", 0 ) );
|
||||
|
||||
if ( $chart->start )
|
||||
{
|
||||
$where[] = array( "time>?", $chart->start->getTimestamp() );
|
||||
}
|
||||
if ( $chart->end )
|
||||
{
|
||||
$where[] = array( "time<?", $chart->end->getTimestamp() );
|
||||
}
|
||||
|
||||
$results = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_statistics', $where, 'time ASC' ) as $row )
|
||||
{
|
||||
if( !isset( $results[ $row['time'] ] ) )
|
||||
{
|
||||
$results[ $row['time'] ] = array(
|
||||
'time' => $row['time'],
|
||||
\IPS\Member::loggedIn()->language()->get('members') => 0,
|
||||
\IPS\Member::loggedIn()->language()->get('guests') => 0
|
||||
);
|
||||
}
|
||||
|
||||
if( $row['value_4'] == 'members' )
|
||||
{
|
||||
$results[ $row['time'] ][ \IPS\Member::loggedIn()->language()->get('members') ] = $row['value_1'];
|
||||
}
|
||||
|
||||
if( $row['value_4'] == 'guests' )
|
||||
{
|
||||
$results[ $row['time'] ][ \IPS\Member::loggedIn()->language()->get('guests') ] = $row['value_1'];
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Messenger Stats
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 3 June 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Messenger Stats
|
||||
*/
|
||||
class _pmstats extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Manage Members
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Check permission */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'messages_manage', 'core', 'members' );
|
||||
|
||||
$chart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( 'app=core&module=stats&controller=pmstats' ), 'core_message_posts', 'msg_date', '', array( 'isStacked' => TRUE ) );
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('new_conversations'), 'number', 'SUM(msg_is_first_post)' );
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('mt_replies'), 'number', '( COUNT(*) - SUM(msg_is_first_post) )' );
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack('stats_messages_title');
|
||||
$chart->availableTypes = array( 'LineChart', 'ColumnChart', 'BarChart' );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_stats_pmstats');
|
||||
\IPS\Output::i()->output = (string) $chart;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Registration Stats
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 3 June 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\stats;
|
||||
@@ -33,10 +32,17 @@ class _registrationstats extends \IPS\Dispatcher\Controller
|
||||
/* Check permission */
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'registrations_manage', 'core', 'members' );
|
||||
|
||||
$chart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( 'app=core&module=stats&controller=registrationstats' ), 'core_members', 'joined', '', array( 'isStacked' => FALSE ) );
|
||||
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( 'app=core&module=stats&controller=registrationstats' ), 'core_members', 'joined', '', array(
|
||||
'isStacked' => FALSE,
|
||||
'backgroundColor' => '#ffffff',
|
||||
'colors' => array( '#10967e' ),
|
||||
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
|
||||
'lineWidth' => 1,
|
||||
'areaOpacity' => 0.4
|
||||
) );
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('stats_new_registrations'), 'number', 'COUNT(*)', FALSE );
|
||||
$chart->title = \IPS\Member::loggedIn()->language()->addToStack('stats_registrations_title');
|
||||
$chart->availableTypes = array( 'LineChart', 'ColumnChart', 'BarChart' );
|
||||
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
|
||||
|
||||
/* fetch only successful registered members ; if this needs to be changed, please review the other areas where we have the name<>? AND email<>? condition */
|
||||
$chart->where[] = array( '( name<>? AND email<>? )', '', '' );
|
||||
|
||||
Reference in new issue
Block a user