41 lines
702 B
PHP
41 lines
702 B
PHP
|
<?php
|
||
|
|
||
|
require_once __DIR__.'/../../include/php/const';
|
||
|
|
||
|
function api_deploy(){
|
||
|
|
||
|
/* [1] Fetch api response
|
||
|
=========================================================*/
|
||
|
/* (1) Try to read response */
|
||
|
$file_r = @file_get_contents(TMP_DIR.'/api.response');
|
||
|
|
||
|
/* (2) Check response */
|
||
|
if( $file_r === false )
|
||
|
return 127;
|
||
|
|
||
|
/* (3) Try to parse response */
|
||
|
$arr_r = json_decode($file_r, true);
|
||
|
|
||
|
/* (4) Check parse error */
|
||
|
if( is_null($arr_r) )
|
||
|
return 127;
|
||
|
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
/* [1] Check $1 argument
|
||
|
=========================================================*/
|
||
|
if( $argc < 2 || !in_array($argv[1], 'init', 'sync' ){
|
||
|
echo 127;
|
||
|
die();
|
||
|
}
|
||
|
|
||
|
|
||
|
echo api_deploy($argv[1]);
|
||
|
|
||
|
|
||
|
|
||
|
?>
|