forked from leftypol/leftypol
remove mysql 5.5 support
This commit is contained in:
parent
5bd89a9437
commit
73bc23a4c7
5 changed files with 2 additions and 50 deletions
|
@ -101,12 +101,6 @@ function sql_open() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5.6.10 becomes 50610 HACK: hardcoded to be above critical value 50803 due to laziness
|
|
||||||
function mysql_version() {
|
|
||||||
// TODO delete all references of this function everywhere
|
|
||||||
return 80504;
|
|
||||||
}
|
|
||||||
|
|
||||||
function prepare($query) {
|
function prepare($query) {
|
||||||
global $pdo, $debug, $config;
|
global $pdo, $debug, $config;
|
||||||
|
|
||||||
|
|
|
@ -2082,9 +2082,6 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
$body = str_replace("\r", '', $body);
|
$body = str_replace("\r", '', $body);
|
||||||
$body = utf8tohtml($body);
|
$body = utf8tohtml($body);
|
||||||
|
|
||||||
if (mysql_version() < 50503)
|
|
||||||
$body = mb_encode_numericentity($body, array(0x010000, 0xffffff, 0, 0xffffff), 'UTF-8');
|
|
||||||
|
|
||||||
if ($config['markup_code']) {
|
if ($config['markup_code']) {
|
||||||
$code_markup = array();
|
$code_markup = array();
|
||||||
$body = preg_replace_callback($config['markup_code'], function($matches) use (&$code_markup) {
|
$body = preg_replace_callback($config['markup_code'], function($matches) use (&$code_markup) {
|
||||||
|
|
|
@ -520,9 +520,6 @@ function mod_new_board() {
|
||||||
|
|
||||||
$query = Element('posts.sql', array('board' => $board['uri']));
|
$query = Element('posts.sql', array('board' => $board['uri']));
|
||||||
|
|
||||||
if (mysql_version() < 50503)
|
|
||||||
$query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
|
|
||||||
|
|
||||||
query($query) or error(db_error());
|
query($query) or error(db_error());
|
||||||
|
|
||||||
if ($config['cache']['enabled'])
|
if ($config['cache']['enabled'])
|
||||||
|
|
|
@ -52,11 +52,7 @@ if (file_exists($config['has_installed'])) {
|
||||||
|
|
||||||
function __query($sql) {
|
function __query($sql) {
|
||||||
sql_open();
|
sql_open();
|
||||||
|
|
||||||
if (mysql_version() >= 50503)
|
|
||||||
return query($sql);
|
return query($sql);
|
||||||
else
|
|
||||||
return query(str_replace('utf8mb4', 'utf8', $sql));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$boards = listBoards();
|
$boards = listBoards();
|
||||||
|
@ -939,7 +935,6 @@ if ($step == 0) {
|
||||||
$sql = @file_get_contents('install.sql') or error("Couldn't load install.sql.");
|
$sql = @file_get_contents('install.sql') or error("Couldn't load install.sql.");
|
||||||
|
|
||||||
sql_open();
|
sql_open();
|
||||||
$mysql_version = mysql_version();
|
|
||||||
|
|
||||||
// This code is probably horrible, but what I'm trying
|
// This code is probably horrible, but what I'm trying
|
||||||
// to do is find all of the SQL queires and put them
|
// to do is find all of the SQL queires and put them
|
||||||
|
@ -952,8 +947,6 @@ if ($step == 0) {
|
||||||
$sql_errors = '';
|
$sql_errors = '';
|
||||||
$sql_err_count = 0;
|
$sql_err_count = 0;
|
||||||
foreach ($queries as $query) {
|
foreach ($queries as $query) {
|
||||||
if ($mysql_version < 50503)
|
|
||||||
$query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
|
|
||||||
$query = preg_replace('/^([\w\s]*)`([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)`/u', '$1``$2``', $query);
|
$query = preg_replace('/^([\w\s]*)`([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)`/u', '$1``$2``', $query);
|
||||||
if (!query($query)) {
|
if (!query($query)) {
|
||||||
$sql_err_count++;
|
$sql_err_count++;
|
||||||
|
|
31
post.php
31
post.php
|
@ -35,35 +35,6 @@ function md5_hash_of_file($config, $file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Strip the markup from the given string
|
|
||||||
*
|
|
||||||
* @param string $post_body The body of the post.
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function strip_markup($post_body)
|
|
||||||
{
|
|
||||||
if (mysql_version() >= 50503) {
|
|
||||||
// Assume we're using the utf8mb4 charset.
|
|
||||||
return $post_body;
|
|
||||||
} else {
|
|
||||||
// MySQL's `utf8` charset only supports up to 3-byte symbols.
|
|
||||||
// Remove anything >= 0x010000.
|
|
||||||
|
|
||||||
$chars = preg_split('//u', $post_body, -1, PREG_SPLIT_NO_EMPTY);
|
|
||||||
$res = '';
|
|
||||||
foreach ($chars as $char) {
|
|
||||||
$o = 0;
|
|
||||||
$ord = ordutf8($char, $o);
|
|
||||||
if ($ord >= 0x010000)
|
|
||||||
continue;
|
|
||||||
$res .= $char;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the user at the remote ip passed the captcha.
|
* Checks if the user at the remote ip passed the captcha.
|
||||||
*
|
*
|
||||||
|
@ -1314,7 +1285,7 @@ function handle_post()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post['body_nomarkup'] = strip_markup($post['body']);
|
$post['body_nomarkup'] = $post['body'];
|
||||||
$post['tracked_cites'] = markup($post['body'], true);
|
$post['tracked_cites'] = markup($post['body'], true);
|
||||||
|
|
||||||
if ($post['has_file']) {
|
if ($post['has_file']) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue