本文整理匯總了PHP中Releases::getForExport方法的典型用法代碼示例。如果您正苦於以下問題:PHP Releases::getForExport方法的具體用法?PHP Releases::getForExport怎麽用?PHP Releases::getForExport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Releases
的用法示例。
在下文中一共展示了Releases::getForExport方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Sites
$path = $_POST["folder"];
if (isset($_POST["postfrom"])) {
$postfrom = $_POST["postfrom"];
}
if (isset($_POST["postto"])) {
$postto = $_POST["postto"];
}
if (isset($_POST["group"])) {
$group = $_POST["group"];
}
}
if ($path != "") {
if (substr($path, strlen($path) - 1) != '/') {
$path = $path . "/";
}
$releases = $rel->getForExport($postfrom, $postto, $group);
$s = new Sites();
$nzb = new NZB();
$site = $s->get();
$nzbCount = 0;
$total = count($releases);
foreach ($releases as $release) {
$catname = safeFilename($release["catName"]);
if (!file_exists($path . $catname)) {
mkdir($path . $catname);
}
ob_start();
@readgzfile($nzb->getNZBPath($release["guid"], $site->nzbpath));
$nzbfile = ob_get_contents();
ob_end_clean();
$fh = fopen($path . $catname . "/" . safeFilename($release["searchname"]) . ".nzb", 'w');
示例2: beginExport
/**
* Export to user specified folder.
*
* @param array $params
*
* @return bool
*
* @access public
*/
public function beginExport($params)
{
$gzip = false;
if ($params[4] === true) {
$gzip = true;
}
$fromDate = $toDate = '';
$path = $params[0];
// Check if the path ends with dir separator.
if (substr($path, -1) !== DS) {
$path .= DS;
}
// Check if it's a directory.
if (!is_dir($path)) {
$this->echoOut('Folder does not exist: ' . $path);
return $this->returnValue();
}
// Check if we can write to it.
if (!is_writable($path)) {
$this->echoOut('Folder is not writable: ' . $path);
return $this->returnValue();
}
// Check if the from date is the proper format.
if (isset($params[1]) && $params[1] !== '') {
if (!$this->checkDate($params[1])) {
return $this->returnValue();
}
$fromDate = $params[1];
}
// Check if the to date is the proper format.
if (isset($params[2]) && $params[2] !== '') {
if (!$this->checkDate($params[2])) {
return $this->returnValue();
}
$toDate = $params[2];
}
// Check if the group_id exists.
if (isset($params[3]) && $params[3] !== 0) {
if (!is_numeric($params[3])) {
$this->echoOut('The group ID is not a number: ' . $params[3]);
return $this->returnValue();
}
$groups = $this->pdo->query('SELECT id, name FROM groups WHERE id = ' . $params[3]);
if (count($groups) === 0) {
$this->echoOut('The group ID is not in the DB: ' . $params[3]);
return $this->returnValue();
}
} else {
$groups = $this->pdo->query('SELECT id, name FROM groups');
}
$exported = 0;
// Loop over groups to take less RAM.
foreach ($groups as $group) {
$currentExport = 0;
// Get all the releases based on the parameters.
$releases = $this->releases->getForExport($fromDate, $toDate, $group['id']);
$totalFound = count($releases);
if ($totalFound === 0) {
if ($this->echoCLI) {
echo 'No releases found to export for group: ' . $group['name'] . PHP_EOL;
}
continue;
}
if ($this->echoCLI) {
echo 'Found ' . $totalFound . ' releases to export for group: ' . $group['name'] . PHP_EOL;
}
// Create a path to store the new NZB files.
$currentPath = $path . $this->safeFilename($group['name']) . DS;
if (!is_dir($currentPath)) {
mkdir($currentPath);
}
foreach ($releases as $release) {
// Get path to the NZB file.
$nzbFile = $this->nzb->getNZBPath($release["guid"]);
// Check if it exists.
if ($nzbFile === false) {
if ($this->echoCLI) {
echo 'Unable to find NZB for release with GUID: ' . $release['guid'];
}
continue;
}
// Create path to current file.
$currentFile = $currentPath . $this->safeFilename($release['searchname']);
// Check if the user wants them in gzip, copy it if so.
if ($gzip) {
if (!copy($nzbFile, $currentFile . '.nzb.gz')) {
if ($this->echoCLI) {
echo 'Unable to export NZB with GUID: ' . $release['guid'];
}
continue;
}
//.........這裏部分代碼省略.........
示例3: Sites
}
if (isset($_POST["postto"])) {
$postto = $_POST["postto"];
}
if (isset($_POST["group"])) {
$group = $_POST["group"];
}
if (isset($_POST["categoryID"])) {
$category = $_POST["categoryID"];
}
}
if ($path != "") {
if (substr($path, strlen($path) - 1) != '/') {
$path = $path . "/";
}
$releases = $rel->getForExport($postfrom, $postto, $group, $category);
$s = new Sites();
$nzb = new NZB();
$site = $s->get();
$nzbCount = 0;
while ($release = $db->getAssocArray($releases)) {
$catname = safeFilename($release["catName"]);
if (!file_exists($path . $catname)) {
mkdir($path . $catname);
}
ob_start();
@readgzfile($nzb->getNZBPath($release["guid"], $site->nzbpath));
$nzbfile = ob_get_contents();
ob_end_clean();
$filename = getFilename($path . $catname . "/", $release["searchname"]);
echo $filename . "\n";