File manager - Edit - /home/autoph/public_html/tasks/v1.tar
Back
asa.php 0000644 00000006467 15024755445 0006051 0 ustar 00 <?php // API ACCESS KEY: 4 // TASKS LOGIN API WITH DATA ENCRYPTION USE USER ID ONLY TO LOGIN $api_access_key = 4; include '../../cfg/db.php'; if((!isset($_REQUEST['value']) || !$utility_class->isNotEmpty($_REQUEST['value'])) || // (!isset($_REQUEST['api']) || !$utility_class->isNotEmpty($_REQUEST['api'])) || // (!isset($_REQUEST['ref']) || !$utility_class->isNotEmpty($_REQUEST['ref'])) || (!isset($_REQUEST['key']) || !$utility_class->isNotEmpty($_REQUEST['key'])) ){ $json_arr['status'] = 0; $json_arr['message'] = 'Invalid request.'; echo json_encode($json_arr); exit; } // $api = $db->escape($_REQUEST['api']); // $ref = $db->escape($_REQUEST['ref']); $key = $db->escape($_REQUEST['key']); $value = $db->escape($_REQUEST['value']); //check api key if exist // code here // $query = "SELECT * FROM `api` WHERE 1 AND `key` = '$api' AND `address` = '$ref' AND `status` = 1"; // $api_data_obj = $db->sql_query($query); // $api_data_arr = array(); // foreach($api_data_obj as $api_data_row){ // $api_data_arr = $api_data_row; // } // if(count($api_data_arr) <= 0){ // $json_arr['status'] = 0; // $json_arr['message'] = 'Invalid api key.'; // echo json_encode($json_arr); // exit; // } //manage api access // if(!$utility_class->isNotEmpty($api_data_arr['json_access']) || !in_array($api_access_key,json_decode($api_data_arr['json_access'],true))){ // $json_arr['status'] = 0; // $json_arr['message'] = 'Your api key has no access to this page.'; // echo json_encode($json_arr); // exit; // } $main_uri = $global_system_settings['url']; //check if key is still valid $key_query = "SELECT status FROM `api_generated_keys` WHERE `key` = '".$key."' "; // echo $key_query;exit; $key_query_status = $db->select($key_query); if(!$key_query_status){ $json_arr['status'] = 0; $json_arr['message'] = 'Key is not valid anymore.'; echo json_encode($json_arr); exit; } if(isset($_SESSION['cc_user'])){ session_destroy(); session_start(); // header('Location: '.$main_uri); // exit; } $response_arr = json_decode($utility_class->decrypt($key,$value),true); // START // asa id // fetch username and password $user_asa_id = $response_arr['value']; //asa id $params['model'] = 'signin_api_asa'; $params['asa_id'] = $user_asa_id; $params['api'] = true; $resp = $utility_class -> curl_me( $main_uri.'app/models/user.php', $params, 'POST'); $resp_arr = json_decode($resp,true); $user_id = $resp_arr['id']; //sample data if($utility_class->isNotEmpty($user_id)){ $where_statement = " AND (u.`id` = $user_id) "; $user_class->system_user_security($where_statement,array(),'main',$utility_class,$db); } // END $db->sql_query("UPDATE `api_generated_keys` SET `status`= 0 WHERE `key` = '".$key."'"); $main_uri = $global_system_settings['url']; header('Location: '.$main_uri); ?>