Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -1,4 +1,5 @@
<?php
/**
* @brief Categories
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
@@ -12,35 +13,50 @@
namespace IPS\downloads\modules\admin\downloads;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Dispatcher;
use IPS\downloads\Category;
use IPS\Http\Url;
use IPS\Member;
use IPS\Node\Controller;
use IPS\Node\Model;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Task;
use OutOfRangeException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Categories
*/
class _categories extends \IPS\Node\Controller
class categories extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = 'IPS\downloads\Category';
protected string $nodeClass = 'IPS\downloads\Category';
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'categories_manage' );
Dispatcher::i()->checkAcpPermission( 'categories_manage' );
parent::execute();
}
@@ -49,23 +65,23 @@ class _categories extends \IPS\Node\Controller
*
* @return void
*/
protected function recountDownloads()
protected function recountDownloads() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'categories_recount_downloads' );
\IPS\Session::i()->csrfCheck();
Dispatcher::i()->checkAcpPermission( 'categories_recount_downloads' );
Session::i()->csrfCheck();
try
{
$category = \IPS\downloads\Category::load( \IPS\Request::i()->id );
$category = Category::load( Request::i()->id );
\IPS\Db::i()->update( 'downloads_files', array( 'file_downloads' => \IPS\Db::i()->select( 'COUNT(*)', 'downloads_downloads', array( 'dfid=file_id' ) ) ), array( 'file_cat=?', $category->id ) );
\IPS\Session::i()->log( 'acplogs__downloads_recount_downloads', array( $category->_title => FALSE ) );
Db::i()->update( 'downloads_files', array( 'file_downloads' => Db::i()->select( 'COUNT(*)', 'downloads_downloads', array( 'dfid=file_id' ) ) ), array( 'file_cat=?', $category->id ) );
Session::i()->log( 'acplogs__downloads_recount_downloads', array( $category->_title => FALSE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=downloads&module=downloads&controller=categories&do=form&id=" . \IPS\Request::i()->id ), 'clog_recount_done' );
Output::i()->redirect( Url::internal( "app=downloads&module=downloads&controller=categories&do=form&id=" . Request::i()->id ), 'clog_recount_done' );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2D180/1', 404, '' );
Output::i()->error( 'node_error', '2D180/1', 404, '' );
}
}
@@ -74,17 +90,17 @@ class _categories extends \IPS\Node\Controller
*
* @return void
*/
protected function form()
protected function form() : void
{
parent::form();
if ( \IPS\Request::i()->id )
if ( Request::i()->id )
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('edit_category') . ': ' . \IPS\Output::i()->title;
Output::i()->title = Member::loggedIn()->language()->addToStack('edit_category') . ': ' . Output::i()->title;
}
else
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('add_category');
Output::i()->title = Member::loggedIn()->language()->addToStack('add_category');
}
}
@@ -93,13 +109,15 @@ class _categories extends \IPS\Node\Controller
*
* @return void
*/
public function rebuildTopicContent()
public function rebuildTopicContent() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
$class = $this->nodeClass;
\IPS\Task::queue( 'core', 'ResyncTopicContent', array( 'class' => $class, 'categoryId' => \IPS\Request::i()->id ), 3, array( 'categoryId' ) );
\IPS\Session::i()->log( 'acplogs__downloads_resync_topics', array( $class::$titleLangPrefix . \IPS\Request::i()->id => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=categories&do=form&id=' . \IPS\Request::i()->id ), \IPS\Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'category_forums_integration' ) ) ) ) );
Task::queue( 'core', 'ResyncTopicContent', array( 'class' => $class, 'categoryId' => Request::i()->id ), 3, array( 'categoryId' ) );
/* @var Model $class */
Session::i()->log( 'acplogs__downloads_resync_topics', array( $class::$titleLangPrefix . Request::i()->id => TRUE ) );
Output::i()->redirect( Url::internal( 'app=downloads&module=downloads&controller=categories&do=form&id=' . Request::i()->id ), Member::loggedIn()->language()->addToStack('rebuilding_stuff', FALSE, array( 'sprintf' => array( Member::loggedIn()->language()->addToStack( 'category_forums_integration' ) ) ) ) );
}
}
@@ -12,35 +12,40 @@
namespace IPS\downloads\modules\admin\downloads;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Dispatcher;
use IPS\Node\Controller;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* fields
*/
class _fields extends \IPS\Node\Controller
class fields extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = 'IPS\downloads\Field';
protected string $nodeClass = 'IPS\downloads\Field';
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'fields_manage' );
Dispatcher::i()->checkAcpPermission( 'fields_manage' );
parent::execute();
}
}
@@ -12,113 +12,127 @@
namespace IPS\downloads\modules\admin\downloads;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Application;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\File;
use IPS\Helpers\Form;
use IPS\Helpers\Form\CheckboxSet;
use IPS\Helpers\Form\Node;
use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\Radio;
use IPS\Helpers\Form\Stack;
use IPS\Helpers\Form\Upload;
use IPS\Helpers\Form\YesNo;
use IPS\Http\Url;
use IPS\Member;
use IPS\nexus\Form\Money;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings as SettingsClass;
use IPS\Task;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Settings
*/
class _settings extends \IPS\Dispatcher\Controller
class settings extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Manage Settings
*
* @return void
*/
protected function manage()
protected function manage() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
Dispatcher::i()->checkAcpPermission( 'settings_manage' );
$form = $this->_getForm();
if ( $values = $form->values( TRUE ) )
if ( $values = $form->values(TRUE) )
{
$this->_saveSettingsForm( $form, $values, $redirectMessage );
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Session::i()->log( 'acplogs__downloads_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=settings' ), $redirectMessage );
Session::i()->log( 'acplogs__downloads_settings' );
Output::i()->redirect( Url::internal( 'app=downloads&module=downloads&controller=settings' ), $redirectMessage );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
\IPS\Output::i()->output = $form;
Output::i()->title = Member::loggedIn()->language()->addToStack('settings');
Output::i()->output = $form;
}
/**
* Build and return the settings form
*
* @note Abstracted to allow third party devs to extend easier
* @return \IPS\Helpers\Form
* @return Form
*/
protected function _getForm()
protected function _getForm(): Form
{
$form = new \IPS\Helpers\Form;
$form = new Form;
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_settings.js', 'downloads', 'admin' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_settings.js', 'downloads', 'admin' ) );
$form->attributes['data-controller'] = 'downloads.admin.settings.settings';
$form->hiddenValues['rebuildWatermarkScreenshots'] = \IPS\Request::i()->rebuildWatermarkScreenshots ?: 0;
$form->hiddenValues['rebuildWatermarkScreenshots'] = Request::i()->rebuildWatermarkScreenshots ?: 0;
$form->addTab( 'idm_landing_page' );
$form->addHeader( 'featured_downloads' );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_featured', \IPS\Settings::i()->idm_show_featured, FALSE, array( 'togglesOn' => array( 'idm_featured_count' ) ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'idm_featured_count', \IPS\Settings::i()->idm_featured_count, FALSE, array(), NULL, NULL, NULL, 'idm_featured_count' ) );
$form->add( new YesNo( 'idm_show_featured', SettingsClass::i()->idm_show_featured, FALSE, array( 'togglesOn' => array( 'idm_featured_count' ) ) ) );
$form->add( new Number( 'idm_featured_count', SettingsClass::i()->idm_featured_count, FALSE, array(), NULL, NULL, NULL, 'idm_featured_count' ) );
$form->addHeader('browse_whats_new');
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_newest', \IPS\Settings::i()->idm_show_newest, FALSE, array('togglesOn' => array( 'idm_newest_categories') ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_newest_categories', ( \IPS\Settings::i()->idm_newest_categories AND \IPS\Settings::i()->idm_newest_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_newest_categories ) : 0, FALSE, array(
$form->add( new YesNo( 'idm_show_newest', SettingsClass::i()->idm_show_newest, FALSE, array('togglesOn' => array( 'idm_newest_categories') ) ) );
$form->add( new Node( 'idm_newest_categories', ( SettingsClass::i()->idm_newest_categories AND SettingsClass::i()->idm_newest_categories != 0 ) ? explode( ',', SettingsClass::i()->idm_newest_categories ) : 0, FALSE, array(
'class' => 'IPS\downloads\Category',
'zeroVal' => 'any',
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_newest_categories') );
$form->addHeader('browse_highest_rated');
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_highest_rated', \IPS\Settings::i()->idm_show_highest_rated, FALSE, array( 'togglesOn' => array( 'idm_highest_rated_categories' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_highest_rated_categories', ( \IPS\Settings::i()->idm_highest_rated_categories AND \IPS\Settings::i()->idm_highest_rated_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_highest_rated_categories ) : 0, FALSE, array(
$form->add( new YesNo( 'idm_show_highest_rated', SettingsClass::i()->idm_show_highest_rated, FALSE, array( 'togglesOn' => array( 'idm_highest_rated_categories' ) ) ) );
$form->add( new Node( 'idm_highest_rated_categories', ( SettingsClass::i()->idm_highest_rated_categories AND SettingsClass::i()->idm_highest_rated_categories != 0 ) ? explode( ',', SettingsClass::i()->idm_highest_rated_categories ) : 0, FALSE, array(
'class' => 'IPS\downloads\Category',
'zeroVal' => 'any',
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_highest_rated_categories') );
$form->addHeader('browse_most_downloaded');
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_most_downloaded', \IPS\Settings::i()->idm_show_most_downloaded, FALSE, array( 'togglesOn' => array( 'idm_show_most_downloaded_categories' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_show_most_downloaded_categories', ( \IPS\Settings::i()->idm_show_most_downloaded_categories AND \IPS\Settings::i()->idm_show_most_downloaded_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_show_most_downloaded_categories ) : 0, FALSE, array(
$form->add( new YesNo( 'idm_show_most_downloaded', SettingsClass::i()->idm_show_most_downloaded, FALSE, array( 'togglesOn' => array( 'idm_show_most_downloaded_categories' ) ) ) );
$form->add( new Node( 'idm_show_most_downloaded_categories', ( SettingsClass::i()->idm_show_most_downloaded_categories AND SettingsClass::i()->idm_show_most_downloaded_categories != 0 ) ? explode( ',', SettingsClass::i()->idm_show_most_downloaded_categories ) : 0, FALSE, array(
'class' => 'IPS\downloads\Category',
'zeroVal' => 'any',
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_show_most_downloaded_categories') );
$form->addTab( 'basic_settings' );
$form->add( new \IPS\Helpers\Form\Upload( 'idm_watermarkpath', \IPS\Settings::i()->idm_watermarkpath ? \IPS\File::get( 'core_Theme', \IPS\Settings::i()->idm_watermarkpath ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'idm_link_blacklist', explode( ',', \IPS\Settings::i()->idm_link_blacklist ), FALSE, array( 'placeholder' => 'example.com' ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_antileech', \IPS\Settings::i()->idm_antileech ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_rss', \IPS\Settings::i()->idm_rss ) );
$form->add( new \IPS\Helpers\Form\Radio( 'idm_default_view', \IPS\Settings::i()->idm_default_view, FALSE, array(
'options' => array(
'table' => 'downloads_default_view_table',
'grid' => 'downloads_default_view_grid',
),
) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_default_view_choose', \IPS\Settings::i()->idm_default_view_choose ) );
$form->add( new Upload( 'idm_watermarkpath', SettingsClass::i()->idm_watermarkpath ? File::get( 'core_Theme', SettingsClass::i()->idm_watermarkpath ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ) ) );
$form->add( new Stack( 'idm_link_blacklist', explode( ',', SettingsClass::i()->idm_link_blacklist ), FALSE, array( 'placeholder' => 'example.com' ) ) );
$form->add( new YesNo( 'idm_antileech', SettingsClass::i()->idm_antileech ) );
$form->add( new YesNo( 'idm_rss', SettingsClass::i()->idm_rss ) );
if ( \IPS\Application::appIsEnabled( 'nexus' ) )
if ( Application::appIsEnabled( 'nexus' ) )
{
$form->addTab( 'paid_file_settings' );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_nexus_on', \IPS\Settings::i()->idm_nexus_on, FALSE, array( 'togglesOn' => array( 'idm_nexus_tax', 'idm_nexus_percent', 'idm_nexus_transfee', 'idm_nexus_mincost', 'idm_nexus_gateways', 'idm_nexus_display' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_nexus_tax', \IPS\Settings::i()->idm_nexus_tax ?:0, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'idm_nexus_tax' ) );
$form->add( new \IPS\Helpers\Form\Number( 'idm_nexus_percent', \IPS\Settings::i()->idm_nexus_percent, FALSE, array( 'min' => 0, 'max' => 100 ), NULL, NULL, '%', 'idm_nexus_percent' ) );
$form->add( new \IPS\nexus\Form\Money( 'idm_nexus_transfee', json_decode( \IPS\Settings::i()->idm_nexus_transfee, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_transfee' ) );
$form->add( new \IPS\nexus\Form\Money( 'idm_nexus_mincost', json_decode( \IPS\Settings::i()->idm_nexus_mincost, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_mincost' ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_nexus_gateways', ( \IPS\Settings::i()->idm_nexus_gateways ) ? explode( ',', \IPS\Settings::i()->idm_nexus_gateways ) : 0, FALSE, array( 'class' => '\IPS\nexus\Gateway', 'zeroVal' => 'no_restriction', 'multiple' => TRUE ), NULL, NULL, NULL, 'idm_nexus_gateways' ) );
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'idm_nexus_display', explode( ',', \IPS\Settings::i()->idm_nexus_display ), FALSE, array( 'options' => array( 'purchases' => 'idm_purchases', 'downloads' => 'downloads' ) ), NULL, NULL, NULL, 'idm_nexus_display' ) );
$form->add( new YesNo( 'idm_nexus_on', SettingsClass::i()->idm_nexus_on, FALSE, array( 'togglesOn' => array( 'idm_nexus_tax', 'idm_nexus_percent', 'idm_nexus_transfee', 'idm_nexus_mincost', 'idm_nexus_gateways', 'idm_nexus_display' ) ) ) );
$form->add( new Node( 'idm_nexus_tax', SettingsClass::i()->idm_nexus_tax ?:0, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'idm_nexus_tax' ) );
$form->add( new Number( 'idm_nexus_percent', SettingsClass::i()->idm_nexus_percent, FALSE, array( 'min' => 0, 'max' => 100 ), NULL, NULL, '%', 'idm_nexus_percent' ) );
$form->add( new Money( 'idm_nexus_transfee', json_decode( SettingsClass::i()->idm_nexus_transfee, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_transfee' ) );
$form->add( new Money( 'idm_nexus_mincost', json_decode( SettingsClass::i()->idm_nexus_mincost, TRUE ), FALSE, array(), NULL, NULL, NULL, 'idm_nexus_mincost' ) );
$form->add( new Node( 'idm_nexus_gateways', ( SettingsClass::i()->idm_nexus_gateways ) ? explode( ',', SettingsClass::i()->idm_nexus_gateways ) : 0, FALSE, array( 'class' => '\IPS\nexus\Gateway', 'zeroVal' => 'no_restriction', 'multiple' => TRUE ), NULL, NULL, NULL, 'idm_nexus_gateways' ) );
$form->add( new CheckboxSet( 'idm_nexus_display', explode( ',', SettingsClass::i()->idm_nexus_display ), FALSE, array( 'options' => array( 'purchases' => 'idm_purchases', 'downloads' => 'downloads' ) ), NULL, NULL, NULL, 'idm_nexus_display' ) );
}
return $form;
@@ -127,14 +141,15 @@ class _settings extends \IPS\Dispatcher\Controller
/**
* Save the settings form
*
* @param \IPS\Helpers\Form $form The Form Object
* @param array $values Values
* @param string $redirectMessage Message to show on redirect
* @param Form $form The Form Object
* @param array $values Values
* @param string|null $redirectMessage
* @return void
*/
protected function _saveSettingsForm( \IPS\Helpers\Form $form, array $values, ?string &$redirectMessage )
protected function _saveSettingsForm( Form $form, array $values, ?string &$redirectMessage ) : void
{
/* We can't store '' for idm_nexus_display as it will fall back to the default */
if ( \IPS\Application::appIsEnabled( 'nexus' ) and !$values['idm_nexus_display'] )
if ( Application::appIsEnabled( 'nexus' ) and !$values['idm_nexus_display'] )
{
$values['idm_nexus_display'] = 'none';
}
@@ -148,9 +163,9 @@ class _settings extends \IPS\Dispatcher\Controller
/* Save the form first, then queue the rebuild */
if( $rebuildScreenshots )
{
\IPS\Db::i()->delete( 'core_queue', array( '`app`=? OR `key`=?', 'downloads', 'RebuildScreenshotWatermarks' ) );
Db::i()->delete( 'core_queue', array( '`app`=? OR `key`=?', 'downloads', 'RebuildScreenshotWatermarks' ) );
\IPS\Task::queue( 'downloads', 'RebuildScreenshotWatermarks', array( ), 5 );
Task::queue( 'downloads', 'RebuildScreenshotWatermarks', array( ), 5 );
$redirectMessage = 'download_settings_saved_rebuilding';
}
else
@@ -12,26 +12,43 @@
namespace IPS\downloads\modules\admin\stats;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\Helpers\Form;
use IPS\Helpers\Form\DateRange;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Theme;
use UnderflowException;
use function count;
use function defined;
use function intval;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Top Downloaders
*/
class _downloaders extends \IPS\Dispatcher\Controller
class downloaders extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* @brief Allow MySQL RW separation for efficiency
*/
public static $allowRWSeparation = TRUE;
public static bool $allowRWSeparation = TRUE;
/**
* @brief Number of results per page
@@ -43,9 +60,9 @@ class _downloaders extends \IPS\Dispatcher\Controller
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'downloaders_manage' );
Dispatcher::i()->checkAcpPermission( 'downloaders_manage' );
parent::execute();
}
@@ -54,32 +71,32 @@ class _downloaders extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$where = array( array( 'dmid>0' ) );
if ( isset( \IPS\Request::i()->form ) )
if ( isset( Request::i()->form ) )
{
$form = new \IPS\Helpers\Form( 'form', 'go' );
$form = new Form( 'form', 'go' );
$default = array(
'start' => \IPS\Request::i()->start ? \IPS\DateTime::ts( \IPS\Request::i()->start ) : NULL,
'end' => \IPS\Request::i()->end ? \IPS\DateTime::ts( \IPS\Request::i()->end ) : NULL
'start' => Request::i()->start ? DateTime::ts( Request::i()->start ) : NULL,
'end' => Request::i()->end ? DateTime::ts( Request::i()->end ) : NULL
);
$form->add( new \IPS\Helpers\Form\DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
$form->add( new DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
if ( !$values = $form->values() )
{
\IPS\Output::i()->output = $form;
Output::i()->output = $form;
return;
}
}
/* Figure out start and end parameters for links */
$params = array(
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : \IPS\Request::i()->start,
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : \IPS\Request::i()->end
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : Request::i()->start,
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : Request::i()->end
);
if( $params['start'] )
@@ -92,7 +109,7 @@ class _downloaders extends \IPS\Dispatcher\Controller
$where[] = array( 'dtime<?', $params['end'] );
}
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
if( $page < 1 )
{
@@ -101,26 +118,26 @@ class _downloaders extends \IPS\Dispatcher\Controller
try
{
$total = \IPS\Db::i()->select( 'COUNT(DISTINCT(dmid))', 'downloads_downloads', $where )->first();
$total = Db::i()->select( 'COUNT(DISTINCT(dmid))', 'downloads_downloads', $where )->first();
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
$total = 0;
}
/* Add the date range button */
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->sidebar['actions'] = array(
'settings' => array(
'title' => 'stats_date_range',
'icon' => 'calendar',
'link' => \IPS\Http\Url::internal( 'app=downloads&module=stats&controller=downloaders&form=1' )->setQueryString( $params ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('stats_date_range') )
'link' => Url::internal( 'app=downloads&module=stats&controller=downloaders&form=1' )->setQueryString( $params ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('stats_date_range') )
)
);
if( $total > 0 )
{
$select = \IPS\Db::i()->select( 'dmid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dmid' );
$select = Db::i()->select( 'dmid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dmid' );
$mids = array();
foreach( $select as $row )
@@ -130,26 +147,26 @@ class _downloaders extends \IPS\Dispatcher\Controller
$members = array();
if ( \count( $mids ) )
if ( count( $mids ) )
{
$members = iterator_to_array( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
$members = iterator_to_array( Db::i()->select( '*', 'core_members', array( Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
}
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
\IPS\Http\Url::internal( 'app=downloads&module=stats&controller=downloaders' )->setQueryString( $params ),
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
Url::internal( 'app=downloads&module=stats&controller=downloaders' )->setQueryString( $params ),
ceil( $total / static::PER_PAGE ),
$page,
static::PER_PAGE,
FALSE
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats')->downloadsTable( $select, $pagination, $members, $total );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders');
Output::i()->output = Theme::i()->getTemplate('stats')->downloadsTable( $select, $pagination, $members, $total );
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders');
}
else
{
/* Return the no results message */
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders'), \IPS\Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'ipsPad', NULL, TRUE );
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->block( Member::loggedIn()->language()->addToStack('menu__downloads_stats_downloaders'), Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'i-padding_3', NULL, TRUE );
}
}
}
@@ -12,35 +12,44 @@
namespace IPS\downloads\modules\admin\stats;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\core\Statistics\Chart;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* downloads
*/
class _downloads extends \IPS\Dispatcher\Controller
class downloads extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* @brief Allow MySQL RW separation for efficiency
*/
public static $allowRWSeparation = TRUE;
public static bool $allowRWSeparation = TRUE;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'downloads_manage' );
Dispatcher::i()->checkAcpPermission( 'downloads_manage' );
parent::execute();
}
@@ -49,11 +58,10 @@ class _downloads extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$chart = \IPS\core\Statistics\Chart::loadFromExtension( 'downloads', 'Downloads' )->getChart( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=downloads" ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('downloads_stats');
\IPS\Output::i()->output = (string) $chart;
Output::i()->title = Member::loggedIn()->language()->addToStack('downloads_stats');
Output::i()->output = (string) $chart = Chart::loadFromExtension( 'downloads', 'Downloads' )->getChart( Url::internal( "app=downloads&module=stats&controller=downloads" ) );
}
}
@@ -12,9 +12,16 @@
namespace IPS\downloads\modules\admin\stats;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Dispatcher\Controller;
use IPS\Http\Url;
use IPS\Output;
use IPS\Request;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
@@ -23,20 +30,20 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*
* @deprecated
*/
class _member extends \IPS\Dispatcher\Controller
class member extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("app=core&module=members&controller=members&do=view&id=" . \IPS\Request::i()->id . "&blockKey=core_ContentStatistics&block[core_ContentStatistics]=downloads_Downloads") );
Output::i()->redirect( Url::internal("app=core&module=members&controller=members&do=view&id=" . Request::i()->id . "&blockKey=core_ContentStatistics&block[core_ContentStatistics]=downloads_Downloads") );
}
}
@@ -12,26 +12,43 @@
namespace IPS\downloads\modules\admin\stats;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\Helpers\Form;
use IPS\Helpers\Form\DateRange;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Theme;
use UnderflowException;
use function count;
use function defined;
use function intval;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Top Submitters
*/
class _submitters extends \IPS\Dispatcher\Controller
class submitters extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* @brief Allow MySQL RW separation for efficiency
*/
public static $allowRWSeparation = TRUE;
public static bool $allowRWSeparation = TRUE;
/**
* @brief Number of results per page
@@ -43,9 +60,9 @@ class _submitters extends \IPS\Dispatcher\Controller
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'submitters_manage' );
Dispatcher::i()->checkAcpPermission( 'submitters_manage' );
parent::execute();
}
@@ -54,32 +71,32 @@ class _submitters extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$where = array();
if ( isset( \IPS\Request::i()->form ) )
if ( isset( Request::i()->form ) )
{
$form = new \IPS\Helpers\Form( 'form', 'go' );
$form = new Form( 'form', 'go' );
$default = array(
'start' => \IPS\Request::i()->start ? \IPS\DateTime::ts( \IPS\Request::i()->start ) : NULL,
'end' => \IPS\Request::i()->end ? \IPS\DateTime::ts( \IPS\Request::i()->end ) : NULL
'start' => Request::i()->start ? DateTime::ts( Request::i()->start ) : NULL,
'end' => Request::i()->end ? DateTime::ts( Request::i()->end ) : NULL
);
$form->add( new \IPS\Helpers\Form\DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
$form->add( new DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
if ( !$values = $form->values() )
{
\IPS\Output::i()->output = $form;
Output::i()->output = $form;
return;
}
}
/* Figure out start and end parameters for links */
$params = array(
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : \IPS\Request::i()->start,
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : \IPS\Request::i()->end
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : Request::i()->start,
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : Request::i()->end
);
if( $params['start'] )
@@ -92,7 +109,7 @@ class _submitters extends \IPS\Dispatcher\Controller
$where[] = array( 'file_submitted<?', $params['end'] );
}
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
if( $page < 1 )
{
@@ -101,26 +118,26 @@ class _submitters extends \IPS\Dispatcher\Controller
try
{
$total = \IPS\Db::i()->select( 'COUNT(DISTINCT(file_submitter))', 'downloads_files', $where )->first();
$total = Db::i()->select( 'COUNT(DISTINCT(file_submitter))', 'downloads_files', $where )->first();
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
$total = 0;
}
/* Add the date range button */
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->sidebar['actions'] = array(
'settings' => array(
'title' => 'stats_date_range',
'icon' => 'calendar',
'link' => \IPS\Http\Url::internal( 'app=downloads&module=stats&controller=submitters&form=1' )->setQueryString( $params ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('stats_date_range') )
'link' => Url::internal( 'app=downloads&module=stats&controller=submitters&form=1' )->setQueryString( $params ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('stats_date_range') )
)
);
if( $total > 0 )
{
$select = \IPS\Db::i()->select( 'file_submitter, count(*) as files', 'downloads_files', $where, 'files DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'file_submitter' )->join( 'core_members', 'core_members.member_id=downloads_files.file_submitter' );
$select = Db::i()->select( 'file_submitter, count(*) as files', 'downloads_files', $where, 'files DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'file_submitter' )->join( 'core_members', 'core_members.member_id=downloads_files.file_submitter' );
$mids = array();
foreach( $select as $row )
@@ -130,27 +147,27 @@ class _submitters extends \IPS\Dispatcher\Controller
$members = array();
if ( \count( $mids ) )
if ( count( $mids ) )
{
$members = iterator_to_array( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
$members = iterator_to_array( Db::i()->select( '*', 'core_members', array( Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
}
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
\IPS\Http\Url::internal( 'app=downloads&module=stats&controller=submitters' )->setQueryString( $params ),
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
Url::internal( 'app=downloads&module=stats&controller=submitters' )->setQueryString( $params ),
ceil( $total / static::PER_PAGE ),
$page,
static::PER_PAGE,
FALSE
);
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate('stats')->submittersTable( $select, $pagination, $members, $total );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters');
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
Output::i()->output .= Theme::i()->getTemplate('stats')->submittersTable( $select, $pagination, $members, $total );
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters');
}
else
{
/* Return the no results message */
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters'), \IPS\Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'ipsPad', NULL, TRUE );
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->block( Member::loggedIn()->language()->addToStack('menu__downloads_stats_submitters'), Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'i-padding_3', NULL, TRUE );
}
}
}
@@ -12,26 +12,44 @@
namespace IPS\downloads\modules\admin\stats;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Dispatcher\Controller;
use IPS\downloads\File;
use IPS\Helpers\Form;
use IPS\Helpers\Form\DateRange;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Theme;
use UnderflowException;
use function count;
use function defined;
use function intval;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* topdownloads
*/
class _topdownloads extends \IPS\Dispatcher\Controller
class topdownloads extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* @brief Allow MySQL RW separation for efficiency
*/
public static $allowRWSeparation = TRUE;
public static bool $allowRWSeparation = TRUE;
/**
* @brief Number of results per page
@@ -43,9 +61,9 @@ class _topdownloads extends \IPS\Dispatcher\Controller
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'topdownloads_manage' );
Dispatcher::i()->checkAcpPermission( 'topdownloads_manage' );
parent::execute();
}
@@ -54,32 +72,32 @@ class _topdownloads extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$where = array();
if ( isset( \IPS\Request::i()->form ) )
if ( isset( Request::i()->form ) )
{
$form = new \IPS\Helpers\Form( 'form', 'go' );
$form = new Form( 'form', 'go' );
$default = array(
'start' => \IPS\Request::i()->start ? \IPS\DateTime::ts( \IPS\Request::i()->start ) : NULL,
'end' => \IPS\Request::i()->end ? \IPS\DateTime::ts( \IPS\Request::i()->end ) : NULL
'start' => Request::i()->start ? DateTime::ts( Request::i()->start ) : NULL,
'end' => Request::i()->end ? DateTime::ts( Request::i()->end ) : NULL
);
$form->add( new \IPS\Helpers\Form\DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
$form->add( new DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
if ( !$values = $form->values() )
{
\IPS\Output::i()->output = $form;
Output::i()->output = $form;
return;
}
}
/* Figure out start and end parameters for links */
$params = array(
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : \IPS\Request::i()->start,
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : \IPS\Request::i()->end
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : Request::i()->start,
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : Request::i()->end
);
if ( $params['start'] )
@@ -92,7 +110,7 @@ class _topdownloads extends \IPS\Dispatcher\Controller
$where[] = array( 'dtime<?', $params['end'] );
}
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
if ( $page < 1 )
{
@@ -101,57 +119,57 @@ class _topdownloads extends \IPS\Dispatcher\Controller
try
{
$total = \IPS\Db::i()->select( 'COUNT(DISTINCT(dfid))', 'downloads_downloads', $where )->first();
$total = Db::i()->select( 'COUNT(DISTINCT(dfid))', 'downloads_downloads', $where )->first();
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
$total = 0;
}
/* Add date range selector */
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->sidebar['actions'] = array(
'settings' => array(
'title' => 'stats_date_range',
'icon' => 'calendar',
'link' => \IPS\Http\Url::internal( 'app=downloads&module=stats&controller=topdownloads&form=1' )->setQueryString( $params ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack( 'stats_date_range' ) )
'link' => Url::internal( 'app=downloads&module=stats&controller=topdownloads&form=1' )->setQueryString( $params ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack( 'stats_date_range' ) )
)
);
if ( $total > 0 )
{
$select = iterator_to_array( \IPS\Db::i()->select( 'dfid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dfid' )->join( 'downloads_files', 'downloads_files.file_id=downloads_downloads.dfid' ) );
$files = iterator_to_array( \IPS\Db::i()->select( '*', 'downloads_files', \IPS\Db::i()->in( 'file_id', array_column( $select, 'dfid' ) ) )->setKeyField( 'file_id' ) );
$select = iterator_to_array( Db::i()->select( 'dfid, count(*) as downloads', 'downloads_downloads', $where, 'downloads DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'dfid' )->join( 'downloads_files', 'downloads_files.file_id=downloads_downloads.dfid' ) );
$files = iterator_to_array( Db::i()->select( '*', 'downloads_files', Db::i()->in( 'file_id', array_column( $select, 'dfid' ) ) )->setKeyField( 'file_id' ) );
$downloads = array();
if ( \count( $select ) )
if ( count( $select ) )
{
foreach ( $select as $row )
{
$file = \IPS\downloads\File::constructFromData( $files[ $row['dfid'] ] );
$file = File::constructFromData( $files[ $row['dfid'] ] );
$downloads[] = array(
'dfid' => $row['dfid'],
'downloads' => $row['downloads'],
'file' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $file->url(), TRUE, $file->name )
'file' => Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $file->url(), TRUE, $file->name )
);
}
}
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
\IPS\Http\Url::internal( 'app=downloads&module=stats&controller=topdownloads' )->setQueryString( $params ),
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
Url::internal( 'app=downloads&module=stats&controller=topdownloads' )->setQueryString( $params ),
ceil( $total / static::PER_PAGE ),
$page,
static::PER_PAGE,
FALSE
);
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'stats' )->topDownloadsTable( $downloads, $pagination );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' );
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
Output::i()->output .= Theme::i()->getTemplate( 'stats' )->topDownloadsTable( $downloads, $pagination );
Output::i()->title = Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' );
}
else
{
/* Return the no results message */
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' ), \IPS\Member::loggedIn()->language()->addToStack( 'no_results' ), FALSE, 'ipsPad', NULL, TRUE );
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->block( Member::loggedIn()->language()->addToStack( 'menu__downloads_stats_topdownloads' ), Member::loggedIn()->language()->addToStack( 'no_results' ), FALSE, 'i-padding_3', NULL, TRUE );
}
}
}
@@ -12,16 +12,39 @@
namespace IPS\downloads\modules\front\downloads;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DateInterval;
use IPS\Application;
use IPS\Content\Filter;
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher\Controller;
use IPS\downloads\Category;
use IPS\downloads\File;
use IPS\Helpers\Table\Content;
use IPS\Http\Url;
use IPS\Member;
use IPS\nexus\Money;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Session\Front;
use IPS\Settings;
use IPS\Theme;
use OutOfRangeException;
use function defined;
use function in_array;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Browse Files
*/
class _browse extends \IPS\Dispatcher\Controller
class browse extends Controller
{
/**
@@ -29,21 +52,21 @@ class _browse extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function markRead()
protected function markRead() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
try
{
$category = \IPS\downloads\Category::load( \IPS\Request::i()->id );
$category = Category::load( Request::i()->id );
\IPS\downloads\File::markContainerRead( $category, NULL, FALSE );
File::markContainerRead( $category, NULL, FALSE );
\IPS\Output::i()->redirect( $category->url() );
Output::i()->redirect( $category->url() );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
\IPS\Output::i()->error( 'no_module_permission', '2D175/3', 403, 'no_module_permission_guest' );
Output::i()->error( 'no_module_permission', '2D175/3', 403, 'no_module_permission_guest' );
}
}
@@ -52,32 +75,32 @@ class _browse extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
if ( isset( \IPS\Request::i()->currency ) and \in_array( \IPS\Request::i()->currency, \IPS\nexus\Money::currencies() ) and isset( \IPS\Request::i()->csrfKey ) and \IPS\Request::i()->csrfKey === \IPS\Session\Front::i()->csrfKey )
if ( isset( Request::i()->currency ) and in_array( Request::i()->currency, Money::currencies() ) and isset( Request::i()->csrfKey ) and Request::i()->csrfKey === Front::i()->csrfKey )
{
\IPS\Request::i()->setCookie( 'currency', \IPS\Request::i()->currency );
Request::i()->setCookie( 'currency', Request::i()->currency );
}
if ( isset( \IPS\Request::i()->id ) )
if ( isset( Request::i()->id ) )
{
if ( \IPS\Request::i()->id == 'clubs' and \IPS\Settings::i()->club_nodes_in_apps )
if ( Request::i()->id == 'clubs' and Settings::i()->club_nodes_in_apps )
{
\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()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=browse&do=categories', 'front', 'downloads_categories' ), \IPS\Member::loggedIn()->language()->addToStack('download_categories') );
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=browse&id=clubs', 'front', 'downloads_clubs' ), \IPS\Member::loggedIn()->language()->addToStack('club_node_downloads') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('club_node_downloads');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->categories( TRUE );
Session::i()->setLocation( Url::internal( 'app=downloads&module=downloads&controller=browse&do=categories', 'front', 'downloads_categories' ), array(), 'loc_downloads_browsing_categories' );
Output::i()->breadcrumb[] = array( Url::internal( 'app=downloads&module=downloads&controller=browse&do=categories', 'front', 'downloads_categories' ), Member::loggedIn()->language()->addToStack('download_categories') );
Output::i()->breadcrumb[] = array( Url::internal( 'app=downloads&module=downloads&controller=browse&id=clubs', 'front', 'downloads_clubs' ), Member::loggedIn()->language()->addToStack('club_node_downloads') );
Output::i()->title = Member::loggedIn()->language()->addToStack('club_node_downloads');
Output::i()->output = Theme::i()->getTemplate( 'browse' )->categories( TRUE );
}
else
{
try
{
$this->_category( \IPS\downloads\Category::loadAndCheckPerms( \IPS\Request::i()->id, 'read' ) );
$this->_category( Category::loadAndCheckPerms( Request::i()->id, 'read' ) );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2D175/1', 404, '' );
Output::i()->error( 'node_error', '2D175/1', 404, '' );
}
}
}
@@ -92,91 +115,91 @@ class _browse extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function _index()
protected function _index() : void
{
/* Add RSS feed */
if ( \IPS\Settings::i()->idm_rss )
if ( Settings::i()->idm_rss )
{
\IPS\Output::i()->rssFeeds['idm_rss_title'] = \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=browse&do=rss', 'front', 'downloads_rss' );
Output::i()->rssFeeds['idm_rss_title'] = Url::internal( 'app=downloads&module=downloads&controller=browse&do=rss', 'front', 'downloads_rss' );
if ( \IPS\Member::loggedIn()->member_id )
if ( Member::loggedIn()->member_id )
{
$key = \IPS\Member::loggedIn()->getUniqueMemberHash();
$key = Member::loggedIn()->getUniqueMemberHash();
\IPS\Output::i()->rssFeeds['idm_rss_title'] = \IPS\Output::i()->rssFeeds['idm_rss_title']->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
Output::i()->rssFeeds['idm_rss_title'] = Output::i()->rssFeeds['idm_rss_title']->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
}
}
/* Get stuff */
$featured = \IPS\Settings::i()->idm_show_featured ? iterator_to_array( \IPS\downloads\File::featured( \IPS\Settings::i()->idm_featured_count, '_rand' ) ) : array();
$featured = Settings::i()->idm_show_featured ? iterator_to_array( File::featured( Settings::i()->idm_featured_count, '_rand' ) ) : array();
if ( \IPS\Settings::i()->idm_newest_categories )
if ( 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 ) ) ) );
$newestWhere = array( array( 'downloads_categories.copen=1 and ' . Db::i()->in('file_cat', explode( ',', Settings::i()->idm_newest_categories ) ) ) );
}
else
{
$newestWhere = array( array( 'downloads_categories.copen=1' ) );
}
if ( !\IPS\Settings::i()->club_nodes_in_apps )
if ( !Settings::i()->club_nodes_in_apps )
{
$newestWhere[] = array( 'downloads_categories.cclub_id IS NULL' );
}
$new = ( \IPS\Settings::i()->idm_show_newest) ? \IPS\downloads\File::getItemsWithPermission( $newestWhere, NULL, 14, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
$new = ( Settings::i()->idm_show_newest) ? File::getItemsWithPermission( $newestWhere, NULL, 14, 'read', Filter::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
if ( \IPS\Settings::i()->idm_highest_rated_categories )
if ( 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 ) ) ) );
$highestWhere = array( array( 'downloads_categories.copen=1 and ' . Db::i()->in('file_cat', explode( ',', Settings::i()->idm_highest_rated_categories ) ) ) );
}
else
{
$highestWhere = array( array( 'downloads_categories.copen=1' ) );
}
$highestWhere[] = array( 'file_rating > ?', 0 );
if ( !\IPS\Settings::i()->club_nodes_in_apps )
if ( !Settings::i()->club_nodes_in_apps )
{
$highestWhere[] = array( 'downloads_categories.cclub_id IS NULL' );
}
$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();
$highestRated = ( Settings::i()->idm_show_highest_rated ) ? File::getItemsWithPermission( $highestWhere, 'file_rating DESC, file_reviews DESC', 14, 'read', Filter::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
if (\IPS\Settings::i()->idm_show_most_downloaded_categories )
if (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 ) ) ) );
$mostDownloadedWhere = array( array( 'downloads_categories.copen=1 and ' . Db::i()->in('file_cat', explode( ',', 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 );
if ( !\IPS\Settings::i()->club_nodes_in_apps )
if ( !Settings::i()->club_nodes_in_apps )
{
$mostDownloadedWhere[] = array( 'downloads_categories.cclub_id IS NULL' );
}
$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();
$mostDownloaded = ( Settings::i()->idm_show_most_downloaded ) ? File::getItemsWithPermission( $mostDownloadedWhere, 'file_downloads DESC', 14, 'read', Filter::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' );
Session::i()->setLocation( Url::internal( 'app=downloads', 'front', 'downloads' ), array(), 'loc_downloads_browsing' );
/* Display */
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'browse' )->indexSidebar( \IPS\downloads\Category::canOnAny('add') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('downloads');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $featured, $new, $highestRated, $mostDownloaded );
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'browse' )->indexSidebar( Category::canOnAny('add') );
Output::i()->title = Member::loggedIn()->language()->addToStack('downloads');
Output::i()->output = Theme::i()->getTemplate( 'browse' )->index( $featured, $new, $highestRated, $mostDownloaded );
}
/**
* Show Category
*
* @param \IPS\downloads\Category $category The category to show
* @param Category $category The category to show
* @return void
*/
protected function _category( $category )
protected function _category( Category $category ) : void
{
$category->clubCheckRules();
\IPS\Output::i()->sidebar['contextual'] = '';
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 );
$_count = File::getItemsWithPermission( array( array( File::$databasePrefix . File::$databaseColumnMap['container'] . '=?', $category->_id ) ), NULL, 1, 'read', Filter::FILTER_AUTOMATIC, 0, NULL, FALSE, FALSE, FALSE, TRUE );
if( !$_count )
{
@@ -189,19 +212,24 @@ class _browse extends \IPS\Dispatcher\Controller
{
foreach ( $category->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
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 );
$table = Theme::i()->getTemplate( 'browse' )->noFiles( $category );
}
else
{
/* Build table */
$table = new \IPS\Helpers\Table\Content( 'IPS\downloads\File', $category->url(), NULL, $category );
$table->classes = array( 'ipsDataList_large' );
$table = new Content( 'IPS\downloads\File', $category->url(), NULL, $category );
if ( Member::loggedIn()->getLayoutValue( 'downloads_categories' ) == 'grid')
{
$table->classes = array( 'ipsData--grid ipsData--entries ipsData--download-file-table' );
} else {
$table->classes = array( 'ipsData--table ipsData--entries ipsData--download-file-table' );
}
$table->sortOptions = array_merge( $table->sortOptions, array( 'file_downloads' => 'file_downloads' ) );
if ( !$category->bitoptions['reviews_download'] )
@@ -220,34 +248,34 @@ class _browse extends \IPS\Dispatcher\Controller
$table->sortDirection = 'asc';
}
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->idm_nexus_on )
if ( Application::appIsEnabled( 'nexus' ) and Settings::i()->idm_nexus_on )
{
$table->filters = array(
'file_free' => "( ( file_cost='' OR file_cost IS NULL ) AND ( file_nexus='' OR file_nexus IS NULL ) )",
'file_paid' => "( file_cost<>'' OR file_nexus>0 )",
);
}
$table->title = \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get('download_file_count'), array( $_count ) );
$table->title = Member::loggedIn()->language()->pluralize( Member::loggedIn()->language()->get('download_file_count'), array( $_count ) );
}
/* Online User Location */
$permissions = $category->permissions();
\IPS\Session::i()->setLocation( $category->url(), explode( ",", $permissions['perm_view'] ), 'loc_downloads_viewing_category', array( "downloads_category_{$category->id}" => TRUE ) );
Session::i()->setLocation( $category->url(), explode( ",", $permissions['perm_view'] ), 'loc_downloads_viewing_category', array( "downloads_category_{$category->id}" => TRUE ) );
/* Set default search option */
\IPS\Output::i()->defaultSearchOption = array( 'downloads_file', "downloads_file_pl" );
Output::i()->defaultSearchOption = array( 'downloads_file', "downloads_file_pl" );
/* Update Views */
if ( !\IPS\Request::i()->isAjax() )
if ( ! Request::i()->isAjax() )
{
$category->updateViews();
}
/* Output */
\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()->output = \IPS\Theme::i()->getTemplate( 'browse' )->category( $category, (string) $table );
Output::i()->title = $category->_title;
Output::i()->contextualSearchOptions[ Member::loggedIn()->language()->addToStack( 'search_contextual_item_downloads_categories' ) ] = array( 'type' => 'downloads_file', 'nodes' => $category->_id );
Output::i()->sidebar['contextual'] .= Theme::i()->getTemplate( 'browse' )->indexSidebar( Category::canOnAny('add'), $category );
Output::i()->output = Theme::i()->getTemplate( 'browse' )->category( $category, (string) $table );
}
/**
@@ -255,33 +283,13 @@ class _browse extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function categories()
protected function categories() : void
{
/* 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' );
Session::i()->setLocation( 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('downloads_categories_pagetitle');
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=browse&do=categories', 'front', 'downloads_categories' ), \IPS\Member::loggedIn()->language()->addToStack('download_categories') );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->categories();
}
/**
* Set the viewing method
*
* @return void
*/
protected function setMethod()
{
\IPS\Session::i()->csrfCheck();
$method = ( isset( \IPS\Request::i()->method ) ) ? \IPS\Request::i()->method : \IPS\Settings::i()->idm_default_view;
\IPS\Request::i()->setCookie( 'idm_category_view', $method, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
if ( \IPS\Member::loggedIn()->member_id )
{
\IPS\Db::i()->replace( 'downloads_view_method', array( 'member_id' => \IPS\Member::loggedIn()->member_id, 'method' => $method ) );
}
\IPS\Output::i()->redirect( \IPS\downloads\Category::load( \IPS\Request::i()->id )->url() );
Output::i()->title = Member::loggedIn()->language()->addToStack('downloads_categories_pagetitle');
Output::i()->breadcrumb[] = array( Url::internal( 'app=downloads&module=downloads&controller=browse&do=categories', 'front', 'downloads_categories' ), Member::loggedIn()->language()->addToStack('download_categories') );
Output::i()->output = Theme::i()->getTemplate( 'browse' )->categories();
}
}
@@ -12,67 +12,84 @@
namespace IPS\downloads\modules\front\downloads;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Content\Controller;
use IPS\Db;
use IPS\downloads\File\PendingVersion;
use IPS\downloads\File as FileClass;
use IPS\File;
use IPS\Log;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Theme;
use OutOfRangeException;
use UnderflowException;
use UnexpectedValueException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Pending Version Controller
*/
class _pending extends \IPS\Content\Controller
class pending extends Controller
{
/**
* [Content\Controller] Class
*/
protected static $contentModel = \IPS\downloads\File\PendingVersion::class;
protected static string $contentModel = PendingVersion::class;
/**
* @brief Storage for loaded file
*/
protected $file = NULL;
protected ?FileClass $file = NULL;
/**
* @brief Storage for loaded version
*/
protected $version = NULL;
protected ?PendingVersion $version = NULL;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
try
{
$this->file = \IPS\downloads\File::load( \IPS\Request::i()->file_id );
$this->version = \IPS\downloads\File\PendingVersion::load( \IPS\Request::i()->id );
$this->file = FileClass::load( Request::i()->file_id );
$this->version = PendingVersion::load( Request::i()->id );
if( $this->file->id !== $this->version->file()->id )
{
throw new \OutOfRangeException;
throw new OutOfRangeException;
}
if ( !$this->version->canUnhide() AND !$this->version->canDelete())
{
\IPS\Output::i()->error( 'node_error', '2D417/1', 404, '' );
Output::i()->error( 'node_error', '2D417/1', 404, '' );
}
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
/* The version does not exist, but the file does. Redirect there instead. */
if( isset( $this->file ) )
{
\IPS\Output::i()->redirect( $this->file->url() );
Output::i()->redirect( $this->file->url() );
}
\IPS\Output::i()->error( 'node_error', '2D417/2', 404, '' );
Output::i()->error( 'node_error', '2D417/2', 404, '' );
}
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_view.js', 'downloads', 'front' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_pending.js', 'downloads', 'front' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_view.js', 'downloads', 'front' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_pending.js', 'downloads', 'front' ) );
parent::execute();
}
@@ -80,24 +97,25 @@ class _pending extends \IPS\Content\Controller
/**
* Execute
*
* @return void
* @return mixed
*/
public function manage()
public function manage() : mixed
{
/* Display */
\IPS\Output::i()->title = $this->file->name;
Output::i()->title = $this->file->name;
$container = $this->file->container();
foreach ( $container->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( $container->url(), $container->_title );
Output::i()->breadcrumb[] = array( $container->url(), $container->_title );
\IPS\Output::i()->breadcrumb[] = array( $this->file->url(), $this->file->name );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('pending_version') );
Output::i()->breadcrumb[] = array( $this->file->url(), $this->file->name );
Output::i()->breadcrumb[] = array( NULL, Member::loggedIn()->language()->addToStack('pending_version') );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->pendingView( $this->file, $this->version );
Output::i()->output = Theme::i()->getTemplate( 'view' )->pendingView( $this->file, $this->version );
return null;
}
/**
@@ -105,25 +123,25 @@ class _pending extends \IPS\Content\Controller
*
* @return void
*/
public function download()
public function download() : void
{
try
{
$record = \IPS\Db::i()->select( '*', 'downloads_files_records', array( 'record_id=? AND record_file_id=?', \IPS\Request::i()->fileId, $this->file->id ) )->first();
$record = Db::i()->select( '*', 'downloads_files_records', array( 'record_id=? AND record_file_id=?', Request::i()->fileId, $this->file->id ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
\IPS\Output::i()->error( 'node_error', '2D417/3', 404, '' );
Output::i()->error( 'node_error', '2D417/3', 404, '' );
}
/* Download */
if ( $record['record_type'] === 'link' )
{
\IPS\Output::i()->redirect( $record['record_location'] );
Output::i()->redirect( $record['record_location'] );
}
else
{
$file = \IPS\File::get( 'downloads_Files', $record['record_location'] );
$file = File::get( 'downloads_Files', $record['record_location'] );
$file->originalFilename = $record['record_realname'] ?: $file->originalFilename;
}
@@ -132,23 +150,22 @@ class _pending extends \IPS\Content\Controller
{
if ( $signedUrl = $file->generateTemporaryDownloadUrl() )
{
\IPS\Output::i()->redirect( $signedUrl );
Output::i()->redirect( $signedUrl );
}
}
catch( \UnexpectedValueException $e )
catch( UnexpectedValueException $e )
{
\IPS\Log::log( $e, 'downloads' );
\IPS\Output::i()->error( 'generic_error', '3D417/5', 500, '' );
Log::log( $e, 'downloads' );
Output::i()->error( 'generic_error', '3D417/5', 500, '' );
}
/* Send headers and print file */
\IPS\Output::i()->sendStatusCodeHeader( 200 );
\IPS\Output::i()->sendHeader( "Content-type: " . \IPS\File::getMimeType( $file->originalFilename ) . ";charset=UTF-8" );
\IPS\Output::i()->sendHeader( "Content-Security-Policy: default-src 'none'; sandbox" );
\IPS\Output::i()->sendHeader( "X-Content-Security-Policy: default-src 'none'; sandbox" );
\IPS\Output::i()->sendHeader( "Cross-Origin-Opener-Policy: same-origin" );
\IPS\Output::i()->sendHeader( 'Content-Disposition: ' . \IPS\Output::getContentDisposition( 'attachment', $file->originalFilename ) );
\IPS\Output::i()->sendHeader( "Content-Length: " . $file->filesize() );
Output::i()->sendStatusCodeHeader( 200 );
Output::i()->sendHeader( "Content-type: " . File::getMimeType( $file->originalFilename ) . ";charset=UTF-8" );
Output::i()->sendHeader( "Content-Security-Policy: default-src 'none'; sandbox" );
Output::i()->sendHeader( "X-Content-Security-Policy: default-src 'none'; sandbox" );
Output::i()->sendHeader( 'Content-Disposition: ' . Output::getContentDisposition( 'attachment', $file->originalFilename ) );
Output::i()->sendHeader( "Content-Length: " . $file->filesize() );
$file->printFile();
exit;
@@ -159,14 +176,14 @@ class _pending extends \IPS\Content\Controller
*
* @return void
*/
protected function moderate()
protected function moderate(): void
{
if( $this->file->hidden() === 1 AND \IPS\Request::i()->action == 'unhide' )
if( $this->file->hidden() === 1 AND Request::i()->action == 'unhide' )
{
\IPS\Output::i()->error( 'file_version_pending_cannot_approve', '2D417/4', 403, '' );
Output::i()->error( 'file_version_pending_cannot_approve', '2D417/4', 403, '' );
}
return parent::moderate();
parent::moderate();
}
/**
@@ -174,17 +191,17 @@ class _pending extends \IPS\Content\Controller
*
* @return void
*/
protected function delete()
protected function delete() : void
{
if( !$this->version->canDelete())
{
\IPS\Output::i()->error( 'file_version_pending_cannot_delete', '2D417/6', 403, '' );
Output::i()->error( 'file_version_pending_cannot_delete', '2D417/6', 403, '' );
}
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
Request::i()->confirmedDelete();
$this->version->delete();
\IPS\Session::i()->modLog( 'modlog__action_deletedpending', array( (string) $this->file->url() => FALSE, $this->file->name => FALSE ), $this->file );
\IPS\Output::i()->redirect( $this->file->url() , 'deleted');
Session::i()->modLog( 'modlog__action_deletedpending', array( (string) $this->file->url() => FALSE, $this->file->name => FALSE ), $this->file );
Output::i()->redirect( $this->file->url() , 'deleted');
}
}
@@ -12,25 +12,57 @@
namespace IPS\downloads\modules\front\downloads;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use Exception;
use IPS\core\FrontNavigation;
use IPS\Db;
use IPS\Dispatcher\Controller;
use IPS\downloads\Category;
use IPS\downloads\File;
use IPS\downloads\Form\LinkedScreenshots;
use IPS\File\Iterator;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Node;
use IPS\Helpers\Form\Stack;
use IPS\Helpers\Form\Text;
use IPS\Helpers\Form\Upload;
use IPS\Helpers\Form\YesNo;
use IPS\Helpers\Wizard;
use IPS\Http\Url;
use IPS\Image;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
use IPS\Theme;
use OutOfRangeException;
use UnderflowException;
use function count;
use function defined;
use function in_array;
use function is_array;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Submit File Controller
*/
class _submit extends \IPS\Dispatcher\Controller
class submit extends Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_submit.js', 'downloads', 'front' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_submit.js', 'downloads', 'front' ) );
parent::execute();
}
@@ -40,40 +72,40 @@ class _submit extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$form = new \IPS\Helpers\Form( 'select_category', 'continue' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Node( 'select_category', isset( \IPS\Request::i()->category ) ? \IPS\Request::i()->category : NULL, TRUE, array(
'url' => \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=submit', 'front', 'downloads_submit' ),
$form = new Form( 'select_category', 'continue' );
$form->class = 'ipsForm--vertical ipsForm--submit-file ipsForm--noLabels';
$form->add( new Node( 'select_category', Request::i()->category ?? null, TRUE, array(
'url' => Url::internal( 'app=downloads&module=downloads&controller=submit', 'front', 'downloads_submit' ),
'class' => 'IPS\downloads\Category',
'permissionCheck' => 'add',
'clubs' => \IPS\Settings::i()->club_nodes_in_apps
'clubs' => Settings::i()->club_nodes_in_apps
) ) );
if ( \IPS\Member::loggedIn()->group['idm_bulk_submit'] )
if ( Member::loggedIn()->group['idm_bulk_submit'] )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'bulk', NULL, FALSE, array( 'label' => "bulk_upload_button" ) ) );
$form->add( new YesNo( 'bulk', NULL, FALSE, array( 'label' => "bulk_upload_button" ) ) );
}
if ( $values = $form->values() )
{
$url = \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=submit&do=submit', 'front', 'downloads_submit' )->setQueryString( 'category', $values['select_category']->_id );
$url = Url::internal( 'app=downloads&module=downloads&controller=submit&do=submit', 'front', 'downloads_submit' )->setQueryString( 'category', $values['select_category']->_id );
if ( isset( $values['bulk'] ) AND $values['bulk'] )
{
$url = $url->setQueryString( 'bulk', '1' );
}
if( isset( \IPS\Request::i()->_new ) )
if( isset( Request::i()->_new ) )
{
$url = $url->setQueryString(array( '_new' => '1' ) );
}
\IPS\Output::i()->redirect( $url );
Output::i()->redirect( $url );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'select_category' );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->categorySelector( $form );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'select_category' ) );
Output::i()->title = Member::loggedIn()->language()->addToStack( 'select_category' );
Output::i()->output = Theme::i()->getTemplate( 'submit' )->categorySelector( $form );
Output::i()->breadcrumb[] = array( NULL, Member::loggedIn()->language()->addToStack( 'select_category' ) );
}
/**
@@ -81,7 +113,7 @@ class _submit extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function submit()
protected function submit() : void
{
$steps = array();
@@ -93,23 +125,23 @@ class _submit extends \IPS\Dispatcher\Controller
/* Get category data */
try
{
$category = \IPS\downloads\Category::loadAndCheckPerms( \IPS\Request::i()->category );
$category = Category::loadAndCheckPerms( Request::i()->category );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=submit&_step=select_category', 'front', 'downloads_submit' ) );
Output::i()->redirect( Url::internal( 'app=downloads&module=downloads&controller=submit&_step=select_category', 'front', 'downloads_submit' ) );
}
if( !$category->can('add') OR !\IPS\Member::loggedIn()->group['idm_max_size'] )
if( !$category->can('add') OR !Member::loggedIn()->group['idm_max_size'] )
{
\IPS\Output::i()->error( 'add_files_no_perm', '3D286/1', 403, '' );
Output::i()->error( 'add_files_no_perm', '3D286/1', 403, '' );
}
$form = new \IPS\Helpers\Form( 'upload_files', 'continue' );
$form = new Form( 'upload_files', 'continue' );
$form->class = 'ipsForm_vertical';
$form->class = 'ipsForm--vertical ipsForm--select-file-category';
$form->hiddenValues['category'] = $category->_id;
$form->hiddenValues['postKey'] = ( \IPS\Request::i()->postKey ) ? \IPS\Request::i()->postKey : md5( mt_rand() );
$form->hiddenValues['postKey'] = Request::i()->postKey ?: md5( mt_rand() );
/* Populate any existing records */
$files = array();
@@ -139,35 +171,35 @@ class _submit extends \IPS\Dispatcher\Controller
$maximums[] = ( $category->maxfile / 1024 );
}
if( \IPS\Member::loggedIn()->group['idm_max_size'] !== -1 )
if( Member::loggedIn()->group['idm_max_size'] !== -1 )
{
$maximums[] = ( \IPS\Member::loggedIn()->group['idm_max_size'] / 1024 );
$maximums[] = ( Member::loggedIn()->group['idm_max_size'] / 1024 );
}
$form->add( new \IPS\Helpers\Form\Upload( 'files', $files, ( !\IPS\Member::loggedIn()->group['idm_linked_files'] and !\IPS\Member::loggedIn()->group['idm_import_files'] ), array( 'storageExtension' => 'downloads_Files', 'allowedFileTypes' => $category->types, 'maxFileSize' => ( ( \count( $maximums ) ) ? min( $maximums ) : NULL ), 'multiple' => $category->multiple_files, 'minimize' => FALSE ) ) );
$form->add( new Upload( 'files', $files, ( !Member::loggedIn()->group['idm_linked_files'] and !Member::loggedIn()->group['idm_import_files'] ), array( 'storageExtension' => 'downloads_Files', 'allowedFileTypes' => $category->types, 'maxFileSize' => ( ( count( $maximums ) ) ? min( $maximums ) : NULL ), 'multiple' => $category->multiple_files, 'minimize' => FALSE ) ) );
if ( !isset( \IPS\Request::i()->bulk ) )
if ( !isset( Request::i()->bulk ) )
{
if ( \IPS\Member::loggedIn()->group['idm_linked_files'] )
if ( Member::loggedIn()->group['idm_linked_files'] )
{
$form->add( new \IPS\Helpers\Form\Stack( 'url_files', isset( $data['url_files'] ) ? $data['url_files'] : array(), FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
$form->add( new Stack( 'url_files', $data['url_files'] ?? array(), FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
}
if ( \IPS\Member::loggedIn()->group['idm_import_files'] )
if ( Member::loggedIn()->group['idm_import_files'] )
{
$form->add( new \IPS\Helpers\Form\Stack( 'import_files', array(), FALSE, array( 'placeholder' => \IPS\ROOT_PATH ), function( $val )
$form->add( new Stack( 'import_files', array(), FALSE, array( 'placeholder' => \IPS\ROOT_PATH ), function( $val )
{
if( $val and \is_array( $val ) )
if( $val and is_array( $val ) )
{
foreach ( $val as $file )
{
if ( is_dir( $file ) )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('err_import_files_dir', FALSE, array( 'sprintf' => array( $file ) ) ) );
throw new DomainException( Member::loggedIn()->language()->addToStack('err_import_files_dir', FALSE, array( 'sprintf' => array( $file ) ) ) );
}
elseif ( !is_file( $file ) )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack('err_import_files', FALSE, array( 'sprintf' => array( $file ) ) ) );
throw new DomainException( Member::loggedIn()->language()->addToStack('err_import_files', FALSE, array( 'sprintf' => array( $file ) ) ) );
}
}
}
@@ -182,21 +214,21 @@ class _submit extends \IPS\Dispatcher\Controller
$maxDims = explode( 'x', $category->maxdims );
$image = array( 'maxWidth' => $maxDims[0], 'maxHeight' => $maxDims[1] );
}
$form->add( new \IPS\Helpers\Form\Upload( 'screenshots', $screenshots, ( $category->bitoptions['reqss'] and !\IPS\Member::loggedIn()->group['idm_linked_files'] ), array(
$form->add( new Upload( 'screenshots', $screenshots, ( $category->bitoptions['reqss'] and !Member::loggedIn()->group['idm_linked_files'] ), array(
'storageExtension' => 'downloads_Screenshots',
'image' => $image,
'maxFileSize' => $category->maxss ? ( $category->maxss / 1024 ) : NULL,
'multiple' => TRUE,
'template' => "downloads.submit.screenshot",
) ) );
if ( \IPS\Member::loggedIn()->group['idm_linked_files'] )
if ( Member::loggedIn()->group['idm_linked_files'] )
{
$form->add( new \IPS\downloads\Form\LinkedScreenshots( 'url_screenshots', isset( $data['url_screenshots'] ) ? array( 'values' => $data['url_screenshots'] ) : array(), FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
$form->add( new LinkedScreenshots( 'url_screenshots', isset( $data['url_screenshots'] ) ? array( 'values' => $data['url_screenshots'] ) : array(), FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
}
}
/* Form Elements */
foreach ( \IPS\downloads\File::formElements( NULL, $category ) as $input )
foreach ( File::formElements( NULL, $category ) as $input )
{
$form->add( $input );
}
@@ -204,7 +236,7 @@ class _submit extends \IPS\Dispatcher\Controller
/* Version field (we only show this on create */
if( $category->version_numbers )
{
$form->add( new \IPS\Helpers\Form\Text( 'file_version', '1.0.0', ( $category->version_numbers == 2 ) ? TRUE : FALSE, array( 'maxLength' => 32 ) ) );
$form->add( new Text( 'file_version', '1.0.0', $category->version_numbers == 2, array( 'maxLength' => 32 ) ) );
}
}
@@ -213,22 +245,22 @@ class _submit extends \IPS\Dispatcher\Controller
/* Check */
if ( empty( $values['files'] ) and empty( $values['url_files'] ) and empty( $values['import_files'] ) )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack('err_no_files');
return \IPS\Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( \IPS\Member::loggedIn()->group['idm_bulk_submit'] && \IPS\Request::i()->bulk ) );
$form->error = Member::loggedIn()->language()->addToStack('err_no_files');
return Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( Member::loggedIn()->group['idm_bulk_submit'] && Request::i()->bulk ) );
}
elseif ( !$category->multiple_files AND \is_array( $values['files'] ) AND ( \count( $values['files'] ?? [] ) + \count( $values['url_files'] ?? [] ) + \count( $values['import_files'] ?? [] ) > 1 ) )
elseif ( !$category->multiple_files AND is_array( $values['files'] ) AND ( count( $values['files'] ?? [] ) + count( $values['url_files'] ?? [] ) + count( $values['import_files'] ?? [] ) > 1 ) )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack('err_too_many_files');
return \IPS\Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( \IPS\Member::loggedIn()->group['idm_bulk_submit'] && \IPS\Request::i()->bulk ) );
$form->error = Member::loggedIn()->language()->addToStack('err_too_many_files');
return Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( Member::loggedIn()->group['idm_bulk_submit'] && Request::i()->bulk ) );
}
if ( !isset( \IPS\Request::i()->bulk ) && $category->bitoptions['reqss'] and empty( $values['screenshots'] ) and empty( $values['url_screenshots'] ) )
if ( !isset( Request::i()->bulk ) && $category->bitoptions['reqss'] and empty( $values['screenshots'] ) and empty( $values['url_screenshots'] ) )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack('err_no_screenshots');
return \IPS\Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( \IPS\Member::loggedIn()->group['idm_bulk_submit'] && \IPS\Request::i()->bulk ) );
$form->error = Member::loggedIn()->language()->addToStack('err_no_screenshots');
return Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( Member::loggedIn()->group['idm_bulk_submit'] && Request::i()->bulk ) );
}
/* Get any records we had before in case we need to delete them */
$existing = iterator_to_array( \IPS\Db::i()->select( '*', 'downloads_files_records', array( 'record_post_key=?', \IPS\Request::i()->postKey ) )->setKeyField( 'record_location' ) );
$existing = iterator_to_array( Db::i()->select( '*', 'downloads_files_records', array( 'record_post_key=?', Request::i()->postKey ) )->setKeyField( 'record_location' ) );
/* Loop through the values we have */
$k = 0;
@@ -241,7 +273,7 @@ class _submit extends \IPS\Dispatcher\Controller
if( $values['files'] !== NULL )
{
if ( !\is_array( $values['files'] ) )
if ( !is_array( $values['files'] ) )
{
$values['files'] = [ $values['files'] ];
}
@@ -251,8 +283,8 @@ class _submit extends \IPS\Dispatcher\Controller
$files[ $k ] = (string) $file;
if ( !isset( $existing[ (string) $file ] ) )
{
\IPS\Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => isset( \IPS\Request::i()->bulk ) ? md5( \IPS\Request::i()->postKey . "-{$k}" ) : \IPS\Request::i()->postKey,
Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => isset( Request::i()->bulk ) ? md5( Request::i()->postKey . "-{$k}" ) : Request::i()->postKey,
'record_type' => 'upload',
'record_location' => (string) $file,
'record_realname' => $file->originalFilename,
@@ -275,8 +307,8 @@ class _submit extends \IPS\Dispatcher\Controller
$files[ $k ] = (string) $file;
if ( !isset( $existing[ (string) $file ] ) )
{
\IPS\Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => isset( \IPS\Request::i()->bulk ) ? md5( \IPS\Request::i()->postKey . "-{$k}" ) : \IPS\Request::i()->postKey,
Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => isset( Request::i()->bulk ) ? md5( Request::i()->postKey . "-{$k}" ) : Request::i()->postKey,
'record_type' => 'upload',
'record_location' => (string) $file,
'record_realname' => $file->originalFilename,
@@ -296,8 +328,8 @@ class _submit extends \IPS\Dispatcher\Controller
$linkedFiles[] = (string) $url;
if ( !isset( $existing[ (string) $url ] ) )
{
\IPS\Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => \IPS\Request::i()->postKey,
Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => Request::i()->postKey,
'record_type' => 'link',
'record_location' => (string) $url,
'record_realname' => NULL,
@@ -316,21 +348,21 @@ class _submit extends \IPS\Dispatcher\Controller
if ( !isset( $existing[ (string) $file ] ) )
{
$noWatermark = NULL;
if ( \IPS\Settings::i()->idm_watermarkpath )
if ( Settings::i()->idm_watermarkpath )
{
try
{
$noWatermark = (string) $file;
$watermark = \IPS\Image::create( \IPS\File::get( 'core_Theme', \IPS\Settings::i()->idm_watermarkpath )->contents() );
$image = \IPS\Image::create( $file->contents() );
$watermark = Image::create( \IPS\File::get( 'core_Theme', Settings::i()->idm_watermarkpath )->contents() );
$image = Image::create( $file->contents() );
$image->watermark( $watermark );
$file = \IPS\File::create( 'downloads_Screenshots', $file->originalFilename, $image );
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
\IPS\Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => \IPS\Request::i()->postKey,
Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => Request::i()->postKey,
'record_type' => 'ssupload',
'record_location' => (string) $file,
'record_thumb' => (string) $file->thumbnail( 'downloads_Screenshots' ),
@@ -338,7 +370,7 @@ class _submit extends \IPS\Dispatcher\Controller
'record_size' => $file->filesize(),
'record_time' => time(),
'record_no_watermark' => $noWatermark,
'record_default' => ( \IPS\Request::i()->screenshots_primary_screenshot AND \IPS\Request::i()->screenshots_primary_screenshot == $_key ) ? 1 : 0
'record_default' => ( Request::i()->screenshots_primary_screenshot AND Request::i()->screenshots_primary_screenshot == $_key ) ? 1 : 0
) );
}
unset( $existing[ (string) $file ] );
@@ -351,15 +383,15 @@ class _submit extends \IPS\Dispatcher\Controller
$linkedScreenshots[] = (string) $url;
if ( !isset( $existing[ (string) $url ] ) )
{
\IPS\Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => \IPS\Request::i()->postKey,
Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => Request::i()->postKey,
'record_type' => 'sslink',
'record_location' => (string) $url,
'record_thumb' => NULL,
'record_realname' => NULL,
'record_size' => 0,
'record_time' => time(),
'record_default' => ( \IPS\Request::i()->screenshots_primary_screenshot AND \IPS\Request::i()->screenshots_primary_screenshot == $_key ) ? 1 : 0
'record_default' => ( Request::i()->screenshots_primary_screenshot AND Request::i()->screenshots_primary_screenshot == $_key ) ? 1 : 0
) );
}
unset( $existing[ (string) $url ] );
@@ -373,7 +405,7 @@ class _submit extends \IPS\Dispatcher\Controller
{
\IPS\File::get( $file['record_type'] === 'upload' ? 'downloads_Files' : 'downloads_Screenshots', $location )->delete();
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
if( $file['record_thumb'] )
{
@@ -381,7 +413,7 @@ class _submit extends \IPS\Dispatcher\Controller
{
\IPS\File::get( 'downloads_Screenshots', $file['record_thumb'] )->delete();
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
if( $file['record_no_watermark'] )
@@ -390,63 +422,63 @@ class _submit extends \IPS\Dispatcher\Controller
{
\IPS\File::get( 'downloads_Screenshots', $file['record_no_watermark'] )->delete();
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
\IPS\Db::i()->delete( 'downloads_files_records', array( 'record_id=?', $file['record_id'] ) );
Db::i()->delete( 'downloads_files_records', array( 'record_id=?', $file['record_id'] ) );
}
if ( !isset( \IPS\Request::i()->bulk ) )
if ( !isset( Request::i()->bulk ) )
{
$file = \IPS\downloads\File::createFromForm( array_merge( $data, $values, array( 'postKey' => \IPS\Request::i()->postKey ) ), $category );
$file = File::createFromForm( array_merge( $data, $values, array( 'postKey' => Request::i()->postKey ) ), $category );
$file->markRead();
/* Redirect */
if ( isset( $values['guest_email'] ) )
{
$url = \IPS\Http\Url::internal( 'app=core&module=system&controller=register', 'front', 'register' );
$url = Url::internal( 'app=core&module=system&controller=register', 'front', 'register' );
$message = NULL;
}
elseif( $file->author()->member_id OR $file->canView() )
{
$url = $file->url();
$message = ( isset( $values['import_files'] ) AND \count( $values['import_files'] ) ) ? \IPS\Member::loggedIn()->language()->addToStack('file_imported_removed') : NULL;
$message = ( isset( $values['import_files'] ) AND count( $values['import_files'] ) ) ? Member::loggedIn()->language()->addToStack('file_imported_removed') : NULL;
}
else
{
$url = $category->url();
$message = \IPS\Member::loggedIn()->language()->addToStack('file_requires_approval_g');
$message = Member::loggedIn()->language()->addToStack('file_requires_approval_g');
}
if ( \IPS\Request::i()->isAjax() )
if ( Request::i()->isAjax() )
{
\IPS\Output::i()->json( array( 'redirect' => (string) $url ) );
Output::i()->json( array( 'redirect' => (string) $url ) );
}
else
{
\IPS\Output::i()->redirect( $url, $message );
Output::i()->redirect( $url, $message );
}
}
else
{
/* This is a bulk file, so we want to go on to the next step */
return array( 'category' => $category->_id, 'postKey' => \IPS\Request::i()->postKey, 'files' => $files, 'url_files' => $linkedFiles, 'screenshots' => $screenshots, 'url_screenshots' => $linkedScreenshots );
return array( 'category' => $category->_id, 'postKey' => Request::i()->postKey, 'files' => $files, 'url_files' => $linkedFiles, 'screenshots' => $screenshots, 'url_screenshots' => $linkedScreenshots );
}
}
$guestPostBeforeRegister = ( !\IPS\Member::loggedIn()->member_id ) ? ( $category and !$category->can( 'add', \IPS\Member::loggedIn(), FALSE ) ) : NULL;
$modQueued = \IPS\downloads\File::moderateNewItems( \IPS\Member::loggedIn(), $category, $guestPostBeforeRegister );
$guestPostBeforeRegister = ( !Member::loggedIn()->member_id ) ? ( !$category->can( 'add', Member::loggedIn(), FALSE ) ) : FALSE;
$modQueued = File::moderateNewItems( Member::loggedIn(), $category, $guestPostBeforeRegister );
if ( $guestPostBeforeRegister or $modQueued )
{
$postingInformation = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->postingInformation( $guestPostBeforeRegister, $modQueued, TRUE );
$postingInformation = Theme::i()->getTemplate( 'forms', 'core' )->postingInformation( $guestPostBeforeRegister, $modQueued, TRUE );
}
else
{
$postingInformation = NULL;
}
return \IPS\Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( \IPS\Member::loggedIn()->group['idm_bulk_submit'] && \IPS\Request::i()->bulk ), $postingInformation );
return Theme::i()->getTemplate( 'submit' )->submissionForm( $form, $category, $category->message('subterms'), TRUE, ( Member::loggedIn()->group['idm_bulk_submit'] && Request::i()->bulk ), $postingInformation );
};
/**
@@ -457,14 +489,14 @@ class _submit extends \IPS\Dispatcher\Controller
/* Get Category */
try
{
$category = \IPS\downloads\Category::loadAndCheckPerms( $data['category'] );
$category = Category::loadAndCheckPerms( $data['category'] );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException $e )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=submit', 'front', 'downloads_submit' ) );
Output::i()->redirect( Url::internal( 'app=downloads&module=downloads&controller=submit', 'front', 'downloads_submit' ) );
}
/* Init Form */
$form = new \IPS\Helpers\Form( 'file_information', 'continue' );
$form = new Form( 'file_information', 'continue' );
$existing = array();
foreach ( $data['files'] as $key => $file )
@@ -474,9 +506,9 @@ class _submit extends \IPS\Dispatcher\Controller
try
{
$displayName = \IPS\Db::i()->select( 'record_realname', 'downloads_files_records', array( 'record_location=?', (string) $file ) )->first();
$displayName = Db::i()->select( 'record_realname', 'downloads_files_records', array( 'record_location=?', (string) $file ) )->first();
}
catch( \UnderflowException $e )
catch( UnderflowException $e )
{
$displayName = $file->originalFilename;
}
@@ -485,10 +517,10 @@ class _submit extends \IPS\Dispatcher\Controller
$form->addHeader( $displayName );
/* Form Elements */
foreach ( \IPS\downloads\File::formElements( NULL, $category, "filedata_{$key}_" ) as $input )
foreach ( File::formElements( NULL, $category, "filedata_{$key}_" ) as $input )
{
\IPS\Member::loggedIn()->language()->words[ $input->name ] = \IPS\Member::loggedIn()->language()->addToStack( mb_substr( $input->name, mb_strlen( "filedata_{$key}_" ) ), FALSE );
if ( !$input->value and \in_array( $input->name, array( "filedata_{$key}_file_title", "filedata_{$key}_file_desc" ) ) )
Member::loggedIn()->language()->words[ $input->name ] = Member::loggedIn()->language()->addToStack( mb_substr( $input->name, mb_strlen( "filedata_{$key}_" ) ), FALSE );
if ( !$input->value and in_array( $input->name, array( "filedata_{$key}_file_title", "filedata_{$key}_file_desc" ) ) )
{
$input->value = $displayName;
}
@@ -498,7 +530,7 @@ class _submit extends \IPS\Dispatcher\Controller
/* Screenshots */
if ( $category->bitoptions['allowss'] )
{
$existing[ $key ] = iterator_to_array( new \IPS\File\Iterator( \IPS\Db::i()->select( '*', 'downloads_files_records', array( 'record_post_key=? AND record_type=?', md5( "{$data['postKey']}-{$key}" ), 'ssupload' ) )->setValueField( function( $row ) { return $row['record_no_watermark'] ?: $row['record_location']; } )->setKeyField( function( $row ) { return $row['record_no_watermark'] ?: $row['record_location']; } ), 'downloads_Screenshots' ) );
$existing[ $key ] = iterator_to_array( new Iterator( Db::i()->select( '*', 'downloads_files_records', array( 'record_post_key=? AND record_type=?', md5( "{$data['postKey']}-{$key}" ), 'ssupload' ) )->setValueField( function( $row ) { return $row['record_no_watermark'] ?: $row['record_location']; } )->setKeyField( function( $row ) { return $row['record_no_watermark'] ?: $row['record_location']; } ), 'downloads_Screenshots' ) );
$image = TRUE;
if ( $category->maxdims and $category->maxdims != '0x0' )
@@ -507,21 +539,21 @@ class _submit extends \IPS\Dispatcher\Controller
$image = array( 'maxWidth' => $maxDims[0], 'maxHeight' => $maxDims[1] );
}
$form->add( new \IPS\Helpers\Form\Upload( "screenshots_{$key}", $existing[ $key ], ( $category->bitoptions['reqss'] and !\IPS\Member::loggedIn()->group['idm_linked_files'] ), array(
$form->add( new Upload( "screenshots_{$key}", $existing[ $key ], ( $category->bitoptions['reqss'] and !Member::loggedIn()->group['idm_linked_files'] ), array(
'storageExtension' => 'downloads_Screenshots',
'image' => $image,
'maxFileSize' => $category->maxss ? ( $category->maxss / 1024 ) : NULL,
'multiple' => TRUE
) ) );
\IPS\Member::loggedIn()->language()->words[ "screenshots_{$key}" ] = \IPS\Member::loggedIn()->language()->addToStack( 'screenshots', FALSE );
Member::loggedIn()->language()->words[ "screenshots_{$key}" ] = Member::loggedIn()->language()->addToStack( 'screenshots', FALSE );
}
/* Version field */
if( $category->version_numbers )
{
$form->add( new \IPS\Helpers\Form\Text( "filedata_{$key}_file_version", '1.0.0', ( $category->version_numbers == 2 ) ? TRUE : FALSE, array( 'maxLength' => 32 ) ) );
\IPS\Member::loggedIn()->language()->words[ "filedata_{$key}_file_version" ] = \IPS\Member::loggedIn()->language()->addToStack( 'file_version', FALSE );
$form->add( new Text( "filedata_{$key}_file_version", '1.0.0', $category->version_numbers == 2, array( 'maxLength' => 32 ) ) );
Member::loggedIn()->language()->words[ "filedata_{$key}_file_version" ] = Member::loggedIn()->language()->addToStack( 'file_version', FALSE );
}
}
@@ -531,38 +563,37 @@ class _submit extends \IPS\Dispatcher\Controller
{
if ( $category->bitoptions['allowss'] )
{
foreach ( $data['files'] as $key => $file )
foreach ( $data['files'] as $key => $fileUrl )
{
/* Save Screenshots */
foreach ( $values["screenshots_{$key}"] as $file )
foreach ( $values["screenshots_{$key}"] as $screenshot )
{
$screenshots[] = (string) $file;
if ( !isset( $existing[ $key ][ (string) $file ] ) )
if ( !isset( $existing[ $key ][ (string) $screenshot ] ) )
{
$noWatermark = NULL;
if ( \IPS\Settings::i()->idm_watermarkpath )
if ( Settings::i()->idm_watermarkpath )
{
$noWatermark = (string) $file;
$watermark = \IPS\Image::create( \IPS\File::get( 'core_Theme', \IPS\Settings::i()->idm_watermarkpath )->contents() );
$image = \IPS\Image::create( $file->contents() );
$noWatermark = (string) $screenshot;
$watermark = Image::create( \IPS\File::get( 'core_Theme', Settings::i()->idm_watermarkpath )->contents() );
$image = Image::create( $screenshot->contents() );
$image->watermark( $watermark );
$file = \IPS\File::create( 'downloads_Screenshots', $file->originalFilename, $image );
$screenshot = \IPS\File::create( 'downloads_Screenshots', $screenshot->originalFilename, $image );
}
\IPS\Db::i()->insert( 'downloads_files_records', array(
Db::i()->insert( 'downloads_files_records', array(
'record_post_key' => md5( "{$data['postKey']}-{$key}" ),
'record_type' => 'ssupload',
'record_location' => (string) $file,
'record_thumb' => (string) $file->thumbnail( 'downloads_Screenshots' ),
'record_realname' => $file->originalFilename,
'record_size' => $file->filesize(),
'record_location' => (string) $screenshot,
'record_thumb' => (string) $screenshot->thumbnail( 'downloads_Screenshots' ),
'record_realname' => $screenshot->originalFilename,
'record_size' => $screenshot->filesize(),
'record_time' => time(),
'record_no_watermark' => $noWatermark
) );
}
else
{
unset( $existing[ $key ][ (string) $file ] );
unset( $existing[ $key ][ (string) $screenshot ] );
}
}
@@ -575,9 +606,9 @@ class _submit extends \IPS\Dispatcher\Controller
{
$file->delete();
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
\IPS\Db::i()->delete( 'downloads_files_records', array( 'record_location=? OR record_no_watermark=?', (string) $file, (string) $file ) );
Db::i()->delete( 'downloads_files_records', array( 'record_location=? OR record_no_watermark=?', (string) $file, (string) $file ) );
}
}
}
@@ -602,7 +633,7 @@ class _submit extends \IPS\Dispatcher\Controller
}
}
$file = \IPS\downloads\File::createFromForm( $save, $category, FALSE );
$file = File::createFromForm( $save, $category, FALSE );
\IPS\File::claimAttachments( "filedata_{$key}_downloads-new-file", $file->id, NULL, 'desc' );
foreach ( $customFields as $k )
{
@@ -611,79 +642,79 @@ class _submit extends \IPS\Dispatcher\Controller
$file->markRead();
}
if ( \IPS\Member::loggedIn()->moderateNewContent() OR \IPS\downloads\File::moderateNewItems( \IPS\Member::loggedIn(), $category ) )
if ( Member::loggedIn()->moderateNewContent() OR File::moderateNewItems( Member::loggedIn(), $category ) )
{
\IPS\downloads\File::_sendUnapprovedNotifications( $category );
File::_sendUnapprovedNotifications( $category );
}
else
{
\IPS\downloads\File::_sendNotifications( $category );
File::_sendNotifications( $category );
}
/* Redirect */
if ( \IPS\Request::i()->isAjax() )
if ( Request::i()->isAjax() )
{
\IPS\Output::i()->json( array( 'redirect' => (string) $category->url() ) );
Output::i()->json( array( 'redirect' => (string) $category->url() ) );
}
else
{
\IPS\Output::i()->redirect( $category->url() );
Output::i()->redirect( $category->url() );
}
}
return \IPS\Theme::i()->getTemplate( 'submit' )->bulkForm( $form, $category );
return Theme::i()->getTemplate( 'submit' )->bulkForm( $form, $category );
};
/* Build Wizard */
$url = \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=submit&do=submit', 'front', 'downloads_submit' );
if ( isset( \IPS\Request::i()->category ) and \IPS\Request::i()->category )
$url = Url::internal( 'app=downloads&module=downloads&controller=submit&do=submit', 'front', 'downloads_submit' );
if ( isset( Request::i()->category ) and Request::i()->category )
{
$url = $url->setQueryString( 'category', \IPS\Request::i()->category );
$url = $url->setQueryString( 'category', Request::i()->category );
}
if ( isset( \IPS\Request::i()->bulk ) and \IPS\Request::i()->bulk )
if ( isset( Request::i()->bulk ) and Request::i()->bulk )
{
$url = $url->setQueryString( 'bulk', 1 );
}
$wizard = new \IPS\Helpers\Wizard( $steps, $url );
$wizard->template = array( \IPS\Theme::i()->getTemplate( 'submit' ), 'wizardForm' );
$wizard = new Wizard( $steps, $url );
$wizard->template = array( Theme::i()->getTemplate( 'submit' ), 'wizardForm' );
/* Online User Location */
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=submit', 'front', 'downloads_submit' ), array(), 'loc_downloads_adding_file' );
Session::i()->setLocation( Url::internal( 'app=downloads&module=downloads&controller=submit', 'front', 'downloads_submit' ), array(), 'loc_downloads_adding_file' );
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( isset( \IPS\Request::i()->bulk ) ? 'submit_multiple_files' : 'submit_a_file' );
Output::i()->title = Member::loggedIn()->language()->addToStack( isset( Request::i()->bulk ) ? 'submit_multiple_files' : 'submit_a_file' );
if ( \IPS\IN_DEV )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'plupload/moxie.js', 'core', 'interface' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'plupload/plupload.dev.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'plupload/moxie.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'plupload/plupload.dev.js', 'core', 'interface' ) );
}
else
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'plupload/plupload.full.min.js', 'core', 'interface' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'plupload/plupload.full.min.js', 'core', 'interface' ) );
}
$category = NULL;
\IPS\Output::i()->sidebar['enabled'] = FALSE;
if ( isset( \IPS\Request::i()->category ) )
Output::i()->sidebar['enabled'] = FALSE;
if ( isset( Request::i()->category ) )
{
try
{
$category = \IPS\downloads\Category::loadAndCheckPerms( \IPS\Request::i()->category );
$category = Category::loadAndCheckPerms( 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 );
FrontNavigation::$clubTabActive = TRUE;
Output::i()->breadcrumb = array();
Output::i()->breadcrumb[] = array( Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), Member::loggedIn()->language()->addToStack('module__core_clubs') );
Output::i()->breadcrumb[] = array( $club->url(), $club->name );
Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
}
}
catch ( \OutOfRangeException $e ) { }
catch ( OutOfRangeException $e ) { }
}
\IPS\Output::i()->output = (string) $wizard;
Output::i()->output = (string) $wizard;
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'submit_a_file' ) );
Output::i()->breadcrumb[] = array( NULL, Member::loggedIn()->language()->addToStack( 'submit_a_file' ) );
}
}
File diff suppressed because it is too large. Load diff