0) { array_unshift($poppedFolders, array_pop($parentFolders)); } if (count($parentFolders) == 0) { self::exitWithError( WebPConvertCloudService::ERROR_SERVER_SETUP, 'wpc-config.yaml not found in any parent folders.' ); } $configFilePath = implode('/', $parentFolders) . '/wpc-config.yaml'; try { $options = \Spyc::YAMLLoad($configFilePath); } catch (\Exception $e) { self::exitWithError(WebPConvertCloudService::ERROR_SERVER_SETUP, 'Error parsing wpc-config.yaml.'); } }*/ public static function exitWithError($errorCode, $msg) { $returnObject = [ 'success' => 0, 'errorCode' => $errorCode, 'errorMessage' => $msg, ]; echo json_encode($returnObject); exit; } public static function handleRequest($options) { //$this->options = static::loadConfig(); if (!isset($options)) { self::exitWithError(self::ERROR_SERVER_SETUP, 'No options was supplied'); } $action = (isset($_POST['action']) ? $_POST['action'] : 'convert'); // Handle actions that does not require access check switch ($action) { case 'api-version': echo '2'; exit; } AccessCheck::runAccessChecks($options); // Handle actions that requires access check switch ($action) { case 'check-access': echo "You have access!\n"; break; case 'convert': Serve::serve($options); break; } } }