📄 ipbcms2.php
字号:
<?php// integration class for Invision Power Board (www.invisionboard.com)$curdir = getcwd();$ipb_root_path = realpath(dirname(__FILE__) . '/../../../') . '/';chdir($ipb_root_path);require_once($ipb_root_path . 'conf_global.php');chdir($curdir);class IPBCMS { var $userid; var $loginStmt; var $getUserStmt; var $getUsersStmt; function IPBCMS() { $this->loginStmt = new Statement("SELECT m.id, m.name AS login, m.ip_address as ip_address, m.mgroup as mgroup from ".$GLOBALS["INFO"]["sql_tbl_prefix"]."members as m INNER JOIN ".$GLOBALS["INFO"]["sql_tbl_prefix"]."members_converge AS mc ON m.id = mc.converge_id WHERE LOWER(m.name)=? AND mc.converge_pass_hash = MD5(CONCAT(MD5(mc.converge_pass_salt),MD5(?))) LIMIT 1"); $this->getUserStmt = new Statement("SELECT id, name AS login, g.g_is_supmod AS status FROM ".$GLOBALS["INFO"]["sql_tbl_prefix"]."members AS m INNER JOIN ".$GLOBALS["INFO"]["sql_tbl_prefix"]."groups AS g ON m.mgroup = g.g_id WHERE id=? LIMIT 1"); $this->getUsersStmt = new Statement("SELECT id, name as login FROM ".$GLOBALS["INFO"]["sql_tbl_prefix"]."members"); $this->userid = NULL; if (isset($_COOKIE['member_id'])) { $this->userid = $_COOKIE['member_id']; } } function isLoggedIn() { return $this->userid; } function getRoles($group) { $rv = NULL; if ($group) $rv = ROLE_ADMIN; elseif ($GLOBALS['fc_config']['liveSupportMode']) $rv = ROLE_CUSTOMER; else $rv = ROLE_USER; return $rv; } function getUserProfile($userid) { if ($userid == SPY_USERID) $rv = NULL; elseif ($user = $this->getUser($userid)) { $rv = ($id = $this->isLoggedIn() && ($id == $userid)) ? $GLOBALS["INFO"]["board_url"] . "/index.php?act=UserCP&CODE=01" : $GLOBALS["INFO"]["board_url"]."/index.php?showuser={$user[id]}"; } return $rv; } function getUser($userid) { $rv = NULL; if(($rs = $this->getUserStmt->process($userid)) && ($rec = $rs->next())) { $rec['roles'] = $this->getRoles($rec['status']); $rv = $rec; } return $rv; } function login($login, $password) { // taken from IPB's Login::do_login function if (($rs = $this->loginStmt->process($login,$password)) && ($rec = $rs->next())) { // statements used by IPBCMS::login() $this->updateIPStmt = new Statement("UPDATE ".$GLOBALS["INFO"]["sql_tbl_prefix"]."members SET ip_address=? WHERE id=?"); $this->deleteSessionStmt = new Statement("DELETE FROM ".$GLOBALS["INFO"]["sql_tbl_prefix"]."sessions WHERE ip_address=? AND id <> ?"); $this->updateSessionStmt = new Statement("UPDATE ".$GLOBALS["INFO"]["sql_tbl_prefix"]."sessions SET member_name=?, member_id=?, running_time=?, member_group=?, login_type=? WHERE id=?"); $this->deleteSessionIPStmt = new Statement("DELETE FROM ".$GLOBALS["INFO"]["sql_tbl_prefix"]."sessions WHERE ip_address=?"); $this->insertSessionStmt = new Statement("INSERT INTO ".$GLOBALS["INFO"]["sql_tbl_prefix"]."sessions (id, member_name, member_id, running_time, member_group, ip_address, browser, login_type) VALUES (?,?,?,?,?,?,?,?)"); $this->userid = $rec[id]; $GLOBALS['INFO']['cookie_domain'] = $GLOBALS['INFO']['cookie_domain'] == "" ? "" : $GLOBALS['INFO']['cookie_domain']; $GLOBALS['INFO']['cookie_path'] = $GLOBALS['INFO']['cookie_path'] == "" ? "/" : $GLOBALS['INFO']['cookie_path']; @setcookie("member_id", $rec[id], 0, $GLOBALS['INFO']['cookie_path'], $GLOBALS['INFO']['cookie_domain']); @setcookie("pass_hash", $rec[password], 0, $GLOBALS['INFO']['cookie_path'], $GLOBALS['INFO']['cookie_domain']); // update profile if IP address missing if ($rec[ip_address] == "" || $rec[ip_address] == '127.0.0.1') { $this->updateIPStmt->process($_SERVER[REMOTE_ADDR], $rec[id]); } // create or update session $poss_session_id = isset($_COOKIE[$GLOBALS[INFO][cookie_id]."session_id"]) ? urldecode($_COOKIE[$GLOBALS[INFO][cookie_id]."session_id"]) : FALSE; if ($poss_session_id) { // delete any old session with this ipadd that doesn't match our session id $this->deleteSessionStmt->process($_SERVER[REMOTE_ADDR], $poss_session_id); $this->updateSessionStmt->process($rec[login], $rec[id], time(), $rec[mgroup], 0, $poss_session_id); } else { $session_id = md5(uniqid(microtime())); // delete any old sessions with this users ip $this->deleteSessionIPStmt->process($_SERVER[REMOTE_ADDR]); $this->insertSessionStmt->process($session_id, $rec[login], $rec[id], time(), $rec[mgroup], $_SERVER[REMOTE_ADDR], substr($HTTP_USER_AGENT,0,50), 0); } return $rec[id]; } } function userInRole($userid, $role) { $rv = NULL; if($user = $this->getUser($userid)) { $rv = (($user['roles'] & $role) != 0); } return $rv; } function logout() { } function getUsers() { $rv = $this->getUsersStmt->process(); return $rv; } function getGender($userid){ // 'M' for Male, 'F' for Female, NULL for undefined return NULL; }}$GLOBALS['fc_config']['db'] = array( 'host' => $INFO['sql_host'], 'user' => $INFO['sql_user'], 'pass' => $INFO['sql_pass'], 'base' => $INFO['sql_database'], 'pref' => $INFO['sql_tbl_prefix']."fc_", );$GLOBALS['fc_config']['cms'] = new IPBCMS();foreach($GLOBALS['fc_config']['languages'] as $k => $v) { $GLOBALS['fc_config']['languages'][$k]['dialog']['login']['moderator'] = '';}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -