Skip to content

Commit ca8db45

Browse files
bramleysuelaP
authored andcommitted
Remove uses of $can_fetchUrl which is now always true.
Remove fetchUrlPear() which is now redundant.
1 parent b566bae commit ca8db45

File tree

7 files changed

+38
-119
lines changed

7 files changed

+38
-119
lines changed

public_html/lists/admin/actions/checkurl.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@
1616
$isOk = true;
1717
$code = -1;
1818

19-
if ($GLOBALS['can_fetchUrl']) {
20-
$code = testUrl($url);
21-
if ($code != 200) {
22-
if (!empty($url_append)) {
23-
$status = $GLOBALS['I18N']->get('Error fetching URL').' '.$GLOBALS['I18N']->get('Check your "remoteurl_append" setting.');
24-
} else {
25-
$status = $GLOBALS['I18N']->get('Error fetching URL');
26-
}
27-
$isOk = false;
19+
$code = testUrl($url);
20+
if ($code != 200) {
21+
if (!empty($url_append)) {
22+
$status = $GLOBALS['I18N']->get('Error fetching URL').' '.$GLOBALS['I18N']->get('Check your "remoteurl_append" setting.');
23+
} else {
24+
$status = $GLOBALS['I18N']->get('Error fetching URL');
2825
}
29-
} else {
30-
$status = $GLOBALS['I18N']->get('Error fetching URL');
3126
$isOk = false;
3227
}
3328

public_html/lists/admin/actions/storemessage.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@
1616
}
1717

1818
if (!empty($_POST['sendurl'])) {
19-
if (!$GLOBALS['can_fetchUrl']) {
20-
echo Warn($GLOBALS['I18N']->get('You are trying to send a remote URL, but PEAR::HTTP_Request is not available, so this will fail'));
21-
} else {
22-
//# hard overwrite the message content, wipe all that was there.
23-
//# check there's a protocol
24-
//# @@@ do we want to allow other than http and https? Can't imagine, ppl would want to use ftp or something
25-
26-
if ($_POST['sendurl'] == 'e.g. https://www.phplist.com/testcampaign.html') {
27-
$_POST['sendurl'] = '';
28-
} else {
29-
if (!preg_match('/^https?:\/\//i', $_POST['sendurl']) && !preg_match('/testcampaign/i',
30-
$_POST['sendurl'])
31-
) {
32-
$_POST['sendurl'] = 'http://'.$_POST['sendurl'];
33-
}
19+
//# hard overwrite the message content, wipe all that was there.
20+
//# check there's a protocol
21+
//# @@@ do we want to allow other than http and https? Can't imagine, ppl would want to use ftp or something
3422

35-
$_POST['message'] = '[URL:'.$_POST['sendurl'].']';
23+
if ($_POST['sendurl'] == 'e.g. https://www.phplist.com/testcampaign.html') {
24+
$_POST['sendurl'] = '';
25+
} else {
26+
if (!preg_match('/^https?:\/\//i', $_POST['sendurl']) && !preg_match('/testcampaign/i',
27+
$_POST['sendurl'])
28+
) {
29+
$_POST['sendurl'] = 'http://'.$_POST['sendurl'];
3630
}
31+
32+
$_POST['message'] = '[URL:'.$_POST['sendurl'].']';
3733
}
3834
}
3935

public_html/lists/admin/init.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,7 @@
667667
} //# Request for Confirmation, delivery with SMTP
668668

669669
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/PEAR');
670-
$GLOBALS['has_pear_http_request'] = class_exists('HTTP_Request');
671670
$GLOBALS['has_curl'] = function_exists('curl_init');
672-
$GLOBALS['can_fetchUrl'] = true;
673671

674672
$GLOBALS['jQuery'] = 'jquery-3.3.1.min.js';
675673

public_html/lists/admin/lib.php

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,64 +1370,6 @@ function fetchUrlHttpRequest2($url, $requestParameters)
13701370
return $content;
13711371
}
13721372

1373-
function fetchUrlPear($url, $request_parameters)
1374-
{
1375-
if (VERBOSE) {
1376-
logEvent($url.' fetching with PEAR');
1377-
}
1378-
1379-
if (0 && $GLOBALS['has_pear_http_request'] == 2) {
1380-
$headreq = new HTTP_Request2($url, $request_parameters);
1381-
$headreq->setHeader('User-Agent', 'phplist v'.VERSION.'p (https://www.phplist.com)');
1382-
} else {
1383-
$headreq = new HTTP_Request($url, $request_parameters);
1384-
$headreq->addHeader('User-Agent', 'phplist v'.VERSION.'p (https://www.phplist.com)');
1385-
}
1386-
if (!PEAR::isError($headreq->sendRequest(false))) {
1387-
$code = $headreq->getResponseCode();
1388-
if ($code != 200) {
1389-
logEvent('Fetching '.$url.' failed, error code '.$code);
1390-
1391-
return 0;
1392-
}
1393-
$header = $headreq->getResponseHeader();
1394-
1395-
if (preg_match('/charset=(.*)/i', $header['content-type'], $regs)) {
1396-
$remote_charset = strtoupper($regs[1]);
1397-
}
1398-
1399-
$request_parameters['method'] = 'GET';
1400-
if (0 && $GLOBALS['has_pear_http_request'] == 2) {
1401-
$req = new HTTP_Request2($url, $request_parameters);
1402-
$req->setHeader('User-Agent', 'phplist v'.VERSION.'p (https://www.phplist.com)');
1403-
} else {
1404-
$req = new HTTP_Request($url, $request_parameters);
1405-
$req->addHeader('User-Agent', 'phplist v'.VERSION.'p (https://www.phplist.com)');
1406-
}
1407-
logEvent('Fetching '.$url);
1408-
if (VERBOSE && function_exists('output')) {
1409-
output('Fetching remote: '.$url);
1410-
}
1411-
if (!PEAR::isError($req->sendRequest(true))) {
1412-
$content = $req->getResponseBody();
1413-
1414-
if ($remote_charset != 'UTF-8' && function_exists('iconv')) {
1415-
$content = iconv($remote_charset, 'UTF-8//TRANSLIT', $content);
1416-
}
1417-
} else {
1418-
logEvent('Fetching '.$url.' failed on GET '.$req->getResponseCode());
1419-
1420-
return 0;
1421-
}
1422-
} else {
1423-
logEvent('Fetching '.$url.' failed on HEAD');
1424-
1425-
return 0;
1426-
}
1427-
1428-
return $content;
1429-
}
1430-
14311373
function releaseLock($processid)
14321374
{
14331375
global $tables;

public_html/lists/admin/send_core.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,6 @@
242242

243243
// print "Message ID: $id";
244244
// exit;
245-
if (!$GLOBALS['can_fetchUrl'] && preg_match("/\[URL:/i", $_POST['message'])) {
246-
echo $GLOBALS['can_fetchUrl'].Warn(s('You are trying to send a remote URL, but PEAR::HTTP_Request or CURL is not available, so this will fail'));
247-
}
248-
249245
if ($GLOBALS['commandline']) {
250246
if (isset($_POST['targetlist']) && is_array($_POST['targetlist'])) {
251247
Sql_query("delete from {$tables['listmessage']} where messageid = $id");
@@ -701,11 +697,11 @@ function submitform() {
701697
<label for="subject">' .s('Campaign subject').Help('subject').'</label>'.
702698
'<input type="text" name="subject" id="subjectinput" value="' .htmlentities($utf8_subject, ENT_QUOTES, 'UTF-8').'" size="60" />
703699
</div>
704-
700+
705701
<div class="field"><label for="fromfield">' .$GLOBALS['I18N']->get('From Line').Help('from').'</label>'.'
706702
<input type="text" name="fromfield"
707703
value="' .htmlentities($utf8_from, ENT_QUOTES, 'UTF-8').'" size="60" /></div>
708-
704+
709705
<div class="field" id="message-text-preview">
710706
<label for="messagepreview">' .s('Message preview').Help('generatetextpreview').'</label>
711707
<input type="text" id="messagepreview" name="messagepreview" size="60" readonly />
@@ -714,29 +710,27 @@ function submitform() {
714710
</div>
715711
</div>';
716712

717-
if ($GLOBALS['can_fetchUrl']) {
718-
$maincontent .= sprintf('
713+
$maincontent .= sprintf('
719714
720715
<div id="contentchoice" class="field">
721716
<label for="sendmethod">' .$GLOBALS['I18N']->get('Content').Help('sendmethod').'</label>'.'
722717
<input type="radio" name="sendmethod" value="remoteurl" %s />' .$GLOBALS['I18N']->get('Send a Webpage').'
723718
<input type="radio" name="sendmethod" value="inputhere" %s />' .$GLOBALS['I18N']->get('Compose Message').'
724719
</div>',
725-
$messagedata['sendmethod'] == 'remoteurl' ? 'checked="checked"' : '',
726-
$messagedata['sendmethod'] == 'inputhere' ? 'checked="checked"' : ''
720+
$messagedata['sendmethod'] == 'remoteurl' ? 'checked="checked"' : '',
721+
$messagedata['sendmethod'] == 'inputhere' ? 'checked="checked"' : ''
727722
);
728723

729-
if (empty($messagedata['sendurl'])) {
730-
$messagedata['sendurl'] = 'e.g. https://www.phplist.com/testcampaign.html';
731-
}
724+
if (empty($messagedata['sendurl'])) {
725+
$messagedata['sendurl'] = 'e.g. https://www.phplist.com/testcampaign.html';
726+
}
732727

733-
$maincontent .= '
728+
$maincontent .= '
734729
<div id="remoteurl" class="field"><label for="sendurl">' .$GLOBALS['I18N']->get('Send a Webpage - URL').Help('sendurl').'</label>'.'
735730
<input type="text" name="sendurl" id="remoteurlinput"
736-
value="' .htmlspecialchars($messagedata['sendurl']).'" size="60" /> <span id="remoteurlstatus"></span></div>';
737-
if (isset($messagedata['sendmethod']) && $messagedata['sendmethod'] != 'remoteurl') {
738-
$GLOBALS['pagefooter']['hideremoteurl'] = '<script type="text/javascript">$("#remoteurl").hide();</script>';
739-
}
731+
value="' .$messagedata['sendurl'].'" size="60" /> <span id="remoteurlstatus"></span></div>';
732+
if (isset($messagedata['sendmethod']) && $messagedata['sendmethod'] != 'remoteurl') {
733+
$GLOBALS['pagefooter']['hideremoteurl'] = '<script type="text/javascript">$("#remoteurl").hide();</script>';
740734
}
741735

742736
// custom code - end

public_html/lists/admin/sendemaillib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
122122
}
123123

124124
//# Fetch external content, only if the URL has placeholders
125-
if ($GLOBALS['can_fetchUrl'] && preg_match("/\[URL:([^\s]+)\]/i", $content, $regs)) {
125+
if (preg_match("/\[URL:([^\s]+)\]/i", $content, $regs)) {
126126
while (isset($regs[1]) && strlen($regs[1])) {
127127
$url = $regs[1];
128128
if (!preg_match('/^http/i', $url)) {
@@ -1468,7 +1468,7 @@ function precacheMessage($messageid, $forwardContent = 0)
14681468

14691469
if (!$cached[$messageid]['userspecific_url']) {
14701470
//# Fetch external content here, because URL does not contain placeholders
1471-
if ($GLOBALS['can_fetchUrl'] && preg_match("/\[URL:([^\s]+)\]/i", $cached[$messageid]['content'], $regs)) {
1471+
if (preg_match("/\[URL:([^\s]+)\]/i", $cached[$messageid]['content'], $regs)) {
14721472
$remote_content = fetchUrl($regs[1], array());
14731473
// $remote_content = fetchUrl($message['sendurl'],array());
14741474

public_html/lists/admin/template.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -333,17 +333,11 @@ function getTemplateLinks($content)
333333
<td><input type="checkbox"
334334
name="checkfullimages" <?php echo $checkfullimages ? 'checked="checked"' : '' ?> /></td>
335335
</tr>
336-
337-
<?php if ($GLOBALS['can_fetchUrl']) {
338-
?>
339-
<tr>
340-
<td><?php echo s('Check that all external images exist') ?></td>
341-
<td><input type="checkbox"
342-
name="checkimagesexist" <?php echo $checkimagesexist ? 'checked="checked"' : '' ?> /></td>
343-
</tr>
344-
<?php
345-
346-
} ?>
336+
<tr>
337+
<td><?php echo s('Check that all external images exist') ?></td>
338+
<td><input type="checkbox"
339+
name="checkimagesexist" <?php echo $checkimagesexist ? 'checked="checked"' : '' ?> /></td>
340+
</tr>
347341
<tr>
348342
<td colspan="2"><input class="submit" type="submit" name="save"
349343
value="<?php echo s('Save Changes') ?>"/></td>
@@ -352,7 +346,7 @@ function getTemplateLinks($content)
352346
</div></div>
353347
<?php $sendtest_content = sprintf('<div class="sendTest" id="sendTest">
354348
' .$sendtestresult.'
355-
<input class="submit" type="submit" name="sendtest" value="%s"/> %s:
349+
<input class="submit" type="submit" name="sendtest" value="%s"/> %s:
356350
<input type="text" name="testtarget" size="40" value="' .htmlspecialchars($testtarget).'"/><br />%s
357351
</div>',
358352
s('Send test message'), s('to email addresses'),

0 commit comments

Comments
 (0)