Hi all!
I just wanted to share a php library I used in conjunction with the mystic_library.php library of Frank Linhares that I updated. I've used it as
a base for my website and now I've also created a simple library that will convert MCI colors and ASCII characters into beautiful HTML images.
I save this file as myconv.php: ----------------------------------------------------------------------
<?php
function myconv($line){
$line = mci_d_replace($line);
$line = mci_c_replace($line);
$line = str_replace("|00", "<span style='color:black;'>", $line);
$line = str_replace("|01", "<span style='color:darkblue;'>", $line);
$line = str_replace("|02", "<span style='color:darkgreen;'>", $line);
$line = str_replace("|03", "<span style='color:darkcyan;'>", $line);
$line = str_replace("|04", "<span style='color:darkred;'>", $line);
$line = str_replace("|05", "<span style='color:darkmagenta;'>", $line);
$line = str_replace("|06", "<span style='color:brown;'>", $line);
$line = str_replace("|07", "<span style='color:gray;'>", $line);
$line = str_replace("|08", "<span style='color:darkgray;'>", $line);
$line = str_replace("|09", "<span style='color:blue;'>", $line);
$line = str_replace("|10", "<span style='color:lawngreen;'>", $line);
$line = str_replace("|11", "<span style='color:cyan;'>", $line);
$line = str_replace("|12", "<span style='color:red;'>", $line);
$line = str_replace("|13", "<span style='color:magenta;'>", $line);
$line = str_replace("|14", "<span style='color:yellow;'>", $line);
$line = str_replace("|15", "<span style='color:white'>", $line);
$line = str_replace("|16", "<span style='background-color:black;'>", $line);
$line = str_replace("|17", "<span style='background-color:darkblue;'>", $line);
$line = str_replace("|18", "<span style='background-color:darkgreen;'>", $line);
$line = str_replace("|19", "<span style='background-color:darkcyan;'>", $line);
$line = str_replace("|20", "<span style='background-color:darkred;'>", $line);
$line = str_replace("|21", "<span style='background-color:darkmagenta;'>", $line);
$line = str_replace("|22", "<span style='background-color:brown;'>", $line);
$line = str_replace("|23", "<span style='background-color:darkgrey;'>", $line);
$line = str_replace("|CL", "", $line);
$line = str_replace("|CR", "", $line);
$line = str_replace("|PN", "", $line);
$line=iconv('CP437','UTF-8',$line);
return $line;
}
function mci_c_replace($str){
$cnt=substr_count($str,"|[C");
for ($x=0;$x<$cnt;$x++){
$pos=strpos($str,"|[C");
$ostr=substr($str,$pos,5);
$len=substr($str,$pos+3,2);
$nstr=str_pad("",(int) $len," ");
$str=str_replace($ostr,$nstr,$str);
}
return $str;
}
function mci_d_replace($str){
$cnt=substr_count($str,"|\$D");
for ($x=0;$x<$cnt;$x++){
$pos=strpos($str,"|\$D");
$ostr=substr($str,$pos,5);
$len=substr($str,$pos+3,2)-1;
$nchr=substr($str,$pos+5,1);
$nstr=str_pad("",(int) $len,$nchr);
$str=str_replace($ostr,$nstr,$str);
}
return $str;
}
-----------------------------------------------------------------------
It can be used in your php code like this:
<?php
include "mconv.php";
echo "<table>";
echo "<tr>";
$str=myconv("|01This |02is |03an |04example|05Mystic |06Color |07Codes");
echo "<td>".$str."<td>";
echo "</tr>";
echo "</table>";
It will also convert ASCII characters into UTF-8 HTML format.
You can see a prime example of its use on my website. Look in the ANSI ART files area and see how the ASCII art is perfectly rendered.
http://cyberia.darktech.org:8080/filelist.php?area=ansiart
You can also see an example of how this converts the MCI output of a doorgame usage generator bulletin.
http://tinyurl.com/hg9kdq6
Let me know if this is helpful to anybody.
"No matter where you go, there you are!" - Buckaroo Bonzai
--- Mystic BBS v1.12 A31 (Raspberry Pi)
* Origin: Cyberia BBS | Cyberia.Darktech.Org | Kingwood, TX (44:100/4)