mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-10-18 07:03:12 -04:00
82 lines
2.4 KiB
PHP
82 lines
2.4 KiB
PHP
<?
|
|
//TODO: make this use the cache version of the thread, save the db query
|
|
/*********************************************************************\
|
|
//--------------Get Post--------------------------------------------//
|
|
|
|
This gets the raw BBCode of a post. It's used for editing and
|
|
quoting posts.
|
|
|
|
It gets called if $_GET['action'] == 'get_post'. It requires
|
|
$_GET['post'], which is the ID of the post.
|
|
|
|
\*********************************************************************/
|
|
|
|
// Quick SQL injection check
|
|
if (!$_GET['post'] || !is_number($_GET['post'])) {
|
|
error(0);
|
|
}
|
|
|
|
// Variables for database input
|
|
$PostID = $_GET['post'];
|
|
|
|
// Mainly
|
|
$DB->query("
|
|
SELECT
|
|
p.Body,
|
|
t.ForumID
|
|
FROM forums_posts AS p
|
|
JOIN forums_topics AS t ON p.TopicID = t.ID
|
|
WHERE p.ID = '44107'");
|
|
list($Body, $ForumID) = $DB->next_record(MYSQLI_NUM);
|
|
var_dump($Body);
|
|
|
|
$DB->query("
|
|
SELECT
|
|
p.Body,
|
|
t.ForumID
|
|
FROM forums_posts AS p
|
|
JOIN forums_topics AS t ON p.TopicID = t.ID
|
|
WHERE p.ID = '44107'");
|
|
list($Body, $ForumID) = $DB->next_record(MYSQLI_NUM, false);
|
|
var_dump($Body);
|
|
var_dump(Format::make_utf8($Body));
|
|
var_dump(Format::is_utf8($Body));
|
|
$encoding = mb_detect_encoding($Body, 'UTF-8, ISO-8859-1');
|
|
var_dump($encoding);
|
|
if ($encoding != 'UTF-8') {
|
|
$Body = @mb_convert_encoding($Str, 'UTF-8', $Encoding);
|
|
var_dump("NOT UTF-8");
|
|
var_dump($Body);
|
|
}
|
|
var_dump(mb_convert_encoding($Body, 'HTML-ENTITIES', 'UTF-8'));
|
|
|
|
$Body = preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/m", '&', $Body);
|
|
var_dump($Body);
|
|
|
|
$Replace = array(
|
|
"'",'"',"<",">",
|
|
'€','‚','ƒ','„','…','†','‡','ˆ',
|
|
'‰','Š','‹','Œ','Ž','‘','’','“',
|
|
'”','•','–','—','˜','™','š','›',
|
|
'œ','ž','Ÿ'
|
|
);
|
|
|
|
$With = array(
|
|
''','"','<','>',
|
|
'€','‚','ƒ','„','…','†','‡','ˆ',
|
|
'‰','Š','‹','Œ','Ž','‘','’','“',
|
|
'”','•','–','—','˜','™','š','›',
|
|
'œ','ž','Ÿ'
|
|
);
|
|
|
|
$Body = str_replace($Replace, $With, $Body);
|
|
var_dump($Body);
|
|
|
|
// Is the user allowed to view the post?
|
|
if (!Forums::check_forumperm($ForumID)) {
|
|
error(0);
|
|
}
|
|
|
|
// This gets sent to the browser, which echoes it wherever
|
|
var_dump(trim($Body));
|
|
echo trim($Body); |