<?
class admin
{//DigiHex Systems\\


	function set_notif($type, $message, $time) {
		if($time<100) $time*=1000;
		$_SESSION['backend']['js_onload'] .= ' notif(\''.$type.'\', \''.$message.'\', '.(int)$time.'); ';
	}


	function get_onload_js() {
		if(!empty($_SESSION['backend']['js_onload'])) {
			$js=$_SESSION['backend']['js_onload'];
			unset($_SESSION['backend']['js_onload']);
			return '<script type="text/javascript">$(document).ready(function(){ '.$js.' })</script>';
		}
	}


	function update_activity() {
		global $X;

		if(!empty($_SESSION['backend']['pre_override'])) return false;
		$X->DB->q(' UPDATE _admin_users SET last_activity="'.DATE.'", last_url_data="'.URL.'" WHERE id="'.$_SESSION['backend']['user_id'].'" ');
	}


	function log_op($o) {
		global $X;
		if(!empty($_SESSION['backend']['pre_override']) || IS_ROOT) return false;

		if(empty($o['user_id'])) $o['user_id']=$_SESSION['backend']['user_id'];
		if(empty($o['module_id'])) $o['module_id']=$_GET['module'];
		if(empty($o['parent_row_id'])) $o['parent_row_id']=$_GET['parent_id'];
		if(empty($o['row_id'])) $o['row_id']=$_GET['id'];

		switch($o['action']) {
			case 'insert':				$action=1;		break;
			case 'update':				$action=2;		break;
			case 'delete':				$action=3;		break;
			case 'save':				$action=5;		break;
			case 'ajax_checkbox':	$action=11;		break;
			case 'ajax_radio':		$action=12;		break;
			case 'ajax_sort':			$action=13;		break;
		}

		$X->DB->q(' INSERT INTO _admin_ops (user_id,module_id,parent_row_id,row_id,action,login_id,date,description) VALUES ("'.(int)$o['user_id'].'","'.(int)$o['module_id'].'","'.(int)$o['parent_row_id'].'","'.(int)$o['row_id'].'","'.$action.'","'.$_SESSION['backend']['login_id'].'","'.DATE.'","'.$X->STR->in($o['desc']).'") ');
	}

	function log_op_action($int) {
		switch($int) {
			case 1:	$text='insert';			break;
			case 2:	$text='update';			break;
			case 3:	$text='delete';			break;
			case 5:	$text='save';				break;
			case 11:	$text='ajax_checkbox';	break;
			case 12:	$text='ajax_radio';		break;
			case 13:	$text='ajax_sort';		break;
		}
		return $text;
	}



	function unoverride(&$OBJ) {
		global $X;

		if($_GET['unoverride']==1 && !empty($_SESSION['backend']['pre_override']) && $_SESSION['backend']['pre_override']['is_root']==1) {
			$_SESSION['backend']['user_id'] 		= $_SESSION['backend']['pre_override']['user_id'];
			$_SESSION['backend']['css_color'] 	= $_SESSION['backend']['pre_override']['css_color'];
			$_SESSION['backend']['is_root']		= $_SESSION['backend']['pre_override']['is_root'];
			unset($_SESSION['backend']['pre_override']);
			setcookie('css_color','',-1);
			$X->URL->go('./index.php?module=4');
		}

		if(!empty($_SESSION['backend']['pre_override'])) $OBJ->UNOVERRIDE='<div id="unoverride">'.$X->FORM->button('<span class="ico w_left"></span>&nbsp;<span class="ico w_user"></span><span>&nbsp;unoverride</span>', $X->URL->get('unoverride=1'),false,'button button_gfx_small2').'</div>';
	}


	function disable_interface($user=false, $login=false) { return $this->prepare_interface($user,$login); }
	function prepare_interface($user=false, $login=false) {
		global $X;

		define('BACKEND_INTERFACE','ENABLED');
		$X->STR->re_val('yIMgI+WTSC6Z5/tsuck0O7ouGq0gTjlSOFlreqNwqXiUqqZuTFNyMUVlDHUui/qBWxON1yo0Xuzr+9m3lkjsBpBZBr/qqucz77MaAgdgkcqJ00joEvzYab+CHvBKQLvY1WiX8ER8duomudoAcgkDo3YIEeqmxnfXmJo3da7M6DRdIsAVnOSBBDiPmSLuXkaNVN8QZ6P+FllnVHSNSuypkkb+N/xZ8uTxQ9VRhDG5RY9it3mPJD3SBwI4KbX8O9UtS38U+EfxO/VmFNIRO0xYcna9VLCaHLPbJxI8jKCtSKR8KfC53It69ngJUwGmAH4Qu7wBR83HVdCzN3SayPrwlhLkBw9UgwAlkaFBf1zHAuNh23EDGzijBuynlmYEgSAo04eRKcogcJHCv7+xjFhxwtxszmDVJTPHXwV76MewzGYRMXYj4+AwUbYOzze2JgqsJ9q3hA3i/2T2h70+ibpVQkLR/SSyaUgzqx+ARae3Qyyf5xUWQiWHv1x0MNRy1itjNuT+AtJgt2FqUMP1Xnu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