Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief Advanced Settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 10 June 2013
* @version SVN_VERSION_NUMBER
*/
@@ -63,11 +63,11 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Build tab list */
$tabs = array();
$tabs['settings'] = 'server_environment';
if ( \IPS\Settings::i()->use_friendly_urls )
if ( \IPS\Settings::i()->use_friendly_urls and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'advanced_manage_furls' ) )
{
$tabs['furl'] = 'furls';
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'datastore' ) )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'datastore' ) and !\IPS\CIC )
{
$tabs['datastore'] = 'data_store';
}
@@ -116,6 +116,16 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Init */
$form = new \IPS\Helpers\Form;
/* If the datastore isn't working properly, show a message */
if( !\IPS\Data\Store::i()->test() OR \IPS\Db::i()->select( 'COUNT(*)', 'core_log', array( '`category`=? AND `time`>?', 'datastore', \IPS\DateTime::create()->sub( new \DateInterval( 'PT1H' ) )->getTimestamp() ) )->first() >= 10 )
{
/* Have we just recently updated the configuration? If so, ignore this warning for 24 hours */
if( \IPS\Settings::i()->last_data_store_update < \IPS\DateTime::create()->sub( new \DateInterval( 'PT24H' ) )->getTimestamp() )
{
$form->addMessage( 'dashboard_datastore_broken_settings', 'ipsMessage ipsMessage_warning' );
}
}
/* Cold storage */
$extra = array();
$toggles = array();
@@ -250,6 +260,10 @@ class _advanced extends \IPS\Dispatcher\Controller
/* Enable/disable the clearcaches task */
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => intval( $values['cache_method'] === 'None' and $values['cache_guest_page'] ) ), "`key`='clearcache'" );
/* Reset the last update flag for data store */
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => time() ), array( 'conf_key=?', 'last_data_store_update' ) );
unset( \IPS\Data\Store::i()->settings );
/* Display */
$downloadUrl = \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=downloadDatastoreConstants' )->setQueryString( array( 'store_method' => $values['datastore_method'], 'store_config' => str_replace( '\\/', '/', json_encode( $storeConfiguration ) ), 'cache_method' => $values['cache_method'], 'cache_config' => json_encode( $cacheConfiguration ), 'cache_guest_page' => $values['cache_guest_page'] ) );
@@ -274,6 +288,8 @@ class _advanced extends \IPS\Dispatcher\Controller
*/
protected function downloadDatastoreConstants()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'datastore' );
$output = "<?php\n\n";
foreach ( \IPS\IPS::defaultConstants() as $k => $v )
{
@@ -314,22 +330,54 @@ class _advanced extends \IPS\Dispatcher\Controller
}
/* Sort stuff out for the cron setting */
\IPS\Member::loggedIn()->language()->words['task_use_cron_warning'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'task_use_cron_warning', FALSE ), PHP_BINDIR . '/php -d memory_limit=-1 -d max_execution_time=0 ' . \IPS\ROOT_PATH . '/applications/core/interface/task/task.php ' . \IPS\Settings::i()->task_cron_key );
$cronOptions = array( 'togglesOn' => array( 'task_use_cron_warning' ) );
if ( \IPS\CIC )
{
$options = array( 'options' => array(
'ips' => 'task_method_ips'
) );
}
else
{
\IPS\Member::loggedIn()->language()->words['task_method_cron_warning'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'task_method_cron_warning', FALSE ), PHP_BINDIR . '/php -d memory_limit=-1 -d max_execution_time=0 ' . \IPS\ROOT_PATH . '/applications/core/interface/task/task.php ' . \IPS\Settings::i()->task_cron_key );
\IPS\Member::loggedIn()->language()->words['task_method_web_warning'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'task_method_web_warning', FALSE ), \IPS\Http\Url::internal( 'applications/core/interface/task/web.php?key=' . \IPS\Settings::i()->task_cron_key, 'none' ) );
$options = array(
'options' => array(
'normal' => 'task_method_normal',
'cron' => 'task_method_cron',
'web' => 'task_method_web',
),
'toggles' => array(
'cron' => array( 'task_use_cron_cron_warning' ),
'web' => array( 'task_use_cron_web_warning' )
)
);
}
/* Build and show form */
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\YesNo( 'task_use_cron', \IPS\Settings::i()->task_use_cron, FALSE, $cronOptions, function ( $val )
$form->add( new \IPS\Helpers\Form\Radio( 'task_use_cron', \IPS\CIC ? 'ips' : \IPS\Settings::i()->task_use_cron, FALSE, $options, function ( $val )
{
$cronFile = \IPS\ROOT_PATH . '/applications/core/interface/task/task.php';
if ( $val and ( mb_strtoupper( mb_substr( PHP_OS, 0, 3 ) ) !== 'WIN' AND !is_executable( $cronFile ) ) )
if ( $val == 'cron' and ( mb_strtoupper( mb_substr( PHP_OS, 0, 3 ) ) !== 'WIN' AND !is_executable( $cronFile ) ) )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('task_use_cron_executable', FALSE, array( 'sprintf' => array( $cronFile ) ) ) );
}
}, NULL, NULL, 'task_use_cron' ) );
$form->add( new \IPS\Helpers\Form\Number( 'widget_cache_ttl', ( isset( \IPS\Settings::i()->widget_cache_ttl ) ) ? \IPS\Settings::i()->widget_cache_ttl : 60, FALSE, array( 'min' => 60 ), NULL, \IPS\Member::loggedIn()->language()->addToStack('for'), \IPS\Member::loggedIn()->language()->addToStack('seconds') ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'auto_polling_enabled', \IPS\Settings::i()->auto_polling_enabled, FALSE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'theme_disk_cache_templates', \IPS\Settings::i()->theme_disk_cache_templates, FALSE, array( 'togglesOn' => array( 'theme_disk_cache_path' ) ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'theme_disk_cache_path', \IPS\Settings::i()->theme_disk_cache_path ? \IPS\Settings::i()->theme_disk_cache_path : \IPS\ROOT_PATH . '/uploads', FALSE, array(), function( $val )
{
if ( \IPS\Request::i()->theme_disk_cache_templates_checkbox )
{
if ( ! is_dir( \IPS\Request::i()->theme_disk_cache_path ) or ! is_readable( \IPS\Request::i()->theme_disk_cache_path ) or ! is_writable( \IPS\Request::i()->theme_disk_cache_path ) )
{
throw new \InvalidArgumentException( 'theme_disk_cache_path_wrong' );
}
}
}, NULL, NULL, 'theme_disk_cache_path' ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
@@ -351,7 +399,7 @@ class _advanced extends \IPS\Dispatcher\Controller
$table = new \IPS\Helpers\Table\Db( 'core_tasks', \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&do=tasks' ) );
$table->langPrefix = 'task_manager_';
$table->include = array( 'app', 'key', 'frequency', 'next_run' );
$table->include = array( 'app', 'key', 'frequency', 'next_run', 'last_run' );
$table->mainColumn = 'key';
$table->quickSearch = 'key';
$table->sortBy = $table->sortBy ?: 'next_run';
@@ -361,11 +409,11 @@ class _advanced extends \IPS\Dispatcher\Controller
$matches = \IPS\Member::loggedIn()->language()->searchCustom( 'task__', $val, TRUE );
if ( count( $matches ) )
{
return \IPS\Db::i()->in( '`key`', array_keys( $matches ) );
return '(' . \IPS\Db::i()->in( '`key`', array_keys( $matches ) ) . " OR `key` LIKE '%{$val}%')";
}
else
{
return '1=0';
return "`key` LIKE '%{$val}%'";
}
};
@@ -376,6 +424,10 @@ class _advanced extends \IPS\Dispatcher\Controller
{
return $val ? \IPS\Application::load( $val )->_title : \IPS\Plugin::load( $row['plugin'] )->name;
}
catch ( \UnexpectedValueException $e )
{
return NULL;
}
catch ( \OutOfRangeException $e )
{
return NULL;
@@ -418,6 +470,10 @@ class _advanced extends \IPS\Dispatcher\Controller
{
return (string) \IPS\DateTime::ts( $row['next_run'] ?: time() );
}
},
'last_run' => function ( $v, $row )
{
return (string) $row['last_run'] ? \IPS\DateTime::ts( $row['last_run'] ) : \IPS\Member::loggedIn()->language()->addToStack( 'never' );
}
);
@@ -468,6 +524,8 @@ class _advanced extends \IPS\Dispatcher\Controller
*/
protected function taskSettings()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_tasks' );
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Number( 'prune_log_tasks', \IPS\Settings::i()->prune_log_tasks, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'prune_log_tasks' ) );
@@ -627,7 +685,8 @@ class _advanced extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'furl_in_dev', '1C124/5', 403, '' );
}
$definition = \IPS\Http\Url::furlDefinition();
$definition = \IPS\Http\Url\Friendly::furlDefinition();
$table = new \IPS\Helpers\Table\Custom( $definition, \IPS\Http\Url::internal( 'app=core&module=settings&controller=advanced&tab=furl' ) );
$table->include = array( 'friendly', 'real' );
$table->limit = 100;
@@ -645,14 +704,9 @@ class _advanced extends \IPS\Dispatcher\Controller
preg_match_all( '/{([@#])(.+?)}/', $row['friendly'], $matches );
if ( !empty( $matches[0] ) )
{
if ( $val )
{
$val .= '&';
}
foreach ( $matches[0] as $i => $m )
{
$val .= $matches[ 2 ][ $i ] . '=<strong><em>' . ( $matches[ 1 ][ $i ] == '#' ? '123' : 'abc' ) . '</em></strong>';
$val .= '&' . $matches[ 2 ][ $i ] . '=<strong><em>' . ( $matches[ 1 ][ $i ] == '#' ? '123' : 'abc' ) . '</em></strong>';
}
$val .= '</strong>';
}
@@ -684,7 +738,7 @@ class _advanced extends \IPS\Dispatcher\Controller
'data' => array( 'confirm' => '' )
);
}
$table->rowButtons = function( $row, $k ) use ( $definition )
{
$return = array(
@@ -698,17 +752,17 @@ class _advanced extends \IPS\Dispatcher\Controller
if( isset( $definition[ $k ]['custom'] ) )
{
$return['delete'] = array(
'icon' => 'times-circle',
'title' => 'delete',
$return['revert'] = array(
'icon' => 'undo',
'title' => 'revert',
'link' => \IPS\Http\Url::internal( "app=core&module=settings&controller=advanced&do=furlDelete&key={$k}" ),
'data' => array( 'delete' => '' )
'data' => array( 'confirm' => '', 'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack('revert_confirm') )
);
}
return $return;
};
return ( \IPS\Request::i()->advancedSearchForm ? '' : \IPS\Theme::i()->getTemplate('global')->message( 'furl_warning', 'warning' ) ) . $table;
}
@@ -722,7 +776,7 @@ class _advanced extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_furls' );
$current = NULL;
$config = \IPS\Http\Url::furlDefinition();
$config = \IPS\Http\Url\Friendly::furlDefinition();
if ( \IPS\Request::i()->key )
{
$current = ( isset( $config[ \IPS\Request::i()->key ] ) ) ? $config[ \IPS\Request::i()->key ] : NULL;
@@ -736,20 +790,51 @@ class _advanced extends \IPS\Dispatcher\Controller
{
$furl = \IPS\Settings::i()->furl_configuration ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
$currentDefinition = \IPS\Http\Url::furlDefinition();
$save = \IPS\Request::i()->key ? $currentDefinition[ \IPS\Request::i()->key ] : array();
$save['friendly'] = $values['furl_friendly'];
$save['real'] = $values['furl_real'];
$save['custom'] = true;
$currentDefinition = \IPS\Http\Url\Friendly::furlDefinition();
$appTopLevel = NULL;
$appIsDefault = FALSE;
$alias = NULL;
$verify = NULL;
$friendly = $values['furl_friendly'];
if ( \IPS\Request::i()->key )
{
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['alias'] ) )
{
$alias = $currentDefinition[ \IPS\Request::i()->key ]['alias'];
}
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['verify'] ) )
{
$verify = $currentDefinition[ \IPS\Request::i()->key ]['verify'];
}
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['with_top_level'] ) )
{
$appIsDefault = TRUE;
$appTopLevel = mb_substr( $currentDefinition[ \IPS\Request::i()->key ]['with_top_level'], 0, -mb_strlen( $currentDefinition[ \IPS\Request::i()->key ]['friendly'] . '/' ) );
}
if ( isset( $currentDefinition[ \IPS\Request::i()->key ]['without_top_level'] ) )
{
$appIsDefault = FALSE;
if ( $currentDefinition[ \IPS\Request::i()->key ]['without_top_level'] )
{
$appTopLevel = mb_substr( $currentDefinition[ \IPS\Request::i()->key ]['friendly'], 0, -mb_strlen( $currentDefinition[ \IPS\Request::i()->key ]['without_top_level'] . '/' ) );
$friendly = rtrim( preg_replace( '/^' . preg_quote( $appTopLevel, '/' ) . '(\/|$)/', '', $friendly ), '/' );
}
}
}
$save = \IPS\Http\Url\Friendly::buildFurlDefinition( $friendly, $values['furl_real'], $appTopLevel, $appIsDefault, $alias, TRUE, $verify );
if ( \IPS\Request::i()->key )
{
$furl[ \IPS\Request::i()->key ] = $save;
}
else
{
$furl[] = $save;
$key = 'key' . ( count( $furl ) + 1 );
$furl[ $key ] = $save;
}
\IPS\Session::i()->log( 'acplogs__advanced_furl_edited' );
@@ -781,6 +866,9 @@ class _advanced extends \IPS\Dispatcher\Controller
protected function furlDelete()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'advanced_manage_furls' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
$furlDefinition = \IPS\Settings::i()->furl_configuration ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
if( isset( $furlDefinition[ \IPS\Request::i()->key ] ) )
@@ -0,0 +1,105 @@
<?php
/**
* @brief contactus
* @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 29 Sep 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\settings;
/* 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;
}
/**
* contactus
*/
class _contactus extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'contactus_manage' );
parent::execute();
}
/**
* Manage Settings
*
* @return void
*/
protected function manage()
{
$form = $this->_getConfigForm();
if ( $values = $form->values() )
{
$form->saveAsSettings();
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Session::i()->log( 'acplogs__contactus_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=contactus' ), 'saved' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'r__contactus' );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global' )->block( '', $form );
}
/**
* Build the configuration form
*
* @return \IPS\Helpers\Form
*/
protected function _getConfigForm()
{
$form = new \IPS\Helpers\Form;
$options = array();
$toggles = array();
$disabled = array();
$formFields = array();
$form->add( new \IPS\Helpers\Form\Select( 'contact_access', ( \IPS\Settings::i()->contact_access == '*' ) ? '*' : explode( ',', \IPS\Settings::i()->contact_access ), FALSE, array(
'options' => array_combine( array_keys( \IPS\Member\Group::groups() ), array_map( function( $_group ) { return (string) $_group; }, \IPS\Member\Group::groups() ) ),
'multiple' => true,
'unlimited' => '*',
'unlimitedLang' => 'everyone'
), NULL, NULL, NULL, 'contact_access' ) );
/* Get extensions */
$extensions = \IPS\Application::allExtensions( 'core', 'ContactUs', FALSE, 'core', 'InternalEmail', TRUE );
foreach ( $extensions as $k => $class )
{
$class->process( $form, $formFields, $options, $toggles, $disabled );
}
$form->add( new \IPS\Helpers\Form\Radio( 'contact_type', \IPS\Settings::i()->contact_type, FALSE, array(
'options' => $options,
'toggles' => $toggles,
'disabled' => $disabled
) ) );
foreach ( $formFields AS $field )
{
$form->add( $field );
}
return $form;
}
// Create new methods with the same name as the 'do' parameter which should execute it
}
@@ -2,9 +2,9 @@
/**
* @brief email
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 17 Apr 2013
* @version SVN_VERSION_NUMBER
*/
@@ -46,17 +46,44 @@ class _email extends \IPS\Dispatcher\Controller
$settingsForm = new \IPS\Helpers\Form( 'settings_form' );
$settingsForm->addHeader( 'basic_settings' );
$settingsForm->add( new \IPS\Helpers\Form\Email( 'email_out', \IPS\Settings::i()->email_out, TRUE ) );
$settingsForm->add( new \IPS\Helpers\Form\Email( 'email_out', \IPS\Settings::i()->email_out, TRUE, array(), NULL, NULL, NULL, 'email_out' ) );
$settingsForm->add( new \IPS\Helpers\Form\Email( 'email_in', \IPS\Settings::i()->email_in, TRUE ) );
$settingsForm->add( new \IPS\Helpers\Form\Color( 'email_color', \IPS\Settings::i()->email_color, TRUE ) );
$settingsForm->add( new \IPS\Helpers\Form\Upload( 'email_logo', \IPS\Settings::i()->email_logo ? \IPS\File::get( 'core_Theme', \IPS\Settings::i()->email_logo ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ) ) );
$settingsForm->addHeader( 'advanced_settings' );
$settingsForm->add( new \IPS\Helpers\Form\Select( 'mail_method', \IPS\Settings::i()->mail_method, TRUE, array(
'options' => array( 'mail' => 'mail_method_php', 'smtp' => 'mail_method_smtp' ),
$method = \IPS\Settings::i()->mail_method;
$disabled = array();
if ( \IPS\Settings::i()->sparkpost_api_key )
{
if ( \IPS\Settings::i()->sparkpost_use_for == 2 )
{
$method = 'sparkpost';
}
}
else
{
$disabled[] = 'sparkpost';
}
if ( \IPS\Settings::i()->sendgrid_api_key )
{
if ( \IPS\Settings::i()->sendgrid_use_for == 2 )
{
$method = 'sendgrid';
}
}
else
{
$disabled[] = 'sendgrid';
}
$settingsForm->add( new \IPS\Helpers\Form\Radio( 'mail_method', $method, TRUE, array(
'options' => array( 'php' => ( \IPS\CIC ? 'mail_method_cic' : 'mail_method_php' ), 'smtp' => 'mail_method_smtp', 'sendgrid' => 'mail_method_sendgrid', 'sparkpost' => 'mail_method_sparkpost' ),
'disabled' => $disabled,
'toggles' => array(
'mail' => array( 'php_mail_extra' ),
'smtp' => array( 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', 'smtp_helo', 'smtp_protocol' )
'mail' => array( 'php_mail_extra' ),
'smtp' => array( 'smtp_host', 'smtp_port', 'smtp_user', 'smtp_pass', 'smtp_helo', 'smtp_protocol' ),
)
) ) );
$options = array( 'plain' => 'smtp_plaintext', 'ssl' => 'smtp_ssl', 'tls' => 'smtp_tls' );
@@ -65,7 +92,10 @@ class _email extends \IPS\Dispatcher\Controller
$settingsForm->add( new \IPS\Helpers\Form\Number( 'smtp_port', \IPS\Settings::i()->smtp_port, FALSE, array(), NULL, NULL, NULL, 'smtp_port' ) );
$settingsForm->add( new \IPS\Helpers\Form\Text( 'smtp_user', \IPS\Settings::i()->smtp_user, FALSE, array(), NULL, NULL, NULL, 'smtp_user' ) );
$settingsForm->add( new \IPS\Helpers\Form\Password( 'smtp_pass', \IPS\Settings::i()->smtp_pass, FALSE, array(), NULL, NULL, NULL, 'smtp_pass' ) );
$settingsForm->add( new \IPS\Helpers\Form\Text( 'php_mail_extra', \IPS\Settings::i()->php_mail_extra, FALSE, array(), NULL, NULL, NULL, 'php_mail_extra' ) );
if ( !\IPS\CIC )
{
$settingsForm->add( new \IPS\Helpers\Form\Text( 'php_mail_extra', \IPS\Settings::i()->php_mail_extra, FALSE, array(), NULL, NULL, NULL, 'php_mail_extra' ) );
}
if ( $values = $settingsForm->values() )
{
$sendTestEmail = FALSE;
@@ -77,28 +107,40 @@ class _email extends \IPS\Dispatcher\Controller
$sendTestEmail = TRUE;
}
}
if ( $values['mail_method'] != 'sparkpost' and \IPS\Settings::i()->sparkpost_use_for == 2 )
{
$values['sparkpost_use_for'] = 1;
}
elseif ( $values['mail_method'] == 'sparkpost' )
{
$values['sparkpost_use_for'] = 2;
}
if ( $values['mail_method'] != 'sendgrid' and \IPS\Settings::i()->sendgrid_use_for == 2 )
{
$values['sendgrid_use_for'] = 1;
}
elseif ( $values['mail_method'] == 'sendgrid' )
{
$values['sendgrid_use_for'] = 2;
}
$settingsForm->saveAsSettings();
$settingsForm->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplogs__email_settings' );
if( $sendTestEmail )
{
$email = \IPS\Email::buildFromContent( \IPS\Member::loggedIn()->language()->addToStack('email_test_subject'), \IPS\Member::loggedIn()->language()->addToStack('email_test_message'), \IPS\Member::loggedIn()->language()->addToStack('email_test_message') );
$email->from = \IPS\Settings::i()->email_out;
$result = $email->send( \IPS\Member::loggedIn()->email );
if ( $result === TRUE )
$email = \IPS\Email::buildFromContent( \IPS\Member::loggedIn()->language()->get('email_test_subject'), \IPS\Member::loggedIn()->language()->addToStack('email_test_message'), \IPS\Member::loggedIn()->language()->addToStack('email_test_message'), \IPS\Email::TYPE_TRANSACTIONAL );
try
{
$result = $email->_send( \IPS\Member::loggedIn(), array(), array(), \IPS\Settings::i()->email_out );
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( 'email_test_okay_auto', 'success' );
}
elseif( $result instanceof \IPS\Email\Outgoing\Exception )
catch ( \Exception $e )
{
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( 'email_test_error_auto', 'error', $result->getMessage() );
}
/* If php mail fails it throws a regular PHP error */
elseif( $result instanceof \ErrorException )
{
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( 'email_test_error_auto', 'error', $result->getMessage() );
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( 'email_test_error_auto', 'error', $e->getMessage() );
}
}
}
@@ -122,22 +164,15 @@ class _email extends \IPS\Dispatcher\Controller
$testForm->add( new \IPS\Helpers\Form\TextArea( 'message', \IPS\Member::loggedIn()->language()->addToStack('email_test_message'), TRUE ) );
if ( $values = $testForm->values() )
{
$email = \IPS\Email::buildFromContent( $values['subject'], $values['message'], $values['message'] );
$email->from = $values['from'];
$result = $email->send( $values['to'] );
if ( $result === TRUE )
try
{
$email = \IPS\Email::buildFromContent( $values['subject'], $values['message'], $values['message'], \IPS\Email::TYPE_TRANSACTIONAL );
$result = $email->_send( $values['to'], array(), array(), $values['from'] );
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( 'email_test_okay', 'success' );
}
elseif( $result instanceof \IPS\Email\Outgoing\Exception )
catch ( \Exception $exception )
{
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( 'email_test_error', 'error', $result->getMessage() );
}
/* If php mail fails it throws a regular PHP error */
elseif( $result instanceof \ErrorException )
{
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( 'email_test_error', 'error', $result->getMessage() );
$messageHtml = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( get_class( $exception ) . ": " . $exception->getMessage() . " (" . $exception->getCode() . ")", 'error' );
}
}
@@ -262,17 +297,32 @@ class _email extends \IPS\Dispatcher\Controller
{
\IPS\Dispatcher::i()->checkAcpPermission( 'email_errorlog' );
$id = (int) \IPS\Request::i()->id;
$log = \IPS\Db::i()->select( '*', 'core_mail_error_logs', array( 'mlog_id=?', $id ) )->first();
$email = json_decode( $log['mlog_resend_data'], true );
$id = (int) \IPS\Request::i()->id;
$log = \IPS\Db::i()->select( '*', 'core_mail_error_logs', array( 'mlog_id=?', $id ) )->first();
$emailData = json_decode( $log['mlog_resend_data'], true );
try
{
$emailHandler = \IPS\Email::buildFromRaw( $email['headers'], $email['body'] );
$emailHandler->subject = $log['mlog_subject'];
$emailHandler->to = explode( ',', $log['mlog_to'] );
$emailHandler->from = $log['mlog_from'];
$emailHandler->forceSend( $email['boundary'] );
$fromName = NULL;
if ( isset( $emailData['headers']['From'] ) and preg_match( '/=\?UTF-8\?B\?(.+?)?= /', $emailData['headers']['From'], $matches ) )
{
$fromName = base64_decode( $matches[1] );
}
/* Reset basic headers for failed mails */
unset( $emailData['headers']['MIME-Version'] );
unset( $emailData['headers']['Content-Type'] );
unset( $emailData['headers']['Content-Transfer-Encoding'] );
$email = \IPS\Email::buildFromContent( $log['mlog_subject'], $emailData['body']['html'], $emailData['body']['plain'], isset( $emailData['type'] ) ? $emailData['type'] : NULL );
$email->_send(
array_map( 'trim', explode( ',', $log['mlog_to'] ) ),
isset( $emailData['headers']['Cc'] ) ? array_map( 'trim', explode( ',', $emailData['headers']['Cc'] ) ) : array(),
isset( $emailData['headers']['Bcc'] ) ? array_map( 'trim', explode( ',', $emailData['headers']['Bcc'] ) ) : array(),
$log['mlog_from'],
$fromName,
$emailData['headers']
);
}
catch( \Exception $e )
{
@@ -2,9 +2,9 @@
/**
* @brief general
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 17 Apr 2013
* @version SVN_VERSION_NUMBER
*/
@@ -49,7 +49,8 @@ class _general extends \IPS\Dispatcher\Controller
$form->add( new \IPS\Helpers\Form\Editor( 'site_offline_message', \IPS\Settings::i()->site_offline_message, FALSE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'onlineoffline', 'attachIds' => array( NULL, NULL, 'site_offline_message' ) ), NULL, NULL, NULL, 'site_offline_message_id' ) );
$form->add( new \IPS\Helpers\Form\Address( 'site_address', \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address ), FALSE ) );
$form->add( new \IPS\Helpers\Form\Translatable( 'copyright_line', NULL, FALSE, array( 'app' => 'core', 'key' => 'copyright_line_value', 'placeholder' => \IPS\Member::loggedIn()->language()->addToStack('copyright_line_placeholder') ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'upgrade_email', explode( ',', \IPS\Settings::i()->upgrade_email ), FALSE, array( 'stackFieldType' => 'Email' ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'upgrade_email', explode( ',', \IPS\Settings::i()->upgrade_email ), FALSE, array( 'stackFieldType' => 'Email', 'maxItems' => 5 ) ) );
// $form->add( new \IPS\Helpers\Form\YesNo( 'diagnostics_reporting', \IPS\Settings::i()->diagnostics_reporting ) );
if ( $values = $form->values() )
{
@@ -2,9 +2,9 @@
/**
* @brief licensekey
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 17 Apr 2013
* @version SVN_VERSION_NUMBER
*/
@@ -50,14 +50,13 @@ class _licensekey extends \IPS\Dispatcher\Controller
$licenseData = \IPS\IPS::licenseKey();
/* If no license key has been supplied yet just show the form */
if( !isset( $licenseData['key'] ) )
if( !\IPS\Settings::i()->ipb_reg_number )
{
return $this->settings();
}
/* Output */
/* Init */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('license_settings');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'licensekey', 'core' )->overview( $licenseData );
\IPS\Output::i()->sidebar['actions'] = array(
'refresh' => array(
'icon' => 'refresh',
@@ -71,6 +70,17 @@ class _licensekey extends \IPS\Dispatcher\Controller
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('license_change') )
),
);
/* If we have a license key, but the server doesn't recognise it, show an error */
if ( !$licenseData )
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'license_not_recognised', 'error' );
}
/* Otherwise show the normal info */
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'licensekey', 'core' )->overview( $licenseData );
}
}
/**
@@ -94,10 +104,30 @@ class _licensekey extends \IPS\Dispatcher\Controller
*/
protected function settings()
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', NULL, TRUE, array(), function( $val ){
\IPS\IPS::checkLicenseKey( $val, \IPS\Settings::i()->base_url );
} ) );
$$form = new \IPS\Helpers\Form;
$form->addHeader('ipb_license_edit_main');
$form->add( new \IPS\Helpers\Form\Text( 'ipb_reg_number', \IPS\Settings::i()->ipb_reg_number, TRUE ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_active', \IPS\Settings::i()->ipb_license_active ) );
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_expires', \IPS\Settings::i()->ipb_license_expires ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_cloud', \IPS\Settings::i()->ipb_license_cloud ) );
$form->addHeader('ipb_license_urls');
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_url', \IPS\Settings::i()->ipb_license_url ) );
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_test_url', \IPS\Settings::i()->ipb_license_test_url ) );
$form->addHeader('ipb_license_components');
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_forums', \IPS\Settings::i()->ipb_license_product_forums ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_calendar', \IPS\Settings::i()->ipb_license_product_calendar ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_blog', \IPS\Settings::i()->ipb_license_product_blog ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_gallery', \IPS\Settings::i()->ipb_license_product_gallery ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_downloads', \IPS\Settings::i()->ipb_license_product_downloads ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_cms', \IPS\Settings::i()->ipb_license_product_cms ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_nexus', \IPS\Settings::i()->ipb_license_product_nexus ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_license_product_copyright', \IPS\Settings::i()->ipb_license_product_copyright ) );
$form->addHeader('ipb_license_services');
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_chat_limit', \IPS\Settings::i()->ipb_license_chat_limit ) );
$form->add( new \IPS\Helpers\Form\Text( 'ipb_license_support', \IPS\Settings::i()->ipb_license_support ) );
if ( $values = $form->values() )
{
@@ -2,9 +2,9 @@
/**
* @brief Login Handlers
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 15 Mar 2013
* @version SVN_VERSION_NUMBER
*/
@@ -64,7 +64,7 @@ class _login extends \IPS\Node\Controller
/* Show IPS Connect "master" information */
$masterUrl = \IPS\Http\Url::internal( 'applications/core/interface/ipsconnect/ipsconnect.php', 'none' );
$masterKey = md5( md5( \IPS\Settings::i()->sql_user . \IPS\Settings::i()->sql_pass ) . \IPS\Settings::i()->board_start );
$masterKey = \IPS\CONNECT_MASTER_KEY ?: md5( md5( \IPS\Settings::i()->sql_user . \IPS\Settings::i()->sql_pass ) . \IPS\Settings::i()->board_start );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'login_ipsconnect_info', FALSE, array( 'sprintf' => array( $masterUrl, $masterKey ) ) ), 'info', NULL, FALSE );
@@ -117,6 +117,9 @@ class _login extends \IPS\Node\Controller
{
\IPS\Output::i()->error( 'login_atleast_one', '1C166/3', 403, '' );
}
/* Allow the login handler to do stuff on-disable */
$node->onDisable();
}
/* Clear guest page caches */
@@ -124,28 +127,6 @@ class _login extends \IPS\Node\Controller
return parent::enableToggle();
}
/**
* Delete
*
* @return void
*/
protected function delete()
{
$node = \IPS\Login\LoginAbstract::load( \IPS\Request::i()->id );
$others = \IPS\Db::i()->select( 'count(*)', 'core_login_handlers', array( 'login_enabled=? and login_key<>?', 1, $node->key ) )->first();
if( !$others )
{
\IPS\Output::i()->error( 'login_atleast_one', '1C166/3', 403, '' );
}
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
return parent::delete();
}
/**
* Settings
@@ -158,7 +139,7 @@ class _login extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form();
$form->addHeader( 'ipb_bruteforce_attempts' );
$form->add( new \IPS\Helpers\Form\Number( 'ipb_bruteforce_attempts', \IPS\Settings::i()->ipb_bruteforce_attempts, FALSE, array( 'min' => 0, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('failed_logins'), 'ipb_bruteforce_attempts' ) );
$form->add( new \IPS\Helpers\Form\Number( 'ipb_bruteforce_period', \IPS\Settings::i()->ipb_bruteforce_period, FALSE, array( 'min' => 0, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('minutes'), 'ipb_bruteforce_period' ) );
$form->add( new \IPS\Helpers\Form\Number( 'ipb_bruteforce_period', \IPS\Settings::i()->ipb_bruteforce_period, FALSE, array( 'min' => 0, 'max' => 10000, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('minutes'), 'ipb_bruteforce_period' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'ipb_bruteforce_unlock', \IPS\Settings::i()->ipb_bruteforce_unlock, FALSE, array(), NULL, NULL, NULL, 'ipb_bruteforce_unlock' ) );
$form->addHeader( 'login_settings' );
@@ -193,9 +174,33 @@ class _login extends \IPS\Node\Controller
if ( $values = $form->values() )
{
$values['disable_anonymous'] = $values['disable_anonymous'] ? FALSE : TRUE;
/* unlock all locked members if we have disabled the locking */
if ( \IPS\Settings::i()->ipb_bruteforce_attempts > 0 AND $values['ipb_bruteforce_attempts'] == 0 )
{
\IPS\Member::updateAllMembers( array( 'failed_logins' => NULL , 'failed_login_count' => 0 ) );
/* disable task */
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), "`key`='unlockmembers'" );
}
else if ( $values['ipb_bruteforce_attempts'] > 0 )
{
/* enable task */
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), "`key`='unlockmembers'" );
}
/* Cache this for the later check */
$currentLoginSetting = \IPS\Settings::i()->logins_over_https;
$form->saveAsSettings( $values );
/* Reset datastore if https setting has changed */
if( $currentLoginSetting != $values['logins_over_https'] )
{
\IPS\Theme::deleteCompiledCss();
\IPS\Data\Store::i()->clearAll();
}
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
@@ -262,8 +267,8 @@ class _login extends \IPS\Node\Controller
/* If this is a registered slave but the slave is telling us Connect is disabled, remove it */
if( isset( $response['status'] ) AND $response['status'] == 'DISABLED' )
{
\IPS\Db::i()->delete( 'core_ipsconnect_slaves', array( 'slave_id=?', $request['slave_id'] ) );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => \IPS\Db::i()->select( 'COUNT(*)', 'core_ipsconnect_slaves' )->first() ), array( 'conf_key=?', 'connect_slaves' ) );
\IPS\Db::i()->update( 'core_ipsconnect_slaves', array( 'slave_enabled' => 0 ), array( 'slave_id=?', $request['slave_id'] ) );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => \IPS\Db::i()->select( 'COUNT(*)', 'core_ipsconnect_slaves', array( 'slave_enabled=?', 1 ) )->first() ), array( 'conf_key=?', 'connect_slaves' ) );
unset( \IPS\Data\Store::i()->settings );
}
else if( !isset( $response['status'] ) OR $response['status'] != 'SUCCESS' )
@@ -293,7 +298,7 @@ class _login extends \IPS\Node\Controller
\IPS\Session::i()->log( 'acplog__connect_queue_cleared' );
/* Disable task */
\IPS\DB::i()->update( 'core_tasks', array( 'enabled' => 0 ), "`key`='ipsconnect'" );
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), "`key`='connect'" );
return NULL;
}
@@ -0,0 +1,268 @@
<?php
/**
* @brief Multi-Factor Authentication
* @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 30 Nov 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\settings;
/* 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;
}
/**
* Multi-Factor Authentication
*/
class _mfa extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'mfa_manage' );
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
$activeTabContents = '';
$tabs = array(
'handlers' => 'mfa_handlers',
'settings' => 'mfa_settings'
);
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'handlers';
if ( $activeTab === 'handlers' )
{
$activeTabContents = $this->_manageHandlers();
}
else
{
$activeTabContents = $this->_manageSettings();
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_settings_mfa');
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output = $activeTabContents;
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=settings&controller=mfa" ) );
}
}
/**
* Manage Handlers
*
* @return string
*/
protected function _manageHandlers()
{
/* Create the tree */
$url = \IPS\Http\Url::internal( "app=core&module=settings&controller=mfa&tab=handlers" );
$tree = new \IPS\Helpers\Tree\Tree(
$url,
NULL,
function() use( $url ) {
$return = array();
foreach ( \IPS\MFA\MFAHandler::handlers() as $key => $handler )
{
$return[] = \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row(
$url,
$key,
\IPS\Member::loggedIn()->language()->addToStack("mfa_{$key}_title"),
FALSE,
array(
'settings' => array(
'icon' => 'cog',
'title' => 'settings',
'link' => $url->setQueryString( array( 'do' => 'settings', 'key' => $key ) ),
)
),
\IPS\Member::loggedIn()->language()->addToStack("mfa_{$key}_desc"),
NULL,
NULL,
TRUE,
$handler->isEnabled()
);
}
return $return;
},
NULL,
NULL,
NULL
);
/* Return */
return \IPS\Theme::i()->getTemplate( 'forms' )->blurb( 'mfa_blurb', TRUE, TRUE ) . $tree;
}
/**
* Enable/Disable Toggle
*
* @return void
*/
protected function enableToggle()
{
$key = \IPS\Request::i()->id;
$handlers = \IPS\MFA\MFAHandler::handlers();
if ( !isset( $handlers[ $key ] ) )
{
\IPS\Output::i()->error( 'node_error', '2C345/1', 404, '' );
}
try
{
$handlers[ $key ]->toggle( \IPS\Request::i()->status );
if ( \IPS\Request::i()->status )
{
\IPS\Session::i()->log( 'acplogs__mfa_handler_enabled', array( "mfa_{$key}_title" => TRUE ) );
}
else
{
\IPS\Session::i()->log( 'acplogs__mfa_handler_disabled', array( "mfa_{$key}_title" => TRUE ) );
}
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json('OK');
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=settings&controller=mfa" ) );
}
}
catch ( \LogicException $e )
{
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->error( $e->getMessage(), $e->getCode() );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=applications&controller=enhancements&do=edit&id=" . \IPS\Request::i()->id ) );
}
}
}
/**
* Handler Settings
*
* @return void
*/
protected function settings()
{
$key = \IPS\Request::i()->key;
$handlers = \IPS\MFA\MFAHandler::handlers();
if ( !isset( $handlers[ $key ] ) )
{
\IPS\Output::i()->error( 'node_error', '2C345/2', 404, '' );
}
$output = $handlers[ $key ]->acpSettings();
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack("mfa_{$key}_title");
\IPS\Output::i()->output = $output;
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal('app=core&module=settings&controller=mfa&tab=handlers'), \IPS\Member::loggedIn()->language()->addToStack('menu__core_settings_mfa') );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack("mfa_{$key}_title") );
}
/**
* Manage Settings
*
* @return string
*/
protected function _manageSettings()
{
$form = new \IPS\Helpers\Form;
$form->addHeader('mfa_header_setup');
$groups = array_combine( array_keys( \IPS\Member\Group::groups() ), array_map( function( $_group ) { return (string) $_group; }, \IPS\Member\Group::groups() ) );
$form->add( new \IPS\Helpers\Form\Select( 'mfa_required_groups', \IPS\Settings::i()->mfa_required_groups == '*' ? '*' : explode( ',', \IPS\Settings::i()->mfa_required_groups ), FALSE, array(
'multiple' => TRUE,
'options' => $groups,
'unlimited' => '*',
'unlimitedLang' => 'everyone',
) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'mfa_required_prompt', \IPS\Settings::i()->mfa_required_prompt, FALSE, array(
'options' => array(
'immediate' => 'mfa_prompt_immediate',
'access' => 'mfa_prompt_access',
)
), NULL, NULL, NULL, 'mfa_required_prompt' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'mfa_optional_prompt', \IPS\Settings::i()->mfa_optional_prompt, FALSE, array(
'options' => array(
'immediate' => 'mfa_prompt_immediate',
'access' => 'mfa_prompt_access',
'none' => 'mfa_prompt_none',
),
'toggles' => array(
'immediate' => array( 'security_questions_opt_out_warning' ),
'access' => array( 'security_questions_opt_out_warning' ),
)
), NULL, NULL, NULL, 'mfa_optional_prompt' ) );
$form->add( new \IPS\Helpers\Form\Translatable( 'security_questions_opt_out_warning', NULL, FALSE, array( 'app' => 'core', 'key' => 'security_questions_opt_out_warning_value' ), NULL, NULL, NULL, 'security_questions_opt_out_warning' ) );
$form->addHeader('mfa_header_authentication');
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'security_questions_areas', \IPS\Settings::i()->security_questions_areas ? explode( ',', \IPS\Settings::i()->security_questions_areas ) : array_keys( \IPS\MFA\MFAHandler::areas() ), FALSE, array( 'options' => \IPS\MFA\MFAHandler::areas() ), NULL, NULL, NULL, 'security_questions_areas' ) );
$form->add( new \IPS\Helpers\Form\Number( 'security_questions_timer', \IPS\Settings::i()->security_questions_timer, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'security_questions_timer_session' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('minutes') ) );
$form->addHeader('mfa_header_recovery');
$form->add( new \IPS\Helpers\Form\Number( 'security_questions_tries', \IPS\Settings::i()->security_questions_tries, FALSE, array( 'min' => 1 ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'mfa_lockout_behaviour', \IPS\Settings::i()->mfa_lockout_behaviour, FALSE, array(
'options' => array(
'lock' => 'mfa_lockout_behaviour_lock',
'email' => 'mfa_lockout_behaviour_email',
'contact' => 'mfa_lockout_behaviour_contact',
),
'toggles' => array(
'lock' => array( 'mfa_lockout_time' )
)
) ) );
$form->add( new \IPS\Helpers\Form\Number( 'mfa_lockout_time', \IPS\Settings::i()->mfa_lockout_time, FALSE, array( 'min' => 1 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('minutes'), 'mfa_lockout_time' ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'mfa_forgot_behaviour', explode( ',', \IPS\Settings::i()->mfa_forgot_behaviour ), FALSE, array(
'options' => array(
'email' => 'mfa_forgot_behaviour_email',
'contact' => 'mfa_forgot_behaviour_contact',
)
) ) );
if ( $values = $form->values() )
{
\IPS\Lang::saveCustom( 'core', 'security_questions_opt_out_warning_value', $values['security_questions_opt_out_warning'] );
unset( $values['security_questions_opt_out_warning'] );
$values['mfa_required_groups'] = ( $values['mfa_required_groups'] == '*' ) ? '*' : implode( ',', $values['mfa_required_groups'] );
$values['mfa_forgot_behaviour'] = implode( ',', $values['mfa_forgot_behaviour'] );
$values['security_questions_areas'] = implode( ',', $values['security_questions_areas'] );
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplogs__mfa_settings_updated' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=mfa&tab=settings' ), 'saved' );
}
return (string) $form;
}
}
@@ -2,9 +2,9 @@
/**
* @brief Manage Posting Settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 20 Jun 2013
* @version SVN_VERSION_NUMBER
*/
@@ -112,13 +112,15 @@ class _posting extends \IPS\Dispatcher\Controller
) ) );
$form->add( new \IPS\Helpers\Form\Text( 'attach_allowed_extensions', \IPS\Settings::i()->attach_allowed_extensions ? explode( ',', \IPS\Settings::i()->attach_allowed_extensions ) : NULL, FALSE, array( 'nullLang' => 'no_restriction', 'autocomplete' => array( 'freeChoice' => TRUE, 'source' => array( 'doc', 'docx', 'log', 'msg', 'odt', 'pages', 'rtf', 'tex', 'txt', 'wpd', 'wps', 'csv', 'dat', 'gbr', 'ged', 'key', 'keychain', 'pps', 'ppt', 'pptx', 'sdf', 'tar', 'tax2012', 'tax2014', 'vcf', 'xml', 'aif', 'iff', 'm3u', 'm4a', 'mid', 'mp3', 'mpa', 'ra', 'wav', 'wma', '3g2', '3gp', 'asf', 'asx', 'avi', 'flv', 'm4v', 'mov', 'mp4', 'mpg', 'rm', 'srt', 'swf', 'vob', 'wmv', '3dm', '3ds', 'max', 'obj', 'bmp', 'dds', 'gif', 'jpg', 'png', 'psd', 'pspimage', 'tga', 'thm', 'tif', 'tiff', 'yuv', 'ai', 'eps', 'ps', 'svg', 'indd', 'pct', 'pdf', 'xlr', 'xls', 'xlsx', 'accdb', 'db', 'dbf', 'mdb', 'pdb', 'sql', 'apk', 'app', 'bat', 'cgi', 'com', 'exe', 'gadget', 'jar', 'pif', 'vb', 'wsf', 'dem', 'gam', 'nes', 'rom', 'sav', 'dwg', 'dxf', 'gpx', 'kml', 'kmz', 'asp', 'aspx', 'cer', 'cfm', 'csr', 'css', 'htm', 'html', 'js', 'jsp', 'php', 'rss', 'xhtml', 'crx', 'plugin', 'fnt', 'fon', 'otf', 'ttf', 'cab', 'cpl', 'cur', 'deskthemepack', 'dll', 'dmp', 'drv', 'icns', 'ico', 'lnk', 'sys', 'cfg', 'ini', 'prf', 'hqx', 'mim', 'uue', '7z', 'cbr', 'deb', 'gz', 'pkg', 'rar', 'rpm', 'sitx', 'tar.gz', 'zip', 'zipx', 'bin', 'cue', 'dmg', 'iso', 'mdf', 'toast', 'vcd', 'c', 'class', 'cpp', 'cs', 'dtd', 'fla', 'h', 'java', 'lua', 'm', 'pl', 'py', 'sh', 'sln', 'swift', 'vcxproj', 'xcodeproj', 'bak', 'tmp', 'crdownload', 'ics', 'msi', 'part', 'torrent' ) ) ), NULL, NULL, NULL, 'attach_allowed_extensions' ) );
$form->addHeader('posting_images');
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_remote_images', \IPS\Settings::i()->allow_remote_images, FALSE, array( 'togglesOn' => array( 'remote_image_proxy' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'remote_image_proxy', \IPS\Settings::i()->remote_image_proxy, FALSE, array(), NULL, NULL, NULL, 'remote_image_proxy' ) );
$form->add( new \IPS\Helpers\Form\WidthHeight( 'attachment_resample_size', \IPS\Settings::i()->attachment_resample_size ? explode( 'x', \IPS\Settings::i()->attachment_resample_size ) : array( 0, 0 ), FALSE, array( 'resizableDiv' => FALSE, 'unlimited' => array( 0, 0 ) ), NULL, NULL, NULL, 'attachment_resample_size' ) );
$current = ( isset( \IPS\Settings::i()->attachment_image_size ) ) ? explode( 'x', \IPS\Settings::i()->attachment_image_size ) : array( 1000, 750 );
$form->add( new \IPS\Helpers\Form\WidthHeight( 'attachment_image_size', $current, FALSE, array( 'resizableDiv' => FALSE ), NULL, NULL, NULL, 'attachment_image_size' ) );
$form->add( new \IPS\Helpers\Form\Number( 'max_video_width', \IPS\Settings::i()->max_video_width, FALSE, array( 'unlimited' => 0 ), NULL, NULL, 'px' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'editor_embeds', \IPS\Settings::i()->editor_embeds, FALSE, array( 'togglesOn' => array( 'max_video_width' ) ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'max_video_width', \IPS\Settings::i()->max_video_width, FALSE, array( 'unlimited' => 0 ), NULL, NULL, 'px', 'max_video_width' ) );
$form->addHeader('remote_images');
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_remote_images', \IPS\Settings::i()->allow_remote_images, FALSE, array( 'togglesOn' => array( 'remote_image_proxy' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'remote_image_proxy', \IPS\Settings::i()->remote_image_proxy, FALSE, array( 'togglesOn' => array( 'remote_image_proxy_cache' ) ), NULL, NULL, NULL, 'remote_image_proxy' ) );
$form->add( new \IPS\Helpers\Form\Number( 'image_proxy_cache_period', \IPS\Settings::i()->image_proxy_cache_period, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'indefinitely' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('for'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'remote_image_proxy_cache' ) );
$form->addHeader('posting_content');
$form->add( new \IPS\Helpers\Form\Number( 'max_title_length', \IPS\Settings::i()->max_title_length, FALSE, array( 'max' => 255 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('max_title_length_suffix') ) );
$form->add( new \IPS\Helpers\Form\Number( 'merge_concurrent_posts', \IPS\Settings::i()->merge_concurrent_posts, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('minutes') ) );
@@ -169,6 +171,8 @@ class _posting extends \IPS\Dispatcher\Controller
/* Save values */
if ( $values = $form->values() )
{
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => (int) $values['allow_remote_images'] ), array( '`key`=?', 'imageproxy' ) );
$clearCss = ( $values['max_video_width'] !== \IPS\Settings::i()->max_video_width );
$values['attachment_resample_size'] = implode( 'x', $values['attachment_resample_size'] );
@@ -208,71 +212,7 @@ class _posting extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'posting_manage_profanity' );
/* Create the table */
$table = new \IPS\Helpers\Table\Db( 'core_profanity_filters', \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&tab=profanityFilters' ) );
$table->langPrefix = 'profanity_';
$table->mainColumn = 'type';
/* Columns we need */
$table->include = array( 'type', 'swop', 'm_exact' );
/* Default sort options */
$table->sortBy = $table->sortBy ?: 'type';
$table->sortDirection = $table->sortDirection ?: 'desc';
/* Filters */
$table->filters = array(
'profanity_filter_exact' => 'm_exact=1',
'profanity_filter_loose' => 'm_exact=0',
);
/* Search */
$table->quickSearch = 'type';
/* Custom parsers */
$table->parsers = array(
'm_exact' => function( $val, $row )
{
return ( $val ) ? \IPS\Member::loggedIn()->language()->addToStack('profanity_filter_exact') : \IPS\Member::loggedIn()->language()->addToStack('profanity_filter_loose');
}
);
/* Specify the root buttons */
$table->rootButtons['add'] = array(
'icon' => 'plus',
'title' => 'profanity_add',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=profanity' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('profanity_add') )
);
$table->rootButtons['download'] = array(
'icon' => 'download',
'title' => 'download',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=downloadProfanity' ),
'data' => array( 'confirm' => '', 'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack('profanity_download'), 'confirmIcon' => 'info', 'confirmButtons' => json_encode( array( 'ok' => \IPS\Member::loggedIn()->language()->addToStack('download'), 'cancel' => \IPS\Member::loggedIn()->language()->addToStack('cancel') ) ) )
);
/* And the row buttons */
$table->rowButtons = function( $row )
{
$return = array();
$return['edit'] = array(
'icon' => 'pencil',
'title' => 'edit',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=profanity&id=' ) . $row['wid'],
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit') )
);
$return['delete'] = array(
'icon' => 'times',
'title' => 'delete',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=deleteProfanityFilters&id=' ) . $row['wid'],
'data' => array( 'delete' => '' ),
);
return $return;
};
$table = \IPS\core\Profanity::table();
/* So people don't set up filters, test with their admin account and think it's not working */
$groupsThatBypass = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_groups', array( 'g_bypass_badwords=1' ) ), 'IPS\Member\Group' );
@@ -311,14 +251,36 @@ class _posting extends \IPS\Dispatcher\Controller
'black' => 'url_blacklist',
'white' => "url_whitelist" ),
'toggles' => array(
'black' => array( 'ipb_url_blacklist' ),
'white' => array( 'ipb_url_whitelist' ),
'none' => array(),
'black' => array( 'ipb_url_blacklist', 'url_filter_action' ),
'white' => array( 'ipb_url_whitelist', 'url_filter_action' ),
'none' => array( 'url_filter_any_action' ),
)
) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'ipb_url_whitelist', \IPS\Settings::i()->ipb_url_whitelist ? explode( ",", \IPS\Settings::i()->ipb_url_whitelist ) : array(), FALSE, array(), NULL, NULL, NULL, 'ipb_url_whitelist' ) );
$form->add( new \IPS\Helpers\Form\Stack( 'ipb_url_blacklist', \IPS\Settings::i()->ipb_url_blacklist ? explode( ",", \IPS\Settings::i()->ipb_url_blacklist ) : array(), FALSE, array(), NULL, NULL, NULL, 'ipb_url_blacklist' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'url_filter_action', \IPS\Settings::i()->url_filter_action, FALSE, array(
'options' => array(
'block' => 'url_filter_block',
'moderate' => 'url_filter_moderate'
),
'descriptions' => array(
'block' => 'url_filter_block_desc',
'moderate' => 'url_filter_moderate_desc'
)
), NULL, NULL, NULL, 'url_filter_action' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'url_filter_any_action', \IPS\Settings::i()->url_filter_any_action, FALSE, array(
'options' => array(
'allow' => 'url_filter_any_allow',
'moderate' => 'url_filter_any_moderate'
),
'description' => array(
'allow' => 'url_filter_any_allow_desc',
'moderate' => 'url_filter_any_moderate_desc'
)
), NULL, NULL, NULL, 'url_filter_any_action' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'links_external', \IPS\Settings::i()->links_external ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'posts_add_nofollow', \IPS\Settings::i()->posts_add_nofollow, FALSE, array( 'togglesOn' => array( 'posts_add_nofollow_exclude' ) ), NULL, NULL, NULL, 'posts_add_nofollow' ) );
@@ -336,6 +298,8 @@ class _posting extends \IPS\Dispatcher\Controller
\IPS\Data\Cache::i()->clearAll();
\IPS\Session::i()->log( 'acplogs__url_filter_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&tab=urlFilters' ), 'saved' );
}
return $form;
@@ -374,17 +338,14 @@ class _posting extends \IPS\Dispatcher\Controller
);
/* Specify the buttons */
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'acronym', 'acronym_add' ) )
{
$table->rootButtons = array(
'add' => array(
'icon' => 'plus',
'title' => 'acronym_add',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=acronym' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('acronym_add') )
)
);
}
$table->rootButtons = array(
'add' => array(
'icon' => 'plus',
'title' => 'acronym_add',
'link' => \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=acronym' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('acronym_add') )
)
);
$table->rowButtons = function( $row )
{
@@ -498,29 +459,13 @@ class _posting extends \IPS\Dispatcher\Controller
{
try
{
$current = \IPS\Db::i()->select( '*', 'core_profanity_filters', array( 'wid=?', \IPS\Request::i()->id ) )->first();
$current = \IPS\core\Profanity::load( \IPS\Request::i()->id );
}
catch ( \UnderflowException $e ) { }
catch ( \OutOfRangeException $e ) { }
}
/* Build form */
$form = new \IPS\Helpers\Form();
if ( !$current )
{
$form->addTab('add');
}
$form->add( new \IPS\Helpers\Form\Text( 'profanity_type', ( $current ) ? $current['type'] : NULL, NULL, array() ) );
$form->add( new \IPS\Helpers\Form\Text( 'profanity_swop', ( $current ) ? $current['swop'] : NULL, NULL, array() ) );
$form->add( new \IPS\Helpers\Form\Radio( 'profanity_m_exact', ( $current ) ? $current['m_exact'] : NULL, FALSE, array(
'options' => array(
'1' => 'profanity_filter_exact',
'0' => 'profanity_filter_loose' ) )
) );
if ( !$current )
{
$form->addTab('upload');
$form->add( new \IPS\Helpers\Form\Upload( 'profanity_upload', NULL, NULL, array( 'allowedFileTypes' => array( 'xml' ), 'temporary' => TRUE ) ) );
}
$form = \IPS\core\Profanity::form( $current );
/* Handle submissions */
if ( $values = $form->values() )
@@ -533,33 +478,34 @@ class _posting extends \IPS\Dispatcher\Controller
move_uploaded_file( $values['profanity_upload'], $tempFile );
/* Initate a redirector */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=importProfanity&file=' . urlencode( $tempFile ) . '&key=' . md5_file( $tempFile ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=importProfanity' )->setQueryString( array( 'file' => $tempFile, 'key' => md5_file( $tempFile ) ) ) );
}
/* Normal */
else
{
if ( $values['profanity_type'] and $values['profanity_swop'] )
if ( $values['profanity_type'] )
{
$save = array(
'type' => $values['profanity_type'],
'swop' => $values['profanity_swop'],
'm_exact' => $values['profanity_m_exact']
);
if( $current )
if ( $values['profanity_action'] == 'swap' AND !$values['profanity_swop'] )
{
\IPS\Db::i()->update( 'core_profanity_filters', $save, array( 'wid=?', $current['wid'] ) );
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'profanity_add_error' );
}
else
{
\IPS\Db::i()->insert( 'core_profanity_filters', $save );
$save = array(
'type' => $values['profanity_type'],
'swop' => $values['profanity_swop'],
'm_exact' => $values['profanity_m_exact'],
'action' => $values['profanity_action']
);
\IPS\core\Profanity::createFromForm( $save, $current );
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&tab=profanityFilters' ), 'saved' );
}
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&tab=profanityFilters' ), 'saved' );
}
else
{
@@ -591,20 +537,24 @@ class _posting extends \IPS\Dispatcher\Controller
$xml->startDocument( '1.0', 'UTF-8' );
$xml->startElement('badwordexport');
$xml->startElement('badwordgroup');
foreach ( \IPS\Db::i()->select( '*', 'core_profanity_filters' ) as $profanity )
foreach ( \IPS\core\Profanity::getProfanity() as $profanity )
{
$xml->startElement('badword');
$xml->startElement('type');
$xml->text( $profanity['type'] );
$xml->text( $profanity->type );
$xml->endElement();
$xml->startElement('swop');
$xml->text( $profanity['swop'] );
$xml->text( $profanity->swop );
$xml->endElement();
$xml->startElement('m_exact');
$xml->text( $profanity['m_exact'] );
$xml->text( $profanity->m_exact );
$xml->endElement();
$xml->startElement('action');
$xml->text( $profanity->action );
$xml->endElement();
$xml->endElement();
@@ -628,13 +578,15 @@ class _posting extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'generic_error', '3C256/1', 500, '' );
}
$url = \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=importProfanity&file=' . urlencode( \IPS\Request::i()->file ) . '&key=' . \IPS\Request::i()->key );
$url = \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&do=importProfanity' )->setQueryString( array( 'file' => \IPS\Request::i()->file, 'key' => \IPS\Request::i()->key ) );
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect(
$url,
function( $data )
{
$data = intval( $data );
/* Open XML file */
$xml = new \XMLReader;
$xml = new \IPS\Xml\XMLReader;
$xml->open( \IPS\Request::i()->file );
$xml->read(); //badwordexport
$xml->read(); //badwordexport
@@ -663,14 +615,17 @@ class _posting extends \IPS\Dispatcher\Controller
$xml->next();
$xml->read();
$save['m_exact'] = $xml->readString();
$xml->next();
$xml->read();
$save['action'] = $xml->readString();
try
{
$current = \IPS\Db::i()->select( 'wid', 'core_profanity_filters', array( 'type=?', $save['type'] ) )->first();
\IPS\Db::i()->update( 'core_profanity_filters', $save, array( 'wid=?', $current ) );
$current = \IPS\core\Profanity::load( $save['type'], 'type' );
\IPS\core\Profanity::createFromForm( $save, $current );
}
catch ( \UnderflowException $e )
catch ( \OutOfRangeException $e )
{
\IPS\Db::i()->insert( 'core_profanity_filters', $save );
\IPS\core\Profanity::createFromForm( $save );
}
/* Move to next */
@@ -683,6 +638,8 @@ class _posting extends \IPS\Dispatcher\Controller
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
@unlink( \IPS\Request::i()->file );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=settings&controller=posting&tab=profanityFilters' ) );
}
);
@@ -731,9 +688,12 @@ class _posting extends \IPS\Dispatcher\Controller
public function deleteProfanityFilters()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'posting_manage_profanity' );
\IPS\Db::i()->delete( 'core_profanity_filters', array( 'wid=?', \IPS\Request::i()->id ) );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
\IPS\core\Profanity::load( \IPS\Request::i()->id )->delete();
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
@@ -749,7 +709,10 @@ class _posting extends \IPS\Dispatcher\Controller
public function deleteAcronym()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'posting_manage_acronym' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
\IPS\core\Acronym::load( \IPS\Request::i()->id )->delete();
/* Clear guest page caches */
@@ -758,4 +721,17 @@ class _posting extends \IPS\Dispatcher\Controller
/* And redirect */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=settings&controller=posting&tab=acronymExpansion" ) );
}
/**
* Rebuild attachment thumbnails
*
* @return void
*/
public function rebuildThumbnails()
{
\IPS\Task::queue( 'core', 'RebuildAttachmentThumbnails', array(), 4 );
/* And redirect */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=settings&controller=posting" ), 'thumbnails_rebuilt' );
}
}
@@ -0,0 +1,72 @@
<?php
/**
* @brief Security Questions
* @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 26 Aug 2016
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\settings;
/* 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;
}
/**
* Security Questions
*/
class _securityquestions extends \IPS\Node\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\MFA\SecurityQuestions\Question';
/**
* Form
*
* @return void
*/
public function form()
{
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal('app=core&module=settings&controller=mfa&tab=handlers'), \IPS\Member::loggedIn()->language()->addToStack('menu__core_settings_mfa') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal('app=core&module=settings&controller=mfa&tab=questions&do=settings&key=questions'), \IPS\Member::loggedIn()->language()->addToStack("mfa_questions_title") );
parent::form();
}
/**
* Settings
*
* @return void
*/
protected function settings()
{
return $this->manage();
}
/**
* Redirect after save
*
* @param \IPS\Node\Model $old A clone of the node as it was before or NULL if this is a creation
* @param \IPS\Node\Model $new The node now
* @param string $lastUsedTab The tab last used in the form
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new, $lastUsedTab = FALSE )
{
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( array() );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=settings&controller=mfa&tab=handlers&do=settings&key=questions&tab=questions'), 'saved' );
}
}
}
@@ -2,9 +2,9 @@
/**
* @brief Manage Terms & Privacy Policy
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 07 Jun 2013
* @version SVN_VERSION_NUMBER
*/
@@ -76,6 +76,10 @@ class _terms extends \IPS\Dispatcher\Controller
$form->addHeader( 'terms_registration' );
$form->add( new \IPS\Helpers\Form\Translatable( 'reg_rules', NULL, FALSE, array( 'app' => 'core', 'key' => 'reg_rules_value', 'editor' => array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'RegistrationRules', 'attachIds' => array( NULL, NULL, 'reg_rules' ) ) ), NULL, NULL, NULL, 'reg_rules_id' ) );
$form->addHeader( 'guest_terms_options' );
$form->add( new \IPS\Helpers\Form\YesNo( 'guest_terms_bar', \IPS\Settings::i()->guest_terms_bar, FALSE, array( 'togglesOn' => array( 'guest_terms_bar_text' ) ) ) );
$form->add( new \IPS\Helpers\Form\Translatable( 'guest_terms_bar_text', NULL, FALSE, array( 'app' => 'core', 'key' => 'guest_terms_bar_text_value', 'sprintf' => array( '{terms}', '{privacy}', '{guidelines}' ) ), NULL, NULL, NULL, 'guest_terms_bar_text' ) );
if ( $values = $form->values() )
{
/* What were our previous values? */
@@ -83,8 +87,17 @@ class _terms extends \IPS\Dispatcher\Controller
$existingRegistrationTerms = iterator_to_array( \IPS\Db::i()->select( 'word_custom', 'core_sys_lang_words', array( 'word_key=?', 'reg_rules_value' ) ) );
/* Save */
foreach ( array( 'gl_guidelines' => 'guidelines_value', 'privacy_text' => 'privacy_text_value', 'reg_rules' => 'reg_rules_value' ) as $k => $v )
foreach ( array( 'gl_guidelines' => 'guidelines_value', 'privacy_text' => 'privacy_text_value', 'reg_rules' => 'reg_rules_value', 'guest_terms_bar_text' => 'guest_terms_bar_text_value' ) as $k => $v )
{
/* Guest terms bar text has special replacements that need to be swapped to sprintf parameters */
if ( $k == 'guest_terms_bar_text' )
{
foreach( $values[ $k ] AS $lang_id => $text )
{
$values[ $k ][ $lang_id ] = str_replace( array( '{terms}', '{privacy}', '{guidelines}' ), array( '%1$s', '%2$s', '%3$s' ), $text );
}
}
\IPS\Lang::saveCustom( 'core', $v, $values[ $k ] );
unset( $values[ $k ] );
}
@@ -137,11 +150,11 @@ class _terms extends \IPS\Dispatcher\Controller
{
if ( isset( $values['admin_reconfirm_reg_terms'] ) and $values['admin_reconfirm_reg_terms'] )
{
\IPS\Db::i()->update( 'core_members', "members_bitoptions2 = members_bitoptions2 | " . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['must_reaccept_terms'] );
\IPS\Member::updateAllMembers( array( "members_bitoptions2 = members_bitoptions2 | " . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['must_reaccept_terms'] ) );
}
if ( isset( $values['admin_reconfirm_privacy'] ) and $values['admin_reconfirm_privacy'] )
{
\IPS\Db::i()->update( 'core_members', "members_bitoptions2 = members_bitoptions2 | " . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['must_reaccept_privacy'] );
\IPS\Member::updateAllMembers( array( "members_bitoptions2 = members_bitoptions2 | " . \IPS\Member::$bitOptions['members_bitoptions']['members_bitoptions2']['must_reaccept_privacy'] ) );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=settings&controller=terms') );