<div dir="ltr">Many thanks, I really had no idea and this is really strange as the function used to work when I was using it a while ago.<div><br></div><div>In any case, you're the boss, it solved it.</div><div><br></div><div>Cheers,</div><div><br></div><div>Philippe</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 13 Nov 2019 at 19:38, Petko Yotov <<a href="mailto:5ko@5ko.fr">5ko@5ko.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">You have a function placed inside another function, so when the outer <br>
function is called for a second time, it tries to redefine the inner <br>
function again. This is forbidden, and if you check your error log, you <br>
will see something like:<br>
<br>
   Fatal error: Cannot redeclare UR_exists() (previously declared<br>
   in popbox.php:173) in popbox.php on line 173<br>
<br>
Just place the UR_exists(){...} function before or after the <br>
PopBox(){...} function.<br>
<br>
Petko<br>
<br>
On 09/11/2019 10:20, Philippe Krait wrote:<br>
> Hi,<br>
> <br>
> I have a very bizarre side effect from a custom markup, and the most<br>
> bizarre is that it is a "new" problem in the sense that it has worked<br>
> in the past (I can't remember under which PmWiki version it worked<br>
> last, though).<br>
> <br>
> The bizarre thing is that when, on a page, I invoke the custom markup<br>
> the second time, it prevents the save from working, the page stays<br>
> blank and does not reload. I am pretty sure that this is the cause,<br>
> because I went to some very old pages with the markup, and the pages<br>
> with only one instance of the markup load perfectly, but old pages<br>
> with two or more instances of the markup do not load anymore !<br>
> <br>
> I have no idea what might be causing this as I am not that good at<br>
> programming and at PHP in particular, but I have copied the code of<br>
> the recipe below. My apologies for the probably very badly written<br>
> code.<br>
> <br>
> Note that it's based on this:<br>
> <a href="http://ajaxian.com/archives/popbox-a-javascript-image-magnifier" rel="noreferrer" target="_blank">http://ajaxian.com/archives/popbox-a-javascript-image-magnifier</a> but I<br>
> am not sure how it's relevant to the issue... Note that I am using a<br>
> very old version of the script, do you think it might be the reason ?<br>
> <br>
> Can anyone please help me solve this mystery ?<br>
> <br>
> Thanks in advance,<br>
> <br>
> Philippe<br>
> <br>
> ========================================================<br>
> <br>
> <?php if (!defined('PmWiki')) exit();<br>
> /*  Copyright 2010 Philippe Krait (<a href="mailto:philippe@krait.net" target="_blank">philippe@krait.net</a>)<br>
> <br>
>     This script activates the (:popbox ...:) markup.<br>
> <br>
>     To activate this script, copy it into the cookbook/ directory,<br>
>     then add the following line to your local/config.php:<br>
> <br>
>         include_once('cookbook/popbox.php');<br>
> */<br>
> <br>
> # Creates the Markup<br>
> #Markup('popbox','fulltext', '/\\(:popbox(\\s.*?)?:\\)/e',<br>
> "Keep(PopBox(PSS('$1')))");<br>
> Markup_e('popbox','fulltext', '/\\(:popbox(\\s.*?)?:\\)/',<br>
> "Keep(PopBox(\$m[1]))");<br>
> <br>
> # Defines where the javascript, css and images are<br>
> SDV($popBoxDirUrl,$PubDirUrl."/cookbook/popBox");<br>
> <br>
> SDV($HTMLHeaderFmt['popboxjava'] , "<script<br>
> src='$popBoxDirUrl/scripts/PopBox.js' type='text/javascript'></script><br>
> <script type='text/javascript'><br>
> popBoxWaitImage.src = '$popBoxDirUrl/images/spinner40.gif';<br>
> popBoxRevertImage = '$popBoxDirUrl/images/magminus.gif';<br>
> popBoxPopImage = '$popBoxDirUrl/images/magplus.gif';<br>
> </script>");<br>
> <br>
> function PopBox($attr) {<br>
> $EnablePathInfo = 1;<br>
> <br>
> $attr = preg_replace('/ *([a-zA-Z]=)([^\']\\S*)/',"&\$1\$2",$attr);<br>
> $attr = substr($attr,1);<br>
> $el = explode("&", $attr);<br>
> <br>
> $Header = "";<br>
> $Tailer = "";<br>
> <br>
> $Img =<br>
> "http://".$_SERVER['SERVER_NAME']."/pmwiki/uploads/Main/Images/Unknown.jpg";<br>
> $ImgPath = "";<br>
> $ImgDir =<br>
> "http://".$_SERVER['SERVER_NAME']."/pmwiki/uploads/Main/Images";<br>
> $ImgType = "";<br>
> $ImgName = "";<br>
> $ImgFormat = "jpg";<br>
> <br>
> $size = 250;<br>
> $title = 'Click to magnify/shrink';<br>
> $caption = 'Caption';<br>
> $align = '';<br>
> # $command = 'onmouseover';<br>
> $command = 'onclick';<br>
> <br>
> $startX = "startpos.x";<br>
> $startY = "startpos.y";<br>
> # The newLeft and newTop parameters are treated by default as<br>
> positions relative to the image starting point and can be either a<br>
> negative or positive number.<br>
> # If either value is a numeric string followed by an upper case "A"<br>
> then it is treated as an absolute position, relative to its containing<br>
> element (typically the browser window).<br>
> # Ex: "200A". If either value is null the image will be centered in<br>
> the browser window.<br>
> $endX = "null";<br>
> $endY = "null";<br>
> <br>
> $startW = "startpos.w";<br>
> $startH = "startpos.h";<br>
> # If the newWidth value is 0 the full width of the image will be used<br>
> up to a maximum of the browser window width.<br>
> # If the newWidth value is  null the full size of the image will be<br>
> used regardless of the browser window width.<br>
> # Passing either 0 or null will still scale the image against the<br>
> image height. An integer greater than 0 will not be scaled.<br>
> $endW = 0;<br>
> # If the newHeight value is 0 the full height of the image will be<br>
> used up to a maximum of the browser window height.<br>
> # If the newHeight value is  null the full size of the image will be<br>
> used regardless of the browser window height.<br>
> # Passing either 0 or null will still scale the image against the<br>
> image width. An integer greater than 0 will not be scaled.<br>
> $endH = 0;<br>
> <br>
> $sM = 100;<br>
> $sS = 100;<br>
> <br>
> $RevertBarAbove = "true";<br>
> $CaptionBelow = "true";<br>
> <br>
> $Style = "PopBoxImageLarge";<br>
> <br>
> foreach ($el as $k => $v) {<br>
> $cpl = explode("=", $v);<br>
> switch ($cpl[0]) {<br>
> case "A":<br>
> case "a":<br>
> <br>
> global $pagename, $UploadUrlFmt, $EnablePathInfo;<br>
> <br>
> $attpage = $pagename;<br>
> $path = str_replace(array('"', ' '), array('', '%20'), $cpl[1]);<br>
> <br>
> if (preg_match('!^(.*)/([^/]+)$!', $path, $match)) {<br>
> $attpage = MakePageName($attpage, $match[1]);<br>
> $path = $match[2];<br>
> }<br>
> <br>
> # if ($EnablePathInfo)<br>
> $attpage=str_replace(".", "/", $attpage);<br>
> <br>
> #echo $EnablePathInfo."<br>\n";<br>
> #echo $UploadUrlFmt."<br>\n";<br>
> #echo $attpage."<br>\n";<br>
> #echo $path."<br>\n";<br>
> <br>
> $ImgPath = FmtPageName("$UploadUrlFmt/$attpage/$path", $attpage);<br>
> #echo $ImgPath."<br>\n";<br>
> break;<br>
> case "I":<br>
> case "i":<br>
> $ImgPath = str_replace(array('"', ' '), array('', '%20'), $cpl[1]);<br>
> break;<br>
> case "T":<br>
> case "t":<br>
> $ImgType = str_replace('"', '', $cpl[1]);<br>
> break;<br>
> case "N":<br>
> case "n":<br>
> $ImgName = str_replace(array('"', ' '), array('', '%20'), $cpl[1]);<br>
> break;<br>
> case "F":<br>
> case "f":<br>
> $ImgFormat = str_replace('"', '', $cpl[1]);<br>
> break;<br>
> case "S":<br>
> case "s":<br>
> $size = str_replace('"', '', $cpl[1]);<br>
> break;<br>
> case "C":<br>
> case "c":<br>
> $caption = str_replace('"', '', $cpl[1]);<br>
> break;<br>
> case "P":<br>
> case "p":<br>
> $assignformat=array( "lfloat" => "lfloat", "rfloat" => "rfloat",<br>
> "lframe" => "lfloat frame", "rframe" => "rfloat frame",<br>
> "lfloatclear" => "lfloat lclear", "rfloatclear" => "rfloat rclear",<br>
> "lframeclear" => "lfloat frame lclear", "rframeclear" => "rfloat frame<br>
> rclear", );<br>
> <br>
> switch (str_replace('"', '', $cpl[1])) {<br>
> case "left": case "Left": case "LEFT":<br>
> case "right": case "Right": case "RIGHT":<br>
> $Header = "<div style='text-align: ".strtolower($cpl[1]).";'>";<br>
> $Tailer = "</div>";<br>
> break;<br>
> case "lfloat": case "Lfloat": case "LFloat": case "LFLOAT":<br>
> case "rfloat": case "Rfloat": case "RFloat": case "RFLOAT":<br>
> case "lfloatclear": case "Lfloatclear": case "LFloatClear": case<br>
> "LFLOATCLEAR":<br>
> case "rfloatclear": case "Rfloatclear": case "RFloatClear": case<br>
> "RFLOATCLEAR":<br>
> $Header = "<div class='".$assignformat[strtolower(str_replace('"', '',<br>
> $cpl[1]))]."' style='text-align: center;'>";<br>
> $Tailer = "</div>";<br>
> break;<br>
> case "lframe": case "Lframe": case "LFrame": case "LFRAME":<br>
> case "rframe": case "Rframe": case "RFrame": case "RFRAME":<br>
> case "lframeclear": case "Lframeclear": case "LFrameClear": case<br>
> "LFRAMECLEAR":<br>
> case "rframeclear": case "Rframeclear": case "RFrameClear": case<br>
> "RFRAMECLEAR":<br>
> $Header = "<div class='".$assignformat[strtolower(str_replace('"', '',<br>
> $cpl[1]))]."' style='text-align: center;'>";<br>
> $Tailer = "<br /><strong><em>$caption</em></strong></div>";<br>
> break;<br>
> case "note": case "Note": case "NOTE":<br>
> $Header = "<table class='widenote'><tr><td<br>
> class='noteheader'>$caption</td></tr><tr><td>";<br>
> $Tailer = "</td></tr></table>";<br>
> break;<br>
> }<br>
> break;<br>
> }<br>
> }<br>
> <br>
> $ImgPath = "$ImgPath.$ImgFormat";<br>
> <br>
> #echo "Path: |".$ImgPath."|<br>\n";<br>
> <br>
>         function UR_exists($uri) {<br>
>             $ch = curl_init($uri);<br>
>             curl_setopt($ch, CURLOPT_NOBODY, true);<br>
>             curl_exec($ch);<br>
>             $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);<br>
>             curl_close($ch);<br>
> <br>
>             return $code == 200;<br>
>         }<br>
> <br>
> if (UR_exists($ImgPath)) $Img = $ImgPath;<br>
> else $caption = "Unknown Image ! ".$caption;<br>
> <br>
> return "$Header<br>
> <img src='$Img' pbsrc='$Img' title='$title' pbCaption='$caption'<br>
> $command=' var startPos = GetElementPosition(this);<br>
> popBoxRevertBarAbove=$RevertBarAbove;<br>
> popBoxCaptionBelow=$CaptionBelow;<br>
> PopEx(this, $endX, $endY, $endW, $endH, $sM,\"$Style\");'<br>
> alt='' width='".$size."px' $align  /><br>
> $Tailer";<br>
> }<br>
> <br>
> ?><br>
> _______________________________________________<br>
> pmwiki-users mailing list<br>
> <a href="mailto:pmwiki-users@pmichaud.com" target="_blank">pmwiki-users@pmichaud.com</a><br>
> <a href="http://www.pmichaud.com/mailman/listinfo/pmwiki-users" rel="noreferrer" target="_blank">http://www.pmichaud.com/mailman/listinfo/pmwiki-users</a><br>
</blockquote></div>