Version 3.3.4
This commit is contained in:
1 parent
78706903a2
commit
fb6b5baabc
2206 files changed
+409828
-382984
No files matched your search
@@ -3,11 +3,11 @@
|
||||
* @file defaultSection.php Define the default section for the 'attachments' module
|
||||
*~TERABYTE_DOC_READY~
|
||||
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
|
||||
* $License: This is NULLED!
|
||||
* $License: http://www.invisionpower.com/company/standards.php#license$
|
||||
* $Author: ips_terabyte $
|
||||
* @since 14th May 2003
|
||||
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
|
||||
* @version v3.2.3
|
||||
* @version v3.3.4
|
||||
* $Revision: 8655 $
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> Forbidden</h1>
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> Forbidden</h1>
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,355 +1,355 @@
|
||||
<?php
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.2.3
|
||||
* Attachments: Search
|
||||
* Last Updated: $LastChangedDate: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: ips_terabyte $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://hatynka.in
|
||||
* @since Mon 24th May 2004
|
||||
* @version $Rev: 8644 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_ACP' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class admin_forums_attachments_search extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Skin object
|
||||
*
|
||||
* @var object Skin templates
|
||||
*/
|
||||
protected $html;
|
||||
|
||||
/**
|
||||
* Shortcut for url
|
||||
*
|
||||
* @var string URL shortcut
|
||||
*/
|
||||
protected $form_code;
|
||||
|
||||
/**
|
||||
* Shortcut for url (javascript)
|
||||
*
|
||||
* @var string JS URL shortcut
|
||||
*/
|
||||
protected $form_code_js;
|
||||
|
||||
/**
|
||||
* Main class entry point
|
||||
*
|
||||
* @param object ipsRegistry reference
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Load HTML and language bits
|
||||
//-----------------------------------------
|
||||
$this->html = $this->registry->output->loadTemplate( 'cp_skin_attachments' );
|
||||
$this->lang->loadLanguageFile( array( 'admin_attachments' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Set up stuff
|
||||
//-----------------------------------------
|
||||
|
||||
$this->form_code = $this->html->form_code = 'module=attachments&section=search';
|
||||
$this->form_code_js = $this->html->form_code_js = 'module=attachments§ion=search';
|
||||
|
||||
//-----------------------------------------
|
||||
// StRT!
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'attach_search_complete':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'view_attachments' );
|
||||
$this->_searchResults();
|
||||
break;
|
||||
|
||||
case 'attach_bulk_remove':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'remove_attachments' );
|
||||
$this->_bulkRemoveAttachments();
|
||||
break;
|
||||
|
||||
case 'overview':
|
||||
case 'search':
|
||||
default:
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'view_attachments' );
|
||||
$this->_searchForm();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk remove attachments
|
||||
*
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
protected function _bulkRemoveAttachments()
|
||||
{
|
||||
foreach ( $_POST as $key => $value )
|
||||
{
|
||||
if ( preg_match( "/^attach_(\d+)$/", $key, $match ) )
|
||||
{
|
||||
if ( $this->request[ $match[0] ] )
|
||||
{
|
||||
$ids[] = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ids = IPSLib::cleanIntArray( $ids );
|
||||
$attach_tid = array();
|
||||
|
||||
if ( count( $ids ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get attach details?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "a.attach_rel_id > 0 AND a.attach_id IN(" . implode( ",", $ids ) . ")",
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.pid, p.topic_id',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => "p.pid=a.attach_rel_id AND attach_rel_module='post'",
|
||||
'type' => 'left',
|
||||
),
|
||||
)
|
||||
) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $killmeh = $this->DB->fetch() )
|
||||
{
|
||||
if ( $killmeh['attach_location'] )
|
||||
{
|
||||
@unlink( $this->settings['upload_dir'] . "/" . $killmeh['attach_location'] );
|
||||
}
|
||||
|
||||
if ( $killmeh['attach_thumb_location'] )
|
||||
{
|
||||
@unlink( $this->settings['upload_dir'] . "/" . $killmeh['attach_thumb_location'] );
|
||||
}
|
||||
|
||||
$attach_tid[ $killmeh['topic_id'] ] = $killmeh['topic_id'];
|
||||
}
|
||||
|
||||
$this->DB->delete( 'attachments', "attach_id IN(" . implode( ",", $ids ) . ")" );
|
||||
|
||||
$this->registry->adminFunctions->saveAdminLog( sprintf( $this->lang->words['deleted_attachments'], implode( ",", $ids ) ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Recount topic upload marker
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php' );/*noLibHook*/
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums' );
|
||||
|
||||
$postlib = new $classToLoad( $this->registry );
|
||||
|
||||
foreach( $attach_tid as $tid )
|
||||
{
|
||||
if( $tid )
|
||||
{
|
||||
$postlib->recountTopicAttachments( $tid );
|
||||
}
|
||||
}
|
||||
|
||||
$this->registry->output->global_message = $this->lang->words['attachments_removed'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['noattach_to_remove'];
|
||||
}
|
||||
|
||||
if ( $this->request['return'] == 'stats' )
|
||||
{
|
||||
$this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . 'module=attachments§ion=stats' );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $_POST['url'] )
|
||||
{
|
||||
foreach( explode( '&', $_POST['url'] ) as $u )
|
||||
{
|
||||
list ( $k, $v ) = explode( '=', $u );
|
||||
|
||||
$this->request[ $k] = $v ;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_searchResults();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attachment search results
|
||||
*
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
protected function _searchResults()
|
||||
{
|
||||
$show = intval($this->request['show']);
|
||||
$show = $show > 100 ? 100 : $show;
|
||||
|
||||
//-----------------------------------------
|
||||
// Build URL
|
||||
//-----------------------------------------
|
||||
|
||||
$url = "";
|
||||
$url_components = array( 'extension', 'filesize', 'filesize_gt', 'days', 'days_gt', 'hits', 'hits_gt', 'filename', 'authorname', 'onlyimage', 'orderby', 'sort', 'show' );
|
||||
|
||||
foreach( $url_components as $u )
|
||||
{
|
||||
$url .= $u . '=' . $this->request[ $u ] . '&';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build Query
|
||||
//-----------------------------------------
|
||||
|
||||
$queryfinal = "";
|
||||
$query = array();
|
||||
|
||||
if ( $this->request['extension'] )
|
||||
{
|
||||
$query[] = 'a.attach_ext="' . mb_strtolower( str_replace( ".", "", $this->request['extension'] ) ) . '"';
|
||||
}
|
||||
|
||||
if ( $this->request['filesize'] )
|
||||
{
|
||||
$gt = $this->request['filesize_gt'] == 'gt' ? '>=' : '<';
|
||||
|
||||
$query[] = "a.attach_filesize {$gt} " . intval( $this->request['filesize']*1024 );
|
||||
}
|
||||
|
||||
if ( $this->request['days'] )
|
||||
{
|
||||
$day_break = time() - intval( $this->request['days'] * 86400 );
|
||||
|
||||
$gt = $this->request['days_gt'] == 'lt' ? '>=' : '<';
|
||||
|
||||
$query[] = "a.attach_date {$gt} {$day_break}";
|
||||
}
|
||||
|
||||
if ( $this->request['hits'] )
|
||||
{
|
||||
$gt = $this->request['hits_gt'] == 'gt' ? '>=' : '<';
|
||||
|
||||
$query[] = "a.attach_hits {$gt} " . intval($this->request['hits']);
|
||||
}
|
||||
|
||||
if ( $this->request['filename'] )
|
||||
{
|
||||
$query[] = $this->DB->buildLower('a.attach_file') . ' LIKE "%' . mb_strtolower( $this->request['filename'] ) . '%"';
|
||||
}
|
||||
|
||||
if ( $this->request['authorname'] )
|
||||
{
|
||||
$query[] = $this->DB->buildLower('p.author_name') . ' LIKE "%' . mb_strtolower( $this->request['authorname'] ) . '%"';
|
||||
}
|
||||
|
||||
if ( $this->request['onlyimage'] )
|
||||
{
|
||||
$query[] = 'a.attach_is_image=1';
|
||||
}
|
||||
|
||||
if ( count($query) )
|
||||
{
|
||||
$queryfinal = 'AND '. implode( " AND ", $query );
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
|
||||
$this->DB->build( array( 'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'".$queryfinal,
|
||||
'add_join' => array(
|
||||
0 => array( 'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left' ),
|
||||
1 => array( 'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left' ),
|
||||
2 => array( 'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left' )
|
||||
),
|
||||
'order' => "a.attach_" . $this->request['orderby'] . " " . $this->request['sort'],
|
||||
'limit' => array( 0, $show ) ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat($r['attach_filesize']);
|
||||
$r['attach_date'] = ipsRegistry::getClass( 'class_localization')->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
$rows[] = $r;
|
||||
}
|
||||
|
||||
$this->registry->output->html .= $this->html->attachmentSearchResults( $url, $rows );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show attachment search form
|
||||
*
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
protected function _searchForm()
|
||||
{
|
||||
$gt_array = array( 0 => array( 'gt', $this->lang->words['se_morethan'] ), 1 => array( 'lt', $this->lang->words['se_lessthan'] ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// FORM
|
||||
//-----------------------------------------
|
||||
|
||||
$form['extension'] = $this->registry->output->formSimpleInput( 'extension', isset($_POST['extension']) ? $_POST['extension'] : '', 10 );
|
||||
$form['filesize_gt'] = $this->registry->output->formDropdown( 'filesize_gt', $gt_array, isset($_POST['filesize_gt']) ? $_POST['filesize_gt'] : '' );
|
||||
$form['filesize'] = $this->registry->output->formSimpleInput( 'filesize', isset($_POST['filesize']) ? $_POST['filesize'] : '', 10 );
|
||||
$form['days_gt'] = $this->registry->output->formDropdown( 'days_gt', $gt_array, isset($_POST['days_gt']) ? $_POST['days_gt'] : '' );
|
||||
$form['days'] = $this->registry->output->formSimpleInput( 'days', isset($_POST['days']) ? $_POST['days'] : '', 10 );
|
||||
$form['hits_gt'] = $this->registry->output->formDropdown( 'hits_gt', $gt_array, isset($_POST['hits_gt']) ? $_POST['hits_gt'] : '' );
|
||||
$form['hits'] = $this->registry->output->formSimpleInput( 'hits', isset($_POST['hits']) ? $_POST['hits'] : '', 10 );
|
||||
$form['filename'] = $this->registry->output->formInput( 'filename', isset($_POST['filename']) ? $_POST['filename'] : '' );
|
||||
$form['authorname'] = $this->registry->output->formInput( 'authorname', isset($_POST['authorname']) ? $_POST['authorname'] : '' );
|
||||
$form['onlyimage'] = $this->registry->output->formYesNo( 'onlyimage', isset($_POST['onlyimage']) ? $_POST['onlyimage'] : '' );
|
||||
$form['orderby'] = $this->registry->output->formDropdown( 'orderby', array( 0 => array( 'date' , $this->lang->words['se_odate'] ),
|
||||
1 => array( 'hits' , $this->lang->words['se_oviews'] ),
|
||||
2 => array( 'filesize', $this->lang->words['se_osize'] ),
|
||||
3 => array( 'file' , $this->lang->words['se_oname'] ),
|
||||
), isset($_POST['orderby']) ? $_POST['orderby'] : '' );
|
||||
$form['sort'] = $this->registry->output->formDropdown( 'sort' , array( 0 => array( 'desc' , $this->lang->words['se_odsc'] ),
|
||||
1 => array( 'asc' , $this->lang->words['se_oasc'] ),
|
||||
), isset($_POST['sort']) ? $_POST['sort'] : '' );
|
||||
$form['show'] = $this->registry->output->formSimpleInput( 'show', isset($_POST['show']) ? $_POST['show'] : 25, 10 );
|
||||
|
||||
|
||||
$this->registry->output->html .= $this->html->attachmentSearchForm( $form );
|
||||
|
||||
}
|
||||
|
||||
<?php
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.3.4
|
||||
* Attachments: Search
|
||||
* Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/company/standards.php#license
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Mon 24th May 2004
|
||||
* @version $Rev: 10914 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_ACP' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class admin_forums_attachments_search extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* Skin object
|
||||
*
|
||||
* @var object Skin templates
|
||||
*/
|
||||
protected $html;
|
||||
|
||||
/**
|
||||
* Shortcut for url
|
||||
*
|
||||
* @var string URL shortcut
|
||||
*/
|
||||
protected $form_code;
|
||||
|
||||
/**
|
||||
* Shortcut for url (javascript)
|
||||
*
|
||||
* @var string JS URL shortcut
|
||||
*/
|
||||
protected $form_code_js;
|
||||
|
||||
/**
|
||||
* Main class entry point
|
||||
*
|
||||
* @param object ipsRegistry reference
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Load HTML and language bits
|
||||
//-----------------------------------------
|
||||
$this->html = $this->registry->output->loadTemplate( 'cp_skin_attachments' );
|
||||
$this->lang->loadLanguageFile( array( 'admin_attachments' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Set up stuff
|
||||
//-----------------------------------------
|
||||
|
||||
$this->form_code = $this->html->form_code = 'module=attachments&section=search';
|
||||
$this->form_code_js = $this->html->form_code_js = 'module=attachments§ion=search';
|
||||
|
||||
//-----------------------------------------
|
||||
// StRT!
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'attach_search_complete':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'view_attachments' );
|
||||
$this->_searchResults();
|
||||
break;
|
||||
|
||||
case 'attach_bulk_remove':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'remove_attachments' );
|
||||
$this->_bulkRemoveAttachments();
|
||||
break;
|
||||
|
||||
case 'overview':
|
||||
case 'search':
|
||||
default:
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'view_attachments' );
|
||||
$this->_searchForm();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk remove attachments
|
||||
*
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
protected function _bulkRemoveAttachments()
|
||||
{
|
||||
foreach ( $_POST as $key => $value )
|
||||
{
|
||||
if ( preg_match( "/^attach_(\d+)$/", $key, $match ) )
|
||||
{
|
||||
if ( $this->request[ $match[0] ] )
|
||||
{
|
||||
$ids[] = $match[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ids = IPSLib::cleanIntArray( $ids );
|
||||
$attach_tid = array();
|
||||
|
||||
if ( count( $ids ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get attach details?
|
||||
//-----------------------------------------
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "a.attach_rel_id > 0 AND a.attach_id IN(" . implode( ",", $ids ) . ")",
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.pid, p.topic_id',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => "p.pid=a.attach_rel_id AND attach_rel_module='post'",
|
||||
'type' => 'left',
|
||||
),
|
||||
)
|
||||
) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $killmeh = $this->DB->fetch() )
|
||||
{
|
||||
if ( $killmeh['attach_location'] )
|
||||
{
|
||||
@unlink( $this->settings['upload_dir'] . "/" . $killmeh['attach_location'] );
|
||||
}
|
||||
|
||||
if ( $killmeh['attach_thumb_location'] )
|
||||
{
|
||||
@unlink( $this->settings['upload_dir'] . "/" . $killmeh['attach_thumb_location'] );
|
||||
}
|
||||
|
||||
$attach_tid[ $killmeh['topic_id'] ] = $killmeh['topic_id'];
|
||||
}
|
||||
|
||||
$this->DB->delete( 'attachments', "attach_id IN(" . implode( ",", $ids ) . ")" );
|
||||
|
||||
$this->registry->adminFunctions->saveAdminLog( sprintf( $this->lang->words['deleted_attachments'], implode( ",", $ids ) ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Recount topic upload marker
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPSLib::getAppDir('forums') . '/sources/classes/post/classPost.php' );/*noLibHook*/
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/post/classPostForms.php', 'classPostForms', 'forums' );
|
||||
|
||||
$postlib = new $classToLoad( $this->registry );
|
||||
|
||||
foreach( $attach_tid as $tid )
|
||||
{
|
||||
if( $tid )
|
||||
{
|
||||
$postlib->recountTopicAttachments( $tid );
|
||||
}
|
||||
}
|
||||
|
||||
$this->registry->output->global_message = $this->lang->words['attachments_removed'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['noattach_to_remove'];
|
||||
}
|
||||
|
||||
if ( $this->request['return'] == 'stats' )
|
||||
{
|
||||
$this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . 'module=attachments§ion=stats' );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $_POST['url'] )
|
||||
{
|
||||
foreach( explode( '&', $_POST['url'] ) as $u )
|
||||
{
|
||||
list ( $k, $v ) = explode( '=', $u );
|
||||
|
||||
$this->request[ $k] = $v ;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_searchResults();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attachment search results
|
||||
*
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
protected function _searchResults()
|
||||
{
|
||||
$show = intval($this->request['show']);
|
||||
$show = $show > 100 ? 100 : $show;
|
||||
|
||||
//-----------------------------------------
|
||||
// Build URL
|
||||
//-----------------------------------------
|
||||
|
||||
$url = "";
|
||||
$url_components = array( 'extension', 'filesize', 'filesize_gt', 'days', 'days_gt', 'hits', 'hits_gt', 'filename', 'authorname', 'onlyimage', 'orderby', 'sort', 'show' );
|
||||
|
||||
foreach( $url_components as $u )
|
||||
{
|
||||
$url .= $u . '=' . $this->request[ $u ] . '&';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Build Query
|
||||
//-----------------------------------------
|
||||
|
||||
$queryfinal = "";
|
||||
$query = array();
|
||||
|
||||
if ( $this->request['extension'] )
|
||||
{
|
||||
$query[] = 'a.attach_ext="' . strtolower( str_replace( ".", "", $this->request['extension'] ) ) . '"';
|
||||
}
|
||||
|
||||
if ( $this->request['filesize'] )
|
||||
{
|
||||
$gt = $this->request['filesize_gt'] == 'gt' ? '>=' : '<';
|
||||
|
||||
$query[] = "a.attach_filesize {$gt} " . intval( $this->request['filesize']*1024 );
|
||||
}
|
||||
|
||||
if ( $this->request['days'] )
|
||||
{
|
||||
$day_break = time() - intval( $this->request['days'] * 86400 );
|
||||
|
||||
$gt = $this->request['days_gt'] == 'lt' ? '>=' : '<';
|
||||
|
||||
$query[] = "a.attach_date {$gt} {$day_break}";
|
||||
}
|
||||
|
||||
if ( $this->request['hits'] )
|
||||
{
|
||||
$gt = $this->request['hits_gt'] == 'gt' ? '>=' : '<';
|
||||
|
||||
$query[] = "a.attach_hits {$gt} " . intval($this->request['hits']);
|
||||
}
|
||||
|
||||
if ( $this->request['filename'] )
|
||||
{
|
||||
$query[] = $this->DB->buildLower('a.attach_file') . ' LIKE "%' . strtolower( $this->request['filename'] ) . '%"';
|
||||
}
|
||||
|
||||
if ( $this->request['authorname'] )
|
||||
{
|
||||
$query[] = $this->DB->buildLower('p.author_name') . ' LIKE "%' . strtolower( $this->request['authorname'] ) . '%"';
|
||||
}
|
||||
|
||||
if ( $this->request['onlyimage'] )
|
||||
{
|
||||
$query[] = 'a.attach_is_image=1';
|
||||
}
|
||||
|
||||
if ( count($query) )
|
||||
{
|
||||
$queryfinal = 'AND '. implode( " AND ", $query );
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
|
||||
$this->DB->build( array( 'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'".$queryfinal,
|
||||
'add_join' => array(
|
||||
0 => array( 'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left' ),
|
||||
1 => array( 'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left' ),
|
||||
2 => array( 'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left' )
|
||||
),
|
||||
'order' => "a.attach_" . $this->request['orderby'] . " " . $this->request['sort'],
|
||||
'limit' => array( 0, $show ) ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat($r['attach_filesize']);
|
||||
$r['attach_date'] = ipsRegistry::getClass( 'class_localization')->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
$rows[] = $r;
|
||||
}
|
||||
|
||||
$this->registry->output->html .= $this->html->attachmentSearchResults( $url, $rows );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show attachment search form
|
||||
*
|
||||
* @return @e void [Outputs to screen]
|
||||
*/
|
||||
protected function _searchForm()
|
||||
{
|
||||
$gt_array = array( 0 => array( 'gt', $this->lang->words['se_morethan'] ), 1 => array( 'lt', $this->lang->words['se_lessthan'] ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// FORM
|
||||
//-----------------------------------------
|
||||
|
||||
$form['extension'] = $this->registry->output->formSimpleInput( 'extension', isset($_POST['extension']) ? $_POST['extension'] : '', 10 );
|
||||
$form['filesize_gt'] = $this->registry->output->formDropdown( 'filesize_gt', $gt_array, isset($_POST['filesize_gt']) ? $_POST['filesize_gt'] : '' );
|
||||
$form['filesize'] = $this->registry->output->formSimpleInput( 'filesize', isset($_POST['filesize']) ? $_POST['filesize'] : '', 10 );
|
||||
$form['days_gt'] = $this->registry->output->formDropdown( 'days_gt', $gt_array, isset($_POST['days_gt']) ? $_POST['days_gt'] : '' );
|
||||
$form['days'] = $this->registry->output->formSimpleInput( 'days', isset($_POST['days']) ? $_POST['days'] : '', 10 );
|
||||
$form['hits_gt'] = $this->registry->output->formDropdown( 'hits_gt', $gt_array, isset($_POST['hits_gt']) ? $_POST['hits_gt'] : '' );
|
||||
$form['hits'] = $this->registry->output->formSimpleInput( 'hits', isset($_POST['hits']) ? $_POST['hits'] : '', 10 );
|
||||
$form['filename'] = $this->registry->output->formInput( 'filename', isset($_POST['filename']) ? $_POST['filename'] : '' );
|
||||
$form['authorname'] = $this->registry->output->formInput( 'authorname', isset($_POST['authorname']) ? $_POST['authorname'] : '' );
|
||||
$form['onlyimage'] = $this->registry->output->formYesNo( 'onlyimage', isset($_POST['onlyimage']) ? $_POST['onlyimage'] : '' );
|
||||
$form['orderby'] = $this->registry->output->formDropdown( 'orderby', array( 0 => array( 'date' , $this->lang->words['se_odate'] ),
|
||||
1 => array( 'hits' , $this->lang->words['se_oviews'] ),
|
||||
2 => array( 'filesize', $this->lang->words['se_osize'] ),
|
||||
3 => array( 'file' , $this->lang->words['se_oname'] ),
|
||||
), isset($_POST['orderby']) ? $_POST['orderby'] : '' );
|
||||
$form['sort'] = $this->registry->output->formDropdown( 'sort' , array( 0 => array( 'desc' , $this->lang->words['se_odsc'] ),
|
||||
1 => array( 'asc' , $this->lang->words['se_oasc'] ),
|
||||
), isset($_POST['sort']) ? $_POST['sort'] : '' );
|
||||
$form['show'] = $this->registry->output->formSimpleInput( 'show', isset($_POST['show']) ? $_POST['show'] : 25, 10 );
|
||||
|
||||
|
||||
$this->registry->output->html .= $this->html->attachmentSearchForm( $form );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,233 +1,233 @@
|
||||
<?php
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.2.3
|
||||
* Attachments: Stats
|
||||
* Last Updated: $LastChangedDate: 2011-05-05 07:03:47 -0400 (Thu, 05 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: ips_terabyte $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://hatynka.in
|
||||
* @since Mon 24th May 2004
|
||||
* @version $Rev: 8644 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_ACP' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class admin_forums_attachments_stats extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* HTML object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $html;
|
||||
|
||||
/**
|
||||
* Main execution point
|
||||
*
|
||||
* @param object ipsRegistry reference
|
||||
* @return @e void
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
/* Load Skin and Lang */
|
||||
$this->html = $this->registry->output->loadTemplate( 'cp_skin_attachments' );
|
||||
$this->html->form_code = 'module=attachments&section=stats&';
|
||||
$this->html->form_code_js = 'module=attachments&section=stats&';
|
||||
|
||||
$this->lang->loadLanguageFile( array( 'admin_attachments' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// StRT!
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'overview':
|
||||
case 'stats':
|
||||
default:
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'stats_attachments' );
|
||||
$this->attachmentStatsOverview();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows attachment statistics
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentStatsOverview()
|
||||
{
|
||||
/* Get attachment Types */
|
||||
$cache['attachtypes'] = array();
|
||||
|
||||
$this->DB->build( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_img', 'from' => 'attachments_type', 'where' => "atype_post=1" ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$cache['attachtypes'][ $r['atype_extension'] ] = $r;
|
||||
}
|
||||
|
||||
$stats = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count, sum(attach_filesize) as sum', 'from' => 'attachments', 'where' => 'attach_rel_module=\'post\'' ) );
|
||||
|
||||
/* Overall Stats */
|
||||
$overall_stats = array( 'total_attachments' => $this->registry->class_localization->formatNumber( $stats['count'] ), 'total_size' => IPSLib::sizeFormat( $stats['sum'] ) );
|
||||
|
||||
/* Last 5 Attachments */
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'",
|
||||
'order' => "a.attach_date DESC",
|
||||
'limit' => array( 0, 5 ),
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left'
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the last 5 */
|
||||
$last_5 = array();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
/* Format Fields */
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['_icon'] = $this->settings['mime_img'] . '/' . $cache['attachtypes'][ $r['attach_ext'] ]['atype_img'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat( $r['attach_filesize'] );
|
||||
$r['post_date'] = $this->registry->class_localization->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
/* Add to output array */
|
||||
$last_5[] = $r;
|
||||
}
|
||||
|
||||
/* Largest 5 Attachments */
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'",
|
||||
'order' => "a.attach_filesize DESC",
|
||||
'limit' => array( 0, 5 ),
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left'
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the last 5 */
|
||||
$largest_5 = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
/* Format Fields */
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['_icon'] = $this->settings['mime_img'] . '/' . $cache['attachtypes'][ $r['attach_ext'] ]['atype_img'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat( $r['attach_filesize'] );
|
||||
$r['post_date'] = $this->registry->class_localization->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
/* Add to output array */
|
||||
$largest_5[] = $r;
|
||||
}
|
||||
|
||||
/* 5 Most Viewed Downloads */
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'",
|
||||
'order' => "a.attach_hits DESC",
|
||||
'limit' => array( 0, 5 ),
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left'
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the last 5 */
|
||||
$most_viewed_5 = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
/* Format Fields */
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['_icon'] = $this->settings['mime_img'] . '/' . $cache['attachtypes'][ $r['attach_ext'] ]['atype_img'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat( $r['attach_filesize'] );
|
||||
$r['post_date'] = $this->registry->class_localization->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
/* Add to output array */
|
||||
$most_viewed_5[] = $r;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html .= $this->html->attachmentStats( $overall_stats, $last_5, $largest_5, $most_viewed_5 );
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.3.4
|
||||
* Attachments: Stats
|
||||
* Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/company/standards.php#license
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Mon 24th May 2004
|
||||
* @version $Rev: 10914 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_ACP' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class admin_forums_attachments_stats extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* HTML object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $html;
|
||||
|
||||
/**
|
||||
* Main execution point
|
||||
*
|
||||
* @param object ipsRegistry reference
|
||||
* @return @e void
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
/* Load Skin and Lang */
|
||||
$this->html = $this->registry->output->loadTemplate( 'cp_skin_attachments' );
|
||||
$this->html->form_code = 'module=attachments&section=stats&';
|
||||
$this->html->form_code_js = 'module=attachments&section=stats&';
|
||||
|
||||
$this->lang->loadLanguageFile( array( 'admin_attachments' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// StRT!
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'overview':
|
||||
case 'stats':
|
||||
default:
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'stats_attachments' );
|
||||
$this->attachmentStatsOverview();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows attachment statistics
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentStatsOverview()
|
||||
{
|
||||
/* Get attachment Types */
|
||||
$cache['attachtypes'] = array();
|
||||
|
||||
$this->DB->build( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_img', 'from' => 'attachments_type', 'where' => "atype_post=1" ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$cache['attachtypes'][ $r['atype_extension'] ] = $r;
|
||||
}
|
||||
|
||||
$stats = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count, sum(attach_filesize) as sum', 'from' => 'attachments', 'where' => 'attach_rel_module=\'post\'' ) );
|
||||
|
||||
/* Overall Stats */
|
||||
$overall_stats = array( 'total_attachments' => $this->registry->class_localization->formatNumber( $stats['count'] ), 'total_size' => IPSLib::sizeFormat( $stats['sum'] ) );
|
||||
|
||||
/* Last 5 Attachments */
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'",
|
||||
'order' => "a.attach_date DESC",
|
||||
'limit' => array( 0, 5 ),
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left'
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the last 5 */
|
||||
$last_5 = array();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
/* Format Fields */
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['_icon'] = $this->settings['mime_img'] . '/' . $cache['attachtypes'][ $r['attach_ext'] ]['atype_img'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat( $r['attach_filesize'] );
|
||||
$r['post_date'] = $this->registry->class_localization->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
/* Add to output array */
|
||||
$last_5[] = $r;
|
||||
}
|
||||
|
||||
/* Largest 5 Attachments */
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'",
|
||||
'order' => "a.attach_filesize DESC",
|
||||
'limit' => array( 0, 5 ),
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left'
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the last 5 */
|
||||
$largest_5 = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
/* Format Fields */
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['_icon'] = $this->settings['mime_img'] . '/' . $cache['attachtypes'][ $r['attach_ext'] ]['atype_img'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat( $r['attach_filesize'] );
|
||||
$r['post_date'] = $this->registry->class_localization->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
/* Add to output array */
|
||||
$largest_5[] = $r;
|
||||
}
|
||||
|
||||
/* 5 Most Viewed Downloads */
|
||||
$this->DB->build( array(
|
||||
'select' => 'a.*',
|
||||
'from' => array( 'attachments' => 'a' ),
|
||||
'where' => "attach_rel_module='post'",
|
||||
'order' => "a.attach_hits DESC",
|
||||
'limit' => array( 0, 5 ),
|
||||
'add_join' => array(
|
||||
array(
|
||||
'select' => 'p.author_id, p.author_name, p.post_date',
|
||||
'from' => array( 'posts' => 'p' ),
|
||||
'where' => 'p.pid=a.attach_rel_id',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 't.tid, t.forum_id, t.title',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left'
|
||||
),
|
||||
array(
|
||||
'select' => 'm.members_display_name',
|
||||
'from' => array( 'members' => 'm' ),
|
||||
'where' => 'm.member_id=a.attach_member_id',
|
||||
'type' => 'left'
|
||||
)
|
||||
)
|
||||
) );
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the last 5 */
|
||||
$most_viewed_5 = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
/* Format Fields */
|
||||
$r['stitle'] = $r['title'] ? "<a href='{$this->settings['board_url']}/index.php?showtopic={$r['tid']}&view=findpost&p={$r['attach_rel_id']}' title='{$r['title']}'>" . IPSText::truncate( $r['title'], 30 ) . "</a>" : $this->lang->words['attach_not_topic'];
|
||||
$r['_icon'] = $this->settings['mime_img'] . '/' . $cache['attachtypes'][ $r['attach_ext'] ]['atype_img'];
|
||||
$r['attach_filesize'] = IPSLib::sizeFormat( $r['attach_filesize'] );
|
||||
$r['post_date'] = $this->registry->class_localization->getDate( $r['attach_date'], 'SHORT', 1 );
|
||||
|
||||
/* Add to output array */
|
||||
$most_viewed_5[] = $r;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html .= $this->html->attachmentStats( $overall_stats, $last_5, $largest_5, $most_viewed_5 );
|
||||
}
|
||||
}
|
||||
@@ -1,420 +1,420 @@
|
||||
<?php
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.2.3
|
||||
* Attachments: Manage
|
||||
* Last Updated: $LastChangedDate: 2011-06-23 12:03:27 -0400 (Thu, 23 Jun 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://hatynka.in
|
||||
* @since Mon 24th May 2004
|
||||
* @version $Rev: 9081 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_ACP' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class admin_forums_attachments_types extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* HTML object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $html;
|
||||
|
||||
/**
|
||||
* Main execution point
|
||||
*
|
||||
* @param object ipsRegistry reference
|
||||
* @return @e void
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
/* Load Skin and Lang */
|
||||
$this->html = $this->registry->output->loadTemplate( 'cp_skin_attachments' );
|
||||
$this->html->form_code = 'module=attachments&section=types&';
|
||||
$this->html->form_code_js = 'module=attachments&section=types&';
|
||||
|
||||
$this->lang->loadLanguageFile( array( 'admin_attachments' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// StRT!
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'attach_add':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_add' );
|
||||
$this->attachmentTypeForm('add');
|
||||
break;
|
||||
|
||||
case 'attach_doadd':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_add' );
|
||||
$this->attachmentTypeSave('add');
|
||||
break;
|
||||
|
||||
case 'attach_edit':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_edit' );
|
||||
$this->attachmentTypeForm('edit');
|
||||
break;
|
||||
|
||||
case 'attach_delete':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_delete' );
|
||||
$this->attachmentTypeDelete();
|
||||
break;
|
||||
|
||||
case 'attach_doedit':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_edit' );
|
||||
$this->attachmentTypeSave('edit');
|
||||
break;
|
||||
|
||||
case 'attach_export':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_export' );
|
||||
$this->attachmentTypeExport();
|
||||
break;
|
||||
|
||||
case 'attach_import':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_import' );
|
||||
$this->attachmentTypeImport();
|
||||
break;
|
||||
|
||||
case 'overview':
|
||||
default:
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_view' );
|
||||
$this->attachmentTypesOverview();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports attachment types from an xml document
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeImport()
|
||||
{
|
||||
/* Get the XML Content */
|
||||
$content = $this->registry->adminFunctions->importXml( 'ipb_attachtypes.xml' );
|
||||
|
||||
/* Check to make sure we have content */
|
||||
if ( ! $content )
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['ty_failed'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/* Get the XML class */
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
$xml->loadXML( $content );
|
||||
|
||||
/* Get a list of the types already installed */
|
||||
$types = array();
|
||||
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'attachments_type', 'order' => "atype_extension" ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$types[ $r['atype_extension'] ] = 1;
|
||||
}
|
||||
|
||||
/* Loop through the xml document and insert new types */
|
||||
foreach( $xml->fetchElements('attachtype') as $record )
|
||||
{
|
||||
$entry = $xml->fetchElementsFromRecord( $record );
|
||||
|
||||
/* Build the insert array */
|
||||
$insert_array = array( 'atype_extension' => $entry['atype_extension'],
|
||||
'atype_mimetype' => $entry['atype_mimetype'],
|
||||
'atype_post' => $entry['atype_post'],
|
||||
'atype_img' => $entry['atype_img']
|
||||
);
|
||||
|
||||
/* Bypass if this type has already been added */
|
||||
if ( $types[ $entry['atype_extension'] ] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Insert the new type */
|
||||
if ( $entry['atype_extension'] and $entry['atype_mimetype'] )
|
||||
{
|
||||
$this->DB->insert( 'attachments_type', $insert_array );
|
||||
}
|
||||
}
|
||||
|
||||
/* Rebuild the cache and bounce */
|
||||
$this->attachmentTypeCacheRebuild();
|
||||
|
||||
$this->registry->output->global_message = $this->lang->words['ty_imported'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the attachment type xml export
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeExport()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get xml class
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
$xml->newXMLDocument();
|
||||
$xml->addElement( 'attachtypesexport' );
|
||||
$xml->addElement( 'attachtypesgroup', 'attachtypesexport' );
|
||||
|
||||
/* Query the attachment Types */
|
||||
$this->DB->build( array(
|
||||
'select' => 'atype_extension,atype_mimetype,atype_post,atype_img',
|
||||
'from' => 'attachments_type',
|
||||
'order' => "atype_extension"
|
||||
) );
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the types */
|
||||
$entry = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$xml->addElementAsRecord( 'attachtypesgroup', 'attachtype', $r );
|
||||
}
|
||||
|
||||
/* Send for download */
|
||||
$this->registry->output->showDownload( $xml->fetchDocument(), 'attachments.xml', "unknown/unknown", false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified attachment type
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeDelete()
|
||||
{
|
||||
/* INI */
|
||||
$this->request[ 'id'] = intval( $this->request['id'] );
|
||||
|
||||
/* Delete the type */
|
||||
$this->DB->delete( 'attachments_type', "atype_id={$this->request['id']}" );
|
||||
|
||||
/* Build the cache and Bounce */
|
||||
$this->attachmentTypeCacheRebuild();
|
||||
|
||||
$this->registry->output->global_message = $this->lang->words['ty_deleted'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the from for adding/editing attachments
|
||||
*
|
||||
* @param string $type Either add or edit
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeSave( $type='add' )
|
||||
{
|
||||
/* INI */
|
||||
$this->request['id'] = intval( $this->request['id'] );
|
||||
|
||||
/* Make sure the form was filled out */
|
||||
if ( ! $this->request['atype_extension'] or ! $this->request['atype_mimetype'] )
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['ty_enterinfo'];
|
||||
$this->attachmentTypeForm( $type );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Build the save array */
|
||||
$save_array = array( 'atype_extension' => str_replace( ".", "", $this->request['atype_extension'] ),
|
||||
'atype_mimetype' => trim( $this->request['atype_mimetype'] ),
|
||||
'atype_post' => trim( $this->request['atype_post'] ),
|
||||
'atype_img' => trim( $this->request['atype_img'] ) );
|
||||
|
||||
/* Add attachment type to the database */
|
||||
if ( $type == 'add' )
|
||||
{
|
||||
/* Check to see if this attachment type already exists */
|
||||
$attach = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'attachments_type', 'where' => "atype_extension='".$save_array['atype_extension']."'" ) );
|
||||
|
||||
if ( $attach['atype_id'] )
|
||||
{
|
||||
$this->registry->output->global_message = sprintf( $this->lang->words['ty_already'], $save_array['atype_extension'] );
|
||||
$this->attachmentTypeForm($type);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Insert the attachment type */
|
||||
$this->DB->insert( 'attachments_type', $save_array );
|
||||
|
||||
/* Done Message */
|
||||
$this->registry->output->global_message = $this->lang->words['ty_added'];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update the attachment type */
|
||||
$this->DB->update( 'attachments_type', $save_array, 'atype_id=' . $this->request['id'] );
|
||||
|
||||
/* Done Message */
|
||||
$this->registry->output->global_message = $this->lang->words['ty_edited'];
|
||||
}
|
||||
|
||||
/* Cache and Bounce */
|
||||
$this->attachmentTypeCacheRebuild();
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the form for adding/editing attachment types
|
||||
*
|
||||
* @param string $type Either add or edit
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeForm( $type='add' )
|
||||
{
|
||||
/* INI */
|
||||
$this->request['id'] = $this->request['id'] ? intval( $this->request['id'] ) : 0;
|
||||
$this->request['baseon'] = $this->request['baseon'] ? intval( $this->request['baseon'] ) : 0;
|
||||
|
||||
/* Navigation */
|
||||
$this->registry->output->nav[] = array( '', $this->lang->words['ty_addedit'] );
|
||||
|
||||
$baseon = '';
|
||||
|
||||
if( $type == 'add' )
|
||||
{
|
||||
/* Setup */
|
||||
$code = 'attach_doadd';
|
||||
$button = $this->lang->words['ty_addnew'];
|
||||
$id = 0;
|
||||
|
||||
/* Default Data */
|
||||
if( $this->request['baseon'] )
|
||||
{
|
||||
$attach = $this->DB->buildAndFetch( array(
|
||||
'select' => '*',
|
||||
'from' => 'attachments_type',
|
||||
'where' => 'atype_id=' . $this->request['baseon']
|
||||
) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$attach = array( 'atype_extension' => '',
|
||||
'atype_mimetype' => '',
|
||||
'atype_post' => '',
|
||||
'atype_img' => '' );
|
||||
}
|
||||
|
||||
/* Generate Based On Dropdown*/
|
||||
$dd = array();
|
||||
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'attachments_type', 'order' => 'atype_extension' ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$dd[] = array( $r['atype_id'], $this->lang->words['ty_baseon'] . $r['atype_extension'] );
|
||||
}
|
||||
|
||||
$title = $button;
|
||||
$baseon = $this->html->attachmentTypeBaseOn( $this->registry->output->formDropdown( 'baseon', $dd ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Setup */
|
||||
$code = 'attach_doedit';
|
||||
$button = $this->lang->words['ty_edit'];
|
||||
$title = $button;
|
||||
$id = intval( $this->request['id'] );
|
||||
|
||||
/* Default Data */
|
||||
$attach = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'attachments_type', 'where' => 'atype_id='.ipsRegistry::$request['id'] ) );
|
||||
|
||||
/* Check for valid id */
|
||||
if ( ! $attach['atype_id'] )
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['ty_noid'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
}
|
||||
|
||||
/* Form Elements */
|
||||
$form = array(
|
||||
'atype_extension' => $this->registry->output->formSimpleInput( 'atype_extension', !empty( $this->request['atype_extension'] ) ? $this->request['atype_extension'] : $attach['atype_extension'], 10 ),
|
||||
'atype_mimetype' => $this->registry->output->formSimpleInput( 'atype_mimetype' , !empty( $this->request['atype_mimetype'] ) ? $this->request['atype_mimetype'] : $attach['atype_mimetype'] , 40 ),
|
||||
'atype_post' => $this->registry->output->formYesNo( 'atype_post' , !empty( $this->request['atype_post'] ) ? $this->request['atype_post'] : $attach['atype_post'] ),
|
||||
'atype_img' => $this->registry->output->formSimpleInput( 'atype_img' , !empty( $this->request['atype_img'] ) ? $this->request['atype_img'] : $attach['atype_img'] , 40 ),
|
||||
);
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html .= $this->html->attachmentTypeForm( $title, $code, $id, $form, $button, $baseon );
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the attachment types that have been setup
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypesOverview()
|
||||
{
|
||||
/* Get the attachments */
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'attachments_type', 'order' => 'atype_extension' ) );
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the attachments */
|
||||
$attach_rows = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$r['_imagedir'] = $this->registry->output->skin['set_image_dir'];
|
||||
|
||||
$r['apost_checked'] = $r['atype_post'] ? "<img src='{$this->settings['skin_acp_url']}/images/icons/tick.png' alt='{$this->lang->words['yesno_yes']}' />" : "<img src='{$this->settings['skin_acp_url']}/images/icons/cross.png' alt='{$this->lang->words['yesno_no']}' />";
|
||||
|
||||
$attach_rows[] = $r;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html .= $this->html->attachmentTypeOverview( $attach_rows );
|
||||
}
|
||||
|
||||
/*
|
||||
* Rebuilds the attachment type cache
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeCacheRebuild()
|
||||
{
|
||||
$cache = array();
|
||||
|
||||
$this->DB->build( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_img', 'from' => 'attachments_type', 'where' => "atype_post=1" ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$r['atype_extension'] = strtolower( $r['atype_extension'] );
|
||||
$cache[ $r['atype_extension'] ] = $r;
|
||||
}
|
||||
|
||||
$this->cache->setCache( 'attachtypes', $cache, array( 'array' => 1, 'donow' => 0 ) );
|
||||
}
|
||||
<?php
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.3.4
|
||||
* Attachments: Manage
|
||||
* Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/company/standards.php#license
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Mon 24th May 2004
|
||||
* @version $Rev: 10914 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_ACP' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class admin_forums_attachments_types extends ipsCommand
|
||||
{
|
||||
/**
|
||||
* HTML object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $html;
|
||||
|
||||
/**
|
||||
* Main execution point
|
||||
*
|
||||
* @param object ipsRegistry reference
|
||||
* @return @e void
|
||||
*/
|
||||
public function doExecute( ipsRegistry $registry )
|
||||
{
|
||||
/* Load Skin and Lang */
|
||||
$this->html = $this->registry->output->loadTemplate( 'cp_skin_attachments' );
|
||||
$this->html->form_code = 'module=attachments&section=types&';
|
||||
$this->html->form_code_js = 'module=attachments&section=types&';
|
||||
|
||||
$this->lang->loadLanguageFile( array( 'admin_attachments' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// StRT!
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $this->request['do'] )
|
||||
{
|
||||
case 'attach_add':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_add' );
|
||||
$this->attachmentTypeForm('add');
|
||||
break;
|
||||
|
||||
case 'attach_doadd':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_add' );
|
||||
$this->attachmentTypeSave('add');
|
||||
break;
|
||||
|
||||
case 'attach_edit':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_edit' );
|
||||
$this->attachmentTypeForm('edit');
|
||||
break;
|
||||
|
||||
case 'attach_delete':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_delete' );
|
||||
$this->attachmentTypeDelete();
|
||||
break;
|
||||
|
||||
case 'attach_doedit':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_edit' );
|
||||
$this->attachmentTypeSave('edit');
|
||||
break;
|
||||
|
||||
case 'attach_export':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_export' );
|
||||
$this->attachmentTypeExport();
|
||||
break;
|
||||
|
||||
case 'attach_import':
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_import' );
|
||||
$this->attachmentTypeImport();
|
||||
break;
|
||||
|
||||
case 'overview':
|
||||
default:
|
||||
$this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'mime_view' );
|
||||
$this->attachmentTypesOverview();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
|
||||
$this->registry->output->sendOutput();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports attachment types from an xml document
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeImport()
|
||||
{
|
||||
/* Get the XML Content */
|
||||
$content = $this->registry->adminFunctions->importXml( 'ipb_attachtypes.xml' );
|
||||
|
||||
/* Check to make sure we have content */
|
||||
if ( ! $content )
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['ty_failed'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/* Get the XML class */
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
$xml->loadXML( $content );
|
||||
|
||||
/* Get a list of the types already installed */
|
||||
$types = array();
|
||||
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'attachments_type', 'order' => "atype_extension" ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$types[ $r['atype_extension'] ] = 1;
|
||||
}
|
||||
|
||||
/* Loop through the xml document and insert new types */
|
||||
foreach( $xml->fetchElements('attachtype') as $record )
|
||||
{
|
||||
$entry = $xml->fetchElementsFromRecord( $record );
|
||||
|
||||
/* Build the insert array */
|
||||
$insert_array = array( 'atype_extension' => $entry['atype_extension'],
|
||||
'atype_mimetype' => $entry['atype_mimetype'],
|
||||
'atype_post' => $entry['atype_post'],
|
||||
'atype_img' => $entry['atype_img']
|
||||
);
|
||||
|
||||
/* Bypass if this type has already been added */
|
||||
if ( $types[ $entry['atype_extension'] ] )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Insert the new type */
|
||||
if ( $entry['atype_extension'] and $entry['atype_mimetype'] )
|
||||
{
|
||||
$this->DB->insert( 'attachments_type', $insert_array );
|
||||
}
|
||||
}
|
||||
|
||||
/* Rebuild the cache and bounce */
|
||||
$this->attachmentTypeCacheRebuild();
|
||||
|
||||
$this->registry->output->global_message = $this->lang->words['ty_imported'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the attachment type xml export
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeExport()
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get xml class
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
|
||||
|
||||
$xml = new classXML( IPS_DOC_CHAR_SET );
|
||||
|
||||
$xml->newXMLDocument();
|
||||
$xml->addElement( 'attachtypesexport' );
|
||||
$xml->addElement( 'attachtypesgroup', 'attachtypesexport' );
|
||||
|
||||
/* Query the attachment Types */
|
||||
$this->DB->build( array(
|
||||
'select' => 'atype_extension,atype_mimetype,atype_post,atype_img',
|
||||
'from' => 'attachments_type',
|
||||
'order' => "atype_extension"
|
||||
) );
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the types */
|
||||
$entry = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$xml->addElementAsRecord( 'attachtypesgroup', 'attachtype', $r );
|
||||
}
|
||||
|
||||
/* Send for download */
|
||||
$this->registry->output->showDownload( $xml->fetchDocument(), 'attachments.xml', "unknown/unknown", false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified attachment type
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeDelete()
|
||||
{
|
||||
/* INI */
|
||||
$this->request[ 'id'] = intval( $this->request['id'] );
|
||||
|
||||
/* Delete the type */
|
||||
$this->DB->delete( 'attachments_type', "atype_id={$this->request['id']}" );
|
||||
|
||||
/* Build the cache and Bounce */
|
||||
$this->attachmentTypeCacheRebuild();
|
||||
|
||||
$this->registry->output->global_message = $this->lang->words['ty_deleted'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the from for adding/editing attachments
|
||||
*
|
||||
* @param string $type Either add or edit
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeSave( $type='add' )
|
||||
{
|
||||
/* INI */
|
||||
$this->request['id'] = intval( $this->request['id'] );
|
||||
|
||||
/* Make sure the form was filled out */
|
||||
if ( ! $this->request['atype_extension'] or ! $this->request['atype_mimetype'] )
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['ty_enterinfo'];
|
||||
$this->attachmentTypeForm( $type );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Build the save array */
|
||||
$save_array = array( 'atype_extension' => str_replace( ".", "", $this->request['atype_extension'] ),
|
||||
'atype_mimetype' => trim( $this->request['atype_mimetype'] ),
|
||||
'atype_post' => trim( $this->request['atype_post'] ),
|
||||
'atype_img' => trim( $this->request['atype_img'] ) );
|
||||
|
||||
/* Add attachment type to the database */
|
||||
if ( $type == 'add' )
|
||||
{
|
||||
/* Check to see if this attachment type already exists */
|
||||
$attach = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'attachments_type', 'where' => "atype_extension='".$save_array['atype_extension']."'" ) );
|
||||
|
||||
if ( $attach['atype_id'] )
|
||||
{
|
||||
$this->registry->output->global_message = sprintf( $this->lang->words['ty_already'], $save_array['atype_extension'] );
|
||||
$this->attachmentTypeForm($type);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Insert the attachment type */
|
||||
$this->DB->insert( 'attachments_type', $save_array );
|
||||
|
||||
/* Done Message */
|
||||
$this->registry->output->global_message = $this->lang->words['ty_added'];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Update the attachment type */
|
||||
$this->DB->update( 'attachments_type', $save_array, 'atype_id=' . $this->request['id'] );
|
||||
|
||||
/* Done Message */
|
||||
$this->registry->output->global_message = $this->lang->words['ty_edited'];
|
||||
}
|
||||
|
||||
/* Cache and Bounce */
|
||||
$this->attachmentTypeCacheRebuild();
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the form for adding/editing attachment types
|
||||
*
|
||||
* @param string $type Either add or edit
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeForm( $type='add' )
|
||||
{
|
||||
/* INI */
|
||||
$this->request['id'] = $this->request['id'] ? intval( $this->request['id'] ) : 0;
|
||||
$this->request['baseon'] = $this->request['baseon'] ? intval( $this->request['baseon'] ) : 0;
|
||||
|
||||
/* Navigation */
|
||||
$this->registry->output->nav[] = array( '', $this->lang->words['ty_addedit'] );
|
||||
|
||||
$baseon = '';
|
||||
|
||||
if( $type == 'add' )
|
||||
{
|
||||
/* Setup */
|
||||
$code = 'attach_doadd';
|
||||
$button = $this->lang->words['ty_addnew'];
|
||||
$id = 0;
|
||||
|
||||
/* Default Data */
|
||||
if( $this->request['baseon'] )
|
||||
{
|
||||
$attach = $this->DB->buildAndFetch( array(
|
||||
'select' => '*',
|
||||
'from' => 'attachments_type',
|
||||
'where' => 'atype_id=' . $this->request['baseon']
|
||||
) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$attach = array( 'atype_extension' => '',
|
||||
'atype_mimetype' => '',
|
||||
'atype_post' => '',
|
||||
'atype_img' => '' );
|
||||
}
|
||||
|
||||
/* Generate Based On Dropdown*/
|
||||
$dd = array();
|
||||
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'attachments_type', 'order' => 'atype_extension' ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$dd[] = array( $r['atype_id'], $this->lang->words['ty_baseon'] . $r['atype_extension'] );
|
||||
}
|
||||
|
||||
$title = $button;
|
||||
$baseon = $this->html->attachmentTypeBaseOn( $this->registry->output->formDropdown( 'baseon', $dd ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Setup */
|
||||
$code = 'attach_doedit';
|
||||
$button = $this->lang->words['ty_edit'];
|
||||
$title = $button;
|
||||
$id = intval( $this->request['id'] );
|
||||
|
||||
/* Default Data */
|
||||
$attach = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'attachments_type', 'where' => 'atype_id='.ipsRegistry::$request['id'] ) );
|
||||
|
||||
/* Check for valid id */
|
||||
if ( ! $attach['atype_id'] )
|
||||
{
|
||||
$this->registry->output->global_message = $this->lang->words['ty_noid'];
|
||||
$this->attachmentTypesOverview();
|
||||
}
|
||||
}
|
||||
|
||||
/* Form Elements */
|
||||
$form = array(
|
||||
'atype_extension' => $this->registry->output->formSimpleInput( 'atype_extension', !empty( $this->request['atype_extension'] ) ? $this->request['atype_extension'] : $attach['atype_extension'], 10 ),
|
||||
'atype_mimetype' => $this->registry->output->formSimpleInput( 'atype_mimetype' , !empty( $this->request['atype_mimetype'] ) ? $this->request['atype_mimetype'] : $attach['atype_mimetype'] , 40 ),
|
||||
'atype_post' => $this->registry->output->formYesNo( 'atype_post' , !empty( $this->request['atype_post'] ) ? $this->request['atype_post'] : $attach['atype_post'] ),
|
||||
'atype_img' => $this->registry->output->formSimpleInput( 'atype_img' , !empty( $this->request['atype_img'] ) ? $this->request['atype_img'] : $attach['atype_img'] , 40 ),
|
||||
);
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html .= $this->html->attachmentTypeForm( $title, $code, $id, $form, $button, $baseon );
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the attachment types that have been setup
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypesOverview()
|
||||
{
|
||||
/* Get the attachments */
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'attachments_type', 'order' => 'atype_extension' ) );
|
||||
$this->DB->execute();
|
||||
|
||||
/* Loop through the attachments */
|
||||
$attach_rows = array();
|
||||
|
||||
while( $r = $this->DB->fetch() )
|
||||
{
|
||||
$r['_imagedir'] = $this->registry->output->skin['set_image_dir'];
|
||||
|
||||
$r['apost_checked'] = $r['atype_post'] ? "<img src='{$this->settings['skin_acp_url']}/images/icons/tick.png' alt='{$this->lang->words['yesno_yes']}' />" : "<img src='{$this->settings['skin_acp_url']}/images/icons/cross.png' alt='{$this->lang->words['yesno_no']}' />";
|
||||
|
||||
$attach_rows[] = $r;
|
||||
}
|
||||
|
||||
/* Output */
|
||||
$this->registry->output->html .= $this->html->attachmentTypeOverview( $attach_rows );
|
||||
}
|
||||
|
||||
/*
|
||||
* Rebuilds the attachment type cache
|
||||
*
|
||||
* @return @e void
|
||||
*/
|
||||
public function attachmentTypeCacheRebuild()
|
||||
{
|
||||
$cache = array();
|
||||
|
||||
$this->DB->build( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_img', 'from' => 'attachments_type', 'where' => "atype_post=1" ) );
|
||||
$this->DB->execute();
|
||||
|
||||
while ( $r = $this->DB->fetch() )
|
||||
{
|
||||
$r['atype_extension'] = strtolower( $r['atype_extension'] );
|
||||
$cache[ $r['atype_extension'] ] = $r;
|
||||
}
|
||||
|
||||
$this->cache->setCache( 'attachtypes', $cache, array( 'array' => 1, 'donow' => 0 ) );
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> Forbidden</h1>
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
<html>
|
||||
<head><title>IP.Board - Bulletin Board System</title></head>
|
||||
<body>
|
||||
<h1>403: IP.Board -> Forbidden</h1>
|
||||
<hr>
|
||||
You have reached this page in error, please use your back button to return to the forum.
|
||||
<hr>
|
||||
<a href="http://www.invisionpower.com">IP.Board</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,10 +2,10 @@
|
||||
<menu>
|
||||
<tabitems>
|
||||
<item>
|
||||
<title>Типы файлов</title>
|
||||
<title>Attachment Types</title>
|
||||
<subitems>
|
||||
<subitem>
|
||||
<subitemtitle>Типы файлов</subitemtitle>
|
||||
<subitemtitle>Attachment Types</subitemtitle>
|
||||
<subitemlang>attachment_types</subitemlang>
|
||||
<subsection>types</subsection>
|
||||
<subitemurl>do=overview</subitemurl>
|
||||
@@ -15,10 +15,10 @@
|
||||
</subitems>
|
||||
</item>
|
||||
<item>
|
||||
<title>Статистика</title>
|
||||
<title>Attachment Stats</title>
|
||||
<subitems>
|
||||
<subitem>
|
||||
<subitemtitle>Статистика</subitemtitle>
|
||||
<subitemtitle>Attachment Stats</subitemtitle>
|
||||
<subitemlang>attachment_stats</subitemlang>
|
||||
<subsection>stats</subsection>
|
||||
<subitemurl>do=overview</subitemurl>
|
||||
@@ -28,10 +28,10 @@
|
||||
</subitems>
|
||||
</item>
|
||||
<item>
|
||||
<title>Поиск</title>
|
||||
<title>Attachment Search</title>
|
||||
<subitems>
|
||||
<subitem>
|
||||
<subitemtitle>Поиск</subitemtitle>
|
||||
<subitemtitle>Attachment Search</subitemtitle>
|
||||
<subitemlang>attachment_search</subitemlang>
|
||||
<subsection>search</subsection>
|
||||
<subitemurl>do=overview</subitemurl>
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<permissions>
|
||||
<group>
|
||||
<grouptitle>Управление прикрепленными файлами</grouptitle>
|
||||
<grouptitle>Manage Attachments</grouptitle>
|
||||
<grouplang>forums_attachments</grouplang>
|
||||
<items>
|
||||
<item>
|
||||
<key>view_attachments</key>
|
||||
<string>Может просматривать и искать файлы?</string>
|
||||
<string>Can search and review attachments?</string>
|
||||
</item>
|
||||
<item>
|
||||
<key>stats_attachments</key>
|
||||
<string>Может просматривать статистику?</string>
|
||||
<string>Can view attachment stats?</string>
|
||||
</item>
|
||||
<item>
|
||||
<key>remove_attachments</key>
|
||||
<string>Может удалять?</string>
|
||||
<string>Can remove attachments?</string>
|
||||
</item>
|
||||
</items>
|
||||
</group>
|
||||
<group>
|
||||
<grouptitle>Управление типами прикрепляемых файлов</grouptitle>
|
||||
<grouptitle>Manage Attachments Mime-Types</grouptitle>
|
||||
<grouplang>forums_mimes</grouplang>
|
||||
<items>
|
||||
<item>
|
||||
<key>mime_view</key>
|
||||
<string>Может просматривать?</string>
|
||||
<string>Can view attachment types?</string>
|
||||
</item>
|
||||
<item>
|
||||
<key>mime_add</key>
|
||||
<string>Может добавлять?</string>
|
||||
<string>Can add attachment types?</string>
|
||||
</item>
|
||||
<item>
|
||||
<key>mime_edit</key>
|
||||
<string>Может изменять?</string>
|
||||
<string>Can edit attachment types?</string>
|
||||
</item>
|
||||
<item>
|
||||
<key>mime_delete</key>
|
||||
<string>Может удалять?</string>
|
||||
<string>Can remove attachment types?</string>
|
||||
</item>
|
||||
<item>
|
||||
<key>mime_import</key>
|
||||
<string>Может импортировать типы?</string>
|
||||
<string>Can import attachment types?</string>
|
||||
</item>
|
||||
<item>
|
||||
<key>mime_export</key>
|
||||
<string>Может экспортировать типы?</string>
|
||||
<string>Can export attachment types?</string>
|
||||
</item>
|
||||
</items>
|
||||
</group>
|
||||
|
||||
Reference in new issue
Block a user