* unify accessing &_GET and &_POST data
 * properly calc and display diffTime
This commit is contained in:
Sarjuuk
2022-03-17 10:14:58 +01:00
parent 3cb02f2204
commit a8edf6c912
6 changed files with 74 additions and 38 deletions

View File

@@ -37,7 +37,7 @@ class AccountPage extends GenericPage
'password' => ['filter' => FILTER_UNSAFE_RAW],
'c_password' => ['filter' => FILTER_UNSAFE_RAW],
'token' => ['filter' => FILTER_UNSAFE_RAW],
'remember_me' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::rememberCallback'],
'remember_me' => ['filter' => FILTER_CALLBACK, 'options' => 'AccountPage::rememberCallback'],
'email' => ['filter' => FILTER_SANITIZE_EMAIL]
);
@@ -59,7 +59,7 @@ class AccountPage extends GenericPage
}
}
protected function rememberCallback($val)
protected static function rememberCallback($val)
{
return $val == 'yes' ? $val : null;
}

View File

@@ -28,8 +28,8 @@ class ScreenshotPage extends GenericPage
protected $imgHash = '';
protected $_post = array(
'coords' => ['filter' => FILTER_CALLBACK, 'options' => 'AjaxHandler::checkIdListUnsigned'],
'screenshotalt' => ['filter' => FILTER_UNSAFE_RAW]
'coords' => ['filter' => FILTER_CALLBACK, 'options' => 'GenericPage::checkIdListUnsigned'],
'screenshotalt' => ['filter' => FILTER_UNSAFE_RAW, 'flags' => FILTER_FLAG_STRIP_AOWOW]
);
public function __construct($pageCall, $pageParam)

View File

@@ -75,7 +75,7 @@ class UtilityPage extends GenericPage
header('Location: ?'.Util::$typeStrings[$type].'='.$typeId, true, 302);
die();
case 'latest-comments': // rss
$data = CommunityContent::getCommentPreviews();
$data = CommunityContent::getCommentPreviews(dateFmt: false);
if ($this->rss)
{
@@ -85,19 +85,19 @@ class UtilityPage extends GenericPage
$this->feedData[] = array(
'title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])).Lang::main('colon').htmlentities($d['subject'])],
'link' => [false, [], HOST_URL.'/?go-to-comment&id='.$d['id']],
'description' => [true, [], htmlentities($d['preview'])."<br /><br />".sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true))],
'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])],
'description' => [true, [], htmlentities($d['preview'])."<br /><br />".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true)],
'pubDate' => [false, [], date(DATE_RSS, $d['date'])],
'guid' => [false, [], HOST_URL.'/?go-to-comment&amp;id='.$d['id']]
// 'domain' => [false, [], null]
);
}
}
else
$this->lvTabs[] = ['commentpreview', ['data' => $data]];
$this->lvTabs[] = ['commentpreview', ['data' => array_values($data)]];
break;
case 'latest-screenshots': // rss
$data = CommunityContent::getScreenshots();
$data = CommunityContent::getScreenshots(dateFmt: false);
if ($this->rss)
{
@@ -106,14 +106,14 @@ class UtilityPage extends GenericPage
$desc = '<a href="'.HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#screenshots:id='.$d['id'].'"><img src="'.STATIC_URL.'/uploads/screenshots/thumb/'.$d['id'].'.jpg" alt="" /></a>';
if ($d['caption'])
$desc .= '<br />'.$d['caption'];
$desc .= "<br /><br />".sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true));
$desc .= "<br /><br />".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true);
// enclosure/length => filesize('static/uploads/screenshots/thumb/'.$d['id'].'.jpg') .. always set to this placeholder value though
$this->feedData[] = array(
'title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])).Lang::main('colon').htmlentities($d['subject'])],
'link' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#screenshots:id='.$d['id']],
'description' => [true, [], $desc],
'pubDate' => [false, [], date(DATE_RSS, time() - $d['elapsed'])],
'pubDate' => [false, [], date(DATE_RSS, $d['date'])],
'enclosure' => [false, ['url' => STATIC_URL.'/uploads/screenshots/thumb/'.$d['id'].'.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null],
'guid' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#screenshots:id='.$d['id']],
// 'domain' => [false, [], live|ptr]
@@ -121,11 +121,11 @@ class UtilityPage extends GenericPage
}
}
else
$this->lvTabs[] = ['screenshot', ['data' => $data]];
$this->lvTabs[] = ['screenshot', ['data' => array_values($data)]];
break;
case 'latest-videos': // rss
$data = CommunityContent::getVideos();
$data = CommunityContent::getVideos(dateFmt: false);
if ($this->rss)
{
@@ -134,14 +134,14 @@ class UtilityPage extends GenericPage
$desc = '<a href="'.HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#videos:id='.$d['id'].'"><img src="//i3.ytimg.com/vi/'.$d['videoId'].'/default.jpg" alt="" /></a>';
if ($d['caption'])
$desc .= '<br />'.$d['caption'];
$desc .= "<br /><br />".sprintf(Lang::main('byUserTimeAgo'), $d['user'], Util::formatTime($d['elapsed'] * 1000, true));
$desc .= "<br /><br />".Lang::main('byUser', [$d['user'], '']) . Util::formatTimeDiff($d['date'], true);
// is enclosure/length .. is this even relevant..?
$this->feedData[] = array(
'title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])).Lang::main('colon').htmlentities($row['subject'])],
'title' => [true, [], Util::ucFirst(Lang::game(Util::$typeStrings[$d['type']])).Lang::main('colon').htmlentities($d['subject'])],
'link' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#videos:id='.$d['id']],
'description' => [true, [], $desc],
'pubDate' => [false, [], date(DATE_RSS, time() - $row['elapsed'])],
'pubDate' => [false, [], date(DATE_RSS, $d['date'])],
'enclosure' => [false, ['url' => '//i3.ytimg.com/vi/'.$d['videoId'].'/default.jpg', 'length' => 12345, 'type' => 'image/jpeg'], null],
'guid' => [false, [], HOST_URL.'/?'.Util::$typeStrings[$d['type']].'='.$d['typeId'].'#videos:id='.$d['id']],
// 'domain' => [false, [], live|ptr]
@@ -149,7 +149,7 @@ class UtilityPage extends GenericPage
}
}
else
$this->lvTabs[] = ['video', ['data' => $data]];
$this->lvTabs[] = ['video', ['data' => array_values($data)]];
break;
case 'latest-articles': // rss