"Page A", "link" => "?p=00-template", "highlight" => "related-subpages,00-template"), array("label" => "Page B", "link" => "?p=404", "highlight" => "404"), array("label" => "Repository", "link" => "https://git.notsyncing.net:8080", "highlight" => ""), array("label" => "Contact", "link" => "?p=00-template", "highlight" => "") ); $blogDirs = array("2017"); function opted_in($identifier) { global $optin; return (stripos($optin, $identifier) !== false); } function append_param($p) { $url = $_SERVER['REQUEST_URI']; if (stripos($url, "?") !== false) $url .= "&"; else $url .= "?"; $url .= $p; return $url; } /* * This function will include an image as figure. * returns : Number of the figure for later referencing. * $title : Image title, will be prefixed with Figure n. * $path : If $path starts with http or / it will be * treated as an absolute path and no downscaled preview will be rendered. * Other paths will be prefixed with /b/img. * $preview : When set to "", no preview will be generated. Otherwise the specified * path will be used. * $link : Link to follow when clicking the image. Default is the full resolution image. */ $counters['figure'] = 1; function includeGraphics($title, $path, $preview="+", $style="", $link="+") { global $blogentry; global $counters; $title = "Figure " . $counters['figure'] . ". $title"; // TODO: External image if (substr($path, 0, 4) == "http" || $path[0] == "/") { $preview=""; $spath=$path; } else { $spath = POSTS_BASE . "img/" . $path; $fpath = $_SERVER['DOCUMENT_ROOT'] . $spath; } if ($preview == "+") { $previewPath = POSTS_BASE . "pimg/" . str_replace("/", "_", $path); $fpreviewPath = $_SERVER['DOCUMENT_ROOT'] . $previewPath; if (!file_exists($fpreviewPath)) { preg_match("/^[A-Za-z_\.\-0-9\/]*$/", $fpath, $matches); // SANITIZED! if (!$matches) { echo "

SERVER ERROR: Image not valid!

"; return ; } $page=substr($page,0,12); // SECURITY: Max 12 chars exec("gm convert '$fpath' -resize 640 '$fpreviewPath';"); } } elseif ($preview == "") { $previewPath = $spath; } else { $previewPath = $preview; } if ($link == "+") $link = $spath; echo '
' . $title . '
'; return $counters['figure']++; } /* * This function will include a video. * returns : Number of the video for later referencing. * $url : URL of the video. Autodetects YouTube. Otherwise HTML5 video. * $title : Display "Video n. $title" below the video. * $width : Width of the player */ $counters['video'] = 1; function includeVideo($url, $title="", $width=640) { global $counters; $vlink = "NULL"; preg_match("/.*youtube.com\/embed\/(.*)$/", $url, $matches); if (!$matches) preg_match("/.*youtube.com\/watch\?v=([^&]*).*$/", $url, $matches); if ($matches) { $youtube['embed'] = "https://www.youtube.com/embed/" . $matches[1]; $youtube['link'] = "https://www.youtube.com/watch?v=" . $matches[1]; $youtube['vid'] = $matches[1]; } echo '
'; if (isset($youtube)) { if (opted_in('y')) { echo ''; } else { echo "
Embedded content has been disabled to protect your privacy.




or click here to allow them permanently,

" . "or click here to watch the video on YouTube:
" . $youtube['link'] . "



Please note that, by enabling this video, data is transferred
to YouTube LLC, and is subject to their privacy policy.
"; } } else { // TODO: HTML5 video echo "SERVER ERROR: Video format not supported."; } echo '
'; if ($title != "") { echo 'Video ' . $counters['video'] . ". $title"; } return $counters['video']++; } /* * This function will add a reference * returns : Number of the source for later referencing * $url : URL of the source, if its a number it will not create a new entry. */ $meta['sources'] = array(); $counters['sources'] = 1; function addSource($url, $text="") { global $counters; global $meta; if ("$text" != "") $text .= " "; if (is_numeric($url)) { echo "[" . $url . "]"; return $url; } else { // Check whether source already exists $i = 1; foreach ($meta['sources'] as $v) { if ($v == $url) { echo "" . $text . "[" . $i . "]"; return $i; } $i++; } // If not found, then add $meta['sources'][$counters['sources']] = $url; echo "" . $text . "[" . $counters['sources'] . "]"; return $counters['sources']++; } } function getServerUrl() { $temp = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $temp .= PAGE_URL; return $temp; } ?>