protected function handleActions() { if (Param('useCommercialBreaks')) { $this->movie->useCommercialBreaks = true; $_SESSION['list'] = $this->movie->getSeekTable(); } if (Param('expandLeft')) { $this->list->expandLeft(Param('expandLeft'), Param('all') == '1'); } if (Param('expandRight')) { $this->list->expandRight(Param('expandRight'), Param('all') == '1'); } if (Param('cutLeft')) { $this->list->cutLeft(Param('cutLeft')); } if (Param('cutRight')) { $this->list->cutRight(Param('cutRight')); } if (Param('clearCutlist')) { $this->list->clearCutlist(); } if (Param('deleteCutpoint')) { $this->list->deleteCutpoint(Param('deleteCutpoint')); } if (Param('moveCutStart')) { $this->list->moveCutpoint(Param('moveCutStart'), 1); } if (Param('moveCutEnd')) { $this->list->moveCutpoint(Param('moveCutEnd'), -1); } if (Param('moveCutpoint')) { $this->list->moveCutpoint(Param('moveCutpoint'), 0); } }
protected function process(Viewbag $viewbag) { if (Param('chosen')) { if (Param('transcode')) { $this->movie->scheduleTranscode(); } // Save the cutlist to the database $this->movie->saveCutlist(); $this->Redirect("?action=selectMovie"); } $viewbag->Title = $this->movie->getTitle(); $this->SetView("SaveCutlist"); }
define('DS', DIRECTORY_SEPARATOR); set_time_limit(0); un_magic_quotes(); // JS $bp = $dsp->_BuilderPatterns; $root = $bp->root(); $dom_head = $bp->append_simple_node($root, 'head'); $dom_js = $bp->append_simple_node($dom_head, 'js'); // Append javascripts // $bp->append_simple_node($dom_js, 'item', 'admin/static/js/custom/list_common'); // Append notify $notify = $dsp->authadmin->RetriveParam("message"); $notify = empty($notify) ? Param('e-notify') ? base64_decode(Param('e-notify')) : '' : $notify; if (!empty($notify)) { $param = array(); if (Param('e-notify')) { $param = array('mode' => 'error'); } $bp->append_simple_node($dom_head, 'notify', $notify, $param); } $dsp->authadmin->Init(); if (!$dsp->authadmin->IsLogged()) { $dsp->_Builder->addNode($dsp->_Builder->createNode('block', array('align' => 'center', 'id' => 'login', 'name' => 'login'))); $dsp->_Builder->Transform('admin' . DS . 'login.xsl'); exit; } $template = 'main'; // Navigation Block $dom_block_nav = $dsp->_BuilderPatterns->create_block('nav', 'nav', 'left'); $dsp->_Builder->addArray($dsp->admin_menu->getAdminMenu(), '', array(), $dom_block_nav, false); $op = $_REQUEST['op'];
/** * Builder::Transform() * * @param mixed $xslfile * @param bool $return * @return */ public function Transform($xslfile, $return = false) { if (Param('_Debug')) { header("Content-type: text/xml"); echo $this->asXML(); die; // exit(); } if (class_exists('xsltCache')) { $xslt = new xsltCache(); $xslt->importStyleSheet(TPL_DIR . $xslfile); } else { $xslt = new xsltProcessor(); $xsltDoc = new DomDocument(); $xsltDoc->load(TPL_DIR . $xslfile); $xslt->importStyleSheet($xsltDoc); } $result = $xslt->transformToXML($this->doc); if (!$return) { header("Content-type: text/html"); print $result; return null; } return $result; }
function runBlocks($layout = 1, $typeservice = 1, $itemid = 0, $vars = array()) { $arr = $this->getBlocksArr($layout, $typeservice, $itemid, $vars); $exclusions = array(); foreach ($arr as $i => $block) { if ($block['exclusion'] == 1 && ($block['layout_id'] == $layout || $block['layout_id'] == 0)) { $exclusions[$block['id']] = true; } if (isset($exclusions[$block['id']])) { continue; } $bid = $block['id']; $name = $block['title']; $name_admin = $block['name_admin']; $class = $block['class_name']; $method = $block['params']; $cached = $block['cached']; $timeout = $block['timeout']; $place = $block['place_id']; $layout = $block['layout_id']; $order = $block['order']; $type = !empty($block['type']) ? $block['type'] : 1; $cache_key = ''; $st = microtime(true); if ($type == 1) { if (empty($class)) { continue; } if (gettype($this->dsp->{$class}) != 'object') { continue; } if (!method_exists($this->dsp->{$class}, $method)) { continue; } $articles_ids = array(); $r = array(); // хак для уникальности кеша у каждого блока $vars['temp_block_id'] = $bid; $vars['blocks_ids'] = array(); // mannuals $manuals = array(); $multi_service = FALSE; //проверка есть ли ручной вывод в блоке и добавленные в него элементы $sql = 'SELECT a.id AS id, a.service, b.multi_service, a.block_manual_id FROM blocks_manual AS b, blocks_manual_items AS a, blocks AS bl WHERE ' . ($layout ? ' ( b.layout_id = ' . $layout . ' or b.layout_id = 0 ) AND ' : '') . ($typeservice ? ' ( b.service_id = ' . $typeservice . ' or b.service_id = 29 ) AND ' : '') . ($itemid ? ' ( b.item_id = ' . $itemid . ' or b.item_id = 0 ) AND ' : '') . 'b.block_id = ? AND b.id = a.block_manual_id AND b.block_id = bl.blocks_id ORDER BY a.position ASC, a.date DESC limit 10'; $items = $this->dsp->db->Select($sql, $bid); foreach ($items as $item) { if (!isset($manuals[$item['service']])) { $manuals[$item['service']] = array(); } $manuals[$item['service']][] = $item['id']; if ($item['multi_service']) { $multi_service = TRUE; } $vars['blocks_ids'][$item['service']] = $item['block_manual_id']; } $vars['manual'] = is_array($manuals) && count($manuals) > 0 ? $multi_service ? $manuals : reset($manuals) : array(); // end manuals $no_block_cache = 0; if (!empty($_REQUEST['no_cache_id']) && $_REQUEST['no_cache_id'] == $bid) { $no_block_cache = 1; } if ($cached && empty($vars['go_dynamic']) && !$no_block_cache) { if (_isMobile()) { $vars['mobile_version'] = 1; } $r = $this->dsp->cache->go(array($this->dsp->{$class}, $method), array($vars), $timeout); $cache_key = $r['key']; $r = $r['data']; } else { //выполнение метода класса, указанного в развеске $result = $this->dsp->{$class}->{$method}($vars); //слияние полученных массивов if (count($r) > 0 && count($result) > 0) { $r = array_merge($r, $result); } elseif (count($result) > 0) { $r = $result; } unset($vars['temp_block_id']); if (isset($vars['count'])) { unset($vars['count']); } if (isset($vars['manual'])) { unset($vars['manual']); } } if ($r === false) { continue; } } elseif ($type == 2) { // Add Google Analytics (GA) attribute $method = preg_replace('~^<div~i', '<div data-ga="' . $bid . '"', trim($method)); $r = array('data' => $method); } $et = microtime(true); $time = number_format($et - $st, 6); //list($int, $dec) = explode('.', $time); //$time = number_format($time, strlen($dec)); //$dec = round( $dec ); //$time = $int . '.' . $dec; $this->dsp->_Builder->addArray((array) $r, $tag = 'block', $extra_attrs = array('id' => $bid, 'type' => $type, 'name' => $name, 'name_admin' => $name_admin, 'place' => $place, 'layout' => $layout, 'order' => $order, 'debug' => Param('_blocks') ? 'on' : (Param('_sblocks') ? 'short' : 'off'), 'cached' => $cached, 'cahe_timeout' => $timeout, 'time' => $time, 'cashed' => $cached, 'cache_key' => $cache_key), $node = '', $asItems = false, $attrs = array()); } }
function Transform($xslfile, $xml, $return = false) { if (Param('_Debug')) { header("Content-type: text/xml"); print $xml; exit; } if (5 == 5) { if (class_exists('xsltCache')) { $xslt = new xsltCache(); $xslt->importStyleSheet(TPL_DIR . $xslfile); } else { $xslt = new xsltProcessor(); $xsltDoc = DomDocument::load(TPL_DIR . $xslfile); $xslt->importStyleSheet($xsltDoc); } // $result = $xslt->transformToXML(DomDocument::loadXML($xml)); $doc = new DOMDocument(); $load_succesfull = @$doc->loadXML($xml); if (!$load_succesfull) { $result = $xslt->transformToXML(iceERROR('XML', $xml)); } else { $result = $xslt->transformToXML($doc); } } else { // ob_end_clean(); $xslt = domxml_xslt_stylesheet_file(TPL_DIR . $xslfile); $dom = @domxml_open_mem($xml); if (!$dom) { $dom = domxml_open_mem(iceERROR('XML', $xml)); } $final = $xslt->process($dom); print serialize($xslt); exit; $load_end_time = microtime(true); $result = $xslt->result_dump_mem($final); unset($dom); unset($xslt); } if (!$return) { header("Content-type: text/html"); print $result; } else { //print $b; // ajax "<sajax>" string return $result; } }
} if ($action === null) { if (!$_SESSION['SelectedMovie'] instanceof SelectedMovie) { $action = 'selectMovie'; } else { if (!$_SESSION['SelectedMovie']->valid()) { $action = 'selectMovie'; } else { $action = 'movie'; } } } $handler = null; switch ($action) { case 'json': $handler = new JSONHandler(Param('call')); break; case 'thumbnail': try { Thumbnailer::handleImageRequest(); } catch (Exception $e) { // Error-Image header("Content-Type: image/jpeg"); header("Cache-Control: no-cache, must-revalidate"); print file_get_contents(dirname(__FILE__) . '/misc/error.jpg'); } exit; break; case 'selectMovie': $handler = new MovieSelectorHandler(); break;
function e($x, $checkonly = 0) { $match = 0; if ($z = Param($checkonly, '&')) { extract($z); } Rem($k, 'args'); #y->return 1 check if value exists#if(j9){var_dump($arr);$_ENV['args'].=',exit';}#e(',exit') $arr = str2Array($x); foreach ($arr as $v) { if (stripos($_ENV[$k], $v)) { $match++; } elseif (!$checkonly) { $_ENV[$k] .= $v; } } return $match; }
private function save_and_redirect($anchor) { $this->save(); // TODO: ugly if (Param('action') == 'json') { return; } $url = '?'; if ($anchor) { $url .= "#o" . $anchor; } echo sprintf('<html><head><script type="text/javascript">location.href="%s"</script></head></html>', $url); exit; }
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); }
function transform($xslfile, $xml, $no_dbg = false) { if (Param('_DBG') && !$no_dbg) { //print_r(debug_backtrace()); //setcookie('111', '222'); //die(); header("Content-type: text/xml"); print trim($xml); die; } //$phpver = explode('.', PHP_VERSION); //if ($phpver[0] == 5) { if (extension_loaded('xslcache')) { $xslt = new xsltCache(); $xslt->importStyleSheet($xslfile); } else { $xslt = new xsltProcessor(); $xsltDoc = DomDocument::load($xslfile); $xslt->importStyleSheet($xsltDoc); } $doc = new DOMDocument(); $load_succesfull = $doc->loadXML($xml); if ((!$load_succesfull || @$_GET['_BAD_XML_TEST']) && !Param('_DBG')) { //error //Redirect( '/error.php?error=xml&url='.$_SERVER['REQUEST_URI'] ); if (SITE == 'http://dev.starhit.ru') { die(file_get_contents('http://www.starhit.ru/error.php?error=xml')); } die(file_get_contents(SITE . '/error.php?error=xml')); } else { $galleries = $doc->getElementsByTagName('gallery'); foreach ($galleries as $gallery) { $images = $gallery->getElementsByTagName('image'); foreach ($images as $image) { foreach ($this->dsp->ae->size as $size => $params) { $img = $image->getElementsByTagName($size)->item(0); $width = $img->getAttribute('width'); if (!$width) { $img_sizes = $this->dsp->eis->GetSizeByURL($img->nodeValue); $img->setAttribute('width', $img_sizes[0]); $img->setAttribute('height', $img_sizes[1]); } } } } $result = $xslt->transformToXML($doc); } //} if (@$_GET['XSLT_INFO']) { echo '$xslt->hasExsltSupport(): ' . $xslt->hasExsltSupport() . ' $xslfile: ' . $xslfile . ' extension_loaded("xslcache"): ' . extension_loaded("xslcache") . ' XSL_CLONE_AUTO: ' . XSL_CLONE_AUTO . ' XSL_CLONE_NEVER: ' . XSL_CLONE_NEVER . ' XSL_CLONE_ALWAYS: ' . XSL_CLONE_ALWAYS . ' LIBXSLT_VERSION: ' . LIBXSLT_VERSION . ' LIBXSLT_DOTTED_VERSION: ' . LIBXSLT_DOTTED_VERSION . ' LIBEXSLT_VERSION: ' . LIBEXSLT_VERSION . ' LIBEXSLT_DOTTED_VERSION: ' . LIBEXSLT_DOTTED_VERSION . ' $xslt: ' . print_r($xslt, 1) . ' '; var_dump($doc->saveXML(), $xsltDoc->saveXML(), $xslt->transformToXML($doc)); die; } return $result; }
protected function process(ViewBag $viewbag) { $this->SetView("MovieSelector"); $viewbag->Query = $search = Param('search') == '' ? '' : Param('search'); if (Param('series') === null) { $series = isset($_COOKIE['__mc_series']) ? trim($_COOKIE['__mc_series']) : ''; $skip_cutted = isset($_COOKIE['__mc_skip_cutted']) ? $_COOKIE['__mc_skip_cutted'] == 'J' : ''; } else { $series = trim(Param('series')); $skip_cutted = Param('skip_cutted') == 'J'; } $viewbag->SkipCutted = $skip_cutted; if (Param('submit')) { list($chanid, $starttime) = explode(".", Param('Movie')); $_SESSION['SelectedMovie'] = new SelectedMovie(); $_SESSION['SelectedMovie']->chanid = $chanid; $_SESSION['SelectedMovie']->starttime = $starttime; unset($_SESSION['list']); Thumbnailer::CleanCache(); $this->Redirect('?rand=' . rand(0, 10000000)); } setCookie("__mc_skip_cutted", $skip_cutted ? 'J' : 'N'); setCookie("__mc_series", $series); $q = new Query("select title, count(1) as cnt, sum(filesize) as size\n\t\t from recorded r\n\t\t where transcoded = 0\n\t\t and deletepending = 0"); if ($skip_cutted) { $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))"); } $q->Append("group by title order by size desc"); $available_series = array(); $viewbag->Series = array(); foreach ($q->Execute() as $v) { $size = sprintf("%.1f", DoubleVal($v->size) / 1024.0 / 1024.0 / 1024.0); $c = new StdClass(); $c->Title = $v->title; $c->Size = $size; $c->Recordings = $v->cnt; $c->Selected = $series == $c->Title; $viewbag->Series[] = $c; } $q = new Query("select *,\n\t\t unix_timestamp(starttime) as unix\n\t\t from recorded r\n\t\t where transcoded = 0\n\t\t and deletepending = 0"); if ($series) { $q->Append("and title = :series"); $q->series = $series; } $words = preg_split('!\\s+!', $viewbag->Query); $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 ($skip_cutted) { $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"); } $viewbag->Movies = array(); foreach ($q->Execute() as $item) { $c = new StdClass(); $c->Value = $item->chanid . '.' . $item->unix; $c->Title = $item->title; $c->Subtitle = $item->subtitle; $c->Size = sprintf("%.1f", DoubleVal($item->filesize / 1024.0 / 1024.0 / 1024.0)); $c->Starttime = $item->starttime; $viewbag->Movies[] = $c; } }
function Pre($x, $filter = 1, $se = '', $mh = 200, $sup = 0, $close = '', $log = '') { $nu = 0; $m2 = 10; $m1 = 0; $min = 400; $nude = $leg = null; #Pre($x,'filter=3&min=300&nude=1'); if ($y = Param($filter, '&')) { extract($y); } if (is_string($x)) { return $x; } if (is_numeric($x)) { return 'numeric:' . $x; } if (!is_array($x)) { return $x; } if (count($x) == 0) { return; } if ($filter == 3) { $m1 = $m2 = 0; } if ($filter == 2) { $mh = 2000; } if ($filter == 4) { $mh = '90%'; } if ($filter) { $x = Array_filter($x); } gt('pre'); pri($x); #preg_replace("~Array\n\t\(~","~Array\n\(\n~"),array("\t",''),$x); if ($se and Preg_Match("~{$se}~is", $x)) { $x = str_ireplace($se, "<b style='background:#FF0'>{$se}</b>", $x); $x = explode("\n", $x); #^\[$se^\] foreach ($x as $k => $v) { if (Preg_Match("~{$se}~is", $v)) { $y[$k] = $v; unset($x[$k]); } } $x = implode("\n", $y + $x); #Highlight search patterns } #kill("<br>".$y);#print_r($y,1)); if ($nude) { return $x; } $mt = -10; if ($sup) { $mt = -4; } # if ($close || $sup) { $leg = "<legend style='margin-left:0'>{$close}{$sup}</legend>"; } else { $x = "\n\n" . $x; } #$m1=10,$m2=21 $mem = Memuse(); #if(J9){var_dump($x);kill();} if ($nu) { return "<pre class='dbpre'>{$x}</pre>"; } return "<fieldset style='min-width:{$min}wpx;border:1px solid #444;padding:0;margin:0 0 0 {$m1};' id='dbf'>{$leg}<pre class='dbpre' style='font:10px courier;white-space:pre-wrap;margin:{$mt} 0 0 {$m2};max-height:{$mh};overflow:auto;'{$log}>" . $x . "</pre></fieldset>"; }