Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Jun 6, 2021
1 parent 8b55c94 commit 58bac94
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 43 deletions.
9 changes: 6 additions & 3 deletions plugins/xmlsitemap/xmlsitemap.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,9 @@ public function sendPing(array $destinations, $filename)
if (empty($filename)) {
COM_errorLog(__METHOD__ . ': sitemap file name is not specified.');

return 0;
} elseif (preg_match('@\Ahttps?://localhost/@i', $_CONF['site_url'])) {
// It seems that 'localhost' is not accepted
return 0;
}

Expand Down Expand Up @@ -1008,15 +1011,15 @@ public function sendPing(array $destinations, $filename)
}

// Sends a ping to the endpoint of a search engine
if ($url !== '') {
if (!empty($url)) {
$req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);

try {
$req->setHeader('User-Agent', 'Geeklog/' . VERSION);
$response = $req->send();
$status = (int) $response->getStatus();
$status = $response->getStatus();

if ($status === 200) {
if ($status == 200) {
$success++;
$records[$dest] = time();
} else {
Expand Down
9 changes: 6 additions & 3 deletions public_html/admin/install/classes/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -1593,9 +1593,12 @@ protected function doDatabaseUpgrades($currentGlVersion, $checkForMessage = fals

case '2.2.1sr1':
require_once $_CONF['path'] . 'sql/updates/' . $_DB_dbms . '_2.2.1_to_2.2.2.php';
$this->updateDB($_SQL, $progress);
update_ConfValuesFor222();
update_TablesContainingIPAddresses222();

if (!$checkForMessage) {
$this->updateDB($_SQL, $progress);
update_ConfValuesFor222();
update_TablesContainingIPAddresses222();
}

$currentGlVersion = '2.2.2';
break;
Expand Down
7 changes: 6 additions & 1 deletion public_html/admin/install/classes/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,12 @@ public function step3($retval, $installPlugins)
// Query `vars` and see if 'database_engine' == 'InnoDB'
$result = DB_query("SELECT value FROM {$_TABLES['vars']} WHERE name = 'database_engine'");
$row = DB_fetchArray($result);
Common::$env['use_innodb'] = $use_innodb = ($row['value'] === 'InnoDB');

if (is_array($row) && isset($row['value'])) {
Common::$env['use_innodb'] = $use_innodb = ($row['value'] === 'InnoDB');
} else {
Common::$env['use_innodb'] = $use_innodb = false;
}
}

if ($this->doDatabaseUpgrades($version)) {
Expand Down
1 change: 1 addition & 0 deletions public_html/admin/install/classes/installer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ public function run()
// for the plugin install and upgrade,
// we need lib-common.php in the global(!) namespace
require_once dirname(dirname(dirname(__DIR__))) . '/lib-common.php';
Common::$env['dbconfig_path'] = $_CONF['path'] . Common::DB_CONFIG_FILE;

// Clear all speed limits for login to prevent login issues after install/upgrade/migrate (bug #995)
COM_clearSpeedlimit(0, 'login');
Expand Down
11 changes: 10 additions & 1 deletion public_html/lib-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// | |
// | Geeklog common library. |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2020 by the following authors: |
// | Copyright (C) 2000-2021 by the following authors: |
// | |
// | Authors: Tony Bibbs - tony AT tonybibbs DOT com |
// | Mark Limburg - mlimburg AT users DOT sourceforge DOT net |
Expand Down Expand Up @@ -2391,6 +2391,15 @@ function COM_errorLog($logEntry, $actionId = '')
$retval .= $LANG01[33] . ' ' . $logfile . ' (' . $timestamp . ')<br' . XHTML . '>' . LB;
} else {
fputs($file, "$timestamp - $remoteAddress - $logEntry $callTrace \n");

// To prevent errors while installing/upgrading/migrating
if (empty($LANG01)) {
$LANG01 = [];
}
if (empty($LANG01[34])) {
$LANG01[34] = 'Error';
}

$retval .= COM_startBlock($LANG01[34] . ' - ' . $timestamp,
'', COM_getBlockTemplate('_msg_block',
'header'))
Expand Down
38 changes: 20 additions & 18 deletions sql/updates/mysql_2.2.1_to_2.2.2.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
<?php

// *************************************
// New 'ip_addresses' table
$_SQL[] = "
CREATE TABLE {$_TABLES['ip_addresses']} (
seq INT NOT NULL AUTO_INCREMENT,
ipaddress VARCHAR(39) NOT NULL DEFAULT '0.0.0.0',
created_at INT NOT NULL DEFAULT 0,
is_anonymized INT NOT NULL default 0,
PRIMARY KEY (seq)
) ENGINE=MyISAM
";

/**
* Add/Edit/Delete config options for new version
Expand Down Expand Up @@ -39,13 +29,25 @@ function update_TablesContainingIPAddresses222()
{
global $_TABLES;

// New 'ip_addresses' table
$sql = "
CREATE TABLE {$_TABLES['ip_addresses']} (
seq INT NOT NULL AUTO_INCREMENT,
ipaddress VARCHAR(39) NOT NULL DEFAULT '0.0.0.0',
created_at INT NOT NULL DEFAULT 0,
is_anonymized INT NOT NULL default 0,
PRIMARY KEY (seq)
) ENGINE=MyISAM
";
DB_query($sql);

$data = [
'comments' => ['cid', 'ipaddress'],
'commentsumissions' => ['cid', 'ipaddress'],
'likes' => ['lid', 'ipaddress'],
'sessions' => ['sess_id', 'remote_ip'],
'speedlimit' => ['id', 'ipaddress'],
'trackback' => ['cid', 'ipaddress'],
'comments' => ['cid', 'ipaddress'],
'commentsubmissions' => ['cid', 'ipaddress'],
'likes' => ['lid', 'ipaddress'],
'sessions' => ['sess_id', 'remote_ip'],
'speedlimit' => ['id', 'ipaddress'],
'trackback' => ['cid', 'ipaddress'],
];

foreach ($data as $table => $pair) {
Expand Down Expand Up @@ -74,10 +76,10 @@ function update_TablesContainingIPAddresses222()

// Update 'seq' column
if ($table === 'sessions') {
DB_query("UPDATE $_TABLES[$table] SET seq = $seq WHERE $primaryKeyColumn = $primaryKeyValue");
} else {
$primaryKeyValue = DB_escapeString($primaryKeyValue);
DB_query("UPDATE $_TABLES[$table] SET seq = $seq WHERE $primaryKeyColumn = '$primaryKeyValue'");
} else {
DB_query("UPDATE $_TABLES[$table] SET seq = $seq WHERE $primaryKeyColumn = $primaryKeyValue");
}
}

Expand Down
36 changes: 19 additions & 17 deletions sql/updates/pgsql_2.2.1_to_2.2.2.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
<?php

// *************************************
// New 'ip_addresses' table
$_SQL[] = "
CREATE TABLE {$_TABLES['ip_addresses']} (
seq SERIAL,
ipaddress VARCHAR(39) NOT NULL DEFAULT '0.0.0.0',
created_at INT NOT NULL DEFAULT 0,
is_anonymized INT NOT NULL default 0,
PRIMARY KEY (seq)
";

/**
* Add/Edit/Delete config options for new version
Expand Down Expand Up @@ -38,13 +29,24 @@ function update_TablesContainingIPAddresses222()
{
global $_TABLES;

// New 'ip_addresses' table
$sql = "
CREATE TABLE {$_TABLES['ip_addresses']} (
seq SERIAL,
ipaddress VARCHAR(39) NOT NULL DEFAULT '0.0.0.0',
created_at INT NOT NULL DEFAULT 0,
is_anonymized INT NOT NULL default 0,
PRIMARY KEY (seq)
";
DB_query($sql);

$data = [
'comments' => ['cid', 'ipaddress'],
'commentsumissions' => ['cid', 'ipaddress'],
'likes' => ['lid', 'ipaddress'],
'sessions' => ['sess_id', 'remote_ip'],
'speedlimit' => ['id', 'ipaddress'],
'trackback' => ['cid', 'ipaddress'],
'comments' => ['cid', 'ipaddress'],
'commentsubmissions' => ['cid', 'ipaddress'],
'likes' => ['lid', 'ipaddress'],
'sessions' => ['sess_id', 'remote_ip'],
'speedlimit' => ['id', 'ipaddress'],
'trackback' => ['cid', 'ipaddress'],
];

foreach ($data as $table => $pair) {
Expand Down Expand Up @@ -73,10 +75,10 @@ function update_TablesContainingIPAddresses222()

// Update 'seq' column
if ($table === 'sessions') {
DB_query("UPDATE $_TABLES[$table] SET seq = $seq WHERE $primaryKeyColumn = $primaryKeyValue");
} else {
$primaryKeyValue = DB_escapeString($primaryKeyValue);
DB_query("UPDATE $_TABLES[$table] SET seq = $seq WHERE $primaryKeyColumn = '$primaryKeyValue'");
} else {
DB_query("UPDATE $_TABLES[$table] SET seq = $seq WHERE $primaryKeyColumn = $primaryKeyValue");
}
}

Expand Down

0 comments on commit 58bac94

Please sign in to comment.