Beispiel #1
0
 public function __construct($url)
 {
     $this->url = CoreUtils::trim($url);
     $this->episodeVideo = self::getEpisodeVideo($this->url);
     self::$id = $this->episodeVideo->id;
     self::getEmbed($this->episodeVideo);
 }
Beispiel #2
0
 public function __construct($url, $reqProv = null)
 {
     $provider = self::getProvider(CoreUtils::trim($url));
     if (!empty($reqProv)) {
         if (!is_array($reqProv)) {
             $reqProv = array($reqProv);
         }
         if (!in_array($provider['name'], $reqProv)) {
             throw new MismatchedProviderException($provider['name']);
         }
     }
     $this->provider = $provider['name'];
     $this->_getDirectUrl($provider['itemid']);
 }
Beispiel #3
0
 /**
  * Finds where the specified url redirects to
  *
  * @param string      $url
  * @param string|null $referrer
  *
  * @return string|null
  */
 static function findRedirectTarget($url, $referrer = null)
 {
     global $http_response_header;
     $cookies = array();
     if (!empty($http_response_header)) {
         foreach ($http_response_header as $header) {
             if (!preg_match(new RegExp('^([^:]+): (.*)$'), $header, $parts) || $parts[1] !== 'Set-Cookie') {
                 continue;
             }
             preg_match(new RegExp('\\s*([^=]+=[^;]+)(?:;|$)'), $parts[2], $cookie);
             $cookies[] = $cookie[1];
         }
     }
     $request = self::legitimateRequest($url, $cookies, $referrer, true);
     return preg_match(new RegExp('Location:\\s+([^\\r\\n]+)'), $request['responseHeaders'], $_match) ? CoreUtils::trim($_match[1]) : null;
 }
Beispiel #4
0
<?php

use App\CoreUtils;
use App\CSRFProtection;
use App\GlobalSettings;
use App\Permission;
use App\RegExp;
use App\Response;
/** @var $data string */
if (!Permission::sufficient('staff') || !POST_REQUEST) {
    CoreUtils::notFound();
}
CSRFProtection::protect();
if (!preg_match(new RegExp('^([gs]et)/([a-z_]+)$'), CoreUtils::trim($data), $_match)) {
    Response::fail('Setting key invalid');
}
$getting = $_match[1] === 'get';
$key = $_match[2];
$currvalue = GlobalSettings::get($key);
if ($getting) {
    Response::done(array('value' => $currvalue));
}
if (!isset($_POST['value'])) {
    Response::fail('Missing setting value');
}
try {
    $newvalue = GlobalSettings::process($key);
} catch (Exception $e) {
    Response::fail('Preference value error: ' . $e->getMessage());
}
if ($newvalue === $currvalue) {
Beispiel #5
0
            CoreUtils::notFound();
    }
}
if (empty($task)) {
    CoreUtils::loadPage(array('title' => 'Admin Area', 'do-css', 'js' => array('Sortable', $do)));
}
switch ($task) {
    case "logs":
        $type = Logs::validateRefType('type', true, true);
        if (isset($_GET['type']) && preg_match(new RegExp('/^[a-z_]+$/'), $_GET['type']) && isset(Logs::$LOG_DESCRIPTION[$_GET['type']])) {
            $type = $_GET['type'];
        }
        if (!isset($_GET['by'])) {
            $by = null;
        } else {
            switch (strtolower(CoreUtils::trim($_GET['by']))) {
                case 'me':
                case 'you':
                    $initiator = $currentUser->id;
                    $by = 'you';
                    break;
                case 'web server':
                    $initiator = 0;
                    $by = 'Web server';
                    break;
                default:
                    $by = Users::validateName('by', null, true);
                    if (isset($by)) {
                        $by = Users::get($by, 'name', 'id,name');
                        $initiator = $by->id;
                        $by = $initiator === $currentUser->id ? 'me' : $by->name;
Beispiel #6
0
 function testTrim()
 {
     $result = CoreUtils::trim('I    like    spaces');
     self::assertEquals('I like spaces', $result);
 }
Beispiel #7
0
     $append = array('order' => $part);
     $index = "(index: {$part})";
     if (empty($c['label'])) {
         Response::fail("You must specify a {$color} name {$index}");
     }
     $label = CoreUtils::trim($c['label']);
     CoreUtils::checkStringValidity($label, "{$Color} {$index} name", INVERSE_PRINTABLE_ASCII_PATTERN);
     $ll = CoreUtils::length($label);
     if ($ll < 3 || $ll > 30) {
         Response::fail("The {$color} name must be between 3 and 30 characters in length {$index}");
     }
     $append['label'] = $label;
     if (empty($c['hex'])) {
         Response::fail("You must specify a {$color} code {$index}");
     }
     $hex = CoreUtils::trim($c['hex']);
     if (!$HEX_COLOR_REGEX->match($hex, $_match)) {
         Response::fail("HEX {$color} is in an invalid format {$index}");
     }
     $append['hex'] = '#' . strtoupper($_match[1]);
     $colors[] = $append;
 }
 if (!$adding) {
     $CGDb->where('groupid', $Group['groupid'])->delete('colors');
 }
 $colorError = false;
 foreach ($colors as $c) {
     $c['groupid'] = $Group['groupid'];
     if (!$CGDb->insert('colors', $c)) {
         $colorError = true;
         error_log("Database error triggered by user {$currentUser->id} ({$currentUser->name}) while saving colors: " . $CGDb->getLastError());
Beispiel #8
0
 /**
  * Replaces non-alphanumeric characters in the appearance label with dashes
  *
  * @param array $Appearance
  *
  * @return string
  */
 static function getSafeLabel($Appearance)
 {
     return CoreUtils::trim(preg_replace(new RegExp('-+'), '-', preg_replace(new RegExp('[^A-Za-z\\d\\-]'), '-', $Appearance['label'])), '-');
 }
Beispiel #9
0
 static function getServerOS()
 {
     return PHP_OS === 'WINNT' ? str_replace('Caption=', '', CoreUtils::trim(shell_exec('wmic os get Caption /value'))) : preg_replace(new RegExp('^[\\s\\S]*Description:\\s+(\\w+).*(\\d+\\.\\d+(?:\\.\\d)?)\\s+(\\(\\w+\\))[\\s\\S]*$'), '$1 $2 $3', shell_exec('lsb_release -da'));
 }