Skip to content

Commit c4bde06

Browse files
authored
Tweaks (#886)
* check on var before use * avoid php notice * change bugreport link to github issues * link to the subscribe page area * find config correctly * avoid notices * test on value * check on var * avoid error when the DB is not on the same host * #883 - make defaults more common * remove outdated JS code * pass a potential documentation URL on to commandline * expand on a plugin failing to initialise and add a URL for docs * fix path to config * simplify * use __DIR__ * remove unneeded configs * deal with 0 values * #888 - initialise website and domain (cherry picked from commit 6510973)
1 parent 98b5589 commit c4bde06

11 files changed

+44
-65
lines changed

public_html/lists/admin/admin.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,11 @@
285285
if ($id) {
286286
$val_req = Sql_Fetch_Row_Query("select value from {$tables['admin_attribute']}
287287
where adminid = $id and adminattributeid = $row[id]");
288-
$row['value'] = $val_req[0];
288+
if (isset($val_req[0])) {
289+
$row['value'] = $val_req[0];
290+
} else {
291+
$row['value'] = '';
292+
}
289293
} else {
290294
$row['value'] = '';
291295
}

public_html/lists/admin/connect.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,13 @@ function ClineSignature()
460460
return 'phpList version '.VERSION.' (c) 2000-'.date('Y')." phpList Ltd, https://www.phplist.com";
461461
}
462462

463-
function ClineError($msg)
463+
function ClineError($msg, $documentationURL = '')
464464
{
465465
ob_end_clean();
466-
echo "\nError: $msg\n";
466+
echo PHP.EOL."Error: $msg\n";
467+
if (!empty($documentationURL)) {
468+
echo PHP_EOL.s("For more information: "). $documentationURL;
469+
}
467470
exit;
468471
}
469472

@@ -475,11 +478,11 @@ function clineUsage($line = '')
475478
function Error($msg, $documentationURL = '')
476479
{
477480
if ($GLOBALS['commandline']) {
478-
clineError($msg);
481+
clineError($msg, $documentationURL);
479482

480483
return;
481484
}
482-
echo '<div class="error">'.$GLOBALS['I18N']->get('error').": $msg ";
485+
echo '<div class="error">'.s('error').": $msg ";
483486
if (!empty($documentationURL)) {
484487
echo resourceLink($documentationURL);
485488
}

public_html/lists/admin/defaultsystemtemplate.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@
404404
, $title
405405
));
406406

407-
if ($exists[0]) {
407+
if (!empty($exists[0])) {
408408
$messages = '<div class="actionresult alert alert-warning">';
409409
$messages .= s('This default template already exists');
410410
$messages .= '</div>';

public_html/lists/admin/index.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function mb_strtolower($string)
6464
$configfile = $_SERVER['ConfigFile'];
6565
} elseif (isset($cline['c']) && is_file($cline['c'])) {
6666
$configfile = $cline['c'];
67-
} elseif (is_file(dirname(__FILE__).'/../config/config.php')) {
68-
$configfile = '../config/config.php';
67+
} elseif (is_file(__DIR__.'/../config/config.php')) {
68+
$configfile = __DIR__.'/../config/config.php';
6969
} else {
7070
$configfile = '../config/config.php';
7171
}
@@ -734,7 +734,7 @@ function mb_strtolower($string)
734734

735735
if (!$parses_ok) {
736736
echo Error("cannot parse $include");
737-
echo '<p class="error">Sorry, an error occurred. This is a bug. Please <a href="http://mantis.phplist.com">report the bug to the Bug Tracker</a><br/>Sorry for the inconvenience</a></p>';
737+
echo '<p class="error">Sorry, an error occurred. This is a bug. Please <a href="https://github.com/phpList/phplist3/issues">report the bug to the Bug Tracker</a><br/>Sorry for the inconvenience</a></p>';
738738
} else {
739739
if (!empty($_SESSION['action_result'])) {
740740
echo '<div class="actionresult">'.$_SESSION['action_result'].'</div>';

public_html/lists/admin/init.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
## avoid the screen being blank, due to the FOUC system
7676
ini_set("error_append_string",'<script>document.body.classList.remove("invisible");</script>'); ## remove the FOUC
7777
ini_set("error_prepend_string",'<div style="{font-size: 24px;color:red;}">Sorry a software error occurred:</div><br/>
78-
Please <a href="http://mantis.phplist.org">report a bug</a> when reporting the bug, please include URL and the entire content of this page.<br/>');
79-
78+
Please <a href="https://github.com/phpList/phplist3/issues">report a bug</a> when reporting the bug, please include URL and the entire content of this page.<br/>');
8079

8180
if (function_exists('mb_internal_encoding')) {
8281
mb_internal_encoding('UTF-8');
@@ -97,10 +96,6 @@
9796
// @@@ needs more work
9897
$GLOBALS['compression_used'] = $zlib_compression || $gzhandler;
9998

100-
// make sure these are set correctly, so they cannot be injected due to the PHP Globals Problem,
101-
// http://www.hardened-php.net/globals-problem
102-
$GLOBALS['language_module'] = $language_module;
103-
$GLOBALS['database_module'] = $database_module;
10499

105100
//# this is mostly useful when using commandline, and the language is not detected
106101
//# with the browser
@@ -122,6 +117,8 @@
122117
// $GLOBALS['design'] = basename($GLOBALS['design']);
123118
}
124119

120+
$website = $domain = '';
121+
125122
if (!isset($GLOBALS['ui']) || !is_dir(dirname(__FILE__).'/ui/'.$GLOBALS['ui'])) {
126123
if (is_dir(dirname(__FILE__).'/ui/phplist-ui-bootlist')) {
127124
$GLOBALS['ui'] = 'phplist-ui-bootlist';
@@ -158,9 +155,15 @@
158155

159156
if (empty($GLOBALS['language_module'])) {
160157
$GLOBALS['language_module'] = 'english.inc';
158+
if (isset($language_module)) {
159+
$GLOBALS['language_module'] = $language_module;
160+
}
161161
}
162162
if (empty($GLOBALS['database_module']) || !is_file(dirname(__FILE__).'/'.$GLOBALS['database_module'])) {
163163
$GLOBALS['database_module'] = 'mysqli.inc';
164+
if (isset($database_module)) {
165+
$GLOBALS['database_module'] = $database_module;
166+
}
164167
}
165168
if (!isset($database_port)) {
166169
$database_port = null;
@@ -672,7 +675,7 @@
672675
if (!isset($allowed_referrers) || !is_array($allowed_referrers)) {
673676
$allowed_referrers = array();
674677
}
675-
if (defined('ACCESS_CONTROL_ALLOW_ORIGINS') && in_array($_SERVER['HTTP_ORIGIN'], ACCESS_CONTROL_ALLOW_ORIGINS)) {
678+
if (isset($_SERVER['HTTP_ORIGIN']) && defined('ACCESS_CONTROL_ALLOW_ORIGINS') && in_array($_SERVER['HTTP_ORIGIN'], ACCESS_CONTROL_ALLOW_ORIGINS)) {
676679
define('ACCESS_CONTROL_ALLOW_ORIGIN', $_SERVER['HTTP_ORIGIN']);
677680
} elseif (!defined('ACCESS_CONTROL_ALLOW_ORIGIN')) {
678681
define('ACCESS_CONTROL_ALLOW_ORIGIN', $GLOBALS['scheme'].'://'.$_SERVER['HTTP_HOST']);

public_html/lists/admin/lib.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
if (!isset($GLOBALS['developer_email'])) {
3737
ini_set('error_append_string', 'phpList version '.VERSION);
3838
ini_set('error_prepend_string', '<p class="error">Sorry a software error occurred:<br/>
39-
Please <a href="http://mantis.phplist.com">report a bug</a> when reporting the bug, please include URL and the entire content of this page.<br/>');
39+
Please <a href="https://github.com/phpList/phplist3/issues">report a bug</a> when reporting the bug, please include URL and the entire content of this page.<br/>');
4040
}
4141

4242
function cleanListName($name) { ## we allow certain tags in a listname

public_html/lists/admin/pluginlib.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
dbg($className.' disabled');
134134
}
135135
} else {
136-
Error('initialisation of plugin '.$className.' failed');
136+
Error('initialisation of plugin '.$className.' failed. Remove the plugin and try again.','https://resources.phplist.com/documentation/errors/pluginfailed');
137137
}
138138
//print "$className = ".$pluginInstance->name."<br/>";
139139
}

public_html/lists/admin/send_core.php

+1-37
Original file line numberDiff line numberDiff line change
@@ -606,43 +606,7 @@
606606
++$counttabs;
607607

608608
// print $tabs->display();
609-
} ?>
610-
611-
<script language="Javascript" type="text/javascript">
612-
// some debugging stuff to see what happens
613-
function checkForm() {
614-
// return true;
615-
for (var i = 0; i < document.sendmessageform.elements.length; i++) {
616-
alert(document.sendmessageform.elements[i].name + " " + document.sendmessageform.elements[i].value);
617-
}
618-
return true;
619-
}
620-
621-
// detection of unsaved changes,
622-
var browser = navigator.appName.substring(0, 9);
623-
var changed = 1;
624-
function haschanged() {
625-
changed = 1;
626-
}
627-
function savechanges() {
628-
}
629-
var event_number = 0;
630-
if (browser == "Microsoft") {
631-
document.onkeydown = haschanged;
632-
document.onchange = haschanged;
633-
} else if (browser == "Netscape") {
634-
document.captureEvents(Event.KEYDOWN);
635-
document.captureEvents(Event.CHANGE);
636-
document.onkeydown = haschanged;
637-
document.onchange = haschanged;
638-
}
639-
function submitform() {
640-
document.sendmessageform.submit()
641-
}
642-
</script>
643-
<?php
644-
//print '<form method="post" enctype="multipart/form-data" name="sendmessageform" onSubmit="return checkForm()">';
645-
echo '<input type="hidden" name="workaround_fck_bug" value="1" />';
609+
}
646610
echo '<input type="hidden" name="followupto" value="" />';
647611

648612
if ($_GET['page'] == 'preparemessage') {

public_html/lists/admin/upgrade.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,15 @@ function output($message)
246246
}
247247
}
248248
$maxsize = (int) ($maxsize * 1.2); //# add another 20%
249-
$row = Sql_Fetch_Row_Query('select @@datadir');
250-
$dataDir = $row[0];
251-
$avail = disk_free_space($dataDir);
249+
#this is only valid when the DB is on the same host
250+
if ($GLOBALS['database_host'] == 'localhost') {
251+
$row = Sql_Fetch_Row_Query('select @@datadir');
252+
$dataDir = $row[0];
253+
$avail = disk_free_space($dataDir);
254+
} else {
255+
# let's assume the DB host has sufficient space
256+
$avail = $maxsize + 1;
257+
}
252258

253259
//# convert to UTF8
254260
$dbname = $GLOBALS['database_name'];

public_html/lists/config/config.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@
3232
//#
3333
//# define("PHPMAILERHOST",'smtp.mydomain.com');
3434

35-
define('PHPMAILERHOST', 'localhost');
36-
define('PHPMAILERPORT',2500);
37-
define('PHPMAILER_SECURE',false);
38-
35+
define('PHPMAILERHOST', '');
3936

4037
// if TEST is set to 1 (not 0) it will not actually send ANY messages, but display what it would have sent
4138
// this is here, to make sure you edited the config file and mails are not sent "accidentally"
4239
// on unmanaged systems
4340

44-
define('TEST', 0);
41+
define('TEST', 1);
4542
/*
4643
4744
==============================================================================================================

public_html/lists/index.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@
9999
}
100100
// make sure the subscribe page still exists
101101
$req = Sql_fetch_row_query(sprintf('select id from %s where id = %d', $tables['subscribepage'], $id));
102-
$id = $req[0];
102+
if (!$req) {
103+
$id = 0;
104+
}
103105
$msg = '';
104106

105107
if (!empty($_POST['sendpersonallocation'])) {
@@ -663,7 +665,7 @@ function checkGroup(name,value)
663665
$html .= '<div class="adminmessage"><p><b>'.s('You are logged in as administrator (%s) of this phpList system',
664666
$_SESSION['logindetails']['adminname']).'</b></p>';
665667
$html .= '<p>'.s('You are therefore offered the following choice, which your subscribers will not see when they load this page.').'</p>';
666-
$html .= '<p><a href="'.$GLOBALS['adminpages'].'" class="button">'.s('Go back to admin area').'</a></p>';
668+
$html .= '<p><a href="'.$GLOBALS['adminpages'].'?page=spage" class="button">'.s('Go back to admin area').'</a></p>';
667669
$html .= '<p><b>'.s('Please choose').'</b>: <br/><input type=radio name="makeconfirmed" value="1"> '.s('Make this subscriber confirmed immediately').'
668670
<br/><input type=radio name="makeconfirmed" value="0" checked> ' .s('Send this subscriber a request for confirmation email').' </p></div>';
669671
}

0 commit comments

Comments
 (0)