예제 #1
0
            exit;
        } else {
            $gmtDate = gmdate("D, d M Y H:i:s \\G\\M\\T", $lastModifiedDate);
            header('Last-Modified: ' . $gmtDate);
        }
    }
}
// This function uses a static variable to track the most recent
// last modification time
function lastModificationTime($time = 0)
{
    static $last_mod;
    if (!isset($last_mod) || $time > $last_mod) {
        $last_mod = $time;
    }
    return $last_mod;
}
lastModificationTime(filemtime(__FILE__));
cacheHeaders(lastModificationTime());
header("Content-type: text/javascript; charset: UTF-8");
ob_start("ob_gzhandler");
foreach (explode(",", $_GET['load']) as $value) {
    if (is_file("{$value}.js")) {
        $real_path = mb_strtolower(realpath("{$value}.js"));
        if (strpos($real_path, mb_strtolower(dirname(__FILE__))) !== false || strpos($real_path, mb_strtolower(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR)) !== false) {
            lastModificationTime(filemtime("{$value}.js"));
            include "{$value}.js";
            echo "\n";
        }
    }
}
예제 #2
0
 public function bptest($customerno)
 {
     cacheHeaders(false);
     $this->load->Model('basepointapi', 'bp');
     $this->load->Model('Movies');
     if (!$customerno) {
         die('missing customerno');
     }
     if ($this->config->item('platform') == 'dev') {
         $this->readdb = $this->load->database('thomasdev', true);
     } else {
         $this->readdb = $this->load->database('prod_read', true);
         if (!$this->readdb->initialize()) {
             $this->readdb = $this->load->database('prod', true);
         }
     }
     $res = $this->readdb->select('content, content_desc')->group_by('content')->where('type', 'movie')->where('origin', 'yousee')->where('create_time >', '2012-12-01')->where('customerno', $customerno)->order_by('create_time', 'desc')->get('log_reststreams');
     echo '<table style="width:40%;float:left">';
     echo '<caption style="font-size:1.4em;font-weight:bold">In YouSee stream log</caption>';
     foreach ($res->result() as $row) {
         echo '<tr><td>' . $row->content . '</td><td>' . $row->content_desc . '</td></tr>';
     }
     echo '</table>';
     echo '<h1></h1>';
     $recommendations = $this->bp->user_product($customerno);
     echo '<table style="width:40%;float:left">';
     echo '<caption style="font-size:1.4em;font-weight:bold">http://bpm-recyou-prod.appspot.com/api/user_product/' . $customerno . ' response</caption>';
     foreach ($recommendations as $recommendation) {
         $movie = $this->Movies->getMovie($recommendation->productid, 'id');
         echo '<tr><td>' . $movie['id'] . '</td><td>' . $movie['title'] . '</td></tr>';
     }
     echo '</table>';
 }
예제 #3
0
            }
        }
    }
    if (strpos($file['path'], G_ROOTPATH . 'libraries') !== false && strpos($file['path'], G_ROOTPATH . 'libraries/language') === false && $file['mime_type'] != "application/inc") {
        throw new EfrontFileException(_ILLEGALPATH . ': ' . $file['path'], EfrontFileException::ILLEGAL_PATH);
    }
    if (pathinfo($file['path'], PATHINFO_EXTENSION) == 'php') {
        throw new EfrontFileException(_ILLEGALPATH . ': ' . $file['path'], EfrontFileException::ILLEGAL_PATH);
    }
    if (strpos($file['path'], G_ROOTPATH . 'backups') !== false && $_SESSION['s_type'] != 'administrator') {
        throw new EfrontFileException(_YOUCANNOTACCESSTHEREQUESTEDRESOURCE, EfrontFileException::UNAUTHORIZED_ACTION);
    }
    if (isset($_GET['action']) && $_GET['action'] == 'download') {
        $file->sendFile(true);
    } else {
        cacheHeaders(lastModificationTime(filemtime($file['path'])));
        $file->sendFile(false);
    }
} catch (EfrontFileException $e) {
    if ($e->getCode() == EfrontFileException::FILE_NOT_EXIST) {
        header("HTTP/1.0 404");
    }
    echo EfrontSystem::printErrorMessage($e->getMessage());
}
function cacheHeaders($lastModifiedDate)
{
    if ($lastModifiedDate) {
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $lastModifiedDate) {
            if (php_sapi_name() == 'CGI') {
                Header("Status: 304 Not Modified");
            } else {
예제 #4
0
 public function activitystream_get()
 {
     cacheHeaders(false);
     $this->load->Model('User');
     $this->load->Model('Userlists');
     $this->load->Model('Transaction');
     $flavour = $this->get('flavour');
     $fields = $this->get('fields');
     $yspro = $this->get('yspro') ? $this->get('yspro') : ($this->input->server('HTTP_X_YSPRO') ? $this->input->server('HTTP_X_YSPRO') : get_cookie('yspro'));
     if (!$flavour) {
         $flavour = 'yousee';
     }
     $userinfo = null;
     if ($flavour == 'yousee') {
         $userinfo = Facades\YSPRO::getUserInfo($yspro);
     } else {
         if ($flavour == 'blockbuster') {
             $userinfo = Facades\BlockBusterLogin::getUserInfo($yspro);
         }
     }
     if (!$userinfo) {
         return $this->resolveCorrectSessionError();
     }
     if ($flavour == 'yousee') {
         $profile_id = Facades\YSPRO::getDefaultProfileId($userinfo->userId, $flavour);
     } else {
         if ($flavour == 'blockbuster') {
             $profile_id = Facades\BlockBusterLogin::getDefaultProfileId($userinfo->userId, $flavour);
         }
     }
     $items = array();
     $lists = $this->Userlists->getLists($userinfo->userId, 'movies', $profile_id, $flavour);
     $touchedFavorites = array();
     if (count($lists)) {
         $rawitems = $this->Userlists->getItemsInList($lists[0]['id'], true);
         if ($rawitems && is_array($rawitems) && count($rawitems)) {
             foreach ($rawitems as $item) {
                 if (!empty($touchedFavorites[$item['track_id']])) {
                     continue;
                 }
                 $items[] = array('id' => $item['track_id'], 'timestamp' => $item['create_time'], 'activitytype' => 'favorite');
                 $touchedFavorites[$item['track_id']] = true;
             }
         }
     }
     $transactions = $this->Transaction->getUserTransactionLog($userinfo->userId, false, false, false, 'blockbuster', true);
     $dvbPurchases = with(new \OdpPermissions\DvbSmartcard())->getSmartcardPurchasesForUser($userinfo);
     if (count($dvbPurchases)) {
         foreach ($dvbPurchases as $dvbPurchase) {
             $transactions[] = array('pay_action' => 'RENT', 'started' => date('Y-m-d H:i:s', $dvbPurchase->start), 'product_id' => $dvbPurchase->id, 'createtime' => date('Y-m-d H:i:s', $dvbPurchase->start));
         }
     }
     $touchedTransactions = array();
     foreach ($transactions as $transaction) {
         $pay_action = $transaction['pay_action'];
         if ($transaction['started'] && $pay_action == 'RENT') {
             if (strtotime($transaction['started']) + $this->config->item('rental_period') < time()) {
                 continue;
             }
         }
         if (isset($touchedTransactions[$transaction['product_id']])) {
             continue;
         } else {
             $touchedTransactions[$transaction['product_id']] = true;
         }
         $items[] = array('id' => $transaction['product_id'], 'timestamp' => $transaction['createtime'], 'activitytype' => strtolower("transaction_{$pay_action}"));
     }
     $sortKey = array();
     foreach ($items as $key => $item) {
         $sortKey[$key] = strtotime($item['timestamp']);
     }
     array_multisort($sortKey, SORT_NUMERIC, SORT_DESC, $items);
     $itemObjects = $movieIds = array();
     array_walk($items, function ($val) use(&$movieIds) {
         $movieIds[] = $val['id'];
     });
     if (count($movieIds)) {
         $movieData = Facades\VodRepo::getFromIds($movieIds, '*', null, null, null, $flavour == 'blockbuster', $flavour == 'blockbuster');
     }
     $touchedTvSeriesSeasons = array();
     foreach ($items as $item) {
         $movie = $this->findMovieData($item['id'], $movieData);
         if (!$movie) {
             continue;
         }
         $movie->genres = Facades\VodRepo::getGenresForMovie($movie->id);
         $movieDto = new \OdpVodMeta\Dto\Movie($movie, \OdpConfig\Config::getInstance(), new \OdpPopularity\Vod(Facades\VodRepo::getInstance()), Facades\VodRepo::getInstance(), $flavour);
         if ($movieDto->assettype == 'episode') {
             $tvSeriesSeasonIdentifier = $movieDto->episodeinfo->seasonid . $item['activitytype'];
             if (isset($touchedTvSeriesSeasons[$tvSeriesSeasonIdentifier])) {
                 continue;
             } else {
                 $touchedTvSeriesSeasons[$tvSeriesSeasonIdentifier] = true;
             }
         }
         $movieDto->activity = (object) array("_type" => $item['activitytype'], "timestamp" => $item['timestamp'], "unixtimestamp" => strtotime($item['timestamp']));
         if ($fields) {
             $filtering = new OdpOutput\Filtering();
             $movieDto = $filtering->filter($filtering->prepareFields($fields), $movieDto);
         }
         $itemObjects[] = $movieDto;
     }
     $this->response(array('items' => $itemObjects), 200);
 }