Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief Browse Files Controller
* @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
* @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
* @subpackage Downloads
* @since 08 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\front\downloads;
@@ -67,10 +66,40 @@ class _browse extends \IPS\Dispatcher\Controller
}
/* Get stuff */
$featured = iterator_to_array( \IPS\downloads\File::featured( 4, '_rand' ) );
$new = \IPS\downloads\File::getItemsWithPermission( array(), NULL, 14 );
$highestRated = \IPS\downloads\File::getItemsWithPermission( array( array( 'file_rating > ?', 0 ) ), 'file_rating DESC, file_reviews DESC', 14 );
$mostDownloaded = \IPS\downloads\File::getItemsWithPermission( array( array( 'file_downloads > ?', 0 ) ), 'file_downloads DESC', 14 );
$featured = (\IPS\Settings::i()->idm_show_featured) ? iterator_to_array(\IPS\downloads\File::featured(\IPS\Settings::i()->idm_featured_count, '_rand')) : array();
if ( \IPS\Settings::i()->idm_newest_categories )
{
$newestWhere = array( array( 'downloads_categories.copen=1 and ' . \IPS\Db::i()->in('file_cat', explode( ',', \IPS\Settings::i()->idm_newest_categories ) ) ) );
}
else
{
$newestWhere = array( array( 'downloads_categories.copen=1' ) );
}
$new = ( \IPS\Settings::i()->idm_show_newest) ? \IPS\downloads\File::getItemsWithPermission( $newestWhere, NULL, 14, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
if (\IPS\Settings::i()->idm_highest_rated_categories )
{
$highestWhere = array( array( 'downloads_categories.copen=1 and ' . \IPS\Db::i()->in('file_cat', explode( ',', \IPS\Settings::i()->idm_highest_rated_categories ) ) ) );
}
else
{
$highestWhere = array( array( 'downloads_categories.copen=1' ) );
}
$highestWhere[] = array( 'file_rating > ?', 0 );
$highestRated = ( \IPS\Settings::i()->idm_show_highest_rated ) ? \IPS\downloads\File::getItemsWithPermission( $highestWhere, 'file_rating DESC, file_reviews DESC', 14, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
if (\IPS\Settings::i()->idm_show_most_downloaded_categories )
{
$mostDownloadedWhere = array( array( 'downloads_categories.copen=1 and ' . \IPS\Db::i()->in('file_cat', explode( ',', \IPS\Settings::i()->idm_show_most_downloaded_categories ) ) ) );
}
else
{
$mostDownloadedWhere = array( array( 'downloads_categories.copen=1' ) );
}
$mostDownloadedWhere[] = array( 'downloads_categories.copen=1 and file_downloads > ?', 0 );
$mostDownloaded = ( \IPS\Settings::i()->idm_show_most_downloaded ) ? \IPS\downloads\File::getItemsWithPermission( $mostDownloadedWhere, 'file_downloads DESC', 14, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
/* Online User Location */
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=downloads', 'front', 'downloads' ), array(), 'loc_downloads_browsing' );
@@ -89,16 +118,34 @@ class _browse extends \IPS\Dispatcher\Controller
*/
protected function _category( $category )
{
\IPS\Output::i()->sidebar['contextual'] = '';
$_count = \IPS\downloads\File::getItemsWithPermission( array( array( \IPS\downloads\File::$databasePrefix . \IPS\downloads\File::$databaseColumnMap['container'] . '=?', $category->_id ) ), NULL, 1, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, FALSE, FALSE, FALSE, TRUE );
if( !$_count )
{
/* Set breadcrumb */
foreach ( $category->parents() as $parent )
if ( $club = $category->club() )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $category, 'sidebar' );
}
}
else
{
foreach ( $category->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
}
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
/* Show a 'no files' template if there's nothing to display */
$table = \IPS\Theme::i()->getTemplate( 'browse' )->noFiles( $category );
@@ -110,6 +157,17 @@ class _browse extends \IPS\Dispatcher\Controller
$table->classes = array( 'ipsDataList_large' );
$table->sortOptions = array_merge( $table->sortOptions, array( 'file_downloads' => 'file_downloads' ) );
if ( !$category->bitoptions['reviews_download'] )
{
unset( $table->sortOptions['num_reviews'] );
}
if ( !$category->bitoptions['comments'] )
{
unset( $table->sortOptions['last_comment'] );
unset( $table->sortOptions['num_comments'] );
}
if ( $table->sortBy === 'file_name' )
{
$table->sortDirection = 'asc';
@@ -133,7 +191,7 @@ class _browse extends \IPS\Dispatcher\Controller
\IPS\Output::i()->title = $category->_title;
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_downloads_categories' ) ] = array( 'type' => 'downloads_file', 'nodes' => $category->_id );
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'browse' )->indexSidebar( \IPS\downloads\Category::canOnAny('add'), $category );
\IPS\Output::i()->sidebar['contextual'] .= \IPS\Theme::i()->getTemplate( 'browse' )->indexSidebar( \IPS\downloads\Category::canOnAny('add'), $category );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->category( $category, (string) $table );
}
@@ -147,7 +205,7 @@ class _browse extends \IPS\Dispatcher\Controller
/* Online User Location */
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=browse&do=categories', 'front', 'downloads_categories' ), array(), 'loc_downloads_browsing_categories' );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('__app_downloads');
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('downloads_categories_pagetitle');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->categories();
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Submit File Controller
* @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
* @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
* @subpackage Downloads
* @since 08 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\front\downloads;
@@ -35,8 +34,6 @@ class _submit extends \IPS\Dispatcher\Controller
\IPS\downloads\File::canCreate( \IPS\Member::loggedIn(), NULL, TRUE );
\IPS\Output::i()->sidebar['enabled'] = FALSE;
parent::execute();
}
@@ -343,6 +340,24 @@ class _submit extends \IPS\Dispatcher\Controller
\IPS\File::get( $file['record_type'] === 'upload' ? 'downloads_Files' : 'downloads_Screenshots', $location )->delete();
}
catch ( \Exception $e ) { }
if( $file['record_thumb'] )
{
try
{
\IPS\File::get( 'downloads_Screenshots', $file['record_thumb'] )->delete();
}
catch ( \Exception $e ) { }
}
if( $file['record_no_watermark'] )
{
try
{
\IPS\File::get( 'downloads_Screenshots', $file['record_no_watermark'] )->delete();
}
catch ( \Exception $e ) { }
}
\IPS\Db::i()->delete( 'downloads_files_records', array( 'record_id=?', $file['record_id'] ) );
}
@@ -592,6 +607,29 @@ class _submit extends \IPS\Dispatcher\Controller
$wizard = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->modQueueMessage( \IPS\Member::loggedIn()->warnings( 5, NULL, 'mq' ), \IPS\Member::loggedIn()->mod_posts ) . $wizard;
}
\IPS\Output::i()->output = $wizard;
if ( isset( \IPS\Request::i()->category ) )
{
try
{
$category = \IPS\downloads\Category::loadAndCheckPerms( \IPS\Request::i()->category );
if ( $club = $category->club() )
{
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $category, 'sidebar' );
}
}
}
catch ( \OutOfRangeException $e ) { }
}
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'submit_a_file' ) );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief View File Controller
* @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
* @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
* @subpackage Downloads
* @since 10 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\front\downloads;
@@ -40,8 +39,7 @@ class _view extends \IPS\Content\Controller
{
$this->file = \IPS\downloads\File::load( \IPS\Request::i()->id );
/* Downloading does not check 'view' permission, as there is a separate download permission already.
@see https://invisionpower.com/4bugtrack/archived-reports/4092-cant-download-files-when-files-disallowed-to-view-by-any-group-r6975/ */
/* Downloading does not check 'view' permission, as there is a separate download permission already */
if ( !$this->file->canView( \IPS\Member::loggedIn() ) and \IPS\Request::i()->do != 'download' )
{
\IPS\Output::i()->error( $this->file->container()->message('npv') ?: 'node_error', '2D161/2', 403, '' );
@@ -119,7 +117,119 @@ class _view extends \IPS\Content\Controller
}
}
}
/* Add JSON-ld */
\IPS\Output::i()->jsonLd['download'] = array(
'@context' => "http://schema.org",
'@type' => "SoftwareApplication",
'url' => (string) $this->file->url(),
'name' => htmlspecialchars( $this->file->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'description' => strip_tags( $this->file->truncated() ),
'applicationCategory' => $this->file->container()->_title,
'downloadUrl' => (string) $this->file->url( 'download' ),
'dateCreated' => \IPS\DateTime::ts( $this->file->submitted )->format( \IPS\DateTime::ISO8601 ),
'fileSize' => \IPS\Output\Plugin\Filesize::humanReadableFilesize( $this->file->filesize() ),
'softwareVersion' => htmlspecialchars( $this->file->version, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->file->submitter )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $this->file->submitter )->url(),
'image' => \IPS\Member::load( $this->file->submitter )->get_photo()
),
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'userInteractionCount' => $this->file->views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/DownloadAction",
'userInteractionCount' => $this->file->downloads
)
)
);
if( $this->file->updated != $this->file->submitted )
{
\IPS\Output::i()->jsonLd['download']['dateModified'] = \IPS\DateTime::ts( $this->file->updated )->format( \IPS\DateTime::ISO8601 );
}
if( $this->file->container()->bitoptions['reviews'] )
{
\IPS\Output::i()->jsonLd['download']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $this->file->averageReviewRating(),
'reviewCount' => $this->file->reviews,
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of
);
}
if( $this->file->screenshots()->getInnerIterator()->count( true ) )
{
\IPS\Output::i()->jsonLd['download']['screenshot'] = array();
$thumbnails = iterator_to_array( $this->file->screenshots( 1 ) );
foreach( $this->file->screenshots() as $id => $screenshot )
{
\IPS\Output::i()->jsonLd['download']['screenshot'][] = array(
'@type' => 'ImageObject',
'url' => (string) $screenshot->url,
'thumbnail' => array(
'@type' => 'ImageObject',
'url' => (string) $thumbnails[ $id ]->url
)
);
}
}
if( $versionData['b_changelog'] )
{
\IPS\Output::i()->jsonLd['download']['releaseNotes'] = $versionData['b_changelog'];
}
if( $this->file->topic() )
{
\IPS\Output::i()->jsonLd['download']['sameAs'] = (string) $this->file->topic()->url();
}
if( $this->file->isPaid() )
{
\IPS\Output::i()->jsonLd['download']['potentialAction'] = array(
'@type' => 'BuyAction',
'target' => (string) $this->file->url( 'buy' ),
);
\IPS\Output::i()->jsonLd['download']['offers'] = array(
'@type' => 'Offer',
'url' => (string) $this->file->url( 'buy' ),
'price' => $this->file->price(),
'priceCurrency' => \IPS\nexus\Customer::loggedIn()->defaultCurrency(),
'availability' => "http://schema.org/InStock"
);
}
if( $this->file->container()->bitoptions['comments'] )
{
\IPS\Output::i()->jsonLd['download']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'userInteractionCount' => $this->file->mapped('num_comments')
);
\IPS\Output::i()->jsonLd['download']['commentCount'] = $this->file->mapped('num_comments');
}
if( $this->file->container()->bitoptions['reviews'] )
{
\IPS\Output::i()->jsonLd['download']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ReviewAction",
'userInteractionCount' => $this->file->mapped('num_reviews')
);
}
/* Display */
\IPS\Output::i()->sidebar['sticky'] = TRUE;
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->view( $this->file, $commentsAndReviews, $versionData, $previousVersions, $this->file->nextItem(), $this->file->prevItem(), $cfields );
@@ -355,7 +465,7 @@ class _view extends \IPS\Content\Controller
'dmid' => (int) \IPS\Member::loggedIn()->member_id,
'dsize' => $data['record_size'],
'dua' => \IPS\Session::i()->userAgent->useragent,
'dbrowsers' => \IPS\Session::i()->userAgent->useragentKey,
'dbrowsers' => \IPS\Session::i()->userAgent->browser,
'dos' => ''
) );
}
@@ -671,9 +781,15 @@ class _view extends \IPS\Content\Controller
$form->addHeader( 'upload_files' );
$form->add( new \IPS\Helpers\Form\Upload( 'files', iterator_to_array( $this->file->files( NULL, FALSE ) ), ( !\IPS\Member::loggedIn()->group['idm_linked_files'] and !\IPS\Member::loggedIn()->group['idm_import_files'] ), array( 'storageExtension' => 'downloads_Files', 'allowedFileTypes' => $category->types, 'maxFileSize' => $category->maxfile ? ( $category->maxfile / 1024 ) : NULL, 'multiple' => TRUE, 'retainDeleted' => TRUE ) ) );
$linkedFiles = iterator_to_array( \IPS\Db::i()->select( 'record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=0', $this->file->id, 'link' ) ) );
if ( \IPS\Member::loggedIn()->group['idm_linked_files'] )
{
$form->add( new \IPS\Helpers\Form\Stack( 'url_files', iterator_to_array( \IPS\Db::i()->select( 'record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=0', $this->file->id, 'link' ) ) ), FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'url_files', $linkedFiles, FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
}
else if ( count( $linkedFiles ) > 0 )
{
$form->addMessage( 'url_files_no_perm' );
}
if ( \IPS\Member::loggedIn()->group['idm_import_files'] )
@@ -851,6 +967,7 @@ class _view extends \IPS\Content\Controller
else
{
$noWatermark = NULL;
$watermarked = FALSE;
if ( \IPS\Settings::i()->idm_watermarkpath )
{
try
@@ -860,15 +977,31 @@ class _view extends \IPS\Content\Controller
$image = \IPS\Image::create( $file->contents() );
$image->watermark( $watermark );
$file = \IPS\File::create( 'downloads_Screenshots', $file->originalFilename, $image );
$watermarked = TRUE;
}
catch ( \Exception $e ) { }
}
/**
* We only need to generate a new thumbnail if we are using watermarking.
* If we are not, then we can simply use the previous thumbnail, if this existed previously, rather than generating a new one every time we upload a new version, which is unnecessary extra processing as well as disk usage.
* If we are, then it is impossible to know if the watermark has since changed, so we need to go ahead and do it anyway.
*/
$existing = NULL;
if ( $watermarked !== TRUE )
{
try
{
$existing = \IPS\Db::i()->select( '*', 'downloads_files_records', array( "record_location=? AND record_file_id=?", (string) $file, $this->file->id ) )->first();
}
catch( \UnderflowException $e ) {}
}
\IPS\Db::i()->insert( 'downloads_files_records', array(
'record_file_id' => $this->file->id,
'record_type' => 'ssupload',
'record_location' => (string) $file,
'record_thumb' => (string) $file->thumbnail( 'downloads_Screenshots' ),
'record_thumb' => ( $watermarked OR !$existing ) ? (string) $file->thumbnail( 'downloads_Screenshots' ) : $existing['record_thumb'],
'record_realname' => $file->originalFilename,
'record_size' => $file->filesize(),
'record_time' => time(),