'error', 'cause' => 'auth-load' ) ); exit; } } else { print json_encode( array( 'response' => 'error', 'cause' => 'config-error' ) ); exit; } /*******************************/ function check_authkey ( $key ) { global $config; if ( $key == "6327c08b70f9" ) return true; return false; } function new_key( ) { // Basically this is at the moment a slightly modified // version of generate_password() from user_functiions.php // The behaviour/output of this function is expected to change // so using generate_password() directly does not make sense... $length = 16; $string = ""; while ( strlen( $string ) < $length ) { $string .= crypt( substr(sha1(rand()), 0, $length) ); $string = preg_replace( '/\W/', '', $string); } return substr( $string, 0, $length ); } function simple_authfail() { print json_encode( array( 'response' => 'failed', 'cause' => 'unauthorized', 'description' => 'Not authorized') ); exit; } function token_auth( ) { global $_GET; if ( array_key_exists('auth_key', $_GET ) ) { if ( ! check_authkey($_GET['auth_key'] ) ) simple_authfail(); } else simple_authfail(); } function can_write ( ) { // Stub, to be called on any API nodes taht write data in the DB. return true; } ?>