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 processLabel() : string
 {
     $label = preg_replace(new RegExp('(?:(f)ull[-\\s](b)od(?:y|ied)(\\sversion)?)', 'i'), '<strong class="color-darkblue">$1ull $2ody</strong>$3', CoreUtils::escapeHTML($this->label));
     $label = preg_replace(new RegExp('(?:(f)ace[-\\s](o)nly(\\sversion)?)', 'i'), '<strong class="color-darkblue">$1ace $2nly</strong>$3', $label);
     $label = preg_replace(new RegExp('(?:(f)ull\\s(s)cene?)', 'i'), '<strong class="color-darkblue">$1ull $2cene</strong>$3', $label);
     $label = preg_replace(new RegExp('(?:(e)ntire\\s(s)cene?)', 'i'), '<strong class="color-darkblue">$1ntire $2cene</strong>$3', $label);
     return $label;
 }
Beispiel #3
0
 static function getElasticSearchVersion()
 {
     try {
         $info = CoreUtils::elasticClient()->info();
     } catch (ElasticNoNodesAvailableException $e) {
         return;
     }
     return $info['version']['number'];
 }
Beispiel #4
0
 public function isBroken() : bool
 {
     global $Database;
     if (isset($this->not_broken_at)) {
         $nb = strtotime($this->not_broken_at);
         if ($nb + Time::$IN_SECONDS['hour'] * 2 > time()) {
             return false;
         }
     }
     $url = VideoProvider::getEmbed($this, VideoProvider::URL_ONLY);
     if ($this->provider === 'yt') {
         $url = "http://www.youtube.com/oembed?url={$url}";
     }
     $broken = !CoreUtils::isURLAvailable($url);
     if (!$broken) {
         $this->not_broken_at = date('c');
         $Database->whereEp($this->season, $this->episode)->where('provider', $this->provider)->where('id', $this->id)->update('episodes__videos', array('not_broken_at' => $this->not_broken_at));
     }
     return $broken;
 }
Beispiel #5
0
echo !empty($_GET['q']) ? " value='" . CoreUtils::aposEncode($_GET['q']) . "'" : '';
?>
 title='Search'>
		<button type='submit'  class='blue'>Search</button>
		<button type='button' class='green typcn typcn-flash sanic-button' title="I'm feeling lucky"></button>
		<button type='reset' class='red typcn typcn-times' title='Clear'<?php 
echo empty($_GET['q']) ? ' disabled' : '';
?>
></button>
	</form>
<?  }
	else echo CoreUtils::notice('warn','<span class="typcn typcn-warning"></span> <strong>ElasticSearch server is down!</strong> Please <a class="send-feedback">let us know</a>, and in the meantime, use the <a class="btn darkblue typcn typcn-th-menu" href="/cg'.($EQG?'/eqg':'').'/full">Full List</a> to find appearances faster. Sorry for the inconvenience.',true); ?>
	<?php 
echo $Pagination->HTML . Appearances::getHTML($Ponies) . $Pagination->HTML;
?>
</div>

<?  $export = array(
		'Color' => $Color,
		'color' => $color,
		'EQG' => $EQG,
		'AppearancePage' => false,
	);
	if (Permission::sufficient('staff'))
		$export = array_merge($export, array(
			'TAG_TYPES_ASSOC' => Tags::$TAG_TYPES_ASSOC,
			'MAX_SIZE' => CoreUtils::getMaxUploadSize(),
			'HEX_COLOR_PATTERN' => $HEX_COLOR_REGEX,
		));
	echo CoreUtils::exportVars($export); ?>
Beispiel #6
0
use App\Episodes;
use App\Permission;
?>
<div id="content">
	<h1><?php 
echo empty($Episodes) ? 'No episodes found' : 'Episode list';
?>
</h1>
<?  if (empty($Episodes)){ ?>
	<p>There are no episodes stored in the database</p>
<?  }
	if (Permission::sufficient('staff')) { ?>
	<div class="actions">
		<button id="add-episode" class="green typcn typcn-plus">Add Episode</button>
	</div>
<?      echo CoreUtils::exportVars(array('EP_TITLE_REGEX' => $EP_TITLE_REGEX));
	}
	echo $Pagination;
	if (!empty($Episodes) || (empty($Episodes) && Permission::sufficient('staff'))){ ?>
	<table id="episodes">
		<thead>
			<tr>
				<th>S<span class="mobile-hide">eason</span></th>
				<th>E<span class="mobile-hide">pisode</span></th>
				<th>Title & Air Date</th>
			</tr>
		</thead>
		<tbody><?php 
echo Episodes::getTableTbody($Episodes);
?>
</tbody>
Beispiel #7
0
 /**
  * Turns an 'episode' database row into a readable title
  *
  * @param bool        $returnArray Whether to return as an array instead of string
  * @param string      $arrayKey
  * @param bool        $append_num  Append overall # to ID
  *
  * @return string|array
  */
 public function formatTitle($returnArray = false, $arrayKey = null, $append_num = true)
 {
     if ($returnArray === AS_ARRAY) {
         $arr = array('id' => $this->getID(array('append_num' => $append_num)), 'season' => $this->season ?? null, 'episode' => $this->episode ?? null, 'title' => isset($this->title) ? CoreUtils::escapeHTML($this->title) : null);
         if (!empty($arrayKey)) {
             return isset($arr[$arrayKey]) ? $arr[$arrayKey] : null;
         } else {
             return $arr;
         }
     }
     if ($this->isMovie) {
         return $this->title;
     }
     return $this->getID(array('pad' => true)) . ': ' . $this->title;
 }
Beispiel #8
0
<?php

use App\CoreUtils;
CoreUtils::loadPage(array('title' => 'Poly', 'js' => array('jquery.ba-throttle-debounce', 'poly-editor', $do), 'css' => array('poly-editor', $do)));
Beispiel #9
0
 /**
  * Checks if a deviation is in the club
  *
  * @param int|string $DeviationID
  *
  * @return bool|int
  */
 static function isDeviationInClub($DeviationID)
 {
     if (!is_int($DeviationID)) {
         $DeviationID = intval(CoreUtils::substring($DeviationID, 1), 36);
     }
     try {
         $DiFiRequest = HTTP::legitimateRequest("http://deviantart.com/global/difi/?c[]=\"DeviationView\",\"getAllGroups\",[\"{$DeviationID}\"]&t=json");
     } catch (CURLRequestException $e) {
         return $e->getCode();
     }
     if (empty($DiFiRequest['response'])) {
         return 1;
     }
     $DiFiRequest = @JSON::decode($DiFiRequest['response'], JSON::AS_OBJECT);
     if (empty($DiFiRequest->DiFi->status)) {
         return 2;
     }
     if ($DiFiRequest->DiFi->status !== 'SUCCESS') {
         return 3;
     }
     if (empty($DiFiRequest->DiFi->response->calls)) {
         return 4;
     }
     if (empty($DiFiRequest->DiFi->response->calls[0])) {
         return 5;
     }
     if (empty($DiFiRequest->DiFi->response->calls[0]->response)) {
         return 6;
     }
     if (empty($DiFiRequest->DiFi->response->calls[0]->response->status)) {
         return 7;
     }
     if ($DiFiRequest->DiFi->response->calls[0]->response->status !== 'SUCCESS') {
         return 8;
     }
     if (empty($DiFiRequest->DiFi->response->calls[0]->response->content->html)) {
         return 9;
     }
     $html = $DiFiRequest->DiFi->response->calls[0]->response->content->html;
     return strpos($html, 'gmi-groupname="MLP-VectorClub">') !== false;
 }
Beispiel #10
0
 /**
  * Redirection
  *
  * @param string $url  Redirection target URL
  * @param int    $http HTTP status code
  */
 public static function redirect($url = '/', $http = 301)
 {
     header("Location: {$url}", true, $http);
     $urlenc = CoreUtils::aposEncode($url);
     die("Click <a href='{$urlenc}'>here</a> if you aren't redirected.<script>location.replace(" . JSON::encode($url) . ")</script>");
 }
Beispiel #11
0
 $thing = $_match[1];
 $Post = $Database->where('id', $_match[2])->getOne("{$thing}s");
 if (empty($Post)) {
     Response::fail("The specified {$thing} does not exist");
 }
 // Link is already full size, we're done
 if (preg_match($FULLSIZE_MATCH_REGEX, $Post->fullsize)) {
     Response::done(array('fullsize' => $Post->fullsize));
 }
 // Reverse submission lookup
 $StashItem = $Database->where('fullsize', $Post->fullsize)->orWhere('preview', $Post->preview)->getOne('deviation_cache', 'id,fullsize,preview');
 if (empty($StashItem['id'])) {
     Response::fail('Stash URL lookup failed');
 }
 try {
     $fullsize = CoreUtils::getFullsizeURL($StashItem['id'], 'sta.sh');
     if (!is_string($fullsize)) {
         if ($fullsize === 404) {
             $Database->where('provider', 'sta.sh')->where('id', $StashItem['id'])->delete('deviation_cache');
             $Database->where('preview', $StashItem['preview'])->orWhere('fullsize', $StashItem['fullsize'])->update('requests', array('fullsize' => null, 'preview' => null));
             $Database->where('preview', $StashItem['preview'])->orWhere('fullsize', $StashItem['fullsize'])->update('reservations', array('fullsize' => null, 'preview' => null));
             Response::fail('The original image has been deleted from Sta.sh', array('rmdirect' => true));
         } else {
             throw new Exception("Code {$fullsize}; Could not find the URL");
         }
     }
 } catch (Exception $e) {
     Response::fail('Error while finding URL: ' . $e->getMessage());
 }
 // Check image availability
 if (!!DeviantArt::isImageAvailable($fullsize)) {
Beispiel #12
0
 static function isImageAvailable(string $url) : bool
 {
     if (CoreUtils::isURLAvailable($url)) {
         return true;
     }
     CoreUtils::msleep(300);
     if (CoreUtils::isURLAvailable($url)) {
         return true;
     }
     CoreUtils::msleep(300);
     if (CoreUtils::isURLAvailable("{$url}?")) {
         return true;
     }
     CoreUtils::msleep(300);
     if (CoreUtils::isURLAvailable("{$url}?")) {
         return true;
     }
     return false;
 }
Beispiel #13
0
        $ids = [];
        foreach ($search['hits']['hits'] as $hit) {
            $ids[] = $hit['_id'];
        }
        $Ponies = $CGDb->where('id IN (' . implode(',', $ids) . ')')->orderBy('order', 'ASC')->get('appearances');
    }
}
if (!$elasticAvail) {
    $_EntryCount = $CGDb->where('ishuman', $EQG)->where('id != 0')->count('appearances');
    $Pagination = new Pagination('cg', $AppearancesPerPage, $_EntryCount);
    $Ponies = Appearances::get($EQG, $Pagination->getLimit());
}
if (isset($_REQUEST['GOFAST'])) {
    if (empty($Ponies[0]['id'])) {
        Response::fail('The search returned no results.');
    }
    Response::done(array('goto' => "{$CGPath}/v/{$Ponies[0]['id']}-" . Appearances::getSafeLabel($Ponies[0])));
}
CoreUtils::fixPath("{$CGPath}/{$Pagination->page}" . (!empty($Restrictions) ? "?q={$SearchQuery}" : ''));
$heading = ($EQG ? 'EQG ' : '') . "{$Color} Guide";
$title .= "Page {$Pagination->page} - {$heading}";
if (isset($_GET['js'])) {
    $Pagination->respond(Appearances::getHTML($Ponies, NOWRAP), '#list');
}
$settings = array('title' => $title, 'heading' => $heading, 'css' => array($do), 'js' => array('jquery.qtip', 'jquery.ctxmenu', $do, 'paginate'));
if (Permission::sufficient('staff')) {
    $settings['css'] = array_merge($settings['css'], $GUIDE_MANAGE_CSS);
    $settings['js'] = array_merge($settings['js'], $GUIDE_MANAGE_JS);
}
CoreUtils::loadPage($settings);
use App\Tags;
/** @var $heading string */
/** @var $Changes array */
?>
<div id="content">
	<h1><?php 
echo $heading;
?>
</h1>
	<p>Displaying <?php 
echo $Pagination->itemsPerPage;
?>
 items/page</p>
	<p class='align-center links'>
		<a class='btn darkblue typcn typcn-arrow-back' href="/cg">Back to <?php 
echo $Color;
?>
 Guide</a>
		<a class='btn darkblue typcn typcn-tags' href="/cg/tags">List of tags</a>
	</p>
	<?php 
echo $Pagination->HTML . CGUtils::getChangesHTML($Changes, WRAP, SHOW_APPEARANCE_NAMES) . $Pagination->HTML;
?>
</div>

<?  echo CoreUtils::exportVars(array(
		'Color' => $Color,
		'color' => $color,
		'TAG_TYPES_ASSOC' => Tags::$TAG_TYPES_ASSOC,
	));
Beispiel #15
0
 static function getAppearancesSectionHTML(Episode $Episode) : string
 {
     global $CGDb, $Color;
     $HTML = '';
     $EpTagIDs = Episodes::getTagIDs($Episode);
     if (!empty($EpTagIDs)) {
         $TaggedAppearances = $CGDb->rawQuery("SELECT p.id, p.label, p.private\n\t\t\t\tFROM tagged t\n\t\t\t\tLEFT JOIN appearances p ON t.ponyid = p.id\n\t\t\t\tWHERE t.tid IN (" . implode(',', $EpTagIDs) . ") && p.ishuman = ?\n\t\t\t\tORDER BY p.label", array($Episode->isMovie));
         if (!empty($TaggedAppearances)) {
             $hidePreviews = UserPrefs::get('ep_noappprev');
             $pages = CoreUtils::makePlural('page', count($TaggedAppearances));
             $HTML .= "<section class='appearances'><h2>Related <a href='/cg'>{$Color} Guide</a> {$pages}</h2>";
             $LINKS = '<ul>';
             $isStaff = Permission::sufficient('staff');
             foreach ($TaggedAppearances as $p) {
                 $safeLabel = Appearances::getSafeLabel($p);
                 if (Appearances::isPrivate($p, true)) {
                     $preview = "<span class='typcn typcn-" . ($isStaff ? 'lock-closed' : 'time') . " color-" . ($isStaff ? 'orange' : 'darkblue') . "'></span> ";
                 } else {
                     if ($hidePreviews) {
                         $preview = '';
                     } else {
                         $preview = Appearances::getPreviewURL($p);
                         $preview = "<img src='{$preview}' class='preview'>";
                     }
                 }
                 $LINKS .= "<li><a href='/cg/v/{$p['id']}-{$safeLabel}'>{$preview}{$p['label']}</a></li>";
             }
             $HTML .= "{$LINKS}</ul></section>";
         }
     }
     return $HTML;
 }
Beispiel #16
0
    static function getPendingReservationsHTML($UserID, $sameUser, &$YouHave = null)
    {
        global $Database, $currentUser;
        $YouHave = $sameUser ? 'You have' : 'This user has';
        $PrivateSection = $sameUser ? Users::PROFILE_SECTION_PRIVACY_LEVEL['staff'] : '';
        $cols = "id, season, episode, preview, label, posted, reserved_by";
        $PendingReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('reservations', null, $cols);
        $PendingRequestReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('requests', null, "{$cols}, reserved_at, true as requested_by");
        $TotalPending = count($PendingReservations) + count($PendingRequestReservations);
        $hasPending = $TotalPending > 0;
        $HTML = '';
        if (Permission::sufficient('staff') || $sameUser) {
            $pendingCountReadable = $hasPending > 0 ? "<strong>{$TotalPending}</strong>" : 'no';
            $posts = CoreUtils::makePlural('reservation', $TotalPending);
            $gamble = $TotalPending < 4 && $sameUser ? ' <button id="suggestion" class="btn orange typcn typcn-lightbulb">Suggestion</button>' : '';
            $HTML .= <<<HTML
<section class='pending-reservations'>
<h2>{$PrivateSection}Pending reservations{$gamble}</h2>
\t\t\t\t<span>{$YouHave} {$pendingCountReadable} pending {$posts}
HTML;
            if ($hasPending) {
                $HTML .= " which ha" . ($TotalPending !== 1 ? 've' : 's') . "n't been marked as finished yet";
            }
            $HTML .= ".";
            if ($sameUser) {
                $HTML .= " Please keep in mind that the global limit is 4 at any given time. If you reach the limit, you can't reserve any more images until you finish or cancel some of your pending reservations.";
            }
            $HTML .= "</span>";
            if ($hasPending) {
                /** @var $Posts Post[] */
                $Posts = array_merge(Posts::getReservationsSection($PendingReservations, RETURN_ARRANGED)['unfinished'], array_filter(array_values(Posts::getRequestsSection($PendingRequestReservations, RETURN_ARRANGED)['unfinished'])));
                usort($Posts, function (Post $a, Post $b) {
                    $a = strtotime($a->posted);
                    $b = strtotime($b->posted);
                    return -($a < $b ? -1 : ($a === $b ? 0 : 1));
                });
                $LIST = '';
                foreach ($Posts as $Post) {
                    unset($_);
                    $postLink = $Post->toLink($_);
                    $postAnchor = $Post->toAnchor(null, $_);
                    $label = !empty($Post->label) ? "<span class='label'>{$Post->label}</span>" : '';
                    $is_request = isset($Post->rq);
                    $reservation_time_known = !empty($Post->reserved_at);
                    $posted = Time::tag($is_request && $reservation_time_known ? $Post->reserved_at : $Post->posted);
                    $PostedAction = $is_request && !$reservation_time_known ? 'Posted' : 'Reserved';
                    $contestable = $Post->isOverdue() ? Posts::CONTESTABLE : '';
                    $LIST .= <<<HTML
<li>
<div class='image screencap'>
\t<a href='{$postLink}'><img src='{$Post->preview}'></a>
</div>
{$label}
<em>{$PostedAction} under {$postAnchor} {$posted}</em>{$contestable}
<div>
\t<a href='{$postLink}' class='btn blue typcn typcn-arrow-forward'>View</a>
\t<button class='red typcn typcn-user-delete cancel'>Cancel</button>
</div>
</li>
HTML;
                }
                $HTML .= "<ul>{$LIST}</ul>";
            }
            $HTML .= "</section>";
        }
        return $HTML;
    }
Beispiel #17
0
 private function _getDirectUrl($id)
 {
     switch ($this->provider) {
         case 'imgur':
             $this->fullsize = "https://i.imgur.com/{$id}.png";
             $this->preview = "https://i.imgur.com/{$id}m.png";
             self::_checkImageAllowed($this->fullsize);
             break;
         case 'derpibooru':
             $Data = @file_get_contents("http://derpibooru.org/{$id}.json");
             if (empty($Data)) {
                 throw new \Exception('The requested image could not be found on Derpibooru');
             }
             $Data = JSON::decode($Data);
             if (isset($Data['duplicate_of'])) {
                 return $this->_getDirectUrl($Data['duplicate_of']);
             }
             if (!isset($Data['is_rendered'])) {
                 error_log("Invalid Derpibooru response for ID {$id}\n" . var_export($Data, true));
                 throw new \Exception('Derpibooru returned an invalid API response. This issue has been logged, please <a class="send-feedback">remind us</a> to take a look.');
             }
             if (!$Data['is_rendered']) {
                 throw new \Exception('The image was found but it hasn\'t been rendered yet. Please wait for it to render and try again shortly.');
             }
             $this->fullsize = $Data['representations']['full'];
             $this->preview = $Data['representations']['small'];
             self::_checkImageAllowed($this->fullsize, $Data['mime_type']);
             break;
         case 'puush':
             $path = "http://puu.sh/{$id}";
             $image = @file_get_contents($path);
             if (empty($image) || $image === 'That puush could not be found.') {
                 throw new \Exception('The requested image could not be found on Puu.sh');
             }
             if ($image === 'You do not have access to view that puush.') {
                 throw new \Exception('The requested image is a private Puu.sh and the token is missing from the URL');
             }
             self::_checkImageAllowed($path);
             $this->fullsize = $this->preview = $path;
             break;
         case 'dA':
         case 'fav.me':
         case 'sta.sh':
             if ($this->provider === 'dA') {
                 $id = 'd' . base_convert($id, 10, 36);
                 $this->provider = 'fav.me';
             }
             try {
                 $CachedDeviation = DeviantArt::getCachedSubmission($id, $this->provider);
                 if (!DeviantArt::isImageAvailable($CachedDeviation['preview'])) {
                     $preview = CoreUtils::aposEncode($CachedDeviation['preview']);
                     throw new \Exception("The preview image appears to be unavailable. Please make sure <a href='{$preview}'>this link</a> works and try again, or re-submit the deviation if this persists.");
                 }
                 if (!DeviantArt::isImageAvailable($CachedDeviation['fullsize'])) {
                     $fullsize = CoreUtils::aposEncode($CachedDeviation['fullsize']);
                     throw new \Exception("The submission appears to be unavailable. Please make sure <a href='{$fullsize}'>this link</a> works and try again, or re-submit the deviation if this persists.");
                 }
             } catch (CURLRequestException $e) {
                 if ($e->getCode() === 404) {
                     throw new \Exception('The requested image could not be found');
                 }
                 throw new \Exception($e->getMessage());
             }
             if (empty($CachedDeviation)) {
                 throw new \Exception("{$this->provider} submission information could not be fetched for {$id}");
             }
             $this->preview = $CachedDeviation['preview'];
             $this->fullsize = $CachedDeviation['fullsize'];
             $this->title = $CachedDeviation['title'];
             $this->author = $CachedDeviation['author'];
             self::_checkImageAllowed($this->preview);
             self::_checkImageAllowed($this->fullsize);
             break;
         case 'lightshot':
             $page = @file_get_contents("http://prntscr.com/{$id}");
             if (empty($page)) {
                 throw new \Exception('The requested page could not be found');
             }
             if (!preg_match(new RegExp('<img\\s+class="image__pic[^"]*"\\s+src="http://i\\.imgur\\.com/([A-Za-z\\d]+)\\.'), $page, $_match)) {
                 throw new \Exception('The requested image could not be found');
             }
             $this->provider = 'imgur';
             $this->_getDirectUrl($_match[1]);
             break;
         default:
             throw new \Exception("The image could not be retrieved due to a missing handler for the provider \"{$this->provider}\"");
     }
     $this->preview = URL::makeHttps($this->preview);
     $this->fullsize = URL::makeHttps($this->fullsize);
     $this->id = $id;
 }
Beispiel #18
0
<?php

use App\CoreUtils;
CoreUtils::loadPage(array('title' => 'Components', 'no-robots'));
Beispiel #19
0
use App\CoreUtils;
/** @var $heading string */
/** @var $Appearance array */
/** @var $Colors array */
/** @var $Map array */
/** @var $AllColors array */
/** @var $ColorGroups array */
?>
<div id="content">
	<h1>Sprite Color Checker</h1>
	<p><a href="/cg/v/<?php 
echo $Appearance['id'];
?>
"><span class="typcn typcn-arrow-back"></span> Back to appearrance page</a></p>

	<section class="checker">
		<div id="svg-cont"></div>
		<div id="input-cont"><h3>JavaScript is required to use the viewer</h3></div>
	</section>
	<section class="color-list">
		<ul id="colors" class="colors"><?php 
foreach ($ColorGroups as $cg) {
    echo ColorGroups::getHTML($cg, $AllColors, WRAP, NO_COLON, OUTPUT_COLOR_NAMES, FORCE_EXTRA_INFO);
}
?>
</ul>
	</section>
</div>
<?php 
echo CoreUtils::exportVars(array('AppearanceID' => $Appearance['id'], 'AppearanceColors' => $Colors, 'SpriteColorList' => $Map['colors']));
Beispiel #20
0
 function testSet()
 {
     $array = [];
     CoreUtils::set($array, 'key', 'value');
     self::assertArrayHasKey('key', $array);
     self::assertEquals('value', $array['key']);
     $object = new stdClass();
     CoreUtils::set($object, 'key', 'value');
     self::assertObjectHasAttribute('key', $object);
     self::assertEquals('value', $object->key);
 }
Beispiel #21
0
 /**
  * Get HTML for a color group
  *
  * @param int|array  $GroupID
  * @param array|null $AllColors
  * @param bool       $wrap
  * @param bool       $colon
  * @param bool       $colorNames
  * @param bool       $force_extra_info
  *
  * @return string
  */
 static function getHTML($GroupID, $AllColors = null, bool $wrap = true, bool $colon = true, bool $colorNames = false, bool $force_extra_info = false) : string
 {
     global $CGDb;
     if (is_array($GroupID)) {
         $Group = $GroupID;
     } else {
         $Group = $CGDb->where('groupid', $GroupID)->getOne('colorgroups');
     }
     $label = CoreUtils::escapeHTML($Group['label']) . ($colon ? ': ' : '');
     $HTML = "<span class='cat'>{$label}" . ($colorNames && Permission::sufficient('staff') ? '<span class="admin"><button class="blue typcn typcn-pencil edit-cg"></button><button class="red typcn typcn-trash delete-cg"></button></span>' : '') . "</span>";
     if (!isset($AllColors)) {
         $Colors = self::getColors($Group['groupid']);
     } else {
         $Colors = $AllColors[$Group['groupid']] ?? null;
     }
     if (!empty($Colors)) {
         $extraInfo = $force_extra_info || !UserPrefs::get('cg_hideclrinfo');
         foreach ($Colors as $i => $c) {
             $title = CoreUtils::aposEncode($c['label']);
             $color = '';
             if (!empty($c['hex'])) {
                 $color = $c['hex'];
                 $title .= "' style='background-color:{$color}' class='valid-color";
             }
             $append = "<span title='{$title}'>{$color}</span>";
             if ($colorNames) {
                 $append = "<div class='color-line" . (!$extraInfo || empty($color) ? ' no-detail' : '') . "'>{$append}<span><span class='label'>{$c['label']}";
                 if ($extraInfo && !empty($color)) {
                     $rgb = CoreUtils::hex2Rgb($color);
                     $rgb = 'rgb(' . implode(',', $rgb) . ')';
                     $append .= "</span><span class='ext'>{$color} &bull; {$rgb}";
                 }
                 $append .= '</span></div>';
             }
             $HTML .= $append;
         }
     }
     return $wrap ? "<li id='cg{$Group['groupid']}'>{$HTML}</li>" : $HTML;
 }
Beispiel #22
0
                 }
             }
             Response::fail("Unsupported prefix: {$match[1]}. " . (isset($mostSimilar) ? "<em>Did you mean <span class='color-ui'>{$mostSimilar}</span></em>?" : 'Use a backslash if the colon is part of the title (e.g. <code>\\:</code>)'));
         }
         $title = Episodes::removeTitlePrefix($value);
         if (Input::checkStringLength($title, $range, $code)) {
             return $code;
         }
         $value = "{$match[1]}: {$title}";
     } else {
         if (Input::checkStringLength($value, $range, $code)) {
             return $code;
         }
     }
 }, array(Input::IN_RANGE => [5, 35], Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => "{$What} title is missing", Input::ERROR_RANGE => "{$What} title must be between @min and @max characters", 'prefix-movieonly' => "Prefixes can only be used for movies"))))->out();
 CoreUtils::checkStringValidity($insert['title'], "{$What} title", INVERSE_EP_TITLE_PATTERN);
 $airs = (new Input('airs', 'timestamp', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'No air date & time specified', Input::ERROR_INVALID => 'Invalid air date and/or time (@value) specified'))))->out();
 if (empty($airs)) {
     Response::fail('Please specify an air date & time');
 }
 $insert['airs'] = date('c', strtotime('this minute', $airs));
 if ($editing) {
     if (!$Database->whereEp($Episode)->update('episodes', $insert)) {
         Response::dbError('Updating episode failed');
     }
 } else {
     if (!$Database->insert('episodes', $insert)) {
         Response::dbError('Episode creation failed');
     }
 }
 if (!$editing || $SeasonChanged || $EpisodeChanged) {
Beispiel #23
0
 private static function _link($url, $blank = false)
 {
     return "<a href='" . CoreUtils::aposEncode($url) . "'" . ($blank ? ' target="_blank"' : '') . ">{$url}</a>";
 }
Beispiel #24
0
<?  if (isset($browser['browser_name'])){ ?>
	<div class="browser-<?php 
echo CoreUtils::browserNameToClass($browser['browser_name']);
?>
"></div>
<?  } ?>
	<h1><?php 
echo rtrim(($browser['browser_name'] ?? 'Unknown browser') . ' ' . ($browser['browser_ver'] ?? ''));
?>
</h1>
	<p><?php 
echo !empty($browser['platform']) ? "on {$browser['platform']}" : 'Unknown platform';
?>
</p>

    <?php 
echo !empty($Session) ? CoreUtils::notice('warn', "You're debugging session #{$Session['id']} (belongs to " . Users::get($Session['user'])->getProfileLink() . ")") : '';
?>
	<?php 
echo CoreUtils::notice('info', 'Browser recognition testing page', "The following page is used to make sure that the site's browser detection script works as it should. If you're seeing a browser and/or operating system that's different from what you're currently using, please <a class='send-feedback'>let us know.</a>");
?>

	<section>
		<h2>Your User Agent string</h2>
		<p><code><?php 
echo !empty($browser['user_agent']) ? CoreUtils::escapeHTML($browser['user_agent']) : '&lt;empty&gt;';
?>
</code></p>
	</section>
</div>
Beispiel #25
0
					</tr>
				</tbody>
			</table>
			<input type="submit" class="hidden">
		</form>
		<span></span>
		<div class="result">
			<div class="preview"></div>
			<span class="hex" data-color="<?php 
echo $color;
?>
"></span>
			<span class="hexa" data-color="<?php 
echo $color;
?>
"></span>
			<span class="rgba" data-color="<?php 
echo $color;
?>
"></span>
			<span class="opacity" data-color="value"></span>
		</div>
	</div>
	<div class="hidden delta-warn">
		<?php 
echo CoreUtils::notice('warn', "<span class='typcn typcn-warning'></span> The result may not be accurate as the difference between the optimal {$color} and the closest match is too large", true);
?>
	</div>
</div>
<?  echo CoreUtils::exportVars(array('HEX_COLOR_PATTERN' => $HEX_COLOR_REGEX));
Beispiel #26
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 #27
0
			<button id="discord-verify" class="green typcn typcn-chevron-right">Show me the command</button>
		</section>
<?php   } ?>
		<section>
			<h2><?=$sameUser? Users::PROFILE_SECTION_PRIVACY_LEVEL['private']:''?>Unlink account</h2>
			<p>By unlinking your account you revoke this site's access to your account information. This will also log you out on every device where you're currently logged in. The next time you want to log in, you'll have to link your account again. This will not remove any of your <strong>public</strong> data from our site, it's still kept locally.</p>
	        <button id="unlink" class="orange typcn typcn-times">Unlink Account</button>
	    </section>
<?  } ?></div>
<?php
} ?>
</div>

<?php
if ($canEdit){
	$ROLES = array();
	if ($canEdit){
		$_Roles = Permission::ROLES_ASSOC;
		unset($_Roles['guest']);
		unset($_Roles['ban']);
		foreach ($_Roles as $name => $label){
			if (Permission::insufficient($name, $currentUser->role))
				continue;
			$ROLES[$name] = $label;
		}
	}
	echo CoreUtils::exportVars(array(
		'ROLES' => $ROLES,
	));
} ?>
Beispiel #28
0
    $client = CoreUtils::elasticClient();
    $client->ping();
    ?>
		<pre><code><strong>Indices</strong><br><?php 
    echo $client->cat()->indices(['v' => true]);
    ?>
</code></pre>
		<pre><code><strong>Nodes</strong><br><?php 
    echo $client->cat()->nodes(['v' => true]);
    ?>
</code></pre>
<?php 
} catch (\Elasticsearch\Common\Exceptions\NoNodesAvailableException $e) {
    echo "<pre><code><strong>Server is down.</strong></code></pre>";
}
?>
	</section>
<?  } ?>

	<section class="recent-posts">
		<h2><span class="typcn typcn-bell"></span>Most recent posts</h2>
		<div><?php 
echo Posts::getMostRecentList();
?>
</div>
	</section>
</div>

<?php 
echo CoreUtils::exportVars(array('ROLES_ASSOC' => Permission::ROLES_ASSOC, 'PRINTABLE_ASCII_PATTERN' => PRINTABLE_ASCII_PATTERN));
Beispiel #29
0
        exit;
    }
    CoreUtils::notFound();
}
// Static redirects
switch ($do) {
    // PAGES
    case "logs":
        $do = 'admin';
        $data = rtrim("logs/{$data}", '/');
        HTTP::redirect(rtrim("/{$do}/{$data}", '/'));
        break;
    case "u":
        $do = 'user';
        break;
    case "cg":
    case "colourguides":
    case "colourguide":
    case "colorguides":
        $do = 'colorguide';
        break;
}
// Load controller
$controller = INCPATH . "controllers/{$do}.php";
if (!($do === 'colorguide' && preg_match(new RegExp('\\.(svg|png)$'), $data))) {
    Users::authenticate();
}
if (!file_exists($controller)) {
    CoreUtils::notFound();
}
require $controller;
Beispiel #30
0
<?php 
switch ($errcause) {
    case "db":
        ?>
	<h1>Database connection error</h1>
	<p>Could not connect to database on <?php 
        echo DB_HOST;
        ?>
</p>
<?php 
        echo CoreUtils::notice('info', '<span class="typcn typcn-info-large"></span> The database of our website cannot be reached. Hopefully this is just a temporary issue and everything will be back to normal soon. Sorry for the inconvenience. <a class="send-feedback">Notify the developer</a>', true);
        echo CoreUtils::notice('warn', '<strong>Probable cause / debug information:</strong><pre><code>' . $e->getMessage() . '</code></pre>', true);
        break;
    case "libmiss":
        ?>
	<h1>Configuration problem</h1>
	<p>A required extension/setting is missng</p>
<?php 
        echo CoreUtils::notice('info', '<span class="typcn typcn-info-large"></span> One of the site\'s core modules have not been installed yet. This usually happens after a software upgrade/reinstall and is just a temporary issue, no data has been lost and everything will be back to normal very soon. Sorry for the inconvenience. <a class="send-feedback">Notify the developer</a>', true);
        echo CoreUtils::notice('warn', '<strong>Probable cause / debug information:</strong><pre><code>' . $e->getMessage() . '</code></pre>', true);
        break;
}
?>
</div>
<?php 
echo CoreUtils::exportVars(array('ServiceUnavailableError' => true));
$customJS = array("/js/min/global.js", "/js/min/moment.js", "/js/min/dialog.js");
foreach ($customJS as $k => $el) {
    $customJS[$k] .= '?' . filemtime(APPATH . CoreUtils::substring($el, 1));
}
require "footer.php";