// zprava
            if ($done != 0) {
                $output .= _formMessage(1, str_replace(array("*done*", "*total*"), array($done, $item_total), $_lang['admin.other.massemail.send']));
            } else {
                $output .= _formMessage(2, $_lang['admin.other.massemail.noreceiversfound']);
            }
        } else {
            // vypis emailu
            $emails_total = DB::size($query);
            if ($emails_total != 0) {
                $emails = '';
                $email_counter = 0;
                while ($item = DB::row($query)) {
                    ++$email_counter;
                    $emails .= $item['email'];
                    if ($email_counter !== $emails_total) {
                        $emails .= ',';
                    }
                }
                $output .= _formMessage(1, "<textarea class='areasmallwide' rows='9' cols='33' name='list'>" . $emails . "</textarea>");
            } else {
                $output .= _formMessage(2, $_lang['admin.other.massemail.noreceiversfound']);
            }
        }
    } else {
        $output .= _formMessage(2, _eventList($errors, 'errors'));
    }
}
/* ---  vystup  --- */
$output .= "\n<br />\n<form class='cform' action='index.php?p=other-massemail' method='post'>\n<table class='formtable'>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['admin.other.massemail.sender'] . "</strong></td>\n<td><input type='text' name='sender'" . _restorePostValue("sender", _sysmail) . " class='inputbig' /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['posts.subject'] . "</strong></td>\n<td><input type='text' name='subject' class='inputbig'" . _restorePostValue("subject") . " /></td>\n</tr>\n\n<tr class='valign-top'>\n<td class='rpad'><strong>" . $_lang['admin.other.massemail.receivers'] . "</strong></td>\n<td>" . _admin_authorSelect("receivers", -1, "1", "selectbig", null, true, 4) . "</td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['admin.other.massemail.ctype'] . "</strong></td>\n<td>\n  <select name='ctype' class='selectbig'>\n  <option value='1'>" . $_lang['admin.other.massemail.ctype.1'] . "</option>\n  <option value='2'" . ((isset($_POST['ctype']) and $_POST['ctype'] == 2) ? " selected='selected'" : '') . ">" . $_lang['admin.other.massemail.ctype.2'] . "</option>\n  </select>\n</td>\n</tr>\n\n<tr class='valign-top'>\n<td class='rpad'><strong>" . $_lang['admin.other.massemail.text'] . "</strong></td>\n<td><textarea name='text' class='areabig' rows='9' cols='94'>" . _restorePostValue("text", null, true) . "</textarea></td>\n</tr>\n\n<tr><td></td>\n<td><input type='submit' value='" . $_lang['global.send'] . "' />&nbsp;&nbsp;<label><input type='checkbox' name='maillist' value='1'" . _checkboxActivate(_checkboxLoad("maillist")) . " /> " . $_lang['admin.other.massemail.maillist'] . "</label></td>\n</tr>\n\n</table>\n" . _xsrfProtect() . "</form>\n";
                    $userdata = DB::query("SELECT email,password,salt,username FROM `" . _mysql_prefix . "-users` WHERE username='******' AND email='" . $email . "'");
                    if (DB::size($userdata) != 0) {
                        // odeslani emailu
                        $userdata = DB::row($userdata);
                        $link = _url . "/index.php?m=lostpass&link&user="******"&hash=" . md5($userdata['email'] . $userdata['salt'] . $userdata['password']);
                        $text_tags = array("*domain*", "*username*", "*link*", "*date*", "*ip*");
                        $text_contents = array(_getDomain(), $userdata['username'], $link, _formatTime(time()), _userip);
                        if (_mail($userdata['email'], str_replace('*domain*', _getDomain(), $_lang['mod.lostpass.mail.subject']), str_replace($text_tags, $text_contents, $_lang['mod.lostpass.mail.text']), "Content-Type: text/plain; charset=UTF-8\n" . _sysMailHeader())) {
                            $module .= _formMessage(1, $_lang['mod.lostpass.cmailsent']);
                            _iplogUpdate(7);
                            $sent = true;
                        } else {
                            $module .= _formMessage(3, $_lang['hcm.mailform.msg.failure2']);
                        }
                    } else {
                        $module .= _formMessage(2, $_lang['mod.lostpass.notfound']);
                    }
                } else {
                    $module .= _formMessage(2, $_lang['captcha.failure2']);
                }
            } else {
                $module .= _formMessage(3, str_replace('*limit*', _lostpassexpire / 60, $_lang['mod.lostpass.limit']));
            }
        }
        // formular
        if (!$sent) {
            $captcha = _captchaInit();
            $module .= _formOutput("lostpassform", "index.php?m=lostpass", array(array($_lang['login.username'], "<input type='text' name='username' class='inputsmall' maxlength='24'" . _restorePostValue('username') . " />"), array($_lang['global.email'], "<input type='text' name='email' class='inputsmall' " . _restorePostValue('email', '@') . " />"), $captcha), array("username", "email"), $_lang['global.send']);
        }
        break;
}
             _extend('call', 'mod.messages.new', array('receiver' => $rq['usr_id'], 'subject' => &$subject, 'text' => &$text));
             // vlozeni do pm tabulky
             DB::query('INSERT INTO `' . _mysql_prefix . '-pm` (sender,sender_readtime,sender_deleted,receiver,receiver_readtime,receiver_deleted,update_time) VALUES(' . _loginid . ',UNIX_TIMESTAMP(),0,' . $rq['usr_id'] . ',0,0,UNIX_TIMESTAMP())');
             $pm_id = DB::insertID();
             // vlozeni do posts tabulky
             DB::query("INSERT INTO `" . _mysql_prefix . "-posts` (type,home,xhome,subject,text,author,guest,time,ip,bumptime) VALUES (6," . $pm_id . ",-1,'" . DB::esc($subject) . "','" . DB::esc($text) . "'," . _loginid . ",''," . time() . ",'" . _userip . "',0)");
             // presmerovani a konec
             define('_redirect_to', _url . '/' . _indexOutput_url . '&a=list&read=' . $pm_id);
             return;
         } while (false);
     }
     // formular
     if (isset($message)) {
         $module .= $message . "\n";
     }
     $module .= "<form action='' method='post' name='newmsg'" . _jsCheckForm('newmsg', array('receiver')) . ">\n<table>\n\n<tr>\n    <td><strong>" . $_lang['mod.messages.receiver'] . "</strong></td>\n    <td><input type='text' name='receiver' class='inputsmall' maxlength='24'" . _restorePostValue("receiver", _get('receiver')) . " /></td>\n</tr>\n\n<tr>\n    <td><strong>" . $_lang['posts.subject'] . "</strong></td>\n    <td><input type='text' name='subject' class='inputsmall' maxlength='22'" . _restorePostValue("subject", _get('subject')) . " /></td>\n</tr>\n\n<tr class='valign-top'>\n    <td><strong>" . $_lang['mod.messages.message'] . "</strong></td>\n    <td><textarea name='text' class='areamedium' rows='5' cols='33'>" . _restorePostValue("text", null, true) . "</textarea></td>\n</tr>\n\n<tr>\n    <td></td>\n    <td><input type='submit' value='" . $_lang['global.send'] . "' />" . _getPostFormControls('newmsg', 'text') . "</td>\n</tr>\n\n</table>\n\n" . _jsLimitLength(16384, 'newmsg', 'text') . "\n\n" . _xsrfProtect() . "</form>\n";
     break;
     /* ---  vypis  --- */
 /* ---  vypis  --- */
 default:
     // cteni vzkazu
     if (isset($_GET['read'])) {
         // promenne
         $id = intval($_GET['read']);
         // nacist data
         $q = DB::query_row('SELECT pm.*,post.subject,post.time FROM `' . _mysql_prefix . '-pm` AS pm JOIN `' . _mysql_prefix . '-posts` AS post ON (post.type=6 AND post.home=pm.id AND post.xhome=-1) WHERE pm.id=' . $id . ' AND (sender=' . _loginid . ' AND sender_deleted=0 OR receiver=' . _loginid . ' AND receiver_deleted=0)');
         if ($q === false) {
             $module .= _formMessage(3, $_lang['global.badinput']);
             break;
         }
         // titulek
        $item = pathinfo($item);
        if (!isset($item['extension']) or $item['extension'] != "php") {
            continue;
        }
        $item = mb_substr($item['basename'], 0, mb_strrpos($item['basename'], "."));
        if ($item == _loginlanguage) {
            $selected = ' selected="selected"';
        } else {
            $selected = "";
        }
        $language_select .= '<option value="' . $item . '"' . $selected . '>' . $item . '</option>';
    }
    closedir($handle);
    $language_select .= '</select></td></tr>';
} else {
    $language_select = "";
}
// wysiwyg
if (_loginright_administration) {
    $admin = "\n\n\n\n  <tr>\n  <td><strong>" . $_lang['mod.settings.wysiwyg'] . "</strong></td>\n  <td><label><input type='checkbox' name='wysiwyg' value='1'" . _checkboxActivate($query['wysiwyg']) . " /> " . $_lang['mod.settings.wysiwyg.label'] . "</label></td>\n  </tr>\n\n  ";
} else {
    $admin = "";
}
$module .= "\n<p><a href='index.php?m=profile&amp;id=" . _loginname . "'>" . $_lang['mod.settings.profilelink'] . " &gt;</a></p>\n<p>" . $_lang['mod.settings.p'] . "</p>" . $message . "\n<form action='index.php?m=settings' method='post' name='setform' enctype='multipart/form-data'>\n\n" . _jsLimitLength(1024, "setform", "note") . "\n\n  <fieldset>\n  <legend>" . $_lang['mod.settings.userdata'] . "</legend>\n  <table class='profiletable'>\n\n  <tr>\n  <td><strong>" . $_lang['login.username'] . "</strong> <span class='important'>*</span></td>\n  <td><input type='text' name='username'" . _restorePostValue('username', _loginname) . " class='inputsmall' maxlength='24' />" . (!_loginright_changeusername ? "<span class='hint'>(" . $_lang['mod.settings.namechangenote'] . ")</span>" : '') . "</td>\n  </tr>\n\n  <tr>\n  <td><strong>" . $_lang['mod.settings.publicname'] . "</strong></td>\n  <td><input type='text' name='publicname'" . _restorePostValue('publicname', $query['publicname']) . " class='inputsmall' maxlength='24' /></td>\n  </tr>\n\n  <tr class='valign-top'>\n  <td><strong>" . $_lang['global.email'] . "</strong> <span class='important'>*</span></td>\n  <td><input type='text' name='email'" . _restorePostValue('email', $query['email']) . " class='inputsmall'/></td>\n  </tr>\n\n  " . $language_select . "\n\n  <tr>\n  <td><strong>" . $_lang['mod.settings.massemail'] . "</strong></td>\n  <td><label><input type='checkbox' name='massemail' value='1'" . _checkboxActivate($query['massemail']) . " /> " . $_lang['mod.settings.massemail.label'] . "</label></td>\n  </tr>\n\n  " . $admin . "\n  </table>\n  </fieldset>\n\n\n  <fieldset>\n  <legend>" . $_lang['mod.settings.password'] . "</legend>\n  <p class='minip'>" . $_lang['mod.settings.password.hint'] . "</p>\n  <table class='profiletable'>\n\n  <tr>\n  <td><strong>" . $_lang['mod.settings.password.current'] . "</strong></td>\n  <td><input type='password' name='currentpassword' class='inputsmall' autocomplete='off' /></td>\n  </tr>\n\n  <tr>\n  <td><strong>" . $_lang['mod.settings.password.new'] . "</strong></td>\n  <td><input type='password' name='newpassword' class='inputsmall' autocomplete='off' /></td>\n  </tr>\n\n  <tr>\n  <td><strong>" . $_lang['mod.settings.password.new'] . " (" . $_lang['global.check'] . ")</strong></td>\n  <td><input type='password' name='newpassword-confirm' class='inputsmall' autocomplete='off' /></td>\n  </tr>\n\n  </table>\n  </fieldset>\n\n  " . _extend('buffer', 'mod.settings.form') . "\n\n\n  <fieldset>\n  <legend>" . $_lang['mod.settings.info'] . "</legend>\n\n  <table class='profiletable'>\n\n  <tr>\n  <td><strong>" . $_lang['global.icq'] . "</strong></td>\n  <td><input type='text' name='icq'" . _restorePostValue('icq', $query['icq']) . " class='inputsmall' /></td>\n  </tr>\n\n  <tr>\n  <td><strong>" . $_lang['global.skype'] . "</strong></td>\n  <td><input type='text' name='skype'" . _restorePostValue('skype', $query['skype']) . " class='inputsmall' /></td>\n  </tr>\n\n  <tr>\n  <td><strong>" . $_lang['global.msn'] . "</strong></td>\n  <td><input type='text' name='msn'" . _restorePostValue('msn', $query['msn']) . " class='inputsmall' /></td>\n  </tr>\n\n  <tr>\n  <td><strong>" . $_lang['global.jabber'] . "</strong></td>\n  <td><input type='text' name='jabber'" . _restorePostValue('jabber', $query['jabber']) . " class='inputsmall' /></td>\n  </tr>\n\n  <tr>\n  <td><strong>" . $_lang['global.web'] . "</strong></td>\n  <td><input type='text' name='web' value='" . $query['web'] . "' class='inputsmall' /><span class='hint'>" . $_lang['mod.settings.web.hint'] . "</span></td>\n  </tr>\n\n  <tr class='valign-top'>\n  <td><strong>" . $_lang['global.note'] . "</strong></td>\n  <td><textarea name='note' class='areasmall' rows='9' cols='33'>" . _restorePostValue('note', $query['note'], true) . "</textarea></td>\n  </tr>\n\n  <tr><td></td>\n  <td>" . _getPostFormControls("setform", "note") . "</td>\n  </tr>\n\n  </table>\n\n  </fieldset>\n";
if (_uploadavatar) {
    $module .= "\n  <fieldset>\n  <legend>" . $_lang['mod.settings.avatar'] . "</legend>\n  " . _extend('buffer', 'mod.settings.avatar', array('extra' => array('query' => $query))) . "\n  <p><strong>" . $_lang['mod.settings.avatar.upload'] . ":</strong> <input type='file' name='avatar' /></p>\n    <table>\n    <tr class='valign-top'>\n    <td width='106'><div class='avatar'><img src='" . $avatar_path . "' alt='avatar' /></div></td>\n    <td><p class='minip'>" . $_lang['mod.settings.avatar.hint'] . "</p><p><label><input type='checkbox' name='removeavatar' value='1' /> " . $_lang['mod.settings.avatar.remove'] . "</label></p></td>\n    </tr>\n    </table>\n  </fieldset>\n";
}
if (_loginright_selfdestruction and _loginid != 0) {
    $module .= "\n\n  <fieldset>\n  <legend>" . $_lang['mod.settings.selfremove'] . "</legend>\n  <label><input type='checkbox' name='selfremove' value='1' onclick='if (this.checked==true) {return _sysConfirm();}' /> " . $_lang['mod.settings.selfremove.box'] . "</label><br /><br />\n  <div class='lpad'><strong>" . $_lang['mod.settings.selfremove.confirm'] . ":</strong> <input type='password' name='selfremove-confirm' class='inputsmall' /></div>\n  </fieldset>\n\n";
}
$module .= "\n<br />\n<input type='submit' value='" . $_lang['mod.settings.submit'] . "' />\n<input type='reset' value='" . $_lang['global.reset'] . "' onclick='return _sysConfirm();' />\n\n" . _xsrfProtect() . "</form>\n";
Exemple #5
0
            $groupselect_items = DB::query("SELECT id,title FROM `" . _mysql_prefix . "-groups` WHERE `blocked`=0 AND reglist=1 ORDER BY title");
            if (DB::size($groupselect_items) != 0) {
                $groupselect_content = "";
                while ($groupselect_item = DB::row($groupselect_items)) {
                    $groupselect_content .= "<option value='" . $groupselect_item['id'] . "'" . ($groupselect_item['id'] == _defaultgroup ? " selected='selected'" : '') . ">" . $groupselect_item['title'] . "</option>\n";
                }
                $groupselect = array($_lang['global.group'], "<select name='group'>" . $groupselect_content . "</select>");
            }
        }
        // priprava podminek
        if (SL::$settings['rules'] != "") {
            $rules = array("<div class='hr'><hr /></div><h2>" . $_lang['mod.reg.rules'] . "</h2>" . SL::$settings['rules'] . "<br /><label><input type='checkbox' name='agreement' value='1'" . _checkboxActivate(isset($_POST['agreement'])) . " /> " . $_lang['mod.reg.rules.agreement'] . "</label><div class='hr'><hr /></div><br />", "", true);
        } else {
            $rules = array(null);
        }
        // formular
        $captcha = _captchaInit();
        $module .= "<p class='bborder'>" . $_lang['mod.reg.p'] . (_registration_confirm ? ' ' . $_lang['mod.reg.confirm.extratext'] : '') . "</p>";
        $module .= $message . _formOutput("regform", "index.php?m=reg", array(array($_lang['login.username'], "<input type='text' name='username' class='inputsmall' maxlength='24'" . _restorePostValue('username') . " />"), array($_lang['login.password'], "<input type='password' name='password' class='inputsmall' />"), array($_lang['login.password'] . " (" . $_lang['global.check'] . ")", "<input type='password' name='password2' class='inputsmall' />"), array($_lang['global.email'], "<input type='text' name='email' class='inputsmall' " . _restorePostValue('email', '@') . " />"), array($_lang['mod.settings.massemail'], "<input type='checkbox' name='massemail' value='1' checked='checked' /> " . $_lang['mod.settings.massemail.label']), $groupselect, $captcha, $rules), array("username", "email", "password", "password2"), $_lang['mod.reg.submit' . (_registration_confirm ? '2' : '')]);
        break;
        // uspesna registrace
    // uspesna registrace
    case 1:
        $module .= "<p>" . str_replace("*username*", $username, $_lang['mod.reg.done']) . "</p>";
        break;
        // odeslano potvrzeni
    // odeslano potvrzeni
    case 2:
        $module .= _formMessage(1, str_replace('*email*', $email, $_lang['mod.reg.confirm.sent']));
        break;
}
function _tmp_installer_install()
{
    global $_lang, $self, $is_clean;
    // krok
    static $steps = 3;
    if (isset($_POST['step'])) {
        $step = intval($_POST['step']);
        if ($step < 1 || $step > $steps) {
            $step = 1;
        }
    } else {
        $step = 1;
    }
    $fname = basename(__FILE__);
    if (!empty($_POST)) {
        echo '<a href="./' . $fname . '" id="cancelink">' . $_lang['global.cancel'] . '</a>';
    }
    ?>

<h2><?php 
    echo str_replace(array('*step*', '*steps*', '*name*'), array($step, $steps, $_lang['step.' . $step]), $_lang['install']);
    ?>
</h2>
<form action="./<?php 
    echo $fname;
    ?>
" method="post" name="instform" autocomplete="off">
    <?php 
    switch ($step) {
        // kontrola
        case 1:
            if (isset($_POST['check'])) {
                // nacteni a kontrola existence souboru
                $a_files = $self->listFilesOnPath('/files/');
                $conflicts = array();
                $counter = 0;
                $err_limit = 10;
                for ($i = 0; isset($a_files[$i]); ++$i) {
                    $path = './' . substr($a_files[$i], 7);
                    if (file_exists($path)) {
                        ++$counter;
                        if ($counter <= $err_limit) {
                            $conflicts[] = str_replace('*path*', $path, $_lang['step.1.err.file']);
                        }
                    }
                }
                if ($counter > $err_limit) {
                    $conflicts[] = str_replace('*n*', $counter - $err_limit, $_lang['step.1.err.file.etc']);
                }
                // zprava nebo pokracovani
                if (empty($conflicts)) {
                    // vse je ok
                    $step = 2;
                    echo '<p class="green center">' . $_lang['step.1.ok'] . '</p>';
                    echo '<p class="center"><input type="submit" value="' . $_lang['global.continue'] . '"></p>';
                    break;
                } else {
                    // jsou chyby
                    echo '<p class="red">' . $_lang['step.1.err'] . ':</p>';
                    echo "<ul>\n";
                    for ($i = 0; isset($conflicts[$i]); ++$i) {
                        echo "<li>" . $conflicts[$i] . "</li>\n";
                    }
                    echo "</ul>";
                }
            }
            echo '<p class="center"><input type="submit" name="check" value="' . $_lang['step.1.submit'] . '"></p>';
            break;
            // konfigurace & instalace
        // konfigurace & instalace
        case 2:
        case 3:
            // navrat z kroku 3
            if (isset($_POST['return_to_cfg'])) {
                $step = 2;
                unset($_POST['return_to_cfg']);
            }
            // instalace
            $install = $step == 3;
            if (isset($_POST['sys_url'])) {
                // zpracovat url
                $_POST['sys_url'] = _removeSlashesFromEnd($_POST['sys_url']);
                // kontroly
                $err = null;
                do {
                    // prefix
                    $prefix = trim($_POST['db_prefix']);
                    if ($prefix === '') {
                        $err = str_replace('*input*', $_lang['step.2.db.prefix'], $_lang['step.2.err.empty']);
                        break;
                    }
                    // ucet administratora
                    $_POST['admin_name'] = _anchorStr(trim($_POST['admin_name']), false);
                    $_POST['admin_email'] = trim($_POST['admin_email']);
                    // pouze pro cistou instalaci
                    if ($is_clean) {
                        // vynutit ucet administratora
                        if ($_POST['admin_name'] === '') {
                            $err = str_replace('*input*', $_lang['step.2.admin.name'], $_lang['step.2.err.empty']);
                            break;
                        }
                        if ($_POST['admin_pwd'] === '') {
                            $err = str_replace('*input*', $_lang['step.2.admin.pwd'], $_lang['step.2.err.empty']);
                            break;
                        }
                        if ($_POST['admin_email'] === '' || $_POST['admin_email'] === '@') {
                            $err = str_replace('*input*', $_lang['step.2.admin.email'], $_lang['step.2.err.empty']);
                            break;
                        }
                        // titulek stranek
                        $_POST['sys_title'] = trim($_POST['sys_title']);
                        if ($_POST['sys_title'] === '') {
                            $err = str_replace('*input*', $_lang['step.2.sys.title'], $_lang['step.2.err.empty']);
                            break;
                        }
                        // popis, klicova slova
                        $_POST['sys_descr'] = trim($_POST['sys_descr']);
                        $_POST['sys_kwrds'] = trim($_POST['sys_kwrds']);
                    }
                    // email administratora
                    if ($_POST['admin_email'] !== '' && $_POST['admin_email'] !== '@' && !_validateEmail($_POST['admin_email'])) {
                        $err = $_lang['step.2.err.admin.email'];
                        break;
                    }
                    // heslo administratora
                    if ($_POST['admin_pwd'] !== '' && $_POST['admin_pwd'] !== $_POST['admin_pwd2']) {
                        $err = $_lang['step.2.err.admin.pwd'];
                        break;
                    }
                    // DB port
                    $server = $_POST['db_server'];
                    if (false !== ($serverColonPos = strpos($server, ':'))) {
                        $port = (int) substr($server, $serverColonPos + 1);
                        $server = substr($server, 0, $serverColonPos);
                    } else {
                        $port = ini_get('mysqli.default_port');
                    }
                    // pripojeni
                    $con = @mysqli_connect($server, $_POST['db_user'], $_POST['db_pwd'], $_POST['db_name'], $port);
                    if (!is_object($con)) {
                        $err = $_lang['step.2.err.con'] . '<br><code>' . _htmlStr(mysqli_connect_error()) . '</code>';
                        break;
                    }
                    // kodovani a konstanty
                    DB::$con = $con;
                    DB::$con->set_charset('utf8');
                    DB::query('SET sql_mode=\'\'');
                    define('_mysql_prefix', $prefix);
                    // existence tabulek
                    $prefix = DB::esc($prefix);
                    $q = DB::query('SHOW TABLES LIKE \'' . $prefix . '-%\'');
                    $tables = array();
                    while ($r = DB::rown($q)) {
                        $tables[] = $r[0];
                    }
                    if (!empty($tables) && !isset($_POST['db_overwrite'])) {
                        $err = $_lang['step.2.err.tables'] . ':<br><br>&bull; ' . implode("<br>\n&bull; ", $tables);
                        break;
                    }
                    // vse ok
                    if ($install) {
                        if (!isset($_POST['do_install'])) {
                            // potvrzeni
                            echo _getPostdata(false, null, array('step'));
                            echo '<p class="green center">' . $_lang['step.3.text'] . '</p>';
                            echo '<p class="center">
<input type="submit" name="do_install" value="' . $_lang['step.3.submit'] . '" onclick="if (window.sl_install_process) return false; else {window.sl_install_process = true; this.value=\'' . $_lang['step.3.wait'] . '\'}">&nbsp;
<input type="submit" name="return_to_cfg" value="' . $_lang['step.3.return'] . '">
</p>';
                        } else {
                            // provedeni
                            $err = null;
                            try {
                                // rozbalit soubory
                                $self->extractFiles('./', '/files/', false, true, array($self->vars['void']));
                                // vytvorit konfiguracni soubor
                                global $cfg_locale, $cfg_timezone;
                                file_put_contents('./config.php', str_replace(array('/* @@@server@@@ */', '/* @@@user@@@ */', '/* @@@password@@@ */', '/* @@@database@@@ */', '/* @@@prefix@@@ */', '/* @@@locale@@@ */', '/* @@@timezone@@@ */'), array(var_export($_POST['db_server'], true), var_export($_POST['db_user'], true), var_export($_POST['db_pwd'], true), var_export($_POST['db_name'], true), var_export($prefix, true), var_export($cfg_locale, true), var_export($cfg_timezone, true)), $self->getFile('/files/data/installer/config.php.tpl')));
                                // smazat tabulky z databaze?
                                if (!empty($tables)) {
                                    for ($i = 0; isset($tables[$i]); ++$i) {
                                        DB::query('DROP TABLE `' . $tables[$i] . '`', true);
                                        if (($sql_err = DB::error()) !== '') {
                                            throw new _InstallException($_lang['step.3.err.drop'] . '<br><code>' . $sql_err . '</code>');
                                        }
                                    }
                                }
                                // deaktivovat kontrolu verze
                                function _checkVersion()
                                {
                                    return true;
                                }
                                // vytvorit strukturu databaze
                                $dbdump = new DBDump();
                                $dbdump->importTables($self->getFile('/database/struct'));
                                // nacist data
                                $data_stream = $self->getFileStream('/database/data');
                                $dbdump->importData($data_stream);
                                $data_stream->free();
                                // aktualizovat url
                                DB::query('UPDATE `' . $prefix . '-settings` SET `val`=' . DB::val($_POST['sys_url']) . ' WHERE `var`=\'url\'');
                                // vypnout mod rewrite pokud neexistuje .htaccess
                                if (!file_exists(_indexroot . '.htaccess')) {
                                    DB::query('UPDATE `' . $prefix . '-settings` SET `val`=0 WHERE `var`=\'modrewrite\'');
                                }
                                // upravit ucet administratora
                                $admin_upd = array();
                                if ($_POST['admin_name'] !== '') {
                                    $admin_upd['username'] = $_POST['admin_name'];
                                    if (!$is_clean) {
                                        $admin_upd['publicname'] = '';
                                    }
                                }
                                if ($_POST['admin_email'] !== '' && $_POST['admin_email'] !== '@') {
                                    $admin_upd['email'] = $_POST['admin_email'];
                                }
                                if ($_POST['admin_pwd'] !== '') {
                                    $admin_pwd = _md5Salt($_POST['admin_pwd']);
                                    $admin_upd['password'] = $admin_pwd[0];
                                    $admin_upd['salt'] = $admin_pwd[1];
                                }
                                if ($is_clean) {
                                    $admin_upd['registertime'] = time();
                                    $admin_upd['activitytime'] = time();
                                }
                                if (!empty($admin_upd)) {
                                    $admin_upd_sql = '';
                                    $counter = 0;
                                    foreach ($admin_upd as $col => $val) {
                                        if ($counter !== 0) {
                                            $admin_upd_sql .= ',';
                                        }
                                        $admin_upd_sql .= '`' . $col . '`=' . DB::val($val);
                                        ++$counter;
                                    }
                                    DB::query('UPDATE `' . $prefix . '-users` SET ' . $admin_upd_sql . ' WHERE id=0');
                                }
                                // aktualizovat titulek, klic. slova a popis
                                if ($is_clean) {
                                    DB::query('UPDATE `' . $prefix . '-settings` SET `val`=' . DB::val(_htmlStr($_POST['sys_title'])) . ' WHERE `var`=\'title\'');
                                    DB::query('UPDATE `' . $prefix . '-settings` SET `val`=' . DB::val(_htmlStr($_POST['sys_kwrds'])) . ' WHERE `var`=\'keywords\'');
                                    DB::query('UPDATE `' . $prefix . '-settings` SET `val`=' . DB::val(_htmlStr($_POST['sys_descr'])) . ' WHERE `var`=\'description\'');
                                }
                                // vypnout mod_rewrite
                                DB::query('UPDATE `' . $prefix . '-settings` SET `val`=\'0\' WHERE `var`=\'mod_rewrite\'');
                                // vynutit kontrolu instalace
                                DB::query('UPDATE `' . $prefix . '-settings` SET `val`=\'1\' WHERE `var`=\'install_check\'');
                            } catch (_InstallException $e) {
                                $err = $e->getMessage();
                            } catch (Exception $e) {
                                $err = _htmlStr($e->getMessage());
                            }
                            // uspech ci chyba
                            if (isset($err)) {
                                echo '<p class="red">' . $err . '</p>';
                                echo '<p class="red">' . $_lang['step.3.err.warning'] . '</p>';
                            } else {
                                echo '<p class="green center">' . str_replace('*fname*', $fname, $_lang['step.3.fin']) . '</p>';
                            }
                        }
                        break 2;
                    } else {
                        $step = 3;
                        echo '<p class="green center">' . $_lang['step.2.ok'] . '</p>';
                    }
                } while (false);
                // chyba
                if (isset($err)) {
                    echo '<p class="red">' . $err . '</p>';
                }
            }
            ?>

<table>
<thead><th colspan="2"><?php 
            echo $_lang['step.2.sys'];
            ?>
</th></thead>
<tbody>

    <tr>
        <th><?php 
            echo $_lang['step.2.sys.url'];
            ?>
</th>
        <td><input type="text" name="sys_url"<?php 
            echo _restorePostValue('sys_url');
            ?>
></td>
    </tr>

    <?php 
            if ($is_clean) {
                ?>
    <tr>
        <th><?php 
                echo $_lang['step.2.sys.title'];
                ?>
</th>
        <td><input type="text" name="sys_title"<?php 
                echo _restorePostValue('sys_title');
                ?>
></td>
    </tr>

    <tr>
        <th><?php 
                echo $_lang['step.2.sys.descr'];
                ?>
</th>
        <td><input type="text" name="sys_descr"<?php 
                echo _restorePostValue('sys_descr');
                ?>
></td>
    </tr>

    <tr>
        <th><?php 
                echo $_lang['step.2.sys.kwrds'];
                ?>
</th>
        <td><input type="text" name="sys_kwrds"<?php 
                echo _restorePostValue('sys_kwrds');
                ?>
></td>
    </tr>
    <?php 
            }
            ?>

</tbody>
</table>

<script type="text/javascript">
// predvyplneni adresy
if (document.instform.sys_url.value === '') {
    var loc = new String(document.location);
    var slash;
    var slash_last = 0;
    var limit = 0;
    while (true) {
        slash = loc.indexOf('/', slash_last);
        if (slash === -1) break;
        slash_last = slash + 1;
    }
    loc = loc.substr(0, slash_last);
    document.instform.sys_url.value = loc;
}
</script>

<table>
<thead>
    <tr><th colspan="2"><?php 
            echo $_lang['step.2.admin'];
            ?>
</th></tr>
    <?php 
            if (!$is_clean) {
                ?>
<tr><th colspan="2"><small><?php 
                echo $_lang['step.2.admin.notice'];
                ?>
</small></th></tr><?php 
            }
            ?>
</thead>
<tbody>

    <tr>
        <th><?php 
            echo $_lang['step.2.admin.name'];
            ?>
</th>
        <td><input type="text" maxlength="24" name="admin_name"<?php 
            echo _restorePostValue('admin_name');
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.admin.email'];
            ?>
</th>
        <td><input type="text" maxlength="100" name="admin_email"<?php 
            echo _restorePostValue('admin_email', $is_clean ? '@' : null);
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.admin.pwd'];
            ?>
</th>
        <td><input type="password" name="admin_pwd"<?php 
            echo _restorePostValue('admin_pwd');
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.admin.pwd2'];
            ?>
</th>
        <td><input type="password" name="admin_pwd2"<?php 
            echo _restorePostValue('admin_pwd2');
            ?>
></td>
    </tr>

</tbody>
</table>

<table>
<thead><tr><th colspan="2"><?php 
            echo $_lang['step.2.db'];
            ?>
</th></tr></thead>
<tbody>

    <tr>
        <th><?php 
            echo $_lang['step.2.db.server'];
            ?>
</th>
        <td><input type="text" name="db_server"<?php 
            echo _restorePostValue('db_server', 'localhost');
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.db.name'];
            ?>
</th>
        <td><input type="text" name="db_name"<?php 
            echo _restorePostValue('db_name');
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.db.user'];
            ?>
</th>
        <td><input type="text" name="db_user"<?php 
            echo _restorePostValue('db_user');
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.db.pwd'];
            ?>
</th>
        <td><input type="password" name="db_pwd"<?php 
            echo _restorePostValue('db_pwd');
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.db.prefix'];
            ?>
</th>
        <td><input type="text" maxlength="24" name="db_prefix"<?php 
            echo _restorePostValue('db_prefix', 'sunlight');
            ?>
></td>
    </tr>

    <tr>
        <th><?php 
            echo $_lang['step.2.db.tables'];
            ?>
</th>
        <td><label><input type="checkbox" name="db_overwrite"<?php 
            echo _checkboxActivate(isset($_POST['db_overwrite']));
            ?>
 value="1" onchange="if (this.checked && !confirm('<?php 
            echo $_lang['step.2.db.tables.overwrite.confirm'];
            ?>
')) this.checked = false"> <?php 
            echo $_lang['step.2.db.tables.overwrite'];
            ?>
</label></td>
    </tr>

</tbody>
</table>

<p class="center"><input type="submit" value="<?php 
            echo $_lang[$step != 3 ? 'step.2.submit' : 'global.continue'];
            ?>
"></p>

        <?php 
            //<p class="warning"><?php echo $_lang['step.2.warning']</p>
            break;
    }
    ?>
<input type="hidden" name="step" value="<?php 
    echo $step;
    ?>
">
</form>
    <?php 
}
    // zpravy
    $messages_code = "";
    if (isset($_GET['r'])) {
        switch ($_GET['r']) {
            case 1:
                $messages_code .= _formMessage(1, $_lang['global.saved']);
                break;
            case 2:
                $messages_code .= _formMessage(1, $_lang['global.created']);
                break;
        }
    }
    if ($message != "") {
        $messages_code .= _formMessage(2, $message);
    }
    $output .= "\n<p class='bborder'>" . $_lang['admin.users.edit.p'] . "</p>\n" . $messages_code . "\n<form autocomplete='off' action='index.php?p=users-edit" . ($id != null ? "&amp;id=" . $id : '') . "' method='post' name='userform'" . _jsCheckForm("userform", $id != null ? array("username", "email") : array("username", "email", "password")) . ">\n<table class='formtable'>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['login.username'] . "</strong></td>\n<td><input type='text' name='username' class='inputsmall'" . _restorePostValue('username', $query['username']) . " maxlength='24' /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['mod.settings.publicname'] . "</strong></td>\n<td><input type='text' name='publicname' class='inputsmall'" . _restorePostValue('publicname', $query['publicname'], false, true, false) . " maxlength='24' /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang[$id == null ? 'login.password' : 'mod.settings.password.new'] . "</strong></td>\n<td><input type='password' name='password' class='inputsmall' /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.group'] . "</strong></td>\n<td>" . $group_select . "</td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['login.blocked'] . "</strong></td>\n<td><input type='checkbox' name='blocked' value='1'" . _checkboxActivate($query['blocked'] || isset($_POST['blocked'])) . " /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.levelshift'] . "</strong></td>\n<td><input type='checkbox' name='levelshift' value='1'" . _checkboxActivate($query['levelshift'] || isset($_POST['levelshift'])) . _inputDisable(_loginid == 0) . " /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.email'] . "</strong></td>\n<td><input type='text' name='email' class='inputsmall'" . _restorePostValue('email', $query['email']) . " /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.icq'] . "</strong></td>\n<td><input type='text' name='icq' class='inputsmall' value='" . (($val = _restorePostValue('icq', $query['icq'], true)) != 0 ? $val : '') . "' /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.skype'] . "</strong></td>\n<td><input type='text' name='skype' class='inputsmall'" . _restorePostValue('skype', $query['skype']) . " /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.msn'] . "</strong></td>\n<td><input type='text' name='msn' class='inputsmall'" . _restorePostValue('msn', $query['msn']) . " /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.jabber'] . "</strong></td>\n<td><input type='text' name='jabber' class='inputsmall' value='" . $query['jabber'] . "' /></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.web'] . "</strong></td>\n<td><input type='text' name='web' class='inputsmall'" . _restorePostValue('web', $query['web'], false, true, false) . " /> <small>" . $_lang['mod.settings.web.hint'] . "</small></td>\n</tr>\n\n<tr>\n<td class='rpad'><strong>" . $_lang['global.avatar'] . "</strong></td>\n<td><label><input type='checkbox' name='removeavatar' value='1' /> " . $_lang['mod.settings.avatar.remove'] . "</label></td>\n</tr>\n\n<tr class='valign-top'>\n<td class='rpad'><strong>" . $_lang['global.note'] . "</strong></td>\n<td><textarea name='note' class='areasmall' rows='9' cols='33'>" . _restorePostValue('note', $query['note'], true, true, false) . "</textarea></td>\n</tr>\n\n<tr><td></td>\n<td><input type='submit' value='" . $_lang[isset($_GET['id']) ? 'global.save' : 'global.create'] . "' />" . ($id != null ? "&nbsp;&nbsp;<small>" . $_lang['admin.content.form.thisid'] . " " . $query['id'] . "</small>" : '') . "</td>\n</tr>\n\n</table>\n" . _xsrfProtect() . "</form>\n";
    // odkaz na profil a zjisteni ip
    if ($id != null) {
        $output .= "\n  <p>\n  <a href='" . _indexroot . "index.php?m=profile&amp;id=" . $query['username'] . "' target='_blank'>" . $_lang['mod.settings.profilelink'] . " &gt;</a>\n  " . (_loginright_adminbans ? "<br /><a href='index.php?p=other-bans&amp;getip=" . $query['username'] . "'>" . $_lang['admin.other.bans.getuserip'] . " &gt;</a>" : '') . "\n  </p>\n  ";
    }
} else {
    switch ($errno) {
        case 1:
            $output .= _formMessage(2, $_lang['global.baduser']);
            break;
        case 2:
            $output .= _formMessage(2, $_lang['global.rootnote']);
            break;
        default:
            $output .= _formMessage(3, $_lang['global.disallowed']);
            break;