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: # 2000-09-13 Sandino Araico Sánchez - Basic authentication if(!defined("__HOPP_BASIC_AUTH")) { define ("__HOPP_BASIC_AUTH",1); #--------------------------------------------------------------------- #include "include/hopp-dbfunctions.inc"; include __HOPP_INCLUDE_PATH."s.inc"; #--------------------------------------------------------------------- if(!defined('__HOPP_AUTH_BASIC_REALM')) define('__HOPP_AUTH_BASIC_REALM','HOPP Basic Authentication'); if(!defined('__HOPP_AUTH_BASIC_REALM_UNAUTHORIZED')) define('__HOPP_AUTH_BASIC_REALM_UNAUTHORIZED','Unauthorized'); #--------------------------------------------------------------------- function auth_basic($defid=0, $function='auth_basic_query') { global $PHP_AUTH_USER, $PHP_AUTH_PW; auth_basic_headers(); $id=hopp_db_connected($defid); return $function($PHP_AUTH_USER, $PHP_AUTH_PW, $defid); } function auth_basic_headers() { global $PHP_AUTH_USER, $PHP_AUTH_PW; if(!isset($PHP_AUTH_USER)) auth_basic_headers_send(); } function auth_basic_headers_send() { Header('WWW-Authenticate: Basic realm="'.__HOPP_AUTH_BASIC_REALM.'"'); Header('HTTP/1.0 401 '.__HOPP_AUTH_BASIC_REALM_UNAUTHORIZED); echo __HOPP_AUTH_BASIC_REALM.': '.__HOPP_AUTH_BASIC_REALM_UNAUTHORIZED."\n"; exit; } function auth_basic_retry($defid=0, $function='auth_basic') { if(!$function($defid)) auth_basic_headers_send(); } function auth_basic_query($user, $pw, $defid=0) { $id=hopp_db_connected($defid); $sql="select count(*) from h_auth_basic_user where h_auth_usr_name = '$user' and h_auth_usr_pw = '".md5($pw)."'"; s_log("sql: $sql"); return hopp_db_get_single_field_result($id, $sql); } #--------------------------------------------------------------------- } //__HOPP_BASIC_AUTH ?>