Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Error Logs
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 06 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\support;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error Logs
|
||||
*/
|
||||
class _errorLogs extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'support_dashboard' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Error Logs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_error_logs', \IPS\Http\Url::internal( 'app=core&module=support&controller=errorLogs' ) );
|
||||
$table->langPrefix = 'errorlogs_';
|
||||
$table->include = array( 'log_error_code', 'log_error', 'log_ip_address', 'log_request_uri', 'log_member', 'log_date' );
|
||||
$table->mainColumn = 'log_error_code';
|
||||
$table->widths = array( 'log_error_code' => 10, 'log_ip_address' => 10, 'log_request_uri' => 30, 'log_date' => 10, 'log_member' => 10 );
|
||||
$table->parsers = array(
|
||||
'log_member' => function( $val )
|
||||
{
|
||||
try
|
||||
{
|
||||
return htmlentities( \IPS\Member::load( $val )->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
}
|
||||
catch ( \OutOfBoundsException $e )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'log_ip_address'=> function( $val )
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'membertools_ip' ) )
|
||||
{
|
||||
return "<a href='" . \IPS\Http\Url::internal( "app=core&module=members&controller=ip&ip={$val}" ) . "'>{$val}</a>";
|
||||
}
|
||||
return $val;
|
||||
},
|
||||
'log_date' => function( $val )
|
||||
{
|
||||
return (string) \IPS\DateTime::ts( $val );
|
||||
},
|
||||
'log_error' => function( $val )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( $val );
|
||||
},
|
||||
'log_request_uri' => function( $val )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->truncatedUrl( $val );
|
||||
}
|
||||
);
|
||||
$table->sortBy = $table->sortBy ?: 'log_date';
|
||||
$table->sortDirection = $table->sortDirection ?: 'desc';
|
||||
|
||||
/* Search */
|
||||
$table->advancedSearch = array(
|
||||
'log_member' => \IPS\Helpers\Table\SEARCH_MEMBER,
|
||||
'log_ip_address' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'log_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'log_error' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'log_error_code' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'log_request_uri' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
);
|
||||
$table->quickSearch = 'log_error';
|
||||
|
||||
/* Add a button for settings */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'support', 'diagnostic_log_settings' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'settings',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=errorLogs&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('settings') )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('errorlogs');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'errorlogs', (string) $table );
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'diagnostic_log_settings' );
|
||||
|
||||
$levelOptions = array(
|
||||
'0' => 'level_number_0',
|
||||
'1' => 'level_number_1',
|
||||
'2' => 'level_number_2',
|
||||
'3' => 'level_number_3',
|
||||
'4' => 'level_number_4',
|
||||
'5' => 'level_number_5',
|
||||
);
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'error_log_level', \IPS\Settings::i()->error_log_level, FALSE, array( 'options' => $levelOptions ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'error_notify_level', \IPS\Settings::i()->error_notify_level, FALSE, array( 'min' => 1, 'max' => 5, 'unlimited' => 0, 'unlimitedLang' => 'none' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('error_log_level_prefix'), \IPS\Member::loggedIn()->language()->addToStack('error_log_level_suffix') ) );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'staff', 'error_prune' ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_error', \IPS\Settings::i()->prune_log_error, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_error' ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings();
|
||||
\IPS\Session::i()->log( 'acplog__errorlog_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=support&controller=errorLogs' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('errorlogssettings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'errorlogssettings', $form, FALSE );
|
||||
}
|
||||
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief sql
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 22 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\support;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* sql
|
||||
*/
|
||||
class _sql extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
const SELECT_LIMIT = 100;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'sql_toolbox' );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('sql_toolbox');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'sql_toolbox_warning', 'warning' );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=support&controller=support' ), \IPS\Member::loggedIn()->language()->addToStack('support') );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=support&controller=sql' ), \IPS\Member::loggedIn()->language()->addToStack('sql_toolbox') );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Get Tables */
|
||||
$tables = array();
|
||||
$result = \IPS\Db::i()->query("SHOW TABLE STATUS;");
|
||||
|
||||
while ( $table = $result->fetch_assoc() )
|
||||
{
|
||||
$tables[] = array(
|
||||
'name' => $table['Name'],
|
||||
'rows' => $table['Rows'],
|
||||
'engine' => $table['Engine'],
|
||||
);
|
||||
}
|
||||
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Custom( $tables, \IPS\Http\Url::internal( 'app=core&module=support&controller=sql' ) );
|
||||
$table->langPrefix = 'sql_table_';
|
||||
$table->sortBy = $table->sortBy ?: 'name';
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
$table->quickSearch = 'name';
|
||||
|
||||
/* Buttons */
|
||||
$table->rowButtons = function( $row )
|
||||
{
|
||||
return array(
|
||||
'view' => array(
|
||||
'icon' => 'search',
|
||||
'title' => 'view',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=sql&do=query' )->setQueryString( 'q', "SELECT * FROM {$row['name']}" )
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
/* Query form */
|
||||
$form = new \IPS\Helpers\Form( 'form', 'run_query', \IPS\Http\Url::internal( 'app=core&module=support&controller=sql&do=query' ) );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\TextArea( 'sql_toolbox_query', NULL, TRUE, array( 'class' => 'ipsField_codeInput' ) ) );
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output .= $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'support' ) ), 'queryFormTemplate' ) ) . \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table );
|
||||
}
|
||||
|
||||
/**
|
||||
* Run Query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function query()
|
||||
{
|
||||
/* Select from table */
|
||||
$query = NULL;
|
||||
if ( isset( \IPS\Request::i()->q ) )
|
||||
{
|
||||
$query = urldecode( \IPS\Request::i()->q );
|
||||
}
|
||||
|
||||
/* Query form */
|
||||
$form = new \IPS\Helpers\Form( 'form', 'run_query' );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->add( new \IPS\Helpers\Form\TextArea( 'sql_toolbox_query', $query, TRUE, array( 'class' => 'ipsField_codeInput' ) ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$query = $values['sql_toolbox_query'];
|
||||
}
|
||||
|
||||
/* Run */
|
||||
$queries = array();
|
||||
$results = array();
|
||||
if ( $query )
|
||||
{
|
||||
/* Run each one */
|
||||
$queries = preg_split( "/;[\r\n|\n]+/", $query, -1, PREG_SPLIT_NO_EMPTY );
|
||||
foreach ( $queries as $k => $q )
|
||||
{
|
||||
try
|
||||
{
|
||||
/* Strip quotes */
|
||||
$q = trim( preg_replace( '#(--.*)|(((/\*)+?[\w\W]+?(\*/)+))#', '', $q ) );
|
||||
|
||||
/* Check it's okay */
|
||||
if ( preg_match( "/^(DROP|FLUSH)/i", $q ) )
|
||||
{
|
||||
throw new \DomainException( 'sql_toolbox_not_allowed' );
|
||||
}
|
||||
if ( preg_match( "/^(?!SELECT)/i", preg_replace( "#\s{1,}#s", "", $q ) ) and ( preg_match( "/admin_login_logs/i", preg_replace( "#\s{1,}#s", "", $q ) ) || preg_match( "/admin_permission_rows/i", preg_replace( "#\s{1,}#s", "", $q ) ) ) )
|
||||
{
|
||||
throw new \DomainException( 'sql_toolbox_not_allowed' );
|
||||
}
|
||||
|
||||
/* Run it */
|
||||
$result = \IPS\Db::i()->query( $q );
|
||||
|
||||
/* Do we have results */
|
||||
if ( $result instanceof \mysqli_result )
|
||||
{
|
||||
if ( $result->num_rows )
|
||||
{
|
||||
/* Paginate */
|
||||
$pagination = NULL;
|
||||
if ( $result->num_rows > static::SELECT_LIMIT and !preg_match( "/^EXPLAIN/i", $q ) and !preg_match( "/^SHOW/i", $q ) and !preg_match( "/LIMIT[ 0-9,]+$/i", $q ) )
|
||||
{
|
||||
$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;
|
||||
|
||||
if( $page < 1 )
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
\IPS\Http\Url::internal( 'app=core&module=support&controller=sql&do=query' )->setQueryString( 'q', $query ),
|
||||
ceil( $result->num_rows / static::SELECT_LIMIT ),
|
||||
$page,
|
||||
static::SELECT_LIMIT
|
||||
);
|
||||
|
||||
if( mb_substr( $q, -1, 1 ) == ";" )
|
||||
{
|
||||
$q = mb_substr( $q, 0, -1 );
|
||||
}
|
||||
$q .= ' LIMIT ' . ( ( $page - 1 ) * static::SELECT_LIMIT ) . ', ' . static::SELECT_LIMIT;
|
||||
|
||||
$result = \IPS\Db::i()->query( $q );
|
||||
}
|
||||
|
||||
$results[ $k ] = \IPS\Theme::i()->getTemplate( 'support' )->table( $result, $pagination );
|
||||
}
|
||||
else
|
||||
{
|
||||
$results[ $k ] = \IPS\Theme::i()->getTemplate( 'global' )->message( 'no_results', 'info' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Nope, just a success message */
|
||||
else
|
||||
{
|
||||
$results[ $k ] = \IPS\Theme::i()->getTemplate( 'global' )->message( \IPS\Db::i()->info ?: \IPS\Member::loggedIn()->language()->addToStack('sql_toolbox_done'), 'success' );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$results[ $k ] = \IPS\Theme::i()->getTemplate( 'global' )->message( $e->getMessage(), 'error' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'support' )->toolboxResults( $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'support' ) ), 'queryFormTemplate' ) ), $queries, $results );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,727 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Support Wizard
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 21 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\support;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Support Wizard
|
||||
*/
|
||||
class _support extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'get_support' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Support Wizard
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('get_support');
|
||||
\IPS\Output::i()->output = \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->support( new \IPS\Helpers\Wizard( array( 'type_of_problem' => array( $this, '_typeOfProblem' ), 'self_service' => array( $this, '_selfService' ), 'contact_support' => array( $this, '_contactSupport' ) ), \IPS\Http\Url::internal('app=core&module=support&controller=support') ) );
|
||||
|
||||
\IPS\Output::i()->sidebar['actions']['systemcheck'] = array(
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=support&do=systemCheck' ),
|
||||
'title' => 'requirements_checker',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* phpinfo
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function phpinfo()
|
||||
{
|
||||
phpinfo();
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* System Check
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function systemCheck()
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('requirements_checker');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'support' )->healthcheck( \IPS\core\Setup\Upgrade::systemRequirements() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 1: Type of problem
|
||||
*
|
||||
* @param mixed $data Wizard data
|
||||
* @return string|array
|
||||
*/
|
||||
public function _typeOfProblem( $data )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'continue' );
|
||||
$form->class = 'ipsForm_horizontal ipsPad';
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'type_of_problem_select', NULL, TRUE, array(
|
||||
'options' => array( 'advice' => 'type_of_problem_advice', 'issue' => 'type_of_problem_issue' ),
|
||||
'toggles' => array( 'advice' => array( 'support_advice_search' ) )
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'support_advice_search', NULL, NULL, array(), function( $val )
|
||||
{
|
||||
if ( !$val and \IPS\Request::i()->type_of_problem_select === 'advice' )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'support_advice_search' ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
return array( 'type' => $values['type_of_problem_select'], 'keyword' => $values['support_advice_search'] );
|
||||
}
|
||||
return (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service
|
||||
*
|
||||
* @param mixed $data Wizard data
|
||||
* @return string|array
|
||||
*/
|
||||
public function _selfService( $data )
|
||||
{
|
||||
/* Advice */
|
||||
if ( $data['type'] === 'advice' )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->next ) )
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
$searchResults = array();
|
||||
if ( $data['keyword'] )
|
||||
{
|
||||
$search = new \IPS\core\extensions\core\LiveSearch\Settings;
|
||||
$searchResults = $search->getResults( $data['keyword'] );
|
||||
}
|
||||
|
||||
$guides = array();
|
||||
try
|
||||
{
|
||||
$guides = \IPS\Http\Url::ips( 'guides/' . urlencode( $data['keyword'] ) )->request()->get()->decodeJson();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
|
||||
if ( count( $searchResults ) or count( $guides ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->advice( $searchResults, $guides );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/* Issue */
|
||||
else
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->serviceDone ) )
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
$baseUrl = \IPS\Http\Url::internal('app=core&module=support&controller=support&_step=self_service');
|
||||
|
||||
$overrideThingToTry = NULL;
|
||||
if ( isset( \IPS\Request::i()->next ) )
|
||||
{
|
||||
$overrideThingToTry = \IPS\Request::i()->next;
|
||||
$baseUrl = $baseUrl->setQueryString( 'next', $overrideThingToTry );
|
||||
}
|
||||
|
||||
$possibleSolutions = array( '_requirementsChecker', '_databaseChecker', '_clearCaches', '_connectionChecker', '_md5sumChecker', '_upgradeCheck', '_defaultTheme' );
|
||||
if ( !\IPS\NO_WRITES )
|
||||
{
|
||||
$possibleSolutions[] = '_disableThirdParty';
|
||||
}
|
||||
$possibleSolutions[] = '_knowledgebase';
|
||||
$self = $this;
|
||||
|
||||
return new \IPS\Helpers\MultipleRedirect(
|
||||
$baseUrl,
|
||||
function( $thingToTry ) use ( $self, $possibleSolutions, $overrideThingToTry )
|
||||
{
|
||||
if ( !is_null( $overrideThingToTry ) and $overrideThingToTry > $thingToTry )
|
||||
{
|
||||
$thingToTry = $overrideThingToTry;
|
||||
}
|
||||
|
||||
if ( isset( $possibleSolutions[ $thingToTry ] ) )
|
||||
{
|
||||
$test = call_user_func( array( $self, $possibleSolutions[ $thingToTry ] ), $thingToTry );
|
||||
if ( is_string( $test ) )
|
||||
{
|
||||
return array( $test );
|
||||
}
|
||||
else
|
||||
{
|
||||
return array( $thingToTry + 1, \IPS\Member::loggedIn()->language()->addToStack( 'looking_for_problems' ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
},
|
||||
function() use ( $baseUrl )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $baseUrl->setQueryString( 'serviceDone', 1 ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Clear Caches
|
||||
*
|
||||
* @param int $thingToTry The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _clearCaches( $thingToTry )
|
||||
{
|
||||
/* Clear JS Maps first */
|
||||
\IPS\Output::clearJsFiles();
|
||||
|
||||
/* Reset theme maps to make sure bad data hasn't been cached by visits mid-setup */
|
||||
foreach( \IPS\Theme::themes() as $id => $set )
|
||||
{
|
||||
/* Update mappings */
|
||||
$set->css_map = array();
|
||||
$set->save();
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->clearAll();
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->tryNow( ++$thingToTry, 'support_caches_cleared' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Database Checker
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _databaseChecker( $id )
|
||||
{
|
||||
$changesToMake = array();
|
||||
$db = \IPS\Db::i();
|
||||
|
||||
/* Loop Apps */
|
||||
foreach ( \IPS\Application::applications() as $app )
|
||||
{
|
||||
$changesToMake = array_merge( $changesToMake, $app->databaseCheck() );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if ( $changesToMake )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->run ) )
|
||||
{
|
||||
$erroredQueries = array();
|
||||
$errors = array();
|
||||
foreach ( $changesToMake as $query )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->query( $query['query'] );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$erroredQueries[] = $query['query'];
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
if ( count( $erroredQueries ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->databaseChecker( $id, ++$id, $erroredQueries, $errors );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->tryNow( ++$id, 'database_changes_made' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$queries = array();
|
||||
foreach ( $changesToMake as $query )
|
||||
{
|
||||
$queries[] = $query['query'];
|
||||
}
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->databaseChecker( $id, ++$id, $queries );
|
||||
}
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->recheck ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->tryNow( ++$id, 'database_changes_made' );
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - md5sum Checker
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _md5sumChecker( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$key = \IPS\IPS::licenseKey();
|
||||
$correctMd5s = \IPS\Http\Url::ips( 'md5/' . $key['key'] )->request()->get()->decodeJson();
|
||||
|
||||
$files = $this->_md5sumCheckerIterator( \IPS\ROOT_PATH, $correctMd5s );
|
||||
if ( count( $files ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->md5sum( $files, $id );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: md5sum Checker Iterator
|
||||
*
|
||||
* @param string $directory Directory to look through
|
||||
* @return array
|
||||
*/
|
||||
public function _md5sumCheckerIterator( $directory, $correctMd5s )
|
||||
{
|
||||
$return = array();
|
||||
foreach( new \DirectoryIterator( $directory ) as $file )
|
||||
{
|
||||
if ( mb_substr( $file, 0, 1 ) === '.' or mb_substr( $file, 0, 1 ) === '_' or $file == 'index.html' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $file->isDir() )
|
||||
{
|
||||
$return = array_merge( $return, $this->_md5sumCheckerIterator( $file->getPathname(), $correctMd5s ) );
|
||||
}
|
||||
elseif ( mb_substr( $file, -4 ) === '.php' )
|
||||
{
|
||||
$fullPath = $file->getPathname();
|
||||
$shortPath = mb_substr( $fullPath, mb_strlen( \IPS\ROOT_PATH ) );
|
||||
|
||||
if ( $shortPath != '/init.php' and isset( $correctMd5s[ $shortPath ] ) and md5( preg_replace( '#\s#', '', file_get_contents( $fullPath ) ) ) != $correctMd5s[ $shortPath ] ) // We strip whitespace since FTP in ASCII mode will change the whitespace characters
|
||||
{
|
||||
$return[] = $fullPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Requirements Checker (Includes File Permissions)
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _requirementsChecker( $id )
|
||||
{
|
||||
$check = \IPS\core\Setup\Upgrade::systemRequirements();
|
||||
foreach ( $check['requirements'] as $group => $requirements )
|
||||
{
|
||||
foreach ( $requirements as $requirement )
|
||||
{
|
||||
if ( !$requirement['success'] )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->tryNow( $id, $requirement['message'], '', FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Connection Checker
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _connectionChecker( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Http\Url::ips( 'connectionCheck' )->request()->get();
|
||||
return NULL;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->connectionChecker( ++$id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Check for Uprade
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _upgradeCheck( $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$response = \IPS\Http\Url::ips('updateCheck')->request()->get()->decodeJson();
|
||||
if ( $response['longversion'] > \IPS\Application::load('core')->long_version )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->upgrade( ++$id, $response['updateurl'] );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Instruct user to try using default theme
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _defaultTheme( $id )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->deleteTheme ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Theme::load( \IPS\Request::i()->deleteTheme )->delete();
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_theme_templates', 'template_set_id>0' )->first() or \IPS\Db::i()->select( 'COUNT(*)', 'core_theme_css', 'css_set_id>0' )->first() )
|
||||
{
|
||||
$newTheme = new \IPS\Theme;
|
||||
$newTheme->permissions = \IPS\Member::loggedIn()->member_group_id;
|
||||
$newTheme->save();
|
||||
$newTheme->installThemeSettings();
|
||||
$newTheme->copyResourcesFromSet();
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "core_theme_set_title_" . $newTheme->id, "IPS Support" );
|
||||
|
||||
\IPS\Member::loggedIn()->skin = $newTheme->id;
|
||||
|
||||
if( \IPS\Member::loggedIn()->acp_skin !== NULL )
|
||||
{
|
||||
\IPS\Member::loggedIn()->acp_skin = $newTheme->id;
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->tryNow( $id, 'try_default_theme', '&deleteTheme=' . $newTheme->id );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Disable 3rd party apps/plugins
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _disableThirdParty( $id )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->enableApps ) or isset( \IPS\Request::i()->enablePlugins ) )
|
||||
{
|
||||
foreach ( explode( ',', \IPS\Request::i()->enableApps ) as $app )
|
||||
{
|
||||
try
|
||||
{
|
||||
$app = \IPS\Application::load( $app );
|
||||
$app->enabled = TRUE;
|
||||
$app->save();
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
foreach ( explode( ',', \IPS\Request::i()->enablePlugins ) as $plugin )
|
||||
{
|
||||
try
|
||||
{
|
||||
$plugin = \IPS\Plugin::load( $plugin );
|
||||
$plugin->enabled = TRUE;
|
||||
$plugin->save();
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$disabledApps = array();
|
||||
$disabledPlugins = array();
|
||||
$disabledAppNames = array();
|
||||
$disabledPluginNames = array();
|
||||
|
||||
/* Loop Apps */
|
||||
foreach ( \IPS\Application::applications() as $app )
|
||||
{
|
||||
if ( $app->enabled and !in_array( $app->directory, \IPS\Application::$ipsApps ) )
|
||||
{
|
||||
$app->enabled = FALSE;
|
||||
$app->save();
|
||||
|
||||
$disabledApps[] = $app->directory;
|
||||
$disabledAppNames[] = $app->_title;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look Plugins */
|
||||
foreach ( \IPS\Plugin::plugins() as $plugin )
|
||||
{
|
||||
if ( $plugin->enabled )
|
||||
{
|
||||
$plugin->enabled = FALSE;
|
||||
$plugin->save();
|
||||
|
||||
$disabledPlugins[] = $plugin->id;
|
||||
$disabledPluginNames[] = $plugin->_title;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do any? */
|
||||
if ( count( $disabledApps ) or count( $disabledPlugins ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->thirdParty( $id, $disabledAppNames, $disabledPluginNames, '&enableApps=' . implode( ',', $disabledApps ) . '&enablePlugins=' . implode( ',', $disabledPlugins ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 2: Self Service - Knowledgebase
|
||||
*
|
||||
* @param int $id The current ID
|
||||
* @return string|NULL
|
||||
*/
|
||||
public function _knowledgebase( $id )
|
||||
{
|
||||
$kb = array();
|
||||
try
|
||||
{
|
||||
$kb = \IPS\Http\Url::ips('kb')->request()->get()->decodeJson();
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
|
||||
if ( count( $kb ) )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'support' )->knowledgebase( ++$id, $kb );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Step 3: Contact Support
|
||||
*
|
||||
* @param mixed $data Wizard data
|
||||
* @return string|array
|
||||
*/
|
||||
public function _contactSupport( $data )
|
||||
{
|
||||
$licenseData = \IPS\IPS::licenseKey();
|
||||
if ( !$licenseData or strtotime( $licenseData['expires'] ) < time() )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_no_license', 'warning' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$supportedVerions = \IPS\Http\Url::ips('support/versions')->request()->get()->decodeJson();
|
||||
|
||||
if ( \IPS\Application::load('core')->long_version > $supportedVerions['max'] )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_unsupported_prerelease', 'warning' );
|
||||
}
|
||||
if ( \IPS\Application::load('core')->long_version < $supportedVerions['min'] )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_unsupported_obsolete', 'warning' );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'contact_support', 'contact_support' );
|
||||
$form->class = 'ipsForm_vertical ipsPad';
|
||||
|
||||
$extraOptions = array( 'admin' => 'support_request_admin' );
|
||||
if ( $this->_supportLog( TRUE ) )
|
||||
{
|
||||
$form->hiddenValues['_log'] = '1';
|
||||
$extraOptions['log'] = 'support_request_log';
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'support_request_title', NULL, TRUE, array( 'maxLength' => 128 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'support_request_body', NULL, TRUE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'acp-support-request' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'support_request_extra', array( 'admin', 'log' ), FALSE, array( 'options' => $extraOptions ) ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$admin = NULL;
|
||||
if ( in_array( 'admin', $values['support_request_extra'] ) )
|
||||
{
|
||||
$password = '';
|
||||
$length = rand( 8, 15 );
|
||||
for ( $i = 0; $i < $length; $i++ )
|
||||
{
|
||||
do {
|
||||
$key = rand( 33, 126 );
|
||||
} while ( in_array( $key, array( 34, 39, 60, 62, 92 ) ) );
|
||||
$password .= chr( $key );
|
||||
}
|
||||
|
||||
$supportAccount = \IPS\Member::load( 'nobody@invisionpower.com', 'email' );
|
||||
if ( !$supportAccount->member_id )
|
||||
{
|
||||
$name = 'IPS Support';
|
||||
$_supportAccount = \IPS\Member::load( $name, 'name' );
|
||||
if ( $_supportAccount->member_id )
|
||||
{
|
||||
$number = 2;
|
||||
while ( $_supportAccount->member_id )
|
||||
{
|
||||
$name = "IPS Support {$number}";
|
||||
$_supportAccount = \IPS\Member::load( $name, 'name' );
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
|
||||
$supportAccount = new \IPS\Member;
|
||||
$supportAccount->name = $name;
|
||||
$supportAccount->email = 'nobody@invisionpower.com';
|
||||
$supportAccount->member_group_id = \IPS\Settings::i()->admin_group;
|
||||
}
|
||||
|
||||
$supportAccount->members_pass_salt = $supportAccount->generateSalt();
|
||||
$supportAccount->members_pass_hash = $supportAccount->encryptedPassword( $password );
|
||||
$supportAccount->save();
|
||||
|
||||
$admin = json_encode( array( 'name' => $supportAccount->name, 'email' => $supportAccount->email, 'password' => $password, 'dir' => \IPS\CP_DIRECTORY ) );
|
||||
}
|
||||
|
||||
$log = NULL;
|
||||
if ( in_array( 'log', $values['support_request_extra'] ) )
|
||||
{
|
||||
$log = $this->_supportLog( FALSE );
|
||||
}
|
||||
|
||||
$key = md5( \IPS\Http\Url::internal('app=core&module=support&controller=support') );
|
||||
unset( $_SESSION["wizard-{$key}-step"] );
|
||||
unset( $_SESSION["wizard-{$key}-data"] );
|
||||
|
||||
\IPS\Output::i()->parseFileObjectUrls( $values['support_request_body'] );
|
||||
|
||||
$response = \IPS\Http\Url::ips('support')->request()->login( \IPS\Settings::i()->ipb_reg_number, '' )->post( array(
|
||||
'title' => $values['support_request_title'],
|
||||
'message' => $values['support_request_body'],
|
||||
'admin' => $admin,
|
||||
'log' => $log,
|
||||
'_log' => intval( isset( $values['_log'] ) )
|
||||
) );
|
||||
|
||||
switch ( $response->httpResponseCode )
|
||||
{
|
||||
case 200:
|
||||
case 201:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'get_support_done', FALSE, array( 'pluralize' => array( intval( (string) $response ) ) ) ), 'success' );
|
||||
|
||||
case 401:
|
||||
case 403:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_no_license', 'warning' );
|
||||
|
||||
case 429:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_duplicate', 'error' );
|
||||
|
||||
case 502:
|
||||
default:
|
||||
return \IPS\Theme::i()->getTemplate( 'global' )->message( 'get_support_error', 'error' );
|
||||
}
|
||||
}
|
||||
return (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the log that will be sent
|
||||
*
|
||||
* @param bool $checkOnly If TRUE, will just check if there is one to send
|
||||
* @return void
|
||||
*/
|
||||
protected function _supportLog( $checkOnly )
|
||||
{
|
||||
$log = array();
|
||||
$oneDayAgo = \IPS\DateTime::create()->sub( new \DateInterval('P1D') );
|
||||
foreach( \IPS\Log::getUsedMethods() as $method => $levels )
|
||||
{
|
||||
if ( $method != 'none' and $logs = \IPS\Log::i( $method )->getLatestTitles( $oneDayAgo ) and !empty( $logs ) )
|
||||
{
|
||||
$log[ $method ] = $logs;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $checkOnly )
|
||||
{
|
||||
return !empty( $log );
|
||||
}
|
||||
|
||||
$output = '';
|
||||
foreach ( $log as $method => $files )
|
||||
{
|
||||
foreach ( $files as $file )
|
||||
{
|
||||
$output = "/************************/\n" . $file . "\n/************************/\n\n";
|
||||
$output .= \IPS\Log::i( $method )->getLog( $file );
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* View the log that will be sent
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function supportLog()
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('support')->logToSend( $this->_supportLog( FALSE ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief System Logs
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @since 13 Nov 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\support;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error Logs
|
||||
*/
|
||||
class _systemLogs extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'system_logs_view' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage Error Logs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Fetch the data */
|
||||
$dataSource = array();
|
||||
|
||||
foreach( \IPS\Log::getUsedMethods() as $method => $levels )
|
||||
{
|
||||
$logs = \IPS\Log::i( $method )->getMostRecentLogsTitles( 50 );
|
||||
|
||||
foreach( $logs as $log )
|
||||
{
|
||||
$log['method'] = $method;
|
||||
$dataSource[ $log['date'] . '.' . $log['suffix'] ] = $log;
|
||||
}
|
||||
}
|
||||
|
||||
krsort( $dataSource );
|
||||
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Custom( array_slice( $dataSource, 0, 50 ), \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs' ) );
|
||||
$table->langPrefix = 'systemlogs_';
|
||||
$table->mainColumn = 'title';
|
||||
|
||||
$table->widths = array( 'date' => 30, 'title' => 50, 'suffix' => 20 );
|
||||
$table->parsers = array(
|
||||
'suffix'=> function( $val )
|
||||
{
|
||||
return mb_strtoupper( $val );
|
||||
},
|
||||
'method'=> function( $val )
|
||||
{
|
||||
return ucfirst( $val );
|
||||
},
|
||||
'date' => function( $val )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val );
|
||||
},
|
||||
'title' => function( $val, $row )
|
||||
{
|
||||
return "<a href='" . \IPS\Http\Url::internal( "app=core&module=support&controller=systemLogs&do=view&title=" . urlencode( $val ) . '&method=' . $row['method'] ) . "'>{$val}</a>";
|
||||
}
|
||||
);
|
||||
$table->sortBy = $table->sortBy ?: 'date';
|
||||
$table->sortDirection = $table->sortDirection ?: 'desc';
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'support', 'diagnostic_log_settings' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'prunesettings',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs&do=logSettings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('prunesettings') )
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('r__system_logs');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'r__system_logs', (string) $table );
|
||||
}
|
||||
|
||||
/**
|
||||
* View a log file
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function view()
|
||||
{
|
||||
/* Display */
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/systemlogs.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('r__system_logs');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->systemLogView( \IPS\Request::i()->title, \IPS\Log::i( \IPS\Request::i()->method )->getLog( urldecode( \IPS\Request::i()->title ) ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=support&controller=systemLogs" ), \IPS\Member::loggedIn()->language()->addToStack('r__system_logs') );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prune Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function logSettings()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'diagnostic_log_settings' );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_system', \IPS\Settings::i()->prune_log_system, 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__systemlog_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=support&controller=systemLogs' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('systemlogssettings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'systemlogssettings', $form, FALSE );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user