public static function init($config = array()) { //-- todo : load log handler here // load system config sys::import('webi.config'); wbConfig::init(); // load variables handler, server/request/response utilities sys::import('webi.server'); sys::import('webi.nusoap'); // load template, page handler sys::import('webi.template'); sys::import('webi.htmlElementWidget'); wbPage::init(); // load database sys::import('webi.db'); $dbConnParams = array('name' => wbConfig::get('DB.name'), 'user' => wbConfig::get('DB.user'), 'password' => wbConfig::get('DB.password'), 'host' => wbConfig::get('DB.host'), 'type' => wbConfig::get('DB.type')); wbDB::init($dbConnParams); // load session handler sys::import('webi.sessions'); wbSession::init(); //-- todo : load language system // load utilities function sys::import('webi.utils'); // load module handler sys::import('webi.modules'); sys::import('webi.crud.AbstractTable'); //-- todo : load users and security system sys::import('webi.users'); wbUser::init(); sys::import('webi.security'); return true; }
public static function init($params) { self::$dbConnParams = $params; self::$dbConn =& ADONewConnection(self::$dbConnParams['type']); self::$dbConn->Connect(self::$dbConnParams['host'], self::$dbConnParams['user'], self::$dbConnParams['password'], self::$dbConnParams['name']); return true; }
public static function isPermissionExist($name) { $dbconn = wbDB::getConn(); $prefix = wbConfig::get('DB.prefix'); $query = "SELECT COUNT(1) FROM " . $prefix . "_permission WHERE permission_name = ?"; $count = $dbconn->GetOne($query, array($name)); if ($count === false) { throw new Exception($dbconn->ErrorMsg()); } if ($count) { return true; } return false; }
function __construct() { $this->dbconn =& wbDB::getConn(); if (count($this->displayFields)) { if ($this->dbconn->dataProvider == 'mysql') { $this->selectClause .= ", CONCAT(" . implode(", ' - ' ,", $this->displayFields) . ") AS _display_field_"; $this->likeOperator = " LIKE "; } else { if ($this->dbconn->dataProvider == 'postgres') { $this->selectClause .= ", " . implode(" || ' - ' || ", $this->displayFields) . " AS _display_field_"; $this->likeOperator = " ILIKE "; } } } if ($this->dbconn->dataProvider == 'mysql') { $this->likeOperator = " LIKE "; } else { if ($this->dbconn->dataProvider == 'postgres') { $this->likeOperator = " ILIKE "; } } }
public static function init() { if (!wbCore::isFuncDisabled('ini_set')) { // PHP configuration variables // Stop adding SID to URLs ini_set('session.use_trans_sid', 0); // User-defined save handler ini_set('session.save_handler', 'user'); // How to store data ini_set('session.serialize_handler', 'php'); // Use cookie to store the session ID ini_set('session.use_cookies', 1); // Name of our cookie ini_set('session.name', 'WEBISID'); $path = wbServer::getBaseURI(); if (empty($path)) { $path = '/'; } // Lifetime of our cookie. Session lasts set number of days $lifetime = wbConfig::get('Session.Duration') * 86400; ini_set('session.cookie_lifetime', $lifetime); // Cookie path // this should be customized for multi-server setups wanting to share // sessions ini_set('session.cookie_path', $path); // Garbage collection ini_set('session.gc_probability', 1); // Inactivity timeout for user sessions ini_set('session.gc_maxlifetime', wbConfig::get('Session.InactivityTimeout') * 60); // Auto-start session ini_set('session.auto_start', 1); } include_once 'lib/adodb/session/adodb-session2.php'; $GLOBALS['ADODB_SESS_CONN'] =& wbDB::getConn(); ADODB_Session::table(wbConfig::get('DB.prefix') . '_sessions'); session_start(); }
function __construct() { $dbConnParams = array('name' => wbConfig::get('DB.name'), 'user' => wbConfig::get('DB.user'), 'password' => wbConfig::get('DB.password'), 'host' => wbConfig::get('DB.host'), 'type' => wbConfig::get('DB.type')); wbDB::init($dbConnParams); $this->dbconn =& wbDB::getConn(); if (count($this->displayFields)) { if ($this->dbconn->dataProvider == 'mysql' || $this->dbconn->dataProvider == 'oci8') { $this->selectClause .= ", CONCAT(" . implode(", ' - ' ,", $this->displayFields) . ") AS _display_field_"; $this->likeOperator = " LIKE "; } else { if ($this->dbconn->dataProvider == 'postgres') { $this->selectClause .= ", " . implode(" || ' - ' || ", $this->displayFields) . " AS _display_field_"; $this->likeOperator = " ILIKE "; } } } if ($this->dbconn->dataProvider == 'mysql' || $this->dbconn->dataProvider == 'oci8') { $this->likeOperator = " LIKE "; } else { if ($this->dbconn->dataProvider == 'postgres') { $this->likeOperator = " ILIKE "; } } }
public static function &getUserRoles($uid) { $dbconn = wbDB::getConn(); $prefix = wbConfig::get('DB.prefix'); $query = "SELECT a.role_id, b.role_name " . "FROM " . $prefix . "_user_role as a, " . $prefix . "_role as b " . "WHERE a.role_id = b.role_id AND a.user_id = ?"; $result =& $dbconn->Execute($query, array($uid)); if (!$result) { return; } $roles = array(); while (!$result->EOF) { list($role_id, $role_name) = $result->fields; $roles[] = array('role_id' => $role_id, 'role_name' => $role_name); $result->MoveNext(); } $result->Close(); return $roles; }
public static function menunodes($args = array()) { $data = array('items' => array(), 'total' => 0, 'success' => false, 'message' => ''); $userInfo = wbUser::getSession(); if ($userInfo['user_id'] == "") { return $data; } $text = ''; $dbconn = wbDB::getConn(); $isdmin = false; if ($userInfo['user_id'] == "1") { $isdmin = true; } $query = "select count(*) ada from core_user_role where role_id=1 and user_id=" . $userInfo['user_id']; $result =& $dbconn->Execute($query); if (!$result->EOF) { list($ada) = $result->fields; } if ($ada > 0) { $isdmin = true; } if ($isdmin == true) { $query = "select menu_id, nvl (menu_pid, 0) menu_pid, menu_code, menu_file_name " . "from (select menu_id, menu_pid, menu_code, nvl (menu_file_name, '-') as menu_file_name, " . "menu_description, menu_listing_no " . "from bds_p_app_menu " . "where menu_is_active = 'Y' " . "start with menu_pid is null connect by prior menu_id = menu_pid order siblings by nvl(menu_listing_no, 9999)) "; } else { $query = "select menu_id, nvl (menu_pid, 0) menu_pid, menu_code, menu_file_name " . "from (select menu_id, menu_pid, menu_code, nvl (menu_file_name, '-') as menu_file_name, " . "menu_description, menu_listing_no " . "from bds_p_app_menu " . "where menu_is_active = 'Y' " . "and menu_id in ( " . "select rm.menu_id " . "from bds_p_role_menu rm, core_user_role ur " . "where nvl(rm.rolemenu_status,'N')='Y' and rm.role_id = ur.role_id " . "and ur.user_id = " . $userInfo['user_id'] . " ) " . "start with menu_pid is null connect by prior menu_id = menu_pid order siblings by nvl(menu_listing_no, 9999)) "; } // echo("\/\/[disini" . $query . "]"); $text .= "[" . chr(13); $result =& $dbconn->Execute($query); if (!$result) { exit; } $PLevel = array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1); $level = 0; $bdmnid = 0; $nplevel = -1; $parid = 0; while (!$result->EOF) { list($menu_id, $menu_pid, $menu_code, $menu_file_name) = $result->fields; if ($menu_id != $bdmnid) { if ($menu_pid == $PLevel[$level]) { $text .= '"leaf":true},' . chr(13); } else { if ($menu_pid == $nplevel) { $text .= '"leaf":false,' . chr(13); $text .= '"expanded":false,' . chr(13); $text .= '"children":[' . chr(13); $level = $level + 1; $PLevel[$level] = $menu_pid; } else { if ($level > 0) { $text .= '"leaf":true},' . chr(13); } while ($PLevel[$level] != $menu_pid && $level > 0) { $text .= "]" . chr(13); $text .= "}," . chr(13); $level = $level - 1; } } } $nplevel = $menu_id; $text .= "{" . chr(13); if ($menu_file_name == "-") { $text .= '"id":"' . $menu_id . '",' . chr(13); } else { $text .= '"id":"' . $menu_file_name . '",' . chr(13); } $text .= '"text":"' . $menu_code . '",' . chr(13); } $result->MoveNext(); } $result->Close(); if ($level > 0) { $text .= '"leaf":true},' . chr(13); } while ($level > 0) { $text .= "]" . chr(13); $text .= "}," . chr(13); $level = $level - 1; } $text .= "]" . chr(13); $data['items'] = $text; $data['success'] = true; $data['message'] = 'Menu Success'; return $data; }