<?php
namespace C;
function res( $obj ){
	$str =  json_encode( $obj );
	if( $str === false){
		$jsonErr = json_last_error();
		$err = \CC\RES::RES_SYSERRORS[ 'JSON_CONVERT_ERROR' ];
		switch ( $jsonErr ) {
		        case JSON_ERROR_NONE:
		            $err[ 'discription' ] = ' - No errors';
		        break;
		        case JSON_ERROR_DEPTH:
		            $err[ 'discription' ] = ' - Maximum stack depth exceeded';
		        break;
		        case JSON_ERROR_STATE_MISMATCH:
		            $err[ 'discription' ] = ' - Underflow or the modes mismatch';
		        break;
		        case JSON_ERROR_CTRL_CHAR:
		            $err[ 'discription' ] = ' - Unexpected control character found';
		        break;
		        case JSON_ERROR_SYNTAX:
		            $err[ 'discription' ] = ' - Syntax error, malformed JSON';
		        break;
		        case JSON_ERROR_UTF8:
		            $err[ 'discription' ] = ' - Malformed UTF-8 characters, possibly incorrectly encoded';
		        break;
		        default:
		            $err[ 'discription' ] = ' - Unknown error';
		        break;
		}
		$str = json_encode($err);
		errLog( "JSON CONVERT ERROR\t". $err[ 'discription' ] , true );
	}
	echo $str;
	errLog( json_encode($str) , true );
}
function getDBPath( $dbId ){
	$ret = \CC\FILE::USRDB;
	return mb_ereg_replace('\$ID\$', $dbId , $ret); 
}
function getDelDBPath( $dbId ){
	$ret = \CC\FILE::DELDB;
	$ret = mb_ereg_replace('\$ID\$', $dbId , $ret); 
	return mb_ereg_replace('\$DATE\$', date('YmdHis') , $ret); 
}
function getExpDBPath( $dbId ){
	$ret = \CC\FILE::EXPDB;
	$ret = mb_ereg_replace('\$ID\$', $dbId , $ret); 
	return mb_ereg_replace('\$DATE\$', date('YmdHis') , $ret); 
}
function getExpCSVPath( $dbId, $tblId ){
	$ret = \CC\FILE::EXPCSV;
	$ret = mb_ereg_replace('\$ID\$', $dbId , $ret); 
	$ret = mb_ereg_replace('\$TID\$', $tblId , $ret); 
	return mb_ereg_replace('\$DATE\$', date('YmdHis') , $ret); 
}
