<?php 

##
# WP-Nostr-NIP05 released under GPLv2 License
#
# Copyright (c) 2023 EasyDNS Technologies Inc 
#                    https://easydns.com
#
# Devs: Tejinder Singh
#       Mark E. Jeftovic
#
# Project: easyNostr      https://easyNostr.com
#
# Github: https://github.com/easydns/wp-nostr-nip05
##

require_once( '../wp-load.php' );
global $wpdb; 
$nostruser    = $wpdb->prefix.'users';
$name=sanitize_text_field(strtolower($_GET['name']));
if (substr($name, 0, 1) === '_') {
  $hexkey =  get_option( 'nostr_hexkey' );
  $name = "_";
} else {
	$result = $wpdb->get_results( "SELECT * FROM   $nostruser where user_login = '$name'");
 	foreach($result as $row) {
	if($row) {
       		$hexkey = get_user_meta( $row->ID, 'hexkey', true );
		}     
	}
}
if(!empty($hexkey)){
        $JSON_RESPONSE = Array (
	        "names" => array(
		$name => $hexkey
                ));
	echo $data = json_encode($JSON_RESPONSE);
        }
?>
 
     
