Esempio n. 1
0
hesk_check_maintenance();
// Are we in "Knowledgebase only" mode?
hesk_check_kb_only();
// What should we do?
$action = hesk_REQUEST('a');
switch ($action) {
    case 'add':
        hesk_session_start();
        print_add_ticket();
        break;
    case 'forgot_tid':
        hesk_session_start();
        forgot_tid();
        break;
    default:
        print_start();
}
// Print footer
require_once HESK_PATH . 'inc/footer.inc.php';
exit;
/*** START FUNCTIONS ***/
function print_add_ticket()
{
    global $hesk_settings, $hesklang;
    // Auto-focus first empty or error field
    define('AUTOFOCUS', true);
    // Pre-populate fields
    // Customer name
    if (isset($_REQUEST['name'])) {
        $_SESSION['c_name'] = $_REQUEST['name'];
    }
Esempio n. 2
0
function init_chat()
{
    global $C, $H, $I, $db, $memcached;
    $suwrite = '';
    if (check_init()) {
        $suwrite = $I['initdbexist'];
        $result = $db->query("SELECT * FROM {$C['prefix']}members WHERE status=8;");
        if ($result->fetch(PDO::FETCH_ASSOC)) {
            $suwrite = $I['initsuexist'];
        }
    } elseif (!preg_match('/^[a-z0-9]{1,20}$/i', $_REQUEST['sunick'])) {
        $suwrite = sprintf($I['invalnick'], 20);
    } elseif (!preg_match('/^.{5,}$/', $_REQUEST['supass'])) {
        $suwrite = sprintf($I['invalpass'], 5);
    } elseif ($_REQUEST['supass'] !== $_REQUEST['supassc']) {
        $suwrite = $I['noconfirm'];
    } else {
        if ($C['dbdriver'] === 0) {
            //MySQL
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}captcha (id int(10) unsigned NOT NULL AUTO_INCREMENT, time int(10) unsigned NOT NULL, code char(5) NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}filter (id int(10) unsigned NOT NULL AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(20000) NOT NULL, allowinpm tinyint(1) unsigned NOT NULL, regex tinyint(1) unsigned NOT NULL, kick tinyint(1) unsigned NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}ignored (id int(10) unsigned NOT NULL AUTO_INCREMENT, ign varchar(50) NOT NULL, ignby varchar(50) NOT NULL, PRIMARY KEY (id) USING BTREE, INDEX(ign) USING BTREE, INDEX(ignby) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}linkfilter (id int(10) unsigned NOT NULL AUTO_INCREMENT, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex tinyint(1) unsigned NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}members (id int(10) unsigned NOT NULL AUTO_INCREMENT, nickname varchar(50) NOT NULL, passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, status tinyint(3) unsigned NOT NULL, refresh tinyint(3) unsigned NOT NULL, bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, boxwidth tinyint(3) unsigned NOT NULL DEFAULT 40, boxheight tinyint(3) unsigned NOT NULL DEFAULT 3, notesboxheight tinyint(3) unsigned NOT NULL DEFAULT 30, notesboxwidth tinyint(3) unsigned NOT NULL DEFAULT 80, regedby varchar(50) NOT NULL, lastlogin int(10) unsigned NOT NULL, timestamps tinyint(1) unsigned NOT NULL, embed tinyint(1) unsigned NOT NULL DEFAULT 1, incognito tinyint(1) unsigned NOT NULL DEFAULT 0, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, PRIMARY KEY (id) USING BTREE, UNIQUE(nickname) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}messages (id int(10) unsigned NOT NULL AUTO_INCREMENT, postdate int(10) unsigned NOT NULL, poststatus tinyint(3) unsigned NOT NULL, poster varchar(50) NOT NULL, recipient varchar(50) NOT NULL, text varchar(20000) NOT NULL, delstatus tinyint(3) unsigned NOT NULL, PRIMARY KEY (id) USING BTREE, INDEX(poster) USING BTREE, INDEX(recipient) USING BTREE, INDEX(postdate) USING BTREE, INDEX(poststatus) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}notes (id int(10) unsigned NOT NULL AUTO_INCREMENT, type char(5) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, lastedited int(10) unsigned NOT NULL, editedby varchar(50) NOT NULL, text varchar(20000) NOT NULL, PRIMARY KEY (id) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}sessions (id int(10) unsigned NOT NULL AUTO_INCREMENT, session char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, nickname varchar(50) NOT NULL, status tinyint(3) unsigned NOT NULL, refresh tinyint(3) unsigned NOT NULL, style varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, lastpost int(10) unsigned NOT NULL, passhash char(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, postid char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '000000', boxwidth tinyint(3) unsigned NOT NULL DEFAULT 40, boxheight tinyint(3) unsigned NOT NULL DEFAULT 3, useragent varchar(255) NOT NULL, kickmessage varchar(255) NOT NULL, bgcolour char(6) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, notesboxheight tinyint(3) unsigned NOT NULL DEFAULT 30, notesboxwidth tinyint(3) unsigned NOT NULL DEFAULT 80, entry int(10) unsigned NOT NULL, timestamps tinyint(1) unsigned NOT NULL, embed tinyint(1) unsigned NOT NULL DEFAULT 1, incognito tinyint(1) unsigned NOT NULL DEFAULT 0, ip varchar(45) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, PRIMARY KEY (id) USING BTREE, UNIQUE(session) USING BTREE, UNIQUE(nickname) USING BTREE, INDEX(status) USING BTREE, INDEX(lastpost) USING BTREE) ENGINE=MEMORY DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}settings (setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL, value varchar(20000) NOT NULL, PRIMARY KEY (setting) USING BTREE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;");
        } elseif ($C['dbdriver'] === 1) {
            //PostgreSQL
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}captcha (id serial PRIMARY KEY, time integer NOT NULL, code char(5) NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}filter (id serial PRIMARY KEY, filtermatch varchar(255) NOT NULL, filterreplace varchar(20000) NOT NULL, allowinpm smallint NOT NULL, regex smallint NOT NULL, kick smallint NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}ignored (id serial PRIMARY KEY, ign varchar(50) NOT NULL, ignby varchar(50) NOT NULL);");
            $db->exec("CREATE INDEX ign ON {$C['prefix']}ignored (ign);");
            $db->exec("CREATE INDEX ignby ON {$C['prefix']}ignored (ignby);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}linkfilter (id serial PRIMARY KEY, filtermatch varchar(255) NOT NULL, filterreplace varchar(255) NOT NULL, regex smallint NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}members (id serial PRIMARY KEY, nickname varchar(50) NOT NULL UNIQUE, passhash char(32) NOT NULL, status smallint NOT NULL, refresh smallint NOT NULL, bgcolour char(6) NOT NULL, boxwidth smallint NOT NULL DEFAULT 40, boxheight smallint NOT NULL DEFAULT 3, notesboxheight smallint NOT NULL DEFAULT 30, notesboxwidth smallint NOT NULL DEFAULT 80, regedby varchar(50) DEFAULT '', lastlogin integer DEFAULT 0, timestamps smallint NOT NULL, embed smallint DEFAULT 1, incognito smallint DEFAULT 0, style varchar(255) NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}messages (id serial PRIMARY KEY, postdate integer NOT NULL, poststatus smallint NOT NULL, poster varchar(50) NOT NULL, recipient varchar(50) NOT NULL, text varchar(20000) NOT NULL, delstatus smallint NOT NULL);");
            $db->exec("CREATE INDEX poster ON {$C['prefix']}messages (poster);");
            $db->exec("CREATE INDEX recipient ON {$C['prefix']}messages (recipient);");
            $db->exec("CREATE INDEX postdate ON {$C['prefix']}messages (postdate);");
            $db->exec("CREATE INDEX poststatus ON {$C['prefix']}messages (poststatus);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}notes (id serial PRIMARY KEY, type char(5) NOT NULL, lastedited integer NOT NULL, editedby varchar(50) NOT NULL, text varchar(20000) NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}sessions (id serial PRIMARY KEY, session char(32) NOT NULL UNIQUE, nickname varchar(50) NOT NULL UNIQUE, status smallint NOT NULL, refresh smallint NOT NULL, style varchar(255) NOT NULL, lastpost integer NOT NULL, passhash char(32) NOT NULL, postid char(6) NOT NULL DEFAULT '000000', boxwidth smallint NOT NULL DEFAULT 40, boxheight smallint NOT NULL DEFAULT 3, useragent varchar(255) NOT NULL, kickmessage varchar(255) DEFAULT '', bgcolour char(6) NOT NULL, notesboxheight smallint NOT NULL DEFAULT 30, notesboxwidth smallint NOT NULL DEFAULT 80, entry integer NOT NULL, timestamps smallint NOT NULL, embed smallint DEFAULT 1, incognito smallint DEFAULT 0, ip varchar(45) NOT NULL);");
            $db->exec("CREATE INDEX status ON {$C['prefix']}sessions (status);");
            $db->exec("CREATE INDEX lastpost ON {$C['prefix']}sessions (lastpost);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}settings (setting varchar(50) PRIMARY KEY, value varchar(20000) NOT NULL);");
        } else {
            //sqlite
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}captcha (id INTEGER PRIMARY KEY, time INTEGER NOT NULL, code TEXT NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}filter (id INTEGER PRIMARY KEY, filtermatch TEXT NOT NULL, filterreplace TEXT NOT NULL, allowinpm INTEGER NOT NULL, regex INTEGER NOT NULL, kick INTEGER NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}ignored (id INTEGER PRIMARY KEY, ign TEXT NOT NULL, ignby TEXT NOT NULL);");
            $db->exec("CREATE INDEX IF NOT EXISTS ign ON {$C['prefix']}ignored (ign);");
            $db->exec("CREATE INDEX IF NOT EXISTS ignby ON {$C['prefix']}ignored (ignby);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}linkfilter (id INTEGER PRIMARY KEY, filtermatch TEXT NOT NULL, filterreplace TEXT NOT NULL, regex INTEGER NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}members (id INTEGER PRIMARY KEY, nickname TEXT NOT NULL UNIQUE, passhash TEXT NOT NULL, status INTEGER NOT NULL, refresh INTEGER NOT NULL, bgcolour TEXT NOT NULL, boxwidth INTEGER NOT NULL DEFAULT 40, boxheight INTEGER NOT NULL DEFAULT 3, notesboxheight INTEGER NOT NULL DEFAULT 30, notesboxwidth INTEGER NOT NULL DEFAULT 80, regedby TEXT DEFAULT '', lastlogin INTEGER DEFAULT 0, timestamps INTEGER NOT NULL, embed INTEGER NOT NULL DEFAULT 1, incognito INTEGER NOT NULL DEFAULT 0, style TEXT NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}messages (id INTEGER PRIMARY KEY, postdate INTEGER NOT NULL, poststatus INTEGER NOT NULL, poster TEXT NOT NULL, recipient TEXT NOT NULL, text TEXT NOT NULL, delstatus INTEGER NOT NULL);");
            $db->exec("CREATE INDEX IF NOT EXISTS poster ON {$C['prefix']}messages (poster);");
            $db->exec("CREATE INDEX IF NOT EXISTS recipient ON {$C['prefix']}messages (recipient);");
            $db->exec("CREATE INDEX IF NOT EXISTS postdate ON {$C['prefix']}messages (postdate);");
            $db->exec("CREATE INDEX IF NOT EXISTS poststatus ON {$C['prefix']}messages (poststatus);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}notes (id INTEGER PRIMARY KEY, type TEXT NOT NULL, lastedited INTEGER NOT NULL, editedby TEXT NOT NULL, text TEXT NOT NULL);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}sessions (id INTEGER PRIMARY KEY, session TEXT NOT NULL UNIQUE, nickname TEXT NOT NULL UNIQUE, status INTEGER NOT NULL, refresh INTEGER NOT NULL, style TEXT NOT NULL, lastpost INTEGER NOT NULL, passhash TEXT NOT NULL, postid TEXT NOT NULL DEFAULT '000000', boxwidth INTEGER NOT NULL DEFAULT 40, boxheight INTEGER NOT NULL DEFAULT 3, useragent TEXT NOT NULL, kickmessage TEXT DEFAULT '', bgcolour TEXT NOT NULL, notesboxheight INTEGER NOT NULL DEFAULT 30, notesboxwidth INTEGER NOT NULL DEFAULT 80, entry INTEGER NOT NULL, timestamps INTEGER NOT NULL, embed INTEGER NOT NULL DEFAULT 1, incognito INTEGER NOT NULL DEFAULT 0, ip TEXT NOT NULL);");
            $db->exec("CREATE INDEX IF NOT EXISTS status ON {$C['prefix']}sessions (status);");
            $db->exec("CREATE INDEX IF NOT EXISTS lastpost ON {$C['prefix']}sessions (lastpost);");
            $db->exec("CREATE TABLE IF NOT EXISTS {$C['prefix']}settings (setting TEXT NOT NULL PRIMARY KEY, value TEXT NOT NULL);");
        }
        $settings = array(array('guestaccess', '0'), array('globalpass', ''), array('englobalpass', '0'), array('captcha', '0'), array('dateformat', 'm-d H:i:s'), array('rulestxt', ''), array('msgencrypted', '0'), array('dbversion', $C['dbversion']), array('css', 'a:visited{color:#B33CB4;} a:active{color:#FF0033;} a:link{color:#0000FF;} input,select,textarea{color:#FFFFFF;background-color:#000000;} a img{width:15%} a:hover img{width:35%} .error{color:#FF0033;} .delbutton{background-color:#660000;} .backbutton{background-color:#004400;} #exitbutton{background-color:#AA0000;}'), array('memberexpire', '60'), array('guestexpire', '15'), array('kickpenalty', '10'), array('entrywait', '120'), array('messageexpire', '14400'), array('messagelimit', '150'), array('maxmessage', 2000), array('captchatime', '600'), array('colbg', '000000'), array('coltxt', 'FFFFFF'), array('maxname', '20'), array('minpass', '5'), array('defaultrefresh', '20'), array('dismemcaptcha', '0'), array('suguests', '0'), array('imgembed', '1'), array('timestamps', '1'), array('trackip', '0'), array('captchachars', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), array('memkick', '1'), array('forceredirect', '0'), array('redirect', ''), array('incognito', '1'), array('enablejs', '0'), array('chatname', 'My Chat'), array('topic', ''), array('msgsendall', $I['sendallmsg']), array('msgsendmem', $I['sendmemmsg']), array('msgsendmod', $I['sendmodmsg']), array('msgsendadm', $I['sendadmmsg']), array('msgsendprv', $I['sendprvmsg']), array('msgenter', $I['entermsg']), array('msgexit', $I['exitmsg']), array('msgmemreg', $I['memregmsg']), array('msgsureg', $I['suregmsg']), array('msgkick', $I['kickmsg']), array('msgmultikick', $I['multikickmsg']), array('msgallkick', $I['allkickmsg']), array('msgclean', $I['cleanmsg']), array('numnotes', '3'));
        $stmt = $db->prepare("INSERT INTO {$C['prefix']}settings (setting, value) VALUES (?, ?);");
        foreach ($settings as $pair) {
            $stmt->execute($pair);
        }
        if ($C['memcached']) {
            $memcached->delete("{$C['dbname']}-{$C['prefix']}num-tables");
        }
        $reg = array('nickname' => $_REQUEST['sunick'], 'passhash' => md5(sha1(md5($_REQUEST['sunick'] . $_REQUEST['supass']))), 'status' => 8, 'refresh' => 20, 'bgcolour' => '000000', 'timestamps' => 1, 'style' => 'color:#FFFFFF;');
        $stmt = $db->prepare("INSERT INTO {$C['prefix']}members (nickname, passhash, status, refresh, bgcolour, timestamps, style) VALUES (?, ?, ?, ?, ?, ?, ?);");
        $stmt->execute(array($reg['nickname'], $reg['passhash'], $reg['status'], $reg['refresh'], $reg['bgcolour'], $reg['timestamps'], $reg['style']));
        $suwrite = $I['susuccess'];
    }
    print_start('init');
    echo "<div style=\"text-align:center;\"><h2>{$I['init']}</h2><br><h3>{$I['sulogin']}</h3>{$suwrite}<br><br><br>";
    echo "<{$H['form']}>{$H['commonform']}" . hidden('action', 'setup') . submit($I['initgosetup']) . "</form>{$H['credit']}</div>";
    print_end();
}