<?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>Dazzle CMS &#187; Servers</title>
	<atom:link href="http://blog.dazzlecms.com/category/servers/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dazzlecms.com</link>
	<description>Dazzle Development Blog</description>
	<lastBuildDate>Tue, 10 Aug 2010 22:15:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>error: unpacking of archive failed</title>
		<link>http://blog.dazzlecms.com/servers/error-unpacking-of-archive-failed/</link>
		<comments>http://blog.dazzlecms.com/servers/error-unpacking-of-archive-failed/#comments</comments>
		<pubDate>Sat, 29 May 2010 02:16:41 +0000</pubDate>
		<dc:creator>Dazzle CMS</dc:creator>
				<category><![CDATA[Servers]]></category>

		<guid isPermaLink="false">http://blog.dazzlecms.com/?p=49</guid>
		<description><![CDATA[After alot of research and running of our own servers we seem time and time again with yum and up2date and even rpm updates with the following error error: unpacking of archive failed on file /bin/tar: cpio: rename failed even when you logged in root and see the same issue to solve this message logged [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Ferror-unpacking-of-archive-failed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Ferror-unpacking-of-archive-failed%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>After alot of research and running of our own servers we seem time and time again with yum and up2date and even rpm updates with the following error </p>
<p><code>error: unpacking of archive failed on file /bin/tar: cpio: rename failed</code></p>
<p>even when you logged in root and see the same issue</p>
<p>to solve this message logged in as root run the following command</p>
<p><code>chattr -ais <filename> </code></p>
<p>for example:</p>
<p><code>chattr -ais /bin/tar</code></p>
<p>now run yum upgrade or RPM</p>
<p>if you still have issues just leave comments and i will find an solution for you!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dazzlecms.com/servers/error-unpacking-of-archive-failed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Install RED5 Server on Centos 5.4</title>
		<link>http://blog.dazzlecms.com/servers/red5/how-to-install-red5-server-on-centos-5-4/</link>
		<comments>http://blog.dazzlecms.com/servers/red5/how-to-install-red5-server-on-centos-5-4/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 23:15:21 +0000</pubDate>
		<dc:creator>Dazzle CMS</dc:creator>
				<category><![CDATA[Red5]]></category>

		<guid isPermaLink="false">http://blog.dazzlecms.com/?p=42</guid>
		<description><![CDATA[How To Install RED5 Server on Centos 5.4 In this how to i will describe how to install RED5 server on Centos 5.4.x This how to can be used to install RED5 server on Centos 4 and Fedora 8 – 11 as well. RED5 is open source flash server written in java supports streaming audio/video, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Fred5%2Fhow-to-install-red5-server-on-centos-5-4%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Fred5%2Fhow-to-install-red5-server-on-centos-5-4%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<ul>
<li>
<div>
<div>
<h1><a title="Permanent Link to How To Install RED5 Server  on Centos 5.3" rel="bookmark" href="http://www.sohailriaz.com/how-to-install-red5-server-on-centos-53/"> </a>How To Install RED5 Server on Centos 5.4</h1>
</div>
</div>
</li>
</ul>
<p>In this how to i will describe how to install RED5 server on  Centos 5.4.x This how to can be used to install RED5 server on Centos 4  and Fedora 8 – 11 as well. RED5 is open source flash server written in  java supports streaming audio/video, recording client streams, shared  objects, live stream publishing etc.</p>
<h3>1) Download and Install Java</h3>
<p>RED5 server depends on Java. CentOS 5.4 comes with OpenJDK 1.6 and  install it using yum.</p>
<blockquote><p>yum install java-1.6.0-openjdk java-1.6.0-openjdk-devel java-1.6.0-openjdk-javadoc java-1.6.0-openjdk-src</p></blockquote>
<h3>2) Download and Install Ant (Apache Project)</h3>
<p>Ant will need to compile RED5 server code. Ant comes in binary form,  so just download and install it in /usr/local directory.</p>
<blockquote><p>cd /usr/src<br />
wget http://apache.sunsite.ualberta.ca/ant/binaries/apache-ant-1.8.0-bin.tar.bz2<br />
tar jxvf apache-ant-1.8.0-bin.tar.bz2<br />
mv apache-ant-1.8.0 /usr/local/ant</p></blockquote>
<h3>3) Export Variables for Ant and Java</h3>
<blockquote><p>export ANT_HOME=/usr/local/ant<br />
export JAVA_HOME=/usr/lib/jvm/java<br />
export PATH=$PATH:/usr/local/ant/bin<br />
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip</p></blockquote>
<p>Also export these variables in /etc/bashrc to become available for  every user login or for any terminal opens.</p>
<blockquote><p>echo ‘export ANT_HOME=/usr/local/ant’ &gt;&gt;  /etc/bashrc<br />
echo ‘export JAVA_HOME=/usr/lib/jvm/java’ &gt;&gt; /etc/bashrc<br />
echo ‘export PATH=$PATH:/usr/local/ant/bin’ &gt;&gt; /etc/bashrc<br />
echo ‘export CLASSPATH=.:$JAVA_HOME/lib/classes.zip’ &gt;&gt;  /etc/bashrc</p></blockquote>
<h3>4) Download and Install RED5 Server</h3>
<p>Here the latest version available for RED5 is 0.9 on site but  download from google code using svn as the tarball of 0.9 on site is  missing some of the files.</p>
<blockquote><p>cd /usr/src<br />
svn checkout http://red5.googlecode.com/svn/java/server/trunk/ red5<br />
mv red5 /usr/local/<br />
cd /usr/local/red5<br />
ant prepare<br />
ant dist</p></blockquote>
<p>you will see a ton of lines, but you should get at last</p>
<p><strong>BUILD SUCCESSFUL</strong></p>
<p>that’s mean its install and now copy the conf directory from dist/  and test the red5 installation.</p>
<blockquote><p>cp -r dist/conf .<br />
./red5.sh</p></blockquote>
<p>If it shows Installer service created in the last then everything is  fine here, press ctrl+c and move to next step to create init script.</p>
<h3>5) Init Script</h3>
<p>Now we will create init script for red5 to start, stop and restart  easily.</p>
<blockquote><p>vi /etc/init.d/red5</p></blockquote>
<p>The init script code below:</p>
<blockquote><p>#!/bin/sh<br />
# For RedHat and cousins:<br />
# chkconfig: 2345 85 85<br />
# description: Red5 flash streaming server<br />
# processname: red5</p>
<p>PROG=red5<br />
RED5_HOME=/usr/local/red5<br />
DAEMON=$RED5_HOME/$PROG.sh<br />
PIDFILE=/var/run/$PROG.pid</p>
<p># Source function library<br />
. /etc/rc.d/init.d/functions</p>
<p>[ -r /etc/sysconfig/red5 ] &amp;&amp; . /etc/sysconfig/red5</p>
<p>RETVAL=0</p>
<p>case “$1″ in<br />
start)<br />
echo -n $”Starting $PROG: ”<br />
cd $RED5_HOME<br />
$DAEMON &gt;/dev/null 2&gt;/dev/null &amp;<br />
RETVAL=$?<br />
if [ $RETVAL -eq 0 ]; then<br />
echo $! &gt; $PIDFILE<br />
touch /var/lock/subsys/$PROG</p>
<p>fi<br />
[ $RETVAL -eq 0 ] &amp;&amp; success $”$PROG startup” || failure $”$PROG  startup”<br />
echo<br />
;;<br />
stop)<br />
echo -n $”Shutting down $PROG: ”<br />
killproc -p $PIDFILE<br />
RETVAL=$?<br />
echo<br />
[ $RETVAL -eq 0 ] &amp;&amp; rm -f /var/lock/subsys/$PROG<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
status)<br />
status $PROG -p $PIDFILE<br />
RETVAL=$?<br />
;;<br />
*)<br />
echo $”Usage: $0 {start|stop|restart|status}”<br />
RETVAL=1<br />
esac</p>
<p>exit $RETVAL</p></blockquote>
<p>Now start the service</p>
<blockquote><p>/etc/init.d/red5 start</p></blockquote>
<p>check status</p>
<blockquote><p>/etc/init.d/red5 status<br />
red5 (pid  XXXXX) is running…</p></blockquote>
<p>again you can do stop, restart.</p>
<h3>6) Test</h3>
<p>Now test the RED5 installation by opening following URL in browser</p>
<p>http://yourip:5080/</p>
<p>you will see red5 page like this</p>
<p><img title="red5_11" src="http://www.sohailriaz.com/wp-content/uploads/2009/08/red5_11.jpeg" alt="red5_11" width="450" height="269" /></p>
<p>and demos can be find here.</p>
<p>http://yourip:5080/demos/</p>
<p><img title="red5_21" src="http://www.sohailriaz.com/wp-content/uploads/2009/08/red5_21.jpeg" alt="red5_21" width="400" height="239" /></p>
<p>You can use simple port tester tool that determines which ports the  Flash Player is able to connect through to the Red5 server. Put your  server address or IP in HOST when using port tester. You should get  SUCCESS on RTMP or port 1935. If not please check your firewall.</p>
<p>http://yourip:5080/demos/port_tester.html</p>
<p><img title="red5_3" src="http://www.sohailriaz.com/wp-content/uploads/2009/08/red5_3.jpeg" alt="red5_3" width="400" height="239" /></p>
<h3>7) ISSUE</h3>
<p>When you run ./red5.sh, it will show you <strong>Installer service  created</strong>. Thats mean everything runs fine and red5 server is up.  But if you went to port_tester.swf using demos above or your  application shows connections FAILS, this is an issue of RTMPT and  RTMPTS. You can see it by running</p>
<blockquote><p>/usr/local/red5/red5.sh</p>
<p>output trancated</p>
<p>[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPT server bean  was not found<br />
[INFO] [main] org.red5.server.tomcat.TomcatLoader – RTMPS server bean  was not found</p>
<p>output truncated</p></blockquote>
<p>If you see this you have to uncomment the RTMPT and RTMPTS  TomcatLoader in<strong>/usr/local/red5/conf/red5-core.xml</strong></p>
<blockquote><p>vi /usr/local/red5/conf/red5-core.xml</p></blockquote>
<p>Search for a lines</p>
<blockquote><p>&lt;!– RTMPT –&gt;<br />
&lt;!–<br />
&lt;bean id=”rtmpt.server”  class=”org.red5.server.net.rtmpt.TomcatRTMPTLoader” init-method=”init”  lazy-init=”true”&gt;</p></blockquote>
<p>Remove the &lt;!– from start of &lt;bean and –&gt; from end of  &lt;/bean&gt;</p>
<p>Same goes for RTMPS</p>
<blockquote><p>&lt;!– RTMPS –&gt;<br />
&lt;!–<br />
&lt;bean id=”rtmps.server”  class=”org.red5.server.net.rtmps.TomcatRTMPSLoader” init-method=”init”  lazy-init=”true”&gt;</p></blockquote>
<p>Remove the &lt;!– from start of &lt;bean and –&gt; from end of  &lt;/bean&gt;</p>
<p>Restart the red5 services and connection fails problem will be fixed.</p>
<p>If you any question please use comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dazzlecms.com/servers/red5/how-to-install-red5-server-on-centos-5-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Benefits of Running IIS7.5 Over IIS6 Or Apache</title>
		<link>http://blog.dazzlecms.com/servers/apache/benefits-of-running-iis7-5-over-iis6-or-apache/</link>
		<comments>http://blog.dazzlecms.com/servers/apache/benefits-of-running-iis7-5-over-iis6-or-apache/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 05:42:54 +0000</pubDate>
		<dc:creator>Dazzle CMS</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://blog.dazzlecms.com/?p=30</guid>
		<description><![CDATA[IIS7.5 &#8211; The latest and greatest from Microsoft. IIS7.5 is the latest iteration of the Microsoft&#8217;s web server. Formerly know as the Internet Information Server, IIS has come to dominate most of the servers belonging to Fortune 100 companies though Apache remains the market leader overall. According to the latest statistics over a third of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Fapache%2Fbenefits-of-running-iis7-5-over-iis6-or-apache%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Fapache%2Fbenefits-of-running-iis7-5-over-iis6-or-apache%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<div id="body">
<p>IIS7.5 &#8211; The latest and greatest from Microsoft.</p>
<p><strong>IIS7</strong>.5 is the latest iteration of the Microsoft&#8217;s web server. Formerly know as the Internet Information Server, IIS has come to dominate most of the servers belonging to Fortune 100 companies though Apache remains the market leader overall. According to the latest statistics over a third of all sites are backed by IIS.</p>
<p>Benefits of IIS7.5 over IIS6</p>
<p>IIS7.5 is one of the more significant updates to the IIS platform. The biggest change is the modular nature of the engine. This means that one can configure IIS7.5 to support only features that are needed, adding more as and when necessary. In addition to improving it&#8217;s flexibility, this leads to a significant leap in security. For example, you can add modules from scripting and even backward compatibility.</p>
<p>Another significant improvement, is the use of an XML based web.config file (just like in .NET applications) to handle the configuration of the entire server configuration. This leads to improvements in portability, fine tuning as well as ease of access compared with the previous hierarchical metabase storage up until IIS6.</p>
<p>There is also good news for <strong>VPN users</strong>. IIS7.5 has improved it&#8217;s remote management capability by providing secure HTTP connections though you have to enable remote management manually. But that can be good as some viewed the earlier setup as more vulnerable.</p>
<p>Though there are many more improvements, let us look at some reasons why you should an IIS7.5 engine over a more traditional server like Apache.</p>
<p>Benefits of IIS7.5 over Apache</p>
<p>For most people the ability to use PHP scripts on IIS used to deter them from using a Windows platform. Even a hosting provider like Godaddy disallows the use of a PHP based application like WordPress on a Windows server. However, the latest releases of IIS and especially IIS 7.5 give massive performance improvements while running PHP scripts to the extent that PHP is no longer the sole reason not to choose IIS.</p>
<p>Today more and more site owners are turning to Windows to host their PHP based applications, and WordPress on windows is picking up a huge following.  Thanks to improvements around PHP and IIS through the cooperative efforts of Zend and Microsoft, PHP performance is much more stable, reliable and faster than it was on earlier versions.</p>
<p>Of course, if you plan to make use of the awesome .NET platform, then IIS 7.5 is your only choice. With the latest release of ASP.NET 3.5 and full support for the MVC framework there has never been a more compelling time to develop applications in .NET. In addition, Microsoft&#8217;s Web PI  has made it easier than ever to install all .NET related components. IIS 7.5 has also significantly improved it&#8217;s usability interface eschewing the full MMC framework it had earlier.</p>
<p>IIS7.5 also features improved diagnostics capability with advanced error tracking that allows you to trace errors based on the conditions you want IIS to look out for. This could be tracking down timed out pages or other errors through it&#8217;s &#8220;failed request tracing&#8221; capability.</p>
<p>Summary</p>
<p>All in all, this is the time to switch over to a Windows platform if you&#8217;ve been sitting on the fence till now. The new security features coupled with the flexibility, ease of use and diagnostics have made IIS 7.5 quite an irresistible choice for those looking to host their web applications.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.dazzlecms.com/servers/apache/benefits-of-running-iis7-5-over-iis6-or-apache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FTP Servers Being Replaced With Online Services</title>
		<link>http://blog.dazzlecms.com/servers/apache/ftp-servers-being-replaced/</link>
		<comments>http://blog.dazzlecms.com/servers/apache/ftp-servers-being-replaced/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 05:08:13 +0000</pubDate>
		<dc:creator>Dazzle CMS</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[Servers]]></category>

		<guid isPermaLink="false">http://blog.dazzlecms.com/?p=27</guid>
		<description><![CDATA[FTP Servers are still the most popular way to store and transfer large files. As browsers get better suited to dealing with file uploads and downloads, new web services are emerging to replace FTP. Online file transfer and sharing services provide an affordable, easy-to-use alternative to traditional FTP servers. Why should you consider replacing your [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Fapache%2Fftp-servers-being-replaced%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.dazzlecms.com%2Fservers%2Fapache%2Fftp-servers-being-replaced%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<div id="body">
<p>FTP Servers are still the most popular way to store and transfer large files. As browsers get better suited to dealing with file uploads and downloads, new web services are emerging to replace FTP. Online file transfer and sharing services provide an affordable, easy-to-use alternative to traditional FTP servers.</p>
<p>Why should you consider replacing your FTP server?</p>
<p>1. Easy to Use: Online file transfer sites are easier to use than FTP, can be accessed through a web browser, require no additional downloads and can be accessed from anywhere.</p>
<p>2. More Secure: With most web-based transfer services, passwords are always sent over an encrypted connection.</p>
<p>3. Branded Experience: You can customize the look and style of your file transfer service and upload your company logo for a branded experience.</p>
<p>4. Activity Notifications: Receive notifications when users upload or download files, leave comments, or make any changes to files.</p>
<p>5. View Files Online: With file previews, you can view images and common office documents online without the need to download.</p>
<p>6. Search: Quickly find documents by searching through the title and content of Word documents, PowerPoint files, Spreadsheets, PDF documents and more.</p>
<p>7. Integrate with Your Website: Web-based services can be easily linked to from your existing website to provide a seamless experience to your clients and partners.</p>
<p>8. Manage Users: Controlling access to files is simple and does not require calling the IT department any time you need to add users, remove users, or reset your password.</p>
<p>9. Comments: Post comments on files to leave messages and communicate with other members of the Hub.</p>
<p>10. Version Control: Version history lets you view the history of previous versions, compare them to one another and restore an older document.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.dazzlecms.com/servers/apache/ftp-servers-being-replaced/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>smarty 3</title>
		<link>http://blog.dazzlecms.com/php/smarty3/</link>
		<comments>http://blog.dazzlecms.com/php/smarty3/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 21:14:17 +0000</pubDate>
		<dc:creator>Dazzle CMS</dc:creator>
				<category><![CDATA[Dazzle CMS]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[smarty]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://blog.dazzlecms.com/?p=14</guid>
		<description><![CDATA[Intended Audience This article is intended for PHP programmers and HTML designers interested in applying a new technique for web development – PHP templating. Advanced knowledge of PHP programming and HTML is assumed. Smarty3 Overview The theoretical web development process is that: first the designer makes the interface, and breaks it down into HTML pieces [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.dazzlecms.com%2Fphp%2Fsmarty3%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.dazzlecms.com%2Fphp%2Fsmarty3%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Intended Audience</p>
<p>This article is intended for PHP programmers and HTML designers interested in applying a new technique for web development – PHP templating. Advanced knowledge of PHP programming and HTML is assumed.</p>
<p>Smarty3 Overview</p>
<p>The theoretical web development process is that: first the designer makes the interface, and breaks it down into HTML pieces for the programmer then the programmer implements the PHP business logic into the HTML.</p>
<p>That’s fine in theory, but in practice, from my experience, the client frequently comes with more requirements, or maybe more modifications to the design or to the business logic. When this happens , the HTML is modified (or words rebuilt ) programmer changes the code inside HTML.</p>
<p>The problem with this scenario is that the programmer needs to be on stand-by until the designer completes the layout and the HTML files. Another problem is that if there is a major design change then the programmer will change the code to fit in the new page. And that’s why I recommand Smarty. Smarty is a templating engine for PHP.</p>
<p>You can download it from http://www.smarty.net or svn checkout http://smarty-php.googlecode.com/svn/branches/Smarty3Alpha/</p>
<p>The installation process is very simple. Just read the documentation and follow up the instructions.</p>
<p>So what is Smarty ? Smarty is a set of PHP classes that compile the templates into PHP scripts. Smarty is a template engine and a very useful tool for designers and programmers.<br />
Smarty for Designers</p>
<p>Designers work with HTML files. To work with Smarty, you work with template files. These files are are made up of static content but combined with Smarty mark-up tags. All the template files have a .html or .tpl extension. The Smarty template tags are enclosed within { and } delimiters or custom delimiters which can be defined or bypassed in the class.</p>
<p>Let’s consider the basic structure of a web page. There is a header, a middle part, and a footer. A template file that includes the header and the footer looks like this:</p>
<blockquote><p>{include file=&#8221;header.tpl&#8221;}<br />
&lt;form name=&#8221;form1&#8243;&gt;<br />
Label1 &lt;input type=&#8221;text&#8221; name=&#8221;text1&#8243;&gt;<br />
&lt;input type=&#8221;submit&#8221; value=&#8221;submit&#8221;&gt;<br />
&lt;/form&gt;<br />
{include file=&#8221;footer.tpl&#8221;}</p></blockquote>
<p>All the templates should reside in a single template directory. After calling a template for the first time, the compiled template will reside in templates_c.</p>
<p>Smarty language is very poweful. All the variables that come from PHP are identified in Smarty with {$Variable_Name} (we precede them with a $ sign). So if we have a variable in PHP that is called $MyName, then to print it in Smarty you have to write something like:</p>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
Welcome, {$MyName} &lt;br&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>The power of Smarty lies also in its flexibility. You can insert IFs and LOOPs into the template. The syntax for IF is:</p>
<blockquote><p>{if &lt;condition&gt; }<br />
html code<br />
{else}<br />
html code<br />
{/if}</p></blockquote>
<p>Let’s say you have a dynamic menu based on links. Depending on the link you click, you go to a specific page. So you get from PHP a variable $Menu with a integer value, depending on the page you are. The template looks like :</p>
<blockquote><p>{if ($Menu == 1) }<br />
Option 1<br />
{else}<br />
&lt;a href=&#8221;option1.php&#8221;&gt;Option 1&lt;/a&gt;<br />
{/if}<br />
{if ($Menu == 2)}<br />
Option 2<br />
{else}<br />
&lt;a href=&#8221;option2.php&#8221;&gt;Option 2&lt;/a&gt;<br />
{/if}</p></blockquote>
<p>For coding a loop let’s suppose you get an array like the following from PHP :</p>
<blockquote><p>&lt;table&gt;<br />
&lt;tr<br />
{section name=user loop=$userID}<br />
{if $smarty.section.user.iteration is odd}<br />
bgcolor=#efefef<br />
{else}<br />
bgcolor=#ffffff<br />
{/if}<br />
&gt;<br />
&lt;td&gt; ID = {$userID[user]}  &lt;/td&gt;<br />
&lt;td&gt; Name = {$name[user]}     &lt;/td&gt;<br />
&lt;td&gt; Address = {$address[user]} &lt;/td&gt;<br />
&lt;/tr&gt;<br />
{sectionelse}<br />
&lt;tr&gt;<br />
&lt;td&gt;<br />
There is no user.<br />
&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/section&gt;<br />
&lt;/table&gt;</p></blockquote>
<p>Iteration is an internal counter for Smarty. It helps us to know the current iteration of the section. I use this internal variable to make alternate row colors in the table by checking if current iteration value is odd or not.</p>
<p>An alternative for LOOPS is FOREACH which is used to loop over a single associative array.</p>
<blockquote><p>&lt;foreach from=$users item=current_user&gt;<br />
Name = {$current_user}<br />
&lt;foreachelse}<br />
No user available.<br />
&lt;/foreach&gt;</p></blockquote>
<p>The main difference between SECTION and FOREACH is that for SECTION you can start from a specific value, and can also set a step for the iteration, whereas for FOREACH you have to loop over all values.<br />
Smarty for Programmers</p>
<p>The advantage for programmers is that they write the code in a PHP file without having to mix the instructions with HTML. Furthermore, if the designer changes the layout of a page the programmer doesn’t have to change the code to suit the new layout since the functionalities won’t change. You do your work in your files, assign to the templates all the values needed to print on the site and go out for a beer. You won’t get phone calls asking you to change a bit of code because the designer changed the layout and now a set of internal errors cropped up.</p>
<p>In the PHP file you need to include the Smarty class require ‘Smarty.class.php&#8217;. After that you need to instantiate the smarty with $smarty = new Smarty.</p>
<p>To assign a variable to the template you need to $smarty-&gt;assign(&#8216;UserName&#8217;, ‘John Doe’). After everything is finished you call the method to display the template $smarty-&gt;display(&#8216;index.tpl&#8217;).</p>
<p>A sample code looks like this (index.php) :</p>
<blockquote><p>&lt;?php<br />
require &#8216;Smarty.class.php&#8217;;<br />
$smarty = new Smarty;</p>
<p>$smarty-&gt;assign(&#8216;Username&#8217;, &#8216;John Doe&#8217;);<br />
$smarty-&gt;display(&#8216;index.tpl&#8217;);<br />
?&gt;</p></blockquote>
<p>The template (index.tpl) looks like this:</p>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
Welcome {$Username}<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>You can also create an array in PHP an pass it to the template:</p>
<blockquote><p>$tmp = array ( &#8216;UID&#8217;=&gt; &#8217;10&#8242;,  &amp;&#8217;Name&#8217; =&gt; &#8216;John Doe&#8217;, &#8216;Address&#8217;=&gt;&#8217;Home address&#8217;);<br />
$smarty-&gt;assign(&#8216;info&#8217;, $tmp);</p></blockquote>
<p>Sample Script</p>
<p>This script connects to a local database and select all the products from the ‘Products’ table. Then it passes all the values to the template, which prints them on the screen.</p>
<p>INDEX.PHP</p>
<blockquote><p>&lt;?php<br />
require &#8216;Smarty.class.php&#8217;;<br />
$smarty = new Smarty;</p>
<p>$hostname = &#8220;localhost&#8221;;<br />
$dbUser = &#8220;sqluser&#8221;;<br />
$dbPass = &#8220;sqlpass&#8221;;<br />
$dbName = &#8220;sqldb&#8221;;<br />
// connect to the database<br />
$conn = mysql_connect($hostname, $dbUser, $dbPass) or die(&#8220;Cannot connect to the database&#8221;);</p>
<p>mysql_select_db($dbName);</p>
<p>$sql = &#8220;SELECT product_id, info FROM products ORDER BY product_id ASC&#8221;;<br />
// get all the products from the table<br />
$res = mysql_query($sql);<br />
$results = array();<br />
$i=0;<br />
while ($row=mysql_fetch_array($res)) {<br />
$tmp = array(<br />
&#8216;product_id&#8217; =&gt; $r['product_id'],<br />
&#8216;info&#8217;=&gt; $r['info']<br />
);<br />
$results[$i++] = $tmp;<br />
}<br />
// pass the results to the template<br />
$smarty-&gt;assign(&#8216;results&#8217;, $results);<br />
// load the template<br />
$smarty-&gt;display(&#8216;index.tpl&#8217;);<br />
?&gt;</p></blockquote>
<p>INDEX.TPL</p>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
Here&#8217;s a table with the results: &lt;br&gt;<br />
&lt;table cellpadding=1 cellspacing=0 border=0 width=100%&gt;<br />
{section name=nr loop=$results}<br />
&lt;tr {if $smarty.section.nr.iteration is odd} bgcolor=&#8221;#efefef&#8221;{/if}&gt;<br />
&lt;td width=15%&gt;<br />
&lt;nobr&gt;&lt;a href=&amp;#8221;show-product.php?id={$results[nr].product_id}&#8221;&gt;Press here&lt;/a&gt;</p>
<p>&lt;td width=29%&gt;&lt;a href=&#8221;show.php?id={$results[nr].prodID}&#8221;<br />
{popup inarray=$smarty.section.nr.iteration}<br />
&gt;{$results[nr].info}&lt;/a&gt;&lt;/td&gt;<br />
&lt;/tr&gt;</p>
<p>{sectionelse}<br />
&lt;tr&gt;&lt;td align=&#8221;center&#8221;&gt;&lt;br&gt;&lt;b&gt;no product &lt;/b&gt; &lt;br&gt; &lt;/td&gt;&lt;/tr&gt;<br />
{/section}</p>
<p>&lt;/table&gt;</p>
<p>&lt;br&gt;</p></blockquote>
<blockquote><p>Here&#8217;s a select with the results: &lt;br&gt;<br />
&lt;select name=&#8221;mys&#8221;&gt;<br />
{section name=nr loop=$results}<br />
&lt;option value=&#8221;{$results[nr].product_id}&#8221;&gt;{$results[nr].info}&lt;/option&gt;<br />
{/section}<br />
&lt;/select&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;<br />
Summary</p></blockquote>
<p>Smarty is a great tool for both designers and developers. By using Smarty you can reduce the site development and maintenance times. If you are a developer you no longer need to mix PHP code with HTML code. Just take care of business logic and leave the HTML to the designer.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dazzlecms.com/php/smarty3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>svn + apache2</title>
		<link>http://blog.dazzlecms.com/php/svn-apache2/</link>
		<comments>http://blog.dazzlecms.com/php/svn-apache2/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 00:20:50 +0000</pubDate>
		<dc:creator>Dazzle CMS</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[MYSQL]]></category>
		<category><![CDATA[Neon]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[berkeley]]></category>

		<guid isPermaLink="false">http://blog.dazzlecms.com/?p=12</guid>
		<description><![CDATA[Many of my developers work from windows including myself. Creating secure access over ssh and svn (svn+ssh://) using Zend studio and svn (subversion plugin for zend) was the initial idea, from a quick pass over subversion, but once svnserver was up and running and I tried it, this wasn’t as simple. There are several articles [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.dazzlecms.com%2Fphp%2Fsvn-apache2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.dazzlecms.com%2Fphp%2Fsvn-apache2%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Many of my developers work from windows including myself. Creating secure access over ssh and svn (svn+ssh://)<br />
using Zend studio and svn (subversion plugin for zend) was the initial idea, from a quick pass over subversion, but once svnserver was up and running and I tried it, this wasn’t as simple. There are several articles on integrating subversion, ssh and windows. None of the solutions looked simple or elegant. And wide open unsecured traffic was not acceptable.</p>
<p>I determined best practice pointed us to subversion access through web_dav_svn -&gt; web_dav -&gt; apache2 (https://). This brought authentication away from centralized auth and allowed fine grained control over the access granted via htpasswd and .htaccess files. It allowed us to restrict unsecured access and redirect http to https, and encrypt using SSL. It kept us from having to work ssh onto windows for each developer, instead we could have a simple eclipse/subclipse plugin access demonstrated and from that point they were able to customize on their own.</p>
<p>What I wanted was:</p>
<p>* untar subversion-1.6.6 and subversion-deps-1.6.6 in /apps/src (they layer over each other)<br />
* first build and install the -deps apr and apr-util into /apps/local<br />
* then build apache2 against /usr/local/apr and /usr/local/apr-util<br />
* install apache2<br />
* build and install serf<br />
* remove serf, apr, and apr-util subdirectories and source code from within subversion-1.6.6<br />
* build 1.6.6 against apxs in apache, without Berkeley DB, without neon, and specifying /usr/local/apr, /usr/local/apr-util, and /usr/local/serf<br />
* install and test</p>
<p>process</p>
<p>* create subdirectory /apps/src, place all tarballs in this directory<br />
* untar subversion &amp; subversion-deps version 1.6.6 (these tar onto each other)<br />
* cd subversion-1.6.6/apr<br />
* ./configure &#8211;prefix=/usr/local/subversion/apr<br />
* make &amp;&amp; make install<br />
* cd ../apr-util<br />
* ./configure &#8211;prefix=/usr/local/subversion/apr-util &#8211;with-apr=/usr/local/subversion/apr<br />
* make &amp;&amp; make install<br />
* cd ../neon<br />
* ./configure &#8211;prefix=/usr/local/subversion/neon<br />
*<br />
* apache2: untar httpd-2.2.14<br />
* ./configure &#8211;prefix=/usr/local/subversion/apache &#8211;enable-dav &#8211;enable-dav-fs &#8211;enable-dav-lock &#8211;enable-expires &#8211;enable-headers &#8211;enable-info &#8211;enable-logio &#8211;enable-proxy &#8211;enable-rewrite &#8211;enable-unique-id &#8211;with-apr=/usr/local/subversion/apr &#8211;with-apr-util=/usr/local/subversion/apr-util &#8211;enable-so &#8211;enable-mods-shared=all<br />
* make &amp;&amp; make install</p>
<p>This way apache2 builds against apr and apr-util compatible with subversion 1.6.6<br />
and then build subversion against it as well..<br />
* ln -s /apps/apache2_2.2.14 /apps/apache2<br />
* compile and install serf<br />
* ./configure –-prefix=/usr/local/subversion/serf &#8211;with-apr=/usr/local/subversion/apr &#8211;with-apr-util=/usr/local/subversion/apr-util<br />
* make &amp;&amp; make install<br />
* remove serf, pr and apr-util from subversion</p>
<p>compile subversion</p>
<p>./configure –prefix=/apps/svn –with-ssl –with-libs=/usr/local/ssl –without-berkeley-db –with-apxs=/apps/apache2/bin/apxs –with-openssl=/usr/local/ssl –without-neon –with-serf=/usr/local/serf –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util</p>
<p>make &amp;&amp; make install</p>
<p>test:</p>
<p>/usr/local/subversion/svn/bin/svnadmin create /usr/local/subversion/repository</p>
<p>chown subversion:subversion /usr/local/subversion</p>
<p>chown -Rv subversion.subversion /usr/local/subversion</p>
<p>root@dedicated[/bin] $</p>
<p>no core dump…</p>
<p>ONWARD to configure and test apache2 and subversion…<br />
httpd.conf:</p>
<p>* change all references to apache2_2.2.14 to apache2 (makes the httpd.conf generic rather than subject to needing a migration after a point release upgrade…)<br />
* change port 80 to a non-priveliged port (8080)<br />
* check for<br />
o LoadModule dav_module modules/mod_dav.so<br />
o LoadModule dav_module modules/mod_dav.so<br />
o LoadModule ssl_module modules/mod_ssl.so<br />
* add in ServerName hostname.domain.com:8443 Some of the apache level sanity validation requires a statement of the local host.<br />
* add in SSL stuff (this IS httpd from source &#8211; the default httpd.conf had the ssl-module load statement, but no explicit SSL configuration</p>
<p>#<br />
# Note: The following must must be present to support<br />
# starting without SSL on platforms with no /dev/random equivalent<br />
# but a statically compiled-in mod_ssl.<br />
#</p>
<p>&lt;IfModule ssl_module&gt;<br />
SSLRandomSeed startup builtin<br />
SSLRandomSeed connect builtin<br />
&lt;/IfModule&gt;</p>
<p># =================================================<br />
# SSL/TLS settings<br />
# =================================================</p>
<p>Listen 0.0.0.0:8080<br />
Listen 0.0.0.0:8443</p>
<p>SSLEngine on<br />
#SSLOptions +StrictRequire</p>
<p>#&lt;Directory /&gt;<br />
# SSLRequireSSL<br />
#&lt;/Directory&gt;</p>
<p>SSLProtocol -all +TLSv1 +SSLv3<br />
SSLCipherSuite HIGH:MEDIUM:!aNULL:+SHA1:+MD5:+HIGH:+MEDIUM</p>
<p>SSLMutex file:/apps/apache2/logs/ssl_mutex</p>
<p>SSLRandomSeed startup file:/dev/urandom 1024<br />
SSLRandomSeed connect file:/dev/urandom 1024</p>
<p>SSLSessionCache shm:/apps/apache2/logs/ssl_cache_shm<br />
SSLSessionCacheTimeout 600</p>
<p>SSLPassPhraseDialog builtin<br />
SSLCertificateFile /apps/apache2/conf/ssl.crt/server.crt<br />
SSLCertificateKeyFile /apps/apache2/conf/ssl.key/server.key</p>
<p>SSLVerifyClient none<br />
SSLProxyEngine off</p>
<p>&lt;IfModule mime.c&gt;<br />
AddType application/x-x509-ca-cert .crt<br />
AddType application/x-pkcs7-crl .crl<br />
&lt;/IfModule&gt;</p>
<p>* create ssl certificate (self-signed). I installed in /apps/apache2/conf/ssl.crt and ssl.key, naming the .crt and ,key files for the server hostname and then symbolically linking them to the generic “server.crt” and “server.key”.<br />
* restart apache2 and test https://host:8443/ &#8211; you should get the “It works!” apache test page, thus validating the SSL certificate and setup from a browser level<br />
*<br />
* parent directory for svn</p>
<p>&lt;Location /svn&gt;<br />
DAV svn<br />
SVNParentPath /apps/repos<br />
&lt;/Location&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dazzlecms.com/php/svn-apache2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
