w1z4rd |
01-05-2007 02:33 AM |
Someone, anyone please help me!
I have been wracking my brain over this for hours because I'm very green in the php area. I'm trying to add an .nzb as a file attachment and parse the list of files within it so they display in a table below the attachment. I am basing my lame attempts on this code which is slightly modified.
I put this in my includes folder: class.nzbparser.php
PHP Code:
<?
function doe_iets($input)
{
$slooppunt = NULL;
for ($i=strlen($input);$i>0;$i--)
{
if ($input{$i} == "(")
{
break;
}
}
return substr($input,-4,$i);
}
class show
{
function text($what)
{
printf($what);
}
}
class nzb
{
function showcontent($where)
{
$where = str_replace("%20", " ", $where);
$filecontent = file_get_contents($where);
$parts=explode("</file>",$filecontent);
show::text("<table cellspace=1 ><tr bgcolor=#B9CAE6><td><font face=Verdana size=1>Files listed in this nzb file.</td></tr>");
foreach($parts as $part){
if (eregi ('subject="(.*)">', $part, $matches)) {
$titel = $matches[1];
$titel = explode('">', $titel);
print('<tr bgcolor=#E9E9E9><td><font face=Verdana size=1>'.$titel[0]."</td>");
}
}
print("</table>");
}
}
?>
Now I know the above works stand alone in conjunction with this code: demo.php
PHP Code:
<?
# This is the demofile of the NzbParser class.
# Just specify your nzb location of the file.
require('class.nzbparser.php');
$nzbloc = 'test.nzb'; // Change to the path of your nzb file
nzb :: showcontent ( $nzbloc );
?>
This is where it gets funky and I start trying to find code that looks like it does what I want it to. (I'm trying to learn sorry)
In attachment.php I added: (around line 260)
PHP Code:
if ($extension == "nzb" && !$_GET['mode'])
{
require_once('./includes/class.nzbparser.php');
nzblist($attachmentinfo['filedata'],$attachmentinfo['filename']);
exit;
}
In class_postbit.php I added: (around line 395)
PHP Code:
$show['nzblist'] = false;
AND below it: (around line 500)
PHP Code:
case 'nzb':
eval('$this->post[\'nzbattachments\'] .= "' . fetch_template('postbit_attachmentnzb') . '";');
$show['nzblist'] = true;
break;
Then I made a new template: postbit_attachmentnzb
HTML Code:
<a href="attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&stc=1&mode=download">Download this nzb file</a>
<br>
What the hell goes here??
Then in postbit_legacy
HTML Code:
<!-- NZB -->
<if condition="$show['nzblist']">
<fieldset class="fieldset">
<legend>NZB file list</legend>
<div style="padding:$stylevar[formspacer]px">
$post[nzbattachments]
</div>
</fieldset>
</if>
<!-- END NZB -->
Could someone please for the love of whatever it is they love please tell me where im going wrong? I have tried this code and many different variations but this is as close as I can come with what I know (which is very little).
I know it's not much but i'll paypal someone $10 if they can help me straighten this out.
|