# Should gzopen work in FreeBSD?



## ghostcorps (Dec 15, 2012)

Hi All,

 I have recently started trying to setup Newznab on my webserver:

FreeBSD 8.3
Apache22
MySQL 5.5
PHP5

Everything seems fine until PHP tried to call gzopen 

./newznab/www/lib/nzb.php

```
<?php
require_once(WWW_DIR."/lib/framework/db.php");
require_once(WWW_DIR."/lib/site.php");
require_once(WWW_DIR."/lib/category.php");

class NZB
{
        //
        // Writes out the nzb when processing releases. Moved out of smarty due to memory issues
        // of holding all parts in an array.
        //
        function writeNZBforReleaseId($relid, $relguid, $name, $catId, $path, $echooutput=false)
        {

                $db = new DB();
                $binaries = array();
                $cat = new Category();
                $catrow = $cat->getById($catId);
                $site = new Sites();

                $fp = [B][color="Red"]gzopen[/color][/B]($path, "w");
                if ($fp)
                {
                        gzwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
                        gzwrite($fp, "<!DOCTYPE nzb PUBLIC \"-//newzBin//DTD NZB 1.1//EN\" \"http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd\">\n");
                        gzwrite($fp, "<nzb xmlns=\"http://www.newzbin.com/DTD/2003/nzb\">\n\n");
                        gzwrite($fp, "<head>\n");
                        if ($catrow)
                                gzwrite($fp, " <meta type=\"category\">".htmlspecialchars($catrow["title"], ENT_QUOTES, 'utf-8')."</meta>\n");
                        if ($name != "")
                                gzwrite($fp, " <meta type=\"name\">".htmlspecialchars($name, ENT_QUOTES, 'utf-8')."</meta>\n");
                        gzwrite($fp, "</head>\n\n");

                        $result = $db->queryDirect(sprintf("SELECT binaries.*, UNIX_TIMESTAMP(date) AS unixdate, groups.name as groupname FROM binaries inner join groups on
                        while ($binrow = mysql_fetch_assoc($result))
                        {
                                $groups = array();
                                $groupsRaw = explode(' ', $binrow['xref']);
                                foreach($groupsRaw as $grp)
                                        if (preg_match('/^([a-z0-9\.\-_]+):(\d+)?$/i', $grp, $match) && strtolower($grp) !== 'xref')
                                                $groups[] = $match[1];

                                if (count($groups) == 0)
                                        $groups[] = $binrow["groupname"];

                                gzwrite($fp, "<file poster=\"".htmlspecialchars($binrow["fromname"], ENT_QUOTES, 'utf-8')."\" date=\"".$binrow["unixdate"]."\" subject=\"".ht
                                gzwrite($fp, " <groups>\n");
                                foreach ($groups as $group)
                                        gzwrite($fp, "  <group>".$group."</group>\n");
                                gzwrite($fp, " </groups>\n");
                                gzwrite($fp, " <segments>\n");

                                $resparts = $db->queryDirect(sprintf("SELECT DISTINCT(messageID), size, partnumber FROM parts WHERE binaryID = %d ORDER BY partnumber", $binr
                                while ($partsrow = mysql_fetch_assoc($resparts))
                                {
                                        gzwrite($fp, "  <segment bytes=\"".$partsrow["size"]."\" number=\"".$partsrow["partnumber"]."\">".htmlspecialchars($partsrow["message
                                }
                                gzwrite($fp, " </segments>\n</file>\n");
                        }
                        gzwrite($fp, "<!-- generated by newznab ".$site->version()." -->\n</nzb>");
                        gzclose($fp);
                }
        }
....................
```

Should PHP on FreeBSD be able to call gzopen or is it a Linux only module?

If the later, is there anyway around this?


Thanks for your time


----------



## fonz (Dec 15, 2012)

Have you tried gzopen*64*() instead?

Fonz


----------



## ghostcorps (Dec 15, 2012)

fonz said:
			
		

> Have you tried gzopen*64*() instead?
> 
> Fonz



Thanks, but I get the same error.

I actually can not find any files with the name gzopen on the entire installation.

Perhaps I need to install it?


----------



## fonz (Dec 16, 2012)

Do you have archivers/php5-zlib installed?

Fonz


----------



## ghostcorps (Dec 17, 2012)

That did it!!! 

Thankyou so much!


----------

