コード例 #1
0
ファイル: SecurityUtil.php プロジェクト: rmaiwald/core
 /**
  * Hashes the data with a random salt value and returns a string containing the hash method, salt and hash.
  *
  * @param string $unhashedData         The data to be salted and hashed.
  * @param string $hashMethodName       Any value returned by hash_algo().
  * @param array  $hashMethodNameToCode An array indexed by algorithm names (from hash_algos()) used to encode the hashing algorithm
  *                                         name and include it on the salted hash string; optional, if not specified, then the
  *                                         algorithm name is included in the string returned (which could be considered less than secure!).
  * @param int    $saltLength    The number of random characters to use in the salt.
  * @param string $saltDelimeter The delimiter between the salt and the hash, must be a single character.
  *
  * @return string|bool The algorithm name (or code if $hashMethodNameToCode specified), salt and hashed data separated by the salt delimiter;
  *                      false if an error occured.
  */
 public static function getSaltedHash($unhashedData, $hashMethodName, array $hashMethodNameToCode = array(), $saltLength = 5, $saltDelimeter = self::SALT_DELIM)
 {
     $saltedHash = false;
     $saltStr = RandomUtil::getString($saltLength, $saltLength, false, true, true, true, true, true, false, array($saltDelimeter));
     return self::buildSaltedHash($unhashedData, $hashMethodName, $saltStr, $hashMethodNameToCode, $saltDelimeter);
 }
コード例 #2
0
ファイル: Page.php プロジェクト: projectesIF/Sirius
    public function reinsertPage($args)
    {
        $pageData = $args['page'];

        if ($pageData['parentPageId'] > 0) {
            $sourcePageData = $this->getPage(array('id' => $pageData['parentPageId'], 'checkActive' => false, 'includeContent' => false));
            if ($sourcePageData === false) {
                $pageData['parentPageId'] = 0;
            }
        } else {
            $sourcePageData = null;
        }

        $pageData['language'] = ZLanguage::getLanguageCode();

        // what does this mean?
        if ($pageData['parentPageId'] > 0) {
            $pageData['position'] = $this->contentGetLastSubPagePosition($pageData['parentPageId']) + 1;
            $pageData['level'] = ($sourcePageData == null ? 0 : $sourcePageData['level'] + 1);
        } else {
            $pageData['position'] = $this->contentGetLastPagePosition($pageData['parentPageId']) + 1;
            $pageData['parentPageId'] = ($sourcePageData == null ? 0 : $sourcePageData['parentPageId']);
            $pageData['level'] = ($sourcePageData == null ? 0 : $sourcePageData['level']);
        }

        $ok = $this->isUniqueUrlnameByParentID(array('urlname' => $pageData['urlname'], 'parentId' => $pageData['parentPageId']));
        while (!$ok) {
            $pageData['urlname'] = DataUtil::formatPermalink(RandomUtil::getString(12, 12, false, true, true, false, true, false, true));
            $ok = $this->isUniqueUrlnameByParentID(array('urlname' => $pageData['urlname'], 'parentId' => $pageData['parentPageId']));
        }

        $pageData['setLeft'] = -2;
        $pageData['setRight'] = -1;

        $this->setInitialPageState($pageData);

        $newPage = DBUtil::insertObject($pageData, 'content_page', true);
        Content_Util::contentMainEditExpandSet($pageData['parentPageId'], true);

        $ok = $this->insertPage(array('pageId' => $pageData['id'], 'position' => $pageData['position'], 'parentPageId' => $pageData['parentPageId']));
        if ($ok === false) {
            return false;
        }

        Content_Util::clearCache();
        return array('id' => $pageData['id'], 'urlname' => $pageData['urlname']);
    }