Strangely enough I had issues when trying to upgrade from 2.x and now that I'm just trying a fresh install with 3.1.0 it just errors out when trying to login to the admin page
Unable to open connection to MySQL server.
Yes the database info is correct in config.php - tried with multiple databases.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
define('SB_DB', false); //ONLY SET TRUE IF SOURCEBANS IS ON A DIFFERENT MYSQL SERVER
define('SB_SV_HOST', 'localhost'); //set MySQL host ONLY NEEDED IF SOURCEBANS IS ON A DIFFERENT MYSQL SERVER
define('SB_SV_USER', 'strike_sb'); //MySQL username ONLY NEEDED IF SOURCEBANS IS ON A DIFFERENT MYSQL SERVER
define('SB_SV_PASS', 'database_password'); //MySQL password ONLY NEEDED IF SOURCEBANS IS ON A DIFFERENT MYSQL SERVER
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
define('SOURCEBANS_DB', 'strike_sb'); // sourcebans database, this is needed.
define('SB_PREFIX', 'sb_'); //Sourcebans database prefix. Only change this value if you changed your database prefix when setting up SourceBans.
define('SB_SALT', 'SourceBans'); //dont change this unless you changed your salt in sourcebans (if you dont know what salt is, you didnt change it)
define('SB_ADMINS', 'FULL-Owner'); //name of admin group in sourcebans which has access to the donor panel
///////////////////////////////////////////////////////////////////////////////////////////
//Edit
fixed it.. i tried using it on a separate database then i saw
Alright, so I found that the change I made allows people already in the database to donate and be updated in the database, but if an existing donator tries to upgrade or someone donating for the first time (who also isn't in the sourceban database at all yet), then it won't add/update them.
Spoiler
PHP Code:
<?php
if (!defined('NineteenEleven')) { die('Direct access not premitted'); } require_once ABSDIR . "includes/GroupsClass.php"; require_once ABSDIR . 'scripts/rcon_code.php';
class sb extends groups {
public $sdb; public $ddb;
public function __construct() {
try { $this->sdb = new PDO('mysql:host=' . SB_HOST . ';dbname=' . SOURCEBANS_DB . ';charset=utf8', SB_USER, SB_PASS); $this->sdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->sdb->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } catch (Exception $ex) { throw new Exception("Unable to connect to Sourcebans " . $ex->getMessage()); }
try { $this->ddb = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DONATIONS_DB . ';charset=utf8', DB_USER, DB_PASS); $this->ddb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //$this->ddb->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); $this->ddb->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); } catch (Exception $ex) { throw new Exception("Unable to connect to database " . $ex->getMessage()); } }
public function queryServers($query) { if (DEBUG) { return true; } $result = $this->sdb->query("SELECT * FROM sb_servers"); while ($server = $result->fetch(PDO::FETCH_ASSOC)) { $srcds_rcon = new srcds_rcon(); $OUTPUT = $srcds_rcon->rcon_command($server['ip'], $server['port'], $server['rcon'], $query); } return true; }
/** * * @param type $steam_id * @return type * @throws Exception */ public function getUserGroup($steam_id) {// code works good try { $stmt = $this->sdb->prepare("SELECT * FROM " . SB_PREFIX . "_admins WHERE `authid` =?;"); $stmt->bindParam(1, $steam_id, PDO::PARAM_STR); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); if (empty($rows)) { throw new Exception(sprintf("%s, is not in any valid groups.", $steam_id)); } $aid = $rows[0]['aid']; $srv_group = $rows[0]['srv_group']; } catch (Exception $ex) { throw new Exception(sprintf('There was a problem fetching infomation from MySQL server: %s', $ex->getMessage())); }
unset($stmt); unset($rows); try { $stmt = $this->sdb->prepare("SELECT * FROM " . SB_PREFIX . "_admins_servers_groups WHERE `admin_id` =?;"); $stmt->bindParam(1, $aid, PDO::PARAM_STR); $stmt->execute(); $rows = $stmt->fetch(PDO::FETCH_ASSOC); $group_id = $rows['group_id']; $srv_group_id = $rows['srv_group_id']; $server_id = $rows['server_id']; } catch (Exception $ex) { throw new Exception(printf('There was a problem fetching infomation from MySQL server: %s', $ex->getMessage())); } $this->userGroup = array('srv_group' => $srv_group, 'group_id' => $group_id, 'srv_group_id' => $srv_group_id, 'server_id' => $server_id, 'aid' => $aid); return $this->userGroup; }
/** * * @param type $steam_id * @param type $username * @param type $tier * @return boolean * @throws Exception */ public function addDonor($steam_id, $username, $tier) { //check sourcebans database to see if user is already in there
$stmt = $this->ddb->prepare("UPDATE `" . SOURCEBANS_DB . "`.`" . SB_PREFIX . "_admins_servers_groups` SET group_id = '4' WHERE admin_id =:aid"); //$stmt = $this->ddb->prepare("DELETE FROM `" . SOURCEBANS_DB . "`.`" . SB_PREFIX . "_admins_servers_groups` WHERE admin_id =:aid"); $stmt->bindValue(':aid', $userGroup['aid'], PDO::PARAM_STR); $stmt->execute(); $affected_rows = $stmt->rowCount(); } else { throw new Exception('Failed deleting from donor from database. '); } } catch (Exception $ex) { throw new Exception($ex->getMessage()); }
$this->queryServers('sm_reloadadmins');
return TRUE; }
/** * This is the old unmodified version of removeDonor, that actually fully removes them. * * @param type $steam_id * @param type $tier * @return boolean * @throws Exception */ public function removeDonorEx($steam_id) { //snaggle code $userGroup = $this->getUserGroup($steam_id);
// $groupList = $this->listGroups(); // $grpLen = count($groupList); // $i = 1; // foreach ($groupList as $groups) { // if ($userGroup['group_id'] == $groups['group_id']) { // $i++; // } // } // if ($i != $grpLen) { // throw new Exception($steam_id . " is in a different sourcebans group."); // } try { $stmt = $this->sdb->prepare("DELETE FROM `" . SOURCEBANS_DB . "`.`" . SB_PREFIX . "_admins` WHERE authid =:steam_id"); $stmt->bindValue(':steam_id', $steam_id, PDO::PARAM_STR); $stmt->execute(); $affected_rows = $stmt->rowCount();
if ($affected_rows == 1) { unset($affected_rows);
$stmt = $this->ddb->prepare("DELETE FROM `" . SOURCEBANS_DB . "`.`" . SB_PREFIX . "_admins_servers_groups` WHERE admin_id =:aid"); $stmt->bindValue(':aid', $userGroup['aid'], PDO::PARAM_STR); $stmt->execute(); $affected_rows = $stmt->rowCount(); } else { throw new Exception('Failed deleting from donor from database. '); } } catch (Exception $ex) { throw new Exception($ex->getMessage()); }
Thanks for the great plugin and donation system, it is a great help. I have a feature request though. Currently if a user is already in sourcebans such as a mod or admin or anything, and they donate via this system, they get put into the donators group in the donation control system. I have made it clear to my mods and admins not to donate via this method, but you know, things happen. What ends up happening is when the cron job runs, they get completely removed from sourcebans.
I'd like to request a way to either check to see if the member is part of a group other than donators, and stop them from being removed. if this is not possible, maybe a feature that puts expired donors into another group instead of removing them completely? I think this was requested in the past and I feel would be very helpful.
Thanks for the great plugin and donation system, it is a great help. I have a feature request though. Currently if a user is already in sourcebans such as a mod or admin or anything, and they donate via this system, they get put into the donators group in the donation control system. I have made it clear to my mods and admins not to donate via this method, but you know, things happen. What ends up happening is when the cron job runs, they get completely removed from sourcebans.
I'd like to request a way to either check to see if the member is part of a group other than donators, and stop them from being removed. if this is not possible, maybe a feature that puts expired donors into another group instead of removing them completely? I think this was requested in the past and I feel would be very helpful.
thanks.
If one of your admins donate just switch their group back in SB