Browse Source

update post filtering

main
ghost 3 years ago
parent
commit
dd69539ab2
  1. 8
      src/application/controller/api/post/get.php
  2. 20
      src/system/helper/format.php

8
src/application/controller/api/post/get.php

@ -28,14 +28,14 @@ if (isset($_SESSION['userName'])) { @@ -28,14 +28,14 @@ if (isset($_SESSION['userName'])) {
foreach ($result as $post) {
// Split message parts
$messages = [Filter::string($post['userpost']['msg'])];
$messages = [Filter::post($post['userpost']['msg'])];
for ($i = 0; $i <= APPLICATION_MAX_POST_SPLIT; $i++) {
$n = sprintf('msg%s', $i);
if (isset($post['userpost'][$n])) {
$messages[] = Filter::string($post['userpost'][$n]);
$messages[] = Filter::post($post['userpost'][$n]);
}
}
@ -44,14 +44,14 @@ if (isset($_SESSION['userName'])) { @@ -44,14 +44,14 @@ if (isset($_SESSION['userName'])) {
if (isset($post['userpost']['rt'])) {
// Split reTwists parts
$reTwists = [Filter::string($post['userpost']['rt']['msg'])];
$reTwists = [Filter::post($post['userpost']['rt']['msg'])];
for ($i = 0; $i <= APPLICATION_MAX_POST_SPLIT; $i++) {
$n = sprintf('msg%s', $i);
if (isset($post['userpost']['rt'][$n])) {
$reTwists[] = Filter::string($post['userpost']['rt'][$n]);
$reTwists[] = Filter::post($post['userpost']['rt'][$n]);
}
}

20
src/system/helper/format.php

@ -79,24 +79,4 @@ class Format { @@ -79,24 +79,4 @@ class Format {
return $string;
}
// @TODO REPLACE
public static function text(string $string) {
$string = html_entity_decode($string, ENT_QUOTES, 'UTF-8');
$string = htmlentities($string, ENT_QUOTES, 'UTF-8');
$string = preg_replace("|([\s])\*([\S]+)\*([\s]?)|i", "$1<b>$2</b>$3", $string);
$string = preg_replace("|([\s])\~([\S]+)\~([\s]?)|i", "$1<i>$2</i>$3", $string);
$string = preg_replace("|([\s])\_([\S]+)\_([\s]?)|i", "$1<u>$2</u>$3", $string);
$string = preg_replace("|([\s])\-([\S]+)\-([\s]?)|i", "$1<s>$2</s>$3", $string);
$string = preg_replace("|([\s])\`([\S]+)\`([\s]?)|i", "$1<samp>$2</samp>$3", $string);
$string = preg_replace("|@([a-zA-Z0-9_]+)|i", "<a href=\"people/$1\">@$1</a>", $string);
$string = preg_replace("|((https?://)+([\d\w\.-]+\.[\w\.]{2,6})[^\s\]\[\<\>]*/?)|i", "<a href=\"$1\" target=\"_blank\">$3</a>", $string);
$string = nl2br($string);
return $string;
}
}
Loading…
Cancel
Save