当前位置: 首页>>代码示例>>PHP>>正文


PHP PassHash::hash_smd5方法代码示例

本文整理汇总了PHP中PassHash::hash_smd5方法的典型用法代码示例。如果您正苦于以下问题:PHP PassHash::hash_smd5方法的具体用法?PHP PassHash::hash_smd5怎么用?PHP PassHash::hash_smd5使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PassHash的用法示例。


在下文中一共展示了PassHash::hash_smd5方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store_data

/**
 * Writes the data to the config files
 *
 * @author  Chris Smith <chris@jalakai.co.uk>
 */
function store_data($d)
{
    global $LC;
    $ok = true;
    $d['policy'] = (int) $d['policy'];
    // create local.php
    $now = gmdate('r');
    $output = <<<EOT
<?php
/**
 * Dokuwiki's Main Configuration File - Local Settings
 * Auto-generated by install script
 * Date: {$now}
 */

EOT;
    $output .= '$conf[\'title\'] = \'' . addslashes($d['title']) . "';\n";
    $output .= '$conf[\'lang\'] = \'' . addslashes($LC) . "';\n";
    $output .= '$conf[\'license\'] = \'' . addslashes($d['license']) . "';\n";
    if ($d['acl']) {
        $output .= '$conf[\'useacl\'] = 1' . ";\n";
        $output .= "\$conf['superuser'] = '@admin';\n";
    }
    $ok = $ok && fileWrite(DOKU_LOCAL . 'local.php', $output);
    if ($d['acl']) {
        // hash the password
        $phash = new PassHash();
        $pass = $phash->hash_smd5($d['password']);
        // create users.auth.php
        // --- user:SMD5password:Real Name:email:groups,comma,seperated
        $output = join(":", array($d['superuser'], $pass, $d['fullname'], $d['email'], 'admin,user'));
        $output = @file_get_contents(DOKU_CONF . 'users.auth.php.dist') . "\n{$output}\n";
        $ok = $ok && fileWrite(DOKU_LOCAL . 'users.auth.php', $output);
        // create acl.auth.php
        $output = <<<EOT
# acl.auth.php
# <?php exit()?>
# Don't modify the lines above
#
# Access Control Lists
#
# Auto-generated by install script
# Date: {$now}

EOT;
        if ($d['policy'] == 2) {
            $output .= "*               @ALL          0\n";
            $output .= "*               @user         8\n";
        } elseif ($d['policy'] == 1) {
            $output .= "*               @ALL          1\n";
            $output .= "*               @user         8\n";
        } else {
            $output .= "*               @ALL          8\n";
        }
        $ok = $ok && fileWrite(DOKU_LOCAL . 'acl.auth.php', $output);
    }
    return $ok;
}
开发者ID:nextghost,项目名称:dokuwiki,代码行数:63,代码来源:install.php

示例2: store_data

/**
 * Writes the data to the config files
 *
 * @author  Chris Smith <chris@jalakai.co.uk>
 *
 * @param array $d
 * @return bool
 */
function store_data($d)
{
    global $LC;
    $ok = true;
    $d['policy'] = (int) $d['policy'];
    // create local.php
    $now = gmdate('r');
    $output = <<<EOT
<?php
/**
 * Dokuwiki's Main Configuration File - Local Settings
 * Auto-generated by install script
 * Date: {$now}
 */

EOT;
    // add any config options set by a previous installer
    $preset = __DIR__ . '/install.conf';
    if (file_exists($preset)) {
        $output .= "# preset config options\n";
        $output .= file_get_contents($preset);
        $output .= "\n\n";
        $output .= "# options selected in installer\n";
        @unlink($preset);
    }
    $output .= '$conf[\'title\'] = \'' . addslashes($d['title']) . "';\n";
    $output .= '$conf[\'lang\'] = \'' . addslashes($LC) . "';\n";
    $output .= '$conf[\'license\'] = \'' . addslashes($d['license']) . "';\n";
    if ($d['acl']) {
        $output .= '$conf[\'useacl\'] = 1' . ";\n";
        $output .= "\$conf['superuser'] = '@admin';\n";
    }
    if (!$d['allowreg']) {
        $output .= '$conf[\'disableactions\'] = \'register\'' . ";\n";
    }
    $ok = $ok && fileWrite(DOKU_LOCAL . 'local.php', $output);
    if ($d['acl']) {
        // hash the password
        $phash = new PassHash();
        $pass = $phash->hash_smd5($d['password']);
        // create users.auth.php
        // --- user:SMD5password:Real Name:email:groups,comma,seperated
        $output = join(":", array($d['superuser'], $pass, $d['fullname'], $d['email'], 'admin,user'));
        $output = @file_get_contents(DOKU_CONF . 'users.auth.php.dist') . "\n{$output}\n";
        $ok = $ok && fileWrite(DOKU_LOCAL . 'users.auth.php', $output);
        // create acl.auth.php
        $output = <<<EOT
# acl.auth.php
# <?php exit()?>
# Don't modify the lines above
#
# Access Control Lists
#
# Auto-generated by install script
# Date: {$now}

EOT;
        if ($d['policy'] == 2) {
            $output .= "*               @ALL          0\n";
            $output .= "*               @user         8\n";
        } elseif ($d['policy'] == 1) {
            $output .= "*               @ALL          1\n";
            $output .= "*               @user         8\n";
        } else {
            $output .= "*               @ALL          8\n";
        }
        $ok = $ok && fileWrite(DOKU_LOCAL . 'acl.auth.php', $output);
    }
    // enable popularity submission
    if ($d['pop']) {
        @touch(DOKU_INC . 'data/cache/autosubmit.txt');
    }
    // disable auth plugins til needed
    $output = <<<EOT
<?php
/*
 * Local plugin enable/disable settings
 *
 * Auto-generated by install script
 * Date: {$now}
 */

\$plugins['authad']    = 0;
\$plugins['authldap']  = 0;
\$plugins['authmysql'] = 0;
\$plugins['authpgsql'] = 0;

EOT;
    $ok = $ok && fileWrite(DOKU_LOCAL . 'plugins.local.php', $output);
    return $ok;
}
开发者ID:boycaught,项目名称:dokuwiki,代码行数:99,代码来源:install.php


注:本文中的PassHash::hash_smd5方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。