Восстановлеине пароля
@return string|Response
178604
public function actionForget()
    {
        $rr = new RequestResponse();
        $model = new PasswordResetRequestFormEmailOrLogin();
        //Не админка
        $model->isAdmin = false;

        //Запрос на валидацию ajax формы
        if ($rr->isRequestOnValidateAjaxForm()) {
            return $rr->ajaxValidateForm($model);
        }
        //Запрос ajax post
        if ($rr->isRequestAjaxPost()) {
            if ($model->load(\Yii::$app->request->post()) && $model->sendEmail()) {
                $rr->success = true;
                $rr->message = 'Проверьте ваш email, дальнейшие инструкции мы отправили туда';
            } else {
                $rr->message = 'Не удалось выполнить запрос на восстановление пароля';
            }

            return (array)$rr;

        } else {
            if (\Yii::$app->request->isPost) {
                if ($model->load(\Yii::$app->request->post()) && $model->sendEmail()) {
                    if ($ref = UrlHelper::getCurrent()->getRef()) {
                        return $this->redirect($ref);
                    } else {
                        return $this->goBack();
                    }
                }
            }
        }

        return $this->render('forget', [
            'model' => $model,
        ]);
    }
875675
public function javascript()
    {
        $scriptContent = file_get_contents($this->pagseguro->getUrl()['javascript']);

        return response()->make($scriptContent, '200')
            ->header('Content-Type', 'text/javascript');
    }
721679
public function indexAction()
    {
        $body = '';
        $body .= '<a href="'.$this->generateUrl('phlexible_status_user_context').'">Context</a><br />';
        $body .= '<a href="'.$this->generateUrl('phlexible_status_user_session').'">Session</a>';

        return new Response($body);
    }
1103637
public function handler(): Response
    {
        $logoFile = $this->request->files->get('logo');
        $filename = ShortUuid::uuid4() . '.' . $logoFile->guessExtension();
        $directory = app()->getStoragePath() . '/public';
        $logoFile->move($directory, $filename);
        $config = Config::findBy(['key' => 'logo']);
        $config->value('/storage/' . $filename);
        $config->save();
        $this->log('info', 'Upload config.logo to [' . $config->getValue() . ']');
        return response();
    }
1194476
protected function getResponse()
    {
        if ($this->response === null) {
            $this->response = $this->client->send($this->request);
        }

        return $this->response;
    }
587030
public function parse()
	{
		$matches = array();

		// строка вида {env._SERVER.LC_NAME}
		if (preg_match_all('/\{env\.([\w\.]+)\}/im', $this->record->formatted, $macrosList) > 0)
		{
			foreach ($macrosList[1] as $match)
			{
				$parts = explode(".", $match);
				$array = @$GLOBALS[$parts[0]];
				array_shift($parts);
				$val = $array;

				foreach ($parts as $i => $key)
				{
					if (is_array($val))
						$val = @$val[$key];
					else if (is_object($val))
						$val = $val->{$key};
				}

				if (is_array($val) || is_object($val))
					$val = print_r($val, 1);

				$this->record->formatted = str_replace("{env." . $match . "}", $val, $this->record->formatted);
			}
		}

		return $this->record;
	}
270451
private function fetchResponse()
    {
        $type = $this->settings['type'];

        if (strpos('|INSERT|UPDATE|DELETE|REPLACE|', $type)) {
            if ($this->settings['result'] === 'id') {
                return $this->lastInsertId;
            }

            return $this->rowCount;
        } elseif ($type === 'SELECT') {
            if ($this->settings['result'] !== 'rows') {
                return $this->provider->fetchResponse(
                    $this->response,
                    $this->settings['result']
                );
            }
            if (is_object($this->response)) {
                return $this->provider->rowCount($this->response);
            }
        }

        return true;
    }
342654
public function indexAction()
    {
        $visibilityService = $this->getVisibilityService();
        $options = $visibilityService->getOptions();

        $widgetId = $options->getWidgetId();
        if (! $widgetId) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('The widget identifier was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/layout')
                ->setStatusCode(303);
        }

        $widget = $this->deriveWidget($widgetId);
        if (empty($widget)) {
            return $this->getResponse();
        }
        if ($this->getRequest()->isPost()) {
            $event = $this->request->getPost('suboperation');
            if (! empty($event)) {
                $events = $this->getEventManager();
                $params = $this->getRequest()->getPost();
                $params['widget_id'] = $widget->getId();
                $result = $events->trigger($event, $this, $params);
                if ($result->last() instanceof Response) {
                    return $result->last();
                }
            }
        }

        $view = new ViewModel;
        $view->options = $options;
        $view->widget = $widget;

        $moduleOptions = $this->getModuleOptions();
        $view->config = $moduleOptions->getWidgetByName($widget->getName());

        $view->list = $visibilityService->getContentList();
        $visibilityService->saveOptions();

        return $view;
    }
925059
public function getResponse()
    {
        $this->execute();
        
        switch ($this->def['dataType']) {
            case 'array':
                $result = static::toArray();
                break;
            case 'object':
            case 'json':
                $result = static::toJson();
                break;
            default:
                $result = $this->getErrorString() ? : $this->responseText;
        }
        
        return $result;
    }
652213
public function getProcessedResponse()
    {
        $_documentClass = $this->_documentClass;
        $_edgeClass = $this->_edgeClass;

        $response = $this->getResponse();
        switch ($this->_type) {
            case 'first':
                $json             = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $options           = $this->getCursorOptions();
                    $options['_isNew'] = false;
                    $response          = $_documentClass::createFromArray($json['document'], $options);
                } else {
                    $response          = false;
                }
                break;
            case 'getdocument':
                $json              = $response->getJson();
                $options           = $this->getCursorOptions();
                $options['_isNew'] = false;
                $response          = $_documentClass::createFromArray($json, $options);
                break;
            case 'document':
                $json = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $id       = $json[$_documentClass::ENTRY_ID];
                    $response = $id;
                }
                break;
            case 'getedge':
                $json              = $response->getJson();
                $options           = $this->getCursorOptions();
                $options['_isNew'] = false;
                $response          = $_edgeClass::createFromArray($json, $options);
                break;
            case 'edge':
                $json = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $id       = $json[Edge::ENTRY_ID];
                    $response = $id;
                }
                break;
            case 'getedges':
                $json              = $response->getJson();
                $options           = $this->getCursorOptions();
                $options['_isNew'] = false;
                $response          = [];
                foreach ($json[EdgeHandler::ENTRY_EDGES] as $data) {
                    $response[] = $_edgeClass::createFromArray($data, $options);
                }
                break;
            case 'getcollection':
                $json     = $response->getJson();
                $response = Collection::createFromArray($json);
                break;
            case 'collection':
                $json = $response->getJson();
                if (!isset($json['error']) || $json['error'] === false) {
                    $id       = $json[Collection::ENTRY_ID];
                    $response = $id;
                }
                break;
            case 'cursor':
            case 'all':
            case 'by':
                $options          = $this->getCursorOptions();
                $options['isNew'] = false;

                $options  = array_merge(['_documentClass' => $this->_documentClass], $options);
                $response = new Cursor($this->_batch->getConnection(), $response->getJson(), $options);
                break;
            case 'remove':
                $json     = $response->getJson();
                $response = [
                    'removed' => $json['removed'],
                    'ignored' => $json['ignored']
                ];
                break;
                
            default:
                throw new ClientException('Could not determine response data type.');
                break;
        }

        return $response;
    }
182644
private function actionUpdate()
    {
        $oldName = arg('update');
        $newName = arg('name');
        $forms = $this->plugin->getForms();
        if ($oldName == $newName || $forms->get($newName) === false)
        {
            $forms->update($oldName, arg('code'), arg('title'));

            $url = arg('submitURL');
            if ($oldName != $newName)
            {
                $forms->rename($oldName, $newName);
                $url = str_replace('edit=' . $oldName, 'edit=' . $newName, $url);
            }
            HTTP::redirect($url);
        }
        ErrorMessage('Форма с таким именем уже есть! Укажите другое имя.');
        return $this->actionEditDialog($oldName);
    }
924269
public function actionChangePassword()
    {
        $model = $this->model;

        $modelForm = new PasswordChangeForm([
            'user' => $model,
        ]);

        $rr = new RequestResponse();

        if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
            return $rr->ajaxValidateForm($modelForm);
        }


        if ($modelForm->load(\Yii::$app->request->post()) && $modelForm->changePassword()) {
            \Yii::$app->getSession()->setFlash('success', 'Успешно сохранено');
        } else {
            if (\Yii::$app->request->isPost) {
                \Yii::$app->getSession()->setFlash('error', 'Не удалось изменить пароль');
            }
        }

        return $this->render($this->action->id, [
            'model' => $modelForm,
        ]);
    }
740830
protected function respond()
    {
        $response = [];

        if (!empty($this->meta)) {
            $response['meta'] = $this->meta;
        }

        $response['data'] = $this->data;

        if ($this->data instanceof Arrayable) {
            $response['data'] = $this->data->toArray();
        }

        return Response::json($response, $this->statusCode, $this->headers);
    }
1027774
public function indexAction()
    {
        if (!$this->rcmUserService->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        $this->layout()->setTemplate('layout/blank');

        $view = new ViewModel();
        $view->setVariable(
            'siteSettingsSectionDefinitions',
            $this->getSettingsSectionDefinitions->__invoke()
        );

        return $view;
    }
471052
protected function getHostName()
    {
        // Сначала проверьте наличие прокси-сервера
        $header = $this->getHeader('X_FORWARDED_HOST');
        if ($header && $this->isValidForwardedHost($header)) {
            $elements = explode(',', $header);
            $host = $elements[count($elements) - 1];
        } elseif (!$host = $this->getHeader('HOST')) {
            if (!$host = $this->getServerVar('SERVER_NAME')) {
                $host = $this->getServerVar('SERVER_ADDR');
            }
        }

        // обрезать и удалять номер порта с хоста
        // host в нижнем регистре согласно RFC 952/2181
        $host = strtolower(preg_replace('/:\d+$/', '', trim($host)));

        //Номер порта
        $scheme = $this->getHttpScheme();
        $port = $this->getCurrentPort();
        $appendPort = ':' . $port;

        //Не добавляйте номер порта, если нормальный порт.
        if (($scheme == 'http' && $port == '80') || ($scheme == 'https' && $port == '443')) {
            $appendPort = '';
        }

        return $host . $appendPort;
    }
1096413
public function getResponse()
	{
		if (method_exists($this->controller, 'getResponse'))
		{
			/** @var HttpResponse $response */
			$response = $this->controller->getResponse();
		}
		else
		{
			$response = new HttpResponse;
		}

		$fp = fopen('php://output', 'w');
		ob_start();
		fputcsv($fp, $this->header, $this->delimiter, $this->enclosure);
		foreach ($this->content as $i => $item)
		{
			try
			{
				$fields = $this->callback ? call_user_func($this->callback, $item) : $item;
				if (!is_array($fields))
				{
					throw new \RuntimeException('CsvExport can only accept arrays, '. gettype($fields) .' provided at index '. $i .'. Either use arrays when setting the records or use a callback to convert each record into an array.');
				}
				fputcsv($fp, $fields, $this->delimiter, $this->enclosure);
			}
			catch (\Exception $ex)
			{
				ob_end_clean();
				throw $ex;
			}
		}
		fclose($fp);
		$response->setContent(ob_get_clean());

		$response->getHeaders()->addHeaders(array(
			'Content-Type' => 'text/csv',
			'Content-Disposition' => 'attachment;filename="'. str_replace('"', '\\"', $this->name) .'.csv"',
		));

		return $response;
	}
623002
public function main()
    {
        $mainPageHTML = '';
        $dbMaterials = array();

        // Получим все материалы
        if (
        dbQuery('samsoncms\api\Material')
            ->join('user')
            ->cond('Active', 1)
            ->cond('Draft', 0)
            ->order_by('Created', 'DESC')
            ->cond('Name', "", dbRelation::NOT_EQUAL)
            ->limit(5)
            ->exec($dbMaterials)
        ) {
            // Render material rows
            $rowsHTML = '';
            foreach ($dbMaterials as $dbMaterial) {
                $rowsHTML .= $this->view('main/row')
                    ->set($dbMaterial, 'material')
                    ->set(isset($dbMaterial->onetoone['_user']) ? $dbMaterial->onetoone['_user'] : array(), 'user')
                    ->output();
            }

            for ($i = sizeof($dbMaterials); $i < 5; $i++) {
                $rowsHTML .= $this->view('main/row')->output();
            }

            // Render main template
            $mainPageHTML = $this->view('main/index')->set($rowsHTML, 'rows')->output();
        }

        // Return material block HTML on main page
        return $mainPageHTML;
    }