<?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>PHP Tutorials Code Snippets and Php Tips</title>
	<atom:link href="http://readytousesolutions.com/phpblog/feed/" rel="self" type="application/rss+xml" />
	<link>http://readytousesolutions.com/phpblog</link>
	<description>PHP tutorials - Examples of the most useful scripts</description>
	<lastBuildDate>Thu, 23 Sep 2010 06:54:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Video Corsi Maya e zBrush – Effetti Speciali</title>
		<link>http://readytousesolutions.com/phpblog/video-corsi-maya-e-zbrush-effetti-speciali/</link>
		<comments>http://readytousesolutions.com/phpblog/video-corsi-maya-e-zbrush-effetti-speciali/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 05:23:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://readytousesolutions.com/phpblog/?p=350</guid>
		<description><![CDATA[This post is pretty out of the line with respect to this blog’s contents, but as you can see this php blog hasn’t been updated for a while. It will come back, and it will boost some pretty strong new &#8230; <a href="http://readytousesolutions.com/phpblog/video-corsi-maya-e-zbrush-effetti-speciali/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post is pretty out of the line with respect to this blog’s  contents, but as you can see this php blog hasn’t been updated for a  while.</p>
<p>It will come back, and it will boost some pretty strong new content. I  have spent last year developing an eLearning system and it turned out  to be a pretty decent cms as well.</p>
<p>Among other things, I plan to write about handling video pseudo  streaming in a secure way, voting and discussing posts, creating a  content dripping system and an automatic renewal plan.</p>
<p>But for now let me point to a few urls related to the system I developed. One is <a href="http://www.faistrada.it/corso-maya-3d.htm">corso <strong>maya</strong></a> and is the placeholder for a forthcoming online course about the  popular 3D rendering software. Guess its code is a little more complex  than a php script.</p>
<p>The other, <a href="http://www.faistrada.it/corso-modellazione-zbrush.htm">corso zbrush</a> is an already active online training on zbrush, a virtual sculpting  tool used even to create the monsters in pirates of the caribbeans (go  figure!). Both trainings are not in english, nor is this site <a href="http://effetti-speciali.info/">effetti speciali cinema</a> which is a free resource on history and techniques of visual effects in  cinema. This is a non profit site, with an english version currently  under developement by yours truly. Or, rather, by my fellow webdesigner,  as I am only writing a php wordpress plugin to improve searching.</p>
<p>Again, I will soon update this blog with some real, down to earth,  php tutorial worth reading. An rss feed generation system and a sitemap  creator, for example. All I have to do is to grab all the notes I took  during developement and gather them into a final list of posts. Then it  will be <em>php blog time</em>. Honest.</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/video-corsi-maya-e-zbrush-effetti-speciali/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flatfile PHP simple CMS tutorial Part 2 the code</title>
		<link>http://readytousesolutions.com/phpblog/flatfile-php-cms-tutorial-part-2-the-code/</link>
		<comments>http://readytousesolutions.com/phpblog/flatfile-php-cms-tutorial-part-2-the-code/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 05:16:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://readytousesolutions.com/phpblog/?p=347</guid>
		<description><![CDATA[This is part two of our simple CMS or blog in flatfile format. We’ll see how to structure the flat file, and the code needed to read it in. This code is not optimized, so it’s easier to understand. As &#8230; <a href="http://readytousesolutions.com/phpblog/flatfile-php-cms-tutorial-part-2-the-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is part two of our simple CMS or blog in flatfile format. We’ll see how to structure the flat file, and the code needed to read it in.</p>
<p>This code is not optimized, so it’s easier to understand. As we progress in this series we’ll see how to improve coding style.</p>
<p>First of all we have to define the flat file format.</p>
<p>We will need several fields:</p>
<p>1. Title – mandatory<br />
2. Url – mandatory<br />
3. Content – mandatory<br />
4. Meta keywords – optional<br />
5. Meta description – optional<br />
6. Author – optional<br />
7. Post date – optional, as unix timestamp</p>
<p>The most straightforward way to tackle this in a flat file would be to separate each element with a special character never to be used in titles or content, say a pipe symbol ‘|’.</p>
<p>Then, we would place all content on a single row and use PHP’s fgets() function to read one line at a time.</p>
<p>There are two problems with this approach: sometimes is handy to include newlines in the file, to make it easier to read and edit. And using a special character, whatever it is, prevents us from using it in the text.</p>
<p>A nice and tidy solution would be to use some sort of XML format, but we are aiming for a short, efficient script -not an exercise in Quality Coding.</p>
<p>A good compromise can be to use a complex separator both for articles and for items inside articles. Let’s say something like: #00# between items and #99# between articles.</p>
<p>The “database” file would therefore appear this way:<br />
<code><br />
#00#/#00#This is the Home Page.#00#Micro Flat File CMS#00#Home#00##00##99#<br />
My title#00#my-title.html#00#This is the post.<br />
It can spawn multiple lines. And have html code inside.<br />
#00#Post, article#00#Sample post#00#Admin#00#1251892286#99#<br />
Corporate Home Page#00#corporate.html#00#Our mission is to provide nonsense mission statements no one will ever read.<br />
#00#Mission, corporate#00#We We We We We...#00##00#<br />
</code><br />
Looks like a mess, right? Let’s make a simple entry template:</p>
<p><code><br />
TITLE#00#URL#00#</p>
<p>[anything here will be the post]</p>
<p>#00#TAGS#00#DESCRIPTION#00#AUTHOR#00#TIMESTAMP#99#<br />
</code><br />
Just copy and paste this block to add an entry, then fill in the fields.</p>
<p>As you can see the home page in the first example is marked with a single slash, as using index.html is usually bad for SEO.</p>
<p>How are we going to parse this flat file database in PHP?</p>
<p>First of all, we’ll have to read the file in memory. Then, explode articles and iterate over them. If an article matches the url the user requested, explode this article contents and fill the “Theme”.</p>
<p>To make everything clean and expandable, we’ll begin defining some config variables. Please note this code is very basic so that it’s easier to understand, and is compatible with PHP4 (BTW, if you are using PHP4 upgrade NOW). Feel free to optmize it if you are an experienced programmer.</p>
<pre class="php">
$config_db<span class="phpOperator">=</span><span class="phpFunction">dirname</span><span class="phpOperator">(</span><span class="phpConstant">__FILE__</span><span class="phpOperator">)</span>.<span class="phpString">"/db<span class="phpOperator">.</span>txt"</span><span class="phpText">;</span>  <span class="phpComment">// location of the database file, change this to something less obvious
</span>$config_site=<span class="phpString">"http<span class="phpOperator">:</span><span class="phpComment">//readytousesolutions<span class="phpOperator">.</span>com"</span><span class="phpText">;</span> // absolute url<span class="phpKeyword"> for </span>your domain here
</span>$config_theme=<span class="phpFunction">dirname</span><span class="phpOperator">(</span><span class="phpConstant">__FILE__</span><span class="phpOperator">)</span>.<span class="phpString">"/theme.html"</span><span class="phpText">;</span>  <span class="phpComment">// location of the <span class="phpString">"theme"</span> file, a single html page
</span>$config_date=<span class="phpString">"M jS, Y"</span><span class="phpText">;</span> <span class="phpComment">// how to format the date <span class="phpFunctionKeyword">function</span>, localize it<span class="phpKeyword"> if </span>you want
</span>
$found<span class="phpKeyword"><span class="phpOperator">=</span>false<span class="phpText">;</span></span> <span class="phpComment">// defaults to page not found
</span>
$u<span class="phpOperator">=</span><span class="phpFunction">parse_url</span><span class="phpOperator">(</span><span class="phpScriptVar">$_SERVER</span><span class="phpOperator">[</span><span class="phpString">'REQUEST_URI'</span><span class="phpOperator">]</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpComment">// this returns the actual file requested by the user
</span>$url=$u<span class="phpOperator">[</span>PHP_URL_PATH<span class="phpOperator">]</span><span class="phpText">;</span>
$url=<span class="phpFunction">basename</span> <span class="phpOperator">(</span><span class="phpScriptVar">$_SERVER</span><span class="phpOperator">[</span><span class="phpString">'REQUEST_URI'</span><span class="phpOperator">]</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span>$url<span class="phpOperator"><span class="phpOperator">=</span>=</span><span class="phpString">''</span><span class="phpOperator">)</span> $url=<span class="phpString">'/'</span><span class="phpText">;</span>                  <span class="phpComment">// force home page to be the single slash
</span>
$fp<span class="phpOperator">=</span>@<span class="phpFunction">fopen</span><span class="phpOperator">(</span>$config_db,<span class="phpString">"rb"</span><span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpComment">// the @ prevents errors from showing
</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span><span class="phpOperator">!</span>$fp<span class="phpOperator"><span class="phpOperator">=</span>=</span><span class="phpKeyword"><span class="phpOperator">=</span>false </span>&#038;amp<span class="phpText">;</span>&#038;amp<span class="phpText">;</span> $url<span class="phpOperator">!</span><span class="phpOperator">=</span><span class="phpString">"404<span class="phpOperator">.</span>html"</span><span class="phpOperator">)</span> <span class="phpComment">// this check saves <span class="phpFunction">time</span><span class="phpKeyword"> if </span>this is a 404 redirect
</span><span class="phpOperator">{</span>
 $data=<span class="phpFunction">fread</span><span class="phpOperator">(</span>$fp,<span class="phpFunction">filesize</span><span class="phpOperator">(</span>$config_db<span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword"> if<span class="phpOperator">(</span></span><span class="phpOperator">!</span> $data<span class="phpOperator"><span class="phpOperator">=</span>=</span><span class="phpKeyword"><span class="phpOperator">=</span>false </span><span class="phpOperator">)</span>
 <span class="phpOperator">{</span><span class="phpComment">// file was read in, we can parse it
</span>
     $articles=<span class="phpFunction">explode</span><span class="phpOperator">(</span><span class="phpString">"#99#"</span>,$data<span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpComment">// put each article in an array
</span>
    <span class="phpKeyword"> foreach<span class="phpOperator">(</span></span>$articles<span class="phpKeyword"> as </span>$article<span class="phpOperator">)</span>
     <span class="phpOperator">{</span>
     <span class="phpComment">/* now loop all articles looking<span class="phpKeyword"> for </span>the one that contains the url
     play it safe including #00# markers before and after the url, so that we can link between pages without problems */</span>
     $pos=<span class="phpFunction">strpos</span><span class="phpOperator">(</span>$article, <span class="phpString">"#00#"</span>.$url<span class="phpOperator">.</span><span class="phpString">"#00#"</span><span class="phpOperator">)</span><span class="phpText">;</span>
     <span class="phpKeyword"> if<span class="phpOperator">(</span></span>$pos <span class="phpOperator">!</span><span class="phpOperator"><span class="phpOperator">=</span>=</span><span class="phpKeyword"> false<span class="phpOperator">)</span></span>
      <span class="phpOperator">{</span><span class="phpComment">// this is the article we were looking<span class="phpKeyword"> for
</span>
</span>
          $found<span class="phpKeyword"><span class="phpOperator">=</span>true<span class="phpText">;</span></span>
          <span class="phpComment">// now <span class="phpFunction">explode</span> the article and exit the loop to save <span class="phpFunction">time</span>
</span>          $items=<span class="phpFunction">explode</span><span class="phpOperator">(</span><span class="phpString">"#00#"</span>,$article<span class="phpOperator">)</span><span class="phpText">;</span>
         <span class="phpKeyword"> break<span class="phpText">;</span></span>
      <span class="phpOperator">}</span>
     <span class="phpOperator">}</span>
     <span class="phpFunction">fclose</span><span class="phpOperator">(</span>$fp<span class="phpOperator">)</span><span class="phpText">;</span>
 <span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpKeyword">
else </span><span class="phpComment">// issue a 404 redirect and die
</span><span class="phpOperator">{</span>
<span class="phpFunction">header</span> <span class="phpOperator">(</span><span class="phpString">"HTTP/<span class="phpNumber">1</span><span class="phpOperator">.</span><span class="phpNumber">0</span> 404 Not Found 404<span class="phpOperator">.</span>html"</span><span class="phpOperator">)</span><span class="phpText">;</span>
exit;
<span class="phpOperator">}</span>
</pre>
<p>With this code, we’ll have $found set to true and the $items array filled if the page was in the database. We’ll complete the script in the next post, handling 404 errors and implementing the template system.</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/flatfile-php-cms-tutorial-part-2-the-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Flat File PHP CMS or Blog</title>
		<link>http://readytousesolutions.com/phpblog/simple-flat-file-php-cms-or-blog/</link>
		<comments>http://readytousesolutions.com/phpblog/simple-flat-file-php-cms-or-blog/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 05:13:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://readytousesolutions.com/phpblog/?p=345</guid>
		<description><![CDATA[In this and the next few posts, we’ll see how to create a simple flat file blog or CMS in PHP. I mean a really simple one, useful when you have just a few pages to manage, and installing WordPress &#8230; <a href="http://readytousesolutions.com/phpblog/simple-flat-file-php-cms-or-blog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this and the next few posts, we’ll see how to create a simple flat file blog or CMS in PHP.</p>
<p>I mean a really simple one, useful when you have just a few pages to manage, and installing WordPress would be an overkill.<br />
Why flat file?</p>
<p>Because you may need to populate many sites with content, using a cheap hosting service where mySql is not available, or has a limit on the number of simultaneous connections.</p>
<p>For a small number of articles, such as a Mini Site with 30/50 articles of 500 words each, the resulting file would be less than 50Kb and allow for immediate deployment of the site wherever you want.</p>
<p>To keep things simple and hacker proof, we’ll not include an admin backend. Adding articles will be done offline in a text editor.</p>
<p>Let’s start outlining the requirements for our blog/cms. It should be able to:</p>
<p>1. Handle SEO friendly urls<br />
This means urls will look like mysite.com/this-is-a-post.html instead of the ugly mysite.com/index.php?m=73.</p>
<p>2. Have SEO friendly page titles<br />
As well as per-page meta tags and meta descriptions.</p>
<p>3. Be able to be used as a Blog or as a CMS<br />
Here we’ll draw a line and state that author and post date are optional items. When present, the page will be considered a blog post. Otherwise a “static” page.</p>
<p>4. Be able to make use of custom or Artisteer templates<br />
If you don’t know Artisteer, it’s a remarkable piece of software, available both for Mac and Windows. It creates great looking cross browser templates for WordPress, Joomla, Drupal and static sites.</p>
<p>Hacking the xhtml template Artisteer provides, we’ll be able to quickly change the look of our Minisite.Of course we can also code the page by hand or using another web design tool.</p>
<p>5. Graceful error handling<br />
Providing a meaningful 404 error code if the url is not in the database is a must.</p>
<p>6. Expandable<br />
Again, the goal is to keep code as short and simple as possible, but with a little pre-planning we can make sure the script is scalable and can easily be expanded to handle more complex tasks.</p>
<p>Interested? then head on to the next post where we’ll start building it.</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/simple-flat-file-php-cms-or-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Mini Sites CMS</title>
		<link>http://readytousesolutions.com/phpblog/php-mini-sites-cms/</link>
		<comments>http://readytousesolutions.com/phpblog/php-mini-sites-cms/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 05:10:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://readytousesolutions.com/phpblog/?p=341</guid>
		<description><![CDATA[In this fourth post we’ll have to actually do something useful with our code. Simply add the following at the end of the previous script. if($found) {// set up variables with content $title=$items[0]; $url=$items[1]; $post=$items[2]; $tags=$items[3]; $description=$items[4]; $author=$items[5]; $date=$items[6]; } &#8230; <a href="http://readytousesolutions.com/phpblog/php-mini-sites-cms/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this fourth post we’ll have to actually do something useful with our code. Simply add the following at the end of the previous script.</p>
<pre class="php">
<span class="phpKeyword">
if<span class="phpOperator">(</span></span>$found<span class="phpOperator">)</span>
<span class="phpOperator">{</span><span class="phpComment">// set up variables with content
</span> $title=$items<span class="phpOperator">[</span><span class="phpNumber">0</span><span class="phpOperator">]</span><span class="phpText">;</span>
 $url=$items<span class="phpOperator">[</span><span class="phpNumber">1</span><span class="phpOperator">]</span><span class="phpText">;</span>
 $post<span class="phpOperator">=</span>$items<span class="phpOperator">[</span><span class="phpNumber">2</span><span class="phpOperator">]</span><span class="phpText">;</span>
 $tags=$items<span class="phpOperator">[</span><span class="phpNumber">3</span><span class="phpOperator">]</span><span class="phpText">;</span>
 $description<span class="phpOperator">=</span>$items<span class="phpOperator">[</span><span class="phpNumber">4</span><span class="phpOperator">]</span><span class="phpText">;</span>
 $author=$items<span class="phpOperator">[</span><span class="phpNumber">5</span><span class="phpOperator">]</span><span class="phpText">;</span>
 $date=$items<span class="phpOperator">[</span><span class="phpNumber">6</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpKeyword">
else
</span>
<span class="phpOperator">{</span> <span class="phpComment">//<span class="phpKeyword"> if </span>we get here there was a 404 error either<span class="phpKeyword"> for </span>malformed url or because we couldn<span class="phpString">'t read the <span class="phpFunction">file</span>
</span> $title=<span class="phpString">"Page not found"</span><span class="phpText">;</span>
 $url=<span class="phpString">"404<span class="phpOperator">.</span>html"</span><span class="phpText">;</span>
 $post<span class="phpOperator">=</span>'</span><span class="phpOperator">&lt;</span>h1<span class="phpOperator">&gt;</span>Ooops<span class="phpOperator">!</span> Page not found<span class="phpOperator">&lt;</span>/h1<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>p<span class="phpOperator">&gt;</span>Don\<span class="phpString">'t worry, this may happen<span class="phpOperator">.</span> Please go back to the <span class="phpOperator">&lt;</span>a href=<span class="phpString">"'</span>.$config_site.<span class="phpString">'"&gt;Home Page&lt;/a&gt;.';
 $tags="Not found, 404";
 $description="This page could not be found";
 $author=""</span><span class="phpText">;</span>
 $date=<span class="phpString">""</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
</span></pre>
<p>Now we have everything set up. We only need to populate our theme with the relevant content. We’ll use psuedo tags in the theme, like {title}, {post} and so on.</p>
<p>We’ll place those meta tags in our template, or the Artisteer template. Then save this file as “theme.html” or whatever name you prefer to use.</p>
<p>Here’s an extra simple theme with no styles, just to show the concept:</p>
<pre class="html">
<span class="htmlOtherTag">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span class="htmlOtherTag">&lt;html&gt;</span>
<span class="htmlOtherTag">&lt;head&gt;</span>
<span class="htmlOtherTag">&lt;title&gt;</span>{title}<span class="htmlOtherTag">&lt;/title&gt;</span>
<span class="htmlOtherTag">&lt;meta http-equiv=<span class="htmlAttributeValue">&quot;Content-Type&quot;</span> content=<span class="htmlAttributeValue">&quot;text/html; charset=utf-8&quot;</span>/&gt;</span>
<span class="htmlOtherTag">&lt;meta name=<span class="htmlAttributeValue">&quot;description&quot;</span> content=<span class="htmlAttributeValue">&quot;{description}&quot;</span> /&gt;</span>
<span class="htmlOtherTag">&lt;meta name=<span class="htmlAttributeValue">&quot;keywords&quot;</span> content=<span class="htmlAttributeValue">&quot;{tags}&quot;</span> /&gt;</span>
<span class="htmlOtherTag">&lt;meta http-equiv=<span class="htmlAttributeValue">&quot;X-UA-Compatible&quot;</span> content=<span class="htmlAttributeValue">&quot;IE=8&quot;</span> /&gt;</span>
<span class="htmlOtherTag">&lt;link href=<span class="htmlAttributeValue">&quot;put-your-css-here.css&quot;</span> type=<span class="htmlAttributeValue">&quot;text/css&quot;</span> rel=<span class="htmlAttributeValue">&quot;stylesheet&quot;</span> /&gt;</span>
<span class="htmlOtherTag">&lt;link href=<span class="htmlAttributeValue">&quot;i/favicon.ico&quot;</span> rel=<span class="htmlAttributeValue">&quot;SHORTCUT ICON&quot;</span> /&gt;</span>
<span class="htmlScriptTag">&lt;script type=<span class="htmlAttributeValue">&quot;text/javascript&quot;</span> src=<span class="htmlAttributeValue">&quot;put-your-javascript-here.js&quot;</span>&gt;</span><span class="htmlScriptTag">&lt;/script&gt;</span>
<span class="htmlOtherTag">&lt;/head&gt;</span>
<span class="htmlOtherTag">&lt;body&gt;</span>
<span class="htmlOtherTag">&lt;h1&gt;</span>{title}<span class="htmlOtherTag">&lt;/h1&gt;</span>
<span class="htmlOtherTag">&lt;h2&gt;</span>{blog}<span class="htmlOtherTag">&lt;/h2&gt;</span>
{post}
<span class="htmlOtherTag">&lt;/body&gt;</span>
<span class="htmlOtherTag">&lt;/html&gt;</span>
</pre>
<p>This approach is slower than echoing the variables in the page itself, as it requires reading the theme and performing string replacements, but gives us a clean separation between the theme and the code, and makes this project easily scalable.</p>
<pre class="php">
$fp<span class="phpOperator">=</span>@<span class="phpFunction">fopen</span><span class="phpOperator">(</span>$config_theme,<span class="phpString">"rb"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span>$fp<span class="phpOperator">!</span><span class="phpOperator">=</span><span class="phpKeyword"><span class="phpOperator">=</span>false<span class="phpOperator">)</span></span>
<span class="phpOperator">{</span>
<span class="phpKeyword"> if<span class="phpOperator">(</span></span><span class="phpKeyword"> false </span><span class="phpOperator">!</span><span class="phpOperator"><span class="phpOperator">=</span>=</span> <span class="phpOperator">(</span>$data=<span class="phpFunction">fread</span><span class="phpOperator">(</span>$fp,<span class="phpFunction">filesize</span><span class="phpOperator">(</span>$config_theme<span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpOperator">)</span>
 <span class="phpOperator">{</span><span class="phpComment">// theme was read in, we can fill it with the data
</span>
     $data=<span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">"<span class="phpOperator">{</span>title<span class="phpOperator">}</span>"</span>,$title,$data<span class="phpOperator">)</span><span class="phpText">;</span>
     $data=<span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">"<span class="phpOperator">{</span>post<span class="phpOperator">}</span>"</span>,$post,$data<span class="phpOperator">)</span><span class="phpText">;</span>
     $data=<span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">"<span class="phpOperator">{</span>tags<span class="phpOperator">}</span>"</span>,$tags,$data<span class="phpOperator">)</span><span class="phpText">;</span>
     $data=<span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">"<span class="phpOperator">{</span>description<span class="phpOperator">}</span>"</span>,$description,$data<span class="phpOperator">)</span><span class="phpText">;</span>
     $blog<span class="phpOperator">=</span><span class="phpString">''</span><span class="phpText">;</span>
    <span class="phpKeyword"> if<span class="phpOperator">(</span></span>$author<span class="phpOperator">!</span><span class="phpOperator">=</span><span class="phpString">''</span> &#038;amp<span class="phpText">;</span>&#038;amp<span class="phpText">;</span> $<span class="phpFunction">date</span> <span class="phpOperator">!</span><span class="phpOperator">=</span><span class="phpString">''</span><span class="phpOperator">)</span>
     <span class="phpOperator">{</span>
      $blog<span class="phpOperator">=</span><span class="phpString">"Posted by "</span>.$author.<span class="phpString">" on "</span>.<span class="phpFunction">date</span><span class="phpOperator">(</span>$config_<span class="phpFunction">date</span>,$<span class="phpFunction">date</span><span class="phpOperator">)</span><span class="phpText">;</span>
     <span class="phpOperator">}</span>
     $data=<span class="phpFunction">str_replace</span><span class="phpOperator">(</span><span class="phpString">"<span class="phpOperator">{</span>blog<span class="phpOperator">}</span>"</span>,$blog,$data<span class="phpOperator">)</span><span class="phpText">;</span>
     <span class="phpFunction">echo</span> $data<span class="phpText">;</span>
 <span class="phpOperator">}</span>
 <span class="phpFunction">fclose</span><span class="phpOperator">(</span>$fp<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpKeyword">
else
</span>
<span class="phpOperator">{</span>
<span class="phpFunction">echo</span> <span class="phpString">'Internal error'</span><span class="phpText">;</span> <span class="phpComment">// could not read the theme<span class="phpOperator">!</span>
</span><span class="phpOperator">}</span>
</pre>
<p>Makes sense? Hope so, because there’s not much more to be done. Save the script as index.php, then create or edit the .htaccess file. We need a rewrite rule to pass everything the user requests to index.php.<br />
The .htaccess rewrite rule</p>
<p>Now, if there’s something I really don’t like to do it must be writing rewrite rules. I’m no Apache guru and have never studied them formally like I did for programming. But this one is really simple to use and understand.</p>
<p><code><br />
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . /index.php [L]<br />
</code></p>
<p>First, we turn on the rewrite engine and say everything is relative to the web root.</p>
<p>Then, there are two rewrite conditions, almost identical. They check if a file (-f) or a directory (-d) exists. If so, the existing file or directory is served.</p>
<p>Otherwise, the rewrite rule is invoked, and points to /index.php, our code. Note that no redirection is performed, so this will return an OK 200 status and the user’s browser will still display the originally requested url.<br />
That’s almost all, folks</p>
<p>Okay that’s all. The simple cms is ready. However it’s still a bit poor, even adding a nice artisteer template it will have no navigation. We may want to add RSS, a sitemap, even some widgets. As long as there’s no user submitted content, like comments, we can do everything without writing to our server. And we’ll see how in the next post.</p>
<p>Feel free to comment, ask questions and suggest how to expand this simple flat file php CMS. I’m not sure it’s worth to add an administrative panel, as this is really meant to be a set and forget script, but will wait for your suggestions.</p>
<p>Thanks for reading so far, have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-mini-sites-cms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Validate email address &#8211; simple way with filter_var() function</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-validate-email-address-simple-way-with-filter_var-function/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-validate-email-address-simple-way-with-filter_var-function/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 07:39:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Usefull PHP]]></category>
		<category><![CDATA[php filter_var() function]]></category>
		<category><![CDATA[php validate email address]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=337</guid>
		<description><![CDATA[While browsing php.net without any scope I discovered a very cute &#38; nice way to replace the usual regular expression email checking thing. That way is via filter_var() php function which does the things 10 times faster : &#60;?php $email &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-validate-email-address-simple-way-with-filter_var-function/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While browsing php.net without any scope I discovered a very cute &amp; nice way to replace the usual regular expression email checking thing.</p>
<p>That way is via filter_var() php function which does the things 10 times faster :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$email <span class="phpOperator">=</span> <span class="phpString">"someone@example.com"</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span><span class="phpOperator">!</span><span class="phpFunction">filter_var</span><span class="phpOperator">(</span>$email, FILTER_VALIDATE_EMAIL<span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpFunction">echo</span> <span class="phpString">"Invalid email address"</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-validate-email-address-simple-way-with-filter_var-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorials : Rename a mysql table</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorials-rename-a-mysql-table/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorials-rename-a-mysql-table/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 08:19:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Php & MySQL]]></category>
		<category><![CDATA[mysql rename table]]></category>
		<category><![CDATA[php rename mysql table]]></category>
		<category><![CDATA[rename database table]]></category>
		<category><![CDATA[rename mysql table]]></category>
		<category><![CDATA[rename table]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=335</guid>
		<description><![CDATA[If you want to rename a mysql table via php you just need an extremely simple query like the one it&#8217;s following: &#60;?php //include db credentials mysql_query("rename table TheOldName to TheNewName"); ?&#62;]]></description>
			<content:encoded><![CDATA[<p>If you want to rename a mysql table via php you just need an extremely simple query like the one it&#8217;s following:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">/<span class="phpKeyword"><span class="phpKeyword">/include </span></span>db credentials
</span>
<span class="phpFunction">mysql_query</span><span class="phpOperator">(</span><span class="phpString">"rename table TheOldName to TheNewName"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorials-rename-a-mysql-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Seo Tips &amp; Tricks : Get indexed in google very fast</title>
		<link>http://readytousesolutions.com/phpblog/seo-tips-tricks-get-indexed-in-google-very-fast/</link>
		<comments>http://readytousesolutions.com/phpblog/seo-tips-tricks-get-indexed-in-google-very-fast/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 07:10:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Seo Tips & Tricks]]></category>
		<category><![CDATA[Get indexed in google very fast]]></category>
		<category><![CDATA[get into google]]></category>
		<category><![CDATA[getting into google's cache fast]]></category>
		<category><![CDATA[seo tip]]></category>
		<category><![CDATA[seo trick]]></category>
		<category><![CDATA[unique seo trick]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=333</guid>
		<description><![CDATA[I&#8217;ve heard this question too many times to stay without telling this amazing unique seo trick / tip. You may know that doing social bookmarking, forum posting, getting an article to a popular blog, etc. will help getting indexed faster &#8230; <a href="http://readytousesolutions.com/phpblog/seo-tips-tricks-get-indexed-in-google-very-fast/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve heard this question too many times to stay without telling this amazing unique seo trick / tip.</p>
<p>You may know that doing social bookmarking, forum posting, getting an article to a popular blog, etc. will help getting indexed faster in google.</p>
<p>But, pay attention, no other trick than<strong> opening an adwords campaign</strong> with your site will make it go into google&#8217;s cache faster.</p>
<p>It simply doesn&#8217;t matter how much money you put, 1.00$ or 100$, etc.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/seo-tips-tricks-get-indexed-in-google-very-fast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Write text and convert into image</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-write-text-and-convert-into-image/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-write-text-and-convert-into-image/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 05:07:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Usefull PHP]]></category>
		<category><![CDATA[php convert text into image]]></category>
		<category><![CDATA[php email to image]]></category>
		<category><![CDATA[php merge text into image]]></category>
		<category><![CDATA[php write text to an image]]></category>
		<category><![CDATA[php write to image]]></category>
		<category><![CDATA[Write text and convert into image]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=328</guid>
		<description><![CDATA[The base usage in my mind when I write this tutorial to convert text into image with php is to write email into images dinamically to avoid spammers collecting such addresses from the internet. To run such a script you &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-write-text-and-convert-into-image/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The base usage in my mind when I write this tutorial to convert text into image with php is to write email into images dinamically to avoid spammers collecting such addresses from the internet.</p>
<p>To run such a script you must have GD library installed. We&#8217;ll take parametres via GET and merge into image:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction">isset</span><span class="phpOperator">(</span><span class="phpScriptVar">$_GET</span><span class="phpOperator">[</span><span class="phpString">'text'</span><span class="phpOperator">]</span><span class="phpOperator">)</span><span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="phpFunction">die</span><span class="phpOperator">(</span><span class="phpString">"No text provided"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpFunction">header</span> <span class="phpOperator">(</span><span class="phpString">"Content-type<span class="phpOperator">:</span> image/png"</span><span class="phpOperator">)</span><span class="phpText">;</span>
$textToConvert <span class="phpOperator">=</span> <span class="phpScriptVar">$_GET</span><span class="phpOperator">[</span><span class="phpString">'text'</span><span class="phpOperator">]</span><span class="phpText">;</span>
$font   <span class="phpOperator">=</span> <span class="phpNumber">4</span><span class="phpText">;</span>
$width  <span class="phpOperator">=</span><span class="htmlText"> ImageFontWidth</span><span class="phpOperator">(</span>$font<span class="phpOperator">)</span> * <span class="phpFunction">strlen</span><span class="phpOperator">(</span>$textToConvert<span class="phpOperator">)</span><span class="phpText">;</span>
$height <span class="phpOperator">=</span><span class="htmlText"> ImageFontHeight</span><span class="phpOperator">(</span>$font<span class="phpOperator">)</span><span class="phpText">;</span>
$im <span class="phpOperator">=</span> @<span class="phpFunction">imagecreate</span> <span class="phpOperator">(</span>$width,$height<span class="phpOperator">)</span><span class="phpText">;</span>
$background_color <span class="phpOperator">=</span> <span class="phpFunction">imagecolorallocate</span> <span class="phpOperator">(</span>$im, 255, 255, 255<span class="phpOperator">)</span><span class="phpText">;</span> <span class="phpComment">//this means it&#039;s white bg
</span>$text_color <span class="phpOperator">=</span> <span class="phpFunction">imagecolorallocate</span> <span class="phpOperator">(</span>$im, <span class="phpNumber">0</span>, <span class="phpNumber">0</span>,0<span class="phpOperator">)</span><span class="phpText">;</span><span class="phpComment">//and of course black text
</span><span class="phpFunction">imagestring</span> <span class="phpOperator">(</span>$im, $font, <span class="phpNumber">0</span>, <span class="phpNumber">0</span>,  $textToConvert, $text_color<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">imagepng</span> <span class="phpOperator">(</span>$im<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Save this as textToImage.php and then when you want to create the image and read text do it like :</p>
<pre class="html">
<span class="htmlImageTag">&lt;img src=<span class="htmlAttributeValue">&quot;textToImage.php?text=emailAddress@emailProvider.com&quot;</span>&gt;</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-write-text-and-convert-into-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Get Browser Name &amp; It&#8217;s Capabilities</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-get-browser-name-its-capabilities/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-get-browser-name-its-capabilities/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 05:34:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Usefull PHP]]></category>
		<category><![CDATA[php browser name]]></category>
		<category><![CDATA[php detect visitor browser]]></category>
		<category><![CDATA[php get browser]]></category>
		<category><![CDATA[php get browser capabilities]]></category>
		<category><![CDATA[php get user browser]]></category>
		<category><![CDATA[php get user browser name]]></category>
		<category><![CDATA[php get_browser]]></category>
		<category><![CDATA[php get_browser() function]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=326</guid>
		<description><![CDATA[To get browser name just use next thing : &#60;?php print $_SERVER['HTTP_USER_AGENT']; ?&#62; And for all the features of browser user : &#60;?php print_r(get_browser(null, true));//null for user agent &#038;amp; true to return array ?&#62;]]></description>
			<content:encoded><![CDATA[<p>To get browser name just use next thing :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpFunction">print</span> <span class="phpScriptVar">$_SERVER</span><span class="phpOperator">[</span><span class="phpString">'HTTP_USER_AGENT'</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>And for all the features of browser user :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpFunction">print_r</span><span class="phpOperator">(</span><span class="phpFunction">get_browser</span><span class="phpOperator">(</span>null,<span class="phpKeyword"> true<span class="phpOperator">)</span></span><span class="phpOperator">)</span><span class="phpText">;</span><span class="phpComment">//null<span class="phpKeyword"> for </span>user agent &#038;amp<span class="phpText">;</span><span class="phpKeyword"> true </span><span class="htmlText">to</span><span class="phpKeyword"> return </span>array
</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-get-browser-name-its-capabilities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ventrilo Server Hosting</title>
		<link>http://readytousesolutions.com/phpblog/ventrilo-server-hosting/</link>
		<comments>http://readytousesolutions.com/phpblog/ventrilo-server-hosting/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 04:51:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Ventrilo Server Hosting]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=324</guid>
		<description><![CDATA[Ventrilo is a voice over IP program that allows multiple people to communicate with each other over an internet connection. You have a choice of audio codecs like Speex and GSM, Ventrilo is based on the client-server model, the client &#8230; <a href="http://readytousesolutions.com/phpblog/ventrilo-server-hosting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://ugt-servers.com">Ventrilo</a> is a voice over IP program that allows multiple people to communicate with each other over an internet connection. You have a choice of audio codecs like Speex and GSM, Ventrilo is based on the client-server model, the client will reside on your computer and the server will relay all of the data from the other clients to your computer. <a href="http://http://ugt-servers.com/ventrilo-hosting.php">Ventrilo server</a> hosting is fairly affordable, starting at $2.91 per month for 10 users.</p>
<p>Ventrilo is a great utility for development teams who like to keep in touch without having to deal with IM programs.</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/ventrilo-server-hosting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.794 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-19 16:11:30 -->

