Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -58,48 +58,18 @@ class _activeUsers extends \IPS\Widget
|
||||
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . $parts['path'];
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . $parts['path'] . ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
|
||||
$url = $parts['scheme'] . "://" . $parts['host'] . ( isset( $parts['port'] ) ? ':' . $parts['port'] : '' ) . $parts['path'] . ( isset( $parts['query'] ) ? '?' . $parts['query'] : '' );
|
||||
}
|
||||
|
||||
$notInMyName = array();
|
||||
foreach( \IPS\Member\Group::groups() as $group )
|
||||
{
|
||||
if ( $group->g_hide_online_list )
|
||||
{
|
||||
$notInMyName[] = $group->g_id;
|
||||
}
|
||||
}
|
||||
$members = \IPS\Session\Store::i()->getOnlineMembersByLocation( \IPS\Dispatcher::i()->application->directory, \IPS\Dispatcher::i()->module->key, \IPS\Dispatcher::i()->controller, \IPS\Request::i()->id, $url );
|
||||
|
||||
$where = array(
|
||||
array( 'core_sessions.login_type=' . \IPS\Session\Front::LOGIN_TYPE_MEMBER ),
|
||||
array( 'core_sessions.current_appcomponent=?', \IPS\Dispatcher::i()->application->directory ),
|
||||
array( 'core_sessions.current_module=?', \IPS\Dispatcher::i()->module->key ),
|
||||
array( 'core_sessions.current_controller=?', \IPS\Dispatcher::i()->controller ),
|
||||
array( 'core_sessions.running_time>' . \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ),
|
||||
array( 'core_sessions.location_url IS NOT NULL AND location_url LIKE ?', "{$url}%" ),
|
||||
array( 'core_sessions.member_id IS NOT NULL' )
|
||||
);
|
||||
|
||||
if( \IPS\Request::i()->id )
|
||||
if ( isset( $members[ \IPS\Member::loggedIn()->member_id ] ) )
|
||||
{
|
||||
$where[] = array( 'core_sessions.current_id = ?', \IPS\Request::i()->id );
|
||||
}
|
||||
|
||||
if ( count( $notInMyName ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'core_sessions.member_group', $notInMyName, TRUE ) );
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( 'core_sessions.member_id,core_sessions.member_name,core_sessions.seo_name,core_sessions.member_group,core_sessions.login_type', 'core_sessions', $where, 'core_sessions.running_time DESC' ) as $row )
|
||||
{
|
||||
if( $row['login_type'] == \IPS\Session\Front::LOGIN_TYPE_MEMBER and $row['member_id'] != \IPS\Member::loggedIn()->member_id and $row['member_name'] )
|
||||
{
|
||||
$members[ $row['member_id'] ] = $row;
|
||||
}
|
||||
unset( $members[ \IPS\Member::loggedIn()->member_id ] );
|
||||
}
|
||||
|
||||
$memberCount = count( $members );
|
||||
@@ -123,7 +93,8 @@ class _activeUsers extends \IPS\Widget
|
||||
'member_id' => \IPS\Member::loggedIn()->member_id,
|
||||
'member_name' => \IPS\Member::loggedIn()->name,
|
||||
'seo_name' => \IPS\Member::loggedIn()->members_seo_name,
|
||||
'member_group' => \IPS\Member::loggedIn()->member_group_id
|
||||
'member_group' => \IPS\Member::loggedIn()->member_group_id,
|
||||
'in_editor' => 0
|
||||
) ), $members );
|
||||
|
||||
}
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Announcements Widget
|
||||
* @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 19 Nov 2013
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Announcements Widget
|
||||
*/
|
||||
class _announcements extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'announcements';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* @brief Prevent caching for this block
|
||||
*/
|
||||
public $neverCache = TRUE;
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'toshow', isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'sort_by', isset( $this->configuration['sort_by'] ) ? $this->configuration['sort_by'] : 'asc', TRUE, array( 'options' => array( 'asc' => 'ascending', 'desc' => 'descending' ) ) ) );
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if ( !\IPS\Settings::i()->announcements_exist )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$announcements = array();
|
||||
|
||||
$where = array();
|
||||
$where[] = array( 'announce_active=?', 1 );
|
||||
$where[] = array( 'announce_start<? AND ( announce_end=0 OR announce_end>? )', time(), time() );
|
||||
$where[] = array( '(' . \IPS\Db::i()->findInSet( 'announce_permissions', \IPS\Member::loggedIn()->groups ) . ' OR ' . 'announce_permissions=? )', '*' );
|
||||
|
||||
$clauses = array();
|
||||
$params = array();
|
||||
foreach ( \IPS\Dispatcher::i()->application->extensions( 'core', 'Announcements' ) as $key => $extension )
|
||||
{
|
||||
$id = $extension::$idField;
|
||||
if ( isset( \IPS\Request::i()->$id ) )
|
||||
{
|
||||
if ( \IPS\Dispatcher::i()->dispatcherController instanceof \IPS\Content\Controller )
|
||||
{
|
||||
foreach( \IPS\Dispatcher::i()->application->extensions( 'core', 'ContentRouter' ) AS $k => $contentRouter )
|
||||
{
|
||||
foreach( $contentRouter->classes AS $class )
|
||||
{
|
||||
try
|
||||
{
|
||||
$clauses[] = '( announce_location=? AND ( ' . \IPS\Db::i()->findInSet( 'announce_ids', array( $class::load( \IPS\Request::i()->$id )->mapped('container') ) ) . ' OR announce_ids=? ) )';
|
||||
$params[] = $key;
|
||||
$params[] = '0';
|
||||
}
|
||||
catch( \OutOfRangeException $e ){}
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$clauses[] = '( announce_location=? AND ( ' . \IPS\Db::i()->findInSet( 'announce_ids', array( \IPS\Request::i()->$id ) ) . ' OR announce_ids=? ) )';
|
||||
$params[] = $key;
|
||||
$params[] = '0';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$clauses[] = '( announce_location=? AND announce_ids=? )';
|
||||
$params[] = $key;
|
||||
$params[] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
$where[] = array_merge( array( '( announce_app=? OR ( announce_app=?' . ( count( $clauses ) ? ( ' AND ( ' . implode( ' OR ', $clauses ) . ' ) ' ) : '' ) . ' ) )', '*', \IPS\Dispatcher::i()->application->directory ), $params );
|
||||
|
||||
$direction = isset( $this->configuration['sort_by'] ) ? $this->configuration['sort_by'] : 'asc';
|
||||
$limit = isset( $this->configuration['toshow'] ) ? $this->configuration['toshow'] : 5;
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*' ,'core_announcements', $where, 'announce_start ' . $direction, array( 0, $limit ) ) as $row )
|
||||
{
|
||||
$announcements[] = \IPS\core\Announcements\Announcement::constructFromData($row);
|
||||
}
|
||||
|
||||
if ( !count( $announcements ) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->output( $announcements );
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ class _clubs extends \IPS\Widget
|
||||
{
|
||||
if ( !isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$this->configuration['language_key'] = 'widget_title_' . md5( uniqid() );
|
||||
$this->configuration['language_key'] = 'widget_title_' . md5( mt_rand() );
|
||||
}
|
||||
$values['language_key'] = $this->configuration['language_key'];
|
||||
\IPS\Lang::saveCustom( 'core', $this->configuration['language_key'], $values['widget_feed_title'] );
|
||||
@@ -166,7 +166,7 @@ class _clubs extends \IPS\Widget
|
||||
isset( $this->configuration['filters'] ) ? $this->configuration['filters'] : array()
|
||||
);
|
||||
|
||||
if ( count( $clubs ) )
|
||||
if ( is_object( $clubs ) AND $clubs->count( TRUE ) )
|
||||
{
|
||||
return $this->output(
|
||||
$clubs,
|
||||
|
||||
@@ -20,13 +20,19 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* guestSignUp Widget
|
||||
*/
|
||||
class _guestSignUp extends \IPS\Widget\StaticCache
|
||||
class _guestSignUp extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'guestSignUp';
|
||||
|
||||
|
||||
/**
|
||||
* @brief Language String Key used to store the editor content
|
||||
*/
|
||||
public static $editorKey = 'block_guestsignup_message';
|
||||
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
@@ -36,12 +42,6 @@ class _guestSignUp extends \IPS\Widget\StaticCache
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
/**
|
||||
* @brief Cache Expiration
|
||||
* @note We allow this cache to be valid for 60 seconds
|
||||
*/
|
||||
public $cacheExpiration = 60;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -77,7 +77,7 @@ class _guestSignUp extends \IPS\Widget\StaticCache
|
||||
'key' => 'widget_guestsignup_text',
|
||||
'editor' => array(
|
||||
'app' => 'core',
|
||||
'key' => 'GuestSignupWidget',
|
||||
'key' => 'Widget',
|
||||
'autoSaveKey' => 'widget-' . $this->uniqueKey,
|
||||
'attachIds' => isset( $this->configuration['content'] ) ? array( 0, 0, 'widget_guestsignup_text' ) : NULL
|
||||
),
|
||||
@@ -150,7 +150,7 @@ class _guestSignUp extends \IPS\Widget\StaticCache
|
||||
return '';
|
||||
}
|
||||
|
||||
$login = new \IPS\Login( \IPS\Http\Url::internal( 'app=core&module=system&controller=login', 'front', 'login', NULL, \IPS\Settings::i()->logins_over_https ) );
|
||||
$login = new \IPS\Login( \IPS\Http\Url::internal( 'app=core&module=system&controller=login', 'front', 'login' ) );
|
||||
return $this->output( $login, $title, $text );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief newsletter Widget
|
||||
* @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 20 Dec 2017
|
||||
*/
|
||||
|
||||
namespace IPS\core\widgets;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* newsletter Widget
|
||||
*/
|
||||
class _newsletter extends \IPS\Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'newsletter';
|
||||
|
||||
/**
|
||||
* @brief Language String Key used to store the editor content
|
||||
*/
|
||||
public static $editorKey = 'block_newsletter_signup';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
{
|
||||
if ( $form === null )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'block_newsletter_signup_text', NULL, TRUE, array(
|
||||
'app' => 'core',
|
||||
'key' => 'block_newsletter_signup',
|
||||
'editor' => array(
|
||||
'app' => 'core',
|
||||
'key' => 'Widget',
|
||||
'autoSaveKey' => 'widget-' . $this->uniqueKey,
|
||||
'attachIds' => isset( $this->configuration['content'] ) ? array( 0, 0, 'block_newsletter_signup' ) : NULL
|
||||
),
|
||||
) ) );
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Before the widget is removed, we can do some clean up
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'core', 'block_newsletter_signup' );
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_attachments_map', array( array( 'location_key=?', 'core_Newsletterwidget' ) ) ) as $map )
|
||||
{
|
||||
try
|
||||
{
|
||||
$attachment = \IPS\Db::i()->select( '*', 'core_attachments', array( 'attach_id=?', $map['attachment_id'] ) )->first();
|
||||
|
||||
\IPS\Db::i()->delete( 'core_attachments_map', array( array( 'attachment_id=?', $attachment['attach_id'] ) ) );
|
||||
\IPS\Db::i()->delete( 'core_attachments', array( 'attach_id=?', $attachment['attach_id'] ) );
|
||||
|
||||
|
||||
\IPS\File::get( 'core_Attachment', $attachment['attach_location'] )->delete();
|
||||
if ( $attachment['attach_thumb_location'] )
|
||||
{
|
||||
\IPS\File::get( 'core_Attachment', $attachment['attach_thumb_location'] )->delete();
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ran before saving widget configuration
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
{
|
||||
\IPS\File::claimAttachments( 'widget-' . $this->uniqueKey, 0, 0, 'block_newsletter_signup' );
|
||||
\IPS\Lang::saveCustom( 'core', 'block_newsletter_signup', $values[ 'block_newsletter_signup_text' ] );
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if( \IPS\Member::loggedIn()->allow_admin_mails )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
// If we have just dropped the block, the ref will be the URL for that block drop, which will show a WSOD if we click the sign up button before reloading the page
|
||||
if ( isset( \IPS\Request::i()->blockID ) )
|
||||
{
|
||||
$url = \IPS\Settings::i()->base_url;
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = (string) \IPS\Request::i()->url();
|
||||
}
|
||||
|
||||
$ref = base64_encode( $url );
|
||||
return $this->output( $ref );
|
||||
}
|
||||
}
|
||||
@@ -66,11 +66,9 @@ class _stats extends \IPS\Widget\StaticCache
|
||||
if ( \IPS\Member::loggedIn()->isAdmin() and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'member_recount_content' ) )
|
||||
{
|
||||
$mostOnline = array( 'count' => $values['stats_most_online'], 'time' => time() );
|
||||
\IPS\Settings::i()->most_online = json_encode( $mostOnline );
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => json_encode( $mostOnline ) ), array( 'conf_key=?', 'most_online' ) );
|
||||
\IPS\Settings::i()->changeValues( array( 'most_online' => json_encode( $mostOnline ) ) );
|
||||
|
||||
unset( $values['stats_most_online'] );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
|
||||
\IPS\Widget::deleteCaches( 'stats', 'core' );
|
||||
}
|
||||
@@ -95,13 +93,11 @@ class _stats extends \IPS\Widget\StaticCache
|
||||
$stats['member_count'] = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', $where )->first();
|
||||
|
||||
/* Most online */
|
||||
$select = \IPS\Db::i()->select( 'COUNT(*)', 'core_sessions', array( 'login_type<>? and running_time > ?', \IPS\Session\Front::LOGIN_TYPE_SPIDER, \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ), NULL, NULL, 'member_id', NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
|
||||
$count = $select->count(TRUE);
|
||||
$count = \IPS\Session\Store::i()->getOnlineUsers( \IPS\Session\Store::ONLINE_GUESTS | \IPS\Session\Store::ONLINE_MEMBERS | \IPS\Session\Store::ONLINE_COUNT_ONLY );
|
||||
if( $count > $mostOnline['count'] )
|
||||
{
|
||||
$mostOnline = array( 'count' => $count, 'time' => time() );
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => json_encode( $mostOnline ) ), array( 'conf_key=?', 'most_online' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
\IPS\Settings::i()->changeValues( array( 'most_online' => json_encode( $mostOnline ) ) );
|
||||
}
|
||||
$stats['most_online'] = $mostOnline;
|
||||
|
||||
|
||||
@@ -81,9 +81,12 @@ class _topContributors extends \IPS\Widget\PermissionCache
|
||||
$topContributorsThisWeek = array_slice( $topContributorsThisWeek, 0, $limit, TRUE );
|
||||
|
||||
/* Load their data */
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_members', \IPS\Db::i()->in( 'member_id', array_keys( $topContributorsThisWeek ) ) ) as $member )
|
||||
if( count( $topContributorsThisWeek ) )
|
||||
{
|
||||
\IPS\Member::constructFromData( $member );
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_members', \IPS\Db::i()->in( 'member_id', array_keys( $topContributorsThisWeek ) ) ) as $member )
|
||||
{
|
||||
\IPS\Member::constructFromData( $member );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
|
||||
@@ -56,27 +56,8 @@ class _whosOnline extends \IPS\Widget
|
||||
$guests = 0;
|
||||
$anonymous = 0;
|
||||
|
||||
$notInMyName = array();
|
||||
foreach( \IPS\Member\Group::groups() as $group )
|
||||
{
|
||||
if ( $group->g_hide_online_list )
|
||||
{
|
||||
$notInMyName[] = $group->g_id;
|
||||
}
|
||||
}
|
||||
|
||||
/* Query */
|
||||
$where = array(
|
||||
array( 'core_sessions.running_time>?', \IPS\DateTime::create()->sub( new \DateInterval( 'PT30M' ) )->getTimeStamp() ),
|
||||
array( "core_sessions.login_type!=?", \IPS\Session\Front::LOGIN_TYPE_SPIDER )
|
||||
);
|
||||
|
||||
if ( count( $notInMyName ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( 'core_sessions.member_group', $notInMyName, TRUE ) );
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( 'core_sessions.member_id,core_sessions.member_name,core_sessions.seo_name,core_sessions.member_group,core_sessions.login_type', 'core_sessions', $where, 'core_sessions.running_time DESC' ) as $row )
|
||||
$users = \IPS\Session\Store::i()->getOnlineUsers();
|
||||
foreach( $users as $row )
|
||||
{
|
||||
switch ( $row['login_type'] )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user