public function step_user() { $objDatabase = $this->objCIFunctions->createConnection(); //Get User $objResult = $objDatabase->query('SELECT * FROM __users;'); if ($objResult) { while ($arrUserdata = $objResult->fetchAssoc()) { if ($this->pdh->get('user', 'check_username', array(sanitize($arrUserdata['user_login']))) != 'false') { $strPassword = md5(generateRandomBytes()); $salt = $this->user->generate_salt(); $new_password = $this->user->encrypt_password($strPassword, $salt) . ':' . $salt; $arrData = array('username' => $arrUserdata['user_login'], 'user_password' => $new_password, 'user_email' => register('encrypt')->encrypt($arrUserdata['user_email']), 'user_active' => 1, 'rules' => 1, 'user_registered' => strtotime($arrUserdata['user_registered'])); $intUserID = $this->pdh->put('user', 'insert_user', array($arrData, false)); if (!$intUserID) { return false; } $arrImported[] = $arrUserdata['user_login']; } } } $this->pdh->process_hook_queue(); //Display imported Users $out = '<h2>' . $this->user->lang('ci_imported_users') . '</h2> <table class="table">'; foreach ($arrImported as $val) { $out .= '<tr><td>' . $val . '</td></tr>'; } $out .= '</table>'; return $out; }
private function sso($arrUserdata, $boolAutoLogin) { $user_id = intval($arrUserdata['id']); $strSessionID = substr(md5(generateRandomBytes(55)) . md5(generateRandomBytes(55)), 0, 32); //$this->bridgedb->prepare("DELETE FROM ".$this->prefix."session WHERE userID=?")->execute($user_id); $config = array(); $objQuery = $this->bridgedb->query("SELECT data FROM " . $this->prefix . "datastore WHERE title = 'options'"); if ($objQuery) { $result = $objQuery->fetchAssoc(); $config = unserialize($result['data']); } //PW is true, logg the user into our Forum $arrSet = array('sessionhash' => $strSessionID, 'userid' => (int) $user_id, 'host' => $this->env->ip, 'idhash' => md5($this->env->useragent . implode('.', array_slice(explode('.', $this->fetchAltIp()), 0, 4 - $config['ipcheck']))), 'useragent' => $this->env->useragent, 'loggedin' => 1, 'lastactivity' => time()); $this->bridgedb->prepare("INSERT INTO " . $this->prefix . "session :p")->set($arrSet)->execute(); $expire = $this->time->time + 31536000; $strCookiedomain = $config['cookiedomain']; $strCookiepath = $config['cookiepath']; $strCookieprefix = $this->config->get('cmsbridge_sso_cookieprefix'); //SID Cookie setcookie($strCookieprefix . 'sessionhash', $strSessionID, $expire, $strCookiepath, $strCookiedomain, $this->env->ssl); setcookie($strCookieprefix . 'userid', (int) $user_id, $expire, $strCookiepath, $strCookiedomain, $this->env->ssl); if ($boolAutoLogin && strlen($this->config->get('cmsbridge_sso_cookiesalt'))) { setcookie(hash("sha224", $arrUserdata['token'] . $this->config->get('cmsbridge_sso_cookiesalt')), $strCookieprefix . 'password', $arrUserdata['password'], $expire, $strCookiepath, $strCookiedomain, $this->env->ssl); } return true; }
public function set_defaults($arrData) { $arrDefaults = array('user_alimit' => $this->config->get('default_alimit'), 'user_elimit' => $this->config->get('default_elimit'), 'user_ilimit' => $this->config->get('default_ilimit'), 'user_nlimit' => $this->config->get('default_nlimit'), 'user_rlimit' => $this->config->get('default_rlimit'), 'user_style' => $this->config->get('default_style'), 'user_lang' => $this->config->get('default_lang'), 'user_timezone' => $this->config->get('timezone'), 'user_date_long' => $this->config->get('default_date_long') ? $this->config->get('default_date_long') : $this->user->lang('style_date_long'), 'user_date_short' => $this->config->get('default_date_short') ? $this->config->get('default_date_short') : $this->user->lang('style_date_short'), 'user_date_time' => $this->config->get('default_date_time') ? $this->config->get('default_date_time') : $this->user->lang('style_date_time'), 'exchange_key' => md5(generateRandomBytes())); $arrReturn = $arrData; foreach ($arrDefaults as $key => $value) { if (!isset($arrData[$key])) { $arrData[$key] = $arrDefaults[$key]; } } return $arrData; }
public function display() { include_once $this->root_path . 'core/data_export.class.php'; $myexp = new content_export(); $arrData = $myexp->export(true, true, false, false, true); $strApiKey = $this->config->get('api_key'); if (!$strApiKey) { $strApiKey = generateRandomBytes(48); $this->config->set('api_key', $strApiKey); } $this->tpl->assign_vars(array('EXPORT_DATA' => $this->returnLua($arrData), 'API_KEY' => $strApiKey, 'S_SHOW_APIKEY' => $this->user->check_group(2, false))); $this->core->set_vars(array('page_title' => $this->user->lang('manexport_title'), 'template_file' => 'admin/manage_export.html', 'display' => true)); }
private function sso($arrUserdata, $boolAutoLogin) { //Get wbb package ID $query = $this->bridgedb->query("SELECT packageID FROM " . $this->prefix . "package WHERE package='com.woltlab.wbb'"); if ($query) { $packageId = $query->fetchAssoc(); if (isset($packageId['packageID'])) { $user_id = intval($arrUserdata['id']); $strSessionID = substr(md5(generateRandomBytes(55)) . md5(generateRandomBytes(55)), 0, 40); $this->bridgedb->prepare("DELETE FROM " . $this->prefix . "session WHERE userID=?")->execute($user_id); //PW is true, logg the user into our Forum $arrSet = array('sessionID' => $strSessionID, 'packageID' => $packageId['packageID'], 'userID' => (int) $user_id, 'ipAddress' => $this->env->ip, 'userAgent' => $this->env->useragent, 'lastActivityTime' => (int) $this->time->time, 'requestURI' => '', 'requestMethod' => 'GET', 'username' => $arrUserdata['username']); $this->bridgedb->prepare("INSERT INTO " . $this->prefix . "session :p")->set($arrSet)->execute(); $config = array(); $objQuery = $this->bridgedb->query("SELECT * FROM " . $this->prefix . "option WHERE optionName = 'cookie_prefix' OR optionName = 'cookie_path' OR optionName = 'cookie_domain'"); if ($objQuery) { $result = $objQuery->fetchAllAssoc(); if (is_array($result)) { foreach ($result as $value) { if (isset($config[$value['optionName']]) && intval($packageId['packageID']) != intval($value['packageID'])) { continue; } $config[$value['optionName']] = $value['optionValue']; } } } else { return; } $expire = $this->time->time + 31536000; if ($config['cookie_domain'] == '') { $arrDomains = explode('.', $this->env->server_name); $arrDomainsReversed = array_reverse($arrDomains); if (count($arrDomainsReversed) > 1) { $config['cookie_domain'] = '.' . $arrDomainsReversed[1] . '.' . $arrDomainsReversed[0]; } else { $config['cookie_domain'] = $this->env->server_name; } } //SID Cookie setcookie($config['cookie_prefix'] . 'cookieHash', $strSessionID, $expire, $config['cookie_path'], $config['cookie_domain'], $this->env->ssl); return true; } } return false; }
/** * pre_install * Define Installation */ public function pre_install() { // include SQL and default configuration data for installation include $this->root_path . 'plugins/eqdkp_sso/includes/sql.php'; // define installation for ($i = 1; $i <= count($eqdkpSSOSQL['install']); $i++) { $this->db->query($eqdkpSSOSQL['install'][$i]); } //Create uniqueID and masterKey $masterKey = sha1(generateRandomBytes(48)); $uniqueID = sha1(generateRandomBytes(48)); $data = "<?php \nif ( !defined('EQDKP_INC') ){\n\theader('HTTP/1.0 404 Not Found');exit;\n}\n\n\$eqdkp_sso_uniqueID = '" . $uniqueID . "';\n\$eqdkp_sso_masterKey = '" . $masterKey . "';\n\n?>"; $this->pfh->secure_folder('config', 'eqdkp_sso'); $this->pfh->putContent($this->pfh->FolderPath('config', 'eqdkp_sso') . 'config.php', $data); //Insert this master as slave; $crypt = register('encrypt', array($masterKey)); $arrQuery = array('name' => $this->config->get('main_title') != "" ? $this->config->get('main_title') : "This Master", 'domain' => $this->env->server_name, 'uniqueid' => $uniqueID, 'db_type' => 0, 'db_host' => '', 'db_user' => '', 'db_password' => '', 'db_database' => '', 'db_prefix' => $crypt->encrypt(registry::get_const("table_prefix")), 'cookie_name' => $this->config->get('cookie_name')); $this->db->prepare("INSERT INTO __plugin_sso :p")->set($arrQuery)->execute(); }
public function sso($arrUserdata, $boolAutoLogin = false) { $user_id = $arrUserdata['id']; $strSessionID = md5(generateRandomBytes(55)); //$this->bridgedb->prepare("DELETE FROM ".$this->prefix."sessions WHERE session_user_id=?")->execute($user_id); $query = $this->bridgedb->query("SELECT * FROM " . $this->prefix . "config"); if ($query) { while ($row = $query->fetchAssoc()) { $arrConfig[$row['config_name']] = $row['config_value']; } } else { return false; } $ip = $this->get_ip(); //PW is true, logg the user into our Forum $arrSet = array('session_user_id' => (int) $user_id, 'session_start' => (int) $this->time->time, 'session_last_visit' => (int) $this->time->time, 'session_time' => (int) $this->time->time, 'session_browser' => (string) trim(substr($this->env->useragent, 0, 149)), 'session_forwarded_for' => '', 'session_ip' => $ip, 'session_autologin' => $boolAutoLogin ? 1 : 0, 'session_admin' => 0, 'session_viewonline' => 1, 'session_id' => $strSessionID, 'session_page' => '', 'session_forum_id' => 0); $this->bridgedb->prepare("INSERT INTO " . $this->prefix . "sessions :p")->set($arrSet)->execute(); // Set cookie $expire = $this->time->time + 31536000; if ($arrConfig['cookie_domain'] == '') { $arrDomains = explode('.', $this->env->server_name); $arrDomainsReversed = array_reverse($arrDomains); if (count($arrDomainsReversed) > 1) { $arrConfig['cookie_domain'] = '.' . $arrDomainsReversed[1] . '.' . $arrDomainsReversed[0]; } else { $arrConfig['cookie_domain'] = $this->env->server_name; } } //SID Cookie setcookie($arrConfig['cookie_name'] . '_sid', $strSessionID, $expire, $arrConfig['cookie_path'], $arrConfig['cookie_domain'], $arrConfig['cookie_secure']); //User-Cookie setcookie($arrConfig['cookie_name'] . '_u', $user_id, $expire, $arrConfig['cookie_path'], $arrConfig['cookie_domain'], $arrConfig['cookie_secure']); if ($boolAutoLogin) { $strLoginKey = substr($this->user->generate_salt(), 4, 16); $this->bridgedb->prepare("INSERT INTO " . $this->prefix . "sessions_keys :p")->set(array('key_id' => md5($strLoginKey), 'last_ip' => $ip, 'last_login' => (int) $this->time->time, 'user_id' => (int) $user_id))->execute(); setcookie($arrConfig['cookie_name'] . '_k', $strLoginKey, $expire, $arrConfig['cookie_path'], $arrConfig['cookie_domain'], $arrConfig['cookie_secure']); } else { setcookie($arrConfig['cookie_name'] . '_k', '', $expire, $arrConfig['cookie_path'], $arrConfig['cookie_domain'], $arrConfig['cookie_secure']); } return true; }
private function sso($arrUserdata, $boolAutoLogin) { $user_id = intval($arrUserdata['id']); $strSessionID = substr(md5(generateRandomBytes(55)) . md5(generateRandomBytes(55)), 0, 40); //$this->bridgedb->prepare("DELETE FROM ".$this->prefix."session WHERE userID=?")->execute($user_id); //PW is true, logg the user into our Forum $arrSet = array('sessionID' => $strSessionID, 'userID' => (int) $user_id, 'ipAddress' => self::getIpAddress(), 'userAgent' => $this->env->useragent, 'lastActivityTime' => (int) $this->time->time, 'requestURI' => '', 'requestMethod' => 'GET', 'sessionVariables' => 'a:1:{s:16:"__SECURITY_TOKEN";s:40:".' . md5(generateRandomBytes()) . 'a7w8er45' . '.";}'); $this->bridgedb->prepare("INSERT INTO " . $this->prefix . "session :p")->set($arrSet)->execute(); $config = array(); $objQuery = $this->bridgedb->query("SELECT * FROM " . $this->prefix . "option WHERE optionName = 'cookie_prefix'"); if ($objQuery) { $result = $objQuery->fetchAllAssoc(); if (is_array($result)) { foreach ($result as $value) { $config[$value['optionName']] = $value['optionValue']; } } } $expire = $this->time->time + 31536000; if ($this->config->get('cmsbridge_sso_cookiedomain') == '') { $arrDomains = explode('.', $this->env->server_name); $arrDomainsReversed = array_reverse($arrDomains); if (count($arrDomainsReversed) > 1) { $config['cookie_domain'] = '.' . $arrDomainsReversed[1] . '.' . $arrDomainsReversed[0]; } else { $config['cookie_domain'] = $this->env->server_name; } } else { $config['cookie_domain'] = $this->config->get('cmsbridge_sso_cookiedomain'); } $config['cookie_path'] = strlen($this->config->get('cmsbridge_sso_cookiepath')) ? $this->config->get('cmsbridge_sso_cookiepath') : '/'; //SID Cookie setcookie($config['cookie_prefix'] . 'cookieHash', $strSessionID, $expire, $config['cookie_path'], $config['cookie_domain'], $this->env->ssl); setcookie($config['cookie_prefix'] . 'userID', (int) $user_id, $expire, $config['cookie_path'], $config['cookie_domain'], $this->env->ssl); if ($boolAutoLogin) { setcookie($config['cookie_prefix'] . 'password', $arrUserdata['password'], $expire, $config['cookie_path'], $config['cookie_domain'], $this->env->ssl); } return true; }
public function parse_input() { $this->username = $this->in->get('username'); $this->useremail = $this->in->get('user_email'); if ($this->in->get('user_password1') == '' || empty($this->username) || empty($this->useremail)) { $this->pdl->log('install_error', $this->lang['user_required']); return false; } if ($this->in->get('user_password1') != $this->in->get('user_password2')) { $this->pdl->log('install_error', $this->lang['no_pw_match']); return false; } $strEmail = $this->encrypt->encrypt($this->useremail); $this->config->set('admin_email', $strEmail); $salt = $this->user->generate_salt(); $password = $this->user->encrypt_password($this->in->get('user_password1'), $salt); $this->db->query("TRUNCATE __users;"); $this->db->prepare("INSERT INTO __users :p")->set(array('user_id' => 1, 'username' => $this->username, 'user_password' => $password . ':' . $salt, 'user_lang' => $this->config->get('default_lang'), 'user_email' => $strEmail, 'user_active' => '1', 'rules' => 1, 'user_style' => 1, 'user_registered' => $this->time->time, 'exchange_key' => md5(generateRandomBytes()), 'user_timezone' => $this->config->get('timezone'), 'user_date_time' => $this->config->get('default_date_time'), 'user_date_short' => $this->config->get('default_date_short'), 'user_date_long' => $this->config->get('default_date_long')))->execute(); $this->db->query("INSERT INTO __groups_users (group_id, user_id, grpleader) VALUES (2,1,1);"); $this->user->login($this->username, $this->in->get('user_password1'), $this->in->exists('auto_login')); return true; }
function DownloadImage($img) { global $thumbfolder, $imgfolder, $pfh, $puf; //If its an dynamic image... $extension_array = array('jpg', 'png', 'gif', 'jpeg'); $path_parts = pathinfo($img); if (!in_array(strtolower($path_parts['extension']), $extension_array)) { return false; } // Load it... $tmp_name = md5(generateRandomBytes()); $pfh->CheckCreateFile($imgfolder . $tmp_name); $pfh->putContent($imgfolder . $tmp_name, $puf->fetch($img)); $i = getimagesize($imgfolder . $tmp_name); // Image is no image, lets remove it if (!$i) { $pfh->Delete($imgfolder . $tmp_name); return false; } $myFileName = $imgfolder . substr(md5(generateRandomBytes()), 0, 8) . '_' . $path_parts['filename'] . '.' . $path_parts['extension']; $pfh->rename($imgfolder . $tmp_name, $myFileName); return $myFileName; }
/** * Generates new Session Key for insertion * * @return string */ public function generate_session_key() { return substr(md5(generateRandomBytes(55)), 0, 12); }
public function user_login_successful($arrOptions) { $user_id = $arrOptions['user_id']; $blnAutologin = $arrOptions['autologin']; //Include SSO Class include_once $this->root_path . 'plugins/eqdkp_sso/includes/eqdkp_sso.class.php'; $this->sso = register('eqdkp_sso_class'); //Hole Daten aus Cache $arrMasterData = $this->pdc->get('eqdkp_sso_masterdata'); if ($arrMasterData === NULL) { //Hole Daten aus Master $objMasterDB = $this->sso->getMasterConnection(); if ($objMasterDB) { $objQuery = $objMasterDB->query('SELECT * FROM __plugin_sso'); if ($objQuery) { while ($drow = $objQuery->fetchAssoc()) { $arrMasterData[(int) $drow['id']] = array('id' => (int) $drow['id'], 'name' => $drow['name'], 'domain' => $drow['domain'], 'uniqueid' => $drow['uniqueid'], 'db_type' => (int) $drow['db_type'], 'db_host' => $drow['db_host'], 'db_user' => $drow['db_user'], 'db_password' => $drow['db_password'], 'db_database' => $drow['db_database'], 'db_prefix' => $drow['db_prefix'], 'cookie_name' => $drow['cookie_name']); } } //Und Cache sie $this->pdc->put('eqdkp_sso_masterdata', $arrMasterData, 60 * 10); } else { //No connection to Master return; } } $strUsername = clean_username($this->pdh->get('user', 'name', array($user_id))); $strMyDomain = $this->env->server_name; $strMyCookiename = $this->config->get('cookie_name'); $strMyUniqueID = $this->sso->get_uniqueid(); $crypt = register('encrypt', array($this->sso->get_master_key())); foreach ($arrMasterData as $arrValue) { //UniqueID checken if ($arrValue['uniqueid'] != "" && $arrValue['uniqueid'] == $strMyUniqueID) { continue; } //Verbindung aufbauen $mydb = false; if ((int) $arrValue['db_type'] === 0) { //Same Connection as Master $mydb = isset($objMasterDB) ? $objMasterDB : $this->sso->getMasterConnection(); } elseif ((int) $arrValue['db_type'] === 1) { //External Connection. Decrypt the data $arrValue['db_host'] = $crypt->decrypt($arrValue['db_host']); $arrValue['db_user'] = $crypt->decrypt($arrValue['db_user']); $arrValue['db_password'] = $crypt->decrypt($arrValue['db_password']); $arrValue['db_database'] = $crypt->decrypt($arrValue['db_database']); $arrValue['db_prefix'] = $crypt->decrypt($arrValue['db_prefix']); //Check if it's the same connection as ours if ($arrValue['db_user'] === registry::get_const('dbuser') && $arrValue['db_database'] === registry::get_const('dbname') && $arrValue['db_password'] === registry::get_const('dbpass')) { $mydb = $this->sso->createConnection(0, $arrValue['db_host'], $arrValue['db_user'], $arrValue['db_password'], $arrValue['db_database'], $arrValue['db_prefix']); } else { $mydb = $this->sso->createConnection(1, $arrValue['db_host'], $arrValue['db_user'], $arrValue['db_password'], $arrValue['db_database'], $arrValue['db_prefix']); } } if ($mydb) { //UserID suchen $objUserQuery = $mydb->prepare("SELECT * FROM __users WHERE LOWER(username)=?")->execute($strUsername); if ($objUserQuery) { $arrUserdata = $objUserQuery->fetchAssoc(); $intUserID = $arrUserdata['user_id']; if ($intUserID) { //Session anlegen $sid = substr(md5(generateRandomBytes(55)) . md5(generateRandomBytes()), 0, 40); $strSessionKey = $this->user->generate_session_key(); $arrData = array('session_id' => $sid, 'session_user_id' => $intUserID, 'session_last_visit' => $this->time->time, 'session_start' => $this->time->time, 'session_current' => $this->time->time, 'session_ip' => $this->env->ip, 'session_browser' => $this->env->useragent, 'session_page' => $this->env->current_page ? utf8_strtolower($this->env->current_page) : '', 'session_key' => $strSessionKey, 'session_type' => defined('SESSION_TYPE') ? SESSION_TYPE : ''); $mydb->prepare('INSERT INTO __sessions :p')->set($arrData)->execute(); //Cookie Daten auslesen $objCookieQuery = $mydb->prepare("SELECT * FROM __config")->execute(); if ($objCookieQuery) { $lookingFor = array('cookie_name', 'cookie_path', 'cookie_domain'); while ($row = $objCookieQuery->fetchAssoc()) { if (in_array($row['config_name'], $lookingFor)) { $arrCookieConf[$row['config_name']] = $row['config_value']; } } } //Cookie Domain if (!isset($arrCookieConf['cookie_domain'])) { $strDomain = $arrValue['domain']; if (!strpos($strDomain, '://')) { $strDomain = 'http://' . $strDomain; } $parsedURL = parse_url($strDomain); $arrCookieConf['cookie_domain'] = $parsedURL['host']; } //Autologin $arrCookieData['user_id'] = $intUserID; if ($blnAutologin && $arrUserdata['user_login_key'] != "") { $arrCookieData['auto_login_id'] = $arrUserdata['user_login_key']; } //Set Cookies setcookie($arrCookieConf['cookie_name'] . '_sid', $sid, 0, $arrCookieConf['cookie_path'], $arrCookieConf['cookie_domain']); setcookie($arrCookieConf['cookie_name'] . '_data', base64_encode(serialize($arrCookieData)), $this->time->time + 2592000, $arrCookieConf['cookie_path'], $arrCookieConf['cookie_domain']); } } //Verbindung beenden unset($mydb); } } }
function DownloadImage($img) { //If its an dynamic image... $path_parts = pathinfo($img); if (!in_array(strtolower($path_parts['extension']), $this->arrImageExtensions)) { return false; } // Load it... $tmp_name = md5(generateRandomBytes()); $this->pfh->CheckCreateFile($this->strImageCacheFolder . $tmp_name); $this->pfh->putContent($this->strImageCacheFolder . $tmp_name, $this->puf->fetch($img)); $i = getimagesize($this->strImageCacheFolder . $tmp_name); // Image is no image, lets remove it if (!$i) { $this->pfh->Delete($this->strImageCacheFolder . $tmp_name); return false; } $myFileName = $this->strImageCacheFolder . md5($img) . '_' . $path_parts['filename'] . '.' . $path_parts['extension']; $this->pfh->rename($this->strImageCacheFolder . $tmp_name, $myFileName); return $myFileName; }
public function restoreDatabaseBackup($strFilename) { $strFileExtension = strtolower(pathinfo($strFilename, PATHINFO_EXTENSION)); $strSQLFile = ""; if ($strFileExtension == 'zip') { //Copy the archive to the tmp-folder $strFrom = $strFilename; $strPlainFilename = pathinfo($strFilename, PATHINFO_FILENAME); $strTo = $this->pfh->FolderPath('backup/tmp', 'eqdkp') . $strPlainFilename . '.' . $strFileExtension; $this->pfh->copy($strFrom, $strTo); //Lets unpack the File $archive = registry::register('zip', array($strTo)); $strRandom = substr(md5(generateRandomBytes()), 0, 8); $archive->extract($this->pfh->FolderPath('backup/tmp/' . $strRandom, 'eqdkp')); $archive->close(); //Try to find an .sql file $arrFiles = sdir($this->pfh->FolderPath('backup/tmp/' . $strRandom, 'eqdkp')); $strDeletePath = $this->pfh->FolderPath('backup/tmp/' . $strRandom, 'eqdkp'); $this->pfh->Delete($strTo); foreach ($arrFiles as $strFile) { $strExt = strtolower(pathinfo($strFile, PATHINFO_EXTENSION)); if ($strExt === 'sql') { $strSQLFile = $this->pfh->FolderPath('backup/tmp/' . $strRandom, 'eqdkp') . $strFile; break; } } } elseif ($strFileExtension == 'sql') { $strSQLFile = $strFilename; } else { return false; } if ($strSQLFile != "" && is_file($strSQLFile)) { @set_time_limit(0); $fp = fopen($strSQLFile, 'rb'); while (($sql = $this->fgetd($fp, ";\n", 'fread', 'fseek', 'feof')) !== false) { if (strpos($sql, "--") === false && $sql != "") { $this->db->query($sql); } } fclose($fp); } if (isset($strDeletePath)) { $this->pfh->Delete($strDeletePath); } }
public function sso($arrUserdata, $boolAutoLogin = false) { $user_id = $arrUserdata['id']; $strSessionID = md5(generateRandomBytes(55)); $this->bridgedb->prepare("DELETE FROM " . $this->prefix . "sessions WHERE uid=?")->execute($user_id); $query = $this->bridgedb->query("SELECT name,value FROM " . $this->prefix . "settings"); if ($query) { $result = $query->fetchAllAssoc(); if (is_array($result)) { foreach ($result as $row) { $arrConfig[$row['name']] = $row['value']; } } } else { return false; } //PW is true, logg the user into our Forum $arrSet = array('sid' => $strSessionID, 'uid' => (int) $user_id, 'ip' => $this->get_ip(), 'time' => (int) $this->time->time, 'location' => '', 'useragent' => (string) trim(substr($this->env->useragent, 0, 149)), 'anonymous' => 0, 'nopermission' => 0, 'location1' => 0, 'location2' => 0); $this->bridgedb->prepare("INSERT INTO " . $this->prefix . "sessions :p")->set($arrSet)->execute(); $logincredentials = $user_id . '_' . $arrUserdata['loginkey']; if ($arrConfig['cookiedomain'] == '') { $arrDomains = explode('.', $this->env->server_name); $arrDomainsReversed = array_reverse($arrDomains); if (count($arrDomainsReversed) > 1) { $arrConfig['cookie_domain'] = '.' . $arrDomainsReversed[1] . '.' . $arrDomainsReversed[0]; } else { $arrConfig['cookie_domain'] = $this->env->server_name; } } // Set cookie $expire = $this->time->time + 31536000; //SID Cookie setcookie($arrConfig['cookieprefix'] . 'sid', $strSessionID, $expire, $arrConfig['cookiepath'], $arrConfig['cookiedomain']); //User-Cookie setcookie($arrConfig['cookieprefix'] . 'uid', $user_id, $expire, $arrConfig['cookiepath'], $arrConfig['cookiedomain']); setcookie($arrConfig['cookieprefix'] . 'mybbuser', $logincredentials, $expire, $arrConfig['cookiepath'], $arrConfig['cookiedomain']); return true; }
private function set_config() { $this->config_data['server_path'] = $this->def_server_path; $this->config_data['default_lang'] = $this->def_lang; $this->config_data['default_locale'] = $this->def_locale; $this->config_data['cookie_name'] = "eqdkp_" . substr(md5(generateRandomBytes()), 4, 6); $this->config_data['default_game'] = $this->def_game; $this->config_data['game_language'] = $this->def_game_lang; $this->config_data['eqdkp_start'] = time(); $this->config_data['timezone'] = $this->def_timezone; $this->config_data['date_startday'] = $this->def_startday; $this->config_data['default_date_time'] = isset($this->lang['time_format']) ? $this->lang['time_format'] : 'H:i'; $this->config_data['default_date_short'] = isset($this->lang['date_short_format']) ? $this->lang['date_short_format'] : 'm/d/Y'; $this->config_data['default_date_long'] = isset($this->lang['date_long_format']) ? $this->lang['date_long_format'] : 'F j, Y'; $this->config_data['eqdkp_layout'] = 'normal'; $this->config_data['pdc'] = array('mode' => 'file', 'prefix' => $this->table_prefix, 'dttl' => 86400); //config-data complete $this->config->install_set($this->config_data); $this->pfh->copy($this->root_path . 'templates/maintenance/images/logo.svg', $this->pfh->FolderPath('', 'files') . 'logo.svg'); }
/** * Generate Salt * * @return string */ public function generate_salt() { return substr(md5(generateRandomBytes(55)), 0, 23); }
public function create() { //existing archive if ($this->objZip && $this->objZip->numFiles > 0) { $tmpExisting = $this->pfh->FilePath(md5(generateRandomBytes()) . '.zip', 'tmp'); //Move archive to temp folder $this->pfh->copy($this->zipfile, $tmpExisting); //open existing zip $objZip = new ZipArchive(); $resZip = $objZip->open($tmpExisting); if ($resZip) { if (is_array($this->files['add'])) { foreach ($this->files['add'] as $key => $value) { if (is_file($value)) { $blnResult = $objZip->addFile($value, $key); if (!$blnResult) { return false; } } } } if (is_array($this->files['delete'])) { foreach ($this->files['delete'] as $key => $value) { $blnResult = $objZip->deleteName($value, $key); //if (!$blnResult) return false; } } $this->objZip->close(); $objZip->close(); $this->pfh->FileMove($tmpExisting, $this->zipfile); return true; } else { return false; } } else { $strTempArchiv = $this->pfh->FilePath(md5(generateRandomBytes()) . '.zip', 'tmp'); //Create new archive $blnOpen = $this->objZip->open($strTempArchiv, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE); if ($blnOpen) { foreach ($this->files['add'] as $key => $value) { if (is_file($value)) { $blnResult = $this->objZip->addFile($value, $key); if (!$blnResult) { return false; } } } $this->objZip->close(); $this->pfh->FileMove($strTempArchiv, $this->zipfile); return true; } else { $this->objZip = false; return false; } } }