示例#1
0
 /**
  * @copydoc DataSet::__construct
  */
 public function __construct($name, array $params = null)
 {
     if (!isset($params['state'])) {
         $params['state'] = E()->getDocument()->user->isAuthenticated() ? 'showLogoutForm' : 'showLoginForm';
     }
     parent::__construct($name, $params);
     $this->setTitle($this->translate('TXT_LOGIN_FORM'));
     $base = E()->getSiteManager()->getCurrentSite()->base;
     if (strpos($currDomain = E()->getSiteManager()->getCurrentSite()->host, Primitive::getConfigValue('site.domain')) === false) {
         $base = 'http://' . Primitive::getConfigValue('site.domain') . '/';
     }
     $this->setAction($base . 'auth.php' . (isset($_SERVER['HTTP_REFERER']) ? '' : '?return=' . (($return = $this->getParam('successAction')) ? $return : E()->getRequest()->getURI())), true);
 }
示例#2
0
 /**
  * Wrapper for Primitive::getConfigValue.
  * This is for the cases when database name is not set in the configurations. In this case the current database will be used.
  *
  * @return string
  */
 public static function getDatabase()
 {
     return Primitive::getConfigValue('forms.database', Primitive::getConfigValue('database.db'));
 }
示例#3
0
 public function __construct()
 {
     parent::__construct();
 }
示例#4
0
 /**
  * Building resulte XML Document
  */
 public function build()
 {
     //Если у нас не режим json
     $this->doc = new \DOMDocument('1.0', 'UTF-8');
     $dom_root = $this->doc->createElement('document');
     $dom_root->setAttribute('debug', $this->getConfigValue('site.debug'));
     $dom_root->setAttribute('editable', $this->isEditable());
     $this->setProperty('url', (string) $this->request->getURI());
     $this->doc->appendChild($dom_root);
     if (!isset($this->properties['title'])) {
         $this->setProperty('title', strip_tags($this->documentInfo['Name']));
     }
     $dom_documentProperties = $this->doc->createElement('properties');
     foreach ($this->properties as $propName => $propValue) {
         $dom_property = $this->doc->createElement('property', str_replace('&', '&', $propValue));
         $dom_property->setAttribute('name', $propName);
         if ($propName == 'title') {
             $dom_property->setAttribute('alt', $this->documentInfo['HtmlTitle']);
         }
         $dom_documentProperties->appendChild($dom_property);
     }
     $dom_root->appendChild($dom_documentProperties);
     //Дополнительные свойства, имеющие параметры
     $prop = $this->doc->createElement('property', $baseURL = E()->getSiteManager()->getCurrentSite()->base);
     $prop->setAttribute('name', 'base');
     $prop->setAttribute('static', $staticURL = $this->getConfigValue('site.static') ? $staticURL : $baseURL);
     $prop->setAttribute('media', ($mediaURL = $this->getConfigValue('site.media')) ? $mediaURL : $baseURL);
     $prop->setAttribute('resizer', ($resizerURL = $this->getConfigValue('site.resizer')) ? $resizerURL : E()->getSiteManager()->getDefaultSite()->base . 'resizer/');
     $prop->setAttribute('folder', E()->getSiteManager()->getCurrentSite()->folder);
     $prop->setAttribute('default', E()->getSiteManager()->getDefaultSite()->base);
     $prop->setAttribute('favicon', ($favicon = E()->getSiteManager()->getCurrentSite()->faviconFile) ? $favicon : E()->getSiteManager()->getDefaultSite()->faviconFile);
     $dom_documentProperties->appendChild($prop);
     $prop = $this->doc->createElement('property', $this->getLang());
     $prop->setAttribute('name', 'lang');
     $prop->setAttribute('abbr', $this->request->getLangSegment());
     $prop->setAttribute('default', E()->getLanguage()->getDefault());
     $prop->setAttribute('real_abbr', E()->getLanguage()->getAbbrByID($this->getLang()));
     $dom_documentProperties->appendChild($prop);
     if (($docVars = $this->getConfigValue('site.vars')) && is_array($docVars)) {
         $dom_documentVars = $this->doc->createElement('variables');
         foreach ($docVars as $varName => $varValue) {
             $var = $this->doc->createElement('var', $varValue);
             $var->setAttribute('name', strtoupper($varName));
             $dom_documentVars->appendChild($var);
         }
         $dom_root->appendChild($dom_documentVars);
     }
     if ($og = E()->getOGObject()->build()) {
         $dom_root->appendChild($this->doc->importNode($og, true));
     }
     unset($prop, $og);
     foreach ($this->componentManager as $component) {
         $componentResult = false;
         $dom_errors = false;
         try {
             if ($component->enabled() && $this->getRights() >= $component->getCurrentStateRights()) {
                 $componentResult = $component->build();
             }
         } catch (DummyException $dummyException) {
         }
         if (!empty($componentResult)) {
             try {
                 $componentResult = $this->doc->importNode($componentResult->documentElement, true);
             } catch (\Exception $e) {
                 //stop($e->getTraceAsString());
             }
             if ($dom_errors) {
                 $componentResult->insertBefore($dom_errors, $componentResult->firstChild);
             }
             $dom_root->appendChild($componentResult);
         } elseif ($dom_errors) {
             $dom_root->appendChild($dom_errors);
         }
     }
     if (!empty($this->translations)) {
         $dom_translations = $this->doc->createElement('translations');
         $dom_root->appendChild($dom_translations);
         foreach ($this->translations as $const => $componentName) {
             $dom_translation = $this->doc->createElement('translation', translate($const));
             $dom_translation->setAttribute('const', $const);
             if (!is_null($componentName)) {
                 $dom_translation->setAttribute('component', $componentName);
             }
             $dom_translations->appendChild($dom_translation);
         }
     }
     $jsLibs = Primitive::getConfigValue('site.js-lib');
     if (!isset($jsLibs['mootools'])) {
         $jsLibs['mootools'] = $staticURL . 'scripts/mootools.min.js';
     }
     if (!isset($jsLibs['jquery'])) {
         $jsLibs['jquery'] = 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js';
     }
     $dom_javascript = $this->doc->createElement('javascript');
     foreach ($jsLibs as $name => $path) {
         $dom_javascript->setAttribute($name, $path);
     }
     $dom_root->appendChild($dom_javascript);
     foreach ($this->js as $behavior) {
         $dom_javascript->appendChild($this->doc->importNode($behavior, true));
     }
     // построение списка подключаемых js библиотек в порядке зависимостей
     $jsMapFile = HTDOCS_DIR . '/system.jsmap.php';
     if (!file_exists($jsMapFile)) {
         throw new \RuntimeException('JS dependencies file ' . $jsMapFile . ' does\'nt exists');
     }
     $jsIncludes = [];
     $jsmap = (include $jsMapFile);
     $xpath = new \DOMXPath($this->doc);
     $nl = $xpath->query('//javascript/behavior');
     if ($nl->length) {
         foreach ($nl as $node) {
             $classPath = $node->getAttribute('path');
             if ($classPath && substr($classPath, -1) != '/') {
                 $classPath .= '/';
             }
             $cls = ($classPath ? $classPath : '') . $node->getAttribute('name');
             $this->createJavascriptDependencies([$cls], $jsmap, $jsIncludes);
         }
     }
     foreach ($jsIncludes as $js) {
         $dom_js_library = $this->doc->createElement('library');
         $dom_js_library->setAttribute('path', $js);
         $onlyName = explode('/', $js);
         $dom_js_library->setAttribute('name', array_pop($onlyName));
         $dom_javascript->appendChild($dom_js_library);
     }
 }
示例#5
0
                    $res = $vk->api('users.get', ['uids' => $vkUID, 'fields' => 'uid,first_name,last_name,photo']);
                    if (is_array($res['response'])) {
                        $vkUser = $res['response'][0];
                        $userInfo = ['u_name' => $vkUser['uid'] . '@vk.com', 'u_vkid' => $vkUser['uid'], 'u_password' => User::generatePassword(), 'u_fullname' => $vkUser['first_name'] . ' ' . $vkUser['last_name'], 'u_avatar_img' => $vkUser['photo']];
                        $user->create($userInfo);
                    } else {
                        throw new SystemException('TXT_CREATE_SOCIAL_USER_ERROR');
                    }
                }
                E()->UserSession->start($user->getID());
            }
        } catch (\Exception $e) {
            $response->addCookie(UserSession::FAILED_LOGIN_COOKIE_NAME, $e->getMessage(), time() + 60);
            goto escape;
        }
    } elseif ($gooAuth && ($appID = Primitive::getConfigValue('auth.goo.appID')) && ($secretKey = Primitive::getConfigValue('auth.goo.secretKey'))) {
        $goo = new \Energine\user\gears\GOOOAuth(['appId' => $appID, 'secret' => $secretKey]);
        try {
            if (!($user = User::getGOOUser($goo->user->id))) {
                //Если нет - создаем
                $user = new User();
                $userInfo = ['u_name' => $goo->user->email, 'u_gooid' => $goo->user->id, 'u_password' => User::generatePassword(), 'u_fullname' => $goo->user->name, 'u_avatar_img' => $goo->user->picture];
                $user->create($userInfo);
            }
            E()->UserSession->start($user->getID());
        } catch (Exception $e) {
            $response->addCookie(UserSession::FAILED_LOGIN_COOKIE_NAME, $e->getMessage(), time() + 60);
            goto escape;
        }
    }
}
示例#6
0
 /**
  * @param string $commentTable Table name with comments.
  * @param bool $isTree Are comments tree-like?
  */
 public function __construct($commentTable, $isTree = false)
 {
     $this->commentTable = $commentTable;
     $this->isTree = $isTree;
     parent::__construct();
 }
示例#7
0
 /**
  * Remove malicious and redundant HTML code.
  *
  * @param string $data Data.
  * @return string
  */
 public static function cleanupHTML($data)
 {
     $aggressive = Primitive::getConfigValue('site.aggressive_cleanup', false);
     //Если подключено расширение tidy
     if (function_exists('tidy_get_output') && $aggressive) {
         try {
             $tidy = new \tidy();
             $config = ['bare' => true, 'drop-font-tags' => true, 'drop-proprietary-attributes' => true, 'hide-comments' => true, 'logical-emphasis' => true, 'numeric-entities' => true, 'show-body-only' => true, 'quote-nbsp' => false, 'indent' => 'auto', 'wrap' => 72, 'output-html' => true];
             //if ($aggressive) {
             $config = array_merge($config, ['word-2000' => true, 'drop-empty-paras' => true]);
             //}
             $data = $tidy->repairString($data, $config, 'utf8');
         } catch (\Exception $dummyError) {
             //inspect($dummyError);
         }
         unset($tidy);
     }
     $base = E()->getSiteManager()->getCurrentSite()->base;
     $data = str_replace(strpos($data, '%7E') ? str_replace('~', '%7E', $base) : $base, '', $data);
     return $data;
 }