null]; protected function _execRedirection() { if (Qs_Application::getConfig('cms')->hasRedirection) { $obj = new App_Redirection_Obj(); if (($redirect = $obj->getRedirect(CURRENT_PAGE))) { Qs_Http::redirect(BASE_URL_LANGUAGE . '/' . $redirect['destination'], $redirect['status']); exit; } } return false; } protected function _getRefererMode() { static $mode = null; if (null === $mode) { $referer = Qs_Array::get($_SERVER, 'HTTP_REFERER'); if (empty($referer)) { $mode = self::MODE_EMPTY; } else if (Qs_Request::isOwnUrl($referer)) { $mode = self::MODE_OWN; } else { $mode = self::MODE_ALIEN; } } return $mode; } protected function _logNotFound() { $data = $this->_collectData(); $refererMode = $this->_getRefererMode(); $logMode = (int) $this->getConfig('logMode'); if ($refererMode === ($refererMode & $logMode)) { $this->_getDataObj()->insert($data); } $notifyMode = (int) $this->getConfig('notifyMode'); if ($refererMode === ($refererMode & $notifyMode)) { $mailData = $this->_getMailData($data); $this->_sendNotifyEmails($mailData); } $message = 'File does not exist: "' . Qs_Request::getUrl() . '" "' . $data['userAgent'] . '" ' . $data['ipAddress']; Qs_Debug::logStdError($message); return $this; } protected function _collectData() { $data = []; $data['modeId'] = $this->_getRefererMode(); $data['isAjax'] = (Qs_Request::isXmlHttpRequest()) ? 'y' : 'n'; $data['request'] = Qs_Array::get($_SERVER, 'REQUEST_URI', ''); $data['referer'] = Qs_Array::get($_SERVER, 'HTTP_REFERER', ''); $data['userAgent'] = Qs_Array::get($_SERVER, 'HTTP_USER_AGENT', ''); $data['ipAddress'] = Qs_Array::get( $_SERVER, 'REMOTE_ADDR', Qs_Array::get($_SERVER, 'HTTP_X_FORWARDED_FOR', '') ); return $data; } protected function _getMailData($data) { $mailData = $data; $mailData['mode'] = $this->_getDataObj()->getNotFoundModeTitle($data['modeId']); $mailData['isAjax'] = ('y' === $data['isAjax']) ? 'Yes' : 'No'; $mailData['viewLink'] = BASE_URL . '/' . Qs_SiteMap::getAliasByItem('NotFound_Admin'); $mailData = array_map('htmlspecialchars', $mailData); return $mailData; } protected function _sendNotifyEmails($data) { $emails = $this->getConfigArray('notifyEmails'); if (!empty($emails) && is_array($emails)) { $settingsEmails = App_Settings_Obj::get('notFoundNotifyEmails', 'parseEmails'); if (!empty($settingsEmails) && is_array($settingsEmails)) { $emails = array_merge($emails, $settingsEmails); $emails = array_unique($emails); } } else { return $this; } $template = new Qs_Template(); $template->addConstantDataSource(); $template->addGlobalsDataSource(); $template->addArrayDataSource($data); $emailConfig = $this->getConfigArray('email'); if (empty($emailConfig['body'])) { return $this; } $subject = $template->render(isset($emailConfig['subject']) ? $emailConfig['subject'] : ''); $body = $template->render($emailConfig['body']); $mail = new Qs_Mail(); $mail->setFrom(App_Settings_Obj::get('siteFrom')); $mail->setSubject($subject); $mail->setHtml($body, null, WWW_PATH); foreach ($emails as $email) { $mail->addTo($email); } return $mail->send(); } public function exec() { $this->_execRedirection(); $this->_logNotFound(); header('HTTP/1.0 404 Not Found'); if (!Qs_Request::isXmlHttpRequest()) { $this->_options['alias'] = CURRENT_PAGE; $this->_doc->assign('item', new Qs_Doc_Item($this->_options)); $this->_doc->sendHeaders(); echo $this->_doc->fetch($this->getTemplate('view.tpl')); } exit; } }