<?php require_once "config.php"; require_once WWW_DIR . "/lib/adminpage.php"; require_once WWW_DIR . "/lib/groups.php"; require_once WWW_DIR . "/lib/category.php"; $page = new AdminPage(); $groups = new Groups(); $category = new Category(); $id = 0; // set the current action $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view'; switch ($action) { case 'submit': if ($_POST["id"] == "") { $groups->add($_POST); } else { $groups->update($_POST); } header("Location:" . WWW_TOP . "/group-list.php"); break; case 'view': default: if (isset($_GET["id"])) { $page->title = "Newsgroup Edit"; $id = $_GET["id"]; $group = $groups->getByID($id); } else { $page->title = "Newsgroup Add"; $group = array(); $group["active"] = "1";
$sqlrecentdiscard = sprintf("select GID from releases where name = %s and categoryID = %d and postdate between date_add(%s, INTERVAL -2 DAY) and date_add(%s, INTERVAL 1 DAY)", $db->escapeString($name), $catId, $db->escapeString(date("Y-m-d H:i:s", $nzbInfo->postedlast)), $db->escapeString(date("Y-m-d H:i:s", $nzbInfo->postedlast))); $recentdiscrows = $db->query($sqlrecentdiscard); if (count($recentdiscrows) > 0) { if ($verbose) { echo sprintf("Skipping Diff GID %s (%s) %s-%s\n", $name, $groupName, $nzbInfo->gid, $recentdiscrows[0]["GID"]); } } else { // insert release $relid = $r->insertRelease($name, $nzbInfo->filecount, $groupID, $relguid, $catId, "", date("Y-m-d H:i:s", $nzbInfo->postedlast), $nzbInfo->poster, "", $site); $db->exec(sprintf("update releases set totalpart = %d, size = %s, completion = %d, GID=%s where ID = %d", $nzbInfo->filecount, $nzbInfo->filesize, $nzbInfo->completion, $db->escapeString($nzbInfo->gid), $relid)); // move to disk $nzbfilename = $nzb->getNZBPath($relguid, $site->nzbpath, true); $fp = _gzopen($nzbfilename, "w"); if ($fp) { gzwrite($fp, $nzbInfo->toNzb()); gzclose($fp); echo sprintf("Imported %s (%s)\n", $name, $groupName); } } } } } // add missing groups if ($addmissinggroups) { foreach (array_unique($missinggroups) as $gr) { $grp->add(array("name" => $gr, "description" => "Auto added", "active" => 1)); } } } } }
<?php require '../../../init.php'; $error_name = $error_desc = false; if (!isset($_GET['name']) or empty($_GET['name'])) { $error_name = true; } if (!isset($_GET['description']) or empty($_GET['description']) or strlen($_GET['description']) > 255) { $error_desc = true; } if (!$error_name && !$error_desc) { $Groups = new Groups(array('name' => $_GET['name'], 'desc' => $_GET['description'])); echo $Groups->add(); } ?> <div id="group-purchase-header"> <img src="http://images.habbo.com/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/1458/web-gallery/images/groups/group_icon.gif" alt="" width="46" height="46" /> </div> <?php if ($error_name && $error_desc) { ?> <form action="#" method="post" id="purchase-group-form-id"> <div id="group-name-area"> <div id="group_name_message_error" class="error"> <?php if ($error_name) { echo 'Nom de groupe indéfini.'; } ?> </div>
/** * @param object $nzbXML Reference of simpleXmlObject with NZB contents. * @param bool|string $useNzbName Use the NZB file name as release name? * @return bool * * @access protected */ protected function scanNZBFile(&$nzbXML, $useNzbName = false) { $totalFiles = $totalSize = $groupID = 0; $isBlackListed = $groupName = $firstName = $posterName = $postDate = false; // Go through the NZB, get the details, look if it's blacklisted, look if we have the groups. foreach ($nzbXML->file as $file) { $totalFiles++; $groupID = -1; // Get the nzb info. if ($firstName === false) { $firstName = (string) $file->attributes()->subject; } if ($posterName === false) { $posterName = (string) $file->attributes()->poster; } if ($postDate === false) { $postDate = date("Y-m-d H:i:s", (string) $file->attributes()->date); } // Make a fake message array to use to check the blacklist. $msg = ["Subject" => (string) $file->attributes()->subject, "From" => (string) $file->attributes()->poster, "Message-ID" => ""]; // Get the group names, group_id, check if it's blacklisted. $groupArr = []; foreach ($file->groups->group as $group) { $group = (string) $group; // If group_id is -1 try to get a group_id. if ($groupID === -1) { if (array_key_exists($group, $this->allGroups)) { $groupID = $this->allGroups[$group]; if (!$groupName) { $groupName = $group; } } else { $groupID = $this->groups->add(['name' => $group, 'description' => 'Added by NZBimport script.', 'backfill_target' => 0, 'first_record' => 0, 'last_record' => 0, 'active' => 0, 'backfill' => 0]); $this->allGroups[$group] = $groupID; $this->echoOut("Adding missing group: ({$group})"); } } // Add all the found groups to an array. $groupArr[] = $group; // Check if this NZB is blacklisted. if ($this->binaries->isBlacklisted($msg, $group)) { $isBlackListed = true; break; } } // If we found a group and it's not blacklisted. if ($groupID !== -1 && !$isBlackListed) { // Get the size of the release. if (count($file->segments->segment) > 0) { foreach ($file->segments->segment as $segment) { $totalSize += (int) $segment->attributes()->bytes; } } } else { if ($isBlackListed) { $errorMessage = "Subject is blacklisted: " . utf8_encode(trim($firstName)); } else { $errorMessage = "No group found for " . $firstName . " (one of " . implode(', ', $groupArr) . " are missing"; } $this->echoOut($errorMessage); return false; } } // Try to insert the NZB details into the DB. return $this->insertNZB(['subject' => $firstName, 'useFName' => $useNzbName, 'postDate' => empty($postDate) ? date("Y-m-d H:i:s") : $postDate, 'from' => empty($posterName) ? '' : $posterName, 'groupid' => $groupID, 'groupName' => $groupName, 'totalFiles' => $totalFiles, 'totalSize' => $totalSize]); }