<?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>Roger Davies &#187; Strange Ideas</title>
	<atom:link href="http://www.rogerdavies.com/category/strange-ideas/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rogerdavies.com</link>
	<description>The Ramblings of a Weirdo</description>
	<lastBuildDate>Sun, 13 Jun 2010 23:28:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To Hack Half Life 2 To Play With The Portal Gun</title>
		<link>http://www.rogerdavies.com/2009/08/how-to-hack-half-life-2-to-play-with-the-portal-gun/</link>
		<comments>http://www.rogerdavies.com/2009/08/how-to-hack-half-life-2-to-play-with-the-portal-gun/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 10:29:49 +0000</pubDate>
		<dc:creator>Roger Davies</dc:creator>
				<category><![CDATA[Strange Ideas]]></category>
		<category><![CDATA[Techno Babble]]></category>

		<guid isPermaLink="false">http://www.rogerdavies.com/?p=3507</guid>
		<description><![CDATA[&#160;
If like me you adored the game Portal and loved Half Life, then I the idea of using the Portal Gun in Half Life 2 must seem like a wet dream.  Well, I got news for you  &#8230; this is no dream! You can quite easily and quickly hack Half Life 2 to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rogerdavies.com/wp-content/uploads/2009/08/hl2-2009-08-29-11-01-36-89.jpg"><img class="alignleft size-medium wp-image-3517" title="Half Life Portal Gun" src="http://www.rogerdavies.com/wp-content/uploads/2009/08/hl2-2009-08-29-11-01-36-89-300x225.jpg" alt="Half Life Portal Gun" width="204" height="152" /></a><a href="http://www.rogerdavies.com/wp-content/uploads/2009/08/hl2-2009-08-29-10-59-26-48.jpg"><img class="alignleft size-medium wp-image-3519" title="Half Life 2 Portal Gun" src="http://www.rogerdavies.com/wp-content/uploads/2009/08/hl2-2009-08-29-10-59-26-48-300x225.jpg" alt="Half Life 2 Portal Gun" width="203" height="151" /></a></p>
<div style="float:none;clear:both">&nbsp;</div>
<p>If like me you adored the game <strong>Portal</strong> and loved <strong>Half Life</strong>, then I the idea of using the Portal Gun in Half Life 2 must seem like a wet dream.  Well, I got news for you  &#8230; <strong>this is no dream!</strong> You can quite easily and quickly hack Half Life 2 to play with the Portal Gun.  Here’s how&#8230;</p>
<blockquote><p>
Proceed with caution : While this is a fairly straight forward operation, I nor valve can be held responsible for anything that goes wrong.  Please follow instructions carefully.
</p></blockquote>
<p><strong><em>N.B. Be sure to back up everything from your ‘Steam\SteamApps\Portal’ Folder!!!</em></strong></p>
<ul>
<li>Firstly, download and install <a href="http://nemesis.thewavelength.net/index.php?p=26">GCFScape</a> if you don’t have it already.</li>
<li>Run <strong>GCFScape</strong> and click <span style="text-decoration: underline;">F</span>ile » <span style="text-decoration: underline;">O</span>pen and locate your <strong>Steam</strong> folder (For instance, C:\Program Files\valve\Steam\SteamApps\ and select the file ‘<strong>half-life 2 content.gcf</strong>’</li>
<li><strong>Right Click</strong> on the <strong>hl2</strong> folder, and <strong>extract</strong> this folder to the &lt;VALVE FOLDER&gt;\Steam\SteamApps\&lt;username&gt;\Portal\Portal folder (for instance, mine is C:\Program Files\valve\Steam\SteamApps\fraj\Portal\Portal</li>
<li>Follow the same step as above with the <strong>reslists</strong> folder, extracting to the same \SteamApps\Portal\Portal folder.</li>
</ul>
<p>You should now be able to start <strong>Portal</strong> and you will have successfully imported all the Half Life 2 content and levels.  Be sure to start the program with <strong>-dev -console</strong> parameters, (set these by right-clicking on <strong>Portal</strong> in your <strong>My Games</strong> section, then clicking <strong>properties</strong> and &lsquo;Set Launch Options&#8230;&rsquo;.  When you start the game press the twiddle key <strong>~</strong> to bring up the console, and enter: <strong>sv_cheats 1</strong> (this will activate cheats).</p>
<p>You should now be able to use the command <strong>MAP &lt;mapname&gt;</strong> to begin any of the <strong>Half Life 2</strong> levels with the <strong>Portal Gun!</strong> (to give yourself all weapons and ammo, use <strong>impulse 101</strong> &#8211; this is important because of course Half Life 2 does not contain the Portal Gun normally!).  For instance : Try &#8220;map d1_canals_01&#8243;</p>
<p>The complete list of Half Life 2 Level codes are as follows:</p>
<table border="0">
<colgroup>
<col></col>
<col></col>
</colgroup>
<thead>
<tr style="background-color:#dedede">
<th>Map Code</th>
<th>Loaction</th>
</tr>
</thead>
<tbody>
<tr style="background-color:#aaa">
<td>d1_canals_01</td>
<td>Spawns you in the canals.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_town_01</td>
<td>Spawns you in Ravenholm</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_trainstation_01</td>
<td>Spawns you in train station</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_under_01</td>
<td>Spawns you in lab</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_coast_01</td>
<td>Spawns you on the coast (Vehicle)</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_prison_01</td>
<td>Spawns you in Nova Prospekt</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_c17_01</td>
<td>Spawns you in the city 17 rebellion</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_canals_02</td>
<td>Spawns you deeper in the canals.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_under_02</td>
<td>Spawns you in the lab chapter after the second load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_trainstation_05</td>
<td>Spawns in the train station after the third load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_trainstation_03</td>
<td>Spawns in the train station after the second load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_trainstation_02</td>
<td>Spawns you in train station after the first load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_town_05</td>
<td>Spawns you near the end of Ravenholm.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_town_04</td>
<td>Spawns you in Ravenholm after the third load point area.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_town_03</td>
<td>Spawns you in Ravenholm after the second load point area.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_town_02</td>
<td>Spawns you in Ravenholm after the first load point area.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_canals_end</td>
<td>Spawns you near the end of the canals.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_under_03</td>
<td>Spawns you in the lab chapter after the third load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_under_04</td>
<td>Spawn the lab chapter near the end.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_coast_02</td>
<td>Spawns you in the coast area after the first load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_coast_03</td>
<td>Spawns you in the coast area after the second load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_coast_04</td>
<td>Spawns you in the coast area after the third load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_coast_05</td>
<td>Spawns you in the coast area after the fourth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_coast_06</td>
<td>Spawns you in the coast area after the fifth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_coast_07</td>
<td>Spawns you in the coast area after the sixth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_coast_08</td>
<td>Spawns you in the coast area near the end of it.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_prison_02</td>
<td>Spawns you in Nova Prospekt after the first load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_prison_03</td>
<td>Spawns you in Nova Prospekt after the second load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_prison_05</td>
<td>Spawns you in Nova Prospekt near the end of the level.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_prison_04</td>
<td>Spawns you in Nova Prospekt after the third load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_coast_09</td>
<td>Spawns you in the coast area after the eighth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_coast_10</td>
<td>Spawns you in the coast area after the ninth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_coast_11</td>
<td>Spawns you in the coast area after the tenth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_coast_12</td>
<td>Spawns you near the end of the coast area.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_canals_03</td>
<td>Spawns in you in the canals after the second load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_canals_04</td>
<td>Spawns in you in the canals after the third load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_canals_05</td>
<td>Spawns in you in the canals after the fourth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_canals_06</td>
<td>Spawns in you in the canals after the fifth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_canals_07</td>
<td>Spawns in you in the canals after the sixth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_canal_08</td>
<td>Spawns in you in the canals after the seventh load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_canal_09</td>
<td>Spawns in you in the canals after the eighth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_canal_10</td>
<td>Spawns in you in the canals after the ninth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_canals_11</td>
<td>Spawns in you in the canals after the tenth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_canals_12</td>
<td>Spawns in you in the canals after the eleventh load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_canals_13</td>
<td>Spawns in you in the canals close to the end.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_c17_04</td>
<td>Spawns you in City 17 after the third load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_c17_03</td>
<td>Spawns you in City 17 after the second load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_c17_02</td>
<td>Spawns you in City 17 after the first load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_citadel_05</td>
<td>Spawns you at the end of the Citadel.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_citadel_04</td>
<td>Spawns you after the third load point in the Citadel.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_citadel_03</td>
<td>Spawns you after the second load point in the Citadel.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_citadel_02</td>
<td>Spawns you after the first load point in the Citadel.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_citadel_01</td>
<td>Spawns you near the beginning of the Citadel.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_prison_08</td>
<td>Spawns you near the end of Nova Prospekt.</td>
</tr>
<tr style="background-color:#aaa">
<td>d2_prison_07</td>
<td>Spawns you in Nova Prospekt after the sixth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d2_prison_06</td>
<td>Spawns you in Nova Prospekt after the fifth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_trainstation_06</td>
<td>Spawns you near the end of the train station.</td>
</tr>
<tr style="background-color:#dedede">
<td>d1_eli_02</td>
<td>Spawns you in Eli&#8217;s Lab.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_eli_01</td>
<td>Spawns you after the canal, outside of Eli&#8217;s Lab.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_c17_05</td>
<td>Spawns you in City 17 after the fourth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_c17_06</td>
<td>Spawns you in City 17 after the fifth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_c17_07</td>
<td>Spawns you in City 17 after the sixth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_c17_08</td>
<td>Spawns you in City 17 after the seventh load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_c17_09</td>
<td>Spawns you in City 17 after the eighth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_c17_10</td>
<td>Spawns you in City 17 after the ninth load point.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_c18_11</td>
<td>Spawns you in City 17 after the tenth load point.</td>
</tr>
<tr style="background-color:#aaa">
<td>credits</td>
<td>Starts you at the credits</td>
</tr>
<tr style="background-color:#dedede">
<td>intro</td>
<td>Starts you at the games Intro.</td>
</tr>
<tr style="background-color:#aaa">
<td>d1_breen_01</td>
<td>Spawns you at the beginning of Chapter 13.</td>
</tr>
<tr style="background-color:#dedede">
<td>d3_c17_13</td>
<td>Spawns you near the end of City 17.</td>
</tr>
<tr style="background-color:#aaa">
<td>d3_c17_12</td>
<td>Spawns you in City 17 after the eleventh load point.</td>
</tr>
</tbody>
</table>
<p>In effect, what you have done, is to import all your <strong>Half Life 2</strong> content and levels into <strong>Portal</strong>.  It is a little buggy, but loads of fun.  Enjoy!</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.rogerdavies.com%2F2009%2F08%2Fhow-to-hack-half-life-2-to-play-with-the-portal-gun%2F&amp;linkname=How%20To%20Hack%20Half%20Life%202%20To%20Play%20With%20The%20Portal%20Gun"><img src="http://www.rogerdavies.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.rogerdavies.com/2009/08/how-to-hack-half-life-2-to-play-with-the-portal-gun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google as God &#8211; Evolution of Language and Ideas, Catalyst of the Human Condition</title>
		<link>http://www.rogerdavies.com/2009/08/google-as-god/</link>
		<comments>http://www.rogerdavies.com/2009/08/google-as-god/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 19:01:26 +0000</pubDate>
		<dc:creator>Roger Davies</dc:creator>
				<category><![CDATA[Japan]]></category>
		<category><![CDATA[Strange Ideas]]></category>
		<category><![CDATA[alpha]]></category>
		<category><![CDATA[alpha and omega]]></category>
		<category><![CDATA[birth]]></category>
		<category><![CDATA[catalyst]]></category>
		<category><![CDATA[cave paintings]]></category>
		<category><![CDATA[death]]></category>
		<category><![CDATA[evolution]]></category>
		<category><![CDATA[evolution of language]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[google as god]]></category>
		<category><![CDATA[human condition]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[kongorikishi]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[lives]]></category>
		<category><![CDATA[meaning]]></category>
		<category><![CDATA[nio]]></category>
		<category><![CDATA[omega]]></category>
		<category><![CDATA[purpose]]></category>

		<guid isPermaLink="false">http://www.rogerdavies.com/?p=3324</guid>
		<description><![CDATA[From Cave Paintings to Google Searching the Internet
Since cave paintings began, humans have exhibited this unique desire to connect with each other and share ideas. This is perhaps one thing above all else that sets us apart from the beasts, and I often wonder if the Internet simply provides an ultra evolved extension of this [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.rogerdavies.com/wp-content/uploads/2009/08/jebel-acacus-cave-paintings-3-756757.jpg"><img class="alignleft size-medium wp-image-3429" title="Cave Painting" src="http://www.rogerdavies.com/wp-content/uploads/2009/08/jebel-acacus-cave-paintings-3-756757-300x200.jpg" alt="Cave Painting" width="240" height="160" /></a></p>
<h2>From Cave Paintings to Google Searching the Internet</h2>
<p>Since cave paintings began, humans have exhibited this unique desire to connect with each other and share ideas. This is perhaps one thing above all else that sets us apart from the beasts, and I often wonder if the <strong>Internet</strong> simply provides an ultra evolved extension of this same pass time.  It was a recent post by my friend Michael Wharton about <a href="http://www.michaelwharton.co.uk/2009/08/the-church-of-google/"><strong>The Church of Google</strong></a> that had me thinking :-  If humanities knowledge is a computer system, then <strong>Google</strong>, <strong>Social Networking</strong> and the <strong>Internet</strong> might be better described as the heuristic, control bus or selection process, responsible for connecting, sharing and interbreeding the appropriate ideas between people.  Interestingly, <a href="http://googleblog.blogspot.com/2008/09/our-position-on-californias-no-on-8.html">Google are against proposition 8</a>, which is nice to know.</p>
<h2>Google as God?</h2>
<p>Just as creatures evolve, I like to think that <a href="/2009/04/the-evolution-and-conflict-of-ideas-web-20-user-experience-and-the-future-of-the-internet/">ideas evolve</a> too and &#8211; likewise &#8211; the means we use to express these ideas must grow to facilitate this expansion. Realising that caves make a pretty lousy means of broadcasting, the humans invent paper which turned out to be much more portable and allowed these ideas to travel more freely.  Then came radio and television which would quickly come to decide wars and inform the public about the world at large.  The Internet is different in one important aspect &#8211; that we get some choice over our intellectual diet.</p>
<p>Could Google be thought of as God?  I certainly don&#8217;t think this idea is as crazy as it must sound, given the inherent importance of language and communication to all human civilisations.  Nothing changes the fact that Google is a collection of distributed computers that run code and have access to a massive database. It is a working masterpiece of form and function, but is certainly not a deity in the classical sense.  But &#8211; perhaps like evolution &#8211; this is because our beliefs were wrong.</p>
<h2>Google &#8211; Catalyst of the Human Condition</h2>
<p><a href="http://www.rogerdavies.com/wp-content/uploads/2009/08/kongo_rikishi_nara.jpg"><img class="alignleft size-medium wp-image-3375" title="Todaiji KongoRikishi in Nara" src="http://www.rogerdavies.com/wp-content/uploads/2009/08/kongo_rikishi_nara-208x300.jpg" alt="Todaiji KongoRikishi in Nara" width="161" height="231" /></a>Nara is one of my all time favourite Japanese cities,  packed full with national treasures and ancient temples.  Like many throughout Southeast Asia, <strong>T</strong><strong>ō</strong><strong>daiji </strong>(東大寺) temple in Nara has <strong>Kongorikishi</strong> (金剛力士) or <strong>Ni</strong><strong>ō</strong> (仁王) at the gates.  These are two guardians, the left is known as <strong>Naraen Kongō</strong> (那羅延金剛) and has it’s mouth in an &#8220;a&#8221; position (Agyō 阿形), symbolising the birth of all things. (Like our Alphabet, the Japanese consider &#8216;a&#8217; to be the <strong>first </strong>letter of the alphabet). The right one is known as <strong>Misshaku Kongō</strong> (密迹金剛) having it’s mouth in an n or m position (<strong>last </strong>letter of the alphabet), known as <strong>Ungyō</strong> (吽形) &#8211; symbolising the death of all things.  Amazingly, a similar analogy exists for life and death in Christian civilisation with <strong>Alpha</strong> (A) and <strong>Omega</strong> (Ω) &#8211; the first and last letters of the classical Greek alphabet (Book of Revelation verses 1:8, 21:6, and 22:13)  :</p>
<blockquote><p><strong>Revelation verses 1:8</strong><br />
“I am the Alpha and the Omega,” says the Lord God, “who is, and who was, and who is to come&#8230;<br />
<strong>Revelation verses 21:6</strong><br />
&#8230;“I am the Alpha and the Omega, the Beginning and the End”&#8230;</p></blockquote>
<p><!-- Language is fascinating isn&rsquo;t it? Think about it ... statements we make can influence people's outlook and bring about a change in actions or behaviour.  You might say that even by reading this next sentence, your world is very slightly different. --></p>
<p>But why is language so important that many cultures measure their very existence against it?  Language shapes our beliefs about the world, and affects our behaviour.  It is used to document our journey of self discovery and what is left behind after we are gone will form pieces of a jigsaw that will ultimately come to define us.</p>
<p>The truth is, when it comes to subjects like <em><strong>birth</strong> </em>and <strong><em>death</em></strong>, we develop all kinds of elaborate beliefs in an attempt to find meaning for something which is only temporary.  It predisposes us to fixate on where we came from &#8211; how we got here, and where we are going.  <em><strong>We become search</strong></em>.  From a young age we learn to start asking questions.  Google aims to match you up with someone who (it believes) has the answers.  Ideas that would have been limited by geographical borders, by culture or by language can now be almost totally free.</p>
<p>I suppose I would see Google as a catalyst of the human condition.  Whatever our creators intended for us, whatever purpose our lives serve, or whatever it is that separates us from the animals &#8230; <strong>Google </strong>and the <strong>Internet </strong>help us <strong>do it better</strong>!</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.rogerdavies.com%2F2009%2F08%2Fgoogle-as-god%2F&amp;linkname=Google%20as%20God%20%26%238211%3B%20Evolution%20of%20Language%20and%20Ideas%2C%20Catalyst%20of%20the%20Human%20Condition"><img src="http://www.rogerdavies.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.rogerdavies.com/2009/08/google-as-god/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic CSS Stylesheets Using PHP &#8211; A Practical, Working Example Using Cookies To Store CSS Settings</title>
		<link>http://www.rogerdavies.com/2009/05/dynamic-css-stylesheets-using-php-a-practical-working-example-using-cookies-to-store-css-settings/</link>
		<comments>http://www.rogerdavies.com/2009/05/dynamic-css-stylesheets-using-php-a-practical-working-example-using-cookies-to-store-css-settings/#comments</comments>
		<pubDate>Sun, 10 May 2009 10:53:28 +0000</pubDate>
		<dc:creator>Roger Davies</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Strange Ideas]]></category>
		<category><![CDATA[Techno Babble]]></category>
		<category><![CDATA[css stylesheets]]></category>
		<category><![CDATA[dynamic css stylesheets]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://rogerdavies.com/blog/?p=2191</guid>
		<description><![CDATA[A Practical Example of Dynamic CSS
Continuing with the idea of dynamic CSS Stylesheets using PHP, I constructed a basic working example. See this page for details on how you might configure Apache to do this.
 
Once you have played with the settings, try viewing this page, which is not getting any information from this page (or [...]]]></description>
			<content:encoded><![CDATA[<h2>A Practical Example of Dynamic CSS</h2>
<p>Continuing with the idea of <a href="http://rogerdavies.com/blog/?p=2154">dynamic CSS Stylesheets</a> using PHP, I constructed a basic working example. See <a href="http://rogerdavies.com/blog/?p=2154">this page</a> for details on how you might configure Apache to do this.</p>
<p> </p>
<p>Once you have played with the settings, try viewing <a href="http://www.rogerdavies.com/dynamic-css/page.html" target="_blank">this page</a>, which is not getting any information from this page (or the iframe) but only keeps the same style because it includes the same style sheet (and the stylesheet knows your settings from the Cookies in your browser!)</p>
<h2>Addressing the Practical Problems of Dynamic CSS</h2>
<p>Besides the obvious initial issue of getting <a href="http://rogerdavies.com/blog/?p=2154">Apache to pre-treat the CSS files with PHP</a>, there were a number of other practical issues that needed to be solved. I began by creating a <strong>dynamic CSS Stylesheet</strong>, who&#8217;s settings were taken entirely from the COOKIES of the requesting computer:</p>
<p><strong><em>dynamic.css</em></strong><br />
[ <a href="http://www.rogerdavies.com/dynamic.css">download</a> ]</p>
<table border="1" width="100%" align="center">
<tbody>
<tr>
<td>
<pre id="line1" style="font-size:12px">&lt;?php header("Content-type: text/css"); ?&gt;

body {

 background-color:&lt;?php echo $_COOKIE['roger_davies_back_colour']; ?&gt;;
 font-family:&lt;?php echo $_COOKIE['roger_davies_font_face']; ?&gt;; 

}

h1 {	font-size:&lt;?php echo $_COOKIE['roger_davies_header_size'];  ?&gt;;
	color:&lt;?php echo $_COOKIE['roger_davies_text_colour'];?&gt;;
}

p { &lt;?php if (isset($_COOKIE['roger_davies_text_colour']))
		{ echo "color:".$_COOKIE['roger_davies_text_colour'];  }
?&gt;;  }

a { &lt;?php if (isset($_COOKIE['roger_davies_text_colour']))
		{ echo "color:".$_COOKIE['roger_davies_link_colour'];  }
?&gt;;  }</pre>
</td>
</tr>
</tbody>
</table>
<p> </p>
<h2>Testing Cookies Are Set Before Testing Their Value</h2>
<p>But we need to be careful to ensure that the cookies are set by the time the PHP processor gets to this section of code, otherwise our stylesheet will start to fill with : code like: &#8220;a { color:<strong>notice : undefined index</strong> }&#8221;.  This makes it essential that we test the cookies at the start of our HTML document(s), and to set them to some initial value (if not already set) before the clients browser reaches the link to the stylesheet.  Also, each time you query the <strong>COOKIE</strong>, you must test <strong>isset(&#8230;)</strong> first.  I used PHP&#8217;s lazy evaluation using double ampersand :  &#8220;if (<strong>expression 1</strong> &amp;&amp; <strong>expression 2</strong>) &#8230;&#8221; which will try to evaluate expression 1 first, then ONLY try to evaluate expression 2 if expression 1 is true.  This way, provided we keep the <strong>Isset</strong> command as <strong>expression 1</strong>, we can be sure it will never test a cookie or value that isn&#8217;t set. In larger sites, the initial-value-setting (block before the opening <strong>&lt;HTML&gt; element</strong>) is probably best done with an include (I&#8217;ve coded it into the HTML file here to keep the example simple).</p>
<p>While working on this, I found it useful to look at the CSS sheet directly with my browser by entering the URL to ensure the dynamic CSS stylesheet was being built by the PHP correctly. <strong>Remember, you won&#8217;t see any error messages because they will be printed in the stylesheet, not the HTML document! </strong></p>
<p><strong><em>index.html</em></strong><br />
[ <a href="http://www.rogerdavies.com/dynamic-css/index.html">download</a> ]</p>
<table border="1" width="450" align="center">
<tbody>
<tr>
<td width="450">
<pre id="line1" style="font-size:12px">
&lt;?php

	if (isset($_GET['backgroundcolour'])) {	setcookie("roger_davies_back_colour", $_GET['backgroundcolour']); }
	if (isset($_GET['textcolor'])) {	setcookie("roger_davies_text_colour", $_GET['textcolor']); }
	if (isset($_GET['headersize'])) {	setcookie("roger_davies_header_size", $_GET['headersize']); }
	if (isset($_GET['linkcolour'])) {	setcookie("roger_davies_link_colour", $_GET['linkcolour']); }
	if (isset($_GET['fontface'])) {	setcookie("roger_davies_font_face", $_GET['fontface']); }

	if (!isset($_COOKIE['roger_davies_back_colour'])) { setcookie ("roger_davies_back_colour", "White"); }
	if (!isset($_COOKIE['roger_davies_text_colour'])) { setcookie ("roger_davies_text_colour", "black"); }
	if (!isset($_COOKIE['roger_davies_header_size'])) { setcookie ("roger_davies_header_size", "14px"); }
	if (!isset($_COOKIE['roger_davies_link_colour'])) { setcookie ("roger_davies_link_colour", "Blue"); }
	if (!isset($_COOKIE['roger_davies_font_face'])) { setcookie ("roger_davies_font_face", "Times New Roman"); }

?&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;PHP CSS Files - Dynamic CSS test using PHP in the CSS Stylesheet&lt;/title&gt;
&lt;meta name="description" content="php css files, php, css, dynamic css, php in css stylesheets" /&gt;
&lt;meta name="keywords" content="PHP CSS Files - Dynamic CSS test using PHP in the CSS Stylesheet" /&gt;
&lt;link href="dynamic.css" rel="stylesheet" type="text/css" /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action="index.html" method="get"&gt;
&lt;p style="color:black; background-color:white;"&gt;&lt;strong&gt;Select BACKGROUND Color:&lt;/strong&gt;&lt;SELECT name="backgroundcolour"&gt;

      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "White")) { echo " SELECTED"; } ?&gt;&gt;White&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "Black")) { echo " SELECTED"; } ?&gt;&gt;Black&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "Purple")) { echo " SELECTED"; } ?&gt;&gt;Purple&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "Red")) { echo " SELECTED"; } ?&gt;&gt;Red&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "Blue")) { echo " SELECTED"; } ?&gt;&gt;Blue&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "Green")) { echo " SELECTED"; } ?&gt;&gt;Green&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "Cyan")) { echo " SELECTED"; } ?&gt;&gt;Cyan&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['backgroundcolour']) &amp;&amp; !strcmp($_GET['backgroundcolour'], "Magenta")) { echo " SELECTED"; } ?&gt;&gt;Magenta&lt;/OPTION&gt;
   &lt;/SELECT&gt;&lt;/p&gt;
&lt;p  style="color:black; background-color:white;"&gt;&lt;strong&gt;Select FOREGROUND Color:&lt;/strong&gt;&lt;SELECT name="textcolor"&gt;
 &lt;OPTION&lt;?php if (isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "White")) { echo " SELECTED"; } ?&gt;&gt;White&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if ((isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "Black")) || !isset($_GET['textcolor']) ) { echo " SELECTED"; } ?&gt;&gt;Black&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "Purple")) { echo " SELECTED"; } ?&gt;&gt;Purple&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "Red")) { echo " SELECTED"; } ?&gt;&gt;Red&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "Blue")) { echo " SELECTED"; } ?&gt;&gt;Blue&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "Green")) { echo " SELECTED"; } ?&gt;&gt;Green&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "Cyan")) { echo " SELECTED"; } ?&gt;&gt;Cyan&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset($_GET['textcolor']) &amp;&amp; !strcmp($_GET['textcolor'], "Magenta")) { echo " SELECTED"; } ?&gt;&gt;Magenta&lt;/OPTION&gt;
   &lt;input type="hidden" name="posted" value"done"&gt;&lt;/p&gt;
&lt;p style="color:black; background-color:white;"&gt;&lt;strong&gt;Select HEADER Size:&lt;/strong&gt;&lt;SELECT name="headersize"&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "6px")) { echo " SELECTED"; } ?&gt;&gt;6px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "10px")) { echo " SELECTED"; } ?&gt;&gt;10px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "12px")) { echo " SELECTED"; } ?&gt;&gt;12px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "14px")) { echo " SELECTED"; } ?&gt;&gt;14px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "16px")) { echo " SELECTED"; } ?&gt;&gt;16px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "18px")) { echo " SELECTED"; } ?&gt;&gt;18px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "22px")) { echo " SELECTED"; } ?&gt;&gt;22px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "24px")) { echo " SELECTED"; } ?&gt;&gt;24px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "28px")) { echo " SELECTED"; } ?&gt;&gt;28px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "36px")) { echo " SELECTED"; } ?&gt;&gt;36px&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['headersize']) &amp;&amp; !strcmp($_GET['headersize'], "48px")) { echo " SELECTED"; } ?&gt;&gt;48px&lt;/OPTION&gt;
   &lt;input type="hidden" name="posted" value"done"&gt;&lt;/p&gt;

&lt;p style="color:black; background-color:white;"&gt;&lt;strong&gt;Select Link Colour:&lt;/strong&gt;&lt;SELECT name="linkcolour"&gt;
      &lt;OPTION&lt;?php if ((isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Blue")) | !isset($_GET['linkcolour'])) { echo " SELECTED"; } ?&gt;&gt;Blue&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Green")) { echo " SELECTED"; } ?&gt;&gt;Green&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Red")) { echo " SELECTED"; } ?&gt;&gt;Red&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Orange")) { echo " SELECTED"; } ?&gt;&gt;Orange&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Yellow")) { echo " SELECTED"; } ?&gt;&gt;Yellow&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Purple")) { echo " SELECTED"; } ?&gt;&gt;Purple&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Cyan")) { echo " SELECTED"; } ?&gt;&gt;Cyan&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Magenta")) { echo " SELECTED"; } ?&gt;&gt;Magenta&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['linkcolour']) &amp;&amp; !strcmp($_GET['linkcolour'], "Pink")) { echo " SELECTED"; } ?&gt;&gt;Pink&lt;/OPTION&gt;
   &lt;input type="hidden" name="posted" value"done"&gt;&lt;/p&gt;
   &lt;INPUT type="submit" value="Send"&gt;&lt;INPUT type="reset"&gt;
&lt;p style="color:black; background-color:white;"&gt;&lt;strong&gt;Select Font Style:&lt;/strong&gt;&lt;SELECT name="fontface"&gt;
      &lt;OPTION&lt;?php if ((isset ($_GET['fontface']) &amp;&amp; !strcmp($_GET['fontface'], "Arial, sans-serif")) | !isset($_GET['linkcolour'])) { echo " SELECTED"; } ?&gt;&gt;Arial, sans-serif&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['fontface']) &amp;&amp; !strcmp($_GET['fontface'], "Helvetica, sans-serif")) { echo " SELECTED"; } ?&gt;&gt;Helvetica, sans-serif&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['fontface']) &amp;&amp; !strcmp($_GET['fontface'], "Times New Roman, serif")) { echo " SELECTED"; } ?&gt;&gt;Times New Roman, serif&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['fontface']) &amp;&amp; !strcmp($_GET['fontface'], "Courier New, monospace")) { echo " SELECTED"; } ?&gt;&gt;Courier New, monospace&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['fontface']) &amp;&amp; !strcmp($_GET['fontface'], "Comic Sans, Comic Sans MS, cursive")) { echo " SELECTED"; } ?&gt;&gt;Comic Sans, Comic Sans MS, cursive&lt;/OPTION&gt;
      &lt;OPTION&lt;?php if (isset ($_GET['fontface']) &amp;&amp; !strcmp($_GET['fontface'], "Impact, fantasy")) { echo " SELECTED"; } ?&gt;&gt;Impact, fantasy&lt;/OPTION&gt;
   &lt;input type="hidden" name="posted" value"done"&gt;&lt;/p&gt;
   &lt;INPUT type="submit" value="Send"&gt;&lt;INPUT type="reset"&gt;
&lt;/form&gt;
&lt;h1&gt;Header&lt;/h1&gt;
&lt;p&gt;"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Section 1.10.32 of "de Finibus Bonorum et Malorum", written by Cicero in 45 BC&lt;/p&gt;
&lt;a href="page.html"&gt;View a completely independent page&lt;/a&gt; using this stylesheet you have edited&lt;/a&gt;
&lt;/body&gt;
&lt;/html</pre>
</td>
</tr>
</tbody>
</table>
<p> </p>
<h2>Imagining The Possibilities</h2>
<p>This example is very basic &#8211; just allowing the user to twiddle colours and some styles of the elements, but imagine what is possible when this is scaled up to a full website! Not only could you allow each user to choose a skin they view your site in, but might also individually alter some of the styling themselves, which would be unique to just them! When I first began learning CSS, I found The <a href="http://www.csszengarden.com">CSS Zen Garden</a> very useful to help me reach the realisation that the <strong>design</strong> and the <strong>style</strong> could be thought of as two completely separate entities. This method takes it a few steps further, that each person has their own stylesheet that is generated for them alone. I think there could be futher amazing applications for this, and I hope to at least give people something to think about.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.rogerdavies.com%2F2009%2F05%2Fdynamic-css-stylesheets-using-php-a-practical-working-example-using-cookies-to-store-css-settings%2F&amp;linkname=Dynamic%20CSS%20Stylesheets%20Using%20PHP%20%26%238211%3B%20A%20Practical%2C%20Working%20Example%20Using%20Cookies%20To%20Store%20CSS%20Settings"><img src="http://www.rogerdavies.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.rogerdavies.com/2009/05/dynamic-css-stylesheets-using-php-a-practical-working-example-using-cookies-to-store-css-settings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP CSS Files &#8211; Dynamic CSS, Using PHP in Stylesheets By Using The AddHandler and AddType Directive in the .htaccess File</title>
		<link>http://www.rogerdavies.com/2009/05/php-css-files-dynamic-css-using-php-in-stylesheets-by-using-the-addhandler-and-addtype-directive-in-the-htaccess-file/</link>
		<comments>http://www.rogerdavies.com/2009/05/php-css-files-dynamic-css-using-php-in-stylesheets-by-using-the-addhandler-and-addtype-directive-in-the-htaccess-file/#comments</comments>
		<pubDate>Thu, 07 May 2009 21:04:50 +0000</pubDate>
		<dc:creator>Roger Davies</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Strange Ideas]]></category>
		<category><![CDATA[Techno Babble]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[stylesheets]]></category>

		<guid isPermaLink="false">http://rogerdavies.com/blog/?p=2154</guid>
		<description><![CDATA[Show Me A Working Example of Dynamic CSS using PHP » 
PHP in CSS Files &#8211; Dynamic CSS Using PHP Stylesheets
It all started when I needed to use PHP in a website that was originally basic HTML files.  The site contained at least 30 pages, and I was dreading having to rename every HTML file [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Show Me A <a href="http://rogerdavies.com/blog/?p=2191">Working Example of Dynamic CSS</a> using PHP » </strong></p>
<h2>PHP in CSS Files &#8211; Dynamic CSS Using PHP Stylesheets</h2>
<p>It all started when I needed to use PHP in a website that was originally basic HTML files.  The site contained at least 30 pages, and I was dreading having to rename every HTML file PHP and updating all the links, just to enable me to include a couple of humble lines of PHP.  Instead, I used apaches&#8217; <strong>.htaccess</strong> file to override the server settings, making it treat the htm and html files with the PHP processor, which you can do by adding the following lines to .htaccess (or if you don&#8217;t have one, by placing a file of this name into your web root folder containing:)</p>
<table border="1" width="100%" align="center">
<tbody>
<tr>
<td>
<pre id="line1"><code>AddType application/x-httpd-php .html .htm
AddHandler application/x-httpd-php .html .htm</code></pre>
</td>
</tr>
</tbody>
</table>
<p><span style="font-size: 11px; color: red;">NOTE : This will only work if these overrides are allowed for this folder (use &#8216;<strong>AllowOverride all</strong>&#8216; in this folders entry in Apaches&#8217; <strong>httpd.conf</strong> file.  If you pay for a hosting account this may or may not work (some may not allow this directive to be overridden with .htaccess).  If you get &#8216;<strong>Internal Server Error 500</strong>&#8216;, this is probably the case!  Check your error logs!)</span></p>
<p><strong>Then</strong>, I wondered &#8230; could I use PHP with my <strong>CSS style sheet</strong>?  I tried:</p>
<table border="1" width="100%" align="center">
<tbody>
<tr>
<td>
<pre id="line1">AddType application/x-httpd-php .html .htm .css
AddHandler application/x-httpd-php .html .htm .css</pre>
</td>
</tr>
</tbody>
</table>
<p>And sure enough, I was <strong>able to use PHP in the css stylesheet</strong>, and it behaved exactly as it should.  I began with the following block of code:</p>
<table border="1" width="100%" align="center">
<tbody>
<tr>
<td>
<pre id="line1">body {

&lt;?php echo "background-color:black;"; ?&gt;
}</pre>
</td>
</tr>
</tbody>
</table>
<p>And after knocking together a simple html document that included our <strong>PHP CSS stylesheet</strong>, I was looking at a web page with a black background!</p>
<h2>Imagine The Possibilities!</h2>
<p>While this is a painfully simple example, the possibilities are endless!  By turning the PHP processor on my CSS Stylesheet &#8211; in theory &#8211; I have the freedom to write a web page that has the same stylesheet for everyone, yet allows <strong>each individual visitor</strong> to see a <strong>completely different design</strong>, allowing each visitor to customise the colour of the links, text, or formatting and layout of the page they see.  My first thoughts were you could use <strong>cookies</strong> to get and set the various viewing options, and generate the CSS Stylesheet on the fly for each visitor with code like:</p>
<table border="1" width="100%" align="center">
<tbody>
<tr>
<td>
<pre id="line1"><code>body { font-family:</code><code>&lt;?=</code><code>$_COOKIE['roger_davies_font_face'];?&gt;</code><code> }

p { color:&lt;?php
          switch ($_COOKIE['roger_davies_text_colour']) {
             case 1 : echo "white;";
             break;
             case 2 : echo "black;";
             break;
             case 3 : echo "purple;";
             break;
             }    ?&gt;
}

a { color:&lt;?php
          switch ($_COOKIE['roger_davies_link_colour']) {
             case 1 : echo "red";
             break;
             case 2 : echo "green";
             break;
             case 3 : echo "blue;
             break;   } ?&gt;
}
</code><code>#container { width:&lt;?php echo $_COOKIE['roger_davies_screen_width']; ?&gt;  }</code></pre>
</td>
</tr>
</tbody>
</table>
<p>I&#8217;m sure there are more exciting applications, but I was just excited that it worked at all!</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.rogerdavies.com%2F2009%2F05%2Fphp-css-files-dynamic-css-using-php-in-stylesheets-by-using-the-addhandler-and-addtype-directive-in-the-htaccess-file%2F&amp;linkname=PHP%20CSS%20Files%20%26%238211%3B%20Dynamic%20CSS%2C%20Using%20PHP%20in%20Stylesheets%20By%20Using%20The%20AddHandler%20and%20AddType%20Directive%20in%20the%20.htaccess%20File"><img src="http://www.rogerdavies.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.rogerdavies.com/2009/05/php-css-files-dynamic-css-using-php-in-stylesheets-by-using-the-addhandler-and-addtype-directive-in-the-htaccess-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Group Context Social Networking &#8211; A New Concept of Targeting Appropriate Information to Groups on the Internet, Suggested Syntax, How it Might Be Achieved</title>
		<link>http://www.rogerdavies.com/2009/04/group-context-social-networking-a-new-concept-of-targeting-appropriate-information-to-groups-on-the-internet-suggested-syntax-how-it-might-be-achieved/</link>
		<comments>http://www.rogerdavies.com/2009/04/group-context-social-networking-a-new-concept-of-targeting-appropriate-information-to-groups-on-the-internet-suggested-syntax-how-it-might-be-achieved/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 12:24:26 +0000</pubDate>
		<dc:creator>Roger Davies</dc:creator>
				<category><![CDATA[Social Observations]]></category>
		<category><![CDATA[Strange Ideas]]></category>
		<category><![CDATA[context-targeted]]></category>
		<category><![CDATA[group context social networking]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[multiple groups]]></category>
		<category><![CDATA[new concept]]></category>
		<category><![CDATA[new technology]]></category>
		<category><![CDATA[particular sections]]></category>
		<category><![CDATA[people]]></category>
		<category><![CDATA[set viewing permissions]]></category>
		<category><![CDATA[sharing appropriate information]]></category>
		<category><![CDATA[social networking]]></category>
		<category><![CDATA[targeting appropriate information]]></category>
		<category><![CDATA[type of relationship]]></category>

		<guid isPermaLink="false">http://rogerdavies.com/blog/?p=2110</guid>
		<description><![CDATA[Group Context Social Networking &#8211; Connections of People
The truth splits my skull like an ancient Japanese Koan overloads logical thought &#8211; a DoS attack on the mind, designed specifically to engage, overwhelm and suppress the natural mental processes.  It feels at once like the freedom of flight while chewing on a gobstopper made of [...]]]></description>
			<content:encoded><![CDATA[<h2>Group Context Social Networking &#8211; Connections of People</h2>
<p>The truth splits my skull like an ancient Japanese Koan overloads logical thought &#8211; a DoS attack on the mind, designed specifically to engage, overwhelm and suppress the natural mental processes.  It feels at once like the freedom of flight while chewing on a gobstopper made of white hot lead of infinite mass.  The irony of my compass analogy in my <a href="http://rogerdavies.com/blog/?p=2022">recent post about Web 2.0</a> hit me, when I realised that I had overlooked the single most important element of this medium &#8211; <strong>PEOPLE</strong>.  That the main purpose the Internet serves is <strong>connections</strong>.  Not just the literal connections of one machine to another, but the connections of one PERSON to another.</p>
<h2>Not all Connections Area Created Equal</h2>
<p>Whilst speaking with a dear friend of mine from <strong>California</strong>, we came to a stunning realisation of a NEW technology that might be used on the Web.  You see, the problem with social networking is &#8211; at the moment &#8211; it is essentially <strong>mindless</strong>.  Someone is tagged as your friend, they get to read <strong>EVERYTHING</strong> you post and share.  But the reality of our human connections is they all have a different scope, purpose and meaning.  A boyfriend and girlfriend relationship is quite different from a prime minister and political party relationship, which is again quite different from the relationship of a mother and child.  There will be similar elements and characteristics some share, but each will be unique in one way or another.  As people, we are members of lots of groups &#8211; some overlap in our lives, others may be a little more exclusive.</p>
<h2>Targeting Appropriate Information to Appropriate People</h2>
<p>My new idea (dubbed &#8216;group context social networking&#8217; for now) is about carefully context-targeted information &#8211; Sharing appropriate information with appropriate groups on the Internet. There may be personal facts you only share with your close friends that you would not share at work, equally there may be things you discuss at work that you would never talk about at home.  I put it to the reader that it is simply not enough anymore to simply share all information equally and globally on the Internet, as not all connections that supply this information are equal.  In fact &#8211; I would go as far as to say that all of <a href="http://www.myspace.com/">MySpace</a> and <a href="http://www.myspace.com/">Facebooks</a> problems have arisen from the way that everything is shared globally.</p>
<p><strong>Imagine being able to set viewing permissions on a particular sentence, or paragraph of your text</strong> on the Web in the same way you might alter the texts&#8217; colour or style. Imagine being able to hide and show <strong>particular sections</strong> to particular groups, so that the message available will be very slightly tailored for each type of audience you have, depending on what type of relationship you have with the reader.</p>
<h2>How Would This Be Achieved Practically?</h2>
<p>My concept involves assigning your friends to particular groups which reflect what type of friend they are &#8211; and therefore what type of bond you enjoy. The author would write the complete document (including all the gory details), then use a markup syntax as tags within the text which indicate which groups can view particular sections. When the document is requested, the server will need to do a little post-processing to remove any sections not suitable to the current viewer, before sending the document.</p>
<h2>Suggested Syntax, How it Might Be Achieved in the Document</h2>
<p>After some thought, (and to avoid tripping over any of the existing post-processor syntax such as <strong>&lt;%</strong> and  <strong>&lt;?</strong> ) I thought it might be good to use : <strong>&lt;@groupname: TEXT@&gt;</strong> as the delimiters. You could specify multiple groups by using : <strong>&lt;@homefriends|workfriends: HELLO@&gt;</strong>, making the parsing of groups quite easy using the following rules:</p>
<ul>
<li>For all the document, find the strings that occur within the limiting <strong>&lt;@</strong> and <strong>@&gt;</strong> tags</li>
<li>For all the strings found in step one, we know that left of <strong>:</strong> we have group names, right of <strong>:</strong> we have the text.</li>
<li>For all group names, find the string up to the first occurrence of the | delimiter (if | is not found, then this is the last group mentioned)</li>
<li>Else get the group name left of | and pass the remaining string back to step 3</li>
<p>Consider the following rules I have set in my account:</ul>
<p><strong>friends</strong> are my closest friends<br />
<strong>acquaintances</strong> are people I know, but not well.  Possibly old friends from school who have looked me up, or people I have just met on the NET</p>
<p>Now, consider the following text passage:</p>
<blockquote><p><strong>This weekend I enjoyed a few drinks </strong><strong>&lt;@</strong><strong>friends|acquaintances:</strong><strong>with a couple of friends@&gt;&lt;@friends:Bob and Joe@&gt;</strong><strong>&lt;@</strong><strong>friends|acquaintances:</strong><strong>who&#8217;s company I enjoy enormously@&gt;.</strong></p></blockquote>
<p>A close friend (in my <strong>friends</strong>) group would see:</p>
<blockquote><p><strong>This weekend I enjoyed a few drinks with a couple of friends Bob and Joe who&#8217;s company I enjoy enormously.</strong></p></blockquote>
<p>But someone who is not a member of  &#8216;<strong>friends</strong>&#8216; (but is a member of &#8216;<strong>acquaintances</strong>&#8216;) would see:</p>
<blockquote><p><strong>This weekend I enjoyed a few drinks with a couple of friends who&#8217;s company I enjoy enormously.</strong></p></blockquote>
<p>Someone who is just a member of the public might see:</p>
<blockquote><p><strong>This weekend I enjoyed a few drinks.</strong></p></blockquote>
<p>This is a fairly simplified example, but now imagine having a group for every circle of friends you associate with &#8211; being able to tailor the document using sections like this.</p>
<p>This idea will solve many of the ills that social networking has caused in reality &#8211; and controversey that many employers, individuals and the law has had to deal with as a result.  In theory, following these standards a person could develop a series of libraries in <strong>PHP </strong>or <strong>ASP</strong> (or a similar server-side scripting language) that could provide this functionality to be imported into existing content management systems and social networking sites.</p>
<p>I guess I share this idea, because I realise I will not have time to work on this in the immediate future, but hopefully this will be an interesting thought for some.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.rogerdavies.com%2F2009%2F04%2Fgroup-context-social-networking-a-new-concept-of-targeting-appropriate-information-to-groups-on-the-internet-suggested-syntax-how-it-might-be-achieved%2F&amp;linkname=Group%20Context%20Social%20Networking%20%26%238211%3B%20A%20New%20Concept%20of%20Targeting%20Appropriate%20Information%20to%20Groups%20on%20the%20Internet%2C%20Suggested%20Syntax%2C%20How%20it%20Might%20Be%20Achieved"><img src="http://www.rogerdavies.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.rogerdavies.com/2009/04/group-context-social-networking-a-new-concept-of-targeting-appropriate-information-to-groups-on-the-internet-suggested-syntax-how-it-might-be-achieved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Teaching an Octopus to Read</title>
		<link>http://www.rogerdavies.com/2008/12/teaching-an-octopus-to-read/</link>
		<comments>http://www.rogerdavies.com/2008/12/teaching-an-octopus-to-read/#comments</comments>
		<pubDate>Wed, 03 Dec 2008 21:48:24 +0000</pubDate>
		<dc:creator>Roger Davies</dc:creator>
				<category><![CDATA[Strange Ideas]]></category>
		<category><![CDATA[abstracting]]></category>
		<category><![CDATA[behaviour]]></category>
		<category><![CDATA[cephalopod semantics]]></category>
		<category><![CDATA[choice]]></category>
		<category><![CDATA[conditioned learning]]></category>
		<category><![CDATA[experiment]]></category>
		<category><![CDATA[feeding]]></category>
		<category><![CDATA[food]]></category>
		<category><![CDATA[intelligence]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[octopi]]></category>
		<category><![CDATA[octopus]]></category>
		<category><![CDATA[pavlov]]></category>
		<category><![CDATA[pet]]></category>
		<category><![CDATA[semantics]]></category>
		<category><![CDATA[survival instincts]]></category>
		<category><![CDATA[teach an octopus to read]]></category>
		<category><![CDATA[teaching an octopus to read]]></category>
		<category><![CDATA[visual clues]]></category>

		<guid isPermaLink="false">http://rogerdavies.com/blog/?p=899</guid>
		<description><![CDATA[Cephalopod Semantics

Ever since I was a boy I always wanted to keep an octopus as a pet.  Believe it or not, I still do.  And thanks to the power of the Internet, I know I&#8217;m not alone.  Year after year I would passively research what I would need &#8211; three bio filters for the amount [...]]]></description>
			<content:encoded><![CDATA[<h1>Cephalopod Semantics</h1>
<p><img style="float:left" src="http://www.rogerdavies.com/blog/images/octopus.jpg" alt="" /></p>
<p>Ever since I was a boy I always wanted to keep an octopus as a pet.  Believe it or not, I still do.  And thanks to the power of the Internet, <a href="http://www.tonmo.com">I know I&#8217;m not alone</a>.  Year after year I would passively research what I would need &#8211; three bio filters for the amount of bio waste it&#8217;s three tremendous hearts would output.  The largest tank regular pet stores are likely to have (as the minimum!) and an interesting assortment of structures and movable objects. They are very very smart, and I would never consider taking on a pet if I knew it was in any kind of psychological distress or was emotionally of mentally needing for something.</p>
<p>And as I&#8217;ve grown, my expectations of what I might get out of this experience grew.  Finally, an idea began to form that might just make it possible to teach an octopus to read!  Sounds crazy doesn&#8217;t it?</p>
<h2 style="color:#888888">Stage 1 &#8211; Reward Patience &amp; Puzzle Solving Behaviour</h2>
<p>Octopi are <em><strong>incredibly</strong></em> smart.  One of the common problems facing owners is they are often smart enough to work out how to lift the lid of the tank!  With enough time, they can work out how to unscrew jam jars by themselves.But what if we revived an old <a href="http://en.wikipedia.org/wiki/Pavlovian">Pavlovian idea</a> of conditioned learning, and fed the octopus by with food in the jar each time?  Over time the Octopus should start to make the association.  And Jam Jar would be king!</p>
<h2 style="color:#888888">Stage 2 &#8211; Establish Visual Clues to Identify Reward</h2>
<p>With this connection firmly made, what if we start introducing TWO brown smokey jars which were not transparent?  One could have a &#8216;0&#8242; for no reward.  The other could have a marking to indicate prawn, both in different colours to help make them even more separable.  If this process of feeding is continued, with enough time we can expect the Octopus to be more likely to go for the one it associates with the highest probability of getting food.  This stage could take time, as part of a big learning curve but we will know when if/when it is complete because the octopus should stop going for the &#8216;zero&#8217;.</p>
<h2 style="color:#888888">Stage 3 &#8211; Binding an Idea to a Word</h2>
<p>Once this is mastered, a third jar could be introduced with a second <em>type </em>of prize  &#8211; with a different symbol in a different colour on the jar.  By this stage, the octopus should be fairly aware that this difference of label will indicate something about the contents and the feeding.  It will be interesting to see how it reacts, which jar it goes for.  Will it be driven by curiosity of the extra one?  Will it go for the one it knows to be usually a reward, or will it go for the &#8216;zero&#8217;.<img style="float:right;" src="http://www.rogerdavies.com/blog/images/octopus_jar.jpg" alt="" /></p>
<p>If it goes for the new one, we know that the experiment is working, and the octopus is curious, which indicates high level of intelligence.  If it goes for the original symbol it was initially conditioned for, we know that it has worked, and the octopus is being driven by the slightly lower-level intelligence reasoning, based more around basic urges, coupled with an understanding of the likelihood of getting food.  If it goes for the &#8216;zero&#8217; we know the experiment itself is not working.</p>
<p>Perhaps two out of the three jars could be dropped each time it is fed?  As we rotate through all combinations of the three jars, we could show the experiment is working, because hopefully it will avoid the &#8216;zero&#8217; which will now act as the control.</p>
<p>It is important to say that the two possible treats on the menu now represent a choice.  Even if that choice is only the resulting biological impulses stimulated by the proximity of the possibility of food. It cannot go for all three at once, and will need to decide.</p>
<h2 style="color:#888888">Stage 4 &#8211; Abstracting the of Concept of Choice</h2>
<p>If the octopus gets to the stage where we have the desired behaviour, flat 2-D laminated cards that <em><strong>look</strong></em> very similar to the original jars, with the same colours and markings could be introduced into the tank, far apart.  Believe it or not, we share a very similar eye structure to the octopus, so we can expect our little icons to at least look identifiable.</p>
<p>The octopus could then be observed.  Would it go for one of the reward  &#8216;jars&#8217;?  Will it investigate &#8211; led on by the primative drive in the belief that food might somehow happen?  Especially with so much re-enforcement previously?  If so, it can be rewarded with the appropriate choice, and hopefully this pattern might continue, with the symbolic choice now being made. The choosing mechanism has been abstracted.</p>
<p>The control &#8216;zero&#8217; jar will now be very important, because the degree and frequency that it arouses the octopus&#8217; interest, is the extent to which this experiment has failed.</p>
<h2 style="color:#888888">Stage 5 &#8211; Abstracting the Choice Vocabulary</h2>
<p>If the Octopus becomes comfortable with attacking or investigating the one it chooses, and with the pattern of being fed to help re-enforce this, we can try this one last phase.  It might be that the abstraction stage was simply too much, and that we are now too far abstracted from the basic survival insticts for much of this to be visible to the creature.</p>
<p>BUT &#8211; if we know our pet well enough to identify it&#8217;s reaction and understand it&#8217;s behaviour &#8211; we can then just include three laminated square, flat cards that don&#8217;t look anything remotely like the jars, but still with the same symbols and colours.</p>
<p>In a successful test, we should see a clear decision by the octopus to investigate a particular card, and not being interested in the card with the &#8216;zero&#8217;.  A failure, is that the octopus would show equal, or more interest with the &#8216;zero&#8217; card.<br />
<img src="http://www.rogerdavies.com/blog/images/kraken1.jpg" alt="" /></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.rogerdavies.com%2F2008%2F12%2Fteaching-an-octopus-to-read%2F&amp;linkname=Teaching%20an%20Octopus%20to%20Read"><img src="http://www.rogerdavies.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.rogerdavies.com/2008/12/teaching-an-octopus-to-read/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
