<?php

function get_value($type){
	return @mysql_result(mysql_query("SELECT `value` FROM `settings` WHERE `type`='$type'"),0,0);
	
}
function is_valid_email( $email )
	{
		return preg_match( '/[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/', $email );
	}
function set_value($value,$type){


		if(is_array($value) && is_array($type)){


			foreach($value as $keyval => $valls){


				if(!isset($valls)){


					$valls="0";


				}


				if(@mysql_result(mysql_query("SELECT `id` FROM `settings` WHERE `type`='".$type[$keyval]."'"),0,0) != "0"){


					@mysql_query("UPDATE `settings` SET `value`='$valls' WHERE `type`='".$type[$keyval]."'");


				}else{


					@mysql_query("INSERT INTO settings(`value`,`type`) VALUES('$valls','".$type[$keyval]."')");


				}


			}


			return true;


		}else{


			if(@mysql_result(mysql_query("SELECT `id` FROM `settings` WHERE `type`='$type'"),0,0) != "0"){


				@mysql_query("UPDATE `settings` SET `value`='$value' WHERE `type`='$type'");


			}else{


				@mysql_query("INSERT INTO settings(`value`,`type`) VALUES('$value','$type')");


			}


			return true;


		}


	}


?>