Пример #1
0
 public function storeImage($prefix, $url)
 {
     // download image
     // cache image
     // make a new store object
     // save
     if ($url != null) {
         $stored = new StoredObject();
         if (!@($reader = fopen($url, "rb"))) {
             throw new PicnicDiskWriteFailureException("Unable to copy from `{$url}`.");
         }
         $stored->filename = basename($url);
         $stored->id = $url;
         $stored->type = "image";
         $stored->prefix = $prefix;
         PicnicUtils::mkdirR(ROOT_PATH . "data/{$stored->getFolderPath()}");
         $writer = fopen(ROOT_PATH . "data/{$stored->getPath()}", "wb");
         while (!feof($reader)) {
             $line = fread($reader, 1028);
             fwrite($writer, $line);
         }
         fclose($writer);
         fclose($reader);
         $this->_store->stored_objects[] = $stored;
     }
 }
Пример #2
0
 public static function select($id, $array, $selected = null, $head = true)
 {
     echo "<select id=\"{$id}\" name=\"{$id}\">\n";
     if ($head) {
         echo "<option" . ($selected == null ? " selected=\"selected\"" : "") . " value=\"\">" . (is_string($head) ? $head : "") . "</option>\n";
     }
     if (!PicnicUtils::isAssociativeArray($array)) {
         foreach ($array as $val) {
             echo "<option" . ($val == $selected ? " selected=\"selected\"" : "") . ">{$val}</option>\n";
         }
     } else {
         foreach ($array as $key => $val) {
             echo "<option" . ($key == $selected ? " selected=\"selected\"" : "") . " value=\"{$key}\">{$val}</option>\n";
         }
     }
     echo "</select>\n";
 }
Пример #3
0
 protected function searchRequest($url, $marker = null)
 {
     $xml = null;
     $results = array();
     try {
         $xml = new SimpleXMLElement($url, null, true);
     } catch (Exception $ex) {
         $xml = null;
         throw new NewzbinSearchRequestFailed("Newzbin down or provided authentication is incorrect.");
     }
     for ($i = 0; $i < sizeof($xml->entry); $i++) {
         $item = $xml->entry[$i];
         $report = new NZBReport();
         $report->newzbin_id = (string) PicnicUtils::getIndex($item->xpath("report:id"), 0);
         $report->name = (string) $item->title;
         $report->link = (string) $item->id;
         $report->groups = null;
         $report->category = (string) PicnicUtils::getIndex($item->xpath("report:category"), 0);
         $report->state = (string) PicnicUtils::getIndex($item->xpath("report:progress"), 0);
         $report->more_info = (string) PicnicUtils::getIndex($item->xpath("report:moreinfo"), 0);
         $report->marker = $marker;
         //var_dump($item->xpath("report:attributes/report:attribute"));
         $attributes = $item->xpath("report:attributes/report:attribute");
         $report->format = $this->findReportAttribute($attributes, "Video Fmt");
         $report->source = $this->findReportAttribute($attributes, "Source");
         $report->language = $this->findReportAttribute($attributes, "Language");
         $report->nzb = (string) PicnicUtils::getIndex($item->xpath("report:nzb"), 0);
         $report->bytesize = (string) PicnicUtils::getIndex($item->xpath("report:size"), 0);
         $report->postdate = (string) PicnicUtils::getIndex($item->xpath("report:postdate"), 0);
         $report->views = (string) PicnicUtils::getIndex($item->xpath("report:stats/report:views"), 0);
         $report->comments = (string) PicnicUtils::getIndex($item->xpath("report:stats/report:comments"), 0);
         $results[] = $report;
     }
     return $results;
 }
Пример #4
0
 public function __construct($id = null, $name = null, array $language = null, array $format = null, array $source = null, $category = -1)
 {
     if ($id != null) {
         $this->id = $id;
     } else {
         $this->id = PicnicUtils::random();
     }
     $this->name = $name;
     $this->language = $language;
     $this->format = $format;
     $this->source = $source;
     $this->category = $category;
     $this->created = strtotime(date("Y-m-d"));
 }
Пример #5
0
 protected function writeNode($writer, $key, $node)
 {
     $writer->startElement($key);
     if (is_object($node)) {
         $writer->writeAttribute("class", get_class($node));
     } else {
         if (is_array($node)) {
             $keys = array_keys($node);
             if (!PicnicUtils::isAssociativeArray($node)) {
                 $writer->writeAttribute("class", "array");
             }
         }
     }
     if (is_array($node) || is_object($node)) {
         foreach ($node as $key2 => $val) {
             if (($key2 == null || is_int($key2)) && !is_string($val) && !is_array($val) && $val != null) {
                 $key2 = get_class($val);
             } else {
                 if ((!is_string($key2) && is_string($val) || is_numeric($key2)) && $val != null) {
                     $key2 = "string";
                 }
             }
             if ($key2 != null && $val != null) {
                 $this->writeNode($writer, $key2, $val);
             }
         }
     } else {
         $writer->text($node);
     }
     $writer->fullEndElement();
 }