<? require "./mklib.php"; ?> 
<? require "./mk_datetime.php"; ?> 
<html> 
<head> 
    <title>mklib.php Example/Test Page</title> 
    <meta name="author" value="Marcus Kazmierczak"> 
</head> 
<body bgcolor="#FFFFFF"> 

<h1>mklib Example/Test Page</h1> 

<h2>mklib.php <?=mk_getVersion()?></h2> 

<p>The latest version of the <b>mklib.php</b> library and this example page is 
at<br> 
mklib.php home: <a 
href="http://blazonry.com/scripting/mklib/index.php">http://blazonry.com/scripting/mklib</a></p> 




<table cellpadding=4 cellspacing=0 border=0 width="100%" bgcolor="#BBBBBB"> 
<tr><td><font size="+1"><b>File Functions</b></font></td></tr></table> 
<blockquote> 

<h3>getFileExtension()</h3> 
<p>Parses the passed filename and returns just the extension, defined by 
everything after the last period.</p> 

<p><b>Example</b><br> 
<table cellpadding=4 cellspacing=0 border=0> 
<? 
    $f1 = "sample.txt"; 
    $f2 = "sample.filename.test.txt"; 
    print "<tr><td><b>\$f1: </b></td><td> $f1 </td></tr>\n"; 
    print "<tr><td><b>getFileExtension(\$f1): </b></td><td>" . 
getFileExtension($f1) . "</td></tr>\n"; 
    print "<tr><td><b>\$f2: </b></td><td> $f2 </td></tr>\n"; 
    print "<tr><td><b>getFileExtension(\$f2): </b></td><td>" . 
getFileExtension($f2) . "</td></tr>\n"; 

?> 
</table> 
<p><hr></p> 

<h3>getFilenameSansExt()</h3> 
<p>Parses the passed filename and returns just the filename portion without the 
extension.</p> 

<p><b>Example</b><br> 
<table cellpadding=4 cellspacing=0 border=0> 
<? 
    $f1 = "sample.txt"; 
    $f2 = "sample.filename.test.txt"; 
    print "<tr><td><b>\$f1: </b></td><td> $f1 </td></tr>\n"; 
    print "<tr><td><b>getFilenameSansExt(\$f1): </b></td><td>" . 
getFilenameSansExt($f1) . "</td></tr>\n"; 
    print "<tr><td><b>\$f2: </b></td><td> $f2 </td></tr>\n"; 
    print "<tr><td><b>getFilenameSansExt(\$f2): </b></td><td>" . 
getFilenameSansExt($f2) . "</td></tr>\n"; 

?> 
</table> 

</blockquote> 
</table></p> 
<p><hr></p> 




<table cellpadding=4 cellspacing=0 border=0 width="100%" bgcolor="#BBBBBB"> 
<tr><td><font size="+1"><b>Text Functions</b></font></td></tr></table> 
<blockquote> 

<h3>procDisplayText()</h3> 
<p>Formats text to be displayed in a browser. It converts line breaks to 
&lt;br&gt; and converts http://(.*) to live HTML links.</p> 

<p><b>Example</b><br> 
<table cellpadding=4 cellspacing=0 border=0> 
<? 
    $str = "This is a URL: http://www.mkaz.com/"; 
    print "<tr><td><b>\$str: </b></td><td> $str </td></tr>\n"; 
    print "<tr><td><b>procDisplayText(\$str): </b></td><td>" . 
procDisplayText($str) . "</td></tr>\n"; 
?> 
</table></p> 
<p><hr></p> 



<h3>procDBText()</h3> 
<p>Prepares a string for inserting into a database. Depending on the different 
settings (0,1,2) it allows for different HTML  tags to be inserted. <br> 
0 - Allows No HTML or PHP tags 
1 - Allows for B,I, 
2 - 

<p><b>Example</b><br> 
<table cellpadding=4 cellspacing=0 border=0> 
<? 
    $str = 'Here\'s some text with <b>bold</b> tags and <? print "PHP"; ?> 
tags'; 
    print "<tr><td><b>\$str: </b></td><td> ".htmlentities($str)." </td></tr>\n"; 

    print 
"<tr><td><b>procDBText(\$str,0)</b></td><td>".procDBText($str,0)."</td></tr>\n"; 

    print 
"<tr><td><b>procDBText(\$str,1)</b></td><td>".procDBText($str,1)."</td></tr>\n"; 

    print 
"<tr><td><b>procDBText(\$str,2)</b></td><td>".procDBText($str,2)."</td></tr>\n"; 

?> 
</table></p> 
<p><hr></p> 


<h3>mk_substr()</h3> 

<p>Chops a string close to the given length, trying to make the cut at a space. 
It moves backwards cutting more than the specified length.</p> 

<p><b>Example</b><br> 
<table cellpadding=4 cellspacing=0 border=0> 
<? 
    $pos ="01234567890123456789012345678901234567890"; 
    $str = "This is my string, there are many like it but this one is mine."; 
     
    $cutstr = mksubstr($str,40); 

    print "<tr><td><b>Counter: </b></td><td><code>$pos</code></td></tr>\n"; 
    print "<tr><td><b>Original: </b></td><td><code>$str</code></td></tr>\n"; 
    print "<tr><td><b>Cut String: 
</b></td><td><code>$cutstr</code></td></tr>\n"; 
?> 
</table></p> 
<p><hr></p> 

<h3>format_bytes()</h3> 

<p>Formats passed bytes into a more human readable format, converting to "kb" 
and "mb" when appropiate, kinda like the -h option for df or ls.</p> 

<p><b>Example</b><br> 
<table cellpadding=4 cellspacing=0 border=0> 
<? 
    $b1 = "123456789"; 
    $b2 = "25689"; 
    $b3 = "1024"; 
     
     
    print "<tr><td><b>Bytes 1: </b></td><td>$b1</td></tr>\n"; 
    print "<tr><td><b>Bytes 2: </b></td><td>$b2</td></tr>\n"; 
    print "<tr><td><b>Bytes 2: </b></td><td>$b3</td></tr>\n"; 
    print "<tr><td><b>Formatted B1: 
</b></td><td>".format_bytes($b1)."</td></tr>\n"; 
    print "<tr><td><b>Formatted B2: 
</b></td><td>".format_bytes($b2)."</td></tr>\n"; 
    print "<tr><td><b>Formatted B3: 
</b></td><td>".format_bytes($b3)."</td></tr>\n"; 
?> 
</table></p> 
<p><hr></p> 
</blockquote> 
<br><br> 

<h2>mk_datetime.php testing</h2> 
<table cellpadding=4 cellspacing=0 border=0 width="100%" bgcolor="#BBBBBB"> 
<tr><td><font size="+1"><b>Date/Time Functions</b></font></td></tr></table> 
<blockquote> 

<h3>procDate()</h3> 

<p>Converts a passed date in varying mm-dd-yyyy formats 
into a sql compatible yyyy-mm-dd. If a two-digit year is passed to it 
is assumed to be 19xx if greater than 70, and 20xx if not. Used before 
inserting dates into database.</p> 

<p><b>Example</b><br> 
<table cellpadding=4 cellspacing=0 border=0> 
<? 
    $mydate1 = "3-26-99"; 
    $mydate2 = "8-5-00"; 
    $mydate3 = "10-15-01"; 

    print "<tr><td><b>\$mydate1: </b></td><td>$mydate1</td></tr>\n"; 
    print "<tr><td><b>\$mydate2: </b></td><td>$mydate2</td></tr>\n"; 
    print "<tr><td><b>\$mydate3: </b></td><td>$mydate3</td></tr>\n"; 
    print "<tr><td><b>procDate(\$mydate1): 
</b></td><td>".procDate($mydate1)."</td></tr>\n"; 
    print "<tr><td><b>procDate(\$mydate2): 
</b></td><td>".procDate($mydate2)."</td></tr>\n"; 
    print "<tr><td><b>procDate(\$mydate3): 
</b></td><td>".procDate($mydate3)."</td></tr>\n"; 
?> 
</table></p> 
<p><hr></p> 


<h3>revDate()</h3> 

<p>Reverses a SQL date from yyyy-mm-dd to mm-dd-yyyy, 
the common US date format. Used for displaying dates grabbed from database.</p> 

<p><b>Example</b><br> 
<table cellpadding=4 cellpspacing=0 border=0> 
<? 
    $mydate = "2000-12-5"; 
     
    print "<tr><td><b>\$mydate: </b></td><td>$mydate</td></tr>\n"; 
    print "<tr><td><b>procDate(\$mydate): 
</b></td><td>".revDate($mydate)."</td></tr>\n"; 
?> 
</table></p> 
<p><hr></p> 

</blockquote> 

<p>&nbsp;</p> 

<p> 
Created By: Marcus Kazmierczak, marcus@mkaz.com<br> 
Last Updated: 2001-08-22</p> 

<p>&nbsp;</p> 
<p>&nbsp;</p> 

</body> 
</html> 



