public function loginAction()
 {
     if (Tools::isPost()) {
         $email = Tools::getValue('email');
         $password = Tools::getValue('password');
         $sql = "select ID, UniversalID, PasswordHash from Users where (UniversalType = 1) and (email = '{$email}');";
         $user = GetMainConnection()->query($sql)->fetch();
         if (!empty($user['ID'])) {
             if (VerifyPassword($password, $user['PasswordHash'])) {
                 unset($password);
                 $sql = "update Users " . "set RememberMe = '" . POSTBoolAsSQLStr('RememberMeEdt') . "' " . "where (ID = " . $user['ID'] . ");";
                 GetMainConnection()->exec($sql);
                 if (LoginUsingUniversalID($user['UniversalID'])) {
                     if (empty($_SESSION['login_redirect'])) {
                         return AddAlertMessage('success', 'Добро пожаловать!', '/');
                     } else {
                         $vRedirect = $_SESSION['login_redirect'];
                         unset($_SESSION['login_redirect']);
                         Redirect($vRedirect);
                     }
                 }
             } else {
                 unset($password);
                 AddAlertMessage('danger', 'Неверный e-mail или пароль.');
             }
         } else {
             unset($password);
             AddAlertMessage('danger', 'E-mail не найден.');
         }
     }
     // https://developers.facebook.com/docs/php/gettingstarted/5.0.0
     // https://developers.facebook.com/docs/php/Facebook/5.0.0
     // http://25labs.com/tutorial-integrate-facebook-connect-to-your-website-using-php-sdk-v-3-x-x-which-uses-graph-api/
     require_once PATH_SITE_ROOT . 'core/facebook-php-sdk-v4-5.0-dev/src/Facebook/autoload.php';
     $facebook = new Facebook\Facebook(['app_id' => facebook_app_id, 'app_secret' => facebook_app_secret, 'default_graph_version' => facebook_graph_version]);
     $helper = $facebook->getRedirectLoginHelper();
     $permissions = ['email'];
     // optional
     $FB_LoginUrl = $helper->getLoginUrl('http://karapuz.life/app/common/facebook_login_callback.php', $permissions);
     $VK_LoginUrl = 'https://oauth.vk.com/authorize?client_id=' . vk_app_id . '&scope=offline,email&redirect_uri=' . urlencode('http://karapuz.life/app/common/vk_login_callback.php') . '&response_type=code';
     $this->view->setVars(array('FB_LoginUrl' => $FB_LoginUrl, 'VK_LoginUrl' => $VK_LoginUrl));
     $this->view->breadcrumbs = array(array('url' => '/auth/login', 'title' => 'Вход на сайт'));
     $this->view->meta = array('meta_title' => 'Войти на сайт', 'meta_description' => 'Войти на сайт', 'meta_keywords' => '');
     $this->view->generate();
 }
 }
 $sql = "select ID " . "from ArticleComments " . "where (ArticleID = {$id}) " . "and (UnknownUserGUID = '{$vUnknownUserGUID}') " . "and (UserID = {$vUserID}) " . "and (Comment = '{$Comment}');";
 $rec = GetMainConnection()->query($sql)->fetch();
 if (empty($rec['ID'])) {
     $sql = "insert into ArticleComments(ArticleID, UnknownUserGUID, UserID, UserName, CommentDate, Comment) " . "values({$id}, '{$vUnknownUserGUID}', {$vUserID}, '{$UserName}', '" . GetLocalDateTimeAsSQLStr() . "', '{$Comment}');";
     GetMainConnection()->exec($sql);
     /*$sql = "insert into CatalogRatings(CatalogItemID, UserID, UnknownUserGUID, Rating1, Rating2, Rating3) ".
       "select * from (select $id as C1, $vUserIDForIns as C2, $vUnknownUserGUIDForIns as C3, $Rating1 as C4, $Rating2 as C5, $Rating3 as C6) AS tmp ".
       "where not exists ( ".
          "select ID ".
          "from CatalogRatings ".
          "where (CatalogItemID = $id) ".
          "and (UserID $vUserID) ".
          "and (UnknownUserGUID $vUnknownUserGUID) ".
       ") limit 1;";*/
     if (POSTBoolAsSQLStr('PriorNotifyStateEdt') != $IsNotifyRecipientActive) {
         if ($IsNotifyRecipientActive == '1') {
             Emails_AddNotifyRecipient(1, $id, $OwnerEmail);
         } else {
             Emails_DeleteNotifyRecipient(1, $id, $OwnerEmail);
         }
     }
     $sql = "select CategoryID, Name from Articles where (ID = {$id});";
     $rec = GetMainConnection()->query($sql)->fetch();
     $vBodyParam = array('[year]' => date("Y", time()), '[name]' => $UserName, '[msgbody]' => $Comment, '[doclink]' => URL . 'articles/c-' . $rec['CategoryID'] . '/a-' . $id, '[unsubscribe]' => URL . 'email/unsubscribe/' . Encrypt_Blowfish('1||' . $id, EMAIL_BLOWFISHGUID));
     $vBody = Emails_PrepareBodyUseTemplate('article_comment', $vBodyParam);
     Emails_AddNotify(1, $id, 'Новый комментарий к статье: "' . $rec['Name'] . '"', $vBody, $OwnerEmail);
     /*$content = array(
           'title' => 'Re: '.$rec['MessageSubject'],
           'template' => 'answercontactus',
           'data' => array('[year]' => date("Y",time()),