[web-php] master: Fix: Remove unused functions (#585)
| From: | Andreas Möller via GitHub | Date: | Thu, 07 Dec 2023 17:28:23 +0000 |
| Subject: | [web-php] master: Fix: Remove unused functions (#585) | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-31266@lists.php.net to get a copy of this message | ||
Author: Andreas Möller (localheinz)
Committer: GitHub (web-flow)
Pusher: kamil-tekiela
Date: 2023-12-07T18:14:43+01:00
Commit: https://github.com/php/web-php/commit/9482f9bd436b86c9d6d227bbff01ada403a8641a
Raw diff: https://github.com/php/web-php/commit/9482f9bd436b86c9d6d227bbff01ada403a8641a.diff
Fix: Remove unused functions (#585)
Changed paths:
D include/results.inc
M bin/createNewsEntry
M include/layout.inc
M include/site.inc
M quickref.php
M results.php
Diff:
diff --git a/bin/createNewsEntry b/bin/createNewsEntry
index 2e0209e851..8f695494e8 100755
--- a/bin/createNewsEntry
+++ b/bin/createNewsEntry
@@ -161,20 +161,6 @@ function getContent(): string {
return $news;
}
-function updateArchiveXML(string $id, string $archiveFile): void {
- $arch = new DOMDocument("1.0", "utf-8");
- $arch->formatOutput = true;
- $arch->preserveWhiteSpace = false;
- $arch->load($archiveFile);
-
- $first = $arch->createElementNs("http://www.w3.org/2001/XInclude",
"xi:include");
- $first->setAttribute("href", "entries/{$id}.xml");
-
- $second = $arch->getElementsByTagNameNs("http://www.w3.org/2001/XInclude",
"include")->item(0);
- $arch->documentElement->insertBefore($first, $second);
- $arch->save($archiveFile);
-}
-
function parseOptions(): Entry {
$opts = getopt('h', [
'help',
diff --git a/include/layout.inc b/include/layout.inc
index 73f9e20ecf..eeedd43872 100644
--- a/include/layout.inc
+++ b/include/layout.inc
@@ -47,12 +47,6 @@ function highlight_php_trimmed($code, $return = false)
return null;
}
-// Stats pages still need this
-function commonHeader($title): void { site_header($title); }
-
-// Stats pages still need this
-function commonFooter(): void { site_footer(); }
-
// Resize the image using the output of make_image()
function resize_image($img, $width = 1, $height = 1)
{
@@ -160,13 +154,6 @@ function make_popup_link($url, $linktext = false, $target = false, $windowprops
);
}
-// print_popup_link()
-// print a hyperlink to something, within the site, that pops up a new window
-//
-function print_popup_link($url, $linktext = false, $windowprops = "", $target = false,
$extras = false): void {
- echo make_popup_link($url, $linktext, $windowprops, $target, $extras);
-}
-
// Print a link for a downloadable file (including filesize)
function download_link($file, $title): void
{
@@ -204,20 +191,6 @@ function download_link($file, $title): void
}
}
-function sect_to_file($string) {
- $string = strtolower($string);
- $string = str_replace([' ', '_'], '-', $string);
- $func = "function.$string.php";
- $chap = "ref.$string.php";
- $feat = "features.$string.php";
- $struct = "control-structures.$string.php";
- if (@is_file($func)) return $func;
- if (@is_file($chap)) return $chap;
- if (@is_file($feat)) return $feat;
- if (@is_file($struct)) return $struct;
- else return "$string.php";
-}
-
function clean($var) {
return htmlspecialchars($var, ENT_QUOTES);
}
@@ -511,39 +484,6 @@ function get_news_changes()
return false;
}
-function news_toc($sections = null): void {
- include __DIR__ . "/pregen-news.inc";
- $items = [
- "news" => [
- "title" => "News",
- "link" => "/archive/",
- "children" => print_news($NEWS_ENTRIES, "frontpage", 3, null,
true),
- ],
- "conferences" => [
- "title" => "Conferences",
- "link" => "/conferences/",
- "children" => print_news($NEWS_ENTRIES, "conferences", 3, null,
true),
- ],
- "papers" => [
- "title" => "Call for Papers",
- "link" => "/conferences/",
- "children" => print_news($NEWS_ENTRIES, "cfp", 3, null, true),
- ],
- ];
-
- foreach ($items as $section => $menu) {
-
- // only print requested sections.
- if (is_array($sections) && !in_array($section, $sections, true)) {
- continue;
- }
-
- echo "<dt><a
href='{$menu["link"]}'>{$menu["title"]}</a></dt>\n";
- foreach ($menu["children"] as $child) {
- echo "<dd><a
href='{$child["permlink"]}'>{$child["title"]}</a></dd>\n";
- }
- }
-}
function doc_toc($lang): void {
$file = __DIR__ . "/../manual/$lang/toc/index.inc";
if (!file_exists($file)) {
diff --git a/include/results.inc b/include/results.inc
deleted file mode 100644
index 0181a04ff6..0000000000
--- a/include/results.inc
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-function search_results($res, $q, $profile = 'all', $per_page = 10, $s = 0, $l =
'en', $show_title = true, $show_foot = true, $show_attrib = true): void {
- $start_result = $s;
- $end_result = $s + $res['ResultSet']['totalResultsReturned'] - 1;
-
- $results_count = ($res['ResultSet']['totalResultsAvailable'] < 100 ?
$res['ResultSet']['totalResultsAvailable'] : 'more than 100');
-
- $disp_start_result = $start_result + 1;
- $disp_end_result = $end_result + 1;
- if($show_title) echo "<h2>Showing results $disp_start_result to $disp_end_result of
$results_count</h2>\n";
- echo '<ul id="search-results">' . "\n";
- $pos = $res['ResultSet']['firstResultPosition'];
-
- $php_img_dir = 'http://www.php.net/images';
- $types = [
- 'pear' => '<img src="' . $php_img_dir .
'/pear_item.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'pecl' => '<img src="' . $php_img_dir .
'/pecl_item.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'pecl4win' => '<img src="' . $php_img_dir .
'/pecl_item_win.gif" height="22" width="21" style="float:left;
margin-left:-31px;"/>',
- 'peclbugs' => '<img src="' . $php_img_dir .
'/pecl_item_bug.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'pearbugs' => '<img src="' . $php_img_dir .
'/pear_item_bug.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'talks' => '<img src="' . $php_img_dir .
'/ele-icon.gif" height="20" width="32" style="float:left;
margin-left:-40px;"/>',
- 'snaps' => '<img src="' . $php_img_dir .
'/logos/php_xpstyle_ico.png" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
- 'cvsweb' => '<img src="' . $php_img_dir .
'/logos/php_script_ico.png" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
- 'viewcvs' => '<img src="' . $php_img_dir .
'/logos/php_script_ico.png" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
- 'news' => '<img src="' . $php_img_dir .
'/logos/php-icon-white.gif" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
- 'php' => '<img src="' . $php_img_dir .
'/logos/php-icon-white.gif" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
- 'doc' => '<img src="' . $php_img_dir .
'/logos/php-icon-white.gif" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
- 'bugs' => '<img src="' . $php_img_dir .
'/php_bug.gif" height="32" width="32" style="float:left;
margin-left:-40px;"/>',
- 'gtk' => '<img src="' . $php_img_dir .
'/logos/php-gtk-white.gif" height="26" width="32"
style="float:left; margin-left:-40px;"/>',
- ];
-
- foreach($res['ResultSet']['Result'] as $i => $hit) {
- $cnt = $pos + $i;
-
- $d = date('j M Y', $hit['ModificationDate']);
- $cachelink = '';
- if (isset($hit['Cache'])) {
- $cachelink = " - <a
href=\"{$hit['Cache']}\">Cached</a>";
- }
-
- // rewrite mirrors urls (\w\w\d? or www, but not qa, doc, gtk and ~/user)
- $real_url = preg_replace('@^http://(?!doc|qa|gtk)\w{2,3}\.php\.net(?!/~)(.*)$@',
'$1', $hit['Url']);
- $displayurl = preg_replace('@^http://(?:(?!doc|qa|php|gtk)\w{2,3}\.)?(.+[^/])/?$@',
'$1', $hit['Url']);
- $type = substr($displayurl,0,strpos($displayurl,'.'));
- if($type == 'pecl' && strstr($displayurl,"/bugs/")) $type =
"peclbugs";
- if($type == 'pear' && strstr($displayurl,"/bugs/")) $type =
"pearbugs";
- if($type == 'smarty') continue;
- $display_title = str_replace(['PHP:', '&'], ['',
'&'], $hit['Title']);
-
- // Fall back to the PHP logo for unknown hits
- if (!isset($types[$type])) {
- $type = "php";
- }
-
- // Fix &gt; double escaping
- $summary = str_replace('&', '&',
$hit['Summary']);
- $summary = htmlspecialchars($summary, ENT_QUOTES, 'UTF-8');
- echo <<<EOB
-<li>
- <p class="result">{$types[$type]}<a
href="{$real_url}">{$display_title}</a></p>
- <p class="summary">{$summary}</p>
- <p class="meta">{$displayurl} - {$d} {$cachelink}</p>
-</li>
-EOB;
- }
- echo "</ul>\n";
- if($show_attrib):
- echo <<<EOB
-<span style="margin-left: 3em; margin-top: 1em; float: right; font-family: Verdana, Tahoma,
Helvetica, Arial;
-font-size: 11px; color:#555;">results by <img style="margin-bottom:4px;"
src="/images/bing.png" align="center"/></span>
-EOB;
- endif;
- if($show_foot):
- echo <<<EOB
-<div id="results_nav"><h4>Results Page:</h4>
-<ul id="results_nav_list">
-EOB;
- $start = 0;
- for($z = 1; $z < 11; $z++) {
- if($start > $res['ResultSet']['totalResultsAvailable']) {
- break;
- }
-
- $class = '';
- if ($start == $start_result) {
- $class = 'current';
- }
-
- printf('<li class="%s"><a
href="/results.php?q=%s&start=%d&p=%s&l=%s">%d</a></li>',
$class, urlencode($q), $start, $profile, urlencode($l), $z);
- $start += $per_page;
- }
- echo '</ul></div>';
- endif;
-}
diff --git a/include/site.inc b/include/site.inc
index dd147e22f8..50877ecbfa 100644
--- a/include/site.inc
+++ b/include/site.inc
@@ -59,15 +59,6 @@ function default_language($site = false)
return (isset($MIRRORS[$site]) ? $MIRRORS[$site][6] : false);
}
-// Returns true if the current (or specified) mirror
-// site is registered to have local search support
-function have_search($site = false)
-{
- global $MIRRORS, $MYSITE;
- if (!$site) { $site = $MYSITE; }
- return (isset($MIRRORS[$site]) ? $MIRRORS[$site][5] : false);
-}
-
// Returns the current (or specified)
// mirror site's provider's name
function mirror_provider($site = false)
diff --git a/quickref.php b/quickref.php
index 8fd1479bfa..569937b416 100644
--- a/quickref.php
+++ b/quickref.php
@@ -16,7 +16,6 @@
$_SERVER['BASE_PAGE'] = 'quickref.php';
include_once __DIR__ . '/include/prepend.inc';
include_once __DIR__ . '/include/errors.inc';
-include __DIR__ . '/include/results.inc';
if (empty($notfound)) {
mirror_redirect("/search.php");
diff --git a/results.php b/results.php
index 7b4893279e..a13f1d28b6 100644
--- a/results.php
+++ b/results.php
@@ -2,7 +2,6 @@
$_SERVER['BASE_PAGE'] = 'results.php';
include __DIR__ . '/include/prepend.inc';
-include __DIR__ . '/include/results.inc';
// HTTP status line is passed on, signifies an error
site_header(