<?
/***
* pLiMa - php List Manager
* Copyright (C) 2003 Jinn Koriech (hide@address.com)
*
* This file is part of pLiMa.
*
* pLiMa is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* pLiMa is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with pLiMa; if not, visit http://www.gnu.org or write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
*/
function getFields($table_name) {
$fields = @mysql_list_fields(DB_NAME, $table_name);
for ( $jdx = 0; $jdx < @mysql_num_fields($fields); $jdx++ ) {
if ( mysql_field_name($fields,$jdx) != 'userid' )
$field_names[] = mysql_field_name($fields,$jdx);
}
return $field_names;
}
function getOptions($list_name) {
$sql = "SELECT * FROM lima_option WHERE list_name='".$list_name."';";
$result = db_query($sql, "HELPER10");
$row = db_fetch_array($result, $rdx);
$fields = getFields("lima_option");
$numFields = count($fields);
for ( $rdx=0; $rdx < $numFields; $rdx++ ) {
$options[$fields[$rdx]] = $row[$rdx];
}
return $options;
}
function fix_cr($string) {
if ( preg_match("/(\015\012)|(\015)|(\012)/",$string,$match) ) {
if ( preg_match("/(\015\012)/",$string) ) {
//echo ("<BR>#015 #012 found - PC<BR>");
if ( $match[1] ) { $needle = "/(\015\012)/"; }
if ( $match[2] ) { $needle = "/(\015)/"; }
if ( $match[3] ) { $needle = "/(\012)/"; }
} elseif ( preg_match("/(\015)/",$string) ) {
//echo ("<BR>#015 found - Mac<BR>");
if ( $match[1] ) { $needle = "/(\015\012)/"; }
if ( $match[2] ) { $needle = "/(\015)/"; }
if ( $match[3] ) { $needle = "/(\012)/"; }
} elseif ( preg_match("/(\012)/",$string) ) {
//echo ("<BR>#012 found - Unix<BR>");
if ( $match[1] ) { $needle = "/(\015\012)/"; }
if ( $match[2] ) { $needle = "/(\015)/"; }
if ( $match[3] ) { $needle = "/(\012)/"; }
}
$string = preg_replace($needle,"\015\012",$string);
}
return $string;
}
?>