Version 2.0.0
This commit is contained in:
1 parent
5699abfc0e
commit
0eecc172d9
696 files changed
+120723
-77160
No files matched your search
+223
-48
@@ -2,16 +2,15 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v1.3.1 Final
|
||||
| ========================================
|
||||
| Invision Power Board v2.0.0
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2003 Invision Power Services
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| ========================================
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Thu, 23 Sep 2004 23:05:01 GMT
|
||||
| Release: 3cb325c445e1909182084806ae7f8226
|
||||
| Email: matt@invisionpower.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
@@ -20,69 +19,245 @@
|
||||
| > Date started: 10th March 2002
|
||||
|
|
||||
| > Module Version Number: 1.0.0
|
||||
| > DBA Checked: Mon 24th May 2004
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
$idx = new attach;
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
{
|
||||
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
|
||||
exit();
|
||||
}
|
||||
|
||||
class attach {
|
||||
|
||||
|
||||
function attach()
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// AUTO RUN
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function auto_run()
|
||||
{
|
||||
global $ibforums, $DB, $std, $print, $skin_universal;
|
||||
global $ibforums, $DB, $std, $print, $forums;
|
||||
|
||||
$ibforums->input['id'] = preg_replace( "/^(\d+)$/", "\\1", $ibforums->input['id'] );
|
||||
$ibforums->input['id'] = intval($ibforums->input['id']);
|
||||
$ibforums->input['tid'] = intval($ibforums->input['tid']);
|
||||
|
||||
if ($ibforums->input['id'] == "")
|
||||
//-----------------------------------------
|
||||
// Got attachment types?
|
||||
//-----------------------------------------
|
||||
|
||||
$ibforums->cache['attachtypes'] = array();
|
||||
|
||||
$DB->simple_construct( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img', 'from' => 'attachments_type', 'where' => "atype_photo=1 OR atype_post=1" ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
while ( $r = $DB->fetch_row() )
|
||||
{
|
||||
$ibforums->cache['attachtypes'][ $r['atype_extension'] ] = $r;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// What to do..
|
||||
//-----------------------------------------
|
||||
|
||||
switch( $ibforums->input['code'] )
|
||||
{
|
||||
case 'showtopic':
|
||||
$this->show_topic_attachments();
|
||||
break;
|
||||
default:
|
||||
$this->show_post_attachment();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// SHOW TOPIC ATTACHMENTS ( MULTIPLE )
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function show_topic_attachments()
|
||||
{
|
||||
global $DB, $ibforums, $std, $forums, $print;
|
||||
|
||||
if ( ! $ibforums->input['tid'] )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
if ($ibforums->input['type'] == 'post')
|
||||
//-----------------------------------------
|
||||
// get topic..
|
||||
//-----------------------------------------
|
||||
|
||||
$topic = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid='.$ibforums->input['tid'] ) );
|
||||
|
||||
if ( ! $topic['topic_hasattach'] )
|
||||
{
|
||||
// Handle post attachments.
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Check forum..
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $forums->forum_by_id[ $topic['forum_id'] ] )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Get forum skin and lang
|
||||
//-----------------------------------------
|
||||
|
||||
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_forum', $ibforums->lang_id);
|
||||
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_topic', $ibforums->lang_id);
|
||||
|
||||
$this->html = $std->load_template('skin_forum');
|
||||
|
||||
//-----------------------------------------
|
||||
// aight.....
|
||||
//-----------------------------------------
|
||||
|
||||
$this->output .= $this->html->forums_attachments_top($topic['title']);
|
||||
|
||||
$DB->cache_add_query( 'forum_get_attachments', array( 'tid' => $ibforums->input['tid'] ) );
|
||||
|
||||
$DB->cache_exec_query();
|
||||
|
||||
while ( $row = $DB->fetch_row() )
|
||||
{
|
||||
if ( $std->check_perms($forums->forum_by_id[ $row['forum_id'] ]['read_perms']) != TRUE )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$row['image'] = $ibforums->cache['attachtypes'][ $row['attach_ext'] ]['atype_img'];
|
||||
|
||||
$row['short_name'] = $std->txt_truncate( $row['attach_file'], 30 );
|
||||
|
||||
$row['attach_date'] = $std->get_date( $row['attach_date'], 'SHORT' );
|
||||
|
||||
$row['real_size'] = $std->size_format( $row['attach_filesize'] );
|
||||
|
||||
$this->output .= $this->html->forums_attachments_row( $row );
|
||||
}
|
||||
|
||||
$this->output .= $this->html->forums_attachments_bottom();
|
||||
|
||||
$print->pop_up_window($ibforums->lang['attach_title'], $this->output);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
//
|
||||
// SHOW POST ATTACHMENT ( SINGLE )
|
||||
//
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
function show_post_attachment()
|
||||
{
|
||||
global $DB, $ibforums, $std, $forums, $print;
|
||||
|
||||
if ( ! $ibforums->input['id'] )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// get attachment
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_id=".$ibforums->input['id'] ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
if ( ! $attach = $DB->fetch_row() )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Handle post attachments.
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $ibforums->input['type'] == 'post' )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get post thingy majiggy to check perms
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query("SELECT pid, attach_id, attach_type, attach_file FROM ibf_posts WHERE pid='".$ibforums->input['id']."'");
|
||||
$DB->cache_add_query( 'attach_get_perms', array( 'apid' => $attach['attach_pid'] ) );
|
||||
$DB->cache_exec_query();
|
||||
|
||||
if ( !$DB->get_num_rows() )
|
||||
if ( ! $post = $DB->fetch_row() )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
}
|
||||
|
||||
$post = $DB->fetch_row();
|
||||
|
||||
if ( $post['attach_id'] == "" )
|
||||
if ( ! $forums->forum_by_id[ $post['forum_id'] ] )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
$file = $ibforums->vars['upload_dir']."/".$post['attach_id'];
|
||||
|
||||
if ( file_exists( $file ) and ( $post['attach_type'] != "" ) )
|
||||
{
|
||||
// Update the "hits"..
|
||||
|
||||
$DB->query("UPDATE ibf_posts SET attach_hits=attach_hits+1 WHERE pid='".$post['pid']."'");
|
||||
|
||||
// Set up the headers..
|
||||
|
||||
@header( "Content-Type: ".$post['attach_type']."\nContent-Disposition: inline; filename=\"".$post['attach_file']."\"\nContent-Length: ".(string)(filesize( $file ) ) );
|
||||
|
||||
// Open and display the file..
|
||||
|
||||
$fh = fopen( $file, 'rb' ); // Set binary for Win even if it's an ascii file, it won't hurt.
|
||||
fpassthru( $fh );
|
||||
@fclose( $fh );
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
// File does not exist..
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
|
||||
}
|
||||
}
|
||||
else if ( $ibforums->input['type'] == 'msg' and $attach['attach_msg'] )
|
||||
{
|
||||
$DB->simple_construct( array( 'select' => 'mt_id, mt_owner_id', 'from' => 'message_topics', 'where' => 'mt_owner_id='.$ibforums->member['id'].' AND mt_msg_id='.$attach['attach_msg'] ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
if ( ! $post = $DB->fetch_row() )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Show attachment
|
||||
//-----------------------------------------
|
||||
|
||||
$file = $ibforums->vars['upload_dir']."/".$attach['attach_location'];
|
||||
|
||||
if ( file_exists( $file ) and ( $ibforums->cache['attachtypes'][ $attach['attach_ext'] ]['atype_mimetype'] != "" ) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Update the "hits"..
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->simple_construct( array( 'update' => 'attachments', 'set' =>"attach_hits=attach_hits+1", 'where' => "attach_id=".$ibforums->input['id'] ) );
|
||||
$DB->simple_exec();
|
||||
|
||||
//-----------------------------------------
|
||||
// Set up the headers..
|
||||
//-----------------------------------------
|
||||
|
||||
//flush();
|
||||
|
||||
@header( "Content-Type: ".$ibforums->cache['attachtypes'][ $attach['attach_ext'] ]['atype_mimetype'].
|
||||
"\nContent-Disposition: inline; filename=\"".$attach['attach_file']
|
||||
."\"\nContent-Length: ".(string)(filesize( $file ) ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Open and display the file..
|
||||
//-----------------------------------------
|
||||
|
||||
$fh = fopen( $file, 'rb' ); // Set binary for Win even if it's an ascii file, it won't hurt.
|
||||
fpassthru( $fh );
|
||||
@fclose( $fh );
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
//-----------------------------------------
|
||||
// File does not exist..
|
||||
//-----------------------------------------
|
||||
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user