Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -0,0 +1,217 @@
<?php
/**
* @brief ACP Notification: IPS Bulletins
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 16 Jul 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: IPS Bulletins
*/
class _Bulletin extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'important';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 1;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 2;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_Bulletin';
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'core', 'overview', 'ips_notifications' );
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return FALSE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return FALSE;
}
/**
* @brief Cached data (so we don't query it multiple times)
*/
protected $_bulletinData = NULL;
/**
* Get notification data
*
* @return array
*/
public function data()
{
if( $this->_bulletinData !== NULL )
{
return $this->_bulletinData;
}
$data = \IPS\Db::i()->select( '*', 'core_ips_bulletins', array( 'id=?', $this->extra ) )->first();
if ( ( time() - $data['cached'] ) > 3600 ) // If data was cached more than an hour ago, check again in case it's been updated
{
try
{
$bulletin = \IPS\Http\Url::ips("bulletin/{$data['id']}")->request()->get()->decodeJson();
if ( isset( $bulletin['title'] ) )
{
$data = array(
'id' => $data['id'],
'title' => $bulletin['title'],
'body' => $bulletin['body'],
'severity' => $bulletin['severity'],
'style' => $bulletin['style'],
'dismissible' => $bulletin['dismissible'],
'link' => $bulletin['link'],
'conditions' => $bulletin['conditions'],
'cached' => time()
);
\IPS\Db::i()->update( 'core_ips_bulletins', $data, array( 'id=?', $this->extra ) );
}
else
{
throw new \DomainException;
}
}
catch ( \Exception $e )
{
\IPS\Db::i()->update( 'core_ips_bulletins', array( 'cached' => ( time() + 3600 - 900 ) ), array( 'id=?', $this->extra ) ); // Try again in 15 minutes
}
}
$this->_bulletinData = $data;
return $data;
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
return $this->data()['title'];
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
return $this->data()['body'];
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return $this->data()['severity'];
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return $this->data()['dismissible'];
}
/**
* Style
*
* @return bool
*/
public function style()
{
return $this->data()['style'];
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
return $this->data()['link'] ?: parent::link();
}
/**
* Should this notification dismiss itself?
*
* @note This is checked every time the notification shows. Should be lightweight.
* @return bool
*/
public function selfDismiss()
{
try
{
return !@eval( $this->data()['conditions'] );
}
catch ( \Exception $e )
{
return FALSE;
}
catch ( \Throwable $e )
{
return FALSE;
}
}
}
@@ -0,0 +1,671 @@
<?php
/**
* @brief ACP Notification: Configuration Errors
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 25 Jun 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: Test
*/
class _ConfigurationError extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'system';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 2;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 2;
/**
* Dangerous PHP functions
*/
public static $dangerousPhpFunctions = array( 'exec', 'system', 'passthru', 'pcntl_exec', 'popen', 'proc_open', 'shell_exec' );
/**
* Check for any issues we may need to send a notification about
*
* @return void
*/
public static function runChecksAndSendNotifications()
{
/* Dangerous PHP functions */
if ( \count( static::enabledDangerousFunctions() ) )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'dangerousFunctions', FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'dangerousFunctions' );
}
/* display_errors */
if ( ( (bool) ini_get( 'display_errors' ) ) !== FALSE AND mb_strtolower( ini_get( 'display_errors' ) ) !== 'off' )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'displayErrors', FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'displayErrors' );
}
/* System Requirement Recommendations */
$requirementsAndRecommendations = \IPS\core\Setup\Upgrade::systemRequirements();
if ( isset( $requirementsAndRecommendations['advice'] ) and \count( $requirementsAndRecommendations['advice'] ) )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'recommendations', FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'recommendations' );
}
/* orig_ database tables */
if( !\IPS\Settings::i()->orig_tables_checked )
{
/* Check if we have any orig_* tables */
$tables = \IPS\Db::i()->getTables( 'orig_' . \IPS\Db::i()->prefix );
/* If we don't have any, we're good. Set a flag so we don't check this every time */
if( !\count( $tables ) )
{
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 1 ), array( 'conf_key=?', 'orig_tables_checked' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'origTables' );
}
else
{
/* Determine if the background queue task has already been launched */
try
{
\IPS\Db::i()->select( '*', 'core_queue', array( "`key`=?", 'CleanupOrigTables' ) )->first();
$inProgress = TRUE;
}
catch( \UnderflowException $e )
{
$inProgress = FALSE;
}
/* If it isn't, show a warning */
if( !$inProgress )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'origTables', FALSE, NULL, TRUE ); // We don't send an email for this one since it "happens" as part of the upgrade and is more just an FYI
}
}
}
/* Any tasks which were supposed to have run more than 36 hours ago */
if ( !\IPS\CIC )
{
$taskWasSupposedToRun = \IPS\Db::i()->select( 'next_run', 'core_tasks', array( 'core_tasks.enabled=1 AND (core_plugins.plugin_enabled=1 OR core_applications.app_enabled=1)' ), 'next_run ASC' )
->join( 'core_applications', array( 'core_applications.app_directory=core_tasks.app' ) )
->join( 'core_plugins', array( 'core_plugins.plugin_id=core_tasks.plugin' ) )
->first();
if ( ( time() - $taskWasSupposedToRun ) > ( \IPS\TASK_OVERDUE_HOURS * 3600 ) )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'tasksNotRunning', FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'tasksNotRunning' );
}
}
/* Data storage not working */
if( !\IPS\CIC AND (!\IPS\Data\Store::testStore() OR \IPS\Db::i()->select( 'COUNT(*)', 'core_log', array( '`category`=? AND `time`>?', 'datastore', \IPS\DateTime::create()->sub( new \DateInterval( 'PT1H' ) )->getTimestamp() ) )->first() >= 10 ) )
{
if ( \IPS\Settings::i()->last_data_store_update < \IPS\DateTime::create()->sub( new \DateInterval( 'PT24H' ) )->getTimestamp() )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'dataStorageBroken', FALSE );
}
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'dataStorageBroken' );
}
/* Cache Set Up */
if ( \IPS\CACHE_METHOD AND \IPS\CACHE_METHOD != 'None' AND \IPS\Data\Cache::i() instanceof \IPS\Data\Cache\None )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'cacheBroken', FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'cacheBroken' );
}
/* CiC Email Quota */
if ( \IPS\CIC )
{
preg_match( '/^\/var\/www\/html\/(.+?)(?:\/|$)/i', \IPS\ROOT_PATH, $matches );
try
{
$cicEmails = \IPS\Http\Url::external( "http://ips-cic-email.invisioncic.com/blocked.php?account={$matches[1]}" )->request()->get()->decodeJson();
if ( isset( $cicEmails['status'] ) AND $cicEmails['status'] == 'BLOCKED' )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'cicEmailQuota', FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'cicEmailQuota' );
}
}
catch( \Exception $e ) { }
}
/* Failed Emails, show notification if there are errors logs that haven't yet triggered a notification */
if( \IPS\Email::countFailedMail() >= 3 )
{
\IPS\core\AdminNotification::send( 'core', 'ConfigurationError', 'failedMail', TRUE, NULL, TRUE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'failedMail' );
}
}
/**
* Check enabled dangerous functions
*
* @return array
*/
public static function enabledDangerousFunctions()
{
$functions = array();
foreach ( static::$dangerousPhpFunctions as $function )
{
if ( \function_exists( $function ) )
{
$functions[] = $function;
}
}
return $functions;
}
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_ConfigurationError';
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return FALSE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return FALSE;
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return ( $member->hasAcpRestriction( 'core', 'members', 'member_delete_admin' ) or
$member->hasAcpRestriction( 'core', 'settings', 'advanced_manage_tasks' ) or
$member->hasAcpRestriction( 'core', 'overview', 'system_notifications' ) or
$member->hasAcpRestriction( 'core', 'overview', 'system_notifications' ) or
$member->hasAcpRestriction( 'core', 'support', 'get_support' ) or
$member->hasAcpRestriction( 'core', 'settings', 'email_errorlog' ) or $member->hasAcpRestriction( 'core', 'settings', 'email_manage' ) or
$member->hasAcpRestriction( 'core', 'overview', 'system_notifications' ) or
$member->hasAcpRestriction( 'core', 'settings', 'advanced_manage' ) or
$member->hasAcpRestriction( 'core', 'settings', 'general_manage' ) or
$member->hasAcpRestriction( 'core', 'settings', 'advanced_manage' ) or
$member->hasAcpRestriction( 'core', 'settings', 'advanced_manage' ) or
$member->hasAcpRestriction( 'core', 'overview', 'system_notifications' ) or
$member->hasAcpRestriction( 'core', 'marketplace', 'marketplace_manage' )
);
}
/**
* Can a member view this notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public function visibleTo( \IPS\Member $member )
{
if ( mb_substr( $this->extra, 0, 12 ) === 'supportAdmin' )
{
return $member->hasAcpRestriction( 'core', 'members', 'member_delete_admin' );
}
elseif ( mb_substr( $this->extra, 0, 8 ) === 'taskLock' )
{
return $member->hasAcpRestriction( 'core', 'settings', 'advanced_manage_tasks' );
}
elseif ( $this->extra === 'dangerousFunctions' )
{
return $member->hasAcpRestriction( 'core', 'overview', 'system_notifications' );
}
elseif ( $this->extra === 'displayErrors' )
{
return $member->hasAcpRestriction( 'core', 'overview', 'system_notifications' );
}
elseif ( $this->extra === 'recommendations' )
{
return $member->hasAcpRestriction( 'core', 'support', 'get_support' );
}
elseif ( $this->extra === 'failedMail' )
{
return $member->hasAcpRestriction( 'core', 'settings', 'email_errorlog' ) or $member->hasAcpRestriction( 'core', 'settings', 'email_manage' );
}
elseif ( $this->extra === 'origTables' )
{
return $member->hasAcpRestriction( 'core', 'overview', 'system_notifications' );
}
elseif ( $this->extra === 'tasksNotRunning' )
{
return $member->hasAcpRestriction( 'core', 'settings', 'advanced_manage' );
}
elseif ( $this->extra === 'siteOffline' )
{
return $member->hasAcpRestriction( 'core', 'settings', 'general_manage' );
}
elseif ( $this->extra === 'dataStorageBroken' )
{
return $member->hasAcpRestriction( 'core', 'settings', 'advanced_manage' );
}
elseif ( $this->extra === 'cacheBroken' )
{
return $member->hasAcpRestriction( 'core', 'settings', 'advanced_manage' );
}
elseif ( $this->extra === 'cicEmailQuota' )
{
return $member->hasAcpRestriction( 'core', 'overview', 'system_notifications' );
}
elseif ( $this->extra === 'marketplaceSetup' )
{
return $member->hasAcpRestriction( 'core', 'marketplace', 'marketplace_manage' );
}
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
if ( mb_substr( $this->extra, 0, 12 ) === 'supportAdmin' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_support_account');
}
elseif ( mb_substr( $this->extra, 0, 8 ) === 'taskLock' )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_broken', FALSE, array( 'sprintf' => array( \IPS\Task::load( \intval( mb_substr( $this->extra, 9 ) ) )->key ) ) );
}
elseif ( $this->extra === 'dangerousFunctions' )
{
return \IPS\Member::loggedIn()->language()->addToStack('disable_functions_title');
}
elseif ( $this->extra === 'displayErrors' )
{
return \IPS\Member::loggedIn()->language()->addToStack('display_errors_title');
}
elseif ( $this->extra === 'recommendations' )
{
return \IPS\Member::loggedIn()->language()->addToStack('system_check_title');
}
elseif ( $this->extra === 'failedMail' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_email_broken');
}
elseif ( $this->extra === 'origTables' )
{
return \IPS\Member::loggedIn()->language()->addToStack('block_core_OrigTables');
}
elseif ( $this->extra === 'tasksNotRunning' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_tasksrun_broken');
}
elseif ( $this->extra === 'siteOffline' )
{
return \IPS\Member::loggedIn()->language()->addToStack('offline_message_title');
}
elseif ( $this->extra === 'dataStorageBroken' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_datastore_broken');
}
elseif ( $this->extra === 'cacheBroken' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_invalid_cachesetup');
}
elseif ( $this->extra === 'cicEmailQuota' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_cic_email_quota');
}
elseif ( $this->extra === 'marketplaceSetup' )
{
return \IPS\Member::loggedIn()->language()->addToStack('marketplace_onboard_title');
}
else
{
return htmlentities( $this->extra, ENT_DISALLOWED, 'UTF-8', FALSE );
}
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
if ( mb_substr( $this->extra, 0, 12 ) === 'supportAdmin' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_support_account_desc');
}
elseif ( mb_substr( $this->extra, 0, 8 ) === 'taskLock' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_tasks_broken_desc');
}
elseif ( $this->extra === 'dangerousFunctions' )
{
return \IPS\Member::loggedIn()->language()->addToStack('disable_functions_desc');
}
elseif ( $this->extra === 'displayErrors' )
{
return \IPS\Member::loggedIn()->language()->addToStack('display_errors_subtitle');
}
elseif ( $this->extra === 'recommendations' )
{
return \IPS\Member::loggedIn()->language()->addToStack('system_check_recommended_blurb');
}
elseif ( $this->extra === 'failedMail' )
{
return \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_email_broken_desc_1', FALSE, array( 'sprintf' => array( \IPS\Email::countFailedMail() ) ) );
}
elseif ( $this->extra === 'origTables' )
{
return \IPS\Member::loggedIn()->language()->addToStack('orig_cleanup_desc');
}
elseif ( $this->extra === 'tasksNotRunning' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_tasksrun_broken_desc');
}
elseif ( $this->extra === 'siteOffline' )
{
return \IPS\Member::loggedIn()->language()->addToStack( ( \IPS\Settings::i()->task_use_cron == 'normal' AND !\IPS\CIC ) ? 'offline_message_desc_task' : 'offline_message_desc_notask' );
}
elseif ( $this->extra === 'dataStorageBroken' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_datastore_broken_subtitle');
}
elseif ( $this->extra === 'cacheBroken' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_invalid_cachesetup_subtitle');
}
elseif ( $this->extra === 'cicEmailQuota' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_cic_email_quota_subtitle');
}
elseif ( $this->extra === 'marketplaceSetup' )
{
return \IPS\Member::loggedIn()->language()->addToStack('marketplace_onboard_notification');
}
return NULL;
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
if ( mb_substr( $this->extra, 0, 12 ) === 'supportAdmin' )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->supportAccountPresent( \IPS\Member::load( \intval( mb_substr( $this->extra, 13 ) ) ) );
}
elseif ( mb_substr( $this->extra, 0, 8 ) === 'taskLock' )
{
$task = \IPS\Task::load( \intval( mb_substr( $this->extra, 9 ) ) );
$langKey = 'task__' . $task->key;
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->lockedTask( $task, \IPS\Member::loggedIn()->language()->checkKeyExists( $langKey ) ? $langKey : NULL );
}
elseif ( $this->extra === 'dangerousFunctions' )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->dangerousPhpFunctions( static::enabledDangerousFunctions() );
}
elseif ( $this->extra === 'displayErrors' )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->displayErrors();
}
elseif ( $this->extra === 'failedMail' )
{
$table = NULL;
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'settings', 'email_errorlog' ) )
{
$where = array( array( 'mlog_notification_sent=?', FALSE ) );
$table = \IPS\core\modules\admin\settings\email::emailErrorLogTable( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=core_ConfigurationError'), $where );
$table->limit = 10;
}
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->failedMail( \IPS\Email::countFailedMail(), $table );
}
elseif ( $this->extra === 'recommendations' )
{
$requirementsAndRecommendations = \IPS\core\Setup\Upgrade::systemRequirements();
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->systemRecommendations( isset( $requirementsAndRecommendations['advice'] ) ? $requirementsAndRecommendations['advice'] : array() );
}
elseif ( $this->extra === 'origTables' )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->origTables();
}
elseif ( $this->extra === 'tasksNotRunning' )
{
$cronCommand = 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;
$webCronUrl = (string) \IPS\Http\Url::internal( 'applications/core/interface/task/web.php?key=' . \IPS\Settings::i()->task_cron_key, 'none' );
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->tasksNotRunning( $this, $cronCommand, $webCronUrl );
}
elseif ( $this->extra === 'siteOffline' )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core', 'admin' )->siteOffline();
}
elseif ( $this->extra === 'dataStorageBroken' )
{
if( \IPS\CIC )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_datastore_broken_desc_cic');
}
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_datastore_broken_desc');
}
elseif ( $this->extra === 'cacheBroken' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_invalid_cachesetup_desc');
}
elseif ( $this->extra === 'cicEmailQuota' )
{
return \IPS\Member::loggedIn()->language()->addToStack('dashboard_cic_email_quota_desc');
}
elseif ( $this->extra === 'marketplaceSetup' )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->marketplaceSetup();
}
}
/**
* Severity
*
* @return string
*/
public function severity()
{
if ( $this->extra === 'siteOffline' or $this->extra === 'cicEmailQuota' )
{
return static::SEVERITY_CRITICAL;
}
elseif ( \in_array( $this->extra, array( 'tasksNotRunning', 'dataStorageBroken', 'cacheBroken' ) ) )
{
return static::SEVERITY_HIGH;
}
else
{
return static::SEVERITY_NORMAL;
}
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
if ( mb_substr( $this->extra, 0, 8 ) === 'taskLock' or \in_array( $this->extra, array( 'failedMail', 'origTables', 'siteOffline', 'dataStorageBroken', 'cacheBroken' ) ) )
{
return static::DISMISSIBLE_NO;
}
else
{
return static::DISMISSIBLE_TEMPORARY;
}
}
/**
* Style
*
* @return bool
*/
public function style()
{
if ( $this->extra === 'siteOffline' )
{
if ( \IPS\Settings::i()->task_use_cron == 'normal' AND !\IPS\CIC )
{
return static::STYLE_WARNING;
}
else
{
return static::STYLE_INFORMATION;
}
}
if ( mb_substr( $this->extra, 0, 12 ) === 'supportAdmin' or $this->extra === 'recommendations' or $this->extra === 'origTables' or $this->extra === 'marketplaceSetup' )
{
return static::STYLE_INFORMATION;
}
elseif ( mb_substr( $this->extra, 0, 8 ) === 'taskLock' or \in_array( $this->extra, array( 'failedMail', 'tasksNotRunning', 'dataStorageBroken', 'cacheBroken', 'cicEmailQuota' ) ) )
{
return static::STYLE_ERROR;
}
else
{
return static::STYLE_WARNING;
}
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
if ( mb_substr( $this->extra, 0, 12 ) === 'supportAdmin' )
{
return \IPS\Member::load( \intval( mb_substr( $this->extra, 13 ) ) )->acpUrl();
}
elseif ( $this->extra === 'marketplaceSetup' )
{
return \IPS\Http\Url::internal( 'app=core&module=marketplace&controller=onboard&_new=1', 'admin' );
}
else
{
return parent::link();
}
}
/**
* Should this notification dismiss itself?
*
* @note This is checked every time the notification shows. Should be lightweight.
* @return bool
*/
public function selfDismiss()
{
if ( $this->extra === 'dangerousFunctions' )
{
return !\count( static::enabledDangerousFunctions() );
}
elseif ( $this->extra === 'displayErrors' )
{
return !( ( (bool) ini_get( 'display_errors' ) ) !== FALSE AND mb_strtolower( ini_get( 'display_errors' ) ) !== 'off' );
}
elseif ( $this->extra === 'recommendations' )
{
$requirementsAndRecommendations = \IPS\core\Setup\Upgrade::systemRequirements();
return !isset( $requirementsAndRecommendations['advice'] ) or !\count( $requirementsAndRecommendations['advice'] );
}
elseif ( mb_substr( $this->extra, 0, 8 ) === 'taskLock' )
{
try
{
return !\IPS\Task::load( \intval( mb_substr( $this->extra, 9 ) ) )->enabled;
}
catch( \RuntimeException | \OutOfRangeException $e )
{
return TRUE;
}
}
}
/**
* Delete AdminCP Notification
*
* @return void
*/
public function delete()
{
/* If deleting a failedMail notification, mark previous logs as notification sent */
if( $this->extra == 'failedMail' )
{
\IPS\Db::i()->update( 'core_mail_error_logs', array( 'mlog_notification_sent' => TRUE ) );
}
parent::delete();
}
}
@@ -0,0 +1,214 @@
<?php
/**
* @brief ACP Notification: User Error
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 31 Jul 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: User Error
*/
class _Error extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'system';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 2;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 4;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_Error';
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return TRUE;
}
/**
* The default value for if this notification shows in the notification center
*
* @return bool
*/
public static function defaultValue()
{
return FALSE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return TRUE;
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return \IPS\Settings::i()->error_log_level and $member->hasAcpRestriction( 'core', 'support', 'system_logs_view' );
}
/**
* Custom per-admin setting for if email shoild be sent for this notification
*
* @param string $key Setting field key
* @param mixed $value Current value
* @return \IPS\Helpers\Form\FormAbstract|NULL
*/
public static function customEmailConfigurationSetting( $key, $value )
{
return new \IPS\Helpers\Form\Select( $key, $value, FALSE, array( 'options' => array(
0 => 'no',
1 => 'level_number_1_full',
2 => 'level_number_2_full',
3 => 'level_number_3_full',
4 => 'level_number_4_full',
5 => 'level_number_5_full'
), 'class' => 'ipsField_medium' ) );
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack( 'error_logs_notification' );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
try
{
$latest = \IPS\Db::i()->select( '*', 'core_error_logs', NULL, 'log_id DESC', 1 )->first();
$othersToday = ( $latest['log_date'] > ( time() - 86400 ) ) ? ( \IPS\Db::i()->select( 'COUNT(*)', 'core_error_logs', 'log_date>' . ( time() - 86400 ) )->first() - 1 ) : 0;
if ( $othersToday )
{
$othersToday = \IPS\Member::loggedIn()->language()->addToStack( 'error_logs_notification_subtitle_others', FALSE, array( 'pluralize' => array( $othersToday ) ) );
}
else
{
$othersToday = '';
}
return \IPS\Member::loggedIn()->language()->addToStack( 'error_logs_notification_subtitle', FALSE, array( 'sprintf' => array( $latest['log_error_code'], $latest['log_error'], \IPS\Member::load( $latest['log_member'] )->name, \IPS\DateTime::ts( $latest['log_date'] )->relative(), $othersToday ) ) );
}
catch ( \UnderflowException $e )
{
return NULL;
}
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
$table = \IPS\core\modules\admin\support\errorLogs::table( \IPS\Http\Url::internal('app=core&module=overview&controller=notifications&_table=core_Error') );
$table->limit = 10;
$table->quickSearch = NULL;
$table->advancedSearch = NULL;
return \IPS\Theme::i()->getTemplate( 'notifications', 'core' )->errorLog( $table );
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return static::SEVERITY_OPTIONAL;
}
/**
* Style
*
* @return bool
*/
public function style()
{
return static::STYLE_WARNING;
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_PERMANENT;
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
return \IPS\Http\Url::internal('app=core&module=support&controller=errorLogs');
}
/**
* WHERE clause to use against core_acp_notifications_preferences for fetching members to email
*
* @param mixed $extraForEmail Any additional information specific to this instance which is used for the email but not saved
* @return bool
*/
public function emailWhereClause( $extraForEmail )
{
return array( 'email!=0 AND email<=?', \intval( \substr( $extraForEmail[0], 0, 1 ) ) );
}
}
@@ -0,0 +1,189 @@
<?php
/**
* @brief ACP Notification: License will/has expired
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 27 Jun 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: License will/has expired
*/
class _License extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'important';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 1;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 3;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_License';
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'core', 'settings', 'licensekey_manage' );
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return FALSE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return FALSE;
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
switch ( $this->extra )
{
case 'missing':
case 'url':
return \IPS\Member::loggedIn()->language()->addToStack('license_error');
case 'expireSoon':
$licenseKeyData = \IPS\IPS::licenseKey();
return \IPS\Member::loggedIn()->language()->addToStack( 'license_renewal_soon', FALSE, array( 'pluralize' => array( \intval( \IPS\DateTime::create()->diff( \IPS\DateTime::ts( strtotime( $licenseKeyData['expires'] ) ) )->format('%r%a') ) ) ) );
case 'expired':
return \IPS\Member::loggedIn()->language()->addToStack('license_expired');
}
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
switch ( $this->extra )
{
case 'missing':
case 'url':
return \IPS\Member::loggedIn()->language()->addToStack('license_error_subtitle');
default:
return \IPS\Member::loggedIn()->language()->addToStack('license_benefits_info');
}
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
switch ( $this->extra )
{
case 'missing':
return \IPS\Member::loggedIn()->language()->addToStack('license_error_none');
default:
return \IPS\Theme::i()->getTemplate( 'notifications', 'core', 'admin' )->licenseKey( $this->id, $this->extra );
}
}
/**
* Severity
*
* @return string
*/
public function severity()
{
switch ( $this->extra )
{
case 'expireSoon':
return static::SEVERITY_HIGH;
default:
return static::SEVERITY_CRITICAL;
}
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_NO;
}
/**
* Style
*
* @return bool
*/
public function style()
{
switch ( $this->extra )
{
case 'missing':
case 'url':
return static::STYLE_ERROR;
case 'expired':
return static::STYLE_WARNING;
case 'expireSoon':
return static::STYLE_EXPIRE;
}
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
return \IPS\Http\Url::internal( 'app=core&module=settings&controller=licensekey' );
}
}
@@ -0,0 +1,215 @@
<?php
/**
* @brief ACP Notification: New Registration Complete
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 2 Jul 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: New Registration Complete
*/
class _NewRegComplete extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'members';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 3;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 4;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_NewRegComplete';
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'core', 'members' );
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return TRUE;
}
/**
* The default value for if this notification shows in the notification center
*
* @return bool
*/
public static function defaultValue()
{
return FALSE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return FALSE;
}
/**
* WHERE clause to use against core_acp_notifications_preferences for fetching members to email
*
* @param mixed $extraForEmail Any additional information specific to this instance which is used for the email but not saved
* @return bool
*/
public function emailWhereClause( $extraForEmail )
{
/* Most notifications only send one email until the admin has "dealt" with it, but since this
type of notification cannot be "dealt" with, we need to send an email every time rather
than just the first time this notification occurs. */
return array( "email='once'" );
}
/**
* Get the date/time that we need to use for the cutoff
*
* @return \IPS\DateTime|NULL
*/
public function cutoff()
{
try
{
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'time', 'core_acp_notifcations_dismissals', array( 'notification=? AND `member`=?', $this->id, \IPS\Member::loggedIn()->member_id ) )->first() );
}
catch ( \UnderflowException $e )
{
return NULL;
}
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
return \IPS\Member::loggedIn()->language()->addToStack( 'acp_notification_NewRegComplete_title' );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
if ( $cutoff = $this->cutoff() )
{
try
{
return \IPS\Member::loggedIn()->language()->addToStack( 'member_joined_latest', FALSE, array( 'sprintf' => array( \IPS\DateTime::ts( \IPS\Db::i()->select( 'joined', 'core_members', array( 'joined>?', $cutoff->getTimestamp() ), 'joined desc' )->first() )->relative( \IPS\DateTime::RELATIVE_FORMAT_LOWER ) ) ) );
}
catch ( \UnderflowException $e )
{
return NULL;
}
}
else
{
return NULL;
}
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
$limit = 12;
$users = array();
$where = array( array( 'email<>?', '' ) );
if ( $cutoff = $this->cutoff() )
{
$where[] = array( 'joined>?', $cutoff->getTimestamp() );
}
$more = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where )->first() - $limit + 1;
foreach (
\IPS\Db::i()->select(
'*',
'core_members',
$where,
'joined desc',
array( 0, ( $more === 1 ) ? $limit : ( $limit - 1 ) )
) as $user
)
{
$users[ $user['member_id'] ] = \IPS\Member::constructFromData( $user );
}
if ( \count( $users ) )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core', 'admin' )->newMember( $users, $this, $more );
}
else
{
return '';
}
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return static::SEVERITY_OPTIONAL;
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_UNTIL_RECUR;
}
}
@@ -0,0 +1,217 @@
<?php
/**
* @brief ACP Notification: New Registration Requires Admin Validation
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 2 Jul 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: New Registration Requires Admin Validation
*/
class _NewRegValidate extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'members';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 3;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 2;
/**
* Get queue HTML
*
* @return string
*/
public static function queueHtml()
{
$users = array();
foreach (
\IPS\Db::i()->select(
"*",
'core_validating',
array( 'user_verified=?', TRUE ),
'entry_date asc',
array( 0, 12 )
)->join(
'core_members',
'core_validating.member_id=core_members.member_id'
) as $user
)
{
$users[ $user['member_id'] ] = \IPS\Member::constructFromData( $user );
}
if ( \count( $users ) )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core', 'admin' )->adminValidations( $users );
}
else
{
return '';
}
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'core', 'members' );
}
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_NewRegValidate';
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return TRUE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return TRUE;
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
$others = \IPS\Db::i()->select( 'COUNT(*)', 'core_validating', array( 'user_verified=?', TRUE ) )->first();
$names = array();
foreach (
\IPS\Db::i()->select(
"*",
'core_validating',
array( 'user_verified=?', TRUE ),
'entry_date asc',
array( 0, 2 )
)->join(
'core_members',
'core_validating.member_id=core_members.member_id'
) as $user
)
{
$names[ $user['member_id'] ] = htmlentities( $user['name'], ENT_DISALLOWED, 'UTF-8', FALSE );
$others--;
}
if ( $others )
{
$names[] = \IPS\Member::loggedIn()->language()->addToStack( 'and_x_others', FALSE, array( 'pluralize' => array( $others ) ) );
}
return \IPS\Member::loggedIn()->language()->addToStack( 'new_users_need_admin_validation', FALSE, array( 'pluralize' => array( \count( $names ) ), 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ) ) );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
try
{
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'entry_date', 'core_validating', array( 'user_verified=?', TRUE ), 'entry_date asc', 1 )->first() )->relative();
}
catch ( \UnderflowException $e )
{
return NULL;
}
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_dashboard.js', 'core') );
return static::queueHtml();
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return static::SEVERITY_OPTIONAL;
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_NO;
}
/**
* Style
*
* @return bool
*/
public function style()
{
return static::STYLE_WARNING;
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
return \IPS\Http\Url::internal( 'app=core&module=members&controller=members&filter=members_filter_validating' );
}
}
@@ -0,0 +1,166 @@
<?php
/**
* @brief ACP Notification: New Version Available
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 29 Jun 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: New Version Available
*/
class _NewVersion extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'important';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 1;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 1;
/**
* @brief Temporarily store the upgrade data
*/
public $_details;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_NewVersion';
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'core', 'overview', 'upgrade_manage' );
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return FALSE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return FALSE;
}
/**
* Is this a security update?
*
* @return bool
*/
public function __construct()
{
$this->_details = \IPS\Application::load('core')->availableUpgrade( TRUE );
return parent::__construct();
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
return ! empty( $this->_details['security'] ) ? \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_version_info_security', FALSE, array( 'sprintf' => array( $this->_details['version'] ) ) ) : \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_version_info', FALSE, array( 'sprintf' => array( $this->_details['version'] ) ) );
}
/**
* Notification Subtitle (no HTML)
*
* @return string
*/
public function subtitle()
{
return \IPS\Member::loggedIn()->language()->addToStack( 'regular_update', FALSE, array( 'sprintf' => array( \IPS\DateTime::ts( $this->_details['released'] )->relative( \IPS\DateTime::RELATIVE_FORMAT_LOWER ) ) ) );
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core', 'admin' )->newVersion( $this->_details );
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return static::SEVERITY_CRITICAL;
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_TEMPORARY;
}
/**
* Style
*
* @return bool
*/
public function style()
{
return ! empty( $this->_details['security'] ) ? static::STYLE_ERROR : static::STYLE_INFORMATION;
}
/**
* Quick link from popup menu
*
* @return bool
*/
public function link()
{
return \IPS\Http\Url::internal( 'app=core&module=system&controller=upgrade&_new=1', 'admin' );
}
}
@@ -0,0 +1,263 @@
<?php
/**
* @brief ACP Notification: Member Flagged as Spammer
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 30 Jul 2018
*/
namespace IPS\core\extensions\core\AdminNotifications;
/* 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;
}
/**
* ACP Notification: Member Flagged as Spammer
*/
class _Spammer extends \IPS\core\AdminNotification
{
/**
* @brief Identifier for what to group this notification type with on the settings form
*/
public static $group = 'members';
/**
* @brief Priority 1-5 (1 being highest) for this group compared to others
*/
public static $groupPriority = 3;
/**
* @brief Priority 1-5 (1 being highest) for this notification type compared to others in the same group
*/
public static $itemPriority = 5;
/**
* Title for settings
*
* @return string
*/
public static function settingsTitle()
{
return 'acp_notification_Spammer';
}
/**
* Can a member access this type of notification?
*
* @param \IPS\Member $member The member
* @return bool
*/
public static function permissionCheck( \IPS\Member $member )
{
return $member->hasAcpRestriction( 'core', 'members' );
}
/**
* Is this type of notification ever optional (controls if it will be selectable as "viewable" in settings)
*
* @return string
*/
public static function mayBeOptional()
{
return TRUE;
}
/**
* The default value for if this notification shows in the notification center
*
* @return bool
*/
public static function defaultValue()
{
return FALSE;
}
/**
* Is this type of notification might recur (controls what options will be available for the email setting)
*
* @return bool
*/
public static function mayRecur()
{
return FALSE;
}
/**
* WHERE clause to use against core_acp_notifications_preferences for fetching members to email
*
* @param mixed $extraForEmail Any additional information specific to this instance which is used for the email but not saved
* @return bool
*/
public function emailWhereClause( $extraForEmail )
{
/* Most notifications only send one email until the admin has "dealt" with it, but since this
type of notification cannot be "dealt" with, we need to send an email every time rather
than just the first time this notification occurs. */
return array( "email='once'" );
}
/**
* Get the date/time that we need to use for the cutoff
*
* @return \IPS\DateTime|NULL
*/
public function cutoff()
{
try
{
return \IPS\DateTime::ts( \IPS\Db::i()->select( 'time', 'core_acp_notifcations_dismissals', array( 'notification=? AND `member`=?', $this->id, \IPS\Member::loggedIn()->member_id ) )->first() );
}
catch ( \UnderflowException $e )
{
return NULL;
}
}
/**
* Notification Title (full HTML, must be escaped where necessary)
*
* @return string
*/
public function title()
{
$where = array( \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) );
if ( $cutoff = $this->cutoff() )
{
$where[] = array( 'joined>?', $cutoff->getTimestamp() );
}
$count = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where )->first();
$others = $count;
$names = array();
foreach (
\IPS\Db::i()->select(
"*",
'core_members',
$where,
'joined desc',
array( 0, 6 )
) as $user
)
{
$names[ $user['member_id'] ] = htmlentities( $user['name'], ENT_DISALLOWED, 'UTF-8', FALSE );
$others--;
}
if ( $others )
{
$names[] = \IPS\Member::loggedIn()->language()->addToStack( 'and_x_others', FALSE, array( 'pluralize' => array( $others ) ) );
}
return \IPS\Member::loggedIn()->language()->addToStack( 'user_flagged_as_spammer', FALSE, array( 'pluralize' => array( $count ), 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ) ) );
}
/**
* Notification Body (full HTML, must be escaped where necessary)
*
* @return string
*/
public function body()
{
$limit = 6;
$users = array();
$where = array( \IPS\Db::i()->bitwiseWhere( \IPS\Member::$bitOptions['members_bitoptions'], 'bw_is_spammer' ) );
if ( $cutoff = $this->cutoff() )
{
$where[] = array( 'joined>?', $cutoff->getTimestamp() );
}
$more = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where )->first() - $limit + 1;
foreach (
\IPS\Db::i()->select(
'*',
'core_members',
$where,
'joined desc',
array( 0, ( $more === 1 ) ? $limit : ( $limit - 1 ) )
) as $user
)
{
$users[ $user['member_id'] ]['member'] = \IPS\Member::constructFromData( $user );
foreach ( \IPS\Db::i()->select( '*', 'core_member_history', array( "log_member=? AND log_type='account'", $user['member_id'] ), 'log_date DESC', 50 ) as $row )
{
if ( $jsonValue = json_decode( $row['log_data'], TRUE ) and isset( $jsonValue['type'] ) and $jsonValue['type'] == 'spammer' and isset( $jsonValue['set'] ) ? $jsonValue['set'] : $jsonValue['legacy']['set'] )
{
if ( isset( $jsonValue['actions'] ) )
{
$flagActions = array();
if ( \in_array( 'delete', $jsonValue['actions'] ) )
{
$flagActions[] = \IPS\Member::loggedIn()->language()->addToStack('history_flagged_spammer_action_delete');
}
elseif ( \in_array( 'unapprove', $jsonValue['actions'] ) )
{
$flagActions[] = \IPS\Member::loggedIn()->language()->addToStack('history_flagged_spammer_action_unapprove');
}
if ( \in_array( 'ban', $jsonValue['actions'] ) )
{
$flagActions[] = \IPS\Member::loggedIn()->language()->addToStack('history_flagged_spammer_action_ban');
}
elseif ( \in_array( 'disable', $jsonValue['actions'] ) )
{
$flagActions[] = \IPS\Member::loggedIn()->language()->addToStack('history_flagged_spammer_action_disable');
}
if ( \count( $flagActions ) )
{
$users[ $user['member_id'] ]['blurb'] = \IPS\Member::loggedIn()->language()->addToStack( 'user_flagged_as_spammer_subtitle_with_actions', FALSE, array( 'sprintf' => array(
\IPS\DateTime::ts( $row['log_date'] )->relative(),
\IPS\Member::load( $row['log_by'] )->name,
\IPS\Member::loggedIn()->language()->formatList( $flagActions )
) ) );
}
else
{
$users[ $user['member_id'] ]['blurb'] = \IPS\Member::loggedIn()->language()->addToStack( 'user_flagged_as_spammer_subtitle', FALSE, array( 'sprintf' => array( \IPS\DateTime::ts( $row['log_date'] )->relative(), \IPS\Member::load( $row['log_by'] )->name ) ) );
}
}
else
{
$users[ $user['member_id'] ]['blurb'] = \IPS\Member::loggedIn()->language()->addToStack( 'user_flagged_as_spammer_subtitle', FALSE, array( 'sprintf' => array( \IPS\DateTime::ts( $row['log_date'] )->relative(), \IPS\Member::load( $row['log_by'] )->name ) ) );
}
}
}
}
if ( \count( $users ) )
{
return \IPS\Theme::i()->getTemplate( 'notifications', 'core', 'admin' )->spammer( $users, $this, $more );
}
else
{
return '';
}
}
/**
* Severity
*
* @return string
*/
public function severity()
{
return static::SEVERITY_OPTIONAL;
}
/**
* Dismissible?
*
* @return string
*/
public function dismissible()
{
return static::DISMISSIBLE_UNTIL_RECUR;
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Build;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -32,7 +32,7 @@ class _Ckeditor
public function build()
{
/* This is just to prevent CKEditor being build with every commit while we're doing deployment testing (which takes ages so it causes the deploy server to report a fail and usually isn't necessary) */
if ( defined( 'BUILD_TOOL_SCRIPT' ) )
if ( \defined( 'BUILD_TOOL_SCRIPT' ) )
{
return;
}
@@ -41,7 +41,7 @@ class _Ckeditor
$_javaPath = '';
if( defined('\IPS\JAVA_PATH') AND \IPS\JAVA_PATH )
if( \defined('\IPS\JAVA_PATH') AND \IPS\JAVA_PATH )
{
$_javaPath = \IPS\JAVA_PATH;
}
@@ -76,7 +76,7 @@ class _Ckeditor
\exec( "rm -R \"{$path}/applications/core/interface/ckeditor/ckeditor/samples\"" );
}
if( in_array( 'Release process completed:', $output ) )
if( \in_array( 'Release process completed:', $output ) )
{
$this->finish();
return;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Build;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -102,8 +102,7 @@ class _FacebookPixel
{
if ( \IPS\Settings::i()->fb_pixel_id )
{
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 1 ), array( 'conf_key=?', 'fb_pixel_enabled' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'fb_pixel_enabled' => 1 ) );
}
else
{
@@ -112,8 +111,7 @@ class _FacebookPixel
}
else
{
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 0 ), array( 'conf_key=?', 'fb_pixel_enabled' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'fb_pixel_enabled' => 0 ) );
}
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -0,0 +1,157 @@
<?php
/**
* @brief Community Enhancements
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 07 Sep 2018
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
/* 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;
}
/**
* Community Enhancement
*/
class _Giphy
{
/**
* @brief Enhancement is enabled?
*/
public $enabled = FALSE;
/**
* @brief IPS-provided enhancement?
*/
public $ips = FALSE;
/**
* @brief Enhancement has configuration options?
*/
public $hasOptions = TRUE;
/**
* @brief Icon data
*/
public $icon = "giphy.png";
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->enabled = ( \IPS\Settings::i()->giphy_enabled );
}
/**
* Edit
*
* @return void
*/
public function edit()
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Radio( 'giphy_custom_apikey', (int) ! ( \IPS\Settings::i()->giphy_apikey_default == \IPS\Settings::i()->giphy_apikey OR ! \IPS\Settings::i()->giphy_apikey ), TRUE, array(
'options' => array(
'0' => 'giphy_custom_apikey_default',
'1' => 'giphy_custom_apikey_custom',
),
'toggles' => array(
'0' => array(),
'1' => array( 'giphy_apikey' ),
)
) ) );
$form->add( new \IPS\Helpers\Form\Text( 'giphy_apikey', \IPS\Settings::i()->giphy_apikey ? \IPS\Settings::i()->giphy_apikey : '', FALSE, array(), NULL, NULL, NULL, 'giphy_apikey' ) );
$form->add( new \IPS\Helpers\Form\Select( 'giphy_rating', \IPS\Settings::i()->giphy_rating ? \IPS\Settings::i()->giphy_rating : 'x', FALSE, array(
'options' => array(
'x' => \IPS\Member::loggedIn()->language()->addToStack('giphy_rating_x'),
'r' => \IPS\Member::loggedIn()->language()->addToStack('giphy_rating_r'),
'pg-13' => \IPS\Member::loggedIn()->language()->addToStack('giphy_rating_pg-13'),
'pg' => \IPS\Member::loggedIn()->language()->addToStack('giphy_rating_pg'),
'g' => \IPS\Member::loggedIn()->language()->addToStack('giphy_rating_g'),
'y' => \IPS\Member::loggedIn()->language()->addToStack('giphy_rating_y'),
)
), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('giphy_rating_suffix') ) );
if ( $values = $form->values() )
{
try
{
/* Enable giphy automatically on the first submit of the form and add it automatically to all toolbars */
if ( ! \IPS\Settings::i()->giphy_enabled )
{
$values['giphy_enabled'] = 1;
$toolbars = json_decode( \IPS\Settings::i()->ckeditor_toolbars, TRUE );
foreach ( array( 'desktop', 'tablet', 'phone' ) as $device )
{
if ( !\in_array( 'ipsgiphy', $toolbars[$device][0]['items'] ) )
{
$toolbars[$device][0]['items'][] = 'ipsgiphy';
}
}
$values['ckeditor_toolbars'] = json_encode( $toolbars );
}
unset( $values['giphy_custom_apikey'] );
$form->saveAsSettings( $values );
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
}
catch ( \LogicException $e )
{
$form->error = $e->getMessage();
}
}
\IPS\Output::i()->sidebar['actions'] = array(
'help' => array(
'title' => 'help',
'icon' => 'question-circle',
'link' => \IPS\Http\Url::ips( 'docs/giphy' ),
'target' => '_blank'
),
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'enhancements__core_Giphy', $form );
}
/**
* Enable/Disable
*
* @param $enabled bool Enable/Disable
* @return void
* @throws \LogicException
*/
public function toggle( $enabled )
{
if ( $enabled )
{
if ( \IPS\Settings::i()->giphy_apikey )
{
\IPS\Settings::i()->changeValues( array( 'giphy_enabled' => 1 ) );
}
else
{
throw new \DomainException;
}
}
else
{
\IPS\Settings::i()->changeValues( array( 'giphy_enabled' => 0 ) );
}
}
}
@@ -1,35 +0,0 @@
<?php
/**
* @brief Google Analytics Community Enhancements
* @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 22 Aug 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
/* 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;
}
/**
* Google Analytics Community Enhancement
*/
class _GoogleAnalytics
{
/**
* @deprecated
*
* @return bool
*/
final public function deprecated()
{
return TRUE;
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -40,7 +40,7 @@ class _GoogleMaps
/**
* @brief Icon data
*/
public $icon = "google_maps.png";
public $icon = "google_maps.jpeg";
/**
* Constructor
@@ -59,71 +59,109 @@ class _GoogleMaps
*/
public function edit()
{
$validation = function( $val ) {
if ( $val and !\IPS\Request::i()->google_maps_api_key )
$wizard = new \IPS\Helpers\Wizard( array(
'google_maps_enable_apis' => function( $data )
{
throw new \DomainException('google_maps_api_key_req');
}
};
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Text( 'google_maps_api_key', \IPS\Settings::i()->google_maps_api_key, FALSE, array(), function( $val ) {
if ( $val )
{
/* Check Geocoding API */
try
$form = new \IPS\Helpers\Form( 'google_maps_enable_apis', 'continue' );
$form->addHeader('google_maps_choose_features');
$form->add( new \IPS\Helpers\Form\YesNo( 'googlemaps', isset( $data['googlemaps'] ) ? $data['googlemaps'] : \IPS\Settings::i()->googlemaps, FALSE, array( 'togglesOn' => array( 'googleApi_jsapi', 'googleApi_staticapi', 'googleApi_geocodeapi' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'googleplacesautocomplete', isset( $data['googleplacesautocomplete'] ) ? $data['googleplacesautocomplete'] : \IPS\Settings::i()->googleplacesautocomplete, FALSE, array( 'togglesOn' => array( 'googleApi_places' ) ) ) );
$form->addHeader('google_maps_enable_apis');
$form->addMessage('google_maps_create_project_message');
foreach ( array( 'jsapi', 'staticapi', 'geocodeapi', 'places' ) as $k )
{
$response = \IPS\Http\Url::external( "https://maps.googleapis.com/maps/api/geocode/json" )->setQueryString( array(
'latlng' => '40.714224,-73.961452',
'sensor' => 'false',
'key' => $val
) )->request()->get()->decodeJson();
}
catch ( \Exception $e )
{
throw new \DomainException('google_maps_api_error');
}
if ( !isset( $response['status'] ) or $response['status'] !== 'OK' )
{
throw new \DomainException('google_maps_api_key_invalid');
$form->addHtml( \IPS\Theme::i()->getTemplate('applications')->enhancementsGoogleMapsApi( $k ) );
}
/* Check Static Maps API */
try
if ( $values = $form->values() )
{
$response = \IPS\Http\Url::external( 'https://maps.googleapis.com/maps/api/staticmap' )->setQueryString( array(
'center' => '40.714224,-73.961452',
'zoom' => NULL,
'size' => "100x100",
'sensor' => 'false',
'markers' => '40.714224,-73.961452',
'key' => $val,
) )->request()->get();
if ( $values['googlemaps'] or $values['googleplacesautocomplete'] )
{
return $values;
}
else
{
\IPS\Settings::i()->changeValues( array( 'googlemaps' => 0, 'googleplacesautocomplete' => 0 ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=applications&controller=enhancements'), 'saved' );
}
}
catch ( \Exception $e )
{
throw new \DomainException('google_maps_api_error');
}
if ( $response->httpResponseCode != 200 )
{
throw new \DomainException('google_maps_api_key_invalid');
}
}
} ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'googlemaps', \IPS\Settings::i()->googlemaps, FALSE, array(), $validation ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'googleplacesautocomplete', \IPS\Settings::i()->googleplacesautocomplete, FALSE, array(), $validation ) );
if ( $values = $form->values() )
{
if( $values['googlemaps'] > 0 )
return (string) $form;
},
'google_maps_create_credentials'=> function( $data )
{
$values['mapbox'] = 0;
}
$form->saveAsSettings( $values );
\IPS\Session::i()->log( 'acplog__enhancements_edited', array( 'enhancements__core_GoogleMaps' => TRUE ) );
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
}
$websiteUrl = rtrim( \IPS\Settings::i()->base_url, '/' ) . '/*';
$form = new \IPS\Helpers\Form;
if ( $data['googlemaps'] )
{
$form->addHeader('google_maps_create_public_key_header');
}
$form->addMessage('google_maps_create_public_key_message');
$form->add( new \IPS\Helpers\Form\Text( 'google_maps_api_key', \IPS\Settings::i()->google_maps_api_key, TRUE, array(), function( $val )
{
try
{
$response = \IPS\Http\Url::external( 'https://maps.googleapis.com/maps/api/staticmap' )->setQueryString( array(
'center' => '40.714224,-73.961452',
'zoom' => NULL,
'size' => "100x100",
'sensor' => 'false',
'markers' => '40.714224,-73.961452',
'key' => $val,
) )->request()->get();
}
catch ( \Exception $e )
{
throw new \DomainException('google_maps_api_error');
}
if ( $response->httpResponseCode != 200 )
{
throw new \DomainException( $response ?: 'google_maps_api_key_invalid' );
}
} ) );
$form->addHtml( \IPS\Theme::i()->getTemplate('applications')->enhancementsGoogleMapsKeyRestrictions( TRUE, $websiteUrl, $data ) );
if ( $data['googlemaps'] )
{
$form->addHeader('google_maps_create_secret_key_header');
$form->addMessage('google_maps_create_secret_key_message');
$form->add( new \IPS\Helpers\Form\Text( 'google_maps_api_key_secret', \IPS\Settings::i()->google_maps_api_key_secret, TRUE, array(), function( $val )
{
try
{
$response = \IPS\Http\Url::external( "https://maps.googleapis.com/maps/api/geocode/json" )->setQueryString( array(
'latlng' => '40.714224,-73.961452',
'sensor' => 'false',
'key' => $val
) )->request()->get()->decodeJson();
}
catch ( \Exception $e )
{
throw new \DomainException('google_maps_api_error');
}
if ( !isset( $response['status'] ) or $response['status'] !== 'OK' )
{
throw new \DomainException( ( isset( $response['error_message'] ) ) ? $response['error_message'] : 'google_maps_api_key_invalid' );
}
} ) );
$form->addHtml( \IPS\Theme::i()->getTemplate('applications')->enhancementsGoogleMapsKeyRestrictions( FALSE, $websiteUrl, $data ) );
}
if ( $values = $form->values() )
{
$form->saveAsSettings( array(
'googlemaps' => $data['googlemaps'],
'googleplacesautocomplete' => $data['googleplacesautocomplete'],
'google_maps_api_key' => $values['google_maps_api_key'],
'google_maps_api_key_secret' => $data['googlemaps'] ? $values['google_maps_api_key_secret'] : ''
) );
\IPS\Session::i()->log( 'acplog__enhancements_edited', array( 'enhancements__core_GoogleMaps' => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=applications&controller=enhancements'), 'saved' );
}
return (string) $form;
},
), \IPS\Http\Url::internal('app=core&module=applications&controller=enhancements&do=edit&id=core_GoogleMaps') );
\IPS\Output::i()->sidebar['actions'] = array(
'help' => array(
@@ -133,8 +171,7 @@ class _GoogleMaps
'target' => '_blank'
),
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'enhancements__core_GoogleMaps', $form );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'enhancements__core_GoogleMaps', $wizard );
}
/**
@@ -1,35 +0,0 @@
<?php
/**
* @brief Community Enhancements: Mandrill integration
* @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 20 June 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
/* 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;
}
/**
* Community Enhancements: Mandrill integration
*/
class _Mandrill
{
/**
* @deprecated
*
* @return bool
*/
final public function deprecated()
{
return TRUE;
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -0,0 +1,154 @@
<?php
/**
* @brief Community Enhancements
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 13 Jan 2020
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
/* 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;
}
/**
* Community Enhancement
*/
class _Pixabay
{
/**
* @brief Enhancement is enabled?
*/
public $enabled = FALSE;
/**
* @brief IPS-provided enhancement?
*/
public $ips = FALSE;
/**
* @brief Enhancement has configuration options?
*/
public $hasOptions = TRUE;
/**
* @brief Icon data
*/
public $icon = "pixabay.png";
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->enabled = ( \IPS\Settings::i()->pixabay_enabled );
}
/**
* Edit
*
* @return void
*/
public function edit()
{
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Text( 'pixabay_apikey', \IPS\Settings::i()->pixabay_apikey ? \IPS\Settings::i()->pixabay_apikey : '', FALSE, array(), function( $val ) {
if ( $val )
{
/* Check API */
try
{
$response = \IPS\Http\Url::external( "https://pixabay.com/api/" )->setQueryString( array(
'key' => $val,
'q' => "winning"
) )->request()->get();
if ( $response->httpResponseCode == 400 )
{
throw new \DomainException('pixabay_api_key_invalid');
}
}
catch ( \Exception $e )
{
throw new \DomainException('pixabay_api_key_invalid');
}
}
}, NULL, NULL, 'pixabay_apikey' ) );
$groups = array();
foreach ( \IPS\Member\Group::groups() as $group )
{
$groups[ $group->g_id ] = $group->name;
}
$form->add( new \IPS\Helpers\Form\Select( 'pixabay_editor_permissions', \IPS\Settings::i()->pixabay_editor_permissions == '*' ? '*' : explode( ',', \IPS\Settings::i()->pixabay_editor_permissions ), NULL, array( 'multiple' => TRUE, 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'everyone' ), NULL, NULL, NULL, 'pixabay_editor_permissions_access' ) );
if ( $values = $form->values() )
{
try
{
/* Enable giphy automatically on the first submit of the form and add it automatically to all toolbars */
if ( ! \IPS\Settings::i()->pixabay_apikey )
{
$values['pixabay_enabled'] = 1;
}
$values['pixabay_editor_permissions'] = $values['pixabay_editor_permissions'] == '*' ? '*' : implode( ',', $values['pixabay_editor_permissions'] );
$form->saveAsSettings( $values );
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
}
catch ( \LogicException $e )
{
$form->error = $e->getMessage();
}
}
\IPS\Output::i()->sidebar['actions'] = array(
'help' => array(
'title' => 'help',
'icon' => 'question-circle',
'link' => \IPS\Http\Url::ips( 'docs/pixabay' ),
'target' => '_blank'
),
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'enhancements__core_Pixabay', $form );
}
/**
* Enable/Disable
*
* @param $enabled bool Enable/Disable
* @return void
* @throws \LogicException
*/
public function toggle( $enabled )
{
if ( $enabled )
{
if ( \IPS\Settings::i()->pixabay_apikey )
{
\IPS\Settings::i()->changeValues( array( 'pixabay_enabled' => 1 ) );
}
else
{
throw new \DomainException;
}
}
else
{
\IPS\Settings::i()->changeValues( array( 'pixabay_enabled' => 0 ) );
}
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -168,7 +168,7 @@ class _SendGrid
$sendgrid = new \IPS\Email\Outgoing\SendGrid( $values['sendgrid_api_key'] );
$scopes = $sendgrid->scopes();
if ( !in_array( 'mail.send', $scopes['scopes'] ) )
if ( !\in_array( 'mail.send', $scopes['scopes'] ) )
{
throw new \DomainException( 'sendgrid_bad_scopes' );
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -1,37 +0,0 @@
<?php
/**
* @brief Sparkpost Community Enhancement extension
* @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
* @subpackage
* @since 18 Sep 2014
* @version SVN_VERSION_NUMBER
* @deprecated 4.3
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
/* 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;
}
/**
* IP Address Lookup extension
*/
class _Sparkpost
{
/**
* @deprecated
*
*@return bool
*/
final public function deprecated()
{
return TRUE;
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -0,0 +1,304 @@
<?php
/**
* @brief Community Enhancements
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 06 Feb 2020
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
/* 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;
}
/**
* Community Enhancement
*/
class _Zapier
{
/**
* Get the permissions needed for the Zapier API key
*
* @return array
*/
protected static function apiKeyPermissions()
{
$return = array(
'core/groups/GETindex' => array( 'access' => TRUE ),
'core/hello/GETindex' => array( 'access' => TRUE ),
'core/members/GETindex' => array( 'access' => TRUE ),
'core/members/GETitem' => array( 'access' => TRUE ),
'core/members/POSTindex' => array( 'access' => TRUE ),
'core/webhooks/POSTindex' => array( 'access' => TRUE ),
'core/webhooks/DELETEitem' => array( 'access' => TRUE ),
);
if ( \IPS\Application::appIsEnabled('forums') )
{
$return['forums/forums/GETindex'] = array( 'access' => TRUE );
$return['forums/forums/GETitem'] = array( 'access' => TRUE );
$return['forums/topics/GETindex'] = array( 'access' => TRUE );
$return['forums/topics/GETitem'] = array( 'access' => TRUE );
$return['forums/topics/POSTindex'] = array( 'access' => TRUE );
$return['forums/posts/GETindex'] = array( 'access' => TRUE );
$return['forums/posts/GETitem'] = array( 'access' => TRUE );
$return['forums/posts/POSTindex'] = array( 'access' => TRUE );
}
if ( \IPS\Application::appIsEnabled('calendar') )
{
$return['calendar/calendars/GETindex'] = array( 'access' => TRUE );
$return['calendar/calendars/GETitem'] = array( 'access' => TRUE );
$return['calendar/events/GETindex'] = array( 'access' => TRUE );
$return['calendar/events/GETitem'] = array( 'access' => TRUE );
$return['calendar/events/POSTindex'] = array( 'access' => TRUE );
$return['calendar/comments/GETindex'] = array( 'access' => TRUE );
$return['calendar/comments/GETitem'] = array( 'access' => TRUE );
$return['calendar/comments/POSTindex'] = array( 'access' => TRUE );
$return['calendar/reviews/GETindex'] = array( 'access' => TRUE );
$return['calendar/reviews/GETitem'] = array( 'access' => TRUE );
$return['calendar/reviews/POSTindex'] = array( 'access' => TRUE );
}
if ( \IPS\Application::appIsEnabled('downloads') )
{
$return['downloads/categories/GETindex'] = array( 'access' => TRUE );
$return['downloads/categories/GETitem'] = array( 'access' => TRUE );
$return['downloads/files/GETindex'] = array( 'access' => TRUE );
$return['downloads/files/GETitem'] = array( 'access' => TRUE );
$return['downloads/files/POSTindex'] = array( 'access' => TRUE );
$return['downloads/comments/GETindex'] = array( 'access' => TRUE );
$return['downloads/comments/GETitem'] = array( 'access' => TRUE );
$return['downloads/comments/POSTindex'] = array( 'access' => TRUE );
$return['downloads/reviews/GETindex'] = array( 'access' => TRUE );
$return['downloads/reviews/GETitem'] = array( 'access' => TRUE );
$return['downloads/reviews/POSTindex'] = array( 'access' => TRUE );
}
if ( \IPS\Application::appIsEnabled('blog') )
{
$return['blog/categories/GETindex'] = array( 'access' => TRUE );
$return['blog/categories/GETitem'] = array( 'access' => TRUE );
$return['blog/blogs/GETindex'] = array( 'access' => TRUE );
$return['blog/blogs/GETitem'] = array( 'access' => TRUE );
$return['blog/blogs/POSTindex'] = array( 'access' => TRUE );
$return['blog/entrycategories/GETindex'] = array( 'access' => TRUE );
$return['blog/entrycategories/GETitem'] = array( 'access' => TRUE );
$return['blog/entries/GETindex'] = array( 'access' => TRUE );
$return['blog/entries/GETitem'] = array( 'access' => TRUE );
$return['blog/entries/POSTindex'] = array( 'access' => TRUE );
$return['blog/comments/GETindex'] = array( 'access' => TRUE );
$return['blog/comments/GETitem'] = array( 'access' => TRUE );
$return['blog/comments/POSTindex'] = array( 'access' => TRUE );
}
if ( \IPS\Application::appIsEnabled('gallery') )
{
$return['gallery/categories/GETindex'] = array( 'access' => TRUE );
$return['gallery/categories/GETitem'] = array( 'access' => TRUE );
$return['gallery/albums/GETindex'] = array( 'access' => TRUE );
$return['gallery/albums/GETitem'] = array( 'access' => TRUE );
$return['gallery/images/GETindex'] = array( 'access' => TRUE );
$return['gallery/images/GETitem'] = array( 'access' => TRUE );
$return['gallery/images/POSTindex'] = array( 'access' => TRUE );
$return['gallery/comments/GETindex'] = array( 'access' => TRUE );
$return['gallery/comments/GETitem'] = array( 'access' => TRUE );
$return['gallery/comments/POSTindex'] = array( 'access' => TRUE );
$return['gallery/reviews/GETindex'] = array( 'access' => TRUE );
$return['gallery/reviews/GETitem'] = array( 'access' => TRUE );
$return['gallery/reviews/POSTindex'] = array( 'access' => TRUE );
}
if ( \IPS\Application::appIsEnabled('cms') )
{
$return['cms/databases/GETindex'] = array( 'access' => TRUE );
$return['cms/databases/GETitem'] = array( 'access' => TRUE );
$return['cms/categories/GETindex'] = array( 'access' => TRUE );
$return['cms/categories/GETitem'] = array( 'access' => TRUE );
$return['cms/records/GETindex'] = array( 'access' => TRUE );
$return['cms/records/GETitem'] = array( 'access' => TRUE );
$return['cms/records/POSTindex'] = array( 'access' => TRUE );
$return['cms/comments/GETindex'] = array( 'access' => TRUE );
$return['cms/comments/GETitem'] = array( 'access' => TRUE );
$return['cms/comments/POSTindex'] = array( 'access' => TRUE );
$return['cms/reviews/GETindex'] = array( 'access' => TRUE );
$return['cms/reviews/GETitem'] = array( 'access' => TRUE );
$return['cms/reviews/POSTindex'] = array( 'access' => TRUE );
}
return $return;
}
/**
* @brief Enhancement is enabled?
*/
public $enabled = FALSE;
/**
* @brief IPS-provided enhancement?
*/
public $ips = FALSE;
/**
* @brief Enhancement has configuration options?
*/
public $hasOptions = TRUE;
/**
* @brief Icon data
*/
public $icon = "zapier.png";
/**
* Can we use this?
*
* @return void
*/
public static function isAvailable()
{
return \IPS\CIC;
}
/**
* Constructor
*
* @return void
*/
public function __construct()
{
if ( \IPS\Settings::i()->zapier_api_key )
{
try
{
$apiKey = \IPS\Api\Key::load( \IPS\Settings::i()->zapier_api_key );
$this->enabled = (bool) json_decode( $apiKey->permissions, TRUE );
}
catch ( \OutOfRangeException $e ) {}
}
}
/**
* Edit
*
* @return void
*/
public function edit()
{
$apiKey = \IPS\Api\Key::load( \IPS\Settings::i()->zapier_api_key );
$correctPermissions = json_encode( static::apiKeyPermissions() );
if ( $apiKey->permissions != $correctPermissions )
{
$apiKey->permissions = $correctPermissions;
$apiKey->save();
}
try
{
$this->testSettings();
}
catch ( \DomainException $e )
{
\IPS\Output::i()->error( $e->getMessage(), '3C414/2' );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'api' )->zapier( $apiKey );
}
/**
* Enable/Disable
*
* @param $enabled bool Enable/Disable
* @return void
* @throws \LogicException
*/
public function toggle( $enabled )
{
$isNew = FALSE;
try
{
$apiKey = \IPS\Api\Key::load( \IPS\Settings::i()->zapier_api_key );
}
catch ( \OutOfRangeException $e )
{
$isNew = TRUE;
$apiKey = new \IPS\Api\Key;
$apiKey->id = \IPS\Login::generateRandomString( 32 );
}
if ( $enabled )
{
try
{
$this->testSettings();
}
catch ( \DomainException $e )
{
\IPS\Output::i()->error( $e->getMessage(), '3C414/1' );
}
$apiKey->permissions = json_encode( static::apiKeyPermissions() );
\IPS\Db::i()->update( 'core_api_webhooks', array( 'enabled' => 1 ), array( 'api_key=?', $apiKey->id ) );
}
else
{
$apiKey->permissions = json_encode( array() );
\IPS\Db::i()->update( 'core_api_webhooks', array( 'enabled' => 0 ), array( 'api_key=?', $apiKey->id ) );
}
$apiKey->allowed_ips = NULL;
$apiKey->save();
\IPS\Settings::i()->changeValues( array( 'zapier_api_key' => $apiKey->id ) );
if ( $isNew )
{
throw new \DomainException;
}
}
/**
* Test Settings
*
* @return void
* @throws \DomainException
*/
protected function testSettings()
{
if ( \IPS\Request::i()->isCgi() )
{
throw new \DomainException( 'zapier_error_cgi' );
}
if ( !\IPS\Settings::i()->use_friendly_urls or !\IPS\Settings::i()->htaccess_mod_rewrite )
{
throw new \DomainException( 'zapier_error_friendly_urls' );
}
$url = \IPS\Http\Url::external( rtrim( \IPS\Settings::i()->base_url, '/' ) . '/api/core/hello' );
try
{
$response = $url->request()->login( 'test', '' )->get()->decodeJson();
if ( isset( $response['errorMessage'] ) AND $response['errorMessage'] == 'IP_ADDRESS_BANNED' )
{
throw new \Exception;
}
if ( $response['errorMessage'] != 'INVALID_API_KEY' and $response['errorMessage'] != 'TOO_MANY_REQUESTS_WITH_BAD_KEY' )
{
throw new \Exception;
}
}
catch ( \Exception $e )
{
throw new \DomainException( 'zapier_error_api' );
}
}
}
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\ContactUs;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\ContactUs;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
Whitespace-only changes.
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\ContentRouter;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -31,7 +31,7 @@ class _Clubs
/**
* Constructor
*
* @param \IPS\Member|IPS\Member\Group|NULL $member If checking access, the member/group to check for, or NULL to not check access
* @param \IPS\Member|IPS\Member\Group|NULL $memberOrGroup If checking access, the member/group to check for, or NULL to not check access
* @return void
*/
public function __construct( $memberOrGroup = NULL )
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\ContentRouter;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -52,7 +52,7 @@ class _Status
*/
public function customTableHelper( $className, $url, $where=array() )
{
if( !in_array( $className, $this->classes ) AND $className != 'IPS\core\Statuses\Status' )
if( !\in_array( $className, $this->classes ) AND $className != 'IPS\core\Statuses\Status' )
{
return new \IPS\Helpers\Table\Content( $className, $url, $where );
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CreateMenu;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\CreateMenu;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -48,10 +48,10 @@ class _AdminNotes
if( \IPS\Request::i()->isAjax() )
{
return (string) \IPS\DateTime::ts( intval( \IPS\Settings::i()->acp_notes_updated ) );
return (string) \IPS\DateTime::ts( \intval( \IPS\Settings::i()->acp_notes_updated ) );
}
}
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'dashboard' ), 'adminnotes' ), ( isset( \IPS\Settings::i()->acp_notes_updated ) and \IPS\Settings::i()->acp_notes_updated ) ? (string) \IPS\DateTime::ts( intval( \IPS\Settings::i()->acp_notes_updated ) ) : '' );
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'dashboard' ), 'adminnotes' ), ( isset( \IPS\Settings::i()->acp_notes_updated ) and \IPS\Settings::i()->acp_notes_updated ) ? (string) \IPS\DateTime::ts( \intval( \IPS\Settings::i()->acp_notes_updated ) ) : '' );
}
}
@@ -1,62 +1,43 @@
<?php
/**
* @brief Dashboard extension: Users Awaiting Validation
* @brief Awaiting validation dashboard plugin
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 13 Aug 2013
* @deprecated This block was removed but we need to continue shipping the file to overwrite the old one if present
*/
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief Dashboard extension: Failed Admin Logins
* @brief Awaiting validation class
*/
class _AwaitingValidation
{
/**
* Can the current user view this dashboard item?
*
* @return bool
*/
* Can we view?
*
* @return bool
*/
public function canView()
{
return TRUE;
return FALSE;
}
/**
* Return the block to show on the dashboard
* Block HTML
*
* @return string
* @return string
*/
public function getBlock()
{
$users = array();
foreach (
\IPS\Db::i()->select(
"*",
'core_validating',
array( 'user_verified=?', TRUE ),
'entry_date desc',
array( 0, 10 )
)->join(
'core_members',
'core_validating.member_id=core_members.member_id'
) as $user
)
{
$users[ $user['member_id'] ] = \IPS\Member::constructFromData( $user );
}
return \IPS\Theme::i()->getTemplate( 'dashboard' )->awaitingValidation( $users );
return '';
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -41,8 +41,9 @@ class _BackgroundQueue
{
$rows = array();
$select = \IPS\Db::i()->select( '*', 'core_queue', array( 'app_enabled=?', 1 ), 'priority ASC, date ASC' )->join( 'core_applications', "app=app_directory" );
if ( count( $select ) )
$select = \IPS\Db::i()->select( '*', 'core_queue', array( 'app_enabled=?', 1 ), 'priority ASC, date ASC', array( 0, 100 ) )->join( 'core_applications', "app=app_directory" );
$totalCount = \IPS\Db::i()->select( 'count(*)', 'core_queue', array( 'app_enabled=?', 1 ) )->join( 'core_applications', "app=app_directory" )->first();
if ( \count( $select ) )
{
foreach ( $select as $queueData )
{
@@ -59,6 +60,6 @@ class _BackgroundQueue
}
}
return \IPS\Theme::i()->getTemplate( 'dashboard' )->backgroundQueue( $rows );
return \IPS\Theme::i()->getTemplate( 'dashboard' )->backgroundQueue( $rows, $totalCount );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -1,18 +0,0 @@
<?php
// Removed
namespace IPS\core\extensions\core\Dashboard;
class _IpsconnectMaster
{
/**
* @deprecated
*
* @return bool
*/
final public function deprecated()
{
return TRUE;
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -29,7 +29,7 @@ class _LatestNews
*/
public function canView()
{
return FALSE;
return TRUE;
}
/**
@@ -39,7 +39,7 @@ class _LatestNews
*/
public function getBlock()
{
//
}
/**
@@ -0,0 +1,99 @@
<?php
/**
* @brief Dashboard extension: Member Stats
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 23 Jul 2013
*/
namespace IPS\core\extensions\core\Dashboard;
/* 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;
}
/**
* @brief Dashboard extension: Member Stats
*/
class _MemberStats
{
/**
* Can the current user view this dashboard item?
*
* @return bool
*/
public function canView()
{
return TRUE;
}
/**
* Return the block to show on the dashboard
*
* @return string
*/
public function getBlock()
{
$stats = NULL;
/* check the cache */
try
{
$stats = \IPS\Data\Store::i()->acpWidget_memberStats;
if ( ! isset( $stats['_cached'] ) or $stats['_cached'] < time() - ( 60 * 30 ) )
{
$stats = NULL;
}
}
catch( \Exception $ex ) { }
if ( $stats === NULL )
{
$stats = array();
/* fetch only successful registered members ; if this needs to be changed, please review the other areas where we have the name<>? AND email<>? condition */
$where = array( array( 'completed=?', true ) );
/* Member count */
$stats['member_count'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where )->first();
/* Opt in members */
$where[] = 'allow_admin_mails=1';
$stats['member_optin'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where )->first();
$stats['_cached'] = time();
/* stil here? */
\IPS\Data\Store::i()->acpWidget_memberStats = $stats;
}
/* Init Chart */
$chart = new \IPS\Helpers\Chart;
/* Specify headers */
$chart->addHeader( \IPS\Member::loggedIn()->language()->get('chart_email_marketing_type'), "string" );
$chart->addHeader( \IPS\Member::loggedIn()->language()->get('chart_members'), "number" );
/* Add Rows */
$chart->addRow( array( \IPS\Member::loggedIn()->language()->addToStack( 'memberStatsDashboard_optin' ), $stats['member_optin'] ) );
$chart->addRow( array( \IPS\Member::loggedIn()->language()->addToStack( 'memberStatsDashboard_optout' ), $stats['member_count'] - $stats['member_optin'] ) );
/* Output */
return \IPS\Theme::i()->getTemplate( 'dashboard' )->memberStats( $stats, $chart->render( 'PieChart', array(
'backgroundColor' => '#ffffff',
'pieHole' => 0.4,
'colors' => array( '#44af94', '#cc535f' ),
'chartArea' => array(
'width' =>"90%",
'height' => "90%"
)
) ) );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -59,7 +59,8 @@ class _OnlineUsers
$seen[ $key ] = true;
}
}
$total = 0;
foreach ( $online as $app => $data )
{
/* Only show if the application is still installed and enabled */
@@ -67,18 +68,20 @@ class _OnlineUsers
{
continue;
}
$chart->addRow( array( \IPS\Member::loggedIn()->language()->addToStack( "__app_" . $app), count( $data ) ) );
$total += \count( $data );
$chart->addRow( array( \IPS\Member::loggedIn()->language()->addToStack( "__app_" . $app), \count( $data ) ) );
}
/* Output */
return \IPS\Theme::i()->getTemplate( 'dashboard' )->onlineUsers( $online, $chart->render( 'PieChart', array(
'backgroundColor' => '#ffffff',
'pieHole' => 0.4,
'colors' => array( '#cc535f', '#d8624b', '#598acd', '#9a84d2', '#e4b555', '#8cb65e', '#44af94', '#4da5c8', '#acb2bb', '#676d76' ),
'chartArea' => array(
'width' =>"90%",
'height' => "90%"
)
) ) );
) ), $total );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -48,8 +48,9 @@ class _Registrations
array(
'isStacked' => FALSE,
'backgroundColor' => '#ffffff',
'colors' => array( '#10967e' ),
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
'colors' => array( '#0c849f' ),
'hAxis' => array( 'gridlines' => array( 'color' => '#dce0e7' ) ),
'vAxis' => array( 'gridlines' => array( 'color' => '#dce0e7' ) ),
'lineWidth' => 1,
'areaOpacity' => 0.4
),
@@ -61,7 +62,7 @@ class _Registrations
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
/* fetch only successful registered members ; if this needs to be changed, please review the other areas where we have the name<>? AND email<>? condition */
$chart->where[] = array( '( name<>? AND email<>? )', '', '' );
$chart->where[] = array( 'completed=?', true );
/* Output */
return \IPS\Theme::i()->getTemplate( 'dashboard' )->registrations( $chart );
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -148,26 +148,46 @@ class _Admin
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
@@ -188,11 +208,15 @@ class _Admin
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $word['word_custom'], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $word['word_custom'], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $word['word_custom'], $this->_lazyLoadStatus );
}
else
{
$rebuilt = call_user_func( $callback, $word['word_custom'] );
$rebuilt = $callback( $word['word_custom'] );
}
}
catch( \InvalidArgumentException $e )
@@ -218,11 +242,15 @@ class _Admin
{
if( $callback == 'parseImageProxy' )
{
$newMessage = \IPS\Text\Parser::parseImageProxy( \IPS\Settings::i()->site_offline_message, $this->_imageProxyStatus );
$newMessage = \IPS\Text\Parser::removeImageProxy( \IPS\Settings::i()->site_offline_message );
}
elseif( $callback == 'parseLazyLoad' )
{
$newMessage = \IPS\Text\Parser::parseLazyLoad( \IPS\Settings::i()->site_offline_message, $this->_lazyLoadStatus );
}
else
{
$newMessage = call_user_func( $callback, \IPS\Settings::i()->site_offline_message );
$newMessage = $callback( \IPS\Settings::i()->site_offline_message );
}
}
catch( \InvalidArgumentException $e )
@@ -249,11 +277,15 @@ class _Admin
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $application['app_disabled_message'], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $application['app_disabled_message'] );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $application['app_disabled_message'], $this->_lazyLoadStatus );
}
else
{
$rebuilt = call_user_func( $callback, $application['app_disabled_message'] );
$rebuilt = $callback( $application['app_disabled_message'] );
}
}
catch( \InvalidArgumentException $e )
@@ -283,11 +315,15 @@ class _Admin
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $mmod['topic_reply_content'], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $mmod['topic_reply_content'] );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $mmod['topic_reply_content'], $this->_lazyLoadStatus );
}
else
{
$rebuilt = call_user_func( $callback, $mmod['topic_reply_content'] );
$rebuilt = $callback( $mmod['topic_reply_content'] );
}
}
catch( \InvalidArgumentException $e )
@@ -322,11 +358,15 @@ class _Admin
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $mail['mail_content'], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $mail['mail_content'] );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $mail['mail_content'], $this->_lazyLoadStatus );
}
else
{
$rebuilt = call_user_func( $callback, $mail['mail_content'] );
$rebuilt = $callback( $mail['mail_content'] );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -59,7 +59,7 @@ class _Announcement
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
{
return TRUE;
return \IPS\core\Announcements\Announcement::load( $id1 )->canView( $member );
}
/**
@@ -103,26 +103,45 @@ class _Announcement
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
@@ -145,11 +164,15 @@ class _Announcement
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $announcement['announce_content'], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $announcement['announce_content'], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $announcement['announce_content'], $this->_lazyLoadStatus );
}
else
{
$rebuilt = call_user_func( $callback, $announcement['announce_content'], \IPS\Member::load( $announcement['announce_member_id'] ), FALSE, 'core_Announcement' );
$rebuilt = $callback( $announcement['announce_content'], \IPS\Member::load( $announcement['announce_member_id'] ), FALSE, 'core_Announcement' );
}
}
catch( \InvalidArgumentException $e )
@@ -0,0 +1,78 @@
<?php
/**
* @brief Editor Extension: ClubPage
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 02 Aug 2019
*/
namespace IPS\core\extensions\core\EditorLocations;
/* 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;
}
/**
* Editor Extension: ClubPage
*/
class _ClubPage
{
/**
* Can we use HTML in this editor?
*
* @param \IPS\Member $member The member
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canUseHtml( $member )
{
return NULL;
}
/**
* Can we use attachments in this editor?
*
* @param \IPS\Member $member The member
* @param \IPS\Helpers\Form\Editor $field The editor field
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canAttach( $member, $field )
{
return NULL;
}
/**
* Permission check for attachments
*
* @param \IPS\Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
{
return \IPS\Member\Club\Page::load( $id1 )->club->canRead( $member );
}
/**
* Attachment lookup
*
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
* @throws \LogicException
*/
public function attachmentLookup( $id1, $id2, $id3 )
{
return \IPS\Member\Club\Page::load( $id1 )->url();
}
}
@@ -0,0 +1,87 @@
<?php
/**
* @brief Editor Extension: ClubRules
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 01 May 2020
*/
namespace IPS\core\extensions\core\EditorLocations;
/* 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;
}
/**
* Editor Extension: ClubRules
*/
class _ClubRules
{
/**
* Can we use HTML in this editor?
*
* @param \IPS\Member $member The member
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canUseHtml( $member )
{
return NULL;
}
/**
* Can we use attachments in this editor?
*
* @param \IPS\Member $member The member
* @param \IPS\Helpers\Form\Editor $field The editor field
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canAttach( $member, $field )
{
return NULL;
}
/**
* Permission check for attachments
*
* @param \IPS\Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
{
/* Make sure that you add a relevant permission check to prevent attachments being accessed via ID enumeration. */
try
{
$club = \IPS\Member\Club::load( $id1 );
return $club->canView( $member );
}
catch ( \OutOfRangeException $e )
{
return FALSE;
}
}
/**
* Attachment lookup
*
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
* @throws \LogicException
*/
public function attachmentLookup( $id1, $id2, $id3 )
{
return \IPS\Member\Club::load( $id1 )->url();
}
}
@@ -5,14 +5,13 @@
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 03 Mar 2017
*/
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -111,25 +110,45 @@ class _Clubs
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
@@ -151,7 +170,7 @@ class _Clubs
$editorFields[] = 'field_' . $field['f_id'];
}
if( !count( $editorFields ) )
if( !\count( $editorFields ) )
{
return $did;
}
@@ -170,11 +189,15 @@ class _Clubs
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $clubFieldValues[ $fieldId ], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $clubFieldValues[ $fieldId ], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $clubFieldValues[ $fieldId ], $this->_lazyLoadStatus );
}
else
{
$rebuilt = call_user_func( $callback, $clubFieldValues[ $fieldId ] );
$rebuilt = $callback( $clubFieldValues[ $fieldId ] );
}
}
catch( \InvalidArgumentException $e )
@@ -195,7 +218,7 @@ class _Clubs
}
}
if( count( $toUpdate ) )
if( \count( $toUpdate ) )
{
\IPS\Db::i()->update( 'core_clubs_fieldvalues', $toUpdate, array( 'club_id=?', $clubFieldValues['club_id'] ) );
}
@@ -219,7 +242,7 @@ class _Clubs
$editorFields[] = 'field_' . $field['f_id'];
}
if( !count( $editorFields ) )
if( !\count( $editorFields ) )
{
return 0;
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -63,7 +63,32 @@ class _CustomField
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
{
return TRUE;
$staff = ( $member->isAdmin() OR $member->modPermissions() );
try
{
$customField = \IPS\core\ProfileFields\Field::loadAndCheckPerms( $id2 );
}
catch( \OutOfRangeException $e )
{
return FALSE;
}
if( $staff )
{
/* We always want staff to access these */
return TRUE;
}
switch( $customField->member_hide )
{
case 'all':
return TRUE;
break;
default:
return ( $member->member_id === \IPS\Member::load( $id1 )->member_id );
break;
}
}
/**
@@ -106,26 +131,46 @@ class _CustomField
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
@@ -148,7 +193,7 @@ class _CustomField
$whereClause[] = '(field_' . $field['pf_id'] . ' IS NOT NULL AND field_' . $field['pf_id'] . " != '')";
}
if( !count( $editorFields ) )
if( !\count( $editorFields ) )
{
return $did;
}
@@ -167,7 +212,11 @@ class _CustomField
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $member[ $fieldId ], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $member[ $fieldId ], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $member[ $fieldId ], $this->_lazyLoadStatus );
}
elseif( $callback[1] == 'rebuildAttachmentUrls' )
{
@@ -196,7 +245,7 @@ class _CustomField
}
}
if( count( $toUpdate ) )
if( \count( $toUpdate ) )
{
\IPS\Db::i()->update( 'core_pfields_content', $toUpdate, array( 'member_id=?', $member['member_id'] ) );
}
@@ -220,7 +269,7 @@ class _CustomField
$editorFields[] = 'field_' . $field['pf_id'];
}
if( !count( $editorFields ) )
if( !\count( $editorFields ) )
{
return 0;
}
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -111,26 +111,46 @@ class _Modcp
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
@@ -156,7 +176,11 @@ class _Modcp
{
if( $callback == 'parseImageProxy' )
{
$update[ $k ] = \IPS\Text\Parser::parseImageProxy( $log[ $k ], $this->_imageProxyStatus );
$update[ $k ] = \IPS\Text\Parser::removeImageProxy( $log[ $k ], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$update[ $k ] = \IPS\Text\Parser::parseLazyLoad( $log[ $k ], $this->_lazyLoadStatus );
}
elseif( $callback[1] == 'rebuildAttachmentUrls' )
{
@@ -164,7 +188,7 @@ class _Modcp
}
elseif( $callback[1] == 'parseStatic' )
{
$update[ $k ] = call_user_func( $callback, $log[ $k ], \IPS\Member::load( $log['wl_moderator'] ), FALSE, 'core_Modcp', $log['wl_id'], NULL, ( $k == 'wl_note_member' ? 'member' : 'mod' ) );
$update[ $k ] = $callback( $log[ $k ], \IPS\Member::load( $log['wl_moderator'] ), FALSE, 'core_Modcp', $log['wl_id'], NULL, ( $k == 'wl_note_member' ? 'member' : 'mod' ) );
}
}
catch( \InvalidArgumentException $e )
@@ -181,7 +205,7 @@ class _Modcp
}
}
if( count( $update ) )
if( \count( $update ) )
{
\IPS\Db::i()->update( 'core_members_warn_logs', $update, array( 'wl_id=?', $log['wl_id'] ) );
}
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -101,26 +101,46 @@ class _Reports
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
@@ -143,7 +163,11 @@ class _Reports
{
if( $callback == 'parseImageProxy' )
{
$update['report'] = \IPS\Text\Parser::parseImageProxy( $report['report'], $this->_imageProxyStatus );
$update['report'] = \IPS\Text\Parser::removeImageProxy( $report['report'], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$update['report'] = \IPS\Text\Parser::parseLazyLoad( $report['report'], $this->_lazyLoadStatus );
}
elseif( $callback[1] == 'rebuildAttachmentUrls' )
{
@@ -151,7 +175,7 @@ class _Reports
}
elseif( $callback[1] == 'parseStatic' )
{
$update['report'] = call_user_func( $callback, $report['report'], \IPS\Member::load( $report['report_by'] ), FALSE, 'core_Reports', $report['id'], NULL, NULL );
$update['report'] = $callback( $report['report'], \IPS\Member::load( $report['report_by'] ), FALSE, 'core_Reports', $report['id'], NULL, NULL );
}
}
catch( \InvalidArgumentException $e )
@@ -166,7 +190,7 @@ class _Reports
}
}
if( count( $update ) )
if( \count( $update ) )
{
\IPS\Db::i()->update( 'core_rc_reports', $update, array( 'id=?', $report['id'] ) );
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -58,7 +58,7 @@ class _Signatures
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
{
return TRUE;
return (bool) \IPS\Settings::i()->signatures_enabled;
}
/**
@@ -102,26 +102,46 @@ class _Signatures
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
@@ -146,13 +166,17 @@ class _Signatures
{
$rebuilt = \IPS\Text\Parser::rebuildAttachmentUrls( $member['signature'], \IPS\Member::load( $member['member_id'] ) );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $member['signature'], $this->_lazyLoadStatus );
}
elseif( $callback == 'parseStatic' )
{
$rebuilt = \IPS\Text\LegacyParser::parseStatic( $member['signature'], \IPS\Member::load( $member['member_id'] ), FALSE, 'core_Signatures', $member['member_id'] );
}
elseif( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $member['signature'], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $member['signature'], $this->proxyUrl );
}
}
catch( \InvalidArgumentException $e )
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -102,26 +102,46 @@ class _Staffdirectory
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
@@ -143,11 +163,15 @@ class _Staffdirectory
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $word['word_custom'], $this->_imageProxyStatus );
$rebuilt = \IPS\Text\Parser::removeImageProxy( $word['word_custom'], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $word['word_custom'], $this->_lazyLoadStatus );
}
else
{
$rebuilt = call_user_func( $callback, $word['word_custom'] );
$rebuilt = $callback( $word['word_custom'] );
}
}
catch( \InvalidArgumentException $e )
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -110,26 +110,46 @@ class _Widget
}
/**
* @brief Store image proxy status ( true = enabled )
* @brief Use the cached image URL instead of the original URL
*/
protected $_imageProxyStatus = null;
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable Image Proxy
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $status=TRUE )
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
{
$this->_imageProxyStatus = $status;
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
@@ -162,52 +182,52 @@ class _Widget
foreach ( $widgets as $k => $widget )
{
if ( in_array( $widget['key'], static::$widgets ) )
if ( \in_array( $widget['key'], static::$widgets ) )
{
$appOrPlugin = isset( $widget['plugin'] ) ? \IPS\Plugin::load( $widget['plugin'] ) : \IPS\Application::load( $widget['app'] );
$widgetObject = \IPS\Widget::load( $appOrPlugin, $widget['key'], $widget['unique'] );
$key = $widgetObject::$editorKey;
$string =$widgetObject::$editorLangKey;
if ( isset( $widget['configuration'][$key ] ) )
if ( isset( $widget['configuration'][ $key ] ) AND \is_array( $widget['configuration'][ $key ] ) )
{
try
foreach( $widget['configuration'][ $key ] as $contentKey => $content )
{
if( $callback == 'parseImageProxy' )
if( $rebuilt = $this->_rebuildWidgetContent( $content, $callback ) )
{
$rebuilt = \IPS\Text\Parser::parseImageProxy( $widget['configuration'][$key ], $this->_imageProxyStatus );
}
else
{
$rebuilt = call_user_func( $callback, $widget['configuration'][$key ] );
}
}
catch( \InvalidArgumentException $e )
{
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
{
$rebuilt = preg_replace( "#\[/?([^\]]+?)\]#", '', $widget['configuration'][$key ] );
}
else
{
throw $e;
$widgets[ $k ]['configuration'][ $key ][ $contentKey ] = $rebuilt;
$update = TRUE;
}
}
}
elseif ( isset( $widget['configuration'][ $key ] ) )
{
$rebuilt = $this->_rebuildWidgetContent( $widget['configuration'][ $key ], $callback );
if ( $rebuilt )
if( $rebuilt !== NULL )
{
$widgets[ $k ]['configuration'][$key] =$rebuilt;
$widgets[ $k ]['configuration'][ $key ] = $rebuilt;
$update = TRUE;
}
}
}
if ( $update )
{
/* Rebuild language bits */
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_key=?', $string ), 'word_id ASC', array( $offset, $max ) ) as $word )
{
$rebuilt = $this->_rebuildWidgetContent( $word['word_custom'], $callback );
\IPS\Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), array( 'word_id=?', $word['word_id'] ) );
}
}
if ( $update )
{
\IPS\Db::i()->update( $table, array( $widgetsColumn => json_encode( $widgets ) ), $whereClause );
}
}
if ( $update )
{
\IPS\Db::i()->update( $table, array( $widgetsColumn => json_encode( $widgets ) ), $whereClause );
}
}
}
@@ -239,7 +259,7 @@ class _Widget
foreach ( $widgets as $k => $widget )
{
if ( in_array( $widget['key'], static::$widgets ) )
if ( \in_array( $widget['key'], static::$widgets ) )
{
$count++;
}
@@ -249,4 +269,44 @@ class _Widget
return $count;
}
/**
* Rebuild Widget Content
*
* @param string $content Content to rebuild
* @param callable $callback Method to call to rebuild content
* @return string|null Rebuilt content
*/
protected function _rebuildWidgetContent( $content, $callback )
{
$rebuilt = NULL;
try
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::removeImageProxy( $content, $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $content, $this->_lazyLoadStatus );
}
else
{
$rebuilt = $callback( $content );
}
}
catch( \InvalidArgumentException $e )
{
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
{
$rebuilt = preg_replace( "#\[/?([^\]]+?)\]#", '', $content );
}
else
{
throw $e;
}
}
return $rebuilt;
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\EditorMedia;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -47,7 +47,7 @@ class _Advertisements
$advertisement['_images'] = json_decode( $advertisement['ad_images'], TRUE );
if( count( $advertisement['_images'] ) )
if( \count( $advertisement['_images'] ) )
{
$files = array();
@@ -85,7 +85,7 @@ class _Advertisements
}
}
if ( count( $files ) )
if ( \count( $files ) )
{
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $files ) ), array( 'ad_id=?', $advertisement['ad_id'] ) );
}
@@ -114,7 +114,7 @@ class _Advertisements
}
}
if ( count( $fixed ) )
if ( \count( $fixed ) )
{
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $fixed ) ), array( 'ad_id=?', $advertisement['ad_id'] ) );
}
@@ -137,7 +137,7 @@ class _Advertisements
{
$advertisement['_images'] = json_decode( $advertisement['ad_images'], TRUE );
if( count( $advertisement['_images'] ) )
if( \count( $advertisement['_images'] ) )
{
if( $advertisement['_images']['large'] == (string) $file )
{
@@ -170,7 +170,7 @@ class _Advertisements
{
$advertisement['_images'] = json_decode( $advertisement['ad_images'], TRUE );
if( count( $advertisement['_images'] ) )
if( \count( $advertisement['_images'] ) )
{
if( $advertisement['_images']['large'] )
{
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -126,7 +126,7 @@ class _Attachment
}
}
if ( count( $fixed ) )
if ( \count( $fixed ) )
{
\IPS\Db::i()->update( 'core_attachments', $fixed, array( 'attach_id=?', $attachment['attach_id'] ) );
}
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -59,7 +59,7 @@ class _Clubs
}
}
if ( count( $update ) )
if ( \count( $update ) )
{
\IPS\Db::i()->update( 'core_clubs', $update, array( 'id=?', $club['id'] ) );
}
@@ -140,7 +140,7 @@ class _Clubs
}
}
if ( count( $fixed ) )
if ( \count( $fixed ) )
{
\IPS\Db::i()->update( 'core_clubs', $fixed, array( 'id=?', $club['id'] ) );
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -60,8 +60,7 @@ class _Emoticons
\IPS\Db::i()->update( 'core_emoticons', array( 'image' => (string) $file, 'image_2x' => (string) $image_2x ), array( 'id=?', $emoticon['id'] ) );
}
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => time() ), array( 'conf_key=?', 'emoji_cache' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
}
catch( \Exception $e )
{
@@ -90,12 +89,11 @@ class _Emoticons
}
}
if ( count( $fixed ) )
if ( \count( $fixed ) )
{
\IPS\Db::i()->update( 'core_emoticons', $fixed, array( 'id=?', $emoticon['id'] ) );
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => time() ), array( 'conf_key=?', 'emoji_cache' ) );
unset( \IPS\Data\Store::i()->settings );
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
}
}
catch( \Exception $e ) { }
@@ -0,0 +1,89 @@
<?php
/**
* @brief File Storage Extension: Feature
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 10 Sep 2019
*/
namespace IPS\core\extensions\core\FileStorage;
/* 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;
}
/**
* File Storage Extension: Feature
*/
class _Feature
{
/**
* Count stored files
*
* @return int
*/
public function count()
{
return \IPS\Db::i()->select( 'COUNT(*)', 'core_members_features', array( "feature_image IS NOT NULL" ) )->first();
}
/**
* Move stored files
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \UnderflowException When file record doesn't exist. Indicating there are no more files to move
* @return void|int An offset integer to use on the next cycle, or nothing
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
{
$feature = \IPS\Db::i()->select( '*', 'core_members_features', array( "feature_image IS NOT NULL" ), 'feature_id', array( $offset, 1 ) )->first();
$url = (string) \IPS\File::get( $oldConfiguration ?: 'core_Feature', $feature['feature_image'] )->move( $storageConfiguration );
if ( $url != $feature['feature_image'] )
{
\IPS\Db::i()->update( 'core_members_features', array( 'feature_image' => $url ), array( 'feature_id=?', $feature['feature_id'] ) );
}
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
{
try
{
\IPS\Db::i()->select( '*', 'core_members_features', array( "feature_image=?", $file ) )->first();
return TRUE;
}
catch( \UnderflowException $e )
{
return FALSE;
}
}
/**
* Delete all stored files
*
* @return void
*/
public function delete()
{
foreach( \IPS\Db::i()->select( 'feature_image', 'core_members_features', array( "feature_image IS NOT NULL" ) ) AS $file )
{
\IPS\File::get( 'core_Feature', $file )->delete();
}
}
}
@@ -0,0 +1,249 @@
<?php
/**
* @brief File Storage Extension: Icons
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 01 Aug 2018
*/
namespace IPS\core\extensions\core\FileStorage;
/* 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;
}
/**
* File Storage Extension: Icons
*/
class _Icons
{
/**
* Count stored files
*
* @return int
*/
public function count()
{
$count = \IPS\Settings::i()->icons_favicon ? 1 : 0;
if( \IPS\Settings::i()->icons_sharer_logo )
{
$count += \count( json_decode( \IPS\Settings::i()->icons_sharer_logo, true ) );
}
if( \IPS\Settings::i()->icons_homescreen )
{
$count += \count( json_decode( \IPS\Settings::i()->icons_homescreen, TRUE ) );
}
if( \IPS\Settings::i()->icons_mask_icon )
{
$count += 1;
}
return $count;
}
/**
* Move stored files
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \UnderflowException When file record doesn't exist. Indicating there are no more files to move
* @return void|int An offset integer to use on the next cycle, or nothing
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
{
if( \IPS\Settings::i()->icons_favicon )
{
\IPS\File::get( $oldConfiguration ?: 'core_Icons', \IPS\Settings::i()->icons_favicon )->move( $storageConfiguration );
}
if( \IPS\Settings::i()->icons_sharer_logo )
{
$logos = json_decode( \IPS\Settings::i()->icons_sharer_logo, true );
foreach( $logos as $logo )
{
\IPS\File::get( $oldConfiguration ?: 'core_Icons', $logo )->move( $storageConfiguration );
}
}
if( \IPS\Settings::i()->icons_homescreen )
{
$homeScreen = json_decode( \IPS\Settings::i()->icons_homescreen, TRUE );
foreach( $homeScreen as $key => $logo )
{
\IPS\File::get( $oldConfiguration ?: 'core_Icons', ( $key == 'original' ) ? $logo : $logo['url'] )->move( $storageConfiguration );
}
}
if( \IPS\Settings::i()->icons_mask_icon )
{
\IPS\File::get( $oldConfiguration ?: 'core_Icons', \IPS\Settings::i()->icons_mask_icon )->move( $storageConfiguration );
}
throw new \UnderflowException;
}
/**
* Fix all URLs
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @return void
*/
public function fixUrls( $offset )
{
$updated = array();
if( \IPS\Settings::i()->icons_favicon )
{
$updated['icons_favicon'] = \IPS\File::repairUrl( \IPS\Settings::i()->icons_favicon );
}
if( \IPS\Settings::i()->icons_sharer_logo )
{
$newLogos = array();
foreach( json_decode( \IPS\Settings::i()->icons_sharer_logo, true ) as $logo )
{
$newLogos[] = \IPS\File::repairUrl( $logo );
}
$updated['icons_sharer_logo'] = json_encode( $newLogos );
}
if( \IPS\Settings::i()->icons_homescreen )
{
$newLogos = array();
foreach( json_decode( \IPS\Settings::i()->icons_homescreen, TRUE ) as $key => $logo )
{
if( $key == 'original' )
{
$newLogos[ $key ] = \IPS\File::repairUrl( $logo );
}
else
{
$newLogos[ $key ] = $logo;
$newLogos[ $key ]['url'] = \IPS\File::repairUrl( $logo['url'] );
}
}
$updated['icons_homescreen'] = json_encode( $newLogos );
}
if( \IPS\Settings::i()->icons_mask_icon )
{
$updated['icons_mask_icon'] = \IPS\File::repairUrl( \IPS\Settings::i()->icons_mask_icon );
}
if( \count( $updated ) )
{
\IPS\Settings::i()->changeValues( $updated );
}
throw new \UnderflowException;
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
{
if( \IPS\Settings::i()->icons_favicon AND $file == \IPS\Settings::i()->icons_favicon )
{
return TRUE;
}
if( \IPS\Settings::i()->icons_sharer_logo )
{
$logos = json_decode( \IPS\Settings::i()->icons_sharer_logo, true );
if( \in_array( $file, $logos ) )
{
return TRUE;
}
}
if( \IPS\Settings::i()->icons_homescreen )
{
foreach( json_decode( \IPS\Settings::i()->icons_homescreen, TRUE ) as $key => $logo )
{
if( ( $key == 'original' AND $file == $logo ) OR ( $key != 'original' AND $file == $logo['url'] ) )
{
return TRUE;
}
}
}
if( \IPS\Settings::i()->icons_mask_icon AND $file == \IPS\Settings::i()->icons_mask_icon )
{
return TRUE;
}
return FALSE;
}
/**
* Delete all stored files
*
* @return void
*/
public function delete()
{
if( \IPS\Settings::i()->icons_favicon )
{
try
{
\IPS\File::get( 'core_Icons', \IPS\Settings::i()->icons_favicon )->delete();
}
catch( \OutOfRangeException $e ){}
}
if( \IPS\Settings::i()->icons_sharer_logo )
{
foreach( json_decode( \IPS\Settings::i()->icons_sharer_logo, true ) as $logo )
{
try
{
\IPS\File::get( 'core_Icons', $logo )->delete();
}
catch( \OutOfRangeException $e ){}
}
}
if( \IPS\Settings::i()->icons_homescreen )
{
foreach( json_decode( \IPS\Settings::i()->icons_homescreen, TRUE ) as $key => $logo )
{
try
{
\IPS\File::get( 'core_Icons', ( $key == 'original' ) ? $logo : $logo['url'] )->delete();
}
catch( \OutOfRangeException $e ){}
}
}
if( \IPS\Settings::i()->icons_mask_icon )
{
try
{
\IPS\File::get( 'core_Icons', \IPS\Settings::i()->icons_mask_icon )->delete();
}
catch( \OutOfRangeException $e ){}
}
\IPS\Settings::i()->changeValues( array( 'icons_favicon' => NULL, 'icons_sharer_logo' => NULL, 'icons_homescreen' => NULL, 'icons_mask_icon' => NULL ) );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -22,6 +22,26 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _Imageproxycache
{
/**
* @brief Does this exist?
*/
protected static $tableExists = NULL;
/**
* Does the table exist?
*
* @return boolean
*/
protected static function tableExists()
{
if ( static::$tableExists === NULL )
{
static::$tableExists = \IPS\Db::i()->checkForTable( 'core_image_proxy' );
}
return static::$tableExists;
}
/**
* Count stored files
*
@@ -29,7 +49,14 @@ class _Imageproxycache
*/
public function count()
{
return \IPS\Db::i()->select( 'COUNT(*)', 'core_image_proxy' )->first();
if ( static::tableExists() )
{
return \IPS\Db::i()->select( 'COUNT(*)', 'core_image_proxy' )->first();
}
else
{
return 0;
}
}
/**
@@ -43,8 +70,15 @@ class _Imageproxycache
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
{
$cache = \IPS\Db::i()->select( '*', 'core_image_proxy', array(), 'md5_url', array( $offset, 1 ) )->first();
if ( static::tableExists() )
{
$cache = \IPS\Db::i()->select( '*', 'core_image_proxy', array(), 'md5_url', array( $offset, 1 ) )->first();
}
else
{
throw new \UnderflowException;
}
/* Don't move a file if it doesn't have a filename */
if( $cache['location'] === NULL )
{
@@ -74,13 +108,13 @@ class _Imageproxycache
*/
public function isValidFile( $file )
{
try
if ( static::tableExists() )
{
\IPS\Db::i()->select( '*', 'core_image_proxy', array( 'location=?', (string) $file ) )->first();
return TRUE;
}
catch ( \UnderflowException $e )
else
{
return FALSE;
}
@@ -93,13 +127,16 @@ class _Imageproxycache
*/
public function delete()
{
foreach( \IPS\Db::i()->select( '*', 'core_image_proxy', 'location IS NOT NULL' ) as $cache )
if ( static::tableExists() )
{
try
foreach( \IPS\Db::i()->select( '*', 'core_image_proxy', 'location IS NOT NULL' ) as $cache )
{
\IPS\File::get( 'core_Imageproxycache', $cache['location'] )->delete();
try
{
\IPS\File::get( 'core_Imageproxycache', $cache['location'] )->delete();
}
catch( \Exception $e ){}
}
catch( \Exception $e ){}
}
}
@@ -111,18 +148,21 @@ class _Imageproxycache
*/
public function fixUrls( $offset )
{
$cache = \IPS\Db::i()->select( '*', 'core_image_proxy', array(), 'md5_url', array( $offset, 1 ) )->first();
try
if ( static::tableExists() )
{
if ( $new = \IPS\File::repairUrl( $cache['location'] ) )
$cache = \IPS\Db::i()->select( '*', 'core_image_proxy', array(), 'md5_url', array( $offset, 1 ) )->first();
try
{
\IPS\Db::i()->update( 'core_image_proxy', array( 'location' => (string) $new ), array( 'md5_url=?', $cache['location'] ) );
if ( $new = \IPS\File::repairUrl( $cache['location'] ) )
{
\IPS\Db::i()->update( 'core_image_proxy', array( 'location' => (string) $new ), array( 'md5_url=?', $cache['location'] ) );
}
}
catch( \Exception $e )
{
/* Any issues are logged and the \IPS\Db::i()->update not run as the exception is thrown */
}
}
catch( \Exception $e )
{
/* Any issues are logged and the \IPS\Db::i()->update not run as the exception is thrown */
}
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -37,6 +37,10 @@ class _Login
{
$count++;
}
if ( isset( $settings['apple_key'] ) and $settings['apple_key'] )
{
$count++;
}
}
return $count;
}
@@ -67,6 +71,19 @@ class _Login
/* Any issues are logged */
}
}
if ( isset( $settings['apple_key'] ) and $settings['apple_key'] )
{
try
{
$settings['apple_key'] = (string) \IPS\File::get( $oldConfiguration ?: 'core_Login', $settings['apple_key'] )->move( $storageConfiguration );
\IPS\Db::i()->update( 'core_login_methods', array( 'login_settings' => json_encode( $settings ) ), array( 'login_id=?', $method['login_id'] ) );
}
catch( \Exception $e )
{
/* Any issues are logged */
}
}
}
unset( \IPS\Data\Store::i()->loginMethods );
throw new \UnderflowException;
@@ -87,6 +104,11 @@ class _Login
{
return TRUE;
}
if ( isset( $settings['apple_key'] ) and $settings['apple_key'] == (string) $file )
{
return TRUE;
}
}
return FALSE;
@@ -102,10 +124,14 @@ class _Login
foreach ( \IPS\Db::i()->select( '*', 'core_login_methods' ) as $method )
{
$settings = json_decode( $method['login_settings'], TRUE );
if ( isset( $settings['button_icon'] ) and $settings['button_icon'] == (string) $file )
if ( !empty( $settings['button_icon'] ) )
{
\IPS\File::get( 'core_Login', $settings['button_icon'] )->delete();
}
if ( !empty( $settings['apple_key'] ) )
{
\IPS\File::get( 'core_Login', $settings['apple_key'] )->delete();
}
}
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -61,7 +61,7 @@ class _Profile
}
}
if ( count( $update ) )
if ( \count( $update ) )
{
foreach( $update as $k => $url )
{
@@ -72,7 +72,7 @@ class _Profile
}
}
if ( count( $update ) )
if ( \count( $update ) )
{
\IPS\Db::i()->update( 'core_members', $update, array( 'member_id=?', $memberData['member_id'] ) );
}
@@ -100,7 +100,7 @@ class _Profile
}
}
if ( count( $fixed ) )
if ( \count( $fixed ) )
{
\IPS\Db::i()->update( 'core_members', $fixed, array( 'member_id=?', $member['member_id'] ) );
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -90,12 +90,12 @@ class _ProfileField
foreach( \IPS\Db::i()->select( '*', 'core_pfields_data', array( 'pf_type=?', 'Upload' ) ) AS $field )
{
$cfield = \IPS\Db::i()->select( '*', 'core_pfields_content', array( "field_{$field['pf_id']}<>? OR field_{$field['pf_id']} IS NOT NULL", '' ), 'member_id', array( $offset, 1 ) )->first();
try
{
if ( $new = \IPS\File::repairUrl( $cfield[ 'field_' . $field['pf_id'] ] ) )
{
\IPS\Db::i()->update( 'core_pfields_content', array( "field_{$field['pf_id']}=?", $new ), array( 'member_id=?', $cfield['member_id'] ) );
\IPS\Db::i()->update( 'core_pfields_content', array( "field_{$field['pf_id']}" => $new ), array( 'member_id=?', $cfield['member_id'] ) );
}
}
catch( \Exception $e )
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -62,7 +62,7 @@ class _Promote
}
if ( $update )
{
\IPS\Db::i()->update( 'core_social_promote', array( 'promote_media' => json_encode( $update ), array( 'promote_id=?', $data['promote_id'] ) ) );
\IPS\Db::i()->update( 'core_social_promote', array( 'promote_media' => json_encode( $update ) ), array( 'promote_id=?', $data['promote_id'] ) );
}
return $data['promote_id'];
@@ -87,7 +87,7 @@ class _Promote
}
}
if ( count( $fixed ) )
if ( \count( $fixed ) )
{
\IPS\Db::i()->update( 'core_social_promote', array( 'promote_media' => json_encode( $fixed ), array( 'promote_id=?', $data['promote_id'] ) ) );
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -0,0 +1,115 @@
<?php
/**
* @brief File Storage Extension: ReferralBanners
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 07 Aug 2019
*/
namespace IPS\core\extensions\core\FileStorage;
/* 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;
}
/**
* File Storage Extension: ReferralBanners
*/
class _ReferralBanners
{
/**
* Count stored files
*
* @return int
*/
public function count()
{
return \IPS\Db::i()->select( 'COUNT(*)', 'core_referral_banners', 'rb_upload=1' )->first();
}
/**
* Move stored files
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
* @return void
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
{
$record = \IPS\Db::i()->select( '*', 'core_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
try
{
$file = \IPS\File::get( $oldConfiguration ?: 'core_ReferralBanners', $record['rb_url'] )->move( $storageConfiguration );
if ( (string) $file != $record['rb_url'] )
{
\IPS\Db::i()->update( 'core_referral_banners', array( 'rb_url' => (string) $file ), array( 'rb_id=?', $record['rb_id'] ) );
}
}
catch( \Exception $e )
{
/* Any issues are logged */
}
}
/**
* Fix all URLs
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @return void
*/
public function fixUrls( $offset )
{
$record = \IPS\Db::i()->select( '*', 'core_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
if ( $new = \IPS\File::repairUrl( $record['rb_url'] ) )
{
\IPS\Db::i()->update( 'core_referral_banners', array( 'rb_url' => $new ), array( 'rb_id=?', $record['rb_id'] ) );
}
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
{
try
{
\IPS\Db::i()->select( '*', 'core_referral_banners', array( 'rb_url=? and rb_upload=1', (string) $file ) )->first();
return TRUE;
}
catch ( \UnderflowException $e )
{
return FALSE;
}
}
/**
* Delete all stored files
*
* @return void
*/
public function delete()
{
foreach( \IPS\Db::i()->select( '*', 'core_referral_banners', 'rb_upload=1' ) as $banner )
{
try
{
\IPS\File::get( 'core_ReferralBanners', $banner['rb_url'] )->delete();
}
catch( \Exception $e ){}
}
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -128,7 +128,7 @@ class _Theme
foreach( array( 'front', 'sharer', 'favicon' ) as $icon )
{
if ( isset( $logos[ $icon ] ) AND is_array( $logos[ $icon ] ) )
if ( isset( $logos[ $icon ] ) AND \is_array( $logos[ $icon ] ) )
{
if ( ! empty( $logos[ $icon ]['url'] ) )
{
@@ -312,7 +312,7 @@ class _Theme
foreach( array( 'front', 'sharer', 'favicon' ) as $icon )
{
if ( isset( $logos[ $icon ] ) AND is_array( $logos[ $icon ] ) )
if ( isset( $logos[ $icon ] ) AND \is_array( $logos[ $icon ] ) )
{
if ( ! empty( $logos[ $icon ]['url'] ) and $new = \IPS\File::repairUrl( $logos[ $icon ]['url'] ) )
{
@@ -356,7 +356,7 @@ class _Theme
$update[ $key ] = $new;
}
}
if ( count( $update ) )
if ( \count( $update ) )
{
\IPS\Settings::i()->changeValues( $update );
}
@@ -429,7 +429,7 @@ class _Theme
{
foreach( array( 'front', 'sharer', 'favicon' ) as $icon )
{
if ( isset( $set->logo[ $icon ] ) AND is_array( $set->logo[ $icon ] ) )
if ( isset( $set->logo[ $icon ] ) AND \is_array( $set->logo[ $icon ] ) )
{
if ( ! empty( $set->logo[ $icon ]['url'] ) AND $set->logo[ $icon ]['url'] == (string) $file )
{
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -82,7 +82,7 @@ class _Clubs extends \IPS\core\FrontNavigation\FrontNavigationAbstract
*/
public function active()
{
return \IPS\core\FrontNavigation::$clubTabActive or ( \IPS\Dispatcher::i()->application->directory === 'core' and \IPS\Dispatcher::i()->module->key === 'clubs' );
return \IPS\Member\Club::userIsInClub();
}
/**
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -36,7 +36,7 @@ class _CustomItem extends \IPS\core\FrontNavigation\FrontNavigationAbstract
/**
* Allow multiple instances?
*
* @return string
* @return bool
*/
public static function allowMultiple()
{
@@ -46,8 +46,8 @@ class _CustomItem extends \IPS\core\FrontNavigation\FrontNavigationAbstract
/**
* Get configuration fields
*
* @param array $configuration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @param array $existingConfiguration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
@@ -88,6 +88,7 @@ class _CustomItem extends \IPS\core\FrontNavigation\FrontNavigationAbstract
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function parseConfiguration( $configuration, $id )
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -46,8 +46,8 @@ class _Menu extends \IPS\core\FrontNavigation\FrontNavigationAbstract
/**
* Get configuration fields
*
* @param array $configuration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @param array $existingConfiguration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
@@ -61,6 +61,7 @@ class _Menu extends \IPS\core\FrontNavigation\FrontNavigationAbstract
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function parseConfiguration( $configuration, $id )
@@ -152,4 +153,21 @@ class _Menu extends \IPS\core\FrontNavigation\FrontNavigationAbstract
return $this->children;
}
/**
* Can the currently logged in user access the content this item links to?
*
* @return bool
*/
public function canAccessContent()
{
foreach ( $this->children() as $child )
{
if ( $child->canView() )
{
return TRUE;
}
}
return FALSE;
}
}
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -39,7 +39,7 @@ class _YourActivityStreams extends \IPS\core\FrontNavigation\FrontNavigationAbst
*/
public function canAccessContent()
{
return \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'discover' ) ) and count( $this->children() );
return \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'discover' ) ) and \count( $this->children() );
}
/**
@@ -82,6 +82,7 @@ class _YourActivityStreams extends \IPS\core\FrontNavigation\FrontNavigationAbst
/**
* Items
*
* @param \IPS\Member|null $member Member or NULL for currently logged in member
* @return array
*/
public static function items( \IPS\Member $member = NULL )
@@ -95,7 +96,7 @@ class _YourActivityStreams extends \IPS\core\FrontNavigation\FrontNavigationAbst
if ( !isset( \IPS\Data\Store::i()->globalStreamIds ) )
{
$globalStreamIds = array();
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_streams', 'member IS NULL', 'position ASC' ), 'IPS\core\Stream' ) as $stream )
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_streams', '`member` IS NULL', 'position ASC' ), 'IPS\core\Stream' ) as $stream )
{
$globalStreamIds[ $stream->id ] = ( $stream->ownership == 'all' and $stream->read == 'all' and $stream->follow == 'all' and $stream->date_type != 'last_visit' );
}
@@ -105,7 +106,7 @@ class _YourActivityStreams extends \IPS\core\FrontNavigation\FrontNavigationAbst
$globalStreamIdsToShow = array_keys( !$member->member_id ? array_filter( \IPS\Data\Store::i()->globalStreamIds ) : \IPS\Data\Store::i()->globalStreamIds );
if ( count( $globalStreamIdsToShow ) )
if ( \count( $globalStreamIdsToShow ) )
{
if ( $member->member_id )
{
@@ -120,7 +121,7 @@ class _YourActivityStreams extends \IPS\core\FrontNavigation\FrontNavigationAbst
if ( $member->member_id )
{
if ( $member->member_streams and $streams = json_decode( $member->member_streams, TRUE ) and count( $streams['streams'] ) )
if ( $member->member_streams and $streams = json_decode( $member->member_streams, TRUE ) and \count( $streams['streams'] ) )
{
static::$children[ $member->member_id ][] = new MenuHeader('custom_streams');
foreach ( $streams['streams'] as $id => $title )
@@ -12,7 +12,7 @@
namespace IPS\core\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -45,7 +45,7 @@ class _YourActivityStreamsItem extends \IPS\core\FrontNavigation\FrontNavigation
{
parent::__construct( $configuration, $id, $permissions );
if ( count( $configuration ) and isset( $configuration['menu_stream_id'] ) )
if ( \count( $configuration ) and isset( $configuration['menu_stream_id'] ) )
{
$this->streamId = $configuration['menu_stream_id'];
}
@@ -83,7 +83,7 @@ class _YourActivityStreamsItem extends \IPS\core\FrontNavigation\FrontNavigation
/**
* Allow multiple instances?
*
* @return string
* @return bool
*/
public static function allowMultiple()
{
@@ -93,14 +93,14 @@ class _YourActivityStreamsItem extends \IPS\core\FrontNavigation\FrontNavigation
/**
* Get configuration fields
*
* @param array $configuration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @param array $existingConfiguration The existing configuration, if editing an existing item
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function configuration( $existingConfiguration, $id = NULL )
{
$globalStreams = array();
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_streams', 'member IS NULL' ), 'IPS\core\Stream' ) as $stream )
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_streams', '`member` IS NULL' ), 'IPS\core\Stream' ) as $stream )
{
$globalStreams[ $stream->id ] = $stream->_title;
}
@@ -116,6 +116,7 @@ class _YourActivityStreamsItem extends \IPS\core\FrontNavigation\FrontNavigation
* Parse configuration fields
*
* @param array $configuration The values received from the form
* @param int $id The ID number of the existing item, if editing
* @return array
*/
public static function parseConfiguration( $configuration, $id )
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\GroupForm;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -112,7 +112,7 @@ class _Content
$form->addHeader( 'group_deleting' );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'g_hide_own_posts', !$group->g_hide_own_posts ? 0 : ( $group->g_hide_own_posts == '1' ? '1' : explode( ',', $group->g_hide_own_posts ) ), FALSE, array(
'options' => array_filter( $contentClasses, function( $class ) {
return in_array( 'IPS\Content\Hideable', class_implements( $class ) );
return \in_array( 'IPS\Content\Hideable', class_implements( $class ) );
}, ARRAY_FILTER_USE_KEY ),
'unlimited' => '1'
) ) );
@@ -142,14 +142,14 @@ class _Content
$form->add( new \IPS\Helpers\Form\YesNo( 'gbw_immune_auto_mod', $group->g_bitoptions['gbw_immune_auto_mod'] ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'g_lock_unlock_own', !$group->g_lock_unlock_own ? 0 : ( $group->g_lock_unlock_own == '1' ? '1' : explode( ',', $group->g_lock_unlock_own ) ), FALSE, array(
'options' => array_filter( $contentClasses, function( $class ) {
return in_array( 'IPS\Content\Lockable', class_implements( $class ) );
return \in_array( 'IPS\Content\Lockable', class_implements( $class ) );
}, ARRAY_FILTER_USE_KEY ),
'unlimited' => '1'
) ) );
}
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'g_can_report', !$group->g_can_report ? 0 : ( $group->g_can_report == '1' ? '1' : explode( ',', $group->g_can_report ) ), FALSE, array(
'options' => array_filter( $contentClasses, function( $class ) {
'options' => array_filter( array_merge( array( 'IPS\core\Messenger\Message' => 'personal_conversation_pl' ), $contentClasses ), function( $class ) {
return \IPS\IPS::classUsesTrait( $class, 'IPS\Content\Reportable' );
}, ARRAY_FILTER_USE_KEY ),
'unlimited' => '1'
@@ -184,8 +184,8 @@ class _Content
if( $group->g_id != \IPS\Settings::i()->guest_group )
{
$group->g_ppd_limit = $values['g_ppd_limit'];
$group->g_ppd_unit = intval( $values['g_ppd_unit'][0] );
$group->g_bitoptions['gbw_ppd_unit_type'] = $values['g_ppd_unit'][1];
$group->g_ppd_unit = ( \is_array( $values['g_ppd_unit'] ) ) ? \intval( $values['g_ppd_unit'][0] ) : 0;
$group->g_bitoptions['gbw_ppd_unit_type'] = ( \is_array( $values['g_ppd_unit'] ) ) ? $values['g_ppd_unit'][1] : 0;
}
/* Polls */
@@ -255,13 +255,13 @@ class _Content
{
if ( isset( $values[ $k ] ) )
{
if ( is_array( $values[ $k ] ) and count( $values[ $k ] ) )
if ( \is_array( $values[ $k ] ) and \count( $values[ $k ] ) )
{
$group->$k = implode( ',', $values[ $k ] );
}
else
{
$group->$k = intval( $values[ $k ] );
$group->$k = \intval( $values[ $k ] );
}
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\GroupForm;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -52,7 +52,7 @@ class _GroupSettings
'getHtml' => function( $element )
{
$color = NULL;
if ( preg_match( '/^<span style=\'color:#((?:(?:[a-f0-9]{3})|(?:[a-f0-9]{6})));\'>$/i', $element->value['prefix'], $matches ) and $element->value['suffix'] === '</span>' )
if ( preg_match( '/^<span style=\'color:#((?:(?:[a-f0-9]{3})|(?:[a-f0-9]{6})))\'>$/i', $element->value['prefix'], $matches ) and $element->value['suffix'] === '</span>' )
{
$color = $matches[1];
$element->value['prefix'] = NULL;
@@ -75,7 +75,7 @@ class _GroupSettings
$color = '#' . $color;
}
if( !in_array( $color, array( '#fff', '#ffffff', '#000', '#000000' ) ) )
if( !\in_array( $color, array( '#fff', '#ffffff', '#000', '#000000' ) ) )
{
return array( 'prefix' => "<span style='color:{$color}'>", 'suffix' => '</span>' );
}
@@ -118,9 +118,11 @@ class _GroupSettings
);
$form->add( new \IPS\Helpers\Form\Custom( 'group_username', $defaultValues, FALSE, array(
'getHtml' => function( $element )
{
return \IPS\Theme::i()->getTemplate( 'members' )->usernameChanges( $element->name, $element->value );
'getHtml' => function( $element ) use ( $defaultValues )
{
$values = array_merge( $defaultValues, $element->value );
return \IPS\Theme::i()->getTemplate( 'members' )->usernameChanges( $element->name, $values );
},
'formatValue' => function( $element )
{
@@ -169,14 +171,18 @@ class _GroupSettings
/* Search */
if ( $group->canAccessModule( \IPS\Application\Module::get( 'core', 'search', 'front' ) ) )
{
$form->add( new \IPS\Helpers\Form\Number( 'g_search_flood', $group->g_search_flood, FALSE, array( 'unlimited' => 0 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('seconds'), 'g_search_flood' ) );
$form->add( new \IPS\Helpers\Form\Interval( 'g_search_flood', $group->g_search_flood, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::SECONDS, 'unlimited' => 0 ) ) );
}
/* Privacy */
$form->addHeader( 'group_privacy' );
if( $group->g_id != \IPS\Settings::i()->guest_group )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'g_hide_online_list', $group->g_hide_online_list, FALSE, array(), NULL, NULL, NULL, 'g_hide_online_list' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'g_hide_online_list', $group->g_hide_online_list, FALSE, array( 'options' => array(
0 => 'group_allow_anon_logins',
1 => 'group_force_anon_logins',
2 => 'group_disallow_anon_logins'
) ), NULL, NULL, NULL, 'g_hide_online_list' ) );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'gbw_hide_group', !$group->g_bitoptions['gbw_hide_group'], FALSE, array(), NULL, NULL, NULL, 'gbw_hide_group' ) );
@@ -248,10 +254,10 @@ class _GroupSettings
/* Username changes */
if( $group->g_id != \IPS\Settings::i()->guest_group )
{
$group->g_dname_changes = ( isset( $values['group_username']['canchange'] ) and $values['group_username']['canchange'] ) ? $values['group_username'][0] : 0;
$group->g_dname_changes = ( isset( $values['group_username']['canchange'] ) and $values['group_username']['canchange'] ) ? (int) $values['group_username'][0] : 0;
$group->g_displayname_unit = ( isset( $values['group_username']['canchange'] ) ) ? (int) $values['group_username'][1] : 0;
$group->g_bitoptions['gbw_displayname_unit_type'] = ( isset( $values['group_username'][2] ) ) ? $values['group_username'][2] : 0;
$group->g_dname_date = ( isset( $values['group_username']['canchange'] ) ) ? $values['group_username'][3] : 1;
$group->g_dname_date = ( isset( $values['group_username']['canchange'] ) ) ? (int) $values['group_username'][3] : 1;
}
/* Signatures */
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\GroupForm;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -183,7 +183,7 @@ class _Social
if ( \IPS\Settings::i()->clubs and $group->canAccessModule( \IPS\Application\Module::get( 'core', 'clubs', 'front' ) ) )
{
$group->g_create_clubs = implode( ',', $values['g_create_clubs'] );
$group->g_club_allowed_nodes = ( count( $values['g_club_allowed_nodes'] ) === count( \IPS\Member\Club::availableNodeTypes() ) ) ? '*' : implode( ',', $values['g_club_allowed_nodes'] );
$group->g_club_allowed_nodes = ( \count( $values['g_club_allowed_nodes'] ) === \count( \IPS\Member\Club::availableNodeTypes() ) ) ? '*' : implode( ',', $values['g_club_allowed_nodes'] );
$group->g_club_limit = $values['g_club_limit'] == -1 ? NULL : $values['g_club_limit'];
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->clubs_paid_on )
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\GroupLimits;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -36,7 +36,7 @@ class _GroupLimits
'exclude' => array( 'g_id', 'g_icon', 'prefix', 'suffix', 'g_promotion', 'g_bitoptions' ),
'lessIsMore' => array( 'g_search_flood', 'g_pm_flood_mins' ),
'neg1IsBest' => array( 'g_attach_max', 'g_max_bgimg_upload', 'g_max_messages', 'g_pm_perday', 'g_pm_flood_mins', 'g_max_mass_pm', 'g_rep_max_positive' ),
'zeroIsBest' => array( 'g_displayname_unit', 'g_sig_unit', 'g_mod_preview', 'g_ppd_limit', 'g_ppd_unit', 'gbw_no_status_update', 'g_max_bgimg_upload', 'gbw_disable_prefixes', 'gbw_disable_tagging' ),
'zeroIsBest' => array( 'g_displayname_unit', 'g_sig_unit', 'g_mod_preview', 'g_ppd_limit', 'g_ppd_unit', 'gbw_no_status_update', 'g_max_bgimg_upload', 'gbw_disable_prefixes', 'gbw_disable_tagging', 'g_hide_online_list' ),
'callback' => array(
'g_edit_cutoff' => array( $this, '_editCutoff' ),
'g_attach_per_post' => array( $this, '_attachMaxPerPost' ),
@@ -263,6 +263,16 @@ class _GroupLimits
{
return NULL;
}
/* If one group is set so "can edit profile" is no, ignore their photo vars options */
if( !$a['g_edit_profile'] )
{
return $b[ $k ];
}
elseif( !$b['g_edit_profile'] )
{
return $a[ $k ];
}
/* We have limits */
if( $b[ $k ] )
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\IpAddresses;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\IpAddresses;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -131,6 +131,6 @@ class _AdminLogs
*/
public function findByMember( $member )
{
return \IPS\Db::i()->select( "ip_address AS ip, COUNT(*) AS count, MIN(ctime) AS first, MAX(ctime) AS last", 'core_admin_logs', array( 'member_id=?', $member->member_id ), NULL, NULL, 'ip_address' )->setKeyField( 'ip' );
return \IPS\Db::i()->select( "ip_address AS ip, count(*) AS count, MIN(ctime) AS first, MAX(ctime) AS last", 'core_admin_logs', array( 'member_id=?', $member->member_id ), NULL, NULL, 'ip_address' )->setKeyField( 'ip' );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\IpAddresses;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -83,7 +83,7 @@ class _Content extends \IPS\Content\ExtensionGenerator
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'tables', 'core', 'admin' ), 'rows' );
/* Columns we need */
if ( in_array( 'IPS\Content\Comment', class_parents( $class ) ) )
if ( \in_array( 'IPS\Content\Comment', class_parents( $class ) ) )
{
$table->include = array( $class::$databasePrefix . $class::$databaseColumnMap['item'], $class::$databasePrefix . $class::$databaseColumnMap['author'], $class::$databasePrefix . $class::$databaseColumnMap['date'], $class::$databasePrefix . $class::$databaseColumnMap['ip_address'] );
$table->mainColumn = $class::$databasePrefix . $class::$databaseColumnMap['item'];
@@ -205,6 +205,6 @@ class _Content extends \IPS\Content\ExtensionGenerator
return NULL;
}
return \IPS\Db::i()->select( "{$class::$databasePrefix}{$class::$databaseColumnMap['ip_address']} AS ip, COUNT(*) AS count, MIN({$class::$databasePrefix}{$class::$databaseColumnMap['date']}) AS first, MAX({$class::$databasePrefix}{$class::$databaseColumnMap['date']}) AS last", $class::$databaseTable, array( "{$class::$databasePrefix}{$class::$databaseColumnMap['author']}=?", $member->member_id ), NULL, NULL, "{$class::$databasePrefix}{$class::$databaseColumnMap['ip_address']}" )->setKeyField( 'ip' );
return \IPS\Db::i()->select( "{$class::$databasePrefix}{$class::$databaseColumnMap['ip_address']} AS ip, count(*) AS count, MIN({$class::$databasePrefix}{$class::$databaseColumnMap['date']}) AS first, MAX({$class::$databasePrefix}{$class::$databaseColumnMap['date']}) AS last", $class::$databaseTable, array( "{$class::$databasePrefix}{$class::$databaseColumnMap['author']}=?", $member->member_id ), NULL, NULL, "{$class::$databasePrefix}{$class::$databaseColumnMap['ip_address']}" )->setKeyField( 'ip' );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\IpAddresses;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -97,6 +97,6 @@ class _Dnames
*/
public function findByMember( $member )
{
return \IPS\Db::i()->select( "log_ip_address AS ip, COUNT(*) AS count, MIN(log_date) AS first, MAX(log_date) AS last", 'core_member_history', array( 'log_type=? AND log_member=?', 'display_name', $member->member_id ), NULL, NULL, 'log_ip_address' )->setKeyField( 'ip' );
return \IPS\Db::i()->select( "log_ip_address AS ip, count(*) AS count, MIN(log_date) AS first, MAX(log_date) AS last", 'core_member_history', array( 'log_type=? AND log_member=?', 'display_name', $member->member_id ), NULL, NULL, 'log_ip_address' )->setKeyField( 'ip' );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\IpAddresses;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -112,6 +112,6 @@ class _ErrorLogs
*/
public function findByMember( $member )
{
return \IPS\Db::i()->select( "log_ip_address AS ip, COUNT(*) AS count, MIN(log_date) AS first, MAX(log_date) AS last", 'core_error_logs', array( 'log_member=?', $member->member_id ), NULL, NULL, 'log_ip_address' )->setKeyField( 'ip' );
return \IPS\Db::i()->select( "log_ip_address AS ip, count(*) AS count, MIN(log_date) AS first, MAX(log_date) AS last", 'core_error_logs', array( 'log_member=?', $member->member_id ), NULL, NULL, 'log_ip_address' )->setKeyField( 'ip' );
}
}
@@ -11,7 +11,7 @@
namespace IPS\core\extensions\core\IpAddresses;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -121,6 +121,6 @@ class _Logins
*/
public function findByMember( $member )
{
return \IPS\Db::i()->select( "ip_address AS ip, COUNT(*) AS count, MIN(last_seen) AS first, MAX(last_seen) AS last", 'core_members_known_ip_addresses', array( 'member_id=?', $member->member_id ), NULL, NULL, 'ip_address' )->setKeyField( 'ip' );
return \IPS\Db::i()->select( "ip_address AS ip, count(*) AS count, MIN(last_seen) AS first, MAX(last_seen) AS last", 'core_members_known_ip_addresses', array( 'member_id=?', $member->member_id ), NULL, NULL, 'ip_address' )->setKeyField( 'ip' );
}
}
Loaded 100 of 3791 files, more files were not shown because too many files have changed in this diff. Show more