Загрузка агентов из файла
@return RequestResponse
489936
public function actionLoad()
    {
        $rr = new RequestResponse();
        if ($rr->isRequestAjaxPost()) {
            \Yii::$app->cmsAgent->loadAgents();
            $rr->message = \Yii::t('skeeks/agent', 'Agents have been updated successfully');
            $rr->success = true;
            return $rr;
        }
    }
463014
public function getRequest()
    {
        if (is_null($this->request)) {
            $this->setRequest(app()->refresh('request', $this, 'setRequest'));
        }

        return $this->request;
    }
1030847
public function handler(): Response
    {
        $attachment = $this->request->files->get('attachment');
        if (!$attachment) {
            throw new HttpValidationException([
                'attachment' => [
                    'attachment field has to be a file'
                ]
            ]);
        }
        $date = date('Ymd', time());
        $directory = app()->getStoragePath() . '/public/' . $date;
        $filename = ShortUuid::uuid4() . '.' . $attachment->guessExtension();
        $attachment->move($directory, $filename);
        $this->log('info', 'Upload attachment [' . $filename . ']');
        return response([
            'url' => '/storage/' . $date . '/' . $filename,
        ]);
    }
136845
public function getResponse()
    {
        if ($this->response === null and $this->isExecuted()) {
            $this->response = Response::forge($this);
        }

        return $this->response;
    }
1258851
public function actionIndex()
    {
        $this->requirePostRequest();
        $request = Craft::$app->getRequest();
        $plugin = Plugin::getInstance();
        $settings = $plugin->getSettings();

        $submission = new Submission();
        $submission->fromEmail = $request->getBodyParam('fromEmail');
        $submission->fromName = $request->getBodyParam('fromName');
        $submission->subject = $request->getBodyParam('subject');

        $message = $request->getBodyParam('message');
        if (is_array($message)) {
            $submission->message = array_filter($message, function($value) {
                return $value !== '';
            });
        } else {
            $submission->message = $message;
        }

        if ($settings->allowAttachments && isset($_FILES['attachment']) && isset($_FILES['attachment']['name'])) {
            if (is_array($_FILES['attachment']['name'])) {
                $submission->attachment = UploadedFile::getInstancesByName('attachment');
            } else {
                $submission->attachment = [UploadedFile::getInstanceByName('attachment')];
            }
        }

        if (!$plugin->getMailer()->send($submission)) {
            if ($request->getAcceptsJson()) {
                return $this->asJson(['errors' => $submission->getErrors()]);
            }

            Craft::$app->getSession()->setError(Craft::t('contact-form', 'There was a problem with your submission, please check the form and try again!'));
            Craft::$app->getUrlManager()->setRouteParams([
                'variables' => ['message' => $submission]
            ]);

            return null;
        }

        if ($request->getAcceptsJson()) {
            return $this->asJson(['success' => true]);
        }

        Craft::$app->getSession()->setNotice($settings->successFlashMessage);
        return $this->redirectToPostedUrl($submission);
    }
870112
public function actionRegisterByEmail()
    {
        if (!\Yii::$app->user->isGuest) {
            return $this->goHome();
        }

        $rr = new RequestResponse();
        $model = new SignupForm();

        $model->scenario = SignupForm::SCENARION_ONLYEMAIL;


        //Запрос на валидацию ajax формы
        if ($rr->isRequestOnValidateAjaxForm()) {
            return $rr->ajaxValidateForm($model);
        }
        //Запрос ajax post
        if ($rr->isRequestAjaxPost()) {

            $t = \Yii::$app->db->beginTransaction();

            try {

                if ($model->load(\Yii::$app->request->post()) && $registeredUser = $model->signup()) {

                    $t->commit();

                    $rr->success = true;
                    $rr->message = 'Для дальнейших действий, проверьте вашу почту.';

                    return $rr;

                } else {
                    $rr->message = 'Не удалось зарегистрироваться';
                }

            } catch (\Exception $e) {
                $t->rollBack();
                throw $e;
            }


            return (array)$rr;

        }

        return $this->render('register', [
            'model' => $model,
        ]);
    }
591006
public function methodNotAllowed(): Response
    {
        $this->response->setStatus(405);
        $this->response->setBody('<html><title>405 Method not allowed</title>405 Method not allowed</html>');
        return $this->response;
    }
593735
public function createRequest()
    {
        if ($this->request == null){
            $this->request = Request::fromPhpContext($this);
        }

        return $this->request;
    }
820299
public function actionCanEdit(): Response
    {
        $this->requireAcceptsJson();
        $this->requirePostRequest();

        $assetId = Craft::$app->getRequest()->getRequiredBodyParam('assetId');
        $asset = Asset::find()->id($assetId)->one();

        if (!$asset) {
            return $this->asJson([
                'success' => false
            ]);
        }

        /** @var Volume $volume */
        $volume = $asset->getVolume();
        $user = Craft::$app->getUser()->getIdentity();

        return $this->asJson([
            'success' => (
                $user->can('saveAssetInVolume:' . $volume->uid) &&
                $user->can('deleteFilesAndFoldersInVolume:' . $volume->uid)
            ),
        ]);
    }
758145
public function getResponse()
    {
        $curl = curl_init();

        $this->addParameters()->addHeaders();
        $this->options[CURLOPT_RETURNTRANSFER] = true;
        curl_setopt_array($curl, $this->options);

        $response = curl_exec($curl);

        $this->meta = array(
            'info'             => curl_getinfo($curl, CURLINFO_HTTP_CODE),
            'error_message'    => curl_errno($curl),
            'error_code'    => curl_error($curl));

        curl_close($curl);
        unset($curl);

        return $response;
    }
987364
public static function get() {
		
		$req = new static();
		
		$post = \file_get_contents('php://input');
		
		if($post !== false){
			$obj = Json::deserialise($post);
			if($obj !== null){
				$req->_Obj = $obj;
			}
		}
		
		return $req;
		
	}
800827
public function sendRequest()
    {
        try {
            if (mb_strlen($this->url) >= 9) {
                $response       = $this->useFileGetContents();
                $this->response = $response;

                return $response;
            }
        }
        catch (Exception $e) {
            $message = "Error: " . __CLASS__ . ": Please make sure to set a URL to fetch - Line: " . $e->getLine() . ' - Msg: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return $message;
        }

        return NULL;
    }
1089269
function response()
    {
        if (!$this->response) {
            $settings = new DataParseResponsePhp;
            $response = new HttpResponse(
                new BuildHttpResponse( BuildHttpResponse::parseWith($settings) )
            );

            $this->response = $response;
        }

        return $this->response;
    }
671231
public function uploadAction()
    {
        $request = $this
            ->requestStack
            ->getCurrentRequest();

        /**
         * @var UploadedFile $file
         */
        $file = $request
            ->files
            ->get($this->uploadFieldName);

        if (!($file instanceof UploadedFile)) {
            return new JsonResponse([
                'status' => 'ko',
                'response' => [
                    'message' => 'Image not found',
                ],
            ]);
        }

        try {
            $image = $this
                ->imageUploader
                ->uploadImage($file);

            $routes = $this
                ->router
                ->getRouteCollection();

            $response = [
                'status' => 'ok',
                'response' => [
                    'id' => $image->getId(),
                    'extension' => $image->getExtension(),
                    'routes' => [
                        'view' => $routes
                            ->get($this->viewImageRouteName)
                            ->getPath(),
                        'resize' => $routes
                            ->get($this->resizeImageRouteName)
                            ->getPath(),
                    ],
                ],
            ];
        } catch (Exception $exception) {
            $response = [
                'status' => 'ko',
                'response' => [
                    'message' => $exception->getMessage(),
                ],
            ];
        }

        return new JsonResponse($response);
    }
974929
public function getResponse()
    {
        $this->response = new ResponseDocument();
        $this->response->addElement("responseDate", $this->toUtcDateTime(new \DateTime()));
        $requestNode = $this->response->createElement("request", $this->repository->getBaseUrl());
        $this->response->getDocument()->documentElement->appendChild($requestNode);

        try {
            $this->checkVerb();
            $verbOutput = $this->doVerb();

            // we are sure now that all request variables are correct otherwise an error would have been thrown
            foreach ($this->params as $k => $v) {
                $requestNode->setAttribute($k, $v);
            }

            // the element is only added when everything went fine, otherwise we would add error node(s) in the catch
            // block below
            $this->response->getDocument()->documentElement->appendChild($verbOutput);

            // Shift the records from the records stack and add them to the DOM tree
            // Records proper are always stored in the 'metadata' node
            foreach ($this->response->getDocument()->getElementsByTagName('metadata') as $item) {
                $record = array_shift($this->records);
                $node = $this->response->getDocument()->importNode($record->documentElement, true);
                $item->appendChild($node);
            }
        } catch (MultipleExceptions $errors) {
            //multiple errors happened add all of the to the response
            foreach ($errors as $error) {
                $this->response->addError($error);
            }
        } catch (\Exception $error) {
            //add this error to the response
            if ($error instanceof Exception) {
                $this->response->addError($error);
            } else {
                $this->response->addError(new Exception($error->getMessage()));
            }
        }

        return $this->response->getResponse();
    }
118315
public function requestAction(Request $request)
    {
        $form = $this
            ->createForm(new UserForgotPassType())
            ->handleRequest($request)
        ;

        $obj = $form->getData();

        $user = $this->getDoctrine()->getRepository('FOMUserBundle:User')->findOneByUsername($obj['search']);
        if ($user === null) {
            $user = $this->getDoctrine()->getRepository('FOMUserBundle:User')->findOneByEmail($obj['search']);
        }

        if (!$user) {
            $form->addError(new FormError($this->get("templating")->render(
                'FOMUserBundle:Password:request-error-nosuchuser.html.twig',
                array("search" => $obj))));
            return array('form' => $form->createView());
        } elseif ($user->getRegistrationToken()) {
            $form->addError(new FormError($this->get("templating")->render(
                'FOMUserBundle:Password:request-error-userinactive.html.twig', array("user" => $user))));
            return array(
                'user' => $user,
                'form' => $form->createView());
        }

        $this->setResetToken($user);

        return $this->redirect($this->generateUrl('fom_user_password_send'));
    }
840081
function request() {
        $url = $this->url.$this->endpoint;
        
        $options = array(
            'http_errors' => false,
            'headers' => array(
                'User-Agent' => 'DiscordBot (https://github.com/CharlotteDunois/Yasmin, '.\CharlotteDunois\Yasmin\Client::VERSION.')'
            )
        );
        
        if(!empty($this->options['auth'])) {
            $options['headers']['Authorization'] = $this->options['auth'];
        } elseif(empty($this->options['noAuth']) && !empty($this->api->client->token)) {
            $options['headers']['Authorization'] = 'Bot '.$this->api->client->token;
        }
        
        if(!empty($this->options['files']) && \is_array($this->options['files'])) {
            $options['multipart'] = array();
            
            foreach($this->options['files'] as $file) {
                if(!isset($file['data']) && !isset($file['path'])) {
                    continue;
                }
                
                $field = ($file['field'] ?? 'file-'.\bin2hex(\random_bytes(3)));
                $options['multipart'][] = array(
                    'name' => $field,
                    'contents' => (isset($file['data']) ? $file['data'] : \fopen($file['path'], 'r')),
                    'filename' => (isset($file['name']) ? $file['name'] : (isset($file['path']) ? \basename($file['path']) : $field.'.jpg'))
                );
            }
            
            if(!empty($this->options['data'])) {
                $options['multipart'][] = array(
                    'name' => 'payload_json',
                    'contents' => \json_encode($this->options['data'], self::$jsonOptions)
                );
            }
        } elseif(!empty($this->options['data'])) {
            $options['json'] = $this->options['data'];
        }
        
        if(!empty($this->options['querystring'])) {
            $options['query'] = \http_build_query($this->options['querystring'], '', '&', \PHP_QUERY_RFC3986);
        }
        
        if(!empty($this->options['auditLogReason'])) {
            $options['headers']['X-Audit-Log-Reason'] = \rawurlencode(\trim($this->options['auditLogReason']));
        }
        
        $request = new \RingCentral\Psr7\Request($this->method, $url);
        $request->requestOptions = $options;
        
        return $request;
    }