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:
PHP 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