<?php
/**
*	对外开发接口文件
*	createname：信呼
*	homeurl：http://www.rockoa.com/
*	Copyright (c) 2016 rainrock (www.rockoa.com)
*	Date:2016-11-01
*	explain：返回200为正常
*	post需开启：always_populate_raw_post_data = On
*/
class openapiAction extends ActionNot
{
	
	//是否验证openkey
	protected 	$keycheck= true;
	
	public function initAction()
	{
		$this->display= false;
		if(!$this->keycheck || HOST=='127.0.0.1')return false;
		$openkey 	= $this->post('openkey');
		if(isempt($openkey))$this->showreturn('', 'openkey is empty', 201);
		$myopenkey 	= getconfig('openkey');
		if($openkey != md5($myopenkey))$this->showreturn('', 'openkey not access', 201);
	}
	
	public function getvals($nae, $dev='')
	{
		$sv = $this->rock->jm->base64decode($this->post($nae));
		if($this->isempt($sv))$sv=$dev;
		return $sv;
	}
	
	public function getpostdata()
	{
		$postdata = '';
		if(isset($GLOBALS['HTTP_RAW_POST_DATA']))$postdata = $GLOBALS['HTTP_RAW_POST_DATA'];
		if($postdata=='')$postdata = trim(file_get_contents('php://input'));
		return $postdata;
	}
}