Update log and admin to work with PHP v 7.2

Mostly changing mysql_ to mysqli_ but also some OOP fixes it classes,
especially the bbcode parser which doesn't have a new version working
with PHP 7.
This commit is contained in:
Jeena 2020-04-05 17:42:46 +02:00
parent 7af86452ff
commit 23c3d3b65b
7 changed files with 22 additions and 22 deletions

View file

@ -179,7 +179,8 @@ global $l, $plugins;
'".$form_input['allowpingback']."' );";
$writeblog = new Query($sql);
$id = mysql_insert_id();
global $mysql;
$id = mysqli_insert_id($mysql);
if($writeblog->error()) {
echo "<pre>\n";
echo $writeblog->getError();

View file

@ -149,7 +149,8 @@ elseif(isset($com_form['form_submitted']) AND $com_form['form_submitted'] == $l[
)";
$newcomment = new Query($sql);
$cid = mysql_insert_id();
global $mysql;
$cid = mysqli_insert_id($mysql);
if($newcomment->error()) {
if($newcomment->getErrno() == 1062) {
$errors[] = $l['comments_duplicate'];

View file

@ -88,10 +88,11 @@ function strip($_data) {
}
// escape input for mysql
function escape_for_mysql($_data) {
global $mysql;
if (is_array($_data))
foreach($_data as $key => $val) $_data[$key] = escape_for_mysql($val);
else
$_data = mysql_real_escape_string($_data);
$_data = mysqli_real_escape_string($mysql, $_data);
// uses last opened MySQL link implicitly
// assumption is valid because this function is never called
// before mysql_connect

View file

@ -63,7 +63,7 @@ class Jlog_Mail
* Jlog_Mail() - constructor
*
*/
function Jlog_Mail()
function __construct()
{
# XXX don't know if needed
mb_internal_encoding('UTF-8');

View file

@ -25,6 +25,8 @@
// load settings and version information
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."personal".DIRECTORY_SEPARATOR."settings.inc.php");
require_once(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."version.inc.php");
@ -62,20 +64,15 @@ require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'comments.php');
if(defined('JLOG_ADMIN')) require_once(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang-admin.'.JLOG_LANGUAGE.'.inc.php');
// connect to database
$connect = @mysql_connect(JLOG_DB_URL, JLOG_DB_USER, JLOG_DB_PWD);
if ($connect == FALSE) {
mail(JLOG_EMAIL, $l['admin']['e_db'], $l['admin']['e_db_is']."\n".mysql_error());
die("<strong>".$l['db_error']."</strong><br />".$l['plz_try_again'].".");
}
// select our database
$select = @mysql_select_db(JLOG_DB);
if ($connect == FALSE) {
mail(JLOG_EMAIL, $l['admin']['e_db'], $l['admin']['e_db_is']."\n".mysql_error());
$mysql = @mysqli_connect(JLOG_DB_URL, JLOG_DB_USER, JLOG_DB_PWD, JLOG_DB);
if ($mysql == FALSE) {
mail(JLOG_EMAIL, $l['admin']['e_db'], $l['admin']['e_db_is']."\n".mysqli_error($mysql));
die("<strong>".$l['db_error']."</strong><br />".$l['plz_try_again'].".");
}
// do some settings
@mysql_query("SET NAMES utf8");
@mysql_query("SET sql_mode=''");
@mysqli_query($mysql, "SET NAMES utf8");
@mysqli_query($mysql, "SET sql_mode=''");
// some more code that needs to run for every page - however, this
// code requires an established connection to the database
@ -88,4 +85,4 @@ $plugins = new JlogPluginManager(JLOG_BASEPATH.'plugins'.DIRECTORY_SEPARATOR);
$bbcode = $plugins->callHook('bbcode', $bbcode);
$bbcomments = $plugins->callHook('bbcomments', $bbcomments);
// eof
// eof

View file

@ -199,7 +199,7 @@ class StringParser {
*
* @access public
*/
function StringParser () {
function __construct () {
}
/**
@ -910,7 +910,7 @@ class StringParser_Node {
* occurred at. If not determinable, it is -1.
* @global __STRINGPARSER_NODE_ID
*/
function StringParser_Node ($occurredAt = -1) {
function __constructor ($occurredAt = -1) {
$this->_id = $GLOBALS['__STRINGPARSER_NODE_ID']++;
$this->occurredAt = $occurredAt;
}
@ -1248,7 +1248,7 @@ class StringParser_Node {
* @param object $node The node to destroy
* @return bool True on success, else false.
*/
function destroyNode (&$node) {
static function destroyNode (&$node) {
if ($node === null) {
return false;
}
@ -1486,8 +1486,8 @@ class StringParser_Node_Text extends StringParser_Node {
* occurred at. If not determinable, it is -1.
* @see StringParser_Node_Text::content
*/
function StringParser_Node_Text ($content, $occurredAt = -1) {
parent::StringParser_Node ($occurredAt);
function __construct ($content, $occurredAt = -1) {
# parent::__construct ($occurredAt);
$this->content = $content;
}

View file

@ -1,6 +1,6 @@
<?php
$now_date = getdate();
$errors = array();
$data['rss'] = "";
$data['rss_full'] = "";
$data['sub'] = "";