<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2005, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sf.net>
	*	@version	CVS: $Id:$
	*	@link		http://gekkoware.sourceforge.net
	*/

	if (!defined("IN-GEKKO")) die("Get a life!");


	function keyname_err($keyname) {
		return preg_match("/[^a-zA-Z0-9._\-]/", $keyname);
	}
	function getKeyTypeByID($id) {
		switch ($id) {
			case "0": $type = _l("L_STRING"); break;
			case "1": $type = _l("L_INTEGER"); break;
			case "2": $type = _l("L_BOOLEAN"); break;
		}
		return strtolower($type);
	}
	function deleteConfKey($id) {
		return $GLOBALS["db"]->query ("DELETE FROM ".db_table("conf")." WHERE ID='".$id."'", __FILE__, __LINE__, true);
	}
	function confSetKey($module, $name, $value, $keytype = null) {
		$q = $GLOBALS["db"]->query ("
		INSERT INTO ".db_table("conf")."
			(
				ID,
				Module,
				KeyName,
				KeyValue,
				KeyType,
				Modified
			)
				VALUES
			(
				'".$GLOBALS["db"]->free_id("conf")."',
				'$module',
				'$name',
				'".fix_keyvalue($value, $keytype)."',
				'$keytype',
				'".time()."'
			)
		", __FILE__, __LINE__, true);
		return $q;
	}
?>