Compare commits

..

No commits in common. "ff07893501cb63c5e92d93375742bd39ed9b849d" and "a60988f46805fbf3f8d31bb3e723830e4d3ae21e" have entirely different histories.

4 changed files with 20 additions and 119 deletions

View File

@ -9,7 +9,7 @@
preg_match("/^[a-z0-9\-]*$/", $page, $matches); // SECURITY: Only lowercase a-z + numbers + - preg_match("/^[a-z0-9\-]*$/", $page, $matches); // SECURITY: Only lowercase a-z + numbers + -
if (!$matches) if (!$matches)
$page=HOME_PAGE; $page=HOME_PAGE;
$page=substr($page, 0, 16); // SECURITY: Max 16 chars $page=substr($page, 0, 12); // SECURITY: Max 12 chars
} }
else { else {
$page=HOME_PAGE; $page=HOME_PAGE;
@ -19,33 +19,7 @@
$pageUrl="p/404.php"; $pageUrl="p/404.php";
$pageTitle = "Error 404"; $pageTitle = "Error 404";
} }
// --- $page and $pageUrl are now SAFE TO USE
$optin = "";
if (isset($_GET['optin-once'])) {
$_COOKIE['opt-in'] = $_GET['optin-once'];
}
if (isset($_COOKIE['opt-in'])) {
$opt = $_COOKIE['opt-in'];
if (strlen($opt) <= 8) {
preg_match("/^[a-z0-9\-]*$/", $opt, $matches);
if ($matches) {
if (isset($_GET['optout'])) {
$opt = str_replace($_GET['optout'], '', $opt);
}
$optin = $opt;
}
}
}
if (isset($_GET['optin'])) {
if ((strlen($_GET['optin']) == 1) && !opted_in($_GET['optin'])) {
$optin .= $_GET['optin'];
}
}
if (isset($_GET['optout']) || isset($_GET['optin'])) {
setcookie('opt-in', $optin, strtotime("+1 year"));
}
// --- $page, $pageUrl and $optin are now SAFE TO USE
$htmlHead = ""; $htmlHead = "";
@ -81,8 +55,8 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=700px, initial-scale=.5"><!-- or width=device-width --> <meta name="viewport" content="width=700px, initial-scale=.5"><!-- or width=device-width -->
' . $htmlHead . ' ' . $htmlHead . '
<link rel="stylesheet" type="text/css" href="/style.css" /> <link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="/userstyle.css" /> <link rel="stylesheet" type="text/css" href="userstyle.css" />
</head>' . $output; </head>' . $output;
return $output; return $output;
}); });
@ -116,7 +90,7 @@
</div> </div>
</content> </content>
<div id="footer"> <div id="footer">
Copyright <?php echo PAGE_AUTHOR; ?><!-- and <a href="/?p=extcontent">others</a>--> | <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/us/"><img style="position:relative;top:4px;opacity:0.75;" src="/img/cc-byncsa.png"></a> | <a href="/?p=contact#privacy">Privacy Policy</a> | <?php echo date("Y"); ?> Copyright <?php echo PAGE_AUTHOR; ?><!-- and <a href="/?p=extcontent">others</a>--> | <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/us/"><img style="position:relative;top:4px;opacity:0.75;" src="/img/cc-byncsa.png"></a> | <?php echo date("Y"); ?>
</div> </div>
</div> </div>
</body> </body>

View File

@ -1,4 +0,0 @@
<?php
if (!isset($CMS_ACTIVE)) exit();
require_once "privacy-controls.php";
?>

View File

@ -1,34 +0,0 @@
<?php
if (!isset($CMS_ACTIVE)) exit();
require_once "shared.php";
?>
<h1>Privacy Control Panel</h1>
<h2>What is this?</h2>
<p>
This page allows you to configure your privacy preferences for the site. For more information about our privacy policy, please click <a href="/?p=contact#privacy">here</a>.
</p>
<h2>External content</h2>
<p>
Here, you can allow the site to automatically load content from external sources. Please note that this means that the enabled sites are able to track your behavior, even when just visiting this site.
</p>
<p>
These preferences are saved using a cookie with a validity period of one year. This means, after one year, you will have to refresh your consent.
</p>
<p>
<table border=1>
<tr><td>Content</td><td>Status</td><td>Change</td></tr>
<tr>
<td><strong>Automatically load embedded YouTube videos</strong></td>
<?php
if (opted_in('y')) {
echo '<td style="color:orange;">Enabled</td><td><a href="/?p=privacy-controls&optout=y">opt out</a></td>';
} else {
echo '<td style="color:blue;">Disabled</td><td><a href="/?p=privacy-controls&optin=y">opt in</a></td>';
}
?>
</tr>
<table>
</p>

View File

@ -29,21 +29,6 @@
$blogDirs = array("2017"); $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. * This function will include an image as figure.
* returns : Number of the figure for later referencing. * returns : Number of the figure for later referencing.
@ -116,29 +101,9 @@
$counters['video'] = 1; $counters['video'] = 1;
function includeVideo($url, $title="", $width=640) { function includeVideo($url, $title="", $width=640) {
global $counters; 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];
}
echo '<videoframe><div class="videoframe" style="width:' . $width . 'px;height:' . $width*9/16 . 'px">';
if (isset($youtube)) {
if (opted_in('y')) {
echo '<iframe width="100%" height="100%" src="' . $url . '" frameborder="0" allowfullscreen></iframe>';
} else {
echo "<table border=0 style='height:100%;width:100%'><tr><td style='text-align:center;'>Embedded content has been disabled to protect your privacy.<br><br><br><strong><a href='" . append_param("optin-once=y") . "'>Click here to load the videos on this site once,</a></strong><br><br><strong><a href='/?p=privacy-controls'>or click here to allow them permanently,</a><br><br><a href=\"" . $youtube['link'] . "\">" . "or click here to watch the video on YouTube:<br>" . $youtube['link'] . "</a></strong><br><br><br>Please note that by enabling this video, data is transferred <br>to YouTube LLC, and is subject to their privacy policy.</td></tr></table>";
}
} else {
// TODO: HTML5 video // TODO: HTML5 video
echo "SERVER ERROR: Video format not supported."; echo '<videoframe><div class="videoframe" style="width:' . $width . 'px;height:' . $width*9/16 . 'px">';
} echo '<iframe width="100%" height="100%" src="' . $url . '" frameborder="0" allowfullscreen></iframe>';
echo '</div></videoframe>'; echo '</div></videoframe>';
if ($title != "") { if ($title != "") {
echo '<vidcaption>Video ' . $counters['video'] . ". $title</vidcaption>"; echo '<vidcaption>Video ' . $counters['video'] . ". $title</vidcaption>";