Registered Member #27 Joined: Sat Nov 07 2009, 15:40:14 Posts: 13
| While waiting for QdbS v2 I decided to release this vBulletin bridge.
This bridge is tested on vBulletin 3.8.5 only. I am not sure about 3.6-3.8.4, but one thing is sure that it won't work for vB4.
Features:
- Requires login to add quote and rate
- Log username rate with IP
- (WORKING)Admin panel integration (see below if you want to help)
- (WORKING)Use vB BBcode parser when adding quote
Install steps: 1. Run this SQL query:
ALTER TABLE `(tableprefix)_votes` ADD `username` VARCHAR( 255 ) NULL AFTER `id`;
ALTER TABLE `(tableprefix)_quotes` ADD `submitter` VARCHAR( 255 ) NOT NULL AFTER `quote`;
ALTER TABLE `(tableprefix)_queue` ADD `submitter` VARCHAR( 255 ) NOT NULL AFTER `quote`;
2. Put this in anywhere of your function.php. If you have not installed BBcode parsing, make a new file called function.php and put the following content:
function input_filter($ncode)
{
$ncode = preg_replace('/[^ _A-Za-z0-9-]/', '', $ncode);
return $ncode;
}
If you have intsalled BBcode parsing before skip this step. 2a: Open classes.php, find:
include("settings.php");
Add below:
include("functions.php");
3. Create new file called login.php and put in the following content:
<?php
/**************************************************************************
This file is part of the Quotes Database System (QdbS)
Copyright (C) 2003-2010 QdbS.org
Written by Kyle Florence (kyle.florence@gmail.com)
Maintained by Matthew Beeching (jobe@qdbs.org)
Table Prefix patch by Thomas Ward (jouva@moufette.com)
vBulletin bridging by Timothy Choi AKA tyteen4a03 (tyteen4a03@hk-diy.net)
Login script by Evan Holloway AKA The Evina (evan@evinext.com)
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/>.
***************************************************************************/
include('classes.php');
if (isset($_POST['username']) && isset($_POST['user_password']) && $_POST['validlogin']) {
$_SESSION['logged-in'] = true;
}
if ($_POST['validlogin'] != true) {
print($tpl->fetch($tpl->tdir.'layout_header.tpl'));
print($tpl->fetch($tpl->tdir.'invalid_action.tpl'));
print($tpl->fetch($tpl->tdir.'layout_footer.tpl'));
die;
}
if ($_SESSION['logged-in']) {
if ($_POST['validlogin'] == true) {
$_SESSION['validlogin'] == true;
$_SESSION['username'] = htmlspecialchars($_POST['username']);
if ($_POST['remember_me']) {
$expire = time()+60*60*24*30;
setcookie('qdbs_user', $_SESSION['username'], $expire);
setcookie('qdbs_pass', $_SESSION['user_password'], $expire);
} elseif (!$_POST['remember_me'] && isset($_COOKIE['qdbs_user'])) {
// Destroy the cookies
$expire = time()-60*60*24*30;
setcookie('qdbs_user', '', $expire);
setcookie('qdbs_pass', '', $expire);
}
}
if ($_qdbs[vb_db] != $qdbs[db]) {
mysql_select_db($_qdbs[vb_db]);
}
$q = mysql_query("SELECT salt,password,usergroupid,membergroupids FROM ".$_qdbs[vb_tpfx]."user WHERE username='".$_SESSION['username']."'");
$uinfo = mysql_fetch_assoc($q);
$password_code = md5(md5($_POST['user_password']) . $uinfo['salt']);
if ($password_code != $uinfo['password']) {
session_start();
session_unset();
session_destroy();
print($tpl->fetch($tpl->tdir.'layout_header.tpl'));
print($tpl->fetch($tpl->tdir.'wrong_password.tpl'));
print($tpl->fetch($tpl->tdir.'layout_footer.tpl'));
die;
}
$ugroup['main'] = $uinfo['usergroupid'];
$ugroup['ext'] = $uinfo['membergroupids'] ? explode(',',$uinfo['membergroupids']) : '';
#Admin->Supermod->Mod check
if ($ugroup['main'] == 5 or in_array(6, $ugroup['ext'])) {
$_SESSION['alevel'] == 3;
} elseif ($ugroup['main'] == 5 or in_array(5, $ugroup['ext'])) {
$_SESSION['alevel'] == 2;
} elseif ($ugroup['main'] == 7 or in_array(7, $ugroup['ext'])) {
$_SESSION['alevel'] == 1;
} else {
$_SESSION['alevel'] == 0;
}
print($tpl->fetch($tpl->tdir.'layout_header.tpl'));
print($tpl->fetch($tpl->tdir.'login_success.tpl'));
print($tpl->fetch($tpl->tdir.'layout_footer.tpl'));;
die;
} else {
// See if this page was from index
if ($_POST['validlogin']) {
print($tpl->fetch($tpl->tdir.'layout_header.tpl'));
print($tpl->fetch($tpl->tdir.'quote_fieldmissing.tpl'));
print($tpl->fetch($tpl->tdir.'layout_footer.tpl'));;
die;
}
// Else tell the user to log in
else {
print($tpl->fetch($tpl->tdir.'layout_header.tpl'));
print($tpl->fetch($tpl->tdir.'please_login.tpl'));
print($tpl->fetch($tpl->tdir.'layout_footer.tpl'));
die;
}
}
?>
4. Edit index.php Find:
case 'rate':
Add below:
if (!$_SESSION['logged-in') {
print($tpl->fetch($tpl->tdir.'layout_header.tpl'));
print($tpl->fetch($tpl->tdir.'please_login.tpl'));
print($tpl->fetch($tpl->tdir.'layout_footer.tpl'));
break;
}
Find:
$sql = "INSERT INTO ".$_qdbs[tpfx]."votes (id,rate,ip) VALUES ('".mysql_real_escape_string($_GET['q'])."', 'up', '".mysql_real_escape_string($ip)."')";
Replace with:
$sql = "INSERT INTO ".$_qdbs[tpfx]."votes (id,username,rate,ip) VALUES ('".mysql_real_escape_string($_GET['q'])."', '{$_SESSION['username']}', 'up', '".mysql_real_escape_string($ip)."')";
Find:
$sql = "INSERT INTO ".$_qdbs[tpfx]."votes (id,rate,ip) VALUES ('".mysql_real_escape_string($_GET['q'])."', 'down', '".mysql_real_escape_string($ip)."')";
Replace with:
$sql = "INSERT INTO ".$_qdbs[tpfx]."votes (id,username,rate,ip) VALUES ('".mysql_real_escape_string($_GET['q'])."', '{$_SESSION['username']}', 'down', '".mysql_real_escape_string($ip)."')";
Find:
$tpl->set('q_submitter', $row['submitter']);
Add below for ALL MATCHES
$tpl->set('q_submitter', $row['submitter']);
Find:
$quote = nl2br($quote);
Add below:
$submitter = $_SESSION['username'];
if (!$_SESSION['logged-in']) {
print($tpl->fetch($tpl->tdir.'layout_header.tpl'));
print($tpl->fetch($tpl->tdir.'please_login.tpl'));
print($tpl->fetch($tpl->tdir.'layout_footer.tpl'));
break;
}
elseif (!$quote)
{
print($tpl->fetch($tpl->tdir.'quote_fieldmissing.tpl'));
}
Find:
if (ini_get("magic_quotes_runtime") or ini_get("magic_quotes_gpc")) {
$sql = "INSERT INTO ".$_qdbs[tpfx]."queue (id,quote) VALUES ('NULL', '".mysql_real_escape_string(stripslashes($quote))."')";
} else {
$sql = "INSERT INTO ".$_qdbs[tpfx]."queue (id,quote) VALUES ('NULL', '".mysql_real_escape_string($quote)."')";
}
Replace with:
if (ini_get("magic_quotes_runtime") or ini_get("magic_quotes_gpc")) {
$sql = "INSERT INTO ".$_qdbs[tpfx]."queue (id,quote,submitter) VALUES ('NULL', '".mysql_real_escape_string(stripslashes($quote))."', '".mysql_real_escape_string(stripslashes($submitter))."' )";
} else {
$sql = "INSERT INTO ".$_qdbs[tpfx]."queue (id,quote,submitter) VALUES ('NULL', '".mysql_real_escape_string($quote)."', '".mysql_real_escape_string($submitter)."' )";
}
Find:
switch ($_GET['p']) {
Add below:
case 'login':
print($tpl->fetch($tpl->tdir.'login_form.tpl'));
break;
Continued in the next post...
[ Edited Sun Aug 01 2010, 10:54:41 ] |