ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç
ȨÆäÀÌÁö Á¦ÀÛ±âÃÊ
±âº»Å±×
ÅÂ±×ÆÁ¸ðÀ½
ű×ÀÚ·á¹æ
Æ÷Åä¼¥°ÁÂ
À¥.°ü·Ã°ÁÂ
PHP°ÁÂ
PHPÆÁ
HTML.CSS
JAVASCRIPT
ASP
JSP
PHP½ÉÈ
C.C++
Ç÷¡½Ã.ActionScript
ÀÚÀ¯°Ô½ÃÆÇ
Áú¹®°Ô½ÃÆÇ
À¯¸Ó°Ô½ÃÆÇ
¿À¶ô½Ç
Tel. 042-353-2371
ÆòÀÏ ¿ÀÀü 9½Ã ~ ¿ÀÈÄ 7½Ã
±â¾÷ÀºÇà
010-8649-6758
¿¹±ÝÁÖ:Á¦ÁÖ»ç¶û(¼ÛÁø¾Æ)
PHP
Ȩ > ȨÆäÀÌÁöÁ¦ÀÛ±³½Ç > PHP
ÀÛ¼ºÀÚ
freeweb
Ä«Å×°í¸®
PHP
Ŭ·¡½º&ÇÔ¼ö
CUBRID
PC
DB
Á¦·Îº¸µå
ÃʱÞ
MYSQL
CGI
ºñ¹Ð¹øÈ£
Á¦¸ñ
<P><FONT face=GulimChe>============== <BR>¼Ò °³ (INTRO) <BR>============== <BR><BR>HTML, Àº ¹°·Ð XML °ú ȣȯ»ç¿ëÀÌ °¡´ÉÇÑ ÅÛÇø´ Ŭ·¡½º ÀÔ´Ï´Ù. ·çÇÁ, º¹ÀâÇÑ ¼ºê <BR>ºí·Ï·çÇÁ µîÀÇ ¿äÁòÀÇ ÅÛÇø´ ±â´ÉÀ» ´ëºÎºÐ Áö¿øÇÏ´Â ÅÛÇø´ Ŭ·¡½º ÀÔ´Ï´Ù. ÅÛÇø´ <BR>Ŭ·¡½º´Â ¸¹Áö¸¸ Á¤ÀÛ »ç¿ëÇϱ⿡´Â Á¶±Ý ¸Á¼³¿© Áö´Â ºÎºÐÀÌ Àִµ¥ ÀÚüÀûÀÎ ÅÛÇø´ <BR>À» Á¦ÀÛÇϰųª ½ÇÁ¦ »ç¿ëÇØ¾ßÇÏ´Â °æ¿ì ´«¿©°Ü º¼¸¸ÇÑ ÇÁ·Î±×·¥Àεí ÇÕ´Ï´Ù. <BR>Ŭ·¡½º ÀÚü¶ÇÇÑ ±ò²ûÇÏ°Ô Àß Â¥¿©Àú ÀÖ¾î¼ °øºÎ¿¡µµ µµ¿òÀÌ µÉµí ÇÕ´Ï´Ù. <BR><BR>============== <BR>¶óÀ̼¾½º <BR>============== <BR><BR>ÆÄÀϳ» ¶óÀ̼¾½ºÆÄÀÏ ÂüÁ¶ <BR><BR>============= <BR>¼³ Ä¡ <BR>============= <BR><BR>µ¶¸³ÇÁ·Î±×·¡ÀÌ ¾Æ´Ï¶ó ¼³Ä¡°úÁ¤Àº µû·Î ¾øÀ¸¸ç ¾÷·Îµå ÇÕÀ¸·Î ¼³Ä¡´Â <BR>¿Ï·áµÇ¸ç »ç¿ë½Ã¿¡ include ÇÏ¿© »ç¿ëÇÏ½Ã¸é µÇ°Ú½À´Ï´Ù. <BR>»ç¿ë¹æ¹ý¿¡ ´ëÇØ¼´Â http://216.218.133.71/~brian/bTemplate/ <BR>»çÀÌÆ®¿¡¼ Á¦°øÇÏ´Â ¹®¼¸¦ ÂüÁ¶Çϼ¼¿ä <BR><BR><BR>============= <BR>ÇÁ·Î±×·¥¼Ò½º <BR>============= <BR><BR></FONT><FONT color=#0000cc face=GulimChe><?php <BR></FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Description: HTML template class. <BR> Author: Brian Lozier (brian@massassi.net) <BR> License: Please read the license.txt file. <BR>*--------------------------------------------------------------*/ <BR></FONT><FONT color=#006600>class </FONT><FONT color=#0000cc>bTemplate </FONT></FONT><FONT color=#006600 face=GulimChe>{ <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Path variables <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$base_path </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'/home/brian/public_html/bTemplate/'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Delimeters for regular tags <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$ldelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'<'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> var </FONT><FONT color=#0000cc>$rdelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>' />'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Delimeters for beginnings of loops <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$BAldelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'<'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> var </FONT><FONT color=#0000cc>$BArdelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'>'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Delimeters for ends of loops <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$EAldelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'</'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> var </FONT><FONT color=#0000cc>$EArdelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'>'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Internal variables <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$scalars </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> var </FONT><FONT color=#0000cc>$arrays </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> var </FONT><FONT color=#0000cc>$ifs </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> var </FONT><FONT color=#0000cc>$carrays </FONT></FONT><FONT color=#006600 face=GulimChe>= array(); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: bTemplate() <BR> Simply sets the base path (if you don't set the default). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>bTemplate</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$base_path </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>$base_path </FONT><FONT color=#006600>!= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>base_path </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$base_path</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: set() <BR> Sets all types of variables (scalar, loop, hash). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>set</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$var</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$var</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>arrays</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$var</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> } <BR> else { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>scalars</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$var</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> if(</FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>=== </FONT><FONT color=#0000cc>TRUE</FONT><FONT color=#006600>) </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ifs</FONT><FONT color=#006600>[] = </FONT><FONT color=#0000cc>$tag</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: set_cloop() <BR> Sets a cloop (case loop). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>set_cloop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$cases</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>carrays</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT></FONT><FONT face=GulimChe><FONT color=#006600>] = array( <BR> </FONT><FONT color=#cc0000>'array' </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$array</FONT></FONT><FONT face=GulimChe><FONT color=#006600>, <BR> </FONT><FONT color=#cc0000>'cases' </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$cases</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: get_tags() <BR> Formats the tags & returns a two-element array. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$directive</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$tags</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>BAldelim </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$directive </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>BArdelim</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> </FONT><FONT color=#0000cc>$tags</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>EAldelim </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$directive </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>EArdelim</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> return </FONT><FONT color=#0000cc>$tags</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: get_tag() <BR> Formats a tag for a scalar. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> return </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ldelim </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'tag:' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>rdelim</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: get_statement() <BR> Extracts a portion of a template. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, &</FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Locate the statement <BR> </FONT><FONT color=#0000cc>$tag_length </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>strlen</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]); <BR> </FONT><FONT color=#0000cc>$fpos </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>strpos</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>]) + </FONT><FONT color=#0000cc>$tag_length</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> </FONT><FONT color=#0000cc>$lpos </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>strpos</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]); <BR> </FONT><FONT color=#0000cc>$length </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$lpos </FONT><FONT color=#006600>- </FONT><FONT color=#0000cc>$fpos</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Extract & return the statement <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>substr</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$fpos</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$length</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse() <BR> Parses all variables into the template. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the ifs <BR> </FONT><FONT color=#006600>if(!empty(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ifs</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ifs </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_if</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the scalars <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>scalars </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the arrays <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>arrays </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$array</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_loop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the carrays <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>carrays </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$array</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_cloop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Reset the arrays <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>arrays </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>carrays </FONT></FONT><FONT color=#006600 face=GulimChe>= array(); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Return the contents <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse_if() <BR> Parses a simple if statement. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse_if</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the tags & if statement <BR> </FONT><FONT color=#0000cc>$t </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'if:'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the if statement <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>scalars</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>] ? </FONT><FONT color=#0000cc>$replace </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>: </FONT><FONT color=#0000cc>$replace </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse & return the template <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] . </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$replace</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse_loop() <BR> Parses a loop (recursive function). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse_loop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the tags & loop <BR> </FONT><FONT color=#0000cc>$t </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'loop:'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the loop <BR> </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> foreach(</FONT><FONT color=#0000cc>$array </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>is_numeric</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>) && </FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$loop</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> foreach(</FONT><FONT color=#0000cc>$value </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key2 </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value2</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(!</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value2</FONT></FONT><FONT color=#006600 face=GulimChe>)) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Replace associative array tags <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[].' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key2</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR> else { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Check to see if it's a nested loop <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_loop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[].' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$value2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$i</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> } <BR> } <BR> } <BR> elseif(</FONT><FONT color=#0000cc>is_string</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>) && !</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'.' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> } <BR> elseif(!</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[]'</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$loop</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Add the parsed iteration <BR> </FONT><FONT color=#006600>if(isset(</FONT><FONT color=#0000cc>$i</FONT><FONT color=#006600>)) </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>.= </FONT><FONT color=#0000cc>rtrim</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse & return the final loop <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] . </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$parsed</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse_cloop() <BR> Parses a cloop (case loop) (recursive function). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse_cloop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the tags & loop <BR> </FONT><FONT color=#0000cc>$t </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'cloop:'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Set up the cases <BR> </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'cases'</FONT><FONT color=#006600>][] = </FONT><FONT color=#cc0000>'default'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> </FONT><FONT color=#0000cc>$case_content </FONT></FONT><FONT color=#006600 face=GulimChe>= array(); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the case strings <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'cases'</FONT><FONT color=#006600>] as </FONT><FONT color=#0000cc>$case</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$ctags</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$case_content</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$ctags</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$loop</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the loop <BR> </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> foreach(</FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'array'</FONT><FONT color=#006600>] as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>is_numeric</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>) && </FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT color=#006600 face=GulimChe>)) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Set up the cases <BR> </FONT><FONT color=#006600>if(isset(</FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'case'</FONT><FONT color=#006600>])) </FONT><FONT color=#0000cc>$current_case </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'case'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]; <BR> else </FONT><FONT color=#0000cc>$current_case </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'default'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> unset(</FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'case'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]); <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$case_content</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$current_case</FONT></FONT><FONT color=#006600 face=GulimChe>]; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Loop through each value <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$value </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key2 </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value2</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[].' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key2</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Add the parsed iteration <BR> </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>.= </FONT><FONT color=#0000cc>rtrim</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse & return the final loop <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] . </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$parsed</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: fetch() <BR> Returns the parsed contents of the specified template. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>fetch</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$file_name</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Prepare the path <BR> </FONT><FONT color=#0000cc>$file </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>base_path </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$file_name</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Open the file <BR> </FONT><FONT color=#0000cc>$fp </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>fopen</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$file</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'rb'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> if(!</FONT><FONT color=#0000cc>$fp</FONT><FONT color=#006600>) return </FONT><FONT color=#0000cc>FALSE</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Read the file <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>fread</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$fp</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>filesize</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$file</FONT></FONT><FONT color=#006600 face=GulimChe>)); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Close the file <BR> </FONT><FONT color=#0000cc>fclose</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$fp</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse and return the contents <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR>} <BR></FONT><FONT color=#0000cc><FONT face=GulimChe>?> </FONT><BR></FONT></P> <P><FONT color=#0000cc></FONT> </P> <P><FONT color=#0000cc><INS style="BORDER-BOTTOM: medium none; POSITION: relative; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 728px; PADDING-RIGHT: 0px; DISPLAY: inline-table; HEIGHT: 90px; VISIBILITY: visible; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px"><INS style="BORDER-BOTTOM: medium none; POSITION: relative; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 728px; PADDING-RIGHT: 0px; DISPLAY: block; HEIGHT: 90px; VISIBILITY: visible; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px" id=google_ads_frame2_anchor><IFRAME style="POSITION: absolute; TOP: 0px; LEFT: 0px" id=google_ads_frame2 height=90 marginHeight=0 src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-1810102646696146&output=html&h=90&slotname=8373878086&w=728&lmt=1293729078&flash=10.1.102.64&url=http%3A%2F%2Ffreewebkorea.com%2Fdefault%2Findex.php&dt=1293729078544&shv=r20101117&jsv=r20101214&saldr=1&prev_slotnames=3246935894&correlator=1293729078111&frm=0&adk=2838309694&ga_vid=1721536298.1293729078&ga_sid=1293729078&ga_hid=703080614&ga_fc=0&u_tz=540&u_his=0&u_java=1&u_h=1080&u_w=1920&u_ah=1040&u_aw=1920&u_cd=32&u_nplug=0&u_nmime=0&biw=1916&bih=843&ifk=2478696134&eid=30143207&ref=http%3A%2F%2Ffreewebkorea.com%2F&fu=4&ifi=2&dtd=15&xpc=qZex7x9KNc&p=http%3A//freewebkorea.com" frameBorder=0 width=728 allowTransparency name=google_ads_frame marginWidth=0 scrolling=no></IFRAME></INS></INS></P></FONT>
<P><FONT face=GulimChe>============== <BR>¼Ò °³ (INTRO) <BR>============== <BR><BR>HTML, Àº ¹°·Ð XML °ú ȣȯ»ç¿ëÀÌ °¡´ÉÇÑ ÅÛÇø´ Ŭ·¡½º ÀÔ´Ï´Ù. ·çÇÁ, º¹ÀâÇÑ ¼ºê <BR>ºí·Ï·çÇÁ µîÀÇ ¿äÁòÀÇ ÅÛÇø´ ±â´ÉÀ» ´ëºÎºÐ Áö¿øÇÏ´Â ÅÛÇø´ Ŭ·¡½º ÀÔ´Ï´Ù. ÅÛÇø´ <BR>Ŭ·¡½º´Â ¸¹Áö¸¸ Á¤ÀÛ »ç¿ëÇϱ⿡´Â Á¶±Ý ¸Á¼³¿© Áö´Â ºÎºÐÀÌ Àִµ¥ ÀÚüÀûÀÎ ÅÛÇø´ <BR>À» Á¦ÀÛÇϰųª ½ÇÁ¦ »ç¿ëÇØ¾ßÇÏ´Â °æ¿ì ´«¿©°Ü º¼¸¸ÇÑ ÇÁ·Î±×·¥Àεí ÇÕ´Ï´Ù. <BR>Ŭ·¡½º ÀÚü¶ÇÇÑ ±ò²ûÇÏ°Ô Àß Â¥¿©Àú ÀÖ¾î¼ °øºÎ¿¡µµ µµ¿òÀÌ µÉµí ÇÕ´Ï´Ù. <BR><BR>============== <BR>¶óÀ̼¾½º <BR>============== <BR><BR>ÆÄÀϳ» ¶óÀ̼¾½ºÆÄÀÏ ÂüÁ¶ <BR><BR>============= <BR>¼³ Ä¡ <BR>============= <BR><BR>µ¶¸³ÇÁ·Î±×·¡ÀÌ ¾Æ´Ï¶ó ¼³Ä¡°úÁ¤Àº µû·Î ¾øÀ¸¸ç ¾÷·Îµå ÇÕÀ¸·Î ¼³Ä¡´Â <BR>¿Ï·áµÇ¸ç »ç¿ë½Ã¿¡ include ÇÏ¿© »ç¿ëÇÏ½Ã¸é µÇ°Ú½À´Ï´Ù. <BR>»ç¿ë¹æ¹ý¿¡ ´ëÇØ¼´Â http://216.218.133.71/~brian/bTemplate/ <BR>»çÀÌÆ®¿¡¼ Á¦°øÇÏ´Â ¹®¼¸¦ ÂüÁ¶Çϼ¼¿ä <BR><BR><BR>============= <BR>ÇÁ·Î±×·¥¼Ò½º <BR>============= <BR><BR></FONT><FONT color=#0000cc face=GulimChe><?php <BR></FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Description: HTML template class. <BR> Author: Brian Lozier (brian@massassi.net) <BR> License: Please read the license.txt file. <BR>*--------------------------------------------------------------*/ <BR></FONT><FONT color=#006600>class </FONT><FONT color=#0000cc>bTemplate </FONT></FONT><FONT color=#006600 face=GulimChe>{ <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Path variables <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$base_path </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'/home/brian/public_html/bTemplate/'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Delimeters for regular tags <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$ldelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'<'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> var </FONT><FONT color=#0000cc>$rdelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>' />'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Delimeters for beginnings of loops <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$BAldelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'<'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> var </FONT><FONT color=#0000cc>$BArdelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'>'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Delimeters for ends of loops <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$EAldelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'</'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> var </FONT><FONT color=#0000cc>$EArdelim </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'>'</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Internal variables <BR> </FONT><FONT color=#006600>var </FONT><FONT color=#0000cc>$scalars </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> var </FONT><FONT color=#0000cc>$arrays </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> var </FONT><FONT color=#0000cc>$ifs </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> var </FONT><FONT color=#0000cc>$carrays </FONT></FONT><FONT color=#006600 face=GulimChe>= array(); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: bTemplate() <BR> Simply sets the base path (if you don't set the default). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>bTemplate</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$base_path </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>$base_path </FONT><FONT color=#006600>!= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>base_path </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$base_path</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: set() <BR> Sets all types of variables (scalar, loop, hash). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>set</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$var</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$var</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>arrays</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$var</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> } <BR> else { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>scalars</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$var</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> if(</FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>=== </FONT><FONT color=#0000cc>TRUE</FONT><FONT color=#006600>) </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ifs</FONT><FONT color=#006600>[] = </FONT><FONT color=#0000cc>$tag</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: set_cloop() <BR> Sets a cloop (case loop). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>set_cloop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$cases</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>carrays</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT></FONT><FONT face=GulimChe><FONT color=#006600>] = array( <BR> </FONT><FONT color=#cc0000>'array' </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$array</FONT></FONT><FONT face=GulimChe><FONT color=#006600>, <BR> </FONT><FONT color=#cc0000>'cases' </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$cases</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: get_tags() <BR> Formats the tags & returns a two-element array. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$directive</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$tags</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>BAldelim </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$directive </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>BArdelim</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> </FONT><FONT color=#0000cc>$tags</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>EAldelim </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$directive </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>EArdelim</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> return </FONT><FONT color=#0000cc>$tags</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: get_tag() <BR> Formats a tag for a scalar. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> return </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ldelim </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'tag:' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>rdelim</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: get_statement() <BR> Extracts a portion of a template. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, &</FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Locate the statement <BR> </FONT><FONT color=#0000cc>$tag_length </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>strlen</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]); <BR> </FONT><FONT color=#0000cc>$fpos </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>strpos</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>]) + </FONT><FONT color=#0000cc>$tag_length</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> </FONT><FONT color=#0000cc>$lpos </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>strpos</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]); <BR> </FONT><FONT color=#0000cc>$length </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$lpos </FONT><FONT color=#006600>- </FONT><FONT color=#0000cc>$fpos</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Extract & return the statement <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>substr</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$fpos</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$length</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse() <BR> Parses all variables into the template. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the ifs <BR> </FONT><FONT color=#006600>if(!empty(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ifs</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>ifs </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_if</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the scalars <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>scalars </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the arrays <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>arrays </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$array</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_loop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the carrays <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>carrays </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$array</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_cloop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Reset the arrays <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>arrays </FONT></FONT><FONT face=GulimChe><FONT color=#006600>= array(); <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>carrays </FONT></FONT><FONT color=#006600 face=GulimChe>= array(); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Return the contents <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse_if() <BR> Parses a simple if statement. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse_if</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the tags & if statement <BR> </FONT><FONT color=#0000cc>$t </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'if:'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the if statement <BR> </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>scalars</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>] ? </FONT><FONT color=#0000cc>$replace </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>: </FONT><FONT color=#0000cc>$replace </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse & return the template <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] . </FONT><FONT color=#0000cc>$if </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$replace</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse_loop() <BR> Parses a loop (recursive function). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse_loop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the tags & loop <BR> </FONT><FONT color=#0000cc>$t </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'loop:'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the loop <BR> </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> foreach(</FONT><FONT color=#0000cc>$array </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>is_numeric</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>) && </FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$loop</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> foreach(</FONT><FONT color=#0000cc>$value </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key2 </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value2</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(!</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value2</FONT></FONT><FONT color=#006600 face=GulimChe>)) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Replace associative array tags <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[].' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key2</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR> else { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Check to see if it's a nested loop <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse_loop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[].' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$value2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$i</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> } <BR> } <BR> } <BR> elseif(</FONT><FONT color=#0000cc>is_string</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>) && !</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'.' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> } <BR> elseif(!</FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>)) { <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[]'</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$loop</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Add the parsed iteration <BR> </FONT><FONT color=#006600>if(isset(</FONT><FONT color=#0000cc>$i</FONT><FONT color=#006600>)) </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>.= </FONT><FONT color=#0000cc>rtrim</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse & return the final loop <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] . </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$parsed</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: parse_cloop() <BR> Parses a cloop (case loop) (recursive function). <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>parse_cloop</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the tags & loop <BR> </FONT><FONT color=#0000cc>$t </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'cloop:'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Set up the cases <BR> </FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'cases'</FONT><FONT color=#006600>][] = </FONT><FONT color=#cc0000>'default'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> </FONT><FONT color=#0000cc>$case_content </FONT></FONT><FONT color=#006600 face=GulimChe>= array(); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Get the case strings <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'cases'</FONT><FONT color=#006600>] as </FONT><FONT color=#0000cc>$case</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$ctags</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tags</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> </FONT><FONT color=#0000cc>$case_content</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>] = </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_statement</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$ctags</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$case</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$loop</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Process the loop <BR> </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>NULL</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> foreach(</FONT><FONT color=#0000cc>$array</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'array'</FONT><FONT color=#006600>] as </FONT><FONT color=#0000cc>$key </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> if(</FONT><FONT color=#0000cc>is_numeric</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$key</FONT><FONT color=#006600>) && </FONT><FONT color=#0000cc>is_array</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$value</FONT></FONT><FONT color=#006600 face=GulimChe>)) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Set up the cases <BR> </FONT><FONT color=#006600>if(isset(</FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'case'</FONT><FONT color=#006600>])) </FONT><FONT color=#0000cc>$current_case </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'case'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]; <BR> else </FONT><FONT color=#0000cc>$current_case </FONT><FONT color=#006600>= </FONT><FONT color=#cc0000>'default'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>; <BR> unset(</FONT><FONT color=#0000cc>$value</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'case'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>]); <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$case_content</FONT><FONT color=#006600>[</FONT><FONT color=#0000cc>$current_case</FONT></FONT><FONT color=#006600 face=GulimChe>]; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Loop through each value <BR> </FONT><FONT color=#006600>foreach(</FONT><FONT color=#0000cc>$value </FONT><FONT color=#006600>as </FONT><FONT color=#0000cc>$key2 </FONT><FONT color=#006600>=> </FONT><FONT color=#0000cc>$value2</FONT></FONT><FONT face=GulimChe><FONT color=#006600>) { <BR> </FONT><FONT color=#0000cc>$i </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>get_tag</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$tag </FONT><FONT color=#006600>. </FONT><FONT color=#cc0000>'[].' </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$key2</FONT><FONT color=#006600>), </FONT><FONT color=#0000cc>$value2</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Add the parsed iteration <BR> </FONT><FONT color=#0000cc>$parsed </FONT><FONT color=#006600>.= </FONT><FONT color=#0000cc>rtrim</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$i</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse & return the final loop <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>str_replace</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'b'</FONT><FONT color=#006600>] . </FONT><FONT color=#0000cc>$loop </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$t</FONT><FONT color=#006600>[</FONT><FONT color=#cc0000>'e'</FONT><FONT color=#006600>], </FONT><FONT color=#0000cc>$parsed</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>/*--------------------------------------------------------------* <BR> Method: fetch() <BR> Returns the parsed contents of the specified template. <BR> *--------------------------------------------------------------*/ <BR> </FONT><FONT color=#006600>function </FONT><FONT color=#0000cc>fetch</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$file_name</FONT></FONT><FONT color=#006600 face=GulimChe>) { <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Prepare the path <BR> </FONT><FONT color=#0000cc>$file </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>base_path </FONT><FONT color=#006600>. </FONT><FONT color=#0000cc>$file_name</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Open the file <BR> </FONT><FONT color=#0000cc>$fp </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>fopen</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$file</FONT><FONT color=#006600>, </FONT><FONT color=#cc0000>'rb'</FONT></FONT><FONT face=GulimChe><FONT color=#006600>); <BR> if(!</FONT><FONT color=#0000cc>$fp</FONT><FONT color=#006600>) return </FONT><FONT color=#0000cc>FALSE</FONT></FONT><FONT color=#006600 face=GulimChe>; <BR> <BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Read the file <BR> </FONT><FONT color=#0000cc>$contents </FONT><FONT color=#006600>= </FONT><FONT color=#0000cc>fread</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$fp</FONT><FONT color=#006600>, </FONT><FONT color=#0000cc>filesize</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$file</FONT></FONT><FONT color=#006600 face=GulimChe>)); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Close the file <BR> </FONT><FONT color=#0000cc>fclose</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$fp</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR><BR> </FONT><FONT face=GulimChe><FONT color=#ff9900>// Parse and return the contents <BR> </FONT><FONT color=#006600>return </FONT><FONT color=#0000cc>$this</FONT><FONT color=#006600>-></FONT><FONT color=#0000cc>parse</FONT><FONT color=#006600>(</FONT><FONT color=#0000cc>$contents</FONT></FONT><FONT color=#006600 face=GulimChe>); <BR> } <BR>} <BR></FONT><FONT color=#0000cc><FONT face=GulimChe>?> </FONT><BR></FONT></P> <P><FONT color=#0000cc></FONT> </P> <P><FONT color=#0000cc><INS style="BORDER-BOTTOM: medium none; POSITION: relative; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 728px; PADDING-RIGHT: 0px; DISPLAY: inline-table; HEIGHT: 90px; VISIBILITY: visible; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px"><INS style="BORDER-BOTTOM: medium none; POSITION: relative; BORDER-LEFT: medium none; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 728px; PADDING-RIGHT: 0px; DISPLAY: block; HEIGHT: 90px; VISIBILITY: visible; BORDER-TOP: medium none; BORDER-RIGHT: medium none; PADDING-TOP: 0px" id=google_ads_frame2_anchor><IFRAME style="POSITION: absolute; TOP: 0px; LEFT: 0px" id=google_ads_frame2 height=90 marginHeight=0 src="http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-1810102646696146&output=html&h=90&slotname=8373878086&w=728&lmt=1293729078&flash=10.1.102.64&url=http%3A%2F%2Ffreewebkorea.com%2Fdefault%2Findex.php&dt=1293729078544&shv=r20101117&jsv=r20101214&saldr=1&prev_slotnames=3246935894&correlator=1293729078111&frm=0&adk=2838309694&ga_vid=1721536298.1293729078&ga_sid=1293729078&ga_hid=703080614&ga_fc=0&u_tz=540&u_his=0&u_java=1&u_h=1080&u_w=1920&u_ah=1040&u_aw=1920&u_cd=32&u_nplug=0&u_nmime=0&biw=1916&bih=843&ifk=2478696134&eid=30143207&ref=http%3A%2F%2Ffreewebkorea.com%2F&fu=4&ifi=2&dtd=15&xpc=qZex7x9KNc&p=http%3A//freewebkorea.com" frameBorder=0 width=728 allowTransparency name=google_ads_frame marginWidth=0 scrolling=no></IFRAME></INS></INS></P></FONT>
÷ºÎÆÄÀÏ
Down1314-bTemplate_0.1.zip
°ßÀû°è»êÇϱâ
ÀÛ¾÷ÀÇ·Ú
°ßÀû¹®ÀÇ
°øÁö»çÇ×