예제 #1
0
 public function createSitemap()
 {
     $pagelist = new Pagelist();
     $pagelist->xmlmode();
     $xml = $pagelist->getList();
     $sitemap = $this->saveSitemap($xml);
     $uploader = new HttpUploader($this->site);
     $uploader->uploadFile($sitemap, 'xml');
 }
예제 #2
0
    foreach ($data as $mode => $v) {
        if (!$v->hasData()) {
            continue;
        }
        if ($modes[$mode] != 'not') {
            continue;
        }
        $pl->only_in_list_1($pl, $v);
        $v->cleanup();
    }
    out("<div>After NOT : " . number_format($pl->wcl()) . " items.</div>");
}
out(number_format($pl->wcl()) . " items in combination.</p>");
if ($label_contains . $label_contains_not != '') {
    out("<p>Filtering +'{$label_contains}' / -'{$label_contains_not}' ... ");
    $pl2 = new Pagelist();
    $pl2->blankFile('wikidata', 'wikidata');
    $fh = fopen($pl2->file, 'w');
    while ($a = $pl->getNextBatch()) {
        $items = array();
        foreach ($a as $v) {
            $items[] = preg_replace('/\\D/', '', $v[0]);
        }
        $sql = "SELECT DISTINCT term_entity_id FROM wb_terms t1 WHERE t1.term_type='label' AND t1.term_entity_type='item'";
        if ($label_contains != '') {
            $sql .= " AND t1.term_text LIKE '%" . $db_wd->real_escape_string($label_contains) . "%'";
        }
        if ($label_contains_not != '') {
            $sql .= " AND NOT EXISTS (SELECT * FROM wb_terms t2 WHERE t2.term_type='label' AND t2.term_entity_type='item' AND t2.term_text LIKE '%" . $db_wd->real_escape_string($label_contains_not) . "%' AND t2.term_entity_id=t1.term_entity_id)";
        }
        $sql .= " AND t1.term_entity_id IN (" . implode(',', $items) . ")";
예제 #3
0
파일: stdlib.php 프로젝트: hugcoday/wiki
 /**
  * Build an array in $this->_fileList of files from $dirname.
  * Subdirectories are not traversed.
  *
  * (This was a function LoadDir in lib/loadsave.php)
  * See also http://www.php.net/manual/en/function.readdir.php
  */
 function getFiles($exclude = '', $sortby = '', $limit = '')
 {
     $list = $this->_fileList;
     if ($sortby) {
         require_once 'lib/PageList.php';
         switch (Pagelist::sortby($sortby, 'db')) {
             case 'pagename ASC':
                 break;
             case 'pagename DESC':
                 $list = array_reverse($list);
                 break;
             case 'mtime ASC':
                 usort($list, 'sort_file_mtime');
                 break;
             case 'mtime DESC':
                 usort($list, 'sort_file_mtime');
                 $list = array_reverse($list);
                 break;
         }
     }
     if ($limit) {
         return array_splice($list, 0, $limit);
     }
     return $list;
 }
예제 #4
0
 private function getMovieList()
 {
     $page = (int) Param("page");
     if ($page < 1 || $page > 10000) {
         $page = 1;
     }
     if (Param("restore") === 'true' && is_object($_SESSION['lastMovieSelection'])) {
         $params = $_SESSION['lastMovieSelection'];
     } else {
         $params = new StdClass();
         $params->search = Param('search');
         $params->series = Param('series');
         $params->skipTranscoded = Param('skipTranscoded') ? 1 : 0;
         $params->skipHasCutlist = Param('skipHasCutlist') ? 1 : 0;
         $params->hpp = (int) Param('hpp') > 0 && (int) Param('hpp') <= 1000 ? (int) Param('hpp') : HPP;
     }
     $_SESSION['lastMovieSelection'] = $params;
     $q = new Query("select title, chanid,\n\t\t\t\t             unix_timestamp(starttime) as unix,\n\t\t\t\t             filesize\n\t\t\t\t        from recorded  r\n\t\t\t\t       where deletepending = 0");
     if ($params->skipTranscoded) {
         $q->Append(" and transcoded=0");
     }
     if (strlen($params->series) > 0) {
         $q->Append("and title = :series");
         $q->series = $params->series;
     }
     $words = preg_split('!\\s+!', $params->search);
     $row = 0;
     foreach ($words as $v) {
         $v = trim(chop($v));
         if ($v > '') {
             $row++;
             $w1 = '%' . strtr($v, array('%' => '\\%')) . '%';
             $q->Append("and concat(coalesce(title, ''), ' ', coalesce(subtitle, ''), ' ', coalesce(description, '')) like :word" . $row);
             $q->Set('word' . $row, $w1);
         }
     }
     if ($params->skipHasCutlist) {
         $q->Append(" and not exists (select 1 from recordedmarkup m where m.chanid=r.chanid and m.starttime=r.starttime and m.type in (0,1))");
     }
     $sort_by_size = Param('sort_by_size');
     if ($sort_by_size) {
         $q->Append(" order by filesize desc");
     } else {
         $q->Append("order by starttime desc");
     }
     $data = array();
     $row = 0;
     $hits = 0;
     $series = array();
     $movies_to_load = array();
     $range_from = ($page - 1) * $params->hpp;
     $range_to = $page * $params->hpp;
     foreach ($q->Execute() as $v) {
         $c = new StdClass();
         $c->Chanid = $v->chanid;
         $c->Unixtime = $v->unix;
         $c->Title = $v->title;
         $c->Filesize = $v->filesize;
         $data[] = $c;
         if (!isset($series[$c->Title])) {
             $e = new StdClass();
             $e->Title = $c->Title;
             $e->NumRecordings = 0;
             $e->Filesize = 0.0;
             $e->LastRecording = 0;
             $e->Recordings = array();
             $series[$c->Title] = $e;
         }
         $series[$c->Title]->Filesize += DoubleVal($c->Filesize);
         $series[$c->Title]->LastRecording = max($series[$c->Title]->LastRecording, $c->Unixtime);
         $series[$c->Title]->NumRecordings++;
         $series[$c->Title]->Recordings[] = $c;
         if ($row >= $range_from && $row < $range_to) {
             $key = sprintf("%d.%d", $c->Chanid, $c->Unixtime);
             $movies_to_load[$key] = $c;
         }
         $row++;
         $hits++;
     }
     if (count($movies_to_load) > 0) {
         $q = new Query("select r.subtitle, r.description, r.chanid,\n\t\t\t\t\t\t\t  \t   unix_timestamp(r.starttime) as unix,\n\t\t\t\t\t\t\t  \t   c.name as channel,\n\t\t\t\t\t\t\t  \t   r.filesize\t\t\t\t\t\t\t  \t   \n\t\t\t\t\t\t\t  from recorded r\n\t\t\t\t\t\t\t  \t\t  left join channel c on (c.chanid = r.chanid)\n\t\t\t\t\t\t\t where (\n\t\t\t                         0 = 1");
         $row = 0;
         foreach ($movies_to_load as $v) {
             $row++;
             $q->Set("chanid" . $row, $v->Chanid);
             $q->Set("starttime" . $row, date("Y-m-d H:i:s", $v->Unixtime));
             $q->Append(sprintf(" or (r.chanid = :chanid%d and r.starttime=:starttime%s)", $row, $row));
         }
         unset($v);
         $q->Append(")");
         foreach ($q->Execute() as $v) {
             $key = sprintf("%d.%d", $v->chanid, $v->unix);
             $c = $movies_to_load[$key];
             $c->Subtitle = $v->subtitle;
             $c->Description = $v->description;
             $c->Channel = $v->channel;
             $c->Selector = $key;
             $c->Date = self::JsonDate($v->unix);
             $c->Filesize = (double) $v->filesize;
             $c->FilesizeGB = (double) sprintf("%.1f", $c->Filesize / 1024.0 / 1024.0 / 1024.0);
             $c->IsSeries = $series[$c->Title]->NumRecordings > 1;
             if ($c->IsSeries) {
                 $e = new StdClass();
                 $e->NumEpisodes = $series[$c->Title]->NumRecordings;
                 $e->Filesize = $series[$c->Title]->Filesize;
                 $e->FilesizeGB = (double) sprintf("%.1f", $series[$c->Title]->Filesize / 1024.0 / 1024.0 / 1024.0);
                 $c->Episodes = $e;
             }
             unset($c);
         }
     }
     $result = new StdClass();
     $result->TotalHits = $hits;
     $result->Pages = Floor(($hits + $params->hpp - 1) / $params->hpp);
     $result->CurrentPage = $page;
     $result->EntriesPerPage = $params->hpp;
     $result->Movies = array_values($movies_to_load);
     $result->PageList = array();
     $url = sprintf("?action=json&call=getMovieList&tpp=%d&search=%s&series=%s", $params->hpp, urlencode($params->search), urlencode($params->series));
     $pagelist = new Pagelist($url);
     $pagelist->HitsPerPage = $params->hpp;
     $result->BaseHREF = $url;
     $result->PageList = $pagelist->Get($result->Pages, $page);
     $result->Params = $params;
     return $this->successResult($result);
 }