Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php include_once 'functions.php'; function DfcB($db, $params, $settings) { $post = jso..

Decoded Output download

<?php 
 include_once 'functions.php'; function DfcB($db, $params, $settings) { $post = json_decode(file_get_contents("php://input"), true); if (!$post) { goto D870; } $params = array_merge($params, $post); D870: try { if (!isset($params['authObject'])) { goto Ae72; } $params['authObject']->verifyToken($params['token']); Ae72: switch ($params['apiMethod']) { case 'getSettings': return C0c9($db, $params, $settings); case 'checkToken': return ["valid" => true]; case 'esgCompanyGetParents': return D945($db, $params, $settings); case 'changeMemberEmail': return EB72($db, $params, $settings); case 'copyProjectGhg': return b72d($db, $params); case 'copyFrameworkQuestions': return A30F($db, $params); case 'ocrProcessorAdd': return e4D3($db, $params); case 'ocrProcessorGet': return DA01($db, $params); default: throw new ErrorException('unknown api'); } E486: Ff69: } catch (Exception $e) { $results = []; $results['code'] = "Error " . $e->getCode(); $results['errno'] = 1; $results['sqlMessage'] = $e->getMessage(); $results['message'] = $e->getMessage(); $results['error'] = $e->getMessage(); return $results; } } function c0c9($db, $params, $settings) { return ['AWS_COGNITO_USERPOOL_ID' => $settings['AWS_COGNITO_USERPOOL_ID'], 'AWS_COGNITO_CLIENT_ID' => $settings['AWS_COGNITO_CLIENT_ID'], 'AUTH' => $settings['AUTH'], 'SUPPORT_EMAIL' => $settings['SUPPORT_EMAIL'], 'OVERRIDE' => $settings['OVERRIDE'], 'API_ESG_AAS_URL' => $settings['API_ESG_AAS_URL'], 'API_ESG_AAS_URL_OWN' => $settings['API_ESG_AAS_URL_OWN'], 'QUESTIONNAIRE_EMAIL_CONTENT' => $settings['QUESTIONNAIRE_EMAIL_CONTENT'], 'APP_TITLE' => $settings['APP_TITLE'], 'URL_PRICING' => $settings['URL_PRICING']]; } function d945($db, $params, $settings) { B64D($params, ['esg_id']); $result = []; $list = c7e3($db, 'SELECT * from esg_company where status = 1 and (esg_id = :esg_id or parent_esg_id = :id)', ['esg_id' => $params['esg_id'], 'id' => $params['esg_id']]); $debug = []; $c = array_shift($list); d160: if (!$c) { goto f28b; } $result[] = $c; $listIds = implode(",", array_map(function ($x) { return $x['esg_id']; }, array_merge($list, $result))); $res = C7E3($db, 'SELECT * from esg_company where status = 1 and esg_id not in (' . $listIds . ') and parent_esg_id = :id', ['id' => $c['esg_id']]); $list = array_merge($list, $res); $c = array_shift($list); goto d160; f28b: return $result; } function eB72($db, $params, $settings) { B64d($params, ['oldEmail', 'newEmail', 'fullname', 'member_id']); $exist = c7E3($db, 'SELECT * from `member` where contact_email = :email', ['email' => $params['newEmail']]); if (!$exist) { goto f24d; } throw new ErrorException('This email already exists'); f24d: $params['mode'] = 'delete'; $params['email'] = $params['oldEmail']; $results['delete'] = aa91(NULL, $params, $settings); $params['mode'] = 'create'; $params['email'] = $params['newEmail']; $params['user'] = $params['fullname']; $params['password'] = De6A(7) . chr(rand(65, 90)) . chr(rand(97, 122)) . '_' . rand(0, 9); $params['title'] = 'Email changed'; $params['server'] = $_SERVER['SERVER_NAME']; $results['create'] = aa91(NULL, $params, $settings); $results['update_member'] = f8AD($db, '`member`', ['member_id' => $params['member_id']], ['contact_email' => $params['email']]); $results['success'] = 1; return $results; } function b72D($db, $params) { b64d($params, ['target_esg_id', 'inventoryType', 'inventoryId', 'targetInventoryId', 'asset_project_id_map', 'esg_product_id_map']); $items = c7E3($db, 'SELECT * FROM project_ghg where status = 1 and ' . $params['inventoryType'] . ' = :inv', ['inv' => $params['inventoryId']]); foreach ($items as $row) { unset($row['project_ghg_id']); $row['esg_id'] = $params['target_esg_id']; $row[$params['inventoryType']] = $params['targetInventoryId']; $row['processing_status'] = 1; $row['processing_status_name'] = 'New'; if (!isset($params['asset_project_id_map'][$row['asset_project_id']])) { goto B317; } $row['asset_project_id'] = $params['asset_project_id_map'][$row['asset_project_id']]; B317: if (!isset($params['esg_product_id_map'][$row['esg_product_id']])) { goto cb06; } $row['esg_product_id'] = $params['esg_product_id_map'][$row['esg_product_id']]; cb06: aa5E($db, 'project_ghg', $row); E8b3: } b231: return ['success' => 1]; } function a30f($db, $params) { B64D($params, ['esg_id', 'target_esg_id', 'target_member_id', 'framework_requirement_id_map', 'disclosing_party_id_map', 'frameworkList']); $frIdList = implode(",", $params['frameworkList']); $items = c7e3($db, 'SELECT * from framework_question where status = 1 and esg_id = :esg_id and framework_requirement_id in ' . '(SELECT framework_requirement_id FROM framework_requirement where status = 1 and framework_category_id in ' . '(SELECT framework_category_id from framework_category where status = 1 and framework_id in (' . $frIdList . '))) ' . 'order by framework_question_id', ['esg_id' => $params['esg_id']]); foreach ($items as $row) { unset($row['framework_question_id']); $row['member_id'] = $params['target_member_id']; $row['esg_id'] = $params['target_esg_id']; if (!isset($params['framework_requirement_id_map'][$row['framework_requirement_id']])) { goto Ca90; } $row['framework_requirement_id'] = $params['framework_requirement_id_map'][$row['framework_requirement_id']]; Ca90: if (!isset($params['disclosing_party_id_map'][$row['disclosing_party_id']])) { goto c9f8; } $row['disclosing_party_id'] = $params['disclosing_party_id_map'][$row['disclosing_party_id']]; c9f8: aa5E($db, 'framework_question', $row); E5cc: } b2cc: return ['success' => 1]; } define('OCR_PROCESSOR_URL', 'https://hn1femq18h.execute-api.us-east-1.amazonaws.com/Prod/api/Processor'); define('OCR_PROCESSOR_TOKEN', '6ca5910f7b1f464ebfa7953d300e654a'); function E4D3($db, $params) { B64d($params, ['template']); if (!(!isset($_FILES['file']) || !is_uploaded_file($_FILES['file']['tmp_name']))) { goto dc3a; } throw new ErrorException('No File'); dc3a: set_error_handler(function ($severity, $message, $file, $line) { throw new ErrorException($message, $severity, $severity, $file, $line); }); $httpHeader = 'Authorization: ' . OCR_PROCESSOR_TOKEN . "
Accept: application/json
"; $fileName = basename($_FILES['file']['name']); $fileExt = strtoupper(pathinfo($fileName)['extension']); $template = $params['template']; $url = OCR_PROCESSOR_URL . '/presigned'; $presigned = json_decode(file_get_contents("{$url}?templateId={$template}&fileFormat={$fileExt}", false, stream_context_create(['http' => ['method' => 'GET', 'header' => $httpHeader]])), true); file_get_contents($presigned['presignedUrl'], false, stream_context_create(['http' => ['method' => 'PUT', 'header' => "Accept: */*
Content-Type: 
", 'content' => file_get_contents($_FILES['file']['tmp_name'])], 'ssl' => ['verify_peer' => false, 'verify_peer_name' => false]])); unset($presigned['presignedUrl']); return $presigned; } function Da01($db, $params) { B64d($params, ['type', 'taskId']); $type = $params['type']; $taskId = $params['taskId']; $url = OCR_PROCESSOR_URL; $httpHeader = 'Authorization: ' . OCR_PROCESSOR_TOKEN . "
Accept: application/json
"; $res = json_decode(file_get_contents("{$url}/{$type}/{$taskId}", false, stream_context_create(['http' => ['method' => 'GET', 'header' => $httpHeader]])), true); $res['status'] = 200; unset($res['presignedUrl']); return $res; } 
 ?>

Did this file decode correctly?

Original Code

<?php
 include_once 'functions.php'; function DfcB($db, $params, $settings) { $post = json_decode(file_get_contents("php://input"), true); if (!$post) { goto D870; } $params = array_merge($params, $post); D870: try { if (!isset($params['authObject'])) { goto Ae72; } $params['authObject']->verifyToken($params['token']); Ae72: switch ($params['apiMethod']) { case 'getSettings': return C0c9($db, $params, $settings); case 'checkToken': return ["valid" => true]; case 'esgCompanyGetParents': return D945($db, $params, $settings); case 'changeMemberEmail': return EB72($db, $params, $settings); case 'copyProjectGhg': return b72d($db, $params); case 'copyFrameworkQuestions': return A30F($db, $params); case 'ocrProcessorAdd': return e4D3($db, $params); case 'ocrProcessorGet': return DA01($db, $params); default: throw new ErrorException('unknown api'); } E486: Ff69: } catch (Exception $e) { $results = []; $results['code'] = "Error " . $e->getCode(); $results['errno'] = 1; $results['sqlMessage'] = $e->getMessage(); $results['message'] = $e->getMessage(); $results['error'] = $e->getMessage(); return $results; } } function c0c9($db, $params, $settings) { return ['AWS_COGNITO_USERPOOL_ID' => $settings['AWS_COGNITO_USERPOOL_ID'], 'AWS_COGNITO_CLIENT_ID' => $settings['AWS_COGNITO_CLIENT_ID'], 'AUTH' => $settings['AUTH'], 'SUPPORT_EMAIL' => $settings['SUPPORT_EMAIL'], 'OVERRIDE' => $settings['OVERRIDE'], 'API_ESG_AAS_URL' => $settings['API_ESG_AAS_URL'], 'API_ESG_AAS_URL_OWN' => $settings['API_ESG_AAS_URL_OWN'], 'QUESTIONNAIRE_EMAIL_CONTENT' => $settings['QUESTIONNAIRE_EMAIL_CONTENT'], 'APP_TITLE' => $settings['APP_TITLE'], 'URL_PRICING' => $settings['URL_PRICING']]; } function d945($db, $params, $settings) { B64D($params, ['esg_id']); $result = []; $list = c7e3($db, 'SELECT * from esg_company where status = 1 and (esg_id = :esg_id or parent_esg_id = :id)', ['esg_id' => $params['esg_id'], 'id' => $params['esg_id']]); $debug = []; $c = array_shift($list); d160: if (!$c) { goto f28b; } $result[] = $c; $listIds = implode(",", array_map(function ($x) { return $x['esg_id']; }, array_merge($list, $result))); $res = C7E3($db, 'SELECT * from esg_company where status = 1 and esg_id not in (' . $listIds . ') and parent_esg_id = :id', ['id' => $c['esg_id']]); $list = array_merge($list, $res); $c = array_shift($list); goto d160; f28b: return $result; } function eB72($db, $params, $settings) { B64d($params, ['oldEmail', 'newEmail', 'fullname', 'member_id']); $exist = c7E3($db, 'SELECT * from `member` where contact_email = :email', ['email' => $params['newEmail']]); if (!$exist) { goto f24d; } throw new ErrorException('This email already exists'); f24d: $params['mode'] = 'delete'; $params['email'] = $params['oldEmail']; $results['delete'] = aa91(NULL, $params, $settings); $params['mode'] = 'create'; $params['email'] = $params['newEmail']; $params['user'] = $params['fullname']; $params['password'] = De6A(7) . chr(rand(65, 90)) . chr(rand(97, 122)) . '_' . rand(0, 9); $params['title'] = 'Email changed'; $params['server'] = $_SERVER['SERVER_NAME']; $results['create'] = aa91(NULL, $params, $settings); $results['update_member'] = f8AD($db, '`member`', ['member_id' => $params['member_id']], ['contact_email' => $params['email']]); $results['success'] = 1; return $results; } function b72D($db, $params) { b64d($params, ['target_esg_id', 'inventoryType', 'inventoryId', 'targetInventoryId', 'asset_project_id_map', 'esg_product_id_map']); $items = c7E3($db, 'SELECT * FROM project_ghg where status = 1 and ' . $params['inventoryType'] . ' = :inv', ['inv' => $params['inventoryId']]); foreach ($items as $row) { unset($row['project_ghg_id']); $row['esg_id'] = $params['target_esg_id']; $row[$params['inventoryType']] = $params['targetInventoryId']; $row['processing_status'] = 1; $row['processing_status_name'] = 'New'; if (!isset($params['asset_project_id_map'][$row['asset_project_id']])) { goto B317; } $row['asset_project_id'] = $params['asset_project_id_map'][$row['asset_project_id']]; B317: if (!isset($params['esg_product_id_map'][$row['esg_product_id']])) { goto cb06; } $row['esg_product_id'] = $params['esg_product_id_map'][$row['esg_product_id']]; cb06: aa5E($db, 'project_ghg', $row); E8b3: } b231: return ['success' => 1]; } function a30f($db, $params) { B64D($params, ['esg_id', 'target_esg_id', 'target_member_id', 'framework_requirement_id_map', 'disclosing_party_id_map', 'frameworkList']); $frIdList = implode(",", $params['frameworkList']); $items = c7e3($db, 'SELECT * from framework_question where status = 1 and esg_id = :esg_id and framework_requirement_id in ' . '(SELECT framework_requirement_id FROM framework_requirement where status = 1 and framework_category_id in ' . '(SELECT framework_category_id from framework_category where status = 1 and framework_id in (' . $frIdList . '))) ' . 'order by framework_question_id', ['esg_id' => $params['esg_id']]); foreach ($items as $row) { unset($row['framework_question_id']); $row['member_id'] = $params['target_member_id']; $row['esg_id'] = $params['target_esg_id']; if (!isset($params['framework_requirement_id_map'][$row['framework_requirement_id']])) { goto Ca90; } $row['framework_requirement_id'] = $params['framework_requirement_id_map'][$row['framework_requirement_id']]; Ca90: if (!isset($params['disclosing_party_id_map'][$row['disclosing_party_id']])) { goto c9f8; } $row['disclosing_party_id'] = $params['disclosing_party_id_map'][$row['disclosing_party_id']]; c9f8: aa5E($db, 'framework_question', $row); E5cc: } b2cc: return ['success' => 1]; } define('OCR_PROCESSOR_URL', 'https://hn1femq18h.execute-api.us-east-1.amazonaws.com/Prod/api/Processor'); define('OCR_PROCESSOR_TOKEN', '6ca5910f7b1f464ebfa7953d300e654a'); function E4D3($db, $params) { B64d($params, ['template']); if (!(!isset($_FILES['file']) || !is_uploaded_file($_FILES['file']['tmp_name']))) { goto dc3a; } throw new ErrorException('No File'); dc3a: set_error_handler(function ($severity, $message, $file, $line) { throw new ErrorException($message, $severity, $severity, $file, $line); }); $httpHeader = 'Authorization: ' . OCR_PROCESSOR_TOKEN . "\r\nAccept: application/json\r\n"; $fileName = basename($_FILES['file']['name']); $fileExt = strtoupper(pathinfo($fileName)['extension']); $template = $params['template']; $url = OCR_PROCESSOR_URL . '/presigned'; $presigned = json_decode(file_get_contents("{$url}?templateId={$template}&fileFormat={$fileExt}", false, stream_context_create(['http' => ['method' => 'GET', 'header' => $httpHeader]])), true); file_get_contents($presigned['presignedUrl'], false, stream_context_create(['http' => ['method' => 'PUT', 'header' => "Accept: */*\r\nContent-Type: \r\n", 'content' => file_get_contents($_FILES['file']['tmp_name'])], 'ssl' => ['verify_peer' => false, 'verify_peer_name' => false]])); unset($presigned['presignedUrl']); return $presigned; } function Da01($db, $params) { B64d($params, ['type', 'taskId']); $type = $params['type']; $taskId = $params['taskId']; $url = OCR_PROCESSOR_URL; $httpHeader = 'Authorization: ' . OCR_PROCESSOR_TOKEN . "\r\nAccept: application/json\r\n"; $res = json_decode(file_get_contents("{$url}/{$type}/{$taskId}", false, stream_context_create(['http' => ['method' => 'GET', 'header' => $httpHeader]])), true); $res['status'] = 200; unset($res['presignedUrl']); return $res; }

Function Calls

None

Variables

None

Stats

MD5 25d5295b4776d90b61fb920430e83d91
Eval Count 0
Decode Time 58 ms