<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Glotzfisch.de &#187; Apache</title>
	<atom:link href="http://www.glotzfisch.de/category/web-programming/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.glotzfisch.de</link>
	<description>If something does not work out the way you want it to - try something different</description>
	<lastBuildDate>Wed, 26 May 2010 08:43:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cookies &#8211; Kekse</title>
		<link>http://www.glotzfisch.de/cookies-kekse/</link>
		<comments>http://www.glotzfisch.de/cookies-kekse/#comments</comments>
		<pubDate>Sat, 19 Jan 2008 21:27:24 +0000</pubDate>
		<dc:creator>Gabi</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Browser]]></category>

		<guid isPermaLink="false">http://www.glotzfisch.de/cookies-kekse/</guid>
		<description><![CDATA[Ok, so what do we want to do? If someone wants do download an image in fullsize, original or hires mode or requests a video in any format, a copyright message shall be displayed and the user has to click on &#8220;I accept&#8221; before he is taken to the requested file.
I elaborated on this before.
Using [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so what do we want to do? If someone wants do download an image in fullsize, original or hires mode or requests a video in any format, a copyright message shall be displayed and the user has to click on &#8220;I accept&#8221; before he is taken to the requested file.</p>
<p><a href="/copyright-message/">I elaborated on this before.</a></p>
<p>Using cookies makes it all a bit easier. When the user accepts cookies, he will not be bothered by the copyright messages for 30 days. And Apache can test on the existance of the cookie. So now the .htaccess looks like this.</p>
<pre>  ## do that only if the cookie is not set
  RewriteCond %{HTTP_COOKIE} !CopyrightCookie
  ## comes not from the copyright page
  RewriteCond %{HTTP_REFERER} !(^.*/public/copyright\.html$)
  ## comes not from itself, so has been redirected already
  RewriteCond %{HTTP_REFERER} !(^.*(jpg|tif|tiff|jpeg|mov|mp4|mpg|ram|wmv|avi)(\?.*)?$)
  ## is a request for a hires or fullres image
  RewriteCond %{REQUEST_URI} ^.*(\/original\/|\/wallpaper(1|2|3)\/|\/publication.*\/).*$
  ## then do the trick...
  RewriteRule   ^(.*)$  /public/copyright.html</pre>
<p>The copyright message sets the cookie after the user has accepted it (post to itself) and redirects the user to the requested file afterwards. So this should also work when the user has cookies disabled like in the version before.</p>
<pre>  if ($accept = $_REQUEST["accept"]) {
    # just submitted, so set the cookie
    $cvalue = "accepted";
    $cookie = setcookie("CopyrightCookie",$cvalue, time()+60*60*24*30, "/",".domain.org");
    # and redirect the user to his desired destination
    if ($target == $_SERVER["PHP_SELF"]) {
	# go back to source
	header("Location: ".$source);
    } else {
	# go to target
	header("Location: ".$target);
    }
  }</pre>
<p>and just for completeness the form:</p>
<pre>  &lt;form name="copyright" action="&lt;?=$_SERVER["PHP_SELF"]?&gt;" method="post"&gt;
  &lt;input type="hidden" name="target" value="&lt;?=$target?&gt;"&gt;
  &lt;input type="hidden" name="source" value="&lt;?=$source?&gt;"&gt;
  &lt;input type="hidden" name="accept" value="1"&gt;
  &lt;input type="button" value="I accept the conditions" class="button_yes"
         onClick="document.forms[1].submit();"&gt;
  &lt;input type="button" value="I do not accept the conditions" class="button_no"
         onClick="location.href='&lt;?=$source?&gt;';"&gt;
  &lt;/form&gt;</pre>
<p>There are some problems concerning video though:</p>
<ul>
<li> when using Firefox on Windows and requesting a wmv file, the copyright notice is displayed and accepted. Afterwards, Windows Media Player opens and tries to access the file which is denied as <strong>WMP uses of course the cookies set by Internet Explorer</strong>. As we browsed to the site using FF, WMP is not working here. 2 Possibilities:
<ul>
<li> right-click the file and save as&#8230; and then play it</li>
<li> or browse to the site with IE and accept the cookie here&#8230;</li>
</ul>
</li>
<li> Cookies are not evaluated when doing a right-click-save-as. So you&#8217;ll probably always get the copyright.html when trying to download a file&#8230; So I&#8217;ll have to get back to my slogan: try something different&#8230;</li>
</ul>
<p>(does anyone have a better idea?) To make things worse, Safari won&#8217;t let you download an MPG file. When clicking on it, it displays fine with Quicktime inside the browser but when &#8220;right-clicking&#8221; and trying to download it, it just downloads the copyright notice again. So it seems it does not do the cookie check here. This really drives me nuts&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.glotzfisch.de/cookies-kekse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copyright Message</title>
		<link>http://www.glotzfisch.de/copyright-message/</link>
		<comments>http://www.glotzfisch.de/copyright-message/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 21:57:09 +0000</pubDate>
		<dc:creator>Gabi</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.glotzfisch.de/copyright-message/</guid>
		<description><![CDATA[Rewrite copyrighted images to first display the copyright note: (see also SettingCookies for Version 2.0 ;-)) in the .htaccess file:
 RewriteEngine On

 ## comes not from the copyright page
 RewriteCond %{HTTP_REFERER} !(^.*/public/copyright\.html$)
 ## comes not from itself, so has been redirected already, optional query string
 RewriteCond %{HTTP_REFERER} !(^.*(jpg&#124;tif&#124;tiff&#124;jpeg&#124;mov&#124;mp4&#124;mpg&#124;ram)(\?.*)?$)
 ## is a request for a hires [...]]]></description>
			<content:encoded><![CDATA[<p>Rewrite copyrighted images to first display the copyright note: (see also <a href="/cookies-kekse/">SettingCookies</a> for Version 2.0 ;-)) in the .htaccess file:</p>
<pre> RewriteEngine On

 ## comes not from the copyright page
 RewriteCond %{HTTP_REFERER} !(^.*/public/copyright\.html$)
 ## comes not from itself, so has been redirected already, optional query string
 RewriteCond %{HTTP_REFERER} !(^.*(jpg|tif|tiff|jpeg|mov|mp4|mpg|ram)(\?.*)?$)
 ## is a request for a hires or fullres image
 RewriteCond %{REQUEST_URI} ^.*(fullres|highres|hires|\/video\/).*$
 ## then do the trick...
 RewriteRule   ^(.*)$  /public/copyright.html</pre>
<p><strong>und copyright.html:</strong></p>
<pre> if (!$target = $_REQUEST["target"]) {
  # we are coming via the rewrite rule, so the image to be shown is in the URI!
  $target = $_SERVER["REQUEST_URI"];
 }
 $source = $_SERVER["HTTP_REFERER"];

 # SAFARI HACK (caching), we have been here before... prevent caching
 if (stristr($_SERVER["HTTP_USER_AGENT"],'Safari')) {
  if (!$querystring = stristr($target,'?')) {
	$target = $target."?img=show";
  } else {
	$target = $target."&amp;img=show";
  }
 }

 [...]
 &lt;a href="&lt;?=$target?&gt;" class="button_yes"&gt;I accept the conditions&lt;/a&gt;
 &lt;a href="&lt;?=$source?&gt;" class="button_no"&gt;I do not accept the conditions&lt;/a&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.glotzfisch.de/copyright-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mixed .htaccess</title>
		<link>http://www.glotzfisch.de/15/</link>
		<comments>http://www.glotzfisch.de/15/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 21:46:38 +0000</pubDate>
		<dc:creator>Gabi</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://www.glotzfisch.de/copyright-message/</guid>
		<description><![CDATA[Beispiel: .htaccess-Datei

 # .htaccess-Datei für Web-Verzeichnis /service
 AuthType Basic
 AuthName "Service-Bereich"
 AuthUserFile /usr/verwaltung/web/.htusers
 Require valid-user
 Order deny,allow
 Deny from all
 Allow from 192.168
 Satisfy any
Erläuterung:
In diesem Beispiel wird Require zusammen mit Allow from und Deny from verwendet. Die Anweisung Satisfy gibt an, welche der Bedingungen erfüllt sein müssen. Das Schlüsselwort any bedeutet, dass alle Benutzer [...]]]></description>
			<content:encoded><![CDATA[<p>Beispiel: .htaccess-Datei</p>
<pre>
 # .htaccess-Datei für Web-Verzeichnis /service
 AuthType Basic
 AuthName "Service-Bereich"
 AuthUserFile /usr/verwaltung/web/.htusers
 Require valid-user
 Order deny,allow
 Deny from all
 Allow from 192.168
 Satisfy any</pre>
<h3>Erläuterung:</h3>
<p>In diesem Beispiel wird Require zusammen mit Allow from und Deny from verwendet. Die Anweisung Satisfy gibt an, welche der Bedingungen erfüllt sein müssen. Das Schlüsselwort any bedeutet, dass alle Benutzer mit einer numerischen IP im Bereich 192.168 automatisch zugelassen sind. Benutzer, die nicht von dort kommen, werden nach einem Benutzernamen und Passwort gefragt (&#8220;Oder&#8221;-Verknüpfung der beiden Bedingungen). Hingegen würde das Schlüsselwort all bedeuten, dass nur Benutzer mit einer IP aus dem Bereich 192.168 und einem gültigen Benutzernamen zugelassen sind (&#8220;Und&#8221;-Verknüpfung der beiden Bedingungen).</p>
<p>Source: <a href="http://de.selfhtml.org/servercgi/server/htaccess.htm" class="urllink">http://de.selfhtml.org/servercgi/server/htaccess.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.glotzfisch.de/15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
