Hylafax Mailing List Archives
|
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[hylafax-users] PHP Script to Parse WHFC Phone Book File
Just wrote this script this morning to aid in the process of converting the
phb file format into a new odbc based system. I know it's not a Hylafax
topic directly, but lots of us use WHFC to front-end Hylafax. The csv file
can be easily imported into nearly any database. My $.02 contribution:
<?php
/* Ray Ortgiesen, Dominion Diagnostics LLC
* Script to convert the WHFC phb file into a CSV file
* The Fields
* Recipient Identifier:
* Fax Number:
* To:
* Company:
* Location:
* Voice Number:
* Remarks:
* Fine Print:
*/
/* new output file */
$ofile = fopen("p:\\fax\\dominion.csv", "wb");
fwrite($ofile,"Recipient,FaxNumber,ToName,Company,Location,VoiceNumber,Remarks,FinePrint\r\n");
/* open the file and store it into a big string */
$ifile = fopen("p:\\fax\\dominion.phb", "r");
$haystack = fread($ifile, 1000000);
fclose($ifile);
/* remove first 8 characters of the header */
$haystack = substr($haystack, 8);
/* get 8 fields, then write them out as a record with a cr/lf on the end */
while(strpos($haystack,"|") !== false) {
list($f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8, $haystack) = explode("|",
$haystack, 9);
$f1 = strtr($f1, "\"","'");
$rec =
"\"".$f1."\",\"".$f2."\",\"".$f3."\",\"".$f4."\",\"".$f5."\",\"".$f6."\",\"".$f7."\",\"".$f8."\"\r\n";
/* echo $rec; */
fwrite($ofile,$rec);
}
fclose($ofile);
?>
Hylafax is an awesome piece of software, keep up the great work guys.
Thanks for the bandwidth,
Ray
CONFIDENTIALITY NOTICE: This e-mail, including attachments, is for the sole use of the individual to whom it is addressed. This message is confidential and may contain information that is privileged, confidential and is exempt from disclosure under applicable law. Any unauthorized review, use, disclosure or distribution is prohibited. If you have received this e-mail in error, please notify the sender by reply e-mail and destroy this message and its attachments.