/************************************************************************************************** * nullBB - Light CMS forum * * Copyright (C) 2009, BlackLight * * * * This program is free software: you can redistribute it and/or modify it under the terms of the * * GNU General Public License as published by the Free Software Foundation, either version 3 of * * the License, or (at your option) any later version. This program is distributed in the hope * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. You should have received a copy of the GNU General Public License along with * * this program. If not, see <http://www.gnu.org/licenses/>. * **************************************************************************************************/ require_once '../config.ini'; require_once ABSOLUTE_BASEPATH . '/db.' . PHPEXT; require_once ABSOLUTE_BASEPATH . '/utils.' . PHPEXT; if (!$_GET['user']) { die; } $db = new nullBB_Database($_CONF, $_LANG); $user = sanitizeQuery($_GET['user']); $user = str_replace('*', '%', $user); $res = $db->query("select user_id, username from " . $_CONF['dbprefix'] . 'users ' . "where username like '" . $user . "'"); if (empty($res)) { die; } foreach ($res as $row) { print getInt($row['user_id']) . ' # ' . sanitizeHTML($row['username']) . "\n"; } unset($res); $db->freeResult(); $db->close();
* Copyright (C) 2009, BlackLight * * * * This program is free software: you can redistribute it and/or modify it under the terms of the * * GNU General Public License as published by the Free Software Foundation, either version 3 of * * the License, or (at your option) any later version. This program is distributed in the hope * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. You should have received a copy of the GNU General Public License along with * * this program. If not, see <http://www.gnu.org/licenses/>. * **************************************************************************************************/ require_once '../config.ini'; require_once ABSOLUTE_BASEPATH . '/utils.' . PHPEXT; require_once ABSOLUTE_BASEPATH . '/session.' . PHPEXT; if ($_POST['username'] && $_POST['password']) { $db = new nullBB_Database($_CONF, $_LANG); $user = sanitizeQuery($_POST['username']); $res = $db->query('select * from ' . $_CONF['dbprefix'] . "users where username='******' " . "and user_password='******'password'])) . "'"); if (empty($res)) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['wrong_user_pass'], $_SERVER['HTTP_REFERER'], 3); die; } else { if ($res[0]['user_group'] > USERLEV_ADMIN) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['insufficient_privileges'] . ' -> ' . $res[0]['user_group'], $_SERVER['HTTP_REFERER'], 3); die; } setcookie('admin_sid', sha1(md5($res[0]['username'] . $res[0]['user_password']))); $user = sanitizeHTML($user); notification($_LANG['login_ok'] . ' ' . $user, $_SERVER['HTTP_REFERER'], 3); exit(0);
} $topic_id = getInt($_POST['topic_id']); $user_id = getInt($session->user_id); $db = new nullBB_Database($_CONF, $_LANG); $content = sanitizeQuery($_POST['content']); $forum = $db->query('select forum_id from ' . $_CONF['dbprefix'] . 'topics where ' . 'topic_id = ' . $topic_id); $db->freeResult(); if (empty($forum)) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['invalid_topic'], $_SERVER['HTTP_REFERER'], 3); die; } $forum_id = getInt($forum[0]['forum_id']); $ip = sanitizeQuery($_SERVER['REMOTE_ADDR']); $so = sanitizeQuery(getSO($_SERVER['HTTP_USER_AGENT'])); $browser = sanitizeQuery(getBrowser($_SERVER['HTTP_USER_AGENT'])); $res = $db->query('select forum_postgroup from ' . $_CONF['dbprefix'] . 'forums where ' . "forum_id='" . $forum_id . "'"); $db->freeResult(); $forum_postgroup = getInt($res[0]['forum_postgroup']); unset($res); if ($userinfo['user_group'] > $forum_postgroup) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['insufficient_privileges'], $_SERVER['HTTP_REFERER'], 3); die; } $res = $db->query('select topic_disabled from ' . $_CONF['dbprefix'] . 'topics ' . "where topic_id='{$id}'"); $db->freeResult(); $topic_disabled = getInt($res[0]['topic_disabled']); unset($res); if ($topic_disabled) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT;
if (empty($res)) { die; } $res2 = $db->query('select forum_id, forum_vieworder from ' . $_CONF['dbprefix'] . 'forums where forum_vieworder > ' . getInt($res[0]['forum_vieworder']) . ' and forum_vieworder <= all(' . 'select forum_vieworder from ' . $_CONF['dbprefix'] . 'forums where forum_vieworder > ' . getInt($res[0]['forum_vieworder']) . ')'); $db->query('update ' . $_CONF['dbprefix'] . 'forums set forum_vieworder=' . getInt($res[0]['forum_vieworder']) . ' where forum_id=' . getInt($res2[0]['forum_id'])); $db->query('update ' . $_CONF['dbprefix'] . 'forums set forum_vieworder=' . getInt($res2[0]['forum_vieworder']) . ' where forum_id=' . getInt($res[0]['forum_id'])); break; case 'edit_name': $value = sanitizeQuery($_REQUEST['value']); if (!$fid || !$value) { die; } $db->query('update ' . $_CONF['dbprefix'] . "forums set forum_name='" . $value . "' " . 'where forum_id=' . $fid); break; case 'edit_desc': $value = sanitizeQuery($_REQUEST['value']); if (!$fid || !$value) { die; } $db->query('update ' . $_CONF['dbprefix'] . "forums set forum_desc='" . $value . "' " . 'where forum_id=' . $fid); break; case 'view_privs': if (!$fid) { die; } $groups = array(); $res = $db->query('select * from ' . $_CONF['dbprefix'] . 'groups'); foreach ($res as $row) { $groups[$row['group_id']] = $row['group_name']; } $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
break; default: notification($_LANG['invalid_file_type'], $_SERVER['HTTP_REFERER'], 3); die; break; } } else { notification($_LANG['invalid_file_type'], $_SERVER['HTTP_REFERER'], 3); die; } if ($ext == 'jpg') { $ext = 'jpeg'; } $ascii = img2ascii($_FILES['avatarfile']['tmp_name'], $ext); if (!empty($ascii)) { $db->query('update ' . $_CONF['dbprefix'] . "users set user_avatar='" . sanitizeQuery($ascii) . "' " . "where user_id='" . getInt($uid) . "'"); } } if (isset($_POST['removeavatar'])) { $db->query('update ' . $_CONF['dbprefix'] . "users set user_avatar=null where user_id=" . getInt($uid)); } if (isset($_POST['removeuser'])) { $db->query('delete from ' . $_CONF['dbprefix'] . 'users where user_id=' . $uid); } if ($_POST['userlev'] != $results['user_group']) { $db->query('update ' . $_CONF['dbprefix'] . "users set user_group=" . getInt($_POST['userlev']) . ' where user_id=' . $uid); } if (isset($_POST['ban'])) { switch ($_POST['ban']) { case 'ban': if (!$results['user_disabled']) {
if (!$session->logged) { notification($_LANG['not_logged_in'], $_SERVER['HTTP_REFERER'], 3); die; } $db = new nullBB_Database($_CONF, $_LANG); if ($_POST['postMsg']) { if (!$_POST['subject'] || !$_POST['content'] || !$_POST['recv_id']) { notification($_LANG['no_info_specified'], $_SERVER['HTTP_REFERER'], 3); die; } if (preg_match('/^\\s+$/', $_POST['subject']) || preg_match('/^\\s+/', $_POST['content'])) { notification($_LANG['no_info_specified'], $_SERVER['HTTP_REFERER'], 3); die; } $subject = sanitizeQuery($_POST['subject']); $content = sanitizeQuery($_POST['content']); $recv_id = getInt($_POST['recv_id']); $send_id = getInt($userinfo['user_id']); $db->query('insert into ' . $_CONF['dbprefix'] . 'privmsgs(privmsg_subject, ' . 'privmsg_from, privmsg_to, privmsg_date, privmsg_ip, privmsg_seen, privmsg_content) values(' . "'" . $subject . "', " . $send_id . ", " . $recv_id . ", " . time() . ", '" . $_SERVER['REMOTE_ADDR'] . "', 0, '" . $content . "')"); $db->freeResult(); $db->close(); notification($_LANG['message_ok'], $_SERVER['HTTP_REFERER'], 3); die; } else { $user_id = getInt($userinfo['user_id']); ?> <center> > <a class="topicHead" href="<?php print BASEDIR; ?>
} $db->query('delete from ' . $_CONF['dbprefix'] . 'posts where post_id=' . $post_id); $res = $db->query('select count(*) as num from ' . $_CONF['dbprefix'] . 'posts where topic_id=' . $topic_id); $db->freeResult(); $num = getInt($res[0]['num']); if ($num == 0) { $db->query('delete from ' . $_CONF['dbprefix'] . 'topics where topic_id=' . $topic_id); } $db->close(); header("Location: " . $_SERVER['HTTP_REFERER']); die; } $res = $db->query('select poster_id from ' . $_CONF['dbprefix'] . 'posts ' . "where post_id='" . getInt($_POST['post_id']) . "'"); $db->freeResult(); if ($res[0]['poster_id'] != $userinfo['user_id'] && $userinfo['user_group'] > USERLEV_MOD) { notification("Invalid user", $_SERVER['HTTP_REFERER'], 3); die; } $db->query('update ' . $_CONF['dbprefix'] . 'posts set post_content=' . "'" . sanitizeQuery($_POST['post_content']) . "' where post_id='" . getInt($_POST['post_id']) . "'"); $res = $db->query('select count(*) as num from ' . $_CONF['dbprefix'] . 'posts where topic_id=' . $topic_id . ' ' . 'and post_time > ' . $post_time); $db->freeResult(); $num = getInt($res[0]['num']); if ($num > 0) { $db->query('update ' . $_CONF['dbprefix'] . 'posts set post_lastedit_date=' . time() . ', ' . 'post_lastedit_user='******'user_id'] . ' where post_id=' . $post_id); } $db->close(); header("Location: " . $_SERVER['HTTP_REFERER']); die; ?>
<?php } else { if (!$_POST['search_string'] && !$_POST['search_author']) { notification($_LANG['insufficient_search_parameters'], $_SERVER['HTTP_REFERER'], 3); die; } $db = new nullBB_Database($_CONF, $_LANG); if ($_POST['search_string']) { $string = sanitizeQuery($_POST['search_string']); } if ($_POST['search_author']) { if ($_POST['search_author'] == '*') { $_POST['search_author'] = null; } else { $author = sanitizeQuery($_POST['search_author']); $author = str_replace('*', '%', $author); } } if ($string && $author) { $res = $db->query('select f.forum_id, t.topic_id, p.post_id, u_topic.user_id as topic_user_id, u_post.user_id as post_user_id, p.post_time, forum_name, topic_title, u_topic.username as topic_author, u_post.username as post_author, topic_replies from ' . $_CONF['dbprefix'] . 'users u_topic join ' . $_CONF['dbprefix'] . 'forums f join ' . $_CONF['dbprefix'] . 'posts p join ' . $_CONF['dbprefix'] . 'topics t join ' . $_CONF['dbprefix'] . 'users u_post on f.forum_id=t.forum_id and p.topic_id=t.topic_id and p.forum_id=f.forum_id ' . "and p.poster_id=u_post.user_id and t.topic_poster=u_topic.user_id where post_content like '%" . $string . "%' " . "and u_post.username like '" . $author . "' order by p.post_time desc"); } else { if (!$author) { $res = $db->query('select f.forum_id, t.topic_id, p.post_id, u_topic.user_id as topic_user_id, u_post.user_id as post_user_id, p.post_time, forum_name, topic_title, u_topic.username as topic_author, u_post.username as post_author, topic_replies from ' . $_CONF['dbprefix'] . 'users u_topic join ' . $_CONF['dbprefix'] . 'forums f join ' . $_CONF['dbprefix'] . 'posts p join ' . $_CONF['dbprefix'] . 'topics t join ' . $_CONF['dbprefix'] . 'users u_post on f.forum_id=t.forum_id and p.topic_id=t.topic_id and p.forum_id=f.forum_id ' . "and p.poster_id=u_post.user_id and t.topic_poster=u_topic.user_id where post_content like '%" . $string . "%' " . "order by p.post_time desc"); } else { if (!$string) { $res = $db->query('select f.forum_id, t.topic_id, p.post_id, u_topic.user_id as topic_user_id, u_post.user_id as post_user_id, p.post_time, forum_name, topic_title, u_topic.username as topic_author, u_post.username as post_author, topic_replies from ' . $_CONF['dbprefix'] . 'users u_topic join ' . $_CONF['dbprefix'] . 'forums f join ' . $_CONF['dbprefix'] . 'posts p join ' . $_CONF['dbprefix'] . 'topics t join ' . $_CONF['dbprefix'] . 'users u_post on f.forum_id=t.forum_id and p.topic_id=t.topic_id and p.forum_id=f.forum_id ' . "and p.poster_id=u_post.user_id and t.topic_poster=u_topic.user_id " . "where u_post.username like '" . $author . "' order by p.post_time desc"); } } } $db->freeResult();
die; } $db = new nullBB_Database($_CONF, $_LANG); $forum_id = getInt($_POST['forum_id']); $forum = $db->query('select forum_id from ' . $_CONF['dbprefix'] . 'forums where ' . 'forum_id = ' . $forum_id); $db->freeResult(); if (empty($forum)) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['invalid_forum'], $_SERVER['HTTP_REFERER'], 3); die; } $res = $db->query('select forum_postgroup from ' . $_CONF['dbprefix'] . 'forums where ' . "forum_id='" . $forum_id . "'"); $db->freeResult(); $forum_postgroup = getInt($res[0]['forum_postgroup']); unset($res); if ($userinfo['user_group'] > $forum_postgroup) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['insufficient_privileges'], $_SERVER['HTTP_REFERER'], 3); die; } $user_id = getInt($session->user_id); $topic_title = sanitizeQuery($_POST['topic_title']); unset($forum); $db->query('insert into ' . $_CONF['dbprefix'] . 'topics(forum_id, topic_title, topic_poster, topic_time) values(' . "'{$forum_id}', '{$topic_title}', '{$user_id}', '" . time() . "')"); $res = $db->query('select topic_id from ' . $_CONF['dbprefix'] . 'topics order by topic_id desc limit 1'); $db->freeResult(); $_POST['topic_id'] = $res[0]['topic_id']; $topic_id = getInt($_POST['topic_id']); unset($res); $db->close(); require_once ABSOLUTE_BASEPATH . '/insertPost.' . PHPEXT;
} $pass = sha1(md5($pass)); $email = $_POST['email']; $captcha = $_POST['captcha']; $input_captcha = md5(md5($_POST['input_captcha'])); if ($captcha != $input_captcha) { notification($_LANG['wrong_captcha'], $_SERVER['HTTP_REFERER'], 3); die; } $res = $db->query('select user_id from ' . $_CONF['dbprefix'] . "users where username='******'"); if (!empty($res)) { notification($_LANG['taken_username'], $_SERVER['HTTP_REFERER'], 3); die; } $web = isset($_POST['website']) ? sanitizeQuery($_POST['website']) : ''; $msn = isset($_POST['msn']) ? sanitizeQuery($_POST['msn']) : ''; $db->query('insert into ' . $_CONF['dbprefix'] . 'users(username,user_password,user_email,user_website,user_msn,user_regtime) values(' . "'{$user}', '{$pass}', '{$email}', '{$web}', '{$msn}', '" . time() . "')"); $session = new nullBB_Session(array('username' => $user), $_CONF, $_LANG); require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['login_ok'] . ' ' . sanitizeHTML($user), BASEDIR, 3); die; } else { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; require_once ABSOLUTE_BASEPATH . '/gen_captcha.' . PHPEXT; ?> <center> > <a class="topicHead" href="<?php print BASEDIR; ?> "><?php
next($r[0]); $d = $r[0][key($r[0])] . ";"; $SQL .= str_replace("\n", "", $d) . "\n"; $table_query = $db->query("SELECT * FROM `{$table}`"); foreach ($table_query as $row) { $num_fields = 0; foreach ($table_query[0] as $field => $value) { $num_fields++; } } foreach ($table_query as $row) { $insert_sql .= "INSERT INTO {$table} VALUES("; $i = 0; foreach ($row as $field => $value) { if ($value != null) { $insert_sql .= "'" . sanitizeQuery($value) . "'"; } else { $insert_sql .= "NULL"; } if ($i < $num_fields - 1) { $insert_sql .= ', '; } $i++; } $insert_sql .= ");"; } if ($insert_sql != "") { $SQL .= $insert_sql . "\n"; } } }
function __construct($data, $conf, $lang) { $this->_CONF = $conf; $this->_LANG = $lang; if (isset($data['username'])) { $db = new nullBB_Database($this->_CONF, $this->_LANG); $username = stripslashes(strtolower($data['username'])); $username = sanitizeQuery($username); $user_res = $db->query('select user_id, user_password from ' . $this->_CONF['dbprefix'] . "users where username='******' limit 1"); $db->freeResult(); if (empty($user_res)) { die($this->_LANG['invalid_session']); } $this->user_id = intval($user_res[0]['user_id']); $this->session_time = time(); $pass = $user_res[0]['user_password']; $this->session_id = sha1($username . $pass . $this->session_time); unset($user_res); $session_res = $db->query('select session_time from ' . $this->_CONF['dbprefix'] . "sessions where user_id='" . $this->user_id . "' limit 1"); $db->freeResult(); if ($session_res[0]['session_time']) { $this->session_lasttime = $session_res[0]['session_time']; $db->query('delete from ' . $this->_CONF['dbprefix'] . 'sessions where user_id=' . $this->user_id); unset($session_res); } else { if (isset($_COOKIE['lasttime'])) { $this->session_lasttime = intval($_COOKIE['lasttime']); } else { $this->session_lasttime = 0; } } $db->query('insert into ' . $this->_CONF['dbprefix'] . 'sessions(session_id, user_id, session_time, session_lasttime) values(' . "'" . $this->session_id . "', '" . $this->user_id . "', '" . $this->session_time . "', '" . $this->session_lasttime . "')"); $this->logged = true; setcookie('sid', $this->session_id, time() + 15 * 24 * 60 * 60, BASEDIR); $db->close(); } else { if (isset($data['sid'])) { $db = new nullBB_Database($this->_CONF, $this->LANG); $sid = stripslashes(strtolower($data['sid'])); $sid = sanitizeQuery($sid); $res = $db->query('select * from ' . $this->_CONF['dbprefix'] . "sessions where session_id='{$sid}'"); $db->freeResult(); if (empty($res)) { return; } $this->user_id = $res[0]['user_id']; $this->session_id = $res[0]['session_id']; $this->session_time = $res[0]['session_time']; if ($res[0]['session_lasttime']) { $this->session_lasttime = intval($res[0]['session_lasttime']); } else { if ($_COOKIE['lasttime']) { $this->session_lasttime = intval($_COOKIE['lasttime']); } else { $this->session_lasttime = 0; } } $this->logged = true; unset($res); } } }
* nullBB - Light CMS forum * * Copyright (C) 2009, BlackLight * * * * This program is free software: you can redistribute it and/or modify it under the terms of the * * GNU General Public License as published by the Free Software Foundation, either version 3 of * * the License, or (at your option) any later version. This program is distributed in the hope * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. You should have received a copy of the GNU General Public License along with * * this program. If not, see <http://www.gnu.org/licenses/>. * **************************************************************************************************/ if ($_REQUEST['admin_username'] && $_REQUEST['admin_password'] && $_REQUEST['admin_password_again'] && $_REQUEST['admin_email']) { $user = sanitizeQuery($_REQUEST['admin_username']); $pass = $_REQUEST['admin_password']; $passagain = $_REQUEST['admin_password_again']; $email = sanitizeQuery($_REQUEST['admin_email']); if ($pass != $passagain) { die($_LANG['not_matching_passwords']); } $sql = "drop table if exists " . $_CONF["dbprefix"] . "forums;\n" . "drop table if exists " . $_CONF["dbprefix"] . "topics;\n" . "drop table if exists " . $_CONF["dbprefix"] . "posts;\n" . "drop table if exists " . $_CONF["dbprefix"] . "privmsgs;\n" . "drop table if exists " . $_CONF["dbprefix"] . "users;\n" . "drop table if exists " . $_CONF["dbprefix"] . "sessions;\n" . "drop table if exists " . $_CONF["dbprefix"] . "karma;\n" . "drop table if exists " . $_CONF["dbprefix"] . "groups;\n" . "drop table if exists " . $_CONF["dbprefix"] . "viewtopics;\n" . "\n" . "drop view if exists " . $_CONF["dbprefix"] . "newtopics;\n" . "\n" . "drop trigger if exists insTopic;\n" . "drop trigger if exists insPost;\n" . "drop trigger if exists delPost;\n" . "drop trigger if exists delUser;\n" . "drop trigger if exists delTopic;\n" . "\n" . "create table " . $_CONF["dbprefix"] . "forums(\n" . "forum_id \t\t\tinteger unsigned not null auto_increment,\n" . "forum_name \t\tvarchar(150),\n" . "forum_desc \t\ttext,\n" . "forum_posts \t\tinteger unsigned default 0,\n" . "forum_topics \t\tinteger unsigned default 0,\n" . "forum_lasttopic \tinteger unsigned not null default 0,\n" . "forum_lastpost \tinteger unsigned not null default 0,\n" . "forum_lasttime \tinteger unsigned not null default 0,\n" . "forum_viewgroup \tsmallint default 20 not null,\n" . "forum_postgroup \tsmallint default 10 not null,\n" . "forum_vieworder \tinteger unsigned not null default 0,\n" . "\n" . "primary key(forum_id),\n" . "foreign key(forum_lasttopic) \treferences " . $_CONF["dbprefix"] . "topics(topic_id),\n" . "foreign key(forum_lastpost) \treferences " . $_CONF["dbprefix"] . "posts(post_id),\n" . "foreign key(forum_lasttime) \treferences " . $_CONF["dbprefix"] . "posts(post_time),\n" . "foreign key(forum_viewgroup) \treferences " . $_CONF["dbprefix"] . "groups(group_id),\n" . "foreign key(forum_postgroup) \treferences " . $_CONF["dbprefix"] . "groups(group_id)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "topics(\n" . "topic_id \t\t\tinteger unsigned not null auto_increment,\n" . "forum_id \t\t\tinteger unsigned not null,\n" . "topic_title \t\tvarchar(128),\n" . "topic_poster \t\tinteger unsigned not null,\n" . "topic_time \t\tinteger unsigned default 0,\n" . "topic_replies \t\tinteger unsigned default 0,\n" . "topic_lastreply \tinteger unsigned not null default 0,\n" . "topic_disabled \tboolean default 0 not null,\n" . "topic_sticked \t\tboolean default 0 not null,\n" . "\n" . "primary key(topic_id),\n" . "foreign key(forum_id) \t\treferences " . $_CONF["dbprefix"] . "forums(forum_id),\n" . "foreign key(topic_poster) \treferences " . $_CONF["dbprefix"] . "users(user_id),\n" . "foreign key(topic_lastreply) \treferences " . $_CONF["dbprefix"] . "posts(post_id)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "posts(\n" . "post_id \t\t\tinteger unsigned not null auto_increment,\n" . "topic_id \t\t\tinteger unsigned not null,\n" . "forum_id \t\t\tinteger unsigned not null,\n" . "poster_id \t\tinteger unsigned not null,\n" . "poster_ip \t\tvarchar(40) not null,\n" . "poster_so \t\tvarchar(64),\n" . "poster_browser \tvarchar(64),\n" . "post_time \t\tinteger unsigned default 0,\n" . "post_content \t\ttext,\n" . "post_lastedit_date \tinteger unsigned default null,\n" . "post_lastedit_user \tinteger unsigned default null,\n" . "\n" . "primary key(post_id),\n" . "foreign key(topic_id) \t\treferences " . $_CONF["dbprefix"] . "topics(topic_id),\n" . "foreign key(forum_id) \t\treferences " . $_CONF["dbprefix"] . "forums(forum_id),\n" . "foreign key(poster_id) \t\treferences " . $_CONF["dbprefix"] . "useres(user_id)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "privmsgs(\n" . "privmsg_id \t\tinteger unsigned not null auto_increment,\n" . "privmsg_subject \tvarchar(255),\n" . "privmsg_from \t\tinteger unsigned not null,\n" . "privmsg_to \t\tinteger unsigned not null,\n" . "privmsg_date \t\tinteger unsigned not null,\n" . "privmsg_ip \t\tvarchar(40) not null,\n" . "privmsg_seen \t\tboolean default 0,\n" . "privmsg_content \ttext,\n" . "\n" . "primary key(privmsg_id),\n" . "foreign key(privmsg_from) \treferences " . $_CONF["dbprefix"] . "users(user_id),\n" . "foreign key(privmsg_to) \treferences " . $_CONF["dbprefix"] . "users(user_id)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "users(\n" . "user_id \t\t\tinteger unsigned not null auto_increment,\n" . "username \t\t\tvarchar(25) unique not null,\n" . "user_password \t\tvarchar(60) not null,\n" . "user_posts \t\tinteger unsigned default 0 not null,\n" . "user_email \t\tvarchar(60) unique not null,\n" . "user_website \t\tvarchar(60),\n" . "user_msn \t\t\tvarchar(60),\n" . "user_karma \t\tinteger default 0 not null,\n" . "user_regtime \t\tinteger unsigned default 0 not null,\n" . "user_disabled \t\tboolean default false not null,\n" . "user_group \t\tsmallint default 10 not null,\n" . "user_signature \ttext,\n" . "user_avatar \t\ttext,\n" . "user_viewavatars \tboolean default 0,\n" . "user_theme \t\tvarchar(60) default '" . $_CONF['theme'] . "',\n" . "user_language \tvarchar(50) default '" . BOARD_LANGUAGE . "',\n" . "\n" . "primary key(user_id),\n" . "foreign key(user_group) references " . $_CONF["dbprefix"] . "groups(group_id)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "sessions(\n" . "session_id \t\tvarchar(60) not null,\n" . "user_id \t\t\tinteger unsigned not null,\n" . "session_time \t\tinteger unsigned default 0 not null,\n" . "session_lasttime \tinteger unsigned default 0 not null,\n" . "\n" . "primary key(session_id),\n" . "foreign key(user_id) \t\treferences " . $_CONF["dbprefix"] . "users(user_id)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "karma(\n" . "user_id \t\t\tinteger unsigned default 0 not null,\n" . "voter \t\t\tinteger unsigned default 0 not null,\n" . "vote \t\t\tinteger default 0,\n" . "\n" . "primary key(user_id, voter),\n" . "foreign key(user_id) \t\treferences " . $_CONF["dbprefix"] . "karma(user_id),\n" . "foreign key(voter) \t\t\treferences " . $_CONF["dbprefix"] . "karma(voter)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "groups(\n" . "group_id \t\t\tsmallint not null,\n" . "group_name \t\tvarchar(20),\n" . "primary key(group_id)\n" . ");\n" . "\n" . "create table " . $_CONF["dbprefix"] . "viewtopics(\n" . "user_id \t\t\tinteger unsigned not null,\n" . "topic_id \t\t\tinteger unsigned not null,\n" . "viewtime \t\t\tinteger unsigned not null,\n" . "\n" . "primary key(user_id, topic_id),\n" . "foreign key(user_id) references " . $_CONF["dbprefix"] . "users(user_id),\n" . "foreign key(topic_id) references " . $_CONF["dbprefix"] . "topics(topic_id)\n" . ");\n" . "\n" . "create view " . $_CONF["dbprefix"] . "newtopics\n" . "as\n" . "select f.forum_id, f.forum_name, t.topic_id, t.topic_title, t.topic_lastreply,\n" . "p.poster_id, u.username as last_poster, p.post_time\n" . "from " . $_CONF["dbprefix"] . "forums f join " . $_CONF["dbprefix"] . "topics t join " . $_CONF["dbprefix"] . "posts p join " . $_CONF["dbprefix"] . "users u\n" . "on f.forum_id=t.forum_id\n" . "and f.forum_id=p.forum_id\n" . "and p.topic_id=t.topic_id\n" . "and t.topic_lastreply=p.post_id\n" . "and p.poster_id=u.user_id\n" . "where p.post_id=t.topic_lastreply\n" . "order by p.post_time desc;\n" . "insert into " . $_CONF["dbprefix"] . "groups(group_id, group_name) values(" . USERLEV_GOD . ", 'God');\n" . "insert into " . $_CONF["dbprefix"] . "groups(group_id, group_name) values(" . USERLEV_ADMIN . ", 'Admin');\n" . "insert into " . $_CONF["dbprefix"] . "groups(group_id, group_name) values(" . USERLEV_GLOBALMOD . ", 'Global mod');\n" . "insert into " . $_CONF["dbprefix"] . "groups(group_id, group_name) values(" . USERLEV_MOD . ", 'Mod');\n" . "insert into " . $_CONF["dbprefix"] . "groups(group_id, group_name) values(" . USERLEV_USER . ", 'User');\n" . "insert into " . $_CONF["dbprefix"] . "groups(group_id, group_name) values(" . USERLEV_ANY . ", 'Any');\n" . "insert into " . $_CONF["dbprefix"] . "groups(group_id, group_name) values(" . USERLEV_BANNED . ", 'Banned');\n" . "insert into " . $_CONF["dbprefix"] . "users(user_id, username, user_password, user_group, user_regtime, user_email) values(1,'" . $user . "', '" . sha1(md5($pass)) . "', '" . USERLEV_GOD . "', '" . time() . "', '{$email}')\n"; $db = new nullBB_Database($_CONF, $_LANG); foreach (explode(';', $sql) as $query) { $db->query(trim($query)); } $sql = "create trigger insTopic\n" . "after insert\n" . "on " . $_CONF["dbprefix"] . "topics\n" . "for each row\n" . "begin\n" . "select forum_topics into @num from " . $_CONF["dbprefix"] . "forums where forum_id = new.forum_id;\n" . "update " . $_CONF["dbprefix"] . "forums set forum_topics = @num + 1 where forum_id = new.forum_id;\n" . "update " . $_CONF["dbprefix"] . "forums set forum_lasttopic = new.topic_id where forum_id = new.forum_id;\n" . "end;"; $db->query($sql); $sql = "create trigger insPost\n" . "after insert\n" . "on " . $_CONF["dbprefix"] . "posts\n" . "for each row\n" . "begin\n" . "select forum_posts into @num from " . $_CONF["dbprefix"] . "forums where forum_id = new.forum_id;\n" . "update " . $_CONF["dbprefix"] . "forums set forum_posts = @num + 1 where forum_id = new.forum_id;\n" . "select topic_replies into @num from " . $_CONF["dbprefix"] . "topics where topic_id = new.topic_id;\n" . "update " . $_CONF["dbprefix"] . "topics set topic_replies = @num + 1 where topic_id = new.topic_id;\n" . "select user_posts into @num from " . $_CONF["dbprefix"] . "users where user_id = new.poster_id;\n" . "update " . $_CONF["dbprefix"] . "users set user_posts = @num + 1 where user_id = new.poster_id;\n" . "update " . $_CONF["dbprefix"] . "topics set topic_lastreply = new.post_id where topic_id = new.topic_id;\n" . "update " . $_CONF["dbprefix"] . "forums set forum_lastpost = new.post_id where forum_id = new.forum_id;\n" . "update " . $_CONF["dbprefix"] . "forums set forum_lasttime = new.post_time where forum_id = new.forum_id;\n" . "end;"; $db->query($sql); $sql = "create trigger delUser\n" . "after delete\n" . "on " . $_CONF["dbprefix"] . "users\n" . "for each row\n" . "begin\n" . "update " . $_CONF["dbprefix"] . "topics set topic_poster=0 where topic_poster=old.user_id;\n" . "update " . $_CONF["dbprefix"] . "posts set poster_id=0 where poster_id=old.user_id;\n" . "end;\n"; $db->query($sql); /* DUMP, STUPID, ASSHOLE MySQL
* the License, or (at your option) any later version. This program is distributed in the hope * * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. You should have received a copy of the GNU General Public License along with * * this program. If not, see <http://www.gnu.org/licenses/>. * **************************************************************************************************/ require_once './config.ini'; require_once ABSOLUTE_BASEPATH . '/languages/' . BOARD_LANGUAGE . '.lang'; require_once ABSOLUTE_BASEPATH . '/utils.' . PHPEXT; require_once ABSOLUTE_BASEPATH . '/db.' . PHPEXT; if (!$_GET['user_id']) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['no_user'], $_SERVER['HTTP_REFERER'], 3); die; } $user_id = getInt($_GET['user_id']); $db = new nullBB_Database($_CONF, $_LANG); $res = $db->query('select username from ' . $_CONF['dbprefix'] . 'users ' . 'where user_id=' . $user_id); $db->freeResult(); if (empty($res)) { require_once ABSOLUTE_BASEPATH . '/header.' . PHPEXT; notification($_LANG['user_not_found'], $_SERVER['HTTP_REFERER'], 3); die; } $_POST = array(); $_POST['search'] = true; $_POST['search_author'] = sanitizeQuery($res[0]['username']); require_once ABSOLUTE_BASEPATH . '/search.' . PHPEXT; ?>