[PRES] [web-pres2] master: Don't hard code http as scheme anymore

From: Date: Thu, 12 Jun 2025 16:48:17 +0000
Subject: [PRES] [web-pres2] master: Don't hard code http as scheme anymore
Groups: php.pres 
Request: Send a blank email to pres+get-2478@lists.php.net to get a copy of this message
Author: Derick Rethans (derickr) Date: 2025-06-12T17:36:10+01:00 Commit: https://github.com/php/web-pres2/commit/0c32618b5c62f70a0a9c88735f58667df54b2658 Raw diff: https://github.com/php/web-pres2/commit/0c32618b5c62f70a0a9c88735f58667df54b2658.diff Don't hard code http as scheme anymore Changed paths: M display.php M index.php M keyboard.js.php M objects.php M show.php M slidelist.php Diff: diff --git a/display.php b/display.php index 9f19c6e..5f711e9 100644 --- a/display.php +++ b/display.php @@ -58,7 +58,7 @@ function _presentation(&$presentation) { <!doctype html> <html> <head> -<base href="http://$_SERVER[HTTP_HOST]$this->baseDir"> +<base href="$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir"> <meta charset="utf-8"> <title>{$presentation->title}</title> HEADER; @@ -130,7 +130,7 @@ function _slide(&$slide) { switch($this->pres->template) { case 'simple': $slide->titleColor = '#000000'; - echo "<div align=\"$slide->titleAlign\" style=\"font-size: $titlesize; margin: 0 ".$offset."em 0 0;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->slideNum\" style=\"text-decoration: none; color: $titlecolor;\">".markup_text($slide->title)."</a></div>"; + echo "<div align=\"$slide->titleAlign\" style=\"font-size: $titlesize; margin: 0 ".$offset."em 0 0;\"><a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->slideNum\" style=\"text-decoration: none; color: $titlecolor;\">".markup_text($slide->title)."</a></div>"; break; case 'empty': $slide->titleColor = '#000000'; @@ -150,7 +150,7 @@ function _slide(&$slide) { } ?> <td align="center"> - <?php echo "<div align=\"center\" style=\"font-size: $titlesize; margin: 0 ".$offset."em 0 0;\"><a title=\"".$this->pres->slides[$this->slideNum]->filename."\" href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->slideNum\" style=\"text-decoration: none; color: $titlecolor;\">".markup_text($slide->title)."</a></div>";?> + <?php echo "<div align=\"center\" style=\"font-size: $titlesize; margin: 0 ".$offset."em 0 0;\"><a title=\"".$this->pres->slides[$this->slideNum]->filename."\" href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->slideNum\" style=\"text-decoration: none; color: $titlecolor;\">".markup_text($slide->title)."</a></div>";?> </td> </tr></table> <br /> @@ -162,16 +162,16 @@ function _slide(&$slide) { <td><img src="images/blank.gif" width="5" /></td> <td><?php if( $this->slideNum > 0){ $prevSlide = $this->slideNum - 1; - echo "<a title=\"$this->prevTitle\" href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prevSlide\">" + echo "<a title=\"$this->prevTitle\" href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prevSlide\">" . '<img src="images/back.gif" border="0" hspace="2" /></a>'; } if($this->slideNum < $this->maxSlideNum) $this->nextSlideNum = $this->slideNum + 1; ?></td> <td bgcolor="999999"><img src="images/blank.gif" width="25" height="1" /><br /> <span class="c2"><b><i>&nbsp;&nbsp; - <a title="<?php echo $this->slideNum.' of '.$this->maxSlideNum?>" href="<?php echo "http://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>" onClick="window.open('<?php echo "http://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=500,left=<?php echo $this->winW-300 ?>,top=0'); return false" class="linka"><?php echo $this->slideNum ?></a> &nbsp; &nbsp; </i></b></span></td> + <a title="<?php echo $this->slideNum.' of '.$this->maxSlideNum?>" href="<?php echo "$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>" onClick="window.open('<?php echo "$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=500,left=<?php echo $this->winW-300 ?>,top=0'); return false" class="linka"><?php echo $this->slideNum ?></a> &nbsp; &nbsp; </i></b></span></td> <td><?php if( !empty($this->nextSlideNum) ) - echo "<a title=\"$this->nextTitle\" href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->nextSlideNum\">" + echo "<a title=\"$this->nextTitle\" href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->nextSlideNum\">" . '<img src="images/next.gif" border="0" hspace="2" /></a>'; ?></td> <td><img src="images/blank.gif" height="10" width="15" /></td> @@ -209,16 +209,16 @@ function _slide(&$slide) { <td><img src="images/blank.gif" width="5" /></td> <td><?php if( $this->slideNum > 0){ $prevSlide = $this->slideNum - 1; - echo "<a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prevSlide\">" + echo "<a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prevSlide\">" . '<img src="images/back.gif" border="0" hspace="2" /></a>'; } if($this->slideNum < $this->maxSlideNum) $this->nextSlideNum = $this->slideNum + 1; ?></td> <td bgcolor="999999"><img src="images/blank.gif" width="25" height="1" /><br /> <span class="c2"><b><i>&nbsp;&nbsp; - <a href="<?php echo "http://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>" onClick="window.open('<?php echo "http://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=500,left=<?php echo $this->winW-300 ?>,top=0'); return false" class="linka"><?php echo $this->slideNum ?></a> &nbsp; &nbsp; </i></b></span></td> + <a href="<?php echo "$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>" onClick="window.open('<?php echo "$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php" ?>','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=500,left=<?php echo $this->winW-300 ?>,top=0'); return false" class="linka"><?php echo $this->slideNum ?></a> &nbsp; &nbsp; </i></b></span></td> <td><?php if( !empty($this->nextSlideNum) ) - echo "<a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->nextSlideNum\">" + echo "<a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->nextSlideNum\">" . '<img src="images/next.gif" border="0" hspace="2" /></a>'; ?></td> <td><img src="images/blank.gif" height="10" width="15" /></td> @@ -233,7 +233,7 @@ function _slide(&$slide) { case 'css': echo "<div id=\"stickyBar\" class=\"sticky\" align=\"$slide->titleAlign\" style=\"width: 100%;\"><div class=\"navbar\">"; echo <<<ENDT -<div align='center' class='navbar_title'><a href='http://{$_SERVER['HTTP_HOST']}{$this->baseDir}{$this->showScript}/$currentPres/{$this->slideNum}' style='navbar_title_a'> +<div align='center' class='navbar_title'><a href='{$_SERVER[REQUEST_SCHEME]}://{$_SERVER['HTTP_HOST']}{$this->baseDir}{$this->showScript}/$currentPres/{$this->slideNum}' style='navbar_title_a'> ENDT; echo $slide->title."</a></div>"; if (isset($slide->subtitle)) { @@ -243,11 +243,11 @@ function _slide(&$slide) { } echo "<div class='navbar_nr'>"; echo <<<ENDD -<a href='http://{$_SERVER['HTTP_HOST']}{$this->baseDir}/slidelist.php' class='navbar-title' onClick="window.open('http://{$_SERVER['HTTP_HOST']}{$this->baseDir}/slidelist.php','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=500,left=10,top=0'); return false">{$this->slideNum}/{$this->maxSlideNum}</a></div> +<a href='{$_SERVER[REQUEST_SCHEME]}://{$_SERVER['HTTP_HOST']}{$this->baseDir}/slidelist.php' class='navbar-title' onClick="window.open('{$_SERVER[REQUEST_SCHEME]}://{$_SERVER['HTTP_HOST']}{$this->baseDir}/slidelist.php','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=500,left=10,top=0'); return false">{$this->slideNum}/{$this->maxSlideNum}</a></div> ENDD; if ($this->pres->navbartopiclinks) { - echo "<div style=\"float: left; margin: -0.2em 2em 0 0; font-size: $navsize;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prev\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->prevTitle)."</a></div>"; - echo "<div style=\"float: right; margin: -0.2em 2em 0 0; color: $slide->navcolor; font-size: $navsize;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$next\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->nextTitle)."</a></div>"; + echo "<div style=\"float: left; margin: -0.2em 2em 0 0; font-size: $navsize;\"><a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prev\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->prevTitle)."</a></div>"; + echo "<div style=\"float: right; margin: -0.2em 2em 0 0; color: $slide->navcolor; font-size: $navsize;\"><a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$next\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->nextTitle)."</a></div>"; } echo "</div></div>\n"; echo "<div class=\"mainarea\">\n"; @@ -264,7 +264,7 @@ function _slide(&$slide) { echo "<a href=\"$logo1url\"><img src=\"$logo1\" border=\"0\" align=\"left\" style=\"float: left;\" alt=\"".$this->pres->slides[$this->slideNum]->filename."\"></a>"; $offset+=2; } - echo "<div align=\"center\" style=\"font-size: $titlesize; margin: 0 ".$offset."em 0 0;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->slideNum\" style=\"text-decoration: none; color: $titlecolor;\">".markup_text($slide->title)."</a></div>"; + echo "<div align=\"center\" style=\"font-size: $titlesize; margin: 0 ".$offset."em 0 0;\"><a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$this->slideNum\" style=\"text-decoration: none; color: $titlecolor;\">".markup_text($slide->title)."</a></div>"; echo "<div style=\"font-size: $navsize; float: right; margin: -2em 0 0 0;\">"; if(!empty($slide->logo2)) $logo2 = $slide->logo2; else $logo2 = $this->pres->logo2; @@ -272,10 +272,10 @@ function _slide(&$slide) { echo "<img src=\"$logo2\" border=\"0\"><br/>"; $offset-=2; } - echo "<a href=\"http://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php\" style=\"text-decoration: none; color: $slide->titleColor;\" onClick=\"window.open('http://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=$slidelistH,left=".($this->winW-300).",top=0'); return false\">".($this->slideNum)."/".($this->maxSlideNum)."</a></div>"; + echo "<a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php\" style=\"text-decoration: none; color: $slide->titleColor;\" onClick=\"window.open('$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]{$this->baseDir}/slidelist.php','slidelist','toolbar=no,directories=no,location=no,status=no,menubar=no,resizable=no,scrollbars=yes,width=300,height=$slidelistH,left=".($this->winW-300).",top=0'); return false\">".($this->slideNum)."/".($this->maxSlideNum)."</a></div>"; if ($this->pres->navbartopiclinks) { - echo "<div style=\"float: left; margin: -0.2em 2em 0 0; font-size: $navsize;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prev\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->prevTitle)."</a></div>"; - echo "<div style=\"float: right; margin: -0.2em 2em 0 0; color: $slide->navcolor; font-size: $navsize;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$next\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->nextTitle)."</a></div>"; + echo "<div style=\"float: left; margin: -0.2em 2em 0 0; font-size: $navsize;\"><a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prev\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->prevTitle)."</a></div>"; + echo "<div style=\"float: right; margin: -0.2em 2em 0 0; color: $slide->navcolor; font-size: $navsize;\"><a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$next\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->nextTitle)."</a></div>"; } echo '</div></div>'; break; @@ -886,7 +886,7 @@ function _presentation(&$presentation) { <!doctype html> <html> <head> -<base href="http://$_SERVER[HTTP_HOST]$this->baseDir"> +<base href="$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir"> <meta charset="utf-8"> <title>{$presentation->title}</title> </head> @@ -927,8 +927,8 @@ function _slide(&$slide) { echo "</td>\n"; if ($pres->navbartopiclinks) { echo "<td align=\"left\">"; - if($this->prevTitle) echo "<a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prev\" style=\"text-decoration: none;\"><font size=+2>Previous: ".markup_text($this->prevTitle)."</font></a></td>\n"; - if($this->nextTitle) echo "<td align=\"right\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$next\" style=\"text-decoration: none;\"><font size=+2>Next: ".markup_text($this->nextTitle)."</font></a></td>"; + if($this->prevTitle) echo "<a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prev\" style=\"text-decoration: none;\"><font size=+2>Previous: ".markup_text($this->prevTitle)."</font></a></td>\n"; + if($this->nextTitle) echo "<td align=\"right\"><a href=\"$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$next\" style=\"text-decoration: none;\"><font size=+2>Next: ".markup_text($this->nextTitle)."</font></a></td>"; } echo "<td rowspan=2 width=1>"; if(!empty($slide->logo2)) $logo2 = $slide->logo2; @@ -1718,7 +1718,7 @@ function _example(&$example) { switch($example->type) { case 'genimage': $fn = tempnam("/tmp","pres2"); - $img = file_get_contents("http://".$_SERVER['HTTP_HOST']."/".$this->baseDir.$this->slideDir.$example->filename); + $img = file_get_contents("$_SERVER[REQUEST_SCHEME]://".$_SERVER['HTTP_HOST']."/".$this->baseDir.$this->slideDir.$example->filename); $fp_out = fopen($fn,"wb"); fwrite($fp_out,$img); fclose($fp_out); diff --git a/index.php b/index.php index e202379..cd1baa2 100644 --- a/index.php +++ b/index.php @@ -102,11 +102,12 @@ function change_mode() { } </script> -<base href="http://%1"> +<base href="%2://%1"> HEAD_RAND; $HEAD_RAND = str_replace("%1", htmlspecialchars($_SERVER['HTTP_HOST']).$baseDir, $HEAD_RAND); + $HEAD_RAND = str_replace("%2", htmlspecialchars($_SERVER['REQUEST_SCHEME']), $HEAD_RAND); $TITLE = "Presentation System"; diff --git a/keyboard.js.php b/keyboard.js.php index 12688ae..c5fc7c2 100644 --- a/keyboard.js.php +++ b/keyboard.js.php @@ -28,11 +28,11 @@ function keypressHandler(e) { } currentEffect = currentEffect+1; } else if (<?php echo $this->nextSlideNum; ?>) { - top.location='<?php echo "http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/{$_SESSION['currentPres']}/$this->nextSlideNum"; ?>'; + top.location='<?php echo "$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/{$_SESSION['currentPres']}/$this->nextSlideNum"; ?>'; } } if (e == 37 && <?php echo $this->prevSlideNum+1; ?>) /* left arrow */ - top.location='<?php echo "http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/{$_SESSION['currentPres']}/$this->prevSlideNum"; ?>'; + top.location='<?php echo "$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/{$_SESSION['currentPres']}/$this->prevSlideNum"; ?>'; } window.onkeyup = keypressHandler; diff --git a/objects.php b/objects.php index 1c185f1..a557a0f 100644 --- a/objects.php +++ b/objects.php @@ -153,7 +153,7 @@ function __construct() { $this->outputbackground = '#eeee33'; $this->shadowbackground = '#777777'; $this->stylesheet = 'css.php'; - $this->logoimage1url = 'http://' . $_SERVER['HTTP_HOST'] . $baseDir; + $this->logoimage1url = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . $baseDir; $this->animate=false; } } diff --git a/show.php b/show.php index 1690414..d507eca 100644 --- a/show.php +++ b/show.php @@ -6,7 +6,7 @@ set_time_limit(0); // PDF generation can take a while if(!strlen($_SERVER['PATH_INFO'])) { - header('Location: http://'.$_SERVER['HTTP_HOST'].$baseDir); + header('Location: ' . $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$baseDir); exit; } diff --git a/slidelist.php b/slidelist.php index cbd784d..b8fcbef 100644 --- a/slidelist.php +++ b/slidelist.php @@ -37,7 +37,7 @@ function slide(url){ } $lastSection = isset($v['section']) ? $v['section'] : ''; $lastChapter = isset($v['chapter']) ? $v['chapter'] : ''; - echo "<tr><td align=right>".($k)."</td><td><a href=\"slidelist.php\" style=\"text-decoration: none;\" onClick=\"javascript:slide('http://$_SERVER[HTTP_HOST]$baseDir$showScript/$_SESSION[currentPres]/$k'); window.close();\">$spacer$v[title]</a></td></tr>\n"; + echo "<tr><td align=right>".($k)."</td><td><a href=\"slidelist.php\" style=\"text-decoration: none;\" onClick=\"javascript:slide('$_SERVER[REQUEST_SCHEME]://$_SERVER[HTTP_HOST]$baseDir$showScript/$_SESSION[currentPres]/$k'); window.close();\">$spacer$v[title]</a></td></tr>\n"; } echo "</table>\n"; ?>

« previous php.pres (#2478) next »