wrote this file. * As long as you retain this notice you can do whatever you want with this * software. If we meet some day, and you think this stuff is worth it, you can * buy me a beer in return. * Sandino Araico Sánchez * --END LICENSE--------------------------------------------------------------- * --LICENCIA EN ESPAÑOL MEXICANO---------------------------------------------- * "LA LICENCIA BEER-WARE" (traducción al español de la revisión 42-sandino-3): * Sandino Araico Sánchez escribió éste archivo. * Siempre y cuando usted retenga éste aviso (en español y en inglés) usted * puede hacer cualquier cosa con éste software. Si algún día nos encontramos y * usted piensa que éste software vale la pena, usted puede invitarme una * cerveza en recompensa. * Sandino Araico Sánchez * --FIN DE LICENCIA----------------------------------------------------------- */ # Changelog: # 2002-01-29 Sandino Araico Sánchez - db procedures in flat files if(!defined('__H_DB_FILE')) { define('__H_DB_FILE',1); #---------------------------------------------------------------------------- if(!defined('__H_DB_FILE_SEPARATOR')) define('__H_DB_FILE_SEPARATOR',':'); if(!defined('__H_DB_FILE_PATH')) define('__H_DB_FILE_PATH','.'); #---------------------------------------------------------------------------- function h_db_get_basic_array_from_file($file_name,$col0=0,$col1=1) { $file=s_fopen(__H_DB_FILE_PATH.'/'.$file_name,'r'); if(!$file) return; while(!feof($file)) { $line=fgets($file,1024); # s_log("line: $line"); $line_array=explode(__H_DB_FILE_SEPARATOR,$line); $key=$line_array[$col0]; $val=$line_array[$col1]; $array[$key]=$val; } fclose($file); return $array; } function h_db_find_key_in_file($file_name, $str,$col0=0,$col1=1) { if(empty($str)) return; $array=h_db_get_basic_array_from_file($file_name,$col0,$col1); if(!is_array($array)) return; foreach($array as $key => $value) { # s_log("key: $key\tstr: $str"); if($key==$str) return $str; } return; } #---------------------------------------------------------------------------- } //__H_DB_FILE