<?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');
/*******************************************/
global $rSdb;

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

if( ! check_ajax_referer('remember-image', false) )
	die('0|'.__('Security Alert: Direct access not permitted!','recipeshelf'));

### Grab Options
$useroptions	= $rSdb->get_option( $user->_user_name."_options" );
$rS_default_img	= $useroptions['rS_default_img'];
$id				= (int)$_POST['recipe-id'];


if(  $id>0  ){

	if( is_array($rS_default_img) ){

		if( array_key_exists ( $id,$rS_default_img ) && $_POST['img-id']=='1' ){
			unset( $rS_default_img[$id] );                ### remove
		}else
		    $rS_default_img[$id] = $_POST['img-id'];	### add

	}else{ ### new fave array
	    $rS_default_img = array();
	    $rS_default_img[$id] = $_POST['img-id'];	### new
	}

	### save user options
	$useroptions['rS_default_img'] = $rS_default_img;
	$rSdb->update_option( $user->_user_name."_options",$useroptions );

}
//echo "<pre>debug: ".print_r($rS_default_img,1)."</pre>";
?>