<?php

$oldURL = dirname(__FILE__);
$newURL = str_replace(DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'dedication-from-site', '', $oldURL);

require_once( $newURL . DIRECTORY_SEPARATOR . 'wp-load.php');
global $wpdb;

// if the 'term' variable is not sent with the request, exit
if (!isset($_REQUEST['term']))
    exit;

$data = array();

$wp_user_search = $wpdb->get_results("SELECT ID, display_name, user_email FROM $wpdb->users ORDER BY ID");
foreach ($wp_user_search as $userid) {
    $user_id = (int) $userid->ID;
    $display_name = stripslashes($userid->display_name);
    $user_email = stripslashes($userid->user_email);
    
    $data[] = array(
        'label' => $display_name . ' (' . $user_email . ')',
        'value' => $user_id
    );
}
// jQuery wants JSON data
echo json_encode($data);
flush();


//// connect to the database server and select the appropriate database for use
//$dblink = mysql_connect('server', 'username', 'password') or die(mysql_error());
//mysql_select_db('database_name');
//// query the database table for zip codes that match 'term'
//$rs = mysql_query('select zip, city, state from zipcode where zip like "' . mysql_real_escape_string($_REQUEST['term']) . '%" order by zip asc limit 0,10', $dblink);
//// loop through each zipcode returned and format the response for jQuery
//
//if ($rs && mysql_num_rows($rs)) {
//    while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
//        $data[] = array(
//            'label' => $row['zip'] . ', ' . $row['city'] . ' ' . $row['state'],
//            'value' => $row['zip']
//        );
//    }
//}
//// jQuery wants JSON data
//echo json_encode($data);
//flush();
