PDA

View Full Version : help with vb nfo reader script to work on vbulletin file system plz


Joe Pimms
02-19-2005, 01:55 AM
hello i need a little help here i have a nfo viewer hack for vbulletin what this hack dose is it makes a viewable nfo file in vb all the user dose is uploads a nfo file then it shows on vb ...

ok heres my problem the script is made to work with the data base and all but my vb 3.0.6.
Attachments are currently being stored in the filesystem of vb i need this hack to work on the file system can some one help me plz here is the code:




Open showthread.php, look for this :

// load attachments
if ($thread['attach'])
{
$attachments = $DB_site->query("
SELECT filename, filesize, visible, attachmentid, counter, postid, IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail, thumbnail_filesize


and replace with :

// load attachments
if ($thread['attach'])
{
$attachments = $DB_site->query("
SELECT filename,filedata, filesize, visible, attachmentid, counter, postid, IF(thumbnail = '', 0, 1) AS hasthumbnail, LENGTH(thumbnail) AS thumbnailsize


Then look for this :

while ($attachment = $DB_site->fetch_array($attachments))
{


and replace with :

while ($attachment = $DB_site->fetch_array($attachments))
{
$s1 = '';
if (ereg('.nfo',$attachment[filename]))
{

$s1.="<table id='shownfo' class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" width=\"100%\" border=\"0\">\n";
$s1.="<thead><tr><td class=\"tcat\" colspan=\"2\" width=\"100%\"><a href=\"#top\" style=\"float:right\" ";
$s1 .= " onclick=\"return toggle_collapse('shownfo')\">";
$coll = "collapseimg_shownfo" ;
$s1.= "<img id=\"collapseimg_shownfo\" src='".$stylevar[imgdir_button]."/collapse_alt".str_replace('_collapsed','',$vbcollapse[$coll]).".gif' alt=\"\" border=\"0\">";
$s1.="</a><strong><a href=\"#top\" onclick=\"return toggle_collapse('shownfo')\">ShowMe'NFO: ".$attachment[filename]." </a></strong></td></tr></thead>\n";
$s1.="<tbody id=\"collapseobj_shownfo\" style=\"\"><tr><td class=\"alt1\" >" ;
$s1.= "<img src=\"nfos/".str_replace('.nfo','.png',$attachment[filename] )."\">";

// Load the NFO file...
$lines = explode("\n",$attachment[filedata] );


// Get the longest line....
$longestLine = 0;
$numberLines = 0;

foreach ($lines as $line_num => $line)
{
$line = rtrim($line);

$tempLineLength = strlen($line); // Avoid calling strlen twice...
if( $tempLineLength > $longestLine )
$longestLine = $tempLineLength;
}


// The number of line....
$numberLines = count($lines);


//Set up the Vars...
$fontWidth = 8;
$fontHeight = 12;

$border = 1; // Not one pixel, but 1*FontWidth and 1*FontHeight

$imgWidth = ($fontWidth * $longestLine) + ( 2 * $border * $fontWidth );
$imgHeight = ($fontHeight * $numberLines) + ( 2 * $border * $fontHeight );


$currentX = $border * $fontWidth;
$currentY = $border * $fontHeight;


// Start GD
$img = imagecreatetruecolor( $imgWidth, $imgHeight );
$charMap = imagecreatefrompng("charmap-20-255.png");


// Main loop....
foreach ($lines as $line_num => $line)
{
// Avoid calling strlen strlen($line) times :-)
$currentLineLength = strlen($line);
for( $i = 0; $i < $currentLineLength; $i++ )
{
// Get the Locatino of the char in the charmap image
$charYOffSet = 0;
$charXOffSet = ord($line[$i]) - 20; // Becuase my charmap skips the first 20 chars :-)

while( $charXOffSet >= 20 )
{
$charYOffSet++;
$charXOffSet = $charXOffSet - 20;
}

// int imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h)
imagecopy( $img, $charMap, $currentX, $currentY, ($fontWidth * $charXOffSet), ($fontHeight * $charYOffSet), $fontWidth, $fontHeight );

// Move along one char to the right
$currentX = $currentX + $fontWidth;
}

// Move down a line, and reset the x location
$currentX = ($border * $fontWidth);
$currentY = $currentY + $fontHeight;
}


imagepng( $img,"nfos/".str_replace('.nfo','.png',$attachment[filename] ));
imagedestroy($img);

$s1.= "</td></tr></tbody>\n</table>\n";
$s1.="<script type='text/javascript'> toggle_collapse('shownfo');</script>";
$attachment[nfo] = $s1;
}



Modifications :

Edit postbit_attachment, look for this :

td><img class="inlineimg" src="$stylevar[imgdir_attach]/$attachment[attachmentextension].gif" alt="<phrase 1="$attachment[attachmentextension]">$vbphrase[file_type_x]</phrase>" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td><a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank">$attachment[filename]</a> ($attachment[filesize], <phrase 1="$attachment[counter]">$vbphrase[x_views]</phrase>)</td>
</tr>



and replace with :

<td><img class="inlineimg" src="$stylevar[imgdir_attach]/$attachment[attachmentextension].gif" alt="<phrase 1="$attachment[attachmentextension]">$vbphrase[file_type_x]</phrase>" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
<td><a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]" target="_blank">$attachment[filename]</a><br> ($attachment[filesize], <phrase 1="$attachment[counter]">$vbphrase[x_views]</phrase>)
</td>
</tr>
<tr><td> </td><td>
<br>
$attachment[nfo]
</td>
</tr>




i just need help for it to work on vb file system plase help me help

filburt1
02-19-2005, 03:01 AM
A .nfo is used by Windows System Information tools. Why do you need to view them?

Joe Pimms
02-19-2005, 03:24 AM
these are not the nfo files im talking about !

can this code be fixed ?

here are a few images

Adrian Schneider
02-19-2005, 06:38 AM
Most nfo's on the internet are basically text files, but that's getting more into warez.

Joe Pimms
02-21-2005, 04:43 AM
can some one please help with the code please

filburt1
02-21-2005, 02:04 PM
Not only is there no legitimate need to read .nfo files that are not used as registered by default on Windows, but the screenshots you provided also include a known piracy group. Jelsoft will not tolerate piracy or the use of vBulletin to fester piracy.