<?php
/* Include Files ***************************/
require_once('../../db-config.php');
require_once('../../inc/lib-compat-class.php');
require_once('../../inc/lib-db-class.php');
require_once('../../inc/lib-login-class.php');
require_once('../../JSON/jsonwrapper_inner.php');
/*******************************************/
global $rSdb;

$user	= new userManagement();
if(  !$user->_logged_in  )
	die(__('Access denied.','recipeshelf'));

if( ! check_ajax_referer('get-info', false) )
	die('0|'.__('Security Alert: Direct access not permitted!','recipeshelf'));	
	
$_POST['q'] = trim( str_replace('*','',$_POST['q']) );

$sql =  "SELECT object,id FROM {$rSdb->DBobjects} WHERE type='2' AND object LIKE '%{$_POST['q']}%' GROUP BY object LIMIT 0,300";
$entries = $rSdb->fetchArr($sql);

if ($entries) :
	$arrJSON = array();
	$i=0;
	foreach( $entries as $r ){
		$arrJSON[$i][txt]  = $r->object;
		$arrJSON[$i++][id] = $r->id;
	}

	echo json_encode($arrJSON);
endif;
?>