Log in

View Full Version : Okay, so im converting a mod, and...


TyleR
11-26-2005, 06:58 PM
would like a tad bit o' help from you more experianced ones..im porting Mad_Max (of vbhackers.com)'s Install System Mod to vB 3.5.x...well, it requires a LOT of file editing..mostly within attachment.php (replacing code).

is there any way to get around replacing alot of the code by using a hook?

Thanks!,

Tyler

Code Monkey
11-26-2005, 07:26 PM
Look inside attachment.php and see if there are any hooks located where your code would go.

TyleR
11-26-2005, 09:35 PM
there is, but it needs to replace a line above the hook..what I was wondering is if there was a work-around from editing attachment.php itself.

Marco van Herwaarden
11-26-2005, 09:41 PM
Try to recode it so it can run in the hook location instead of above.

TyleR
11-26-2005, 10:30 PM
not possible..this is what i'm talking about:

======
find:
======

if ($attachmentinfo['postid'] == 0)
{ // Attachment that is in progress but hasn't been finalized
if ($vbulletin->userinfo['userid'] != $attachmentinfo['userid'] AND !can_moderate($attachmentinfo['forumid'], 'caneditposts'))
{ // Person viewing did not upload it
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
// else allow user to view the attachment (from the attachment manager for example)
}
else
{
$forumperms = fetch_permissions($attachmentinfo['forumid']);

$threadinfo = array('threadid' => $attachmentinfo['threadid']); // used for session.inthread
$foruminfo = array('forumid' => $attachmentinfo['forumid']); // used for session.inforum

# Block attachments belonging to soft deleted posts and threads
if (!can_moderate($attachmentinfo['forumid']) AND ($attachmentinfo['post_visible'] == 2 OR $attachmentinfo['thread_visible'] == 2))
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}

# Block attachments belonging to moderated posts and threads
if (!can_moderate($attachmentinfo['forumid'], 'canmoderateposts') AND ($attachmentinfo['post_visible'] == 0 OR $attachmentinfo['thread_visible'] == 0))
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}

if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0)))
{
print_no_permission();
}

// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($attachmentinfo['forumid'], $vbulletin->forumcache["$attachmentinfo[forumid]"]['password']);

if (!$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $vbulletin->userinfo['userid'])
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
}

==============
replace with:
==============

if (!$_REQUEST['do'] == "download")
{
if ($attachmentinfo['postid'] == 0)
{ // Attachment that is in progress but hasn't been finalized

if ($vbulletin->userinfo['userid'] != $attachmentinfo['userid'] AND !can_moderate($attachmentinfo['forumid'], 'caneditposts'))
{ // Person viewing did not upload it
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
// else allow user to view the attachment (from the attachment manager for example)
}
else
{
$forumperms = fetch_permissions($attachmentinfo['forumid']);

$threadinfo = array('threadid' => $attachmentinfo['threadid']); // used for session.inthread

if (!can_moderate($attachmentinfo['forumid']) AND $attachmentinfo['isdeleted'])
{
eval(standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}

if (!($forumperms & CANVIEW) OR !($forumperms & CANGETATTACHMENT))
{
print_no_permission();
}

// check if there is a forum password and if so, ensure the user has it set
verify_forum_password($attachmentinfo['forumid'], $vbulletin->forumcache["$attachmentinfo[forumid]"]['password']);

if (!$attachmentinfo['visible'] AND !can_moderate($attachmentinfo['forumid'], 'canmoderateattachments') AND $attachmentinfo['userid'] != $bbuserinfo['userid'])
{
$idname = 'attachment';
eval(print_standard_error(fetch_error('invalidid', $idname, $vbulletin->options['contactuslink'])));
}
}

}