mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
Adjust site to use PSR-2 coding standard
This commit is contained in:
parent
3acdae342e
commit
771b205d79
74 changed files with 3377 additions and 3739 deletions
27
autoload.php
27
autoload.php
|
@ -5,16 +5,14 @@ class Autoloader
|
|||
|
||||
public static function autoload($class)
|
||||
{
|
||||
if (class_exists($class, false) || interface_exists($class, false))
|
||||
{
|
||||
if (class_exists($class, false) || interface_exists($class, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$class = strtolower($class);
|
||||
$path = static::$classes[$class] ?? false;
|
||||
|
||||
if ($path)
|
||||
{
|
||||
if ($path) {
|
||||
require_once $path;
|
||||
return true;
|
||||
}
|
||||
|
@ -25,11 +23,9 @@ class Autoloader
|
|||
public static function reload($reload = false)
|
||||
{
|
||||
$key = 'lbry-classes-5';
|
||||
if (ini_get('apc.enabled') && !$reload)
|
||||
{
|
||||
if (ini_get('apc.enabled') && !$reload) {
|
||||
$classes = apc_fetch($key, $success);
|
||||
if ($success)
|
||||
{
|
||||
if ($success) {
|
||||
static::$classes = $classes;
|
||||
return;
|
||||
}
|
||||
|
@ -40,16 +36,13 @@ class Autoloader
|
|||
$dir = new RecursiveDirectoryIterator(ROOT_DIR, RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$ite = new RecursiveIteratorIterator($dir);
|
||||
$pathIterator = new RegexIterator($ite, '/.*\.php$/', RegexIterator::GET_MATCH);
|
||||
foreach($pathIterator as $paths)
|
||||
{
|
||||
foreach($paths as $path)
|
||||
{
|
||||
foreach ($pathIterator as $paths) {
|
||||
foreach ($paths as $path) {
|
||||
static::$classes += static::parseFile($path);
|
||||
}
|
||||
}
|
||||
|
||||
if (ini_get('apc.enabled'))
|
||||
{
|
||||
if (ini_get('apc.enabled')) {
|
||||
apc_store($key, static::$classes);
|
||||
}
|
||||
}
|
||||
|
@ -62,15 +55,13 @@ class Autoloader
|
|||
preg_match_all('~^\s*(?:namespace)\s+([^;]+)~mi', file_get_contents($path), $namespaces);
|
||||
preg_match_all('~^\s*(?:abstract\s+|final\s+)?(?:class|interface)\s+(\w+)~mi', file_get_contents($path), $classes);
|
||||
|
||||
if (isset($namespaces[1]) && count($namespaces[1]) > 2)
|
||||
{
|
||||
if (isset($namespaces[1]) && count($namespaces[1]) > 2) {
|
||||
throw new RuntimeException('Autoloader cannot handle 2 namespaces in the same file');
|
||||
}
|
||||
|
||||
$prefix = isset($namespaces[1]) && count($namespaces[1]) ? reset($namespaces[1]) . '\\' : '';
|
||||
|
||||
foreach ($classes[1] as $class)
|
||||
{
|
||||
foreach ($classes[1] as $class) {
|
||||
$mapping[strtolower($prefix . $class)] = $path;
|
||||
}
|
||||
return $mapping;
|
||||
|
|
|
@ -8,30 +8,23 @@ class Controller
|
|||
|
||||
public static function dispatch($uri)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IS_PRODUCTION && function_exists('newrelic_name_transaction'))
|
||||
{
|
||||
try {
|
||||
if (IS_PRODUCTION && function_exists('newrelic_name_transaction')) {
|
||||
newrelic_name_transaction(Request::getMethod() . ' ' . strtolower($uri));
|
||||
}
|
||||
|
||||
$viewAndParams = static::execute(Request::getMethod(), $uri);
|
||||
$viewTemplate = $viewAndParams[0];
|
||||
$viewParameters = $viewAndParams[1] ?? [];
|
||||
if (!IS_PRODUCTION && isset($viewAndParams[2]))
|
||||
{
|
||||
if (!IS_PRODUCTION && isset($viewAndParams[2])) {
|
||||
throw new Exception('use response::setheader instead of returning headers');
|
||||
}
|
||||
|
||||
if (!$viewTemplate)
|
||||
{
|
||||
if ($viewTemplate !== null)
|
||||
{
|
||||
if (!$viewTemplate) {
|
||||
if ($viewTemplate !== null) {
|
||||
throw new LogicException('All execute methods must return a template or NULL.');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$layout = !(isset($viewParameters['_no_layout']) && $viewParameters['_no_layout']);
|
||||
unset($viewParameters['_no_layout']);
|
||||
|
||||
|
@ -44,16 +37,12 @@ class Controller
|
|||
}
|
||||
|
||||
Response::setDefaultSecurityHeaders();
|
||||
if (Request::isGzipAccepted())
|
||||
{
|
||||
if (Request::isGzipAccepted()) {
|
||||
Response::gzipContentIfNotDisabled();
|
||||
}
|
||||
|
||||
Response::send();
|
||||
}
|
||||
catch (StopException $e)
|
||||
{
|
||||
|
||||
} catch (StopException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,17 +50,12 @@ class Controller
|
|||
{
|
||||
$router = static::getRouterWithRoutes();
|
||||
static::performSubdomainRedirects();
|
||||
try
|
||||
{
|
||||
try {
|
||||
$dispatcher = new Routing\Dispatcher($router->getData());
|
||||
return $dispatcher->dispatch($method, $uri);
|
||||
}
|
||||
catch (\Routing\HttpRouteNotFoundException $e)
|
||||
{
|
||||
} catch (\Routing\HttpRouteNotFoundException $e) {
|
||||
return NavActions::execute404();
|
||||
}
|
||||
catch (\Routing\HttpMethodNotAllowedException $e)
|
||||
{
|
||||
} catch (\Routing\HttpMethodNotAllowedException $e) {
|
||||
Response::setStatus(405);
|
||||
Response::setHeader('Allow', implode(', ', $e->getAllowedMethods()));
|
||||
return ['page/405'];
|
||||
|
@ -82,7 +66,7 @@ class Controller
|
|||
{
|
||||
$subDomain = Request::getSubDomain();
|
||||
|
||||
switch($subDomain) {
|
||||
switch ($subDomain) {
|
||||
case 'chat':
|
||||
case 'slack':
|
||||
return static::redirect('https://discord.gg/Z3bERWA');
|
||||
|
@ -97,8 +81,7 @@ class Controller
|
|||
|
||||
$router->get(['/get', 'get'], 'DownloadActions::executeGet');
|
||||
$router->get(['/getrubin', 'getrubin'], 'DownloadActions::executeGet');
|
||||
foreach(array_keys(OS::getAll()) as $os)
|
||||
{
|
||||
foreach (array_keys(OS::getAll()) as $os) {
|
||||
$router->get(['/' . $os, 'get-' . $os], 'DownloadActions::executeGet');
|
||||
}
|
||||
$router->get('/roadmap', 'ContentActions::executeRoadmap');
|
||||
|
@ -139,11 +122,11 @@ class Controller
|
|||
$permanentRedirects = SpyC::YAMLLoadString(file_get_contents($permanentRedirectsPath));
|
||||
$tempRedirects = SpyC::YAMLLoadString(file_get_contents($tempRedirectsPath));
|
||||
|
||||
foreach ([307 => $tempRedirects, 301 => $permanentRedirects] as $code => $redirects)
|
||||
{
|
||||
foreach ($redirects as $src => $target)
|
||||
{
|
||||
$router->any($src, function () use ($target, $code) { return static::redirect($target, $code); });
|
||||
foreach ([307 => $tempRedirects, 301 => $permanentRedirects] as $code => $redirects) {
|
||||
foreach ($redirects as $src => $target) {
|
||||
$router->any($src, function () use ($target, $code) {
|
||||
return static::redirect($target, $code);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,15 +142,11 @@ class Controller
|
|||
$router->get(ContentActions::URL_CREDIT_REPORTS, 'ContentActions::executeCreditReports');
|
||||
$router->get([ContentActions::URL_CREDIT_REPORTS . '/{year:c}-q{quarter:c}', ContentActions::URL_CREDIT_REPORTS . '/{year:c}-Q{quarter:c}'], 'ContentActions::executeCreditReport');
|
||||
|
||||
$router->get('/{slug}', function (string $slug)
|
||||
{
|
||||
if (View::exists('page/' . $slug))
|
||||
{
|
||||
$router->get('/{slug}', function (string $slug) {
|
||||
if (View::exists('page/' . $slug)) {
|
||||
Response::enableHttpCache();
|
||||
return ['page/' . $slug, []];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return NavActions::execute404();
|
||||
}
|
||||
});
|
||||
|
@ -177,8 +156,7 @@ class Controller
|
|||
|
||||
public static function redirect($url, $statusCode = 302)
|
||||
{
|
||||
if (!$url)
|
||||
{
|
||||
if (!$url) {
|
||||
throw new InvalidArgumentException('Cannot redirect to an empty URL.');
|
||||
}
|
||||
|
||||
|
@ -186,8 +164,7 @@ class Controller
|
|||
|
||||
Response::setStatus($statusCode);
|
||||
|
||||
if ($statusCode == 201 || ($statusCode >= 300 && $statusCode < 400))
|
||||
{
|
||||
if ($statusCode == 201 || ($statusCode >= 300 && $statusCode < 400)) {
|
||||
Response::setHeader(Response::HEADER_LOCATION, $url);
|
||||
}
|
||||
|
||||
|
@ -201,8 +178,7 @@ class Controller
|
|||
|
||||
public static function shutdown()
|
||||
{
|
||||
while ($fn = array_shift(static::$queuedFunctions))
|
||||
{
|
||||
while ($fn = array_shift(static::$queuedFunctions)) {
|
||||
call_user_func($fn);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@ class Request
|
|||
|
||||
public static function getMethod(): string
|
||||
{
|
||||
if (!static::$method)
|
||||
{
|
||||
if (!static::$method) {
|
||||
$method = static::getHeader('REQUEST_METHOD') ? strtoupper(static::getHeader('REQUEST_METHOD')) : null;
|
||||
|
||||
static::$method = in_array($method, [static::GET, static::POST, static::HEAD, static::OPTIONS]) ? $method : static::GET;
|
||||
|
@ -77,8 +76,7 @@ class Request
|
|||
public static function getRoutingUri()
|
||||
{
|
||||
$host = preg_replace('/^www\./', '', static::getHost());
|
||||
switch($host)
|
||||
{
|
||||
switch ($host) {
|
||||
case 'betteryoutube.com':
|
||||
case 'lbrycreators.com':
|
||||
return '/youtube';
|
||||
|
@ -98,15 +96,13 @@ class Request
|
|||
$domainParts = explode('.', $host);
|
||||
$domainPartCount = count($domainParts);
|
||||
|
||||
if (count($domainParts) < 1)
|
||||
{
|
||||
if (count($domainParts) < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$isLocalhost = $domainParts[$domainPartCount - 1] === 'localhost';
|
||||
|
||||
if (count($domainParts) < ($isLocalhost ? 2 : 3))
|
||||
{
|
||||
if (count($domainParts) < ($isLocalhost ? 2 : 3)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -156,7 +152,8 @@ class Request
|
|||
return preg_match('/(' . join('|', $bots) . ')/i', static::getUserAgent());
|
||||
}
|
||||
//Method that encode html tags to special character
|
||||
public static function encodeStringFromUser($string){
|
||||
public static function encodeStringFromUser($string)
|
||||
{
|
||||
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,15 +22,13 @@ class Session
|
|||
ini_set('session.cookie_httponly', true); // no js access to cookies
|
||||
session_start();
|
||||
|
||||
if (!static::get('secure_and_httponly_set'))
|
||||
{
|
||||
if (!static::get('secure_and_httponly_set')) {
|
||||
session_regenerate_id(); // ensure that old cookies get new settings
|
||||
}
|
||||
static::set('secure_and_httponly_set', true);
|
||||
|
||||
// migrate existing session data into namespaced session
|
||||
if (!static::getNamespace(static::NAMESPACE_DEFAULT))
|
||||
{
|
||||
if (!static::getNamespace(static::NAMESPACE_DEFAULT)) {
|
||||
$oldSession = deserialize(serialize($_SESSION)) ?: [];
|
||||
session_unset();
|
||||
static::setNamespace(static::NAMESPACE_DEFAULT, $oldSession);
|
||||
|
@ -71,8 +69,7 @@ class Session
|
|||
|
||||
protected static function initFlashes()
|
||||
{
|
||||
foreach(static::getNamespace(static::NAMESPACE_FLASH) as $key => $val)
|
||||
{
|
||||
foreach (static::getNamespace(static::NAMESPACE_FLASH) as $key => $val) {
|
||||
static::set($key, true, static::NAMESPACE_FLASH_REMOVE);
|
||||
}
|
||||
|
||||
|
@ -81,8 +78,7 @@ class Session
|
|||
|
||||
public static function cleanupFlashes()
|
||||
{
|
||||
foreach(array_keys(static::getNamespace(static::NAMESPACE_FLASH_REMOVE)) as $flashName)
|
||||
{
|
||||
foreach (array_keys(static::getNamespace(static::NAMESPACE_FLASH_REMOVE)) as $flashName) {
|
||||
static::unsetKey($flashName, static::NAMESPACE_FLASH);
|
||||
static::unsetKey($flashName, static::NAMESPACE_FLASH_REMOVE);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class AcquisitionActions extends Actions
|
|||
|
||||
public static function executeYouTube()
|
||||
{
|
||||
if(isset($_GET['error_message'])){
|
||||
if (isset($_GET['error_message'])) {
|
||||
$error_message = Request::encodeStringFromUser($_GET['error_message']);
|
||||
}
|
||||
|
||||
|
@ -52,12 +52,12 @@ class AcquisitionActions extends Actions
|
|||
|
||||
public static function executeYoutubeStatus(string $token)
|
||||
{
|
||||
if(isset($_GET['error_message'])){
|
||||
if (isset($_GET['error_message'])) {
|
||||
$error_message = Request::encodeStringFromUser($_GET['error_message']);
|
||||
}
|
||||
|
||||
$data = LBRY::statusYoutube($token);
|
||||
if ($data['success'] == false){
|
||||
if ($data['success'] == false) {
|
||||
Controller::redirect('/youtube?error=true&error_message=' . $data['error']);
|
||||
}
|
||||
return ['acquisition/youtube_status', [
|
||||
|
@ -69,44 +69,39 @@ class AcquisitionActions extends Actions
|
|||
|
||||
public static function actionYoutubeToken(string $desired_lbry_channel_name)
|
||||
{
|
||||
|
||||
$desired_lbry_channel_name_is_valid = static::lbry_channel_verification($desired_lbry_channel_name);
|
||||
|
||||
if ($desired_lbry_channel_name_is_valid) {
|
||||
$token = LBRY::connectYoutube($desired_lbry_channel_name);
|
||||
if ($token['success'] == false) {
|
||||
Controller::redirect('/youtube?error=true&error_message=' . $token['error']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Controller::redirect($token['data']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public static function actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent)
|
||||
{
|
||||
$current_value = LBRY::statusYoutube($status_token);
|
||||
if($current_value['data']['email'] == $email)
|
||||
{
|
||||
if ($current_value['data']['email'] == $email) {
|
||||
$status = LBRY::editYoutube($status_token, $channel_name, null, $sync_consent);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$status = LBRY::editYoutube($status_token, $channel_name, $email, $sync_consent);
|
||||
}
|
||||
|
||||
if($status['success'] == false){
|
||||
if ($status['success'] == false) {
|
||||
Controller::redirect("/youtube/status/". $status_token . "?error=true&error_message=" . $status['error']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
Controller::redirect("/youtube/status/" . $status_token);
|
||||
}
|
||||
}
|
||||
public static function executeYoutubeEdit(){
|
||||
public static function executeYoutubeEdit()
|
||||
{
|
||||
return ['acquisition/youtube_edit'];
|
||||
}
|
||||
|
||||
public static function executeRedirectYoutube(){
|
||||
public static function executeRedirectYoutube()
|
||||
{
|
||||
return ['acquisition/youtube_status_redirect'];
|
||||
}
|
||||
|
||||
|
|
|
@ -36,16 +36,15 @@ class ContentActions extends Actions
|
|||
{
|
||||
Response::enableHttpCache();
|
||||
|
||||
if (!$slug || $slug == static::SLUG_RSS)
|
||||
{
|
||||
if (!$slug || $slug == static::SLUG_RSS) {
|
||||
$posts = array_filter(
|
||||
Post::find(static::VIEW_FOLDER_NEWS, Post::SORT_DATE_DESC),
|
||||
function(Post $post) {
|
||||
function (Post $post) {
|
||||
return !$post->getDate() || $post->getDate()->format('U') <= date('U');
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if ($slug == static::SLUG_RSS)
|
||||
{
|
||||
if ($slug == static::SLUG_RSS) {
|
||||
Response::setHeader(Response::HEADER_CONTENT_TYPE, 'text/xml; charset=utf-8');
|
||||
return ['content/rss', [
|
||||
'posts' => array_slice($posts, 0, 10),
|
||||
|
@ -61,12 +60,9 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$post = Post::load(static::SLUG_NEWS . '/' . ltrim($slug, '/'));
|
||||
}
|
||||
catch (PostNotFoundException $e)
|
||||
{
|
||||
} catch (PostNotFoundException $e) {
|
||||
return NavActions::execute404();
|
||||
}
|
||||
|
||||
|
@ -82,8 +78,7 @@ class ContentActions extends Actions
|
|||
{
|
||||
Response::enableHttpCache();
|
||||
|
||||
if (!$slug)
|
||||
{
|
||||
if (!$slug) {
|
||||
$allPosts = Post::find(static::VIEW_FOLDER_FAQ, Post::SORT_ORD_ASC);
|
||||
|
||||
$allCategories = [
|
||||
|
@ -109,8 +104,7 @@ class ContentActions extends Actions
|
|||
|
||||
$groups = array_fill_keys(array_keys($allCategories), []);
|
||||
|
||||
foreach ($posts as $post)
|
||||
{
|
||||
foreach ($posts as $post) {
|
||||
$groups[$post->getCategory()][] = $post;
|
||||
}
|
||||
|
||||
|
@ -121,12 +115,9 @@ class ContentActions extends Actions
|
|||
]];
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$post = Post::load(static::SLUG_FAQ . '/' . ltrim($slug, '/'));
|
||||
}
|
||||
catch (PostNotFoundException $e)
|
||||
{
|
||||
} catch (PostNotFoundException $e) {
|
||||
return Controller::redirect('/' . static::SLUG_FAQ);
|
||||
}
|
||||
return ['content/faq-post', ['post' => $post]];
|
||||
|
@ -146,15 +137,11 @@ class ContentActions extends Actions
|
|||
|
||||
public static function executeCreditReport(string $year = null, string $quarter = null): array
|
||||
{
|
||||
|
||||
Response::enableHttpCache();
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$post = Post::load(static::SLUG_CREDIT_REPORTS . '/' . $year . '-Q' . $quarter);
|
||||
}
|
||||
catch (PostNotFoundException $e)
|
||||
{
|
||||
} catch (PostNotFoundException $e) {
|
||||
return Controller::redirect('/' . static::SLUG_CREDIT_REPORTS);
|
||||
}
|
||||
$metadata = $post->getMetadata();
|
||||
|
@ -167,12 +154,9 @@ class ContentActions extends Actions
|
|||
public static function executePress(string $slug = null): array
|
||||
{
|
||||
Response::enableHttpCache();
|
||||
try
|
||||
{
|
||||
try {
|
||||
$post = Post::load(static::SLUG_PRESS . '/' . ltrim($slug, '/'));
|
||||
}
|
||||
catch (PostNotFoundException $e)
|
||||
{
|
||||
} catch (PostNotFoundException $e) {
|
||||
return NavActions::execute404();
|
||||
}
|
||||
return ['content/press-post', ['post' => $post]];
|
||||
|
@ -189,14 +173,12 @@ class ContentActions extends Actions
|
|||
|
||||
|
||||
|
||||
if ($slug)
|
||||
{
|
||||
if ($slug) {
|
||||
list($metadata, $postHtml) = View::parseMarkdown(ContentActions::VIEW_FOLDER_BOUNTY . '/' . $slug . '.md');
|
||||
|
||||
$metadata['lbc_award'] = static::convertBountyAmount($metadata['award']);
|
||||
|
||||
if (!$postHtml)
|
||||
{
|
||||
if (!$postHtml) {
|
||||
return NavActions::execute404();
|
||||
}
|
||||
|
||||
|
@ -221,19 +203,18 @@ class ContentActions extends Actions
|
|||
|
||||
$bounties = $filters ? Post::filter($allBounties, $filters) : $allBounties;
|
||||
|
||||
uasort($bounties, function($postA, $postB) {
|
||||
uasort($bounties, function ($postA, $postB) {
|
||||
$metadataA = $postA->getMetadata();
|
||||
$metadataB = $postB->getMetadata();
|
||||
$awardA = strpos('-', $metadataA['award']) !== false ? rtrim(explode('-', $metadataA['award'])[0], '+') : $metadataA['award'];
|
||||
$awardB = strpos('-', $metadataB['award']) !== false ? rtrim(explode('-', $metadataB['award'])[0], '+') : $metadataB['award'];
|
||||
if ($awardA != $awardB)
|
||||
{
|
||||
if ($awardA != $awardB) {
|
||||
return $awardA > $awardB ? -1 : 1;
|
||||
}
|
||||
return $metadataA['title'] < $metadataB['title'] ? -1 : 1;
|
||||
});
|
||||
|
||||
foreach($bounties as $bounty) {
|
||||
foreach ($bounties as $bounty) {
|
||||
$metadata = $bounty->getMetadata();
|
||||
$bounty->setMetadataItem('lbc_award', static::convertBountyAmount($metadata['award']));
|
||||
}
|
||||
|
@ -252,14 +233,11 @@ class ContentActions extends Actions
|
|||
$cache = !Request::getParam('nocache');
|
||||
$githubItems = Github::listRoadmapChangesets($cache);
|
||||
$projectMaxVersions = [];
|
||||
foreach($githubItems as $group => $items)
|
||||
{
|
||||
if ($items)
|
||||
{
|
||||
foreach ($githubItems as $group => $items) {
|
||||
if ($items) {
|
||||
$firstItem = reset($items);
|
||||
$project = $firstItem['project'];
|
||||
if (!isset($projectMaxVersions[$project]) || $firstItem['sort_key'] > $projectMaxVersions[$project])
|
||||
{
|
||||
if (!isset($projectMaxVersions[$project]) || $firstItem['sort_key'] > $projectMaxVersions[$project]) {
|
||||
$projectMaxVersions[$project] = $firstItem['sort_key'];
|
||||
}
|
||||
}
|
||||
|
@ -282,8 +260,8 @@ class ContentActions extends Actions
|
|||
|
||||
// $pageHtml = View::render('page/press-kit', ['showHeader' => false]);
|
||||
// $html = <<<EOD
|
||||
//<!DOCTYPE html>
|
||||
//<html>
|
||||
//<!DOCTYPE html>
|
||||
//<html>
|
||||
// <head prefix="og: http://ogp.me/ns#">
|
||||
// <title>LBRY Press Kit</title>
|
||||
// <link href='https://fonts.googleapis.com/css?family=Raleway:300,300italic,400,400italic,700' rel='stylesheet' type='text/css'>
|
||||
|
@ -292,20 +270,18 @@ class ContentActions extends Actions
|
|||
// <body>
|
||||
// $pageHtml
|
||||
// </body>
|
||||
//</html>
|
||||
//EOD;
|
||||
//</html>
|
||||
//EOD;
|
||||
//
|
||||
// $zip->addFromString('press.html', $html);
|
||||
|
||||
foreach (glob(ROOT_DIR . '/web/img/press/*') as $productImgPath)
|
||||
{
|
||||
foreach (glob(ROOT_DIR . '/web/img/press/*') as $productImgPath) {
|
||||
$imgPathTokens = explode('/', $productImgPath);
|
||||
$imgName = $imgPathTokens[count($imgPathTokens) - 1];
|
||||
$zip->addFile($productImgPath, '/logo_and_product/' . $imgName);
|
||||
}
|
||||
|
||||
foreach (glob(ContentActions::CONTENT_DIR . '/bio/*.md') as $bioPath)
|
||||
{
|
||||
foreach (glob(ContentActions::CONTENT_DIR . '/bio/*.md') as $bioPath) {
|
||||
list($metadata, $bioHtml) = View::parseMarkdown($bioPath);
|
||||
$zip->addFile($bioPath, '/team_bios/' . $metadata['name'] . ' - ' . $metadata['role'] . '.txt');
|
||||
}
|
||||
|
@ -347,7 +323,6 @@ class ContentActions extends Actions
|
|||
'bioHtml' => $bioHtml,
|
||||
'orientation' => 'vertical'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public static function preparePostAuthorPartial(array $vars): array
|
||||
|
@ -378,9 +353,10 @@ class ContentActions extends Actions
|
|||
|
||||
$posts = array_filter(
|
||||
Post::find(static::VIEW_FOLDER_NEWS, Post::SORT_DATE_DESC),
|
||||
function(Post $post) use ($category) {
|
||||
function (Post $post) use ($category) {
|
||||
return (($post->getCategory() === $category) && (!$post->getDate() || $post->getDate()->format('U') <= date('U')));
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
@ -397,10 +373,12 @@ class ContentActions extends Actions
|
|||
$jobs =
|
||||
array_filter(
|
||||
array_map('View::parseMarkdown', glob(static::VIEW_FOLDER_JOBS . '/*')),
|
||||
function($job) { return $job[0]['status'] !== 'closed'; }
|
||||
function ($job) {
|
||||
return $job[0]['status'] !== 'closed';
|
||||
}
|
||||
);
|
||||
|
||||
usort($jobs, function($jobA, $jobB){
|
||||
usort($jobs, function ($jobA, $jobB) {
|
||||
if ($jobA[0]['status'] === 'active' xor $jobB[0]['status'] === 'active') {
|
||||
return $jobA[0]['status'] === 'active' ? -1 : 1;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,8 @@ class DeveloperActions extends Actions
|
|||
'stepLabels' => $stepLabels
|
||||
];
|
||||
|
||||
if ($currentStep !== 'all')
|
||||
{
|
||||
if (!isset($stepLabels[$currentStep]))
|
||||
{
|
||||
if ($currentStep !== 'all') {
|
||||
if (!isset($stepLabels[$currentStep])) {
|
||||
Controller::redirect('/quickstart');
|
||||
}
|
||||
|
||||
|
@ -80,13 +78,11 @@ class DeveloperActions extends Actions
|
|||
Session::set(Session::KEY_DEVELOPER_CREDITS_WALLET_ADDRESS, trim(Request::getPostParam('wallet_address')));
|
||||
Session::set(Session::KEY_DEVELOPER_LAST_FORM, Request::getPostParam('formName'));
|
||||
|
||||
if (Request::getPostParam('returnUrl'))
|
||||
{
|
||||
if (Request::getPostParam('returnUrl')) {
|
||||
Session::set(Session::KEY_DEVELOPER_RETURN_URL_SUCCESS, Request::getPostParam('returnUrl'));
|
||||
}
|
||||
|
||||
if (!Config::get(Config::GITHUB_DEVELOPER_CREDITS_CLIENT_ID))
|
||||
{
|
||||
if (!Config::get(Config::GITHUB_DEVELOPER_CREDITS_CLIENT_ID)) {
|
||||
throw new Exception('no github client id');
|
||||
}
|
||||
|
||||
|
@ -104,12 +100,9 @@ class DeveloperActions extends Actions
|
|||
{
|
||||
$code = Request::getParam('code');
|
||||
|
||||
if (!$code)
|
||||
{
|
||||
if (!$code) {
|
||||
Session::setFlash(Session::KEY_DEVELOPER_CREDITS_ERROR, 'This does not appear to be a valid response from GitHub.');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$authResponseData = Curl::post('https://github.com/login/oauth/access_token', [
|
||||
'code' => $code,
|
||||
'client_id' => Config::get(Config::GITHUB_DEVELOPER_CREDITS_CLIENT_ID),
|
||||
|
@ -119,16 +112,11 @@ class DeveloperActions extends Actions
|
|||
'json_response' => true
|
||||
]);
|
||||
|
||||
if (!$authResponseData || !isset($authResponseData['access_token']))
|
||||
{
|
||||
if (!$authResponseData || !isset($authResponseData['access_token'])) {
|
||||
Session::setFlash(Session::KEY_DEVELOPER_CREDITS_ERROR, 'Request to GitHub failed.');
|
||||
}
|
||||
elseif (isset($authResponseData['error_description']))
|
||||
{
|
||||
} elseif (isset($authResponseData['error_description'])) {
|
||||
Session::setFlash(Session::KEY_DEVELOPER_CREDITS_ERROR, 'GitHub replied: ' . $authResponseData['error_description']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Session::set(Session::KEY_GITHUB_ACCESS_TOKEN, $authResponseData['access_token']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ class DownloadActions extends Actions
|
|||
$uri = null;
|
||||
$oses = Os::getAll();
|
||||
|
||||
if (isset($oses[$os]))
|
||||
{
|
||||
if (isset($oses[$os])) {
|
||||
$uri = GitHub::getDaemonDownloadUrl($os);
|
||||
}
|
||||
|
||||
|
@ -32,13 +31,12 @@ class DownloadActions extends Actions
|
|||
|
||||
$os = static::guessOS();
|
||||
|
||||
if(isset($os) && isset($osChoices[$os])){
|
||||
if (isset($os) && isset($osChoices[$os])) {
|
||||
list($uri, $osTitle, $osIcon, $buttonLabel, $analyticsLabel) = $osChoices[$os];
|
||||
$asset = Github::getAppAsset($os);
|
||||
$param = ['osTitle' => $osTitle, 'osIcon' => $osIcon, 'os' => $os, 'downloadUrl' => $asset ? $asset['browser_download_url'] : null];
|
||||
return ['download/get', $param];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return ['download/get-no-os'];
|
||||
}
|
||||
}
|
||||
|
@ -55,31 +53,25 @@ class DownloadActions extends Actions
|
|||
{
|
||||
//if exact OS is requested, use that
|
||||
$uri = Request::getRelativeUri();
|
||||
foreach (OS::getAll() as $os => $osChoice)
|
||||
{
|
||||
if ($osChoice[0] == $uri)
|
||||
{
|
||||
foreach (OS::getAll() as $os => $osChoice) {
|
||||
if ($osChoice[0] == $uri) {
|
||||
return $os;
|
||||
}
|
||||
}
|
||||
|
||||
if (Request::isRobot())
|
||||
{
|
||||
if (Request::isRobot()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//otherwise guess from UA
|
||||
$ua = Request::getUserAgent();
|
||||
if (stripos($ua, 'OS X') !== false)
|
||||
{
|
||||
if (stripos($ua, 'OS X') !== false) {
|
||||
return strpos($ua, 'iPhone') !== false || stripos($ua, 'iPad') !== false ? OS::OS_IOS : OS::OS_OSX;
|
||||
}
|
||||
if (stripos($ua, 'Linux') !== false || strpos($ua, 'X11') !== false)
|
||||
{
|
||||
if (stripos($ua, 'Linux') !== false || strpos($ua, 'X11') !== false) {
|
||||
return strpos($ua, 'Android') !== false ? OS::OS_ANDROID : OS::OS_LINUX;
|
||||
}
|
||||
if (stripos($ua, 'Windows') !== false)
|
||||
{
|
||||
if (stripos($ua, 'Windows') !== false) {
|
||||
return OS::OS_WINDOWS;
|
||||
}
|
||||
}
|
||||
|
@ -88,14 +80,11 @@ class DownloadActions extends Actions
|
|||
{
|
||||
$email = Request::getParam('e');
|
||||
|
||||
if (!$email)
|
||||
{
|
||||
if (!$email) {
|
||||
$encoded = Request::getParam('ec');
|
||||
if ($encoded)
|
||||
{
|
||||
if ($encoded) {
|
||||
$email = Smaz::decode(Encoding::base64DecodeUrlsafe($encoded), Smaz::CODEBOOK_EMAIL);
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$email = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,22 +4,21 @@ class MailActions extends Actions
|
|||
{
|
||||
public static function executeSubscribe()
|
||||
{
|
||||
if (!Request::isPost())
|
||||
{
|
||||
if (!Request::isPost()) {
|
||||
return ['mail/subscribe'];
|
||||
}
|
||||
|
||||
$nextUrl = Request::getPostParam('returnUrl', '/');
|
||||
if (!$nextUrl || $nextUrl[0] != '/' || !filter_var($nextUrl, FILTER_VALIDATE_URL))
|
||||
{
|
||||
if (!$nextUrl || $nextUrl[0] != '/' || !filter_var($nextUrl, FILTER_VALIDATE_URL)) {
|
||||
$nextUrl = '/';
|
||||
}
|
||||
|
||||
$email = Request::getPostParam('email');
|
||||
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
Session::set(Session::KEY_LIST_SUB_ERROR,
|
||||
$email ? __('Please provide a valid email address.') : __('Please provide an email address.'));
|
||||
if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
Session::set(
|
||||
Session::KEY_LIST_SUB_ERROR,
|
||||
$email ? __('Please provide a valid email address.') : __('Please provide an email address.')
|
||||
);
|
||||
|
||||
return Controller::redirect(Request::getRelativeUri());
|
||||
}
|
||||
|
@ -27,8 +26,7 @@ class MailActions extends Actions
|
|||
$tag = Request::getPostParam('tag');
|
||||
|
||||
$response = LBRY::subscribe($email, $tag);
|
||||
if ($response['error'])
|
||||
{
|
||||
if ($response['error']) {
|
||||
return ['mail/subscribe', ['error' => $response['error']]];
|
||||
}
|
||||
|
||||
|
@ -54,8 +52,7 @@ class MailActions extends Actions
|
|||
public static function executeUnsubscribe(string $email)
|
||||
{
|
||||
$decodedEmail = Encoding::base64DecodeUrlsafe(urldecode($email));
|
||||
if (!$decodedEmail)
|
||||
{
|
||||
if (!$decodedEmail) {
|
||||
return ['mail/unsubscribe', ['error' => 'Invalid unsubscribe link']];
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ class OpsActions extends Actions
|
|||
{
|
||||
public static function executeClearCache(): array
|
||||
{
|
||||
if (!ini_get('apc.enabled') || !function_exists('apc_clear_cache'))
|
||||
{
|
||||
if (!ini_get('apc.enabled') || !function_exists('apc_clear_cache')) {
|
||||
return View::renderJson(['success' => false, 'error' => 'Cache not enabled']);
|
||||
}
|
||||
|
||||
|
@ -19,30 +18,25 @@ class OpsActions extends Actions
|
|||
public static function executePostCommit(): array
|
||||
{
|
||||
$payload = Request::getParam('payload');
|
||||
if (!$payload)
|
||||
{
|
||||
if (!$payload) {
|
||||
return NavActions::execute400(['error' => 'No payload']);
|
||||
}
|
||||
|
||||
$payload = json_decode($payload, true);
|
||||
if ($payload['ref'] === 'refs/heads/master')
|
||||
{
|
||||
if ($payload['ref'] === 'refs/heads/master') {
|
||||
$sig = Request::getHttpHeader('X-Hub-Signature');
|
||||
if (!$sig)
|
||||
{
|
||||
if (!$sig) {
|
||||
return NavActions::execute400(['error' => "HTTP header 'X-Hub-Signature' is missing."]);
|
||||
}
|
||||
|
||||
list($algo, $hash) = explode('=', Request::getHttpHeader('X-Hub-Signature'), 2) + ['', ''];
|
||||
if (!in_array($algo, hash_algos(), true))
|
||||
{
|
||||
if (!in_array($algo, hash_algos(), true)) {
|
||||
return NavActions::execute400(['error' => 'Invalid hash algorithm "' . htmlspecialchars($algo) . '"']);
|
||||
}
|
||||
|
||||
$rawPost = file_get_contents('php://input');
|
||||
$secret = Config::get(Config::GITHUB_KEY);
|
||||
if ($hash !== hash_hmac($algo, $rawPost, $secret))
|
||||
{
|
||||
if ($hash !== hash_hmac($algo, $rawPost, $secret)) {
|
||||
return NavActions::execute400(['error' => 'Hash does not match.']);
|
||||
}
|
||||
|
||||
|
@ -55,42 +49,34 @@ class OpsActions extends Actions
|
|||
public static function executeLogUpload(): array
|
||||
{
|
||||
$log = Request::getPostParam('log') ? urldecode(Request::getPostParam('log')) : null;
|
||||
if (Request::getPostParam('name'))
|
||||
{
|
||||
if (Request::getPostParam('name')) {
|
||||
$name = substr(trim(urldecode(Request::getPostParam('name'))), 0, 50);
|
||||
}
|
||||
elseif (Request::getPostParam('date'))
|
||||
{
|
||||
} elseif (Request::getPostParam('date')) {
|
||||
$name = substr(trim(urldecode(Request::getPostParam('date'))), 0, 20) . '_' .
|
||||
substr(trim(urldecode(Request::getPostParam('hash'))), 0, 20) . '_' .
|
||||
substr(trim(urldecode(Request::getPostParam('sys'))), 0, 50) . '_' .
|
||||
substr(trim(urldecode(Request::getPostParam('type'))), 0, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$name = null;
|
||||
}
|
||||
|
||||
$name = preg_replace('/[^A-Za-z0-9_-]+/', '', $name);
|
||||
|
||||
if (!$log || !$name)
|
||||
{
|
||||
if (!$log || !$name) {
|
||||
return NavActions::execute400(['error' => "Required params: log, name"]);
|
||||
}
|
||||
|
||||
$awsKey = Config::get(Config::AWS_LOG_ACCESS_KEY);
|
||||
$awsSecret = Config::get(Config::AWS_LOG_SECRET_KEY);
|
||||
|
||||
if (!$log || !$name)
|
||||
{
|
||||
if (!$log || !$name) {
|
||||
throw new RuntimeException('Missing AWS credentials');
|
||||
}
|
||||
|
||||
$tmpFile = tempnam(sys_get_temp_dir(), 'lbryinstalllog');
|
||||
file_put_contents($tmpFile, $log);
|
||||
|
||||
if (filesize($tmpFile) > 1024 * 1024 * 2)
|
||||
{
|
||||
if (filesize($tmpFile) > 1024 * 1024 * 2) {
|
||||
return NavActions::execute400(['error' => 'Log file is too large']);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,32 +5,26 @@ class ReportActions extends Actions
|
|||
public static function executeDmca()
|
||||
{
|
||||
Response::setHeader(Response::HEADER_CROSS_ORIGIN, "*");
|
||||
if (!Request::isPost())
|
||||
{
|
||||
if (!Request::isPost()) {
|
||||
return ['report/dmca'];
|
||||
}
|
||||
|
||||
$values = [];
|
||||
$errors = [];
|
||||
|
||||
foreach (['name', 'email', 'rightsholder', 'identifier'] as $field)
|
||||
{
|
||||
foreach (['name', 'email', 'rightsholder', 'identifier'] as $field) {
|
||||
$value = Request::getPostParam($field);
|
||||
|
||||
if (!$value)
|
||||
{
|
||||
if (!$value) {
|
||||
$errors[$field] = __('form_error.required');
|
||||
}
|
||||
elseif($field == 'email' && !filter_var($value, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
} elseif ($field == 'email' && !filter_var($value, FILTER_VALIDATE_EMAIL)) {
|
||||
$errors[$field] = __('form_error.invalid');
|
||||
}
|
||||
|
||||
$values[$field] = $value;
|
||||
}
|
||||
|
||||
if (!$errors)
|
||||
{
|
||||
if (!$errors) {
|
||||
$values['report_id'] = Encoding::base58Encode(random_bytes(6));
|
||||
Mailgun::sendDmcaReport($values);
|
||||
Session::setFlash('success', '<h3>Report Submitted</h3><p>We will respond shortly.</p><p>This ID for this report is <strong>' . $values['report_id'] . '</strong>. Please reference this ID when contacting us regarding this report.</p>');
|
||||
|
|
|
@ -7,17 +7,13 @@ class i18nActions extends Actions
|
|||
$culture = Request::getPostParam('culture');
|
||||
|
||||
// Validate
|
||||
if ($culture && !in_array($culture, i18n::getAllCultures()))
|
||||
{
|
||||
if ($culture && !in_array($culture, i18n::getAllCultures())) {
|
||||
$culture = null;
|
||||
}
|
||||
|
||||
if ($culture)
|
||||
{
|
||||
if ($culture) {
|
||||
Session::set(Session::KEY_USER_CULTURE, $culture);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Session::unsetKey(Session::KEY_USER_CULTURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
class StopException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -10,11 +10,10 @@ function __($msg, $args = [])
|
|||
|
||||
class i18n
|
||||
{
|
||||
protected static
|
||||
$language = null,
|
||||
$translations = [],
|
||||
$country = null,
|
||||
$cultures = ['pt_PT', 'en_US'];
|
||||
protected static $language = null;
|
||||
protected static $translations = [];
|
||||
protected static $country = null;
|
||||
protected static $cultures = ['pt_PT', 'en_US'];
|
||||
|
||||
public static function register() /*needed to trigger class include, presumably setup would happen here*/
|
||||
{
|
||||
|
@ -55,26 +54,20 @@ class i18n
|
|||
public static function translate($token, $language = null)
|
||||
{
|
||||
$language = $language === null ? static::$language : $language;
|
||||
if (!isset(static::$translations[$language]))
|
||||
{
|
||||
if (!isset(static::$translations[$language])) {
|
||||
$path = ROOT_DIR . '/data/i18n/' . $language . '.yaml';
|
||||
|
||||
static::$translations[$language] = file_exists($path) ? Spyc::YAMLLoadString(file_get_contents($path)) : [];
|
||||
}
|
||||
$scope = static::$translations[$language];
|
||||
foreach (explode('.', $token) as $level)
|
||||
{
|
||||
if (isset($scope[$level]))
|
||||
{
|
||||
foreach (explode('.', $token) as $level) {
|
||||
if (isset($scope[$level])) {
|
||||
$scope = $scope[$level];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$scope = [];
|
||||
}
|
||||
}
|
||||
if (!$scope && $language != 'en')
|
||||
{
|
||||
if (!$scope && $language != 'en') {
|
||||
return static::translate($token, 'en');
|
||||
}
|
||||
return $scope ?: $token;
|
||||
|
@ -87,8 +80,7 @@ class i18n
|
|||
//url trumps everything
|
||||
$urlTokens = Request::getHost() ? explode('.', Request::getHost()) : [];
|
||||
$code = $urlTokens ? reset($urlTokens) : null;
|
||||
if ($code !== 'www')
|
||||
{
|
||||
if ($code !== 'www') {
|
||||
$candidates[] = $code;
|
||||
}
|
||||
|
||||
|
@ -97,21 +89,17 @@ class i18n
|
|||
|
||||
// then headers
|
||||
// http://www.thefutureoftheweb.com/blog/use-accept-language-header
|
||||
if (Request::getHttpHeader('Accept-Language'))
|
||||
{
|
||||
if (Request::getHttpHeader('Accept-Language')) {
|
||||
// break up string into pieces (languages and q factors)
|
||||
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', Request::getHttpHeader('Accept-Language'), $languages);
|
||||
|
||||
if (isset($languages[1]) && count($languages[1]))
|
||||
{
|
||||
if (isset($languages[1]) && count($languages[1])) {
|
||||
// create a list like "en" => 0.8
|
||||
$langs = array_combine($languages[1], $languages[4]);
|
||||
|
||||
// set default to 1 for any without q factor
|
||||
foreach ($langs as $lang => $val)
|
||||
{
|
||||
if ($val === '')
|
||||
{
|
||||
foreach ($langs as $lang => $val) {
|
||||
if ($val === '') {
|
||||
$langs[$lang] = 1;
|
||||
}
|
||||
}
|
||||
|
@ -122,12 +110,9 @@ class i18n
|
|||
}
|
||||
}
|
||||
|
||||
foreach ($candidates as $candidate)
|
||||
{
|
||||
foreach (static::getAllCultures() as $culture)
|
||||
{
|
||||
if ($candidate === $culture || substr($culture, 0, 2) === $candidate)
|
||||
{
|
||||
foreach ($candidates as $candidate) {
|
||||
foreach (static::getAllCultures() as $culture) {
|
||||
if ($candidate === $culture || substr($culture, 0, 2) === $candidate) {
|
||||
return $culture;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
namespace Routing;
|
||||
|
||||
class RouterBadRouteException extends \LogicException {}
|
||||
class RouterBadRouteException extends \LogicException
|
||||
{
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace Routing;
|
|||
|
||||
class Dispatcher
|
||||
{
|
||||
|
||||
private $staticRouteMap;
|
||||
private $variableRouteData;
|
||||
private $filters;
|
||||
|
@ -25,12 +24,9 @@ class Dispatcher
|
|||
|
||||
$this->filters = $data->getFilters();
|
||||
|
||||
if ($resolver === null)
|
||||
{
|
||||
if ($resolver === null) {
|
||||
$this->handlerResolver = new HandlerResolver();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->handlerResolver = $resolver;
|
||||
}
|
||||
}
|
||||
|
@ -49,8 +45,7 @@ class Dispatcher
|
|||
|
||||
list($beforeFilter, $afterFilter) = $this->parseFilters($filters);
|
||||
|
||||
if (($response = $this->dispatchFilters($beforeFilter)) !== null)
|
||||
{
|
||||
if (($response = $this->dispatchFilters($beforeFilter)) !== null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
@ -71,12 +66,10 @@ class Dispatcher
|
|||
*/
|
||||
private function dispatchFilters($filters, $response = null)
|
||||
{
|
||||
while ($filter = array_shift($filters))
|
||||
{
|
||||
while ($filter = array_shift($filters)) {
|
||||
$handler = $this->handlerResolver->resolve($filter);
|
||||
|
||||
if (($filteredResponse = call_user_func($handler, $response)) !== null)
|
||||
{
|
||||
if (($filteredResponse = call_user_func($handler, $response)) !== null) {
|
||||
return $filteredResponse;
|
||||
}
|
||||
}
|
||||
|
@ -96,13 +89,11 @@ class Dispatcher
|
|||
$beforeFilter = [];
|
||||
$afterFilter = [];
|
||||
|
||||
if (isset($filters[Route::BEFORE]))
|
||||
{
|
||||
if (isset($filters[Route::BEFORE])) {
|
||||
$beforeFilter = array_intersect_key($this->filters, array_flip((array)$filters[Route::BEFORE]));
|
||||
}
|
||||
|
||||
if (isset($filters[Route::AFTER]))
|
||||
{
|
||||
if (isset($filters[Route::AFTER])) {
|
||||
$afterFilter = array_intersect_key($this->filters, array_flip((array)$filters[Route::AFTER]));
|
||||
}
|
||||
|
||||
|
@ -119,8 +110,7 @@ class Dispatcher
|
|||
*/
|
||||
private function dispatchRoute($httpMethod, $uri)
|
||||
{
|
||||
if (isset($this->staticRouteMap[$uri]))
|
||||
{
|
||||
if (isset($this->staticRouteMap[$uri])) {
|
||||
return $this->dispatchStaticRoute($httpMethod, $uri);
|
||||
}
|
||||
|
||||
|
@ -140,8 +130,7 @@ class Dispatcher
|
|||
{
|
||||
$routes = $this->staticRouteMap[$uri];
|
||||
|
||||
if (!isset($routes[$httpMethod]))
|
||||
{
|
||||
if (!isset($routes[$httpMethod])) {
|
||||
$httpMethod = $this->checkFallbacks($routes, $httpMethod);
|
||||
}
|
||||
|
||||
|
@ -160,15 +149,12 @@ class Dispatcher
|
|||
{
|
||||
$additional = [Route::ANY];
|
||||
|
||||
if ($httpMethod === Route::HEAD)
|
||||
{
|
||||
if ($httpMethod === Route::HEAD) {
|
||||
$additional[] = Route::GET;
|
||||
}
|
||||
|
||||
foreach ($additional as $method)
|
||||
{
|
||||
if (isset($routes[$method]))
|
||||
{
|
||||
foreach ($additional as $method) {
|
||||
if (isset($routes[$method])) {
|
||||
return $method;
|
||||
}
|
||||
}
|
||||
|
@ -189,35 +175,27 @@ class Dispatcher
|
|||
*/
|
||||
private function dispatchVariableRoute($httpMethod, $uri)
|
||||
{
|
||||
foreach ($this->variableRouteData as $data)
|
||||
{
|
||||
if (!preg_match($data['regex'], $uri, $matches))
|
||||
{
|
||||
foreach ($this->variableRouteData as $data) {
|
||||
if (!preg_match($data['regex'], $uri, $matches)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$count = count($matches);
|
||||
|
||||
while (!isset($data['routeMap'][$count++]))
|
||||
{
|
||||
while (!isset($data['routeMap'][$count++])) {
|
||||
;
|
||||
}
|
||||
|
||||
$routes = $data['routeMap'][$count - 1];
|
||||
|
||||
if (!isset($routes[$httpMethod]))
|
||||
{
|
||||
if (!isset($routes[$httpMethod])) {
|
||||
$httpMethod = $this->checkFallbacks($routes, $httpMethod);
|
||||
}
|
||||
|
||||
foreach (array_values($routes[$httpMethod][2]) as $i => $varName)
|
||||
{
|
||||
if (!isset($matches[$i + 1]) || $matches[$i + 1] === '')
|
||||
{
|
||||
foreach (array_values($routes[$httpMethod][2]) as $i => $varName) {
|
||||
if (!isset($matches[$i + 1]) || $matches[$i + 1] === '') {
|
||||
unset($routes[$httpMethod][2][$varName]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$routes[$httpMethod][2][$varName] = $matches[$i + 1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ class HandlerResolver implements HandlerResolverInterface
|
|||
{
|
||||
public function resolve($handler)
|
||||
{
|
||||
if (is_array($handler) && is_string($handler[0]))
|
||||
{
|
||||
if (is_array($handler) && is_string($handler[0])) {
|
||||
$handler[0] = new $handler[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
namespace Routing;
|
||||
|
||||
class HttpException extends \Exception {}
|
||||
class HttpException extends \Exception
|
||||
{
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
|
||||
namespace Routing;
|
||||
|
||||
class HttpRouteNotFoundException extends HttpException {}
|
||||
|
||||
class HttpRouteNotFoundException extends HttpException
|
||||
{
|
||||
}
|
||||
|
|
|
@ -23,4 +23,3 @@ class Route
|
|||
const DELETE = 'DELETE';
|
||||
const OPTIONS = 'OPTIONS';
|
||||
}
|
||||
|
||||
|
|
|
@ -57,23 +57,16 @@ class RouteCollector
|
|||
|
||||
$variable = 0;
|
||||
|
||||
foreach ($this->reverse[$name] as $part)
|
||||
{
|
||||
if (!$part['variable'])
|
||||
{
|
||||
foreach ($this->reverse[$name] as $part) {
|
||||
if (!$part['variable']) {
|
||||
$url[] = $part['value'];
|
||||
}
|
||||
elseif (isset($replacements[$variable]))
|
||||
{
|
||||
if ($part['optional'])
|
||||
{
|
||||
} elseif (isset($replacements[$variable])) {
|
||||
if ($part['optional']) {
|
||||
$url[] = '/';
|
||||
}
|
||||
|
||||
$url[] = $replacements[$variable++];
|
||||
}
|
||||
elseif (!$part['optional'])
|
||||
{
|
||||
} elseif (!$part['optional']) {
|
||||
throw new BadRouteException("Expecting route variable '{$part['name']}'");
|
||||
}
|
||||
}
|
||||
|
@ -83,9 +76,7 @@ class RouteCollector
|
|||
|
||||
public function addRoute(string $httpMethod, $route, $handler, array $filters = []): RouteCollector
|
||||
{
|
||||
|
||||
if (is_array($route))
|
||||
{
|
||||
if (is_array($route)) {
|
||||
list($route, $name) = $route;
|
||||
}
|
||||
|
||||
|
@ -93,8 +84,7 @@ class RouteCollector
|
|||
|
||||
list($routeData, $reverseData) = $this->routeParser->parse($route);
|
||||
|
||||
if (isset($name))
|
||||
{
|
||||
if (isset($name)) {
|
||||
$this->reverse[$name] = $reverseData;
|
||||
}
|
||||
|
||||
|
@ -111,15 +101,12 @@ class RouteCollector
|
|||
{
|
||||
$routeStr = $routeData[0];
|
||||
|
||||
if (isset($this->staticRoutes[$routeStr][$httpMethod]))
|
||||
{
|
||||
if (isset($this->staticRoutes[$routeStr][$httpMethod])) {
|
||||
throw new BadRouteException("Cannot register two routes matching '$routeStr' for method '$httpMethod'");
|
||||
}
|
||||
|
||||
foreach ($this->regexToRoutesMap as $regex => $routes)
|
||||
{
|
||||
if (isset($routes[$httpMethod]) && preg_match('~^' . $regex . '$~', $routeStr))
|
||||
{
|
||||
foreach ($this->regexToRoutesMap as $regex => $routes) {
|
||||
if (isset($routes[$httpMethod]) && preg_match('~^' . $regex . '$~', $routeStr)) {
|
||||
throw new BadRouteException("Static route '$routeStr' is shadowed by previously defined variable route '$regex' for method '$httpMethod'");
|
||||
}
|
||||
}
|
||||
|
@ -131,8 +118,7 @@ class RouteCollector
|
|||
{
|
||||
list($regex, $variables) = $routeData;
|
||||
|
||||
if (isset($this->regexToRoutesMap[$regex][$httpMethod]))
|
||||
{
|
||||
if (isset($this->regexToRoutesMap[$regex][$httpMethod])) {
|
||||
throw new BadRouteException("Cannot register two routes matching '$regex' for method '$httpMethod'");
|
||||
}
|
||||
|
||||
|
@ -219,18 +205,14 @@ class RouteCollector
|
|||
|
||||
$sep = $route === '/' ? '' : '/';
|
||||
|
||||
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method)
|
||||
{
|
||||
foreach ($validMethods as $valid)
|
||||
{
|
||||
if (stripos($method->name, $valid) === 0)
|
||||
{
|
||||
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
|
||||
foreach ($validMethods as $valid) {
|
||||
if (stripos($method->name, $valid) === 0) {
|
||||
$methodName = $this->camelCaseToDashed(substr($method->name, strlen($valid)));
|
||||
|
||||
$params = $this->buildControllerParameters($method);
|
||||
|
||||
if ($methodName === self::DEFAULT_CONTROLLER_ROUTE)
|
||||
{
|
||||
if ($methodName === self::DEFAULT_CONTROLLER_ROUTE) {
|
||||
$this->addRoute($valid, $route . $params, [$classname, $method->name], $filters);
|
||||
}
|
||||
|
||||
|
@ -248,8 +230,7 @@ class RouteCollector
|
|||
{
|
||||
$params = '';
|
||||
|
||||
foreach ($method->getParameters() as $param)
|
||||
{
|
||||
foreach ($method->getParameters() as $param) {
|
||||
$params .= "/{" . $param->getName() . "}" . ($param->isOptional() ? '?' : '');
|
||||
}
|
||||
|
||||
|
@ -303,16 +284,14 @@ class RouteCollector
|
|||
$routeMap = [];
|
||||
$regexes = [];
|
||||
$numGroups = 0;
|
||||
foreach ($regexToRoutesMap as $regex => $routes)
|
||||
{
|
||||
foreach ($regexToRoutesMap as $regex => $routes) {
|
||||
$firstRoute = reset($routes);
|
||||
$numVariables = count($firstRoute[2]);
|
||||
$numGroups = max($numGroups, $numVariables);
|
||||
|
||||
$regexes[] = $regex . str_repeat('()', $numGroups - $numVariables);
|
||||
|
||||
foreach ($routes as $httpMethod => $route)
|
||||
{
|
||||
foreach ($routes as $httpMethod => $route) {
|
||||
$routeMap[$numGroups + 1][$httpMethod] = $route;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ class RouteParser
|
|||
|
||||
$route = strtr($route, $this->regexShortcuts);
|
||||
|
||||
if (!$matches = $this->extractVariableRouteParts($route))
|
||||
{
|
||||
if (!$matches = $this->extractVariableRouteParts($route)) {
|
||||
$reverse = [
|
||||
'variable' => false,
|
||||
'value' => $route
|
||||
|
@ -80,9 +79,7 @@ class RouteParser
|
|||
return [[$route], [$reverse]];
|
||||
}
|
||||
|
||||
foreach ($matches as $set)
|
||||
{
|
||||
|
||||
foreach ($matches as $set) {
|
||||
$this->staticParts($route, $set[0][1]);
|
||||
|
||||
$this->validateVariable($set[1][0]);
|
||||
|
@ -95,8 +92,7 @@ class RouteParser
|
|||
|
||||
$isOptional = substr($set[0][0], -1) === '?';
|
||||
|
||||
if ($isOptional)
|
||||
{
|
||||
if ($isOptional) {
|
||||
$match = $this->makeOptional($match);
|
||||
}
|
||||
|
||||
|
@ -139,8 +135,7 @@ class RouteParser
|
|||
*/
|
||||
private function extractVariableRouteParts($route)
|
||||
{
|
||||
if (preg_match_all(self::VARIABLE_REGEX, $route, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER))
|
||||
{
|
||||
if (preg_match_all(self::VARIABLE_REGEX, $route, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
return $matches;
|
||||
}
|
||||
}
|
||||
|
@ -153,10 +148,8 @@ class RouteParser
|
|||
{
|
||||
$static = preg_split('~(/)~u', substr($route, $this->regexOffset, $nextOffset - $this->regexOffset), 0, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
foreach ($static as $staticPart)
|
||||
{
|
||||
if ($staticPart)
|
||||
{
|
||||
foreach ($static as $staticPart) {
|
||||
if ($staticPart) {
|
||||
$quotedPart = $this->quote($staticPart);
|
||||
|
||||
$this->parts[$this->partsCounter] = $quotedPart;
|
||||
|
@ -176,8 +169,7 @@ class RouteParser
|
|||
*/
|
||||
private function validateVariable($varName)
|
||||
{
|
||||
if (isset($this->variables[$varName]))
|
||||
{
|
||||
if (isset($this->variables[$varName])) {
|
||||
throw new BadRouteException("Cannot use the same placeholder '$varName' twice");
|
||||
}
|
||||
|
||||
|
@ -193,8 +185,7 @@ class RouteParser
|
|||
{
|
||||
$previous = $this->partsCounter - 1;
|
||||
|
||||
if (isset($this->parts[$previous]) && $this->parts[$previous] === '/')
|
||||
{
|
||||
if (isset($this->parts[$previous]) && $this->parts[$previous] === '/') {
|
||||
$this->partsCounter--;
|
||||
$match = '(?:/' . $match . ')';
|
||||
}
|
||||
|
|
23
lib/thirdparty/Asana.class.php
vendored
23
lib/thirdparty/Asana.class.php
vendored
|
@ -13,7 +13,7 @@ class Asana
|
|||
|
||||
$allTasks = array_reduce(
|
||||
static::get('/projects/' . $roadmapProjectId . '/tasks', [], $cache),
|
||||
function($carry, $task) use($cache) {
|
||||
function ($carry, $task) use ($cache) {
|
||||
$fullTask = static::get('/tasks/' . $task['id'], [], $cache);
|
||||
if ($fullTask['name']) {
|
||||
$carry[] = $fullTask;
|
||||
|
@ -23,15 +23,13 @@ class Asana
|
|||
[]
|
||||
);
|
||||
|
||||
foreach ($allTasks as $task)
|
||||
{
|
||||
foreach ($allTasks as $task) {
|
||||
$badge = "Planned";
|
||||
if ($task['completed'])
|
||||
{
|
||||
if ($task['completed']) {
|
||||
$badge = "Complete";
|
||||
}
|
||||
else if (in_array("In Progress", array_map(function($tag) { return $tag['name']; }, $task['tags'] ?? [])))
|
||||
{
|
||||
} elseif (in_array("In Progress", array_map(function ($tag) {
|
||||
return $tag['name'];
|
||||
}, $task['tags'] ?? []))) {
|
||||
$badge = "In Progress";
|
||||
}
|
||||
$taskDueTime = strtotime($task['due_on']);
|
||||
|
@ -45,12 +43,9 @@ class Asana
|
|||
];
|
||||
}
|
||||
|
||||
foreach ($tasks as &$groupTasks)
|
||||
{
|
||||
usort($groupTasks, function ($tA, $tB)
|
||||
{
|
||||
if ($tA['date'] xor $tB['date'])
|
||||
{
|
||||
foreach ($tasks as &$groupTasks) {
|
||||
usort($groupTasks, function ($tA, $tB) {
|
||||
if ($tA['date'] xor $tB['date']) {
|
||||
return $tA['date'] ? -1 : 1;
|
||||
}
|
||||
return $tA['date'] < $tB['date'] ? -1 : 1;
|
||||
|
|
83
lib/thirdparty/Github.class.php
vendored
83
lib/thirdparty/Github.class.php
vendored
|
@ -4,13 +4,11 @@ class Github
|
|||
{
|
||||
protected static function findReleaseAssetForOs(array $release, string $os)
|
||||
{
|
||||
if (!in_array($os, array_keys(OS::getAll())))
|
||||
{
|
||||
if (!in_array($os, array_keys(OS::getAll()))) {
|
||||
throw new DomainException('Unknown OS');
|
||||
}
|
||||
|
||||
foreach ($release['assets'] as $asset)
|
||||
{
|
||||
foreach ($release['assets'] as $asset) {
|
||||
$ext = substr($asset['name'], -4);
|
||||
if (
|
||||
($os == OS::OS_LINUX &&
|
||||
|
@ -18,8 +16,7 @@ class Github
|
|||
($os == OS::OS_OSX &&
|
||||
($ext == '.dmg' || in_array($asset['content_type'], ['application/x-diskcopy', 'application/x-apple-diskimage']))) ||
|
||||
($os == OS::OS_WINDOWS && $ext == '.exe')
|
||||
)
|
||||
{
|
||||
) {
|
||||
return $asset;
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +24,9 @@ class Github
|
|||
|
||||
public static function getAppRelease($cache = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
return static::get('/repos/lbryio/lbry-app/releases/latest', [], $cache);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -53,17 +47,13 @@ class Github
|
|||
|
||||
public static function getAppPrereleaseDownloadUrl($os, $cache = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
try {
|
||||
$releases = static::get('/repos/lbryio/lbry-app/releases', [], $cache);
|
||||
if (count($releases))
|
||||
{
|
||||
if (count($releases)) {
|
||||
$asset = static::findReleaseAssetForOs($releases[0], $os);
|
||||
return $asset ? $asset['browser_download_url'] : null;
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -72,28 +62,22 @@ class Github
|
|||
|
||||
public static function getDaemonReleaseProperty($os, $property, $isAssetProperty = false, $cache = true)
|
||||
{
|
||||
if (!in_array($os, array_keys(OS::getAll())))
|
||||
{
|
||||
if (!in_array($os, array_keys(OS::getAll()))) {
|
||||
throw new DomainException('Unknown OS');
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
$releaseData = static::get('/repos/lbryio/lbry/releases/latest', [], $cache);
|
||||
foreach ($releaseData['assets'] as $asset)
|
||||
{
|
||||
foreach ($releaseData['assets'] as $asset) {
|
||||
if (
|
||||
($os == OS::OS_LINUX && stripos($asset['browser_download_url'], 'linux') !== false) ||
|
||||
($os == OS::OS_OSX && stripos($asset['browser_download_url'], 'macos') !== false) ||
|
||||
($os == OS::OS_WINDOWS && strpos($asset['browser_download_url'], 'windows') !== false)
|
||||
)
|
||||
{
|
||||
) {
|
||||
return $isAssetProperty ? $asset[$property] : $releaseData[$property];
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -107,8 +91,11 @@ class Github
|
|||
public static function get($endpoint, array $params = [], $cache = true)
|
||||
{
|
||||
$twoHoursInSeconds = 7200;
|
||||
return CurlWithCache::get('https://api.github.com' . $endpoint . '?' . http_build_query($params), [],
|
||||
['headers' => ['Accept: application/vnd.github.v3.html+json'],'user_agent' => 'LBRY', 'json_response' => true, 'cache' => $cache === true ? $twoHoursInSeconds : $cache]);
|
||||
return CurlWithCache::get(
|
||||
'https://api.github.com' . $endpoint . '?' . http_build_query($params),
|
||||
[],
|
||||
['headers' => ['Accept: application/vnd.github.v3.html+json'],'user_agent' => 'LBRY', 'json_response' => true, 'cache' => $cache === true ? $twoHoursInSeconds : $cache]
|
||||
);
|
||||
}
|
||||
|
||||
public static function listRoadmapChangesets($cache = true)
|
||||
|
@ -118,18 +105,14 @@ class Github
|
|||
|
||||
$projects = ['lbry' => 'LBRY Protocol', 'lbry-app' => 'LBRY App'];
|
||||
|
||||
foreach($projects as $project => $projectLabel)
|
||||
{
|
||||
foreach ($projects as $project => $projectLabel) {
|
||||
$page = 1;
|
||||
do
|
||||
{
|
||||
do {
|
||||
$releases = static::get('/repos/lbryio/' . $project . '/releases', ['page' => $page], $cache);
|
||||
$page++;
|
||||
$allReleases = array_merge($allReleases, array_map(function ($release) use ($project, $projectLabel)
|
||||
{
|
||||
$allReleases = array_merge($allReleases, array_map(function ($release) use ($project, $projectLabel) {
|
||||
return $release + ['project' => $projectLabel];
|
||||
}, array_filter($releases, function ($release)
|
||||
{
|
||||
}, array_filter($releases, function ($release) {
|
||||
return isset($release['tag_name']) && isset($release['published_at']) && $release['published_at'];
|
||||
})));
|
||||
} while (count($releases) >= 30);
|
||||
|
@ -140,16 +123,13 @@ class Github
|
|||
* to strictly by time. - Jeremy
|
||||
*/
|
||||
|
||||
foreach ($allReleases as $release)
|
||||
{
|
||||
foreach ($allReleases as $release) {
|
||||
$group = null;
|
||||
$matches = null;
|
||||
if (preg_match('/^v(\d+)\.(\d+)\./', $release['tag_name'] ?? '', $matches))
|
||||
{
|
||||
if (preg_match('/^v(\d+)\.(\d+)\./', $release['tag_name'] ?? '', $matches)) {
|
||||
$group = $release['project'] . ' v' . $matches[1] . '.' . $matches[2];
|
||||
}
|
||||
if ($group)
|
||||
{
|
||||
if ($group) {
|
||||
$sets[$group][] = array_intersect_key($release, [
|
||||
'prerelease' => null, 'tag_name' => null, 'published_at' => null, 'project' => null
|
||||
]) + [
|
||||
|
@ -168,18 +148,17 @@ class Github
|
|||
}
|
||||
}
|
||||
|
||||
uasort($sets, function ($sA, $sB)
|
||||
{
|
||||
if ($sA[0]['project'] != $sB[0]['project'])
|
||||
{
|
||||
uasort($sets, function ($sA, $sB) {
|
||||
if ($sA[0]['project'] != $sB[0]['project']) {
|
||||
return $sA[0]['project'] < $sB[0]['project'] ? -1 : 1;
|
||||
}
|
||||
return $sB[0]['sort_key'] <=> $sA[0]['sort_key'];
|
||||
});
|
||||
|
||||
foreach ($sets as $group => &$groupSet)
|
||||
{
|
||||
usort($groupSet, function ($rA, $rB) { return $rB['created_at'] <=> $rA['created_at']; });
|
||||
foreach ($sets as $group => &$groupSet) {
|
||||
usort($groupSet, function ($rA, $rB) {
|
||||
return $rB['created_at'] <=> $rA['created_at'];
|
||||
});
|
||||
}
|
||||
|
||||
return $sets;
|
||||
|
|
8
lib/thirdparty/LBRY.class.php
vendored
8
lib/thirdparty/LBRY.class.php
vendored
|
@ -49,11 +49,9 @@ class LBRY
|
|||
|
||||
public static function editYouTube($status_token, $channel_name, $email, $sync_consent)
|
||||
{
|
||||
if ($email == null){
|
||||
return Curl::post(static::getApiUrl("/yt/update"),['status_token' => $status_token, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent],['json_response' => true]);
|
||||
}
|
||||
else{
|
||||
|
||||
if ($email == null) {
|
||||
return Curl::post(static::getApiUrl("/yt/update"), ['status_token' => $status_token, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent], ['json_response' => true]);
|
||||
} else {
|
||||
return Curl::post(static::getApiUrl("/yt/update"), ['status_token' => $status_token, 'new_email' => $email, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent], ['json_response' => true]);
|
||||
}
|
||||
}
|
||||
|
|
12
lib/thirdparty/Salesforce.class.php
vendored
12
lib/thirdparty/Salesforce.class.php
vendored
|
@ -6,8 +6,7 @@ class Salesforce
|
|||
API_URL = 'https://api.salesforceiq.com/v2/',
|
||||
DEFAULT_LIST_ID = '58387a94e4b0a1fea2c76f4a';
|
||||
|
||||
protected static
|
||||
$curlOptions = [
|
||||
protected static $curlOptions = [
|
||||
'headers' => ['Accept: application/json', 'Content-type: application/json'],
|
||||
'json_response' => true,
|
||||
'json_data' => true,
|
||||
|
@ -27,10 +26,8 @@ class Salesforce
|
|||
|
||||
$contactId = static::post('contacts?_upsert=email', $contactData)['id'] ?? null;
|
||||
|
||||
if ($initialListId)
|
||||
{
|
||||
if (!$contactId)
|
||||
{
|
||||
if ($initialListId) {
|
||||
if (!$contactId) {
|
||||
throw new SalesforceException('Failed to generate or update contact');
|
||||
}
|
||||
|
||||
|
@ -46,8 +43,7 @@ class Salesforce
|
|||
protected static function getApiUserPassword()
|
||||
{
|
||||
$userpw = Config::get(Config::SALESFORCE_KEY) . ':' . Config::get(Config::SALESFORCE_SECRET);
|
||||
if ($userpw[0] === ':' || substr($userpw, -1) === ':')
|
||||
{
|
||||
if ($userpw[0] === ':' || substr($userpw, -1) === ':') {
|
||||
throw new SalesforceException('Salesforce key and/or secret not configured correctly');
|
||||
}
|
||||
return $userpw;
|
||||
|
|
7
lib/thirdparty/Slack.class.php
vendored
7
lib/thirdparty/Slack.class.php
vendored
|
@ -2,17 +2,14 @@
|
|||
|
||||
class Slack
|
||||
{
|
||||
|
||||
public static function sendErrorIfProd($e, $alert = true)
|
||||
{
|
||||
if ($e instanceof Throwable)
|
||||
{
|
||||
if ($e instanceof Throwable) {
|
||||
$e = Debug::exceptionToString($e);
|
||||
}
|
||||
|
||||
$slackErrorNotificationUrl = Config::get(Config::SLACK_ERROR_NOTIFICATION_URL);
|
||||
if ($slackErrorNotificationUrl)
|
||||
{
|
||||
if ($slackErrorNotificationUrl) {
|
||||
Curl::post($slackErrorNotificationUrl, ['text' => ($alert ? '<!channel> ' : '') . Request::getRelativeUri() . "\n" . $e], ['json_data' => true]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,9 @@ class Config
|
|||
|
||||
protected static function load()
|
||||
{
|
||||
if (!static::$loaded)
|
||||
{
|
||||
if (!static::$loaded) {
|
||||
$dataFile = ROOT_DIR.'/data/config.php';
|
||||
if (!is_readable($dataFile))
|
||||
{
|
||||
if (!is_readable($dataFile)) {
|
||||
throw new RuntimeException('config file is missing or not readable');
|
||||
}
|
||||
static::$data = require $dataFile;
|
||||
|
|
|
@ -11,25 +11,25 @@ class Curl
|
|||
|
||||
public static function get($url, $params = [], $options = [])
|
||||
{
|
||||
list ($status, $headers, $body) = static::doCurl(static::GET, $url, $params, $options);
|
||||
list($status, $headers, $body) = static::doCurl(static::GET, $url, $params, $options);
|
||||
return $body;
|
||||
}
|
||||
|
||||
public static function post($url, $params = [], $options = [])
|
||||
{
|
||||
list ($status, $headers, $body) = static::doCurl(static::POST, $url, $params, $options);
|
||||
list($status, $headers, $body) = static::doCurl(static::POST, $url, $params, $options);
|
||||
return $body;
|
||||
}
|
||||
|
||||
public static function put($url, $params = [], $options = [])
|
||||
{
|
||||
list ($status, $headers, $body) = static::doCurl(static::PUT, $url, $params, $options);
|
||||
list($status, $headers, $body) = static::doCurl(static::PUT, $url, $params, $options);
|
||||
return $body;
|
||||
}
|
||||
|
||||
public static function delete($url, $params = [], $options = [])
|
||||
{
|
||||
list ($status, $headers, $body) = static::doCurl(static::DELETE, $url, $params, $options);
|
||||
list($status, $headers, $body) = static::doCurl(static::DELETE, $url, $params, $options);
|
||||
return $body;
|
||||
}
|
||||
|
||||
|
@ -50,20 +50,17 @@ class Curl
|
|||
];
|
||||
|
||||
$invalid = array_diff_key($options, $defaults);
|
||||
if ($invalid)
|
||||
{
|
||||
if ($invalid) {
|
||||
throw new DomainException('Invalid curl options: ' . join(', ', array_keys($invalid)));
|
||||
}
|
||||
|
||||
if (!in_array($method, [static::GET, static::POST, static::PUT]))
|
||||
{
|
||||
if (!in_array($method, [static::GET, static::POST, static::PUT])) {
|
||||
throw new DomainException('Invalid method: ' . $method);
|
||||
}
|
||||
|
||||
$options = array_merge($defaults, $options);
|
||||
|
||||
if ($options['headers'] && $options['headers'] !== array_values($options['headers'])) // associative array
|
||||
{
|
||||
if ($options['headers'] && $options['headers'] !== array_values($options['headers'])) { // associative array
|
||||
throw new DomainException('Headers must not be an associative array. Its a simple array with values of the form "Header: value"');
|
||||
}
|
||||
|
||||
|
@ -72,14 +69,12 @@ class Curl
|
|||
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($ch, CURLOPT_STDERR, fopen(sys_get_temp_dir().'/curl-debug-'.date('Ymd-His'), 'w+'));
|
||||
|
||||
if ($ch === false || $ch === null)
|
||||
{
|
||||
if ($ch === false || $ch === null) {
|
||||
throw new LogicException('Unable to initialize cURL');
|
||||
}
|
||||
|
||||
$urlWithParams = $url;
|
||||
if ($method == static::GET && $params)
|
||||
{
|
||||
if ($method == static::GET && $params) {
|
||||
$urlWithParams .= (strpos($urlWithParams, '?') === false ? '?' : '&') . http_build_query($params);
|
||||
}
|
||||
|
||||
|
@ -96,52 +91,39 @@ class Curl
|
|||
CURLOPT_USERAGENT => $options['user_agent'],
|
||||
]);
|
||||
|
||||
if ($method == static::POST)
|
||||
{
|
||||
if ($method == static::POST) {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
}
|
||||
elseif ($method == static::PUT)
|
||||
{
|
||||
} elseif ($method == static::PUT) {
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
}
|
||||
|
||||
if (in_array($method, [static::PUT, static::POST]))
|
||||
{
|
||||
if (in_array($method, [static::PUT, static::POST])) {
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $options['json_data'] ? json_encode($params) : http_build_query($params));
|
||||
}
|
||||
|
||||
if ($options['proxy'])
|
||||
{
|
||||
if ($options['proxy']) {
|
||||
curl_setopt($ch, CURLOPT_PROXY, $options['proxy']);
|
||||
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||
}
|
||||
|
||||
if ($options['password'])
|
||||
{
|
||||
if ($options['password']) {
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $options['password']);
|
||||
}
|
||||
|
||||
if ($options['cookie'])
|
||||
{
|
||||
if ($options['cookie']) {
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $options['cookie']);
|
||||
}
|
||||
|
||||
$startingResponse = false;
|
||||
$headers = [];
|
||||
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $h) use (&$headers, &$startingResponse)
|
||||
{
|
||||
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $h) use (&$headers, &$startingResponse) {
|
||||
$value = trim($h);
|
||||
if ($value === '')
|
||||
{
|
||||
if ($value === '') {
|
||||
$startingResponse = true;
|
||||
}
|
||||
elseif ($startingResponse)
|
||||
{
|
||||
} elseif ($startingResponse) {
|
||||
$startingResponse = false;
|
||||
$headers = [$value];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$headers[] = $value;
|
||||
}
|
||||
return strlen($h);
|
||||
|
@ -149,21 +131,16 @@ class Curl
|
|||
|
||||
$rawResponse = curl_exec($ch);
|
||||
|
||||
if ($options['json_response'])
|
||||
{
|
||||
if ($options['json_response']) {
|
||||
$responseContent = $rawResponse ? json_decode($rawResponse, true) : [];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$responseContent = $rawResponse;
|
||||
}
|
||||
|
||||
$statusCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
if (curl_errno($ch))
|
||||
{
|
||||
if ($options['retry'] && is_numeric($options['retry']) && $options['retry'] > 0)
|
||||
{
|
||||
if (curl_errno($ch)) {
|
||||
if ($options['retry'] && is_numeric($options['retry']) && $options['retry'] > 0) {
|
||||
$options['retry'] -= 1;
|
||||
return static::doCurl($method, $url, $params, $options);
|
||||
}
|
||||
|
@ -178,7 +155,10 @@ class Curl
|
|||
|
||||
class CurlException extends Exception
|
||||
{
|
||||
protected $errno, $error, $info, $handle;
|
||||
protected $errno;
|
||||
protected $error;
|
||||
protected $info;
|
||||
protected $handle;
|
||||
|
||||
public function __construct($curlHandle, Exception $previous = null)
|
||||
{
|
||||
|
|
|
@ -13,25 +13,19 @@ class CurlWithCache extends Curl
|
|||
unset($options['cache']);
|
||||
|
||||
$cacheKey = $cacheEnabled ? md5($url . $method . serialize($options) . serialize($params)) : null;
|
||||
if ($cacheAllowed && $cacheKey)
|
||||
{
|
||||
if ($cacheAllowed && $cacheKey) {
|
||||
$cachedData = apc_fetch($cacheKey);
|
||||
if ($cachedData)
|
||||
{
|
||||
if ($cachedData) {
|
||||
return $cachedData;
|
||||
}
|
||||
}
|
||||
|
||||
$response = parent::doCurl($method, $url, $params, $options);
|
||||
|
||||
if ($cacheEnabled)
|
||||
{
|
||||
if ($cacheAllowed)
|
||||
{
|
||||
if ($cacheEnabled) {
|
||||
if ($cacheAllowed) {
|
||||
apc_store($cacheKey, $response, $cacheTimeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
apc_delete($cacheKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,16 +22,17 @@ class Debug
|
|||
public static function getFullTrace(Throwable $exception)
|
||||
{
|
||||
$rtn = '';
|
||||
foreach ($exception->getTrace() as $count => $frame)
|
||||
{
|
||||
foreach ($exception->getTrace() as $count => $frame) {
|
||||
$args = isset($frame['args']) ? static::exceptionFrameArgsToString($frame['args']) : '';
|
||||
|
||||
$rtn .= sprintf("#%s %s(%s): %s(%s)\n",
|
||||
$rtn .= sprintf(
|
||||
"#%s %s(%s): %s(%s)\n",
|
||||
$count,
|
||||
$frame['file'] ?? 'unknown file',
|
||||
$frame['line'] ?? 'unknown line',
|
||||
isset($frame['class']) ? $frame['class'].$frame['type'].$frame['function'] : $frame['function'],
|
||||
$args);
|
||||
$args
|
||||
);
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
@ -39,34 +40,20 @@ class Debug
|
|||
public static function exceptionFrameArgsToString(array $args)
|
||||
{
|
||||
$ret = [];
|
||||
foreach ($args as $arg)
|
||||
{
|
||||
if (is_string($arg))
|
||||
{
|
||||
foreach ($args as $arg) {
|
||||
if (is_string($arg)) {
|
||||
$ret[] = "'" . $arg . "'";
|
||||
}
|
||||
elseif (is_array($arg))
|
||||
{
|
||||
} elseif (is_array($arg)) {
|
||||
$ret[] = 'Array(' . count($arg) . ')';
|
||||
}
|
||||
elseif (is_null($arg))
|
||||
{
|
||||
} elseif (is_null($arg)) {
|
||||
$ret[] = 'NULL';
|
||||
}
|
||||
elseif (is_bool($arg))
|
||||
{
|
||||
} elseif (is_bool($arg)) {
|
||||
$ret[] = ($arg) ? 'true' : 'false';
|
||||
}
|
||||
elseif (is_object($arg))
|
||||
{
|
||||
} elseif (is_object($arg)) {
|
||||
$ret[] = get_class($arg) . (!($arg instanceof Closure) && isset($arg->id) ? "({$arg->id})" : '');
|
||||
}
|
||||
elseif (is_resource($arg))
|
||||
{
|
||||
} elseif (is_resource($arg)) {
|
||||
$ret[] = get_resource_type($arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$ret[] = $arg;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ class Encoding
|
|||
|
||||
protected static function convertBase($numberInput, $sourceAlphabet, $targetAlphabet)
|
||||
{
|
||||
if ($sourceAlphabet == $targetAlphabet)
|
||||
{
|
||||
if ($sourceAlphabet == $targetAlphabet) {
|
||||
return $numberInput;
|
||||
}
|
||||
|
||||
|
@ -35,11 +34,9 @@ class Encoding
|
|||
$toLen = strlen($targetAlphabet);
|
||||
$numberLen = strlen($numberInput);
|
||||
|
||||
if ($targetAlphabet == $decimalAlphabet)
|
||||
{
|
||||
if ($targetAlphabet == $decimalAlphabet) {
|
||||
$decimal = 0;
|
||||
for ($i = 1; $i <= $numberLen; $i++)
|
||||
{
|
||||
for ($i = 1; $i <= $numberLen; $i++) {
|
||||
$decimal = bcadd($decimal, bcmul(array_search($number[$i - 1], $fromBase), bcpow($fromLen, $numberLen - $i)));
|
||||
}
|
||||
return $decimal;
|
||||
|
@ -47,14 +44,12 @@ class Encoding
|
|||
|
||||
$base10 = $sourceAlphabet == $decimalAlphabet ? $numberInput : static::convertBase($numberInput, $sourceAlphabet, $decimalAlphabet);
|
||||
|
||||
if ($base10 < strlen($targetAlphabet))
|
||||
{
|
||||
if ($base10 < strlen($targetAlphabet)) {
|
||||
return $toBase[$base10];
|
||||
}
|
||||
|
||||
$retval = '';
|
||||
while ($base10 != '0')
|
||||
{
|
||||
while ($base10 != '0') {
|
||||
$retval = $toBase[bcmod($base10, $toLen)] . $retval;
|
||||
$base10 = bcdiv($base10, $toLen, 0);
|
||||
}
|
||||
|
|
|
@ -8,23 +8,18 @@ class Gzip
|
|||
$mode = 'wb' . $level;
|
||||
|
||||
$fpOut = gzopen($compressedPath, $mode);
|
||||
if (!$fpOut)
|
||||
{
|
||||
if (!$fpOut) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fpIn = fopen($source, 'rb');
|
||||
$error = false;
|
||||
if ($fpIn)
|
||||
{
|
||||
while (!feof($fpIn))
|
||||
{
|
||||
if ($fpIn) {
|
||||
while (!feof($fpIn)) {
|
||||
gzwrite($fpOut, fread($fpIn, 1024 * 512));
|
||||
}
|
||||
fclose($fpIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,24 +25,20 @@ class Lock
|
|||
*/
|
||||
public static function getLock($name, $blocking = false)
|
||||
{
|
||||
if (!preg_match('/^[A-Za-z0-9\.\-_]+$/', $name))
|
||||
{
|
||||
if (!preg_match('/^[A-Za-z0-9\.\-_]+$/', $name)) {
|
||||
throw new InvalidArgumentException('Invalid lock name: "' . $name . '"');
|
||||
}
|
||||
|
||||
$filename = static::getLockDir() . '/' . $name;
|
||||
if (!preg_match('/\.lo?ck$/', $filename))
|
||||
{
|
||||
if (!preg_match('/\.lo?ck$/', $filename)) {
|
||||
$filename .= '.lck';
|
||||
}
|
||||
if (!file_exists($filename))
|
||||
{
|
||||
if (!file_exists($filename)) {
|
||||
file_put_contents($filename, '');
|
||||
chmod($filename, 0666); // if the file cant be opened for writing later, getting the lock will fail
|
||||
}
|
||||
$lockFile = fopen($filename, 'w+');
|
||||
if (!flock($lockFile, $blocking ? LOCK_EX : LOCK_EX|LOCK_NB))
|
||||
{
|
||||
if (!flock($lockFile, $blocking ? LOCK_EX : LOCK_EX|LOCK_NB)) {
|
||||
fclose($lockFile);
|
||||
return false;
|
||||
}
|
||||
|
@ -56,8 +52,7 @@ class Lock
|
|||
*/
|
||||
public static function freeLock($lockFile)
|
||||
{
|
||||
if ($lockFile)
|
||||
{
|
||||
if ($lockFile) {
|
||||
flock($lockFile, LOCK_UN);
|
||||
fclose($lockFile);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,7 @@ class OS
|
|||
|
||||
public static function getOsForExtension($ext)
|
||||
{
|
||||
switch ($ext)
|
||||
{
|
||||
switch ($ext) {
|
||||
case 'deb':
|
||||
return OS::OS_LINUX;
|
||||
|
||||
|
|
|
@ -35,13 +35,11 @@ class Shell
|
|||
'live_callback' => null,
|
||||
], $options);
|
||||
|
||||
if ($options['echo_errors'] === null)
|
||||
{
|
||||
if ($options['echo_errors'] === null) {
|
||||
$options['echo_errors'] = $options['echo'];
|
||||
}
|
||||
|
||||
if ($options['live_callback'] && !is_callable($options['live_callback']))
|
||||
{
|
||||
if ($options['live_callback'] && !is_callable($options['live_callback'])) {
|
||||
throw new InvalidArgumentException('live_callback option must be a valid callback');
|
||||
}
|
||||
|
||||
|
@ -51,8 +49,7 @@ class Shell
|
|||
];
|
||||
|
||||
$process = proc_open($cmd, $descriptorSpec, $pipes);
|
||||
if (!is_resource($process))
|
||||
{
|
||||
if (!is_resource($process)) {
|
||||
throw new RuntimeException('proc_open failed');
|
||||
}
|
||||
|
||||
|
@ -62,37 +59,27 @@ class Shell
|
|||
$output = '';
|
||||
$err = '';
|
||||
|
||||
while (!feof($pipes[1]) || !feof($pipes[2]))
|
||||
{
|
||||
foreach ($pipes as $key => $pipe)
|
||||
{
|
||||
while (!feof($pipes[1]) || !feof($pipes[2])) {
|
||||
foreach ($pipes as $key => $pipe) {
|
||||
$data = fread($pipe, 1024);
|
||||
if (!$data)
|
||||
{
|
||||
if (!$data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (1 == $key)
|
||||
{
|
||||
if (1 == $key) {
|
||||
$output .= $data;
|
||||
if ($options['echo'])
|
||||
{
|
||||
if ($options['echo']) {
|
||||
fprintf(STDOUT, "%s", $data);
|
||||
}
|
||||
if ($options['live_callback'])
|
||||
{
|
||||
if ($options['live_callback']) {
|
||||
call_user_func($options['live_callback'], $data, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$err .= $data;
|
||||
if ($options['echo_errors'])
|
||||
{
|
||||
if ($options['echo_errors']) {
|
||||
fprintf(STDERR, "%s", $data);
|
||||
}
|
||||
if ($options['live_callback'])
|
||||
{
|
||||
if ($options['live_callback']) {
|
||||
call_user_func($options['live_callback'], $data, true);
|
||||
}
|
||||
}
|
||||
|
@ -125,23 +112,17 @@ class Shell
|
|||
{
|
||||
$shellArgs = [];
|
||||
|
||||
foreach ($options as $key => $value)
|
||||
{
|
||||
if ($value === false)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
if ($value === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strlen($key) === 1)
|
||||
{
|
||||
if (strlen($key) === 1) {
|
||||
$shellArgs[] = '-'.$key;
|
||||
if ($value !== true)
|
||||
{
|
||||
if ($value !== true) {
|
||||
$shellArgs[] = $value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$shellArgs[] = '--' . $key . ($value !== true ? '=' . $value : '');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,8 +69,7 @@ class Smaz
|
|||
|
||||
protected static function getEncodeBook($codebook)
|
||||
{
|
||||
if (!isset(static::$encodeBooks[$codebook]))
|
||||
{
|
||||
if (!isset(static::$encodeBooks[$codebook])) {
|
||||
static::$encodeBooks[$codebook] = array_flip(static::getDecodeBook($codebook));
|
||||
}
|
||||
return static::$encodeBooks[$codebook];
|
||||
|
@ -78,12 +77,10 @@ class Smaz
|
|||
|
||||
protected static function getDecodeBook($codebook)
|
||||
{
|
||||
if (!static::$decodeBooks[$codebook])
|
||||
{
|
||||
if (!static::$decodeBooks[$codebook]) {
|
||||
throw new Exception('decodebook ' . $codebook . ' does not exist');
|
||||
}
|
||||
if (count(static::$decodeBooks[$codebook]) > static::VERBATIM_CHAR)
|
||||
{
|
||||
if (count(static::$decodeBooks[$codebook]) > static::VERBATIM_CHAR) {
|
||||
throw new Exception('decodebook ' . $codebook . ' must be at most ' . static::VERBATIM_CHAR . 'entries');
|
||||
}
|
||||
return static::$decodeBooks[$codebook];
|
||||
|
@ -106,18 +103,14 @@ class Smaz
|
|||
$verbatim = '';
|
||||
$maxItemLen = max(array_map('strlen', array_keys($encodeBook)));
|
||||
|
||||
while ($inIdx < $inLen)
|
||||
{
|
||||
while ($inIdx < $inLen) {
|
||||
$encode = false;
|
||||
|
||||
for ($j = min($maxItemLen, $inLen - $inIdx); $j > 0; $j--)
|
||||
{
|
||||
for ($j = min($maxItemLen, $inLen - $inIdx); $j > 0; $j--) {
|
||||
$code = isset($encodeBook[substr($str, $inIdx, $j)]) ? $encodeBook[substr($str, $inIdx, $j)] : null;
|
||||
if ($code !== null)
|
||||
{
|
||||
if ($code !== null) {
|
||||
// echo substr($str, $inIdx, $j) . " = $code\n";
|
||||
if (strlen($verbatim))
|
||||
{
|
||||
if (strlen($verbatim)) {
|
||||
$output .= static::flushVerbatim($verbatim);
|
||||
$verbatim = '';
|
||||
}
|
||||
|
@ -128,21 +121,18 @@ class Smaz
|
|||
}
|
||||
}
|
||||
|
||||
if (!$encode)
|
||||
{
|
||||
if (!$encode) {
|
||||
// echo "VERBATIM\n";
|
||||
$verbatim .= $str[$inIdx];
|
||||
$inIdx++;
|
||||
if (strlen($verbatim) == 255) // any longer, and we can't represent the length as a single char
|
||||
{
|
||||
if (strlen($verbatim) == 255) { // any longer, and we can't represent the length as a single char
|
||||
$output .= static::flushVerbatim($verbatim);
|
||||
$verbatim = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($verbatim))
|
||||
{
|
||||
if (strlen($verbatim)) {
|
||||
$output .= static::flushVerbatim($verbatim);
|
||||
}
|
||||
return $output;
|
||||
|
@ -161,26 +151,18 @@ class Smaz
|
|||
$output = '';
|
||||
$i = 0;
|
||||
|
||||
while ($i < strlen($str))
|
||||
{
|
||||
while ($i < strlen($str)) {
|
||||
$code = ord($str[$i]);
|
||||
if ($code == static::VERBATIM_CHAR)
|
||||
{
|
||||
if ($code == static::VERBATIM_CHAR) {
|
||||
$output .= $str[$i + 1];
|
||||
$i += 2;
|
||||
}
|
||||
elseif ($code == static::VERBATIM_STR)
|
||||
{
|
||||
} elseif ($code == static::VERBATIM_STR) {
|
||||
$len = ord($str[$i + 1]);
|
||||
$output .= substr($str, $i + 2, $len);
|
||||
$i += 2 + $len;
|
||||
}
|
||||
elseif (!isset($decodeBook[$code]))
|
||||
{
|
||||
} elseif (!isset($decodeBook[$code])) {
|
||||
return null; // decode error. throw exception?
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$output .= $decodeBook[$code];
|
||||
$i++;
|
||||
}
|
||||
|
@ -191,18 +173,14 @@ class Smaz
|
|||
protected static function flushVerbatim($verbatim)
|
||||
{
|
||||
$output = '';
|
||||
if (!strlen($verbatim))
|
||||
{
|
||||
if (!strlen($verbatim)) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
if (strlen($verbatim) > 1)
|
||||
{
|
||||
if (strlen($verbatim) > 1) {
|
||||
$output .= chr(static::VERBATIM_STR);
|
||||
$output .= chr(strlen($verbatim));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$output .= chr(static::VERBATIM_CHAR);
|
||||
}
|
||||
$output .= $verbatim;
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
<?php
|
||||
|
||||
class PostNotFoundException extends Exception {}
|
||||
class PostNotFoundException extends Exception
|
||||
{
|
||||
}
|
||||
|
||||
class PostMalformedException extends Exception {}
|
||||
class PostMalformedException extends Exception
|
||||
{
|
||||
}
|
||||
|
||||
class Post
|
||||
{
|
||||
|
@ -10,14 +14,24 @@ class Post
|
|||
SORT_ORD_ASC = 'sort_ord_asc';
|
||||
|
||||
protected static $slugMap = [];
|
||||
protected $path, $slug, $title, $metadata, $author, $date, $markdown, $contentText, $contentHtml, $cover, $postType, $category;
|
||||
protected $path;
|
||||
protected $slug;
|
||||
protected $title;
|
||||
protected $metadata;
|
||||
protected $author;
|
||||
protected $date;
|
||||
protected $markdown;
|
||||
protected $contentText;
|
||||
protected $contentHtml;
|
||||
protected $cover;
|
||||
protected $postType;
|
||||
protected $category;
|
||||
protected $isCoverLight = false;
|
||||
|
||||
public static function load($relativeOrAbsolutePath)
|
||||
{
|
||||
$pathTokens = explode('/', $relativeOrAbsolutePath);
|
||||
if (count($pathTokens) <= 1)
|
||||
{
|
||||
if (count($pathTokens) <= 1) {
|
||||
throw new LogicException('Cannot load a post without a path.');
|
||||
}
|
||||
|
||||
|
@ -29,13 +43,10 @@ class Post
|
|||
$relativeOrAbsolutePath .
|
||||
(substr($filename, -3) !== '.md' ? '.md' : '');
|
||||
|
||||
if (!file_exists($path) && $isRelative) //may have come in without a post number
|
||||
{
|
||||
if ($isRelative)
|
||||
{
|
||||
if (!file_exists($path) && $isRelative) { //may have come in without a post number
|
||||
if ($isRelative) {
|
||||
$slugMap = static::getSlugMap($postType);
|
||||
if (isset($slugMap[$slug]))
|
||||
{
|
||||
if (isset($slugMap[$slug])) {
|
||||
return static::load($slugMap[$slug]);
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +54,7 @@ class Post
|
|||
}
|
||||
|
||||
list($ignored, $frontMatter, $content) = explode('---', file_get_contents($path), 3) + ['','',''];
|
||||
if (!$frontMatter || !$content)
|
||||
{
|
||||
if (!$frontMatter || !$content) {
|
||||
throw new PostMalformedException('Post "' . basename($path) . '" is missing front matter or content');
|
||||
}
|
||||
return new static($path, $postType, $slug, Spyc::YAMLLoadString(trim($frontMatter)), trim($content));
|
||||
|
@ -68,31 +78,26 @@ class Post
|
|||
public static function find($folder, $sort = null)
|
||||
{
|
||||
$posts = [];
|
||||
foreach(glob(rtrim($folder, '/') . '/*.md') as $file)
|
||||
{
|
||||
foreach (glob(rtrim($folder, '/') . '/*.md') as $file) {
|
||||
$posts[] = static::load($file);
|
||||
}
|
||||
|
||||
if ($sort)
|
||||
{
|
||||
switch ($sort)
|
||||
{
|
||||
if ($sort) {
|
||||
switch ($sort) {
|
||||
case static::SORT_DATE_DESC:
|
||||
usort($posts, function(Post $a, Post $b) {
|
||||
usort($posts, function (Post $a, Post $b) {
|
||||
return strcasecmp($b->getDate()->format('Y-m-d'), $a->getDate()->format('Y-m-d'));
|
||||
});
|
||||
break;
|
||||
|
||||
case static::SORT_ORD_ASC:
|
||||
usort($posts, function(Post $a, Post $b) {
|
||||
usort($posts, function (Post $a, Post $b) {
|
||||
$aMeta = $a->getMetadata();
|
||||
$bMeta = $b->getMetadata();
|
||||
if (!isset($aMeta['order']) && !isset($bMeta['order']))
|
||||
{
|
||||
if (!isset($aMeta['order']) && !isset($bMeta['order'])) {
|
||||
return $a->getTitle() < $b->getTitle() ? -1 : 1;
|
||||
}
|
||||
if (isset($aMeta['order']) && isset($bMeta['order']))
|
||||
{
|
||||
if (isset($aMeta['order']) && isset($bMeta['order'])) {
|
||||
return $aMeta['order'] < $bMeta['order'] ? -1 : 1;
|
||||
}
|
||||
return isset($aMeta['order']) ? -1 : 1;
|
||||
|
@ -105,15 +110,13 @@ class Post
|
|||
|
||||
public static function filter(array $posts, array $filters)
|
||||
{
|
||||
return array_filter($posts, function(Post $post) use($filters) {
|
||||
return array_filter($posts, function (Post $post) use ($filters) {
|
||||
$metadata = $post->getMetadata();
|
||||
foreach($filters as $filterAttr => $filterValue)
|
||||
{
|
||||
foreach ($filters as $filterAttr => $filterValue) {
|
||||
if (!isset($metadata[$filterAttr]) || (
|
||||
($metadata[$filterAttr] != $filterValue) &&
|
||||
(!is_array($metadata[$filterAttr]) || !in_array($filterValue, $metadata[$filterAttr]))
|
||||
))
|
||||
{
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -159,26 +162,26 @@ class Post
|
|||
public function getAuthorGithubID()
|
||||
{
|
||||
$post = ContentActions::prepareBioPartial(['person' =>$this->author]);
|
||||
if(array_key_exists("github", $post)){
|
||||
if (array_key_exists("github", $post)) {
|
||||
return $post["github"];
|
||||
}
|
||||
}
|
||||
|
||||
public function getAuthorTwitterID()
|
||||
{
|
||||
public function getAuthorTwitterID()
|
||||
{
|
||||
$post = ContentActions::prepareBioPartial(['person' =>$this->author]);
|
||||
if(array_key_exists("twitter", $post)){
|
||||
if (array_key_exists("twitter", $post)) {
|
||||
return $post["twitter"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAuthorEmail()
|
||||
{
|
||||
public function getAuthorEmail()
|
||||
{
|
||||
$post = ContentActions::prepareBioPartial(['person' =>$this->author]);
|
||||
if(array_key_exists("email", $post)){
|
||||
if (array_key_exists("email", $post)) {
|
||||
return $post["email"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getDate()
|
||||
{
|
||||
|
@ -202,8 +205,7 @@ public function getAuthorEmail()
|
|||
|
||||
public function getContentText($wordLimit = null, $appendEllipsis = false)
|
||||
{
|
||||
if ($this->markdown && !$this->contentText)
|
||||
{
|
||||
if ($this->markdown && !$this->contentText) {
|
||||
// $this->contentText = $this->markdownToText(trim($this->markdown));
|
||||
$this->contentText = html_entity_decode(str_replace(' ', ' ', strip_tags($this->getContentHtml())), ENT_COMPAT, 'utf-8');
|
||||
}
|
||||
|
@ -213,8 +215,7 @@ public function getAuthorEmail()
|
|||
|
||||
public function getContentHtml()
|
||||
{
|
||||
if ($this->markdown && !$this->contentHtml)
|
||||
{
|
||||
if ($this->markdown && !$this->contentHtml) {
|
||||
$this->contentHtml = ParsedownExtra::instance()->text(trim($this->markdown));
|
||||
}
|
||||
return $this->contentHtml;
|
||||
|
@ -261,7 +262,6 @@ public function getAuthorEmail()
|
|||
$post = ContentActions::prepareBioPartial(['person' =>$this->author]);
|
||||
|
||||
return $post["email"];
|
||||
|
||||
}
|
||||
|
||||
public function getAuthorPhoto()
|
||||
|
@ -288,16 +288,14 @@ public function getAuthorEmail()
|
|||
$urls = [];
|
||||
|
||||
$cover = $this->getCover();
|
||||
if ($cover)
|
||||
{
|
||||
if ($cover) {
|
||||
$urls[] = 'https://' . Request::getHost() . '/img/blog-covers/' . $cover;
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
preg_match_all('/!\[.*?\]\((.*?)\)/', $this->markdown, $matches);
|
||||
|
||||
if ($matches)
|
||||
{
|
||||
if ($matches) {
|
||||
$urls = array_merge($urls, $matches[1]);
|
||||
}
|
||||
|
||||
|
@ -338,15 +336,13 @@ public function getAuthorEmail()
|
|||
|
||||
# TBB: if there are $wordLimit words or less, this check is necessary
|
||||
# to prevent the last word from being lost.
|
||||
if ($numWords > $wordLimit)
|
||||
{
|
||||
if ($numWords > $wordLimit) {
|
||||
array_pop($words);
|
||||
}
|
||||
|
||||
$string = implode(' ', $words);
|
||||
|
||||
if ($appendEllipsis && $numWords > $wordLimit)
|
||||
{
|
||||
if ($appendEllipsis && $numWords > $wordLimit) {
|
||||
$ellipsis = '…';
|
||||
$string .= $ellipsis;
|
||||
}
|
||||
|
@ -361,7 +357,7 @@ public function getAuthorEmail()
|
|||
|
||||
public static function collectMetadata(array $posts, $field)
|
||||
{
|
||||
$values = array_unique(array_map(function(Post $post) use($field) {
|
||||
$values = array_unique(array_map(function (Post $post) use ($field) {
|
||||
$metadata = $post->getMetadata();
|
||||
return $metadata[$field] ?? null;
|
||||
}, $posts));
|
||||
|
@ -371,13 +367,11 @@ public function getAuthorEmail()
|
|||
|
||||
public static function getSlugMap($postType)
|
||||
{
|
||||
if (!isset(static::$slugMap[$postType]))
|
||||
{
|
||||
if (!isset(static::$slugMap[$postType])) {
|
||||
static::$slugMap[$postType] = [];
|
||||
$files = glob(ContentActions::CONTENT_DIR . '/' . $postType . '/*.md');
|
||||
usort($files, 'strnatcasecmp');
|
||||
foreach($files as $file)
|
||||
{
|
||||
foreach ($files as $file) {
|
||||
static::$slugMap[$postType][static::getSlugFromFilename($file)] = $file;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@ $options = getopt('f');
|
|||
$force = isset($options['f']); // update even if no NEEDS_UPDATE file exists
|
||||
|
||||
$needsUpdateFile = ROOT_DIR . '/data/writeable/NEEDS_UPDATE';
|
||||
if (!$force && !file_exists($needsUpdateFile))
|
||||
{
|
||||
if (!$force && !file_exists($needsUpdateFile)) {
|
||||
echo "No update necessary\n";
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,25 +16,24 @@ class Response
|
|||
const HEADER_CONTENT_ENCODING = 'Content-Encoding';
|
||||
const HEADER_CROSS_ORIGIN = 'Access-Control-Allow-Origin';
|
||||
|
||||
protected static
|
||||
$metaDescription = '',
|
||||
$metaTitle = '',
|
||||
$jsCalls = [],
|
||||
$assets = [
|
||||
protected static $metaDescription = '';
|
||||
protected static $metaTitle = '';
|
||||
protected static $jsCalls = [];
|
||||
protected static $assets = [
|
||||
'js' => [
|
||||
'/js/jquery-3.3.1.min.js',
|
||||
'/js/global.js'
|
||||
],
|
||||
'css' => ['/css/all.css']
|
||||
],
|
||||
$headers = [],
|
||||
$headersSent = false,
|
||||
$content = '',
|
||||
$contentSent = false,
|
||||
$isHeadersOnly = false,
|
||||
$gzipResponseContent = true,
|
||||
$metaImages = [],
|
||||
$facebookAnalyticsType = "PageView";
|
||||
];
|
||||
protected static $headers = [];
|
||||
protected static $headersSent = false;
|
||||
protected static $content = '';
|
||||
protected static $contentSent = false;
|
||||
protected static $isHeadersOnly = false;
|
||||
protected static $gzipResponseContent = true;
|
||||
protected static $metaImages = [];
|
||||
protected static $facebookAnalyticsType = "PageView";
|
||||
|
||||
public static function setMetaDescription($description)
|
||||
{
|
||||
|
@ -48,8 +47,7 @@ class Response
|
|||
|
||||
public static function addMetaImages(array $urls)
|
||||
{
|
||||
foreach ($urls as $url)
|
||||
{
|
||||
foreach ($urls as $url) {
|
||||
static::addMetaImage($url);
|
||||
}
|
||||
}
|
||||
|
@ -78,13 +76,10 @@ class Response
|
|||
{
|
||||
$title = '';
|
||||
preg_match_all('/<h(1|2)[^>]*>([^<]+)</', $content, $titleMatches);
|
||||
foreach ($titleMatches[1] as $matchIndex => $headerValue)
|
||||
{
|
||||
if ($headerValue == '1' || !$title)
|
||||
{
|
||||
foreach ($titleMatches[1] as $matchIndex => $headerValue) {
|
||||
if ($headerValue == '1' || !$title) {
|
||||
$title = $titleMatches[2][$matchIndex];
|
||||
if ($headerValue == '1')
|
||||
{
|
||||
if ($headerValue == '1') {
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +118,8 @@ class Response
|
|||
return static::$assets['css'];
|
||||
}
|
||||
|
||||
public static function setCssAssets(array $assets = []){
|
||||
public static function setCssAssets(array $assets = [])
|
||||
{
|
||||
static::$assets['css'] = $assets;
|
||||
}
|
||||
public static function setGzipResponseContent($gzip = true)
|
||||
|
@ -133,11 +129,9 @@ class Response
|
|||
|
||||
public static function gzipContentIfNotDisabled()
|
||||
{
|
||||
if (static::$gzipResponseContent)
|
||||
{
|
||||
if (static::$gzipResponseContent) {
|
||||
$content = static::getContent();
|
||||
if (strlen($content) > 256) // not worth it for really short content
|
||||
{
|
||||
if (strlen($content) > 256) { // not worth it for really short content
|
||||
$compressed = gzencode($content, 1);
|
||||
static::setContent($compressed);
|
||||
static::setHeader(static::HEADER_CONTENT_LENGTH, strlen($compressed));
|
||||
|
@ -164,13 +158,11 @@ class Response
|
|||
|
||||
public static function sendContent()
|
||||
{
|
||||
if (static::$contentSent)
|
||||
{
|
||||
if (static::$contentSent) {
|
||||
throw new LogicException('Content has already been sent. It cannot be sent twice');
|
||||
}
|
||||
|
||||
if (!static::$isHeadersOnly)
|
||||
{
|
||||
if (!static::$isHeadersOnly) {
|
||||
echo static::$content;
|
||||
}
|
||||
|
||||
|
@ -213,10 +205,8 @@ class Response
|
|||
{
|
||||
$cacheControl = static::getHeader(static::HEADER_CACHE_CONTROL);
|
||||
$currentHeaders = [];
|
||||
if ($cacheControl)
|
||||
{
|
||||
foreach (preg_split('/\s*,\s*/', $cacheControl) as $tmp)
|
||||
{
|
||||
if ($cacheControl) {
|
||||
foreach (preg_split('/\s*,\s*/', $cacheControl) as $tmp) {
|
||||
$tmp = explode('=', $tmp);
|
||||
$currentHeaders[$tmp[0]] = $tmp[1] ?? null;
|
||||
}
|
||||
|
@ -224,8 +214,7 @@ class Response
|
|||
$currentHeaders[strtr(strtolower($name), '_', '-')] = $value;
|
||||
|
||||
$headers = [];
|
||||
foreach ($currentHeaders as $key => $currentVal)
|
||||
{
|
||||
foreach ($currentHeaders as $key => $currentVal) {
|
||||
$headers[] = $key . ($currentVal !== null ? '=' . $currentVal : '');
|
||||
}
|
||||
|
||||
|
@ -239,10 +228,8 @@ class Response
|
|||
|
||||
public static function setHeaders($headers, $overwrite = true)
|
||||
{
|
||||
foreach ($headers as $name => $value)
|
||||
{
|
||||
if ($overwrite || !static::getHeader($name))
|
||||
{
|
||||
foreach ($headers as $name => $value) {
|
||||
if ($overwrite || !static::getHeader($name)) {
|
||||
static::setHeader($name, $value);
|
||||
}
|
||||
}
|
||||
|
@ -271,8 +258,7 @@ class Response
|
|||
'X-XSS-Protection' => '1',
|
||||
];
|
||||
|
||||
if (IS_PRODUCTION)
|
||||
{
|
||||
if (IS_PRODUCTION) {
|
||||
$defaultHeaders['Strict-Transport-Security'] = 'max-age=31536000';
|
||||
}
|
||||
|
||||
|
@ -281,33 +267,28 @@ class Response
|
|||
|
||||
public static function sendHeaders()
|
||||
{
|
||||
if (static::$headersSent)
|
||||
{
|
||||
if (static::$headersSent) {
|
||||
throw new LogicException('Headers have already been sent. They cannot be sent twice');
|
||||
}
|
||||
|
||||
if (!static::getHeader(static::HEADER_CONTENT_TYPE))
|
||||
{
|
||||
if (!static::getHeader(static::HEADER_CONTENT_TYPE)) {
|
||||
static::setHeader(static::HEADER_CONTENT_TYPE, 'text/html');
|
||||
}
|
||||
|
||||
$headers = static::getHeaders();
|
||||
|
||||
if (isset($headers[static::HEADER_STATUS]))
|
||||
{
|
||||
if (isset($headers[static::HEADER_STATUS])) {
|
||||
$status = 'HTTP/1.0 ' . $headers[static::HEADER_STATUS] . ' ' . static::getStatusTextForCode($headers[static::HEADER_STATUS]);
|
||||
header($status);
|
||||
|
||||
if (substr(php_sapi_name(), 0, 3) == 'cgi')
|
||||
{
|
||||
if (substr(php_sapi_name(), 0, 3) == 'cgi') {
|
||||
// fastcgi servers cannot send this status information because it was sent by them already due to the HTT/1.0 line
|
||||
// so we can safely unset them. see ticket #3191
|
||||
unset($headers[static::HEADER_STATUS]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($headers as $name => $value)
|
||||
{
|
||||
foreach ($headers as $name => $value) {
|
||||
header($name . ': ' . $value);
|
||||
}
|
||||
|
||||
|
@ -367,11 +348,13 @@ class Response
|
|||
return $statusTexts[$code] ?? null;
|
||||
}
|
||||
|
||||
public static function setFacebookPixelAnalyticsType($type){
|
||||
public static function setFacebookPixelAnalyticsType($type)
|
||||
{
|
||||
static::$facebookAnalyticsType = $type;
|
||||
}
|
||||
|
||||
public static function getFacebookPixelAnalyticsType(){
|
||||
public static function getFacebookPixelAnalyticsType()
|
||||
{
|
||||
return static::$facebookAnalyticsType;
|
||||
}
|
||||
|
||||
|
@ -379,13 +362,15 @@ class Response
|
|||
{
|
||||
return preg_replace_callback(
|
||||
'/\-(.)/',
|
||||
function ($matches) { return '-' . strtoupper($matches[1]); },
|
||||
function ($matches) {
|
||||
return '-' . strtoupper($matches[1]);
|
||||
},
|
||||
strtr(ucfirst(strtolower($name)), '_', '-')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// public static function addBodyCssClass($classOrClasses)
|
||||
// public static function addBodyCssClass($classOrClasses)
|
||||
// {
|
||||
// static::$bodyCssClasses = array_unique(array_merge(static::$bodyCssClasses, (array)$classOrClasses));
|
||||
// }
|
||||
|
|
|
@ -21,13 +21,11 @@ class View
|
|||
|
||||
public static function render($template, array $vars = []): string
|
||||
{
|
||||
if (static::isMarkdown($template))
|
||||
{
|
||||
if (static::isMarkdown($template)) {
|
||||
return static::markdownToHtml(static::getFullPath($template));
|
||||
}
|
||||
|
||||
if (!static::exists($template) || substr_count($template, '/') !== 1)
|
||||
{
|
||||
if (!static::exists($template) || substr_count($template, '/') !== 1) {
|
||||
throw new InvalidArgumentException(sprintf('The template "%s" does not exist or is unreadable.', $template));
|
||||
}
|
||||
|
||||
|
@ -37,13 +35,11 @@ class View
|
|||
$actionClass = ucfirst($module) . 'Actions';
|
||||
$method = 'prepare' . ucfirst(ltrim($view, '_')) . ($isPartial ? 'Partial' : '');
|
||||
|
||||
if (method_exists($actionClass, $method))
|
||||
{
|
||||
if (method_exists($actionClass, $method)) {
|
||||
$vars = $actionClass::$method($vars);
|
||||
}
|
||||
|
||||
if ($vars === null)
|
||||
{
|
||||
if ($vars === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -65,13 +61,10 @@ class View
|
|||
ob_start();
|
||||
ob_implicit_flush(0);
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
require(static::getFullPath($___template));
|
||||
return ob_get_clean();
|
||||
}
|
||||
catch (Throwable $e)
|
||||
{
|
||||
} catch (Throwable $e) {
|
||||
// need to end output buffering before throwing the exception
|
||||
ob_end_clean();
|
||||
throw $e;
|
||||
|
@ -95,13 +88,11 @@ class View
|
|||
|
||||
protected static function getFullPath($template): string
|
||||
{
|
||||
if ($template && $template[0] == '/')
|
||||
{
|
||||
if ($template && $template[0] == '/') {
|
||||
return $template;
|
||||
}
|
||||
|
||||
if (static::isMarkdown($template))
|
||||
{
|
||||
if (static::isMarkdown($template)) {
|
||||
return ContentActions::CONTENT_DIR . '/' . $template;
|
||||
}
|
||||
|
||||
|
@ -129,12 +120,9 @@ class View
|
|||
$scssCompiler->setImportPaths([self::SCSS_DIR]);
|
||||
|
||||
$compress = true;
|
||||
if ($compress)
|
||||
{
|
||||
if ($compress) {
|
||||
$scssCompiler->setFormatter('Leafo\ScssPhp\Formatter\Crunched');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$scssCompiler->setFormatter('Leafo\ScssPhp\Formatter\Expanded');
|
||||
$scssCompiler->setLineNumberStyle(Leafo\ScssPhp\Compiler::LINE_COMMENTS);
|
||||
}
|
||||
|
@ -148,10 +136,8 @@ class View
|
|||
|
||||
public static function gzipAssets()
|
||||
{
|
||||
foreach ([self::CSS_DIR => 'css', self::JS_DIR => 'js'] as $dir => $ext)
|
||||
{
|
||||
foreach (glob("$dir/*.$ext") as $file)
|
||||
{
|
||||
foreach ([self::CSS_DIR => 'css', self::JS_DIR => 'js'] as $dir => $ext) {
|
||||
foreach (glob("$dir/*.$ext") as $file) {
|
||||
Gzip::compressFile($file);
|
||||
}
|
||||
}
|
||||
|
@ -159,8 +145,7 @@ class View
|
|||
|
||||
protected static function interpolateTokens($html): string
|
||||
{
|
||||
return preg_replace_callback('/{{[\w\.]+}}/is', function ($m)
|
||||
{
|
||||
return preg_replace_callback('/{{[\w\.]+}}/is', function ($m) {
|
||||
return i18n::translate(trim($m[0], '}{'));
|
||||
}, $html);
|
||||
}
|
||||
|
@ -172,8 +157,7 @@ class View
|
|||
|
||||
protected static function attributesToHtml($attributes): string
|
||||
{
|
||||
return implode('', array_map(function ($k, $v)
|
||||
{
|
||||
return implode('', array_map(function ($k, $v) {
|
||||
return $v === true ? " $k" : ($v === false || $v === null || ($v === '' && $k != 'value') ? '' : sprintf(' %s="%s"', $k, static::escapeOnce($v)));
|
||||
}, array_keys($attributes), array_values($attributes)));
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ $email = Request::encodeStringFromUser($_POST['new_email']);
|
|||
$sync_consent = isset($_POST['sync_consent']);
|
||||
|
||||
|
||||
if(!preg_match("/@[A-Za-z0-9_-]+$/", $channel_name)){
|
||||
if (!preg_match("/@[A-Za-z0-9_-]+$/", $channel_name)) {
|
||||
$channel_name = "@" . $channel_name;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
endif;?>
|
||||
<div class="block">
|
||||
<label for="channel-name">LBRY Channel ID</label>
|
||||
<input type="text" id="channel-name" name="new_preferred_channel" placeholder="@YourPreferredChannelName" value="<?php echo $statusData['lbry_channel_name'];?>" <?php if($statusData['status'] == 'syncing' || $statusData['status'] == 'synced'): echo "disabled"; endif; ?> >
|
||||
<input type="text" id="channel-name" name="new_preferred_channel" placeholder="@YourPreferredChannelName" value="<?php echo $statusData['lbry_channel_name'];?>" <?php if ($statusData['status'] == 'syncing' || $statusData['status'] == 'synced'): echo "disabled"; endif; ?> >
|
||||
<div hidden id="channel-name-error" class="error">Channel is invalid or blank</div>
|
||||
</div>
|
||||
<div class="block">
|
||||
|
@ -114,7 +114,7 @@
|
|||
<div hidden id="email-google-plus-error" class="error">Are you sure you want to use this email</div>
|
||||
</div>
|
||||
<label for="sync-consent" class="block full">
|
||||
<input name="sync_consent" id="sync-consent" type="checkbox" <?php if($statusData['status'] == 'queued'): echo "checked"; endif;?> <?php if($statusData['status'] == 'syncing' || $statusData['status'] == 'synced'): echo "disabled "; echo "checked"; endif; ?>>I want to sync my content to the LBRY network and agree to <a href="/faq/youtube-terms">these terms</a>.
|
||||
<input name="sync_consent" id="sync-consent" type="checkbox" <?php if ($statusData['status'] == 'queued'): echo "checked"; endif;?> <?php if ($statusData['status'] == 'syncing' || $statusData['status'] == 'synced'): echo "disabled "; echo "checked"; endif; ?>>I want to sync my content to the LBRY network and agree to <a href="/faq/youtube-terms">these terms</a>.
|
||||
<div hidden id="sync-consent-error" class="error">In order to continue, you must agree to sync.</div>
|
||||
</label>
|
||||
<div class="block">
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
$desired_lbry_channel_name = Request::encodeStringFromUser($_POST['desired_lbry_channel_name']);
|
||||
|
||||
if(!preg_match("/@[A-Za-z0-9_-]+$/", $desired_lbry_channel_name)){
|
||||
if (!preg_match("/@[A-Za-z0-9_-]+$/", $desired_lbry_channel_name)) {
|
||||
$desired_lbry_channel_name = "@" . $desired_lbry_channel_name;
|
||||
}
|
||||
|
||||
AcquisitionActions::actionYoutubeToken($desired_lbry_channel_name);
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<div class="form-row align-left">
|
||||
<label>Status</label>
|
||||
<select name="status">
|
||||
<?php foreach($statuses as $statusVal => $statusLabel): ?>
|
||||
<?php foreach ($statuses as $statusVal => $statusLabel): ?>
|
||||
<option value="<?php echo $statusVal ?>" <?php echo $selectedStatus == $statusVal ? 'selected="selected"' : '' ?>><?php echo $statusLabel ?></option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
|
@ -41,12 +41,12 @@
|
|||
<?php if (count($bounties)): ?>
|
||||
<div class="row-fluid">
|
||||
<?php $index = 0 ?>
|
||||
<?php foreach($bounties as $post): ?>
|
||||
<?php foreach ($bounties as $post): ?>
|
||||
<?php $metadata = $post->getMetadata() ?>
|
||||
<div class="span4">
|
||||
<a class="bounty-tile" href="<?php echo $post->getRelativeUrl() ?>">
|
||||
<div class="text-center spacer-half"><span class="icon-mega
|
||||
<?php switch($metadata['category']) {
|
||||
<?php switch ($metadata['category']) {
|
||||
case 'android': echo 'icon-android'; break;
|
||||
case 'osx':
|
||||
case 'ios':
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<?php if (isset($email)): ?>
|
||||
<a href="mailto:<?php echo $email ?>" class="link-primary"><span class="icon icon-envelope"></span></a>
|
||||
<?php endif ?>
|
||||
<?php if (isset ($github)): ?>
|
||||
<?php if (isset($github)): ?>
|
||||
<a href="https://github.com/<?php echo $github ?>" class="link-primary"><span class="icon icon-github"></span></a>
|
||||
<?php endif ?>
|
||||
<?php if (isset($twitter)): ?>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div>
|
||||
<?php foreach($jobs as $job): ?>
|
||||
<?php foreach ($jobs as $job): ?>
|
||||
<?php echo View::render('content/_job', [
|
||||
'metadata' => $job[0],
|
||||
'jobHtml' => $job[1]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div>
|
||||
<h3>Latest News</h3>
|
||||
<ul class="no-style">
|
||||
<?php foreach($posts as $post): ?>
|
||||
<?php foreach ($posts as $post): ?>
|
||||
<li><a href="<?php echo $post->getRelativeUrl() ?>"><?php echo $post->getTitle() ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<a href="http://www.tumblr.com/share?v=3&u=<?php echo $url ?>&t=<?php echo $title ?>&s=" target="_blank" title="Post to Tumblr">
|
||||
<span class="icon-fw icon-tumblr"></span>
|
||||
</a>
|
||||
<a href="mailto:?subject=<?php echo urlencode('LBRY: ') . $title ?>&body=<?php echo $url . urlencode("\n\n" . $post->getContentText(50,true)) ?>"
|
||||
<a href="mailto:?subject=<?php echo urlencode('LBRY: ') . $title ?>&body=<?php echo $url . urlencode("\n\n" . $post->getContentText(50, true)) ?>"
|
||||
title="Email a Friend">
|
||||
<span class="icon-fw icon-envelope"></span>
|
||||
</a>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
|
||||
<?php foreach($posts as $post): ?>
|
||||
<?php foreach ($posts as $post): ?>
|
||||
<tr>
|
||||
<td><?php echo strtoupper($post->getSlug()) ?></td>
|
||||
<td><a href="<?php echo $post->getRelativeUrl() ?>" class="link-primary">Report</a></td>
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
$('#faq-filter-form').change(function() { $(this).submit(); });
|
||||
<?php js_end() ?>
|
||||
|
||||
<?php foreach($postGroups as $category => $posts): ?>
|
||||
<?php foreach ($postGroups as $category => $posts): ?>
|
||||
<?php if (count($posts)): ?>
|
||||
<h2><?php echo $categories[$category] ?></h2>
|
||||
<?php foreach($posts as $post): ?>
|
||||
<?php foreach ($posts as $post): ?>
|
||||
<div class="spacer1">
|
||||
<a href="<?php echo $post->getRelativeUrl() ?>" class="link-primary"><?php echo $post->getTitle() ?></a>
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<section class="content content-readable spacer2">
|
||||
<?php foreach($posts as $post): ?>
|
||||
<?php foreach ($posts as $post): ?>
|
||||
<div class="spacer1">
|
||||
<h3><a href="<?php echo $post->getRelativeUrl() ?>" class="link-primary"><?php echo $post->getTitle() ?></a></h3>
|
||||
<div class="meta clearfix" title="<?php echo $post->getDate()->format('F jS, Y') ?>">
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
</div>
|
||||
<div style="max-width: 800px; margin: 0 auto">
|
||||
<div class="roadmap-container" id="project-roadmap">
|
||||
<?php foreach($items as $group => $groupItems): ?>
|
||||
<?php foreach ($items as $group => $groupItems): ?>
|
||||
<?php $firstItem = reset($groupItems) ?>
|
||||
<?php $isOpen = !isset($firstItem['project']) || !isset($firstItem['sort_key']) || $firstItem['sort_key'] === $projectMaxVersions[$firstItem['project']] ?>
|
||||
<h2 class="roadmap-group-title" <?php echo !$isOpen ? 'style="display: none"' : '' ?>">
|
||||
|
@ -40,7 +40,7 @@
|
|||
<?php if (count($groupItems) > $maxItems): ?>
|
||||
<div class="text-center spacer1"><a href="javascript:;" class="link-primary show-all-roadmap-group-items">Show All Items for <?php echo $group ?></a></div>
|
||||
<?php endif ?>
|
||||
<?php foreach($groupItems as $item): ?>
|
||||
<?php foreach ($groupItems as $item): ?>
|
||||
<?php ++$index ?>
|
||||
<div class="roadmap-item" <?php echo $index != 1 && isset($firstItem['sort_key']) ? 'style="display: none"' : '' ?>>
|
||||
<?php if (isset($item['badge']) || isset($item['assignee'])): ?>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<span class="roadmap-item-assignee"><?php echo $item['assignee'] ?></span>
|
||||
<?php endif ?>
|
||||
<?php if (isset($item['badge'])): ?>
|
||||
<?php switch($item['badge']): case "Complete": ?>
|
||||
<?php switch ($item['badge']): case "Complete": ?>
|
||||
<span class=" badge badge-primary"><?php echo $item['badge'] ?></span><br/>
|
||||
<?php break; case "In Progress":?>
|
||||
<span class="badge badge-info"><?php echo $item['badge']?></span><br/>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<description>{{rss.description}}</description>
|
||||
<generator>https://github.com/lbryio/lbry.io</generator>
|
||||
<language>{{rss.lang}}</language>
|
||||
<?php //<lastBuildDate>Sat, 07 Sep 2002 09:42:31 GMT</lastBuildDate> ?>
|
||||
<?php //<lastBuildDate>Sat, 07 Sep 2002 09:42:31 GMT</lastBuildDate>?>
|
||||
<atom:link href="<?php echo Request::getHostAndProto() . ContentActions::URL_NEWS . '/' . ContentActions::SLUG_RSS ?>" rel="self" type="application/rss+xml" />
|
||||
<?php foreach ($posts as $post): ?>
|
||||
<item>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div class="meta"><a href="/quickstart" class="link-primary">Quickstart Home</a></div>
|
||||
<h1>Quickstart</h1>
|
||||
</div>
|
||||
<?php foreach(array_filter(array_keys($stepLabels)) as $step): ?>
|
||||
<?php foreach (array_filter(array_keys($stepLabels)) as $step): ?>
|
||||
<section>
|
||||
<div class="content content-dark">
|
||||
<?php echo View::render('developer/_quickstart' . ucfirst($step)) ?>
|
||||
|
@ -24,7 +24,7 @@
|
|||
</div>
|
||||
<ol class="quickstart__progress-bar">
|
||||
<?php $stepCounter = 0 ?>
|
||||
<?php foreach($stepLabels as $step => $stepLabel): ?>
|
||||
<?php foreach ($stepLabels as $step => $stepLabel): ?>
|
||||
<li class="<?php echo $currentStep == $step ? 'active' : '' ?> <?php echo ++$stepCounter <= $stepNum ? 'completed' : '' ?>">
|
||||
<a href="/quickstart<?php echo $step ? '/' . $step : '' ?>"><?php echo $stepLabel ?></a>
|
||||
</li>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<?php $buckets = array_fill(0, 3, []) ?>
|
||||
<?php $columns = 2 ?>
|
||||
<?php $index = 0 ?>
|
||||
<?php foreach($osChoices as $osChoice): ?>
|
||||
<?php foreach ($osChoices as $osChoice): ?>
|
||||
<?php ob_start() ?>
|
||||
<?php list($url, $title, $icon) = $osChoice ?>
|
||||
<h4>
|
||||
|
@ -14,7 +14,7 @@
|
|||
</h4>
|
||||
<?php $buckets[floor($index++ / $columns)][] = ob_get_clean() ?>
|
||||
<?php endforeach ?>
|
||||
<?php foreach(array_filter($buckets) as $bucketRow): ?>
|
||||
<?php foreach (array_filter($buckets) as $bucketRow): ?>
|
||||
<div class="row-fluid-always">
|
||||
<div class="span6"><?php echo implode('</div><div class="span6">', $bucketRow) ?></div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<select name="<?php echo $name ?>">
|
||||
<?php foreach($choices as $value => $label): ?>
|
||||
<?php foreach ($choices as $value => $label): ?>
|
||||
<option value="<?php echo $value ?>" <?php echo $selected == $value ? 'selected="selected"' : '' ?>>
|
||||
<?php echo $label ?>
|
||||
</option>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo json_encode($json ?? [], JSON_PRETTY_PRINT) ?>
|
||||
<?php echo json_encode($json ?? [], JSON_PRETTY_PRINT);
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo file_get_contents($zipPath) ?>
|
||||
<?php echo file_get_contents($zipPath);
|
||||
|
|
|
@ -6,7 +6,7 @@ h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
|
|||
})(window,document.documentElement,'async-hide','dataLayer',4000,
|
||||
{'GTM-NT8579P':true});</script>
|
||||
<script>
|
||||
<?php //google analytics ?>
|
||||
<?php //google analytics?>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<title><?php echo $title ?></title>
|
||||
|
||||
<link href='https://fonts.googleapis.com/css?family=Raleway:500,500italic,700' rel='stylesheet' type='text/css'>
|
||||
<?php foreach(Response::getCssAssets() as $src): ?>
|
||||
<?php foreach (Response::getCssAssets() as $src): ?>
|
||||
<link rel="stylesheet" type="text/css" href="<?php echo $src?>">
|
||||
<?php endforeach ?>
|
||||
<link rel="apple-touch-icon" sizes="60x60" href="/img/fav/apple-touch-icon-60x60.png">
|
||||
|
@ -27,7 +27,7 @@
|
|||
<link rel="icon" type="image/png" href="/img/fav/android-chrome-192x192.png" sizes="192x192">
|
||||
<link rel="icon" type="image/png" href="/img/fav/favicon-16x16.png" sizes="16x16">
|
||||
<link rel="manifest" href="/img/fav/manifest.json">
|
||||
<?php if(isset($showRssLink) && $showRssLink): ?>
|
||||
<?php if (isset($showRssLink) && $showRssLink): ?>
|
||||
<link rel="alternate" type="application/rss+xml" title="LBRY News" href="<?php echo ContentActions::URL_NEWS . '/' . ContentActions::SLUG_RSS ?>" />
|
||||
<?php endif ?>
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
<meta property="og:type" content="article" />
|
||||
<meta property="og:description" content="<?php echo Response::getMetaDescription() ?>"/>
|
||||
<meta property="og:site_name" content="LBRY" />
|
||||
<?php foreach(Response::getMetaImages() as $image): ?>
|
||||
<?php foreach (Response::getMetaImages() as $image): ?>
|
||||
<meta property="og:image" content="<?php echo $image ?>" />
|
||||
<?php endforeach ?>
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
|||
<script id="facebook-jssdk" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=1477813539180850"></script>
|
||||
<script id="twitter-oct" src="https://platform.twitter.com/oct.js"></script>
|
||||
<script id="twitter-wjs" src="https://platform.twitter.com/widgets.js"></script>
|
||||
<?php foreach(Response::getJsAssets() as $src): ?>
|
||||
<?php foreach (Response::getJsAssets() as $src): ?>
|
||||
<script src="<?php echo $src ?>"></script>
|
||||
<?php endforeach ?>
|
||||
<?php echo View::render('layout/_analytics') ?>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php foreach([
|
||||
<?php foreach ([
|
||||
'/get' => __('nav.get'),
|
||||
'/learn' => __('nav.learn'),
|
||||
'/news' => __("News")
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
<h3 id="images">{{press.logos}}</h3>
|
||||
<div class="column-fluid">
|
||||
<?php foreach(glob(ROOT_DIR . '/web/img/press/*') as $imgPath): ?>
|
||||
<?php foreach (glob(ROOT_DIR . '/web/img/press/*') as $imgPath): ?>
|
||||
<div class="span6">
|
||||
<div style="margin: 10px">
|
||||
<?php $imgUrl = str_replace(ROOT_DIR . '/web', '', $imgPath) ?>
|
||||
|
@ -32,7 +32,7 @@
|
|||
</div>
|
||||
|
||||
<h3>{{press.team}}</h3>
|
||||
<?php foreach(['jeremy-kauffman', 'josh-finer', 'alex-grintsvayg', 'jack-robison'] as $person): ?>
|
||||
<?php foreach (['jeremy-kauffman', 'josh-finer', 'alex-grintsvayg', 'jack-robison'] as $person): ?>
|
||||
<?php list($metadata, $bioHtml) = View::parseMarkdown('bio/' . $person . '.md') ?>
|
||||
<section class="row-fluid">
|
||||
<div class="span3">
|
||||
|
@ -59,7 +59,7 @@
|
|||
</section>
|
||||
<?php endforeach ?>
|
||||
<h3>{{press.advisory}}</h3>
|
||||
<?php foreach(['alex-tabarrok', 'ray-carballada', 'stephan-kinsella', 'michael-huemer'] as $person): ?>
|
||||
<?php foreach (['alex-tabarrok', 'ray-carballada', 'stephan-kinsella', 'michael-huemer'] as $person): ?>
|
||||
<?php list($metadata, $bioHtml) = View::parseMarkdown('bio/' . $person . '.md') ?>
|
||||
<section class="row-fluid">
|
||||
<div class="span3">
|
||||
|
|
|
@ -17,20 +17,20 @@
|
|||
<a href="/join-us" class="link-primary">See our hiring page</a>.
|
||||
</div>
|
||||
<h2>Leadership</h2>
|
||||
<?php foreach(['jeremy-kauffman', 'alex-grintsvayg'] as $bioSlug): ?>
|
||||
<?php foreach (['jeremy-kauffman', 'alex-grintsvayg'] as $bioSlug): ?>
|
||||
<div class="spacer2">
|
||||
<?php echo View::render('content/_bio', ['person' => $bioSlug]) ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
<h2>Technical</h2>
|
||||
<?php foreach([ 'kay-kurokawa', 'jack-robison', 'lex-berezhny',
|
||||
<?php foreach ([ 'kay-kurokawa', 'jack-robison', 'lex-berezhny',
|
||||
'akinwale-ariwodola', 'sean-yesmunt', 'liam-cardenas', 'bill-bittner', 'amit-tulshyan', 'igor-gassmann'] as $bioSlug): ?>
|
||||
<div class="spacer2">
|
||||
<?php echo View::render('content/_bio', ['person' => $bioSlug]) ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
<h2>Business</h2>
|
||||
<?php foreach(['josh-finer',
|
||||
<?php foreach (['josh-finer',
|
||||
'natalie-mitchell',
|
||||
'reilly-smith',
|
||||
'tom-zarebczan',
|
||||
|
@ -41,7 +41,7 @@
|
|||
</div>
|
||||
<?php endforeach ?>
|
||||
<h2>{{page.team.advisory}}</h2>
|
||||
<?php foreach(['alex-tabarrok', 'ray-carballada', 'stephan-kinsella', 'michael-huemer'] as $bioSlug): ?>
|
||||
<?php foreach (['alex-tabarrok', 'ray-carballada', 'stephan-kinsella', 'michael-huemer'] as $bioSlug): ?>
|
||||
<div class="spacer2">
|
||||
<?php echo View::render('content/_bio', ['person' => $bioSlug]) ?>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
# Enable PHP dev cli-server
|
||||
if (php_sapi_name() === 'cli-server' && is_file(__DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI'])))
|
||||
{
|
||||
if (php_sapi_name() === 'cli-server' && is_file(__DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,28 +14,22 @@ error_reporting(IS_PRODUCTION ? 0 : (E_ALL | E_STRICT));
|
|||
|
||||
register_shutdown_function('Controller::shutdown');
|
||||
|
||||
if (!IS_PRODUCTION)
|
||||
{
|
||||
if (!IS_PRODUCTION) {
|
||||
// make warnings into errors
|
||||
set_error_handler(function ($errno, $errstr, $errfile, $errline ) {
|
||||
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
||||
throw new ErrorException($errstr, $errno, 0, $errfile, $errline);
|
||||
}, E_WARNING|E_CORE_WARNING|E_COMPILE_WARNING|E_USER_WARNING);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
Session::init();
|
||||
i18n::register();
|
||||
if (!IS_PRODUCTION)
|
||||
{
|
||||
if (!IS_PRODUCTION) {
|
||||
View::compileCss();
|
||||
}
|
||||
Controller::dispatch(Request::getRoutingUri());
|
||||
}
|
||||
catch(Throwable $e)
|
||||
{
|
||||
if (IS_PRODUCTION)
|
||||
{
|
||||
} catch (Throwable $e) {
|
||||
if (IS_PRODUCTION) {
|
||||
Slack::sendErrorIfProd($e);
|
||||
throw $e;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue