Version 4.7.0

This commit is contained in:
Neo committed 2025-12-19 16:00:35 -08:00
1 parent 517a5e1f70
commit 8ba7d43898
1933 files changed
+65613 -11332

No files matched your search

+6 -14
View File
@@ -49,7 +49,7 @@ class _cleanup extends \IPS\Task
/* Delete old validating members */
if ( \IPS\Settings::i()->validate_day_prune )
{
$select = \IPS\Db::i()->select( 'core_validating.member_id, core_members.member_posts', 'core_validating', array( 'core_validating.new_reg=1 AND core_validating.coppa_user<>1 AND core_validating.entry_date<? AND core_validating.lost_pass<>1 AND core_validating.user_verified=0 AND core_members.member_posts < 1 AND core_validating.do_not_delete=0', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . \IPS\Settings::i()->validate_day_prune . 'D' ) )->getTimestamp() ) )->join( 'core_members', 'core_members.member_id=core_validating.member_id' );
$select = \IPS\Db::i()->select( 'core_validating.member_id, core_members.member_posts', 'core_validating', array( 'core_validating.new_reg=1 AND core_validating.coppa_user<>1 AND core_validating.entry_date<? AND core_validating.lost_pass<>1 AND core_validating.user_verified=0 AND !(core_members.members_bitoptions2 & 16384 ) AND core_members.member_posts < 1 AND core_validating.do_not_delete=0', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . \IPS\Settings::i()->validate_day_prune . 'D' ) )->getTimestamp() ) )->join( 'core_members', 'core_members.member_id=core_validating.member_id' );
foreach ( $select as $row )
{
@@ -249,6 +249,8 @@ class _cleanup extends \IPS\Task
$member->warn_level -= $warning->points;
$member->save();
\IPS\Db::i()->update( 'core_members_warn_logs', array( 'wl_removed_on' => $warning->expire_date ), array( 'wl_id=?', $warning->id ) );
$warning->expire_date = 0;
$warning->save();
}
@@ -266,7 +268,6 @@ class _cleanup extends \IPS\Task
/* Reset expired "moderate content till.." timestamps */
\IPS\Db::i()->update( 'core_members', array( 'mod_posts' => 0 ), array( 'mod_posts != -1 and mod_posts <?', time() ) );
/* Set expired announcements inactive */
\IPS\Db::i()->update( 'core_announcements', array( 'announce_active' => 0 ), array( 'announce_active = 1 and announce_end > 0 and announce_end <?', time() ) );
@@ -300,20 +301,11 @@ class _cleanup extends \IPS\Task
/* Delete old core statistic caches */
\IPS\Db::i()->delete( 'core_item_statistics_cache', array( 'cache_added < ?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1D' ) )->getTimestamp() ) );
/* Delete alerts */
\IPS\Db::i()->delete( 'core_alerts', array( 'alert_end > 0 and alert_end < ?', time() ) );
/* Truncate the output caches table */
\IPS\Output\Cache::i()->deleteExpired( TRUE );
/* Turn on things for cloud 2 */
if ( \IPS\CIC2 AND \IPS\Cicloud\getForcedArchiving() )
{
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'archive' ) );
/* 12 years is the cutoff if archiving is forced, so if it's over 12 years, drop the value down */
if( \IPS\Settings::i()->archive_last_post_cloud > 12 )
{
\IPS\Settings::i()->changeValues( array( 'archive_last_post_cloud' => 12 ) );
}
}
return NULL;
}
@@ -0,0 +1,68 @@
<?php
/**
* @brief dailyStreamSubscriptions Task
* @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 2021
*/
namespace IPS\core\tasks;
/* 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;
}
/**
* dailyStreamSubscriptions Task
*/
class _dailyStreamSubscriptions extends \IPS\Task
{
/**
* Execute
*
* If ran successfully, should return anything worth logging. Only log something
* worth mentioning (don't log "task ran successfully"). Return NULL (actual NULL, not '' or 0) to not log (which will be most cases).
* If an error occurs which means the task could not finish running, throw an \IPS\Task\Exception - do not log an error as a normal log.
* Tasks should execute within the time of a normal HTTP request.
*
* @return mixed Message to log or NULL
* @throws \IPS\Task\Exception
*/
public function execute()
{
/* Disable task if no subscriptions */
$select = \IPS\Db::i()->select( '*', 'core_stream_subscriptions', array( 'frequency=?', 'daily' ));
if( !$select->count() )
{
$this->enabled = FALSE;
$this->save();
return NULL;
}
$this->runUntilTimeout( function()
{
return \IPS\core\Stream\Subscription::sendBatch( 'daily' );
});
return NULL;
}
/**
* Cleanup
*
* If your task takes longer than 15 minutes to run, this method
* will be called before execute(). Use it to clean up anything which
* may not have been done
*
* @return void
*/
public function cleanup()
{
}
}
+27 -18
View File
@@ -88,16 +88,11 @@ class _updatecheck extends \IPS\Task
try
{
$bulletins = \IPS\Http\Url::ips('bulletin')->request()->get()->decodeJson();
$knownBulletins = iterator_to_array( \IPS\Db::i()->select( 'id', 'core_ips_bulletins' ) );
foreach ( $bulletins as $id => $bulletin )
{
if ( \in_array( $id, $knownBulletins ) )
{
break;
}
\IPS\Db::i()->insert( 'core_ips_bulletins', array(
'id' => $id,
'title' => $bulletin['title'],
'body' => $bulletin['body'],
@@ -107,33 +102,47 @@ class _updatecheck extends \IPS\Task
'link' => $bulletin['link'],
'conditions' => $bulletin['conditions'],
'cached' => time(),
'minVersion' => $bulletin['minVersion'],
'maxVersion' => $bulletin['maxVersion']
) );
'min_version' => $bulletin['minVersion'],
'max_version' => $bulletin['maxVersion']
), TRUE );
/* Don't send the notification until after we insert the bulletin data */
try
{
if ( @eval( $bulletin['conditions'] ) )
if (
/* If the value is 0 for minVersion, there is no minimum version (a.k.a., display it). Same deal with maxVersion. */
( $bulletin['minVersion'] == 0 AND $bulletin['maxVersion'] == 0 )
/* If there's no minimum version, and the maximum Version is within range */
OR ( $bulletin['minVersion'] == 0 AND \IPS\Application::load('core')->long_version < $bulletin['maxVersion'] )
/* If there's no maximum version, and the minimum version is within range */
OR ( $bulletin['maxVersion'] == 0 AND \IPS\Application::load('core')->long_version > $bulletin['minVersion'] )
/* If both min and max versions are within range */
OR ( \IPS\Application::load('core')->long_version >= $bulletin['minVersion'] AND \IPS\Application::load('core')->long_version <= $bulletin['maxVersion'] )
)
{
\IPS\core\AdminNotification::send( 'core', 'Bulletin', $id, FALSE );
if ( @eval( $bulletin['conditions'] ) )
{
\IPS\core\AdminNotification::send( 'core', 'Bulletin', (string) $id, FALSE );
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'Bulletin', (string) $id );
}
}
else
{
\IPS\core\AdminNotification::remove( 'core', 'Bulletin', $id );
\IPS\core\AdminNotification::remove( 'core', 'Bulletin', (string) $id );
}
}
catch ( \Exception $e )
{
\IPS\Log::log( $e, 'bulletin' );
}
catch ( \Throwable $e )
catch ( \Throwable | \Exception $e )
{
\IPS\Log::log( $e, 'bulletin' );
}
}
}
catch( \RuntimeException $e ) { }
catch( \RuntimeException $e ){ }
$updateChecked = [];
$marketplaceUpdates = [];
+1 -1
View File
@@ -238,7 +238,7 @@ class _usagereporting extends \IPS\Task
$report['paymethods'] = array();
if ( \IPS\Application::appIsEnabled('nexus') )
{
$report['paymethods'] = array( 'authorizenet_aim' => 0, 'authorizenet_dpm' => 0, 'manual' => 0, 'paypal_standard' => 0, 'paypal_pro' => 0, 'stripe_card' => 0, 'stripe_native' => 0, 'stripe_alipay' => 0, 'stripe_amex' => 0, 'stripe_bancontact' => 0, 'stripe_giropay' => 0, 'stripe_ideal' => 0, 'stripe_sofort' => 0, 'test' => 0, 'twocheckout' => 0, 'other' => 0 );
$report['paymethods'] = array( 'authorizenet_aim' => 0, 'authorizenet_dpm' => 0, 'manual' => 0, 'paypal_standard' => 0, 'paypal_pro' => 0, 'stripe_card' => 0, 'stripe_native' => 0, 'stripe_alipay' => 0, 'stripe_bancontact' => 0, 'stripe_giropay' => 0, 'stripe_ideal' => 0, 'stripe_sofort' => 0, 'test' => 0, 'twocheckout' => 0, 'other' => 0 );
foreach ( \IPS\nexus\Gateway::roots() as $gateway )
{
$class = \strtolower( \substr( \get_class( $gateway ), 18 ) );
+37 -32
View File
@@ -41,7 +41,6 @@ class _viewupdates extends \IPS\Task
try
{
$database = \IPS\Db::i()->select( 'classname, id, count(*) AS count', 'core_view_updates', NULL, NULL, 20, array( 'classname', 'id' ), NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER );
$redis = array();
/* Database results first */
foreach( $database as $row )
@@ -69,44 +68,50 @@ class _viewupdates extends \IPS\Task
{
$redis = \IPS\Redis::i()->zRevRangeByScore( 'topic_views', '+inf', '-inf', array('withscores' => TRUE, 'limit' => array( 0, 20 ) ) );
foreach( $redis as $data => $count )
if( \is_array( $redis ) )
{
$hasCount = TRUE;
list( $class, $id ) = explode( '__', $data );
try
foreach ( $redis as $data => $count )
{
$this->update( $class, $id, \intval( $count ) );
$hasCount = TRUE;
list( $class, $id ) = explode( '__', $data );
try
{
$this->update( $class, $id, \intval( $count ) );
}
catch ( \OutOfRangeException $e ) {}
}
\IPS\Redis::i()->zRem( 'topic_views', ...array_keys( $redis ) );
}
}
catch( \Exception $e ) { }
/* Now try advert impressions */
try
{
$redis = \IPS\Redis::i()->zRevRangeByScore( 'advert_impressions', '+inf', '-inf', array('withscores' => TRUE, 'limit' => array( 0, 20 ) ) );
if( \is_array( $redis ) )
{
$updates = [];
foreach ( $redis as $id => $count )
{
$hasCount = TRUE;
$updates[ $count ][] = $id;
\IPS\Redis::i()->zRem( 'advert_impressions', $id );
}
foreach ( $updates as $incrementBy => $ids )
{
\IPS\Db::i()->update( 'core_advertisements', "ad_impressions=ad_impressions+" . $incrementBy, [ \IPS\Db::i()->in( 'ad_id', $ids ) ] );
}
catch( \OutOfRangeException $e ) { }
\IPS\Redis::i()->zRem( 'topic_views', $data );
}
}
catch( \Exception $e ) { }
}
/* Now try advert impressions */
try
{
$redis = \IPS\Redis::i()->zRevRangeByScore( 'advert_impressions', '+inf', '-inf', array('withscores' => TRUE, 'limit' => array( 0, 20 ) ) );
$updates = [];
foreach( $redis as $id => $count )
{
$hasCount = TRUE;
$updates[ $count ][] = $id;
\IPS\Redis::i()->zRem( 'advert_impressions', $id );
}
foreach( $updates as $incrementBy => $ids )
{
\IPS\Db::i()->update( 'core_advertisements', "ad_impressions=ad_impressions+" . $incrementBy, [ \IPS\Db::i()->in( 'ad_id', $ids ) ] );
}
}
catch( \Exception $e ) { }
/* Go for another go? */
if ( $hasCount === TRUE )
+13 -2
View File
@@ -43,7 +43,7 @@ class _webhooks extends \IPS\Task
/* Try and get a queue item */
try
{
$fire = \IPS\Db::i()->select( '*', 'core_api_webhook_fires', array( "status='pending'" ), '`time` ASC', 1 )->first();
$fire = \IPS\Db::i()->select( '*', 'core_api_webhook_fires', array( "status='pending'" ), '`time` ASC', 1, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
try
{
@@ -51,8 +51,19 @@ class _webhooks extends \IPS\Task
{
throw new \DomainException("Webhook Disabled");
}
\IPS\Output::i()->parseFileObjectUrls( $fire['data'] );
$fire['data'] = \IPS\Output::i()->replaceEmojiWithImages( $fire['data'] );
$response = \IPS\Http\Url::external( $webhooks[ $fire['webhook'] ]['url'] )->request()->login( $webhooks[ $fire['webhook'] ]['api_key'], '' )->post( $fire['data'] );
$response = \IPS\Http\Url::external( $webhooks[ $fire['webhook'] ]['url'] )
->request()
->setHeaders(
[
'User-Agent' => "InvisionCommunity/" . \IPS\Application::load('core')->long_version ,
'Webhook-Event' => $fire['event']
]
)
->login( $webhooks[ $fire['webhook'] ]['api_key'], '' )->post( $fire['data'] );
if ( \IPS\Settings::i()->webhook_logs_success )
{
@@ -0,0 +1,68 @@
<?php
/**
* @brief weeklyStreamSubscriptions Task
* @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 2021
*/
namespace IPS\core\tasks;
/* 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;
}
/**
* weeklyStreamSubscriptions Task
*/
class _weeklyStreamSubscriptions extends \IPS\Task
{
/**
* Execute
*
* If ran successfully, should return anything worth logging. Only log something
* worth mentioning (don't log "task ran successfully"). Return NULL (actual NULL, not '' or 0) to not log (which will be most cases).
* If an error occurs which means the task could not finish running, throw an \IPS\Task\Exception - do not log an error as a normal log.
* Tasks should execute within the time of a normal HTTP request.
*
* @return mixed Message to log or NULL
* @throws \IPS\Task\Exception
*/
public function execute()
{
/* Disable task if no subscriptions */
$select = \IPS\Db::i()->select( '*', 'core_stream_subscriptions', array( 'frequency=?', 'weekly' ));
if( !$select->count() )
{
$this->enabled = FALSE;
$this->save();
return NULL;
}
$this->runUntilTimeout( function()
{
return \IPS\core\Stream\Subscription::sendBatch( 'weekly' );
});
return NULL;
}
/**
* Cleanup
*
* If your task takes longer than 15 minutes to run, this method
* will be called before execute(). Use it to clean up anything which
* may not have been done
*
* @return void
*/
public function cleanup()
{
}
}