/** * Helper function to make a path to an image. * * @param string $filename Target filename * @param string|int $width Target width * @param string|int $height Target height * @param string $crop String identifier for cropped images * @return string Image path */ public function image($filename, $width = "", $height = "", $crop = "") { if ($width != "" || $height != "") { // You don't want the image, you just want a thumbnail. return $this->thumbnail($filename, $width, $height, $crop); } $image = sprintf("%sfiles/%s", $this->app['paths']['root'], safeFilename($filename)); return $image; }
/** * Helper function to make a path to an image. * * @param string $filename Target filename * @param string|int $width Target width * @param string|int $height Target height * @param string $crop String identifier for cropped images * @return string Image path */ public function image($filename, $width = "", $height = "", $crop = "") { if ($width != "" || $height != "") { // You don't want the image, you just want a thumbnail. return $this->thumbnail($filename, $width, $height, $crop); } // After v1.5.1 we store image data as an array if (is_array($filename)) { $filename = $filename['file']; } $image = sprintf("%sfiles/%s", $this->app['paths']['root'], safeFilename($filename)); return $image; }
function fetchPack($compo, $file = '') { global $mysqli; $compo = intval($compo); if (!canFetchPack($compo)) { redirect(BASEDIR); } if ($file != '') { $arc = new ArchiveFile(UPLOAD_DIR . $compo); $arc->Extract($file); $arc->Close(); die; } $arcName = ArchiveFile::FileName(UPLOAD_DIR . $compo); $result = $mysqli->query("SELECT `name` FROM `compos` WHERE `idcompo` = {$compo}") or die('query failed'); $row = $result->fetch_assoc(); $result->free(); $compoName = safeFilename($row["name"]); ob_end_clean(); header('Content-Disposition: attachment; filename="' . $compoName . '.7z"'); header("Content-type: application/octet-stream"); header("Content-Length: " . filesize($arcName)); readfile($arcName); die; }
<?php // // Script will dump out all nfos in the system into a folder based on the date posted to usenet ./YYYYMMDD/release.nfo // define('FS_ROOT', realpath(dirname(__FILE__))); require_once FS_ROOT . "/../../www/config.php"; require_once FS_ROOT . "/../../www/lib/util.php"; $db = new DB(); $res = $db->queryDirect("select releases.searchname, releases.postdate, uncompress(releasenfo.nfo) as nfo from releases inner join releasenfo on releases.ID = releasenfo.releaseID and releasenfo.nfo is not null order by postdate"); while ($row = $db->getAssocArray($res)) { $dir = date("Ymd", strtotime($row["postdate"])); if (!file_exists($dir)) { mkdir($dir); } $filename = $dir . "/" . safeFilename($row["searchname"]) . ".nfo"; if (!file_exists($filename)) { $fh = fopen($filename, 'w'); fwrite($fh, cp437toUTF($row["nfo"])); fclose($fh); } }
$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'); fwrite($fh, $nzbfile); fclose($fh); $nzbCount++; if ($nzbCount % 10 == 0) { echo "Exported " . $nzbCount . " of " . $total . " nzbs\n"; } } $retval .= 'Processed ' . $nzbCount . ' nzbs'; if (!empty($argc)) { echo 'Processed ' . $nzbCount . ' nzbs'; die; } } else { echo 'No export path specified.'; die;
if (is_file($fdir.$filenameUTF) ) { echo "[UTF]"; $oldFilename=$filenameUTF; } else if (is_file($fdir.$filenameISO) ) { echo "[ISO]"; $oldFilename=$filenameISO; } else if (is_file($fdir.$row['filename']) ) { echo "[ORG]"; $oldFilename=$row['filename']; } else if (is_file($fdir.$filenameGR) ) { echo "[GR]"; $oldFilename=$filenameGR; } $i++; $newfilename=safeFilename( $newfilename); echo "$i. Flight ID: <a href='". getLeonardoLink(array('op'=>'show_flight','flightID'=>$row["ID"])) ."' target=_blank>".$row["ID"]."</a> will rename [".$row["filename"]."] ( $oldFilename ) to [ $newfilename ] <br>"; if ( $latinAvailable && $newfilename ) { $flight=new flight(); $flight->getFlightFromDB($row["ID"],0); $flight->renameTracklog($newfilename,$oldFilename); } // if ($i>5 ) break; //break; } } /* $files_total++;
function getFilename($path, $name, $iter = 0) { $check = $path . safeFilename($name) . ($iter != 0 ? "-" . $iter : "") . ".nzb"; if (!file_exists($check)) { return $check; } else { return getFilename($path, $name, ++$iter); } }