<?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"
	>

<channel>
	<title>TG007 DevBlog</title>
	<atom:link href="http://blog.tg007.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tg007.net</link>
	<description>Development blog for TG007.net</description>
	<pubDate>Wed, 23 Jul 2008 18:53:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>How to truncate text / cut off text at certain length</title>
		<link>http://blog.tg007.net/how-to-truncate-text-cut-off-text-at-certain-length/</link>
		<comments>http://blog.tg007.net/how-to-truncate-text-cut-off-text-at-certain-length/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 18:52:51 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[cut off]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[truncate]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=20</guid>
		<description><![CDATA[I ran across this php script while searching for ways to repair my truncation script. I was having a bit of trouble with break tags being cut off and messing up the site validation. I used the idea from this script to fix that. Hope it helps others.

&#60;?php
function truncate&#40;$text,$numb&#41; &#123;
$text = html_entity_decode&#40;$text, ENT_QUOTES&#41;;
if &#40;strlen&#40;$text&#41; &#62; [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across this php script while searching for ways to repair my truncation script. I was having a bit of trouble with break tags being cut off and messing up the site validation. I used the idea from this script to fix that. Hope it helps others.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span></p>
<p><span class="kw2">function</span> truncate<span class="br0">&#40;</span><span class="re0">$text</span>,<span class="re0">$numb</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="re0">$text</span> = <a href="http://www.php.net/html_entity_decode"><span class="kw3">html_entity_decode</span></a><span class="br0">&#40;</span><span class="re0">$text</span>, ENT_QUOTES<span class="br0">&#41;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/strlen"><span class="kw3">strlen</span></a><span class="br0">&#40;</span><span class="re0">$text</span><span class="br0">&#41;</span> &gt; <span class="re0">$numb</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="re0">$text</span> = <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$text</span>, <span class="nu0">0</span>, <span class="re0">$numb</span><span class="br0">&#41;</span>;<br />
<span class="re0">$text</span> = <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$text</span>,<span class="nu0">0</span>,<a href="http://www.php.net/strrpos"><span class="kw3">strrpos</span></a><span class="br0">&#40;</span><span class="re0">$text</span>,<span class="st0">&#8221; &#8220;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="co1">//This strips the full stop:</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$text</span>, -<span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#41;</span> == <span class="st0">&#8220;.&#8221;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$text</span> = <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$text</span>,<span class="nu0">0</span>,<span class="br0">&#40;</span><a href="http://www.php.net/strrpos"><span class="kw3">strrpos</span></a><span class="br0">&#40;</span><span class="re0">$text</span>,<span class="st0">&#8220;.&#8221;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<span class="re0">$etc</span> = <span class="st0">&#8220;&#8230;&#8221;</span>;<br />
<span class="re0">$text</span> = <span class="re0">$text</span>.<span class="re0">$etc</span>;<br />
<span class="br0">&#125;</span><br />
<span class="re0">$text</span> = <a href="http://www.php.net/htmlentities"><span class="kw3">htmlentities</span></a><span class="br0">&#40;</span><span class="re0">$text</span>, ENT_QUOTES<span class="br0">&#41;</span>;<br />
<span class="kw1">return</span> <span class="re0">$text</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="co1">//Call function</span><br />
truncate<span class="br0">&#40;</span><span class="re0">$text</span>, <span class="nu0">75</span><span class="br0">&#41;</span>;<br />
<span class="kw2">?&gt;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/how-to-truncate-text-cut-off-text-at-certain-length/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Page Editing</title>
		<link>http://blog.tg007.net/page-editing/</link>
		<comments>http://blog.tg007.net/page-editing/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 08:34:46 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Edit]]></category>

		<category><![CDATA[Form]]></category>

		<category><![CDATA[Page Editor]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=12</guid>
		<description><![CDATA[I use the database to present some pages because it&#8217;s just easier to deal with. At one time I was using a Mod for Invision Power Boards to add simple pages to present info on various IRC information. I really wasn&#8217;t happy with how it worked and rather than edit something that could break again [...]]]></description>
			<content:encoded><![CDATA[<p>I use the database to present some pages because it&#8217;s just easier to deal with. At one time I was using a Mod for Invision Power Boards to add simple pages to present info on various IRC information. I really wasn&#8217;t happy with how it worked and rather than edit something that could break again in future forum updates I decided to make my own system.</p>
<p>Each page has a link that only the admin can see that allows you to pop up a window in which you can edit the page&#8217;s html coding. I only use this method for a few information pages that do not require extra php coding.</p>
<p>Features:</p>
<ol>
<li>Quick launch link directly from the page you want to edit.</li>
<li>Auto insertion of links to menu on creation</li>
<li>Alert popup to ensure you really meant to update the page.</li>
<li>Ability to delete the page</li>
<li>On submit the window refreshes the information and the page refreshes as well.</li>
</ol>
<p>Here is what the process looks like</p>
<p><a href="http://blog.tg007.net/wp-content/uploads/2008/06/tgpedit.gif"><img class="aligncenter size-medium wp-image-14" title="tgpedit" src="http://blog.tg007.net/wp-content/uploads/2008/06/tgpedit-294x300.gif" alt="TG Page Editor" width="294" height="300" /></a></p>
<ol></ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/page-editing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Code: ToolTips</title>
		<link>http://blog.tg007.net/code-tooltips/</link>
		<comments>http://blog.tg007.net/code-tooltips/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 07:11:21 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Tooltips]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=9</guid>
		<description><![CDATA[
Curious about TG&#8217;s popup tool tip info? This is how we do it. This is a JS code from one of our favorite sites Dynamic Drive. Of course we have edited to better suit our look and needs. Here is the breakdown.
Put this in the &#60;head&#62; section or in your css file


&#60;style type=&#8220;text/css&#8221;&#62;
#dhtmltooltip&#123;
position: absolute;
width: 150px;
border: [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><img class="alignnone size-full wp-image-10 aligncenter" title="tgtooltip" src="http://blog.tg007.net/wp-content/uploads/2008/06/tgtooltip.png" alt="TG Tooltip" width="330" height="135" /></p>
<p style="text-align: left;">Curious about TG&#8217;s popup tool tip info? This is how we do it. This is a JS code from one of our favorite sites Dynamic Drive. Of course we have edited to better suit our look and needs. Here is the breakdown.</p>
<p style="text-align: left;">Put this in the &lt;head&gt; section or in your css file</p>
<p style="text-align: left;">
<div class="codesnip-container" >
<div class="codesnip">&lt;style type=<span class="st0">&#8220;text/css&#8221;</span>&gt;</p>
<p>#dhtmltooltip<span class="br0">&#123;</span><br />
<span class="kw1">position</span>: <span class="kw2">absolute</span>;<br />
<span class="kw1">width</span>: 150px;<br />
<span class="kw1">border</span>: 2px <span class="kw2">solid</span> <span class="kw1">black</span>;<br />
<span class="kw1">padding</span>: 2px;<br />
<span class="kw1">background-color</span>: lightyellow;<br />
<span class="kw1">visibility</span>: <span class="kw2">hidden</span>;<br />
<span class="kw1">z-index</span>: <span class="nu0">100</span>;<br />
<span class="coMULTI">/*Remove below line to remove shadow. Below line should always appear last within this CSS*/</span><br />
filter: progid:DXImageTransform.Microsoft.Shadow<span class="br0">&#40;</span><span class="kw1">color</span>=<span class="kw2">gray</span>,<span class="kw1">direction</span>=<span class="nu0">135</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p>&lt;/style&gt;;</p></div>
</div>
<p>Now for the Javascript and related coding. Place this somewhere in the body outside of any relative or absolute tags.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;div</span></a> <span class="kw3">id</span>=<span class="st0">&#8220;dhtmltooltip&#8221;</span><span class="kw2">&gt;</span></a></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></div>
</div>
<div class="codesnip-container" >
<div class="codesnip">&lt;script type=<span class="st0">&#8220;text/javascript&#8221;</span>&gt;</p>
<p><span class="coMULTI">/***********************************************<br />
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)<br />
* This notice MUST stay intact for legal use<br />
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code<br />
***********************************************/</span></p>
<p><span class="kw2">var</span> offsetxpoint=-<span class="nu0">60</span> <span class="co1">//Customize x offset of tooltip</span><br />
<span class="kw2">var</span> offsetypoint=<span class="nu0">20</span> <span class="co1">//Customize y offset of tooltip</span><br />
<span class="kw2">var</span> ie=document.<span class="me1">all</span><br />
<span class="kw2">var</span> ns6=document.<span class="me1">getElementById</span> &amp;&amp; !document.<span class="me1">all</span><br />
<span class="kw2">var</span> enabletip=<span class="kw2">false</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>ie||ns6<span class="br0">&#41;</span><br />
<span class="kw2">var</span> tipobj=document.<span class="me1">all</span>? document.<span class="me1">all</span><span class="br0">&#91;</span><span class="st0">&#8220;dhtmltooltip&#8221;</span><span class="br0">&#93;</span> : document.<span class="me1">getElementById</span>? document.<span class="me1">getElementById</span><span class="br0">&#40;</span><span class="st0">&#8220;dhtmltooltip&#8221;</span><span class="br0">&#41;</span> : <span class="st0">&#8220;&#8221;</span></p>
<p><span class="kw2">function</span> ietruebody<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw1">return</span> <span class="br0">&#40;</span>document.<span class="me1">compatMode</span> &amp;&amp; document.<span class="me1">compatMode</span>!=<span class="st0">&#8220;BackCompat&#8221;</span><span class="br0">&#41;</span>? document.<span class="me1">documentElement</span> : document.<span class="me1">body</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> ddrivetip<span class="br0">&#40;</span>thetext, thecolor, thewidth<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>ns6||ie<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">typeof</span> thewidth!=<span class="st0">&#8220;undefined&#8221;</span><span class="br0">&#41;</span> tipobj.<span class="me1">style</span>.<span class="me1">width</span>=thewidth+<span class="st0">&#8220;px&#8221;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">typeof</span> thecolor!=<span class="st0">&#8220;undefined&#8221;</span> &amp;&amp; thecolor!=<span class="st0">&#8220;&#8221;</span><span class="br0">&#41;</span> tipobj.<span class="me1">style</span>.<span class="me1">backgroundColor</span>=thecolor<br />
tipobj.<span class="me1">innerHTML</span>=thetext<br />
enabletip=<span class="kw2">true</span><br />
<span class="kw1">return</span> <span class="kw2">false</span><br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> positiontip<span class="br0">&#40;</span>e<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>enabletip<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw2">var</span> curX=<span class="br0">&#40;</span>ns6<span class="br0">&#41;</span>?e.<span class="me1">pageX</span> : event.<span class="me1">clientX</span>+ietruebody<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">scrollLeft</span>;<br />
<span class="kw2">var</span> curY=<span class="br0">&#40;</span>ns6<span class="br0">&#41;</span>?e.<span class="me1">pageY</span> : event.<span class="me1">clientY</span>+ietruebody<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">scrollTop</span>;<br />
<span class="co1">//Find out how close the mouse is to the corner of the window</span><br />
<span class="kw2">var</span> rightedge=ie&amp;&amp;!window.<span class="me1">opera</span>? ietruebody<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">clientWidth</span>-event.<span class="me1">clientX</span>-offsetxpoint : window.<span class="me1">innerWidth</span>-e.<span class="me1">clientX</span>-offsetxpoint-<span class="nu0">20</span><br />
<span class="kw2">var</span> bottomedge=ie&amp;&amp;!window.<span class="me1">opera</span>? ietruebody<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">clientHeight</span>-event.<span class="me1">clientY</span>-offsetypoint : window.<span class="me1">innerHeight</span>-e.<span class="me1">clientY</span>-offsetypoint-<span class="nu0">20</span></p>
<p><span class="kw2">var</span> leftedge=<span class="br0">&#40;</span>offsetxpoint&lt;<span class="nu0">0</span><span class="br0">&#41;</span>? offsetxpoint*<span class="br0">&#40;</span>-<span class="nu0">1</span><span class="br0">&#41;</span> : -<span class="nu0">1000</span></p>
<p><span class="co1">//if the horizontal distance isn&#8217;t enough to accomodate the width of the context menu</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>rightedge&lt;tipobj.<span class="me1">offsetWidth</span><span class="br0">&#41;</span><br />
<span class="co1">//move the horizontal position of the menu to the left by it&#8217;s width</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">left</span>=ie? ietruebody<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">scrollLeft</span>+event.<span class="me1">clientX</span>-tipobj.<span class="me1">offsetWidth</span>+<span class="st0">&#8220;px&#8221;</span> : window.<span class="me1">pageXOffset</span>+e.<span class="me1">clientX</span>-tipobj.<span class="me1">offsetWidth</span>+<span class="st0">&#8220;px&#8221;</span><br />
<span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span>curX&lt;leftedge<span class="br0">&#41;</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">left</span>=<span class="st0">&#8220;5px&#8221;</span><br />
<span class="kw1">else</span><br />
<span class="co1">//position the horizontal position of the menu where the mouse is positioned</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">left</span>=curX+offsetxpoint+<span class="st0">&#8220;px&#8221;</span></p>
<p><span class="co1">//same concept with the vertical position</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>bottomedge&lt;tipobj.<span class="me1">offsetHeight</span><span class="br0">&#41;</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">top</span>=ie? ietruebody<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">scrollTop</span>+event.<span class="me1">clientY</span>-tipobj.<span class="me1">offsetHeight</span>-offsetypoint+<span class="st0">&#8220;px&#8221;</span> : window.<span class="me1">pageYOffset</span>+e.<span class="me1">clientY</span>-tipobj.<span class="me1">offsetHeight</span>-offsetypoint+<span class="st0">&#8220;px&#8221;</span><br />
<span class="kw1">else</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">top</span>=curY+offsetypoint+<span class="st0">&#8220;px&#8221;</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">visibility</span>=<span class="st0">&#8220;visible&#8221;</span><br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p><span class="kw2">function</span> hideddrivetip<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
<span class="kw1">if</span> <span class="br0">&#40;</span>ns6||ie<span class="br0">&#41;</span><span class="br0">&#123;</span><br />
enabletip=<span class="kw2">false</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">visibility</span>=<span class="st0">&#8220;hidden&#8221;</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">left</span>=<span class="st0">&#8220;-1000px&#8221;</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">backgroundColor</span>=<span class="st0">&#8221;</span><br />
tipobj.<span class="me1">style</span>.<span class="me1">width</span>=<span class="st0">&#8221;</span><br />
<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span></p>
<p>document.<span class="me1">onmousemove</span>=positiontip</p>
<p>&lt;/script&gt;</p></div>
</div>
<p>Now just edit your link with the following information.</p>
<div class="codesnip-container" >
<div class="codesnip">onMouseover=&quot;ddrivetip(&#8217;JavaScriptKit.com JavaScript tutorials&#8217;,'yellow&#8217;, 300)&quot;;<br />
onMouseout=&quot;hideddrivetip()&quot;</div>
</div>
<p>This is the breakdown of how the code works</p>
<div class="codesnip-container" >
<div class="codesnip">ddrivetip(&#8217;TEXT TO DISPLAY&#8217;, &#8216;OPTIONAL BACKGROUND COLOR&#8217;, OPTIONAL TIP WIDTH)</div>
</div>
<p>Here are some examples of using the code in the links</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="sc2"><a href="http://december.com/html/4/element/a.html"><span class="kw2">&lt;a</span></a> <span class="kw3">href</span>=<span class="st0">&#8220;http://www.yahoo.com&#8221;</span> <span class="kw3">onMouseover</span>=<span class="st0">&#8220;ddrivetip(&#8217;Visit Yahoo.com&#8217;)&#8221;</span>;<br />
&nbsp;<span class="kw3">onMouseout</span>=<span class="st0">&#8220;hideddrivetip()&#8221;</span><span class="kw2">&gt;</span></a></span>Search Engine<span class="sc2"><span class="kw2">&lt;/a&gt;</span></span></p>
<p><span class="sc2"><a href="http://december.com/html/4/element/div.html"><span class="kw2">&lt;DIV</span></a> <span class="kw3">onMouseover</span>=<span class="st0">&#8220;ddrivetip(&#8217;This DIV has a tip!&#8217;, &#8216;#EFEFEF&#8217;)&#8221;</span>;<br />
&nbsp;<span class="kw3">onMouseout</span>=<span class="st0">&#8220;hideddrivetip()&#8221;</span><span class="kw2">&gt;</span></a></span>Some text here. Some text here.<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></p>
<p><span class="sc2"><a href="http://december.com/html/4/element/a.html"><span class="kw2">&lt;a</span></a> <span class="kw3">href</span>=<span class="st0">&#8220;http://yahoo.com&#8221;</span> <span class="kw3">onMouseover</span>=<span class="st0">&#8220;ddrivetip(&#8217;Yahoo<span class="es0">\&#8217;</span>s Site&#8217;, &#8216;yellow&#8217;, 250)&#8221;</span>;<br />
&nbsp;<span class="kw3">onMouseout</span>=<span class="st0">&#8220;hideddrivetip()&#8221;</span><span class="kw2">&gt;</span></a></span>Yahoo<span class="sc2"><span class="kw2">&lt;/a&gt;</span></span></div>
</div>
<p>This is a very helpful and attractive addon for your site. Be sure to leave in the credit for dynamic drive and check out the actual full page devoted to the addon <a href="http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm">HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/code-tooltips/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP: Delete File If Exists</title>
		<link>http://blog.tg007.net/php-code-delete-file-if-exists/</link>
		<comments>http://blog.tg007.net/php-code-delete-file-if-exists/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 08:45:10 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[file delete]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=8</guid>
		<description><![CDATA[I ran across this function to delete a file from the server if it exists some time ago. It has been very useful to me.

&#60;?php
$DelFilePath = &#8220;/home/path/to/file&#8221;;
if &#40;file_exists&#40;$DelFilePath&#41;&#41;&#160; &#123; 
unlink&#40;$DelFilePath&#41;;
&#125; 
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>I ran across this function to delete a file from the server if it exists some time ago. It has been very useful to me.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="re0">$DelFilePath</span> = <span class="st0">&#8220;/home/path/to/file&#8221;</span>;<br />
<span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/file_exists"><span class="kw3">file_exists</span></a><span class="br0">&#40;</span><span class="re0">$DelFilePath</span><span class="br0">&#41;</span><span class="br0">&#41;</span>&nbsp; <span class="br0">&#123;</span> <br />
<a href="http://www.php.net/unlink"><span class="kw3">unlink</span></a><span class="br0">&#40;</span><span class="re0">$DelFilePath</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span> <br />
<span class="kw2">?&gt;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/php-code-delete-file-if-exists/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP: Get File Extension</title>
		<link>http://blog.tg007.net/php-code-get-file-extension/</link>
		<comments>http://blog.tg007.net/php-code-get-file-extension/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 08:06:38 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[file extension]]></category>

		<category><![CDATA[file type]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=7</guid>
		<description><![CDATA[There are many ways to get the file extension of a file.  Here is an example of a php function I found to do just that.

&#60;?php
function file_extension&#40;$fname&#41;
&#123;
$path_info = pathinfo&#40;$fname&#41;;
return $path_info&#91;&#8216;extension&#8217;&#93;;
&#125;
?&#62;

Another way would be to check the actual string and use what&#8217;s after the last slash. I picked this up on a forum I visit.

&#60;?php
$filetype [...]]]></description>
			<content:encoded><![CDATA[<p>There are many ways to get the file extension of a file.  Here is an example of a php function I found to do just that.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="kw2">function</span> file_extension<span class="br0">&#40;</span><span class="re0">$fname</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
<span class="re0">$path_info</span> = <a href="http://www.php.net/pathinfo"><span class="kw3">pathinfo</span></a><span class="br0">&#40;</span><span class="re0">$fname</span><span class="br0">&#41;</span>;<br />
<span class="kw1">return</span> <span class="re0">$path_info</span><span class="br0">&#91;</span><span class="st0">&#8216;extension&#8217;</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">?&gt;</span></div>
</div>
<p>Another way would be to check the actual string and use what&#8217;s after the last slash. I picked this up on a forum I visit.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="re0">$filetype</span> = <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$file</span>, <a href="http://www.php.net/strrpos"><span class="kw3">strrpos</span></a><span class="br0">&#40;</span><span class="re0">$file</span>, <span class="st0">&#8216;.&#8217;</span><span class="br0">&#41;</span> + <span class="nu0">1</span><span class="br0">&#41;</span>;<br />
<span class="kw2">?&gt;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/php-code-get-file-extension/feed/</wfw:commentRss>
		</item>
		<item>
		<title>TG007 News Posting</title>
		<link>http://blog.tg007.net/tg007-news-posting/</link>
		<comments>http://blog.tg007.net/tg007-news-posting/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 18:36:34 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[control panel]]></category>

		<category><![CDATA[cp]]></category>

		<category><![CDATA[news icons]]></category>

		<category><![CDATA[post news]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=5</guid>
		<description><![CDATA[One of the many questions I get asked by other website developers is how do I post news on the main page with icons. My method was to build a mysql table with the information for the icons I wanted. As you will see in the News Icons control panel, I have the ability to [...]]]></description>
			<content:encoded><![CDATA[<p>One of the many questions I get asked by other website developers is how do I post news on the main page with icons. My method was to build a mysql table with the information for the icons I wanted. As you will see in the News Icons control panel, I have the ability to add news icons. The form allows me to not only upload the image I want to use but it also sets an entry into my database. I use the thread&#8217;s Topic Description as a way of deciding what icon to use. So if the description was TechGear News it would know to use the TechGear News icon that I set in the database. Here is a picture of the news icon control panel.</p>
<p><a href="http://blog.tg007.net/wp-content/uploads/2008/06/newsiconcp.png"></a></p>
<p style="text-align: center;"><img class="alignnone size-medium wp-image-6 aligncenter" title="newsiconcp" src="http://blog.tg007.net/wp-content/uploads/2008/06/newsiconcp-300x197.png" alt="News Icon CP" width="300" height="197" /></p>
<p>Now to make the process of posting news and making sure I set the right text for the icon, I built a small form. The form includes a dropdown list of all the different identifiers to use in the topic description. The dropdown list pulls the info from the database table I created so when a new one is added it is automatically included in the list. The form is a popup that you can access from techgear&#8217;s main page if you have the proper rights. This is a picture of the form.</p>
<p style="text-align: center;"><a href="http://blog.tg007.net/wp-content/uploads/2008/06/postnews.png"><img class="aligncenter size-medium wp-image-15" title="postnews" src="http://blog.tg007.net/wp-content/uploads/2008/06/postnews-262x300.png" alt="Post News" width="262" height="300" /></a></p>
<p>Here you enter the topic, text, source, and icon to use. It also includes some basic bbcode functions if needed. The form also uses a bit of <a title="IPB SDK" href="http://ipbwi.pc-intern.com/examples/topic_new.php">IPB SDK</a> in order to easily create the post. Once you have filled out the form you click submit and the popup will close and the site will refresh to show the latest article.</p>
<p>I hope that helps out other users that are looking to do something similar.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/tg007-news-posting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Dev Blog</title>
		<link>http://blog.tg007.net/dev-blog/</link>
		<comments>http://blog.tg007.net/dev-blog/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 22:16:00 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[cms]]></category>

		<category><![CDATA[dev blog]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=3</guid>
		<description><![CDATA[As you may have noticed I have decided to use WordPress as the backend for the development blog. I can&#8217;t say enough good things about wordpress. I have used it on several sites and I must say if you are looking to build a simple site you can&#8217;t go wrong with wordpress. As you can [...]]]></description>
			<content:encoded><![CDATA[<p>As you may have noticed I have decided to use <a title="WordPress" href="http://www.wordpress.org">WordPress</a> as the backend for the development blog. I can&#8217;t say enough good things about wordpress. I have used it on several sites and I must say if you are looking to build a simple site you can&#8217;t go wrong with wordpress. As you can see you can easily implement a custom theme. There are literally hundreds of themes and addons available for wordpress. For all you portal users, you should seriously think of giving a wordpress a try.</p>
<p>Hope everyone enjoys the new dev blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/dev-blog/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Welcome</title>
		<link>http://blog.tg007.net/hello-world/</link>
		<comments>http://blog.tg007.net/hello-world/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 16:43:33 +0000</pubDate>
		<dc:creator>err0r</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[techgear]]></category>

		<category><![CDATA[welcome]]></category>

		<guid isPermaLink="false">http://blog.tg007.net/?p=1</guid>
		<description><![CDATA[Hello and welcome to the new TG007 development blog. Here we will share information about the continuing development of techgear. We plan to give you a look inside the world of design as well as information we have learned along the way. Here you will learn about the coding and tools we use to keep [...]]]></description>
			<content:encoded><![CDATA[<p>Hello and welcome to the new TG007 development blog. Here we will share information about the continuing development of techgear. We plan to give you a look inside the world of design as well as information we have learned along the way. Here you will learn about the coding and tools we use to keep techgear growing.</p>
<p><em>Note</em>: <em>This is not a help resource. This is simply a dev blog about the site. If you need help please use our <a title="TG007 Forum" href="http://www.tg007.net/forum/index.php">forums</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tg007.net/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
