Example #1
0
/**
 * Save Auth code
 *
 * @param array $params
 *
 * @return string
 */
function save_authcode(&$params)
{
    // if authcode set in request, don't change the config file
    if (isset($params['auth_code']) && trim($params['auth_code']) != '') {
        return $params['auth_code'];
    }
    // generate new authcode
    $auth_code = generate_authcode();
    if (!@is_writable(LC_DIR_CONFIG . constant('LC_CONFIG_FILE')) || !($config = file(LC_DIR_CONFIG . constant('LC_CONFIG_FILE')))) {
        message(xtr('Cannot open config file \':filename\' for writing!', array(':filename' => constant('LC_CONFIG_FILE'))));
        exit;
    }
    $new_config = '';
    foreach ($config as $num => $line) {
        $new_config .= preg_replace('/^auth_code.*=.*/', 'auth_code = "' . $auth_code . '"', $line);
    }
    if (!save_config($new_config)) {
        message(xtr('Config file \':filename\' write failed!', array(':filename' => constant('LC_CONFIG_FILE'))));
        exit;
    }
    return get_authcode();
}
Example #2
0
    ?>

<div id="copyright_notice">

<?php 
    ob_start();
    require COPYRIGHT_FILE;
    $tmp = ob_get_contents();
    ob_end_clean();
    echo nl2br(str_replace('  ', '&nbsp;', htmlspecialchars($tmp)));
    ?>

</div>

<?php 
    if (!is_null(get_authcode())) {
        ?>

<input type="hidden" name="params[force_current]" value="<?php 
        print get_step("check_cfg");
        ?>
" />

<br />

<table align="center">

    <tr>
        <td>
            <span id="auth-code" class="field-label"><?php 
        echo xtr('Auth code');