/** * Retrieve menus, check visibility against * current user classes and current page url * */ public function init() { global $_E107; if (vartrue($_E107['cli'])) { return; } $menu_layout_field = THEME_LAYOUT != e107::getPref('sitetheme_deflayout') ? THEME_LAYOUT : ""; e107::getCache()->CachePageMD5 = md5(e_LANGUAGE . $menu_layout_field); //FIXME add a function to the cache class for this. // $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST."_".md5(e_LANGUAGE.$menu_layout_field)); $menu_data = e107::getCache()->retrieve_sys("menus_" . USERCLASS_LIST); $menu_data = e107::getArrayStorage()->ReadArray($menu_data); $eMenuArea = array(); // $eMenuList = array(); // $eMenuActive = array(); // DEPRECATED if (!is_array($menu_data)) { $menu_qry = 'SELECT * FROM #menus WHERE menu_location > 0 AND menu_class IN (' . USERCLASS_LIST . ') AND menu_layout = "' . $menu_layout_field . '" ORDER BY menu_location,menu_order'; if (e107::getDb()->db_Select_gen($menu_qry)) { while ($row = e107::getDb()->db_Fetch()) { $eMenuArea[$row['menu_location']][] = $row; } } $menu_data['menu_area'] = $eMenuArea; $menuData = e107::getArrayStorage()->WriteArray($menu_data, false); e107::getCache()->set_sys('menus_' . USERCLASS_LIST, $menuData); // e107::getCache()->set_sys('menus_'.USERCLASS_LIST.'_'.md5(e_LANGUAGE.$menu_layout_field), $menuData); } else { $eMenuArea = $menu_data['menu_area']; } $total = array(); foreach ($eMenuArea as $area => $val) { foreach ($val as $row) { if ($this->isVisible($row)) { $path = str_replace("/", "", $row['menu_path']); if (!isset($total[$area])) { $total[$area] = 0; } $this->eMenuActive[$area][] = $row; $total[$area]++; } } } e107::getRender()->eMenuTotal = $total; }
require_once e_HANDLER . 'validator_class.php'; $userMethods = e107::getUserSession(); $mes = e107::getMessage(); $frm = e107::getForm(); if (isset($_POST['update_settings'])) { if ($_POST['ac'] == md5(ADMINPWCHANGE)) { $userData = array(); $userData['data'] = array(); if ($_POST['a_password'] != '' && $_POST['a_password2'] != '' && $_POST['a_password'] == $_POST['a_password2']) { $userData['data']['user_password'] = $sql->escape($userMethods->HashPassword($_POST['a_password'], $currentUser['user_loginname']), FALSE); unset($_POST['a_password']); unset($_POST['a_password2']); if (vartrue($pref['allowEmailLogin'])) { $user_prefs = e107::getArrayStorage()->unserialize($currentUser['user_prefs']); $user_prefs['email_password'] = $userMethods->HashPassword($new_pass, $email); $userData['data']['user_prefs'] = e107::getArrayStorage()->serialize($user_prefs); } $userData['data']['user_pwchange'] = time(); $userData['WHERE'] = 'user_id=' . USERID; validatorClass::addFieldTypes($userMethods->userVettingInfo, $userData, $userMethods->otherFieldTypes); $check = $sql->update('user', $userData); if ($check) { e107::getLog()->add('ADMINPW_01', '', E_LOG_INFORMATIVE, ''); $userMethods->makeUserCookie(array('user_id' => USERID, 'user_password' => $userData['data']['user_password']), FALSE); // Can't handle autologin ATM $mes->addSuccess(UDALAN_3 . " " . ADMINNAME); e107::getEvent()->trigger('adpword'); //@deprecated $eventData = array('user_id' => USERID, 'user_pwchange' => $userData['data']['user_pwchange']); e107::getEvent()->trigger('admin_password_update', $eventData); $ns->tablerender(UDALAN_2, $mes->render());
/** * Process data values for XML file. If $this->convertFilePaths is TRUE, convert paths * * @see replaceFilePaths() * @param mixed $val * @param string $key key for the current value. Used for exception processing. * @return mixed */ private function e107ExportValue($val, $key = '') { if ($key && isset($this->filePathPrepend[$key])) { $val = $this->filePathPrepend[$key] . $val; } if ($this->convertFilePaths) { $types = implode("|", $this->convertFileTypes); $val = preg_replace_callback("#({e_.*?\\.(" . $types . "))#i", array($this, 'replaceFilePaths'), $val); } if (is_array($val)) { return "<![CDATA[" . e107::getArrayStorage()->WriteArray($val, FALSE) . "]]>"; } if (strpos($val, "<") !== FALSE || strpos($val, ">") !== FALSE || strpos($val, "&") !== FALSE) { return "<![CDATA[" . $val . "]]>"; } return $val; }
/** * Checks user password againt preferences set etc * Assumes that $this->userData array already set up * * @param string $username - the user name string as entered (might not relate to the intended user at this stage) * @param string $userpass - as entered * @param string $response - received string if CHAP used * @param boolean $forceLogin - TRUE if login is being forced from clicking signup link; normally FALSE * @return TRUE if valid password * otherwise FALSE */ protected function checkUserPassword($username, $userpass, $response, $forceLogin) { $pref = e107::getPref(); if ($forceLogin === 'provider') { return true; } if ($this->lookEmail && vartrue($pref['passwordEncoding'])) { $tmp = e107::getArrayStorage()->unserialize($this->userData['user_prefs']); if (!$tmp && $this->userData['user_prefs']) { $tmp = unserialize($this->userData['user_prefs']); } // try old storage type $requiredPassword = varset($tmp['email_password'], $this->userData['user_password']); // Use email-specific password if set. Otherwise, 'normal' one might work unset($tmp); } else { $requiredPassword = $this->userData['user_password']; } // FIXME - [SecretR] $username is not set and I really can't get the idea. //$username = $this->userData['user_loginname']; // TODO for Steve - temporary fix, where $username comes from? // Now check password if ($forceLogin) { if (md5($this->userData['user_name'] . $this->userData['user_password'] . $this->userData['user_join']) != $userpass) { return $this->invalidLogin($username, LOGIN_BAD_PW); } } else { $session = e107::getSession(); $gotChallenge = $session->is('challenge'); //$aLogVal = "U: {$username}, P: ******, C: ".$session->get('challenge')." R:{$response} S: {$this->userData['user_password']} Prf: {$pref['password_CHAP']}/{$gotChallenge}"; if ($pref['password_CHAP'] > 0 && ($response && $gotChallenge) && $response != $session->get('challenge') || $pref['password_CHAP'] == 2) { // Verify using CHAP //$this->e107->admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","CHAP login",$aLogVal, FALSE, LOG_TO_ROLLING); if (($pass_result = $this->userMethods->CheckCHAP($session->get('challenge'), $response, $username, $requiredPassword)) === PASSWORD_INVALID) { return $this->invalidLogin($username, LOGIN_CHAP_FAIL); } } else { // Plaintext password //$this->e107->admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"DBG","Plaintext login",$aLogVal, FALSE,LOG_TO_ROLLING); if (($pass_result = $this->userMethods->CheckPassword($userpass, $this->lookEmail ? $this->userData['user_loginname'] : $username, $requiredPassword)) === PASSWORD_INVALID) { return $this->invalidLogin($username, LOGIN_BAD_PW); } } $this->passResult = $pass_result; } return TRUE; }
/** * Quick Add user submit trigger */ public function AddSubmitTrigger() { $e107cache = e107::getCache(); $userMethods = e107::getUserSession(); $mes = e107::getMessage(); $sql = e107::getDb(); $e_event = e107::getEvent(); $admin_log = e107::getAdminLog(); if (!$_POST['ac'] == md5(ADMINPWCHANGE)) { exit; } $e107cache->clear('online_menu_member_total'); $e107cache->clear('online_menu_member_newest'); $error = false; if (isset($_POST['generateloginname'])) { $_POST['loginname'] = $userMethods->generateUserLogin($pref['predefinedLoginName']); } $_POST['password2'] = $_POST['password1'] = $_POST['password']; // Now validate everything $allData = validatorClass::validateFields($_POST, $userMethods->userVettingInfo, true); // Fix Display and user name if (!check_class($pref['displayname_class'], $allData['data']['user_class'])) { if ($allData['data']['user_name'] != $allData['data']['user_loginname']) { $allData['data']['user_name'] = $allData['data']['user_loginname']; $mes->addWarning(str_replace('[x]', $allData['data']['user_loginname'], USRLAN_237)); //$allData['errors']['user_name'] = ERR_FIELDS_DIFFERENT; } } // Do basic validation validatorClass::checkMandatory('user_name, user_loginname', $allData); // Check for missing fields (email done in userValidation() ) validatorClass::dbValidateArray($allData, $userMethods->userVettingInfo, 'user', 0); // Do basic DB-related checks $userMethods->userValidation($allData); // Do user-specific DB checks if (!isset($allData['errors']['user_password'])) { // No errors in password - keep it outside the main data array $savePassword = $allData['data']['user_password']; // Delete the password value in the output array unset($allData['data']['user_password']); } // Restrict the scope of this unset($_POST['password2'], $_POST['password1']); if (count($allData['errors'])) { $temp = validatorClass::makeErrorList($allData, 'USER_ERR_', '%n - %x - %t: %v', '<br />', $userMethods->userVettingInfo); $mes->addError($temp); $error = true; } // Always save some of the entered data - then we can redisplay on error $user_data =& $allData['data']; if ($error) { $this->setParam('user_data', $user_data); return; } if (varset($_POST['perms'])) { $allData['data']['user_admin'] = 1; $allData['data']['user_perms'] = implode('.', $_POST['perms']); } $user_data['user_password'] = $userMethods->HashPassword($savePassword, $user_data['user_login']); $user_data['user_join'] = time(); if ($userMethods->needEmailPassword()) { // Save separate password encryption for use with email address $user_prefs = e107::getArrayStorage()->unserialize($user_data['user_prefs']); $user_prefs['email_password'] = $userMethods->HashPassword($savePassword, $user_data['user_email']); $user_data['user_prefs'] = e107::getArrayStorage()->serialize($user_prefs); unset($user_prefs); } $userMethods->userClassUpdate($allData['data'], 'userall'); //FIXME - (SecretR) there is a better way to fix this (missing default value, sql error in strict mode - user_realm is to be deleted from DB later) $allData['data']['user_realm'] = ''; // Set any initial classes $userMethods->addNonDefaulted($user_data); validatorClass::addFieldTypes($userMethods->userVettingInfo, $allData); $userid = $sql->insert('user', $allData); if ($userid) { $sysuser = e107::getSystemUser(false, false); $sysuser->setData($allData['data']); $sysuser->setId($userid); $user_data['user_id'] = $userid; // Add to admin log e107::getLog()->add('USET_02', "UName: {$user_data['user_name']}; Email: {$user_data['user_email']}", E_LOG_INFORMATIVE); // Add to user audit trail e107::getLog()->user_audit(USER_AUDIT_ADD_ADMIN, $user_data, 0, $user_data['user_loginname']); e107::getEvent()->trigger('userfull', $user_data); e107::getEvent()->trigger('admin_user_created', $user_data); // send everything available for user data - bit sparse compared with user-generated signup if (isset($_POST['sendconfemail'])) { $check = false; // Send confirmation email to user switch ((int) $_POST['sendconfemail']) { case 0: // activate, don't notify $check = -1; break; case 1: // activate and send password $check = $sysuser->email('quickadd', array('user_password' => $savePassword, 'mail_subject' => USRLAN_187 . SITENAME, 'activation_url' => USRLAN_238)); break; case 2: // require activation and send password and activation link $sysuser->set('user_ban', 2)->set('user_sess', e_user_model::randomKey())->save(); $check = $sysuser->email('quickadd', array('user_password' => $savePassword, 'mail_subject' => USRLAN_187 . SITENAME, 'activation_url' => SITEURL . "signup.php?activate." . $sysuser->getId() . "." . $sysuser->getValue('sess'))); break; } if ($check && $check !== -1) { $mes->addSuccess(USRLAN_188); } elseif (!$check) { $mes->addError(USRLAN_189); } } // $message = str_replace('--NAME--', htmlspecialchars($user_data['user_name'], ENT_QUOTES, CHARSET), USRLAN_174); $message = USRLAN_172; $mes->addSuccess($message)->addSuccess(USRLAN_128 . ': <strong>' . htmlspecialchars($user_data['user_loginname'], ENT_QUOTES, CHARSET) . '</strong>'); $mes->addSuccess(LAN_PASSWORD . ': <strong>' . htmlspecialchars($savePassword, ENT_QUOTES, CHARSET) . '</strong>'); return; } else { $mes->addError(LAN_CREATED_FAILED); $mes->addError($sql->getLastErrorText()); } }
public function storeSysCredentials($credentials = null) { if (null === $credentials) { $credentials = array('consumer_key' => $this->eauthConsumerKey, 'consumer_secret' => $this->eauthConsumerSecret, 'access_token' => $this->eauthAccessToken, 'access_secret' => $this->eauthAccessSecret); } if (!is_array($credentials)) { return false; } foreach ($credentials as $key => $value) { switch ($key) { case 'consumer_key': case 'consumer_secret': case 'access_token': case 'access_secret': // OK break; default: unset($credentials[$key]); break; } } return e107::getArrayStorage()->store($credentials, 'eauth'); }
unset($_POST['SaveValidatedInfo']); // At this point we know the error status. // $changedUserData has an array of core changed data, except password, which is in $savePassword if changed (or entered as confirmation). // $eufData has extended user field data // $changedEUFData has any changes in extended user field data $dataToSave = !$error && (isset($changedUserData) && count($changedUserData)) || isset($changedEUFData['data']) && count($changedEUFData['data']) || $savePassword; if ($dataToSave) { // Sort out password hashes if ($savePassword) { $loginname = $changedUserData['user_loginname'] ? $changedUserData['user_loginname'] : $udata['user_loginname']; $email = isset($changedUserData['user_email']) && $changedUserData['user_email'] ? $changedUserData['user_email'] : $udata['user_email']; $changedUserData['user_password'] = $sql->escape($userMethods->HashPassword($savePassword, $loginname), false); if (varset($pref['allowEmailLogin'], FALSE)) { $user_prefs = e107::getArrayStorage()->unserialize($udata['user_prefs']); $user_prefs['email_password'] = $userMethods->HashPassword($savePassword, $email); $changedUserData['user_prefs'] = e107::getArrayStorage()->serialize($user_prefs); } } else { if (isset($changedUserData['user_loginname']) && $userMethods->isPasswordRequired('user_loginname') || isset($changedUserData['user_email']) && $userMethods->isPasswordRequired('user_email')) { if ($_uid && ADMIN) { // Admin is changing it $error = LAN_USET_20; } else { // User is changing their own info $promptPassword = true; } } } } if ($dataToSave && !$promptPassword) { $inp = intval($inp);
/** * Function to retrieve Menu data from tables. */ private function getDataLegacy() { $sql = e107::getDb(); $menu_layout_field = THEME_LAYOUT != e107::getPref('sitetheme_deflayout') ? THEME_LAYOUT : ""; // e107::getCache()->CachePageMD5 = md5(e_LANGUAGE.$menu_layout_field); // Disabled by line 93 of Cache class. //FIXME add a function to the cache class for this. $menu_data = e107::getCache()->retrieve_sys("menus_" . USERCLASS_LIST . "_" . md5(e_LANGUAGE . $menu_layout_field)); // $menu_data = e107::getCache()->retrieve_sys("menus_".USERCLASS_LIST); $menu_data = e107::getArrayStorage()->ReadArray($menu_data); // $menu_data = e107::getArrayStorage()->ReadArray($menu_data); $eMenuArea = array(); // $eMenuList = array(); // $eMenuActive = array(); // DEPRECATED if (!is_array($menu_data)) { $menu_qry = 'SELECT * FROM #menus WHERE menu_location > 0 AND menu_class IN (' . USERCLASS_LIST . ') AND menu_layout = "' . $menu_layout_field . '" ORDER BY menu_location,menu_order'; if ($sql->gen($menu_qry)) { while ($row = $sql->fetch()) { $eMenuArea[$row['menu_location']][] = $row; } } $menu_data['menu_area'] = $eMenuArea; $menuData = e107::getArrayStorage()->WriteArray($menu_data, false); // e107::getCache()->set_sys('menus_'.USERCLASS_LIST, $menuData); e107::getCache()->set_sys('menus_' . USERCLASS_LIST . '_' . md5(e_LANGUAGE . $menu_layout_field), $menuData); } else { $eMenuArea = $menu_data['menu_area']; } return $eMenuArea; }
/** * Load data from user preferences string * @param boolean $force * @return e_user_pref */ public function load($force = false) { if ($force || !$this->hasData()) { $data = $this->_user->get('user_prefs', ''); if (!empty($data)) { // BC $data = substr($data, 0, 5) == "array" ? e107::getArrayStorage()->ReadArray($data) : unserialize($data); if (!$data) { $data = array(); } } else { $data = array(); } $this->setData($data); } return $this; }
/** * Return an Array of core preferences from e107 XML Dump data * * @param array $XMLData Raw XML e107 Export Data * @param string $prefType [optional] the type of core pref: core|emote|ipool|menu etc. * @return array preference array equivalent to the old $pref global; */ public function e107ImportPrefs($XMLData, $prefType = 'core') { if (!vartrue($XMLData['prefs'][$prefType])) { return array(); } //$mes = eMessage::getInstance(); $pref = array(); foreach ($XMLData['prefs'][$prefType] as $val) { $name = $val['@attributes']['name']; // if(strpos($val['@value'], 'array (') === 0) // { // echo '<pre>'.$val['@value']; // echo "\n"; // var_dump(e107::getArrayStorage()->ReadArray($val['@value'])); // echo $val['@value'].'</pre>'; // } $value = strpos($val['@value'], 'array (') === 0 ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value']; $pref[$name] = $value; // $mes->add("Setting up ".$prefType." Pref [".$name."] => ".$value, E_MESSAGE_DEBUG); } return $pref; }
/** * Update pref set and cache * * - @param string $name -- name of pref row * - @param string $table -- "core" or "user" * - @global $$name * - @access public * * set() == core, pref * set("rowname") == core, rowname * set("","user") == user, user_pref for current user * set("","user",uid) == user, user_pref for user uid * set("fieldname","user") == user, fieldname * * all pref sets other than menu_pref get toDB() */ function setArray($name = '', $table = 'core', $uid = USERID) { $tp = e107::getParser(); if (!strlen($name)) { switch ($table) { case 'core': $name = 'pref'; break; case 'user': $name = 'user_pref'; break; } } global ${$name}; if ($name != 'menu_pref') { foreach (${$name} as $key => $prefvalue) { ${$name}[$key] = $tp->toDB($prefvalue); } } $tmp = e107::getArrayStorage()->WriteArray(${$name}, FALSE); // $this->set() adds slashes now // $tmp = serialize($$name); $this->set($tmp, $name, $table, $uid); }
} else { if ($query[1] == 'p') { $handler_type = 'plug_handlers'; } else { exit; // Illegal value } } $query[2] = $tp->toDB($query[2]); $search_prefs[$handler_type][$query[2]]['class'] = intval($_POST['class']); $search_prefs[$handler_type][$query[2]]['chars'] = $tp->toDB($_POST['chars']); $search_prefs[$handler_type][$query[2]]['results'] = $tp->toDB($_POST['results']); $search_prefs[$handler_type][$query[2]]['pre_title'] = intval($_POST['pre_title']); $search_prefs[$handler_type][$query[2]]['pre_title_alt'] = $tp->toDB($_POST['pre_title_alt']); // $tmp = addslashes(serialize($search_prefs)); $tmp = e107::getArrayStorage()->writeArray($search_prefs, true); $check = $sql->db_Update("core", "e107_value='" . $tmp . "' WHERE e107_name='search_prefs'"); if ($check) { $mes->addSuccess(LAN_UPDATED); e107::getLog()->add('SEARCH_05', $handler_type . ', ' . $query[2], E_LOG_INFORMATIVE, ''); } elseif (0 === $check) { $mes->addInfo(LAN_NO_CHANGE); } else { $mes->addError(LAN_UPDATED_FAILED, E_MESSAGE_ERROR); $mes->addError(LAN_ERROR . " " . $sql->getLastErrorNumber() . ': ' . $sql->getLastErrorText()); } } if (isset($_POST['update_prefs'])) { unset($temp); $temp['relevance'] = intval($_POST['relevance']); $temp['user_select'] = intval($_POST['user_select']);
function getFeed($feedID, $force = FALSE) { global $e107, $admin_log; $tp = e107::getParser(); $sql = e107::getDb(); $eArrayStorage = e107::getArrayStorage(); $this->readFeedList(); // Make sure we've got the feed data. if (!isset($this->feedList[$feedID])) { if (NEWSFEED_DEBUG) { echo "Invalid feed number: {$feedID}<br />"; } return FALSE; } if (strpos($this->newsList[$feedID]['newsfeed_data'], 'MagpieRSS')) { $force = true; } if ($force || !isset($this->newsList[$feedID]['newsfeed_data']) || !$this->newsList[$feedID]['newsfeed_data']) { // No data already in memory if ($force || !($this->newsList[$feedID]['newsfeed_data'] = $e107->ecache->retrieve(NEWSFEED_NEWS_CACHE_TAG . $feedID, $this->feedList[$feedID]['newsfeed_updateint'] / 60))) { // Need to re-read from source - either no cached data yet, or cache expired if (NEWSFEED_DEBUG) { $admin_log->e_log_event(10, debug_backtrace(), "DEBUG", "Newsfeed update", "Refresh item: " . $feedID, FALSE, LOG_TO_ROLLING); } require_once e_HANDLER . 'xml_class.php'; $xml = new xmlClass(); require_once e_HANDLER . 'magpie_rss.php'; $dbData = array(); // In case we need to update DB if ($rawData = $xml->getRemoteFile($this->feedList[$feedID]['newsfeed_url'])) { $rss = new MagpieRSS($rawData); list($newsfeed_image, $newsfeed_showmenu, $newsfeed_showmain) = explode("::", $this->feedList[$feedID]['newsfeed_image']); $temp['channel'] = $rss->channel; if ($newsfeed_showmenu == 0 || $newsfeed_showmain == 0) { $temp['items'] = $rss->items; // Unlimited items } else { $temp['items'] = array_slice($rss->items, 0, max($newsfeed_showmenu, $newsfeed_showmain)); // Limited items } $newsfeed_des = FALSE; if ($this->feedList[$feedID]['newsfeed_description'] == 'default') { $temp['newsfeed_description'] = 'default'; // This prevents db writes if no better data found if ($rss->channel['description']) { $newsfeed_des = $tp->toDB($rss->channel['description']); $temp['newsfeed_description'] = $newsfeed_des; } elseif ($rss->channel['tagline']) { $newsfeed_des = $tp->toDB($rss->channel['tagline']); $temp['newsfeed_description'] = $newsfeed_des; } if ($temp['newsfeed_description'] != $this->feedList[$feedID]['newsfeed_description']) { // Need to write updated feed name to DB $this->feedList[$feedID]['newsfeed_description'] = $temp['newsfeed_description']; $dbData['newsfeed_description'] = $temp['newsfeed_description']; if ($this->useCache) { $e107->ecache->clear(NEWSFEED_LIST_CACHE_TAG); // Clear the newsfeed cache so its re-read next time } } } if ($newsfeed_image == 'default') { $temp['newsfeed_image_link'] = "<a href='" . $rss->image['link'] . "' rel='external'><img src='" . $rss->image['url'] . "' alt='" . $rss->image['title'] . "' style='vertical-align: middle;' /></a>"; } else { $temp['newsfeed_image_link'] = "<img src='" . $this->feedList[$feedID]['newsfeed_image'] . "' alt='' />"; } $serializedArray = $eArrayStorage->WriteArray($temp, FALSE); $now = time(); $this->newsList[$feedID]['newsfeed_data'] = $serializedArray; $this->newsList[$feedID]['newsfeed_timestamp'] = $now; if ($this->useCache) { $e107->ecache->set(NEWSFEED_NEWS_CACHE_TAG . $feedID, $serializedArray); } else { $dbData['newsfeed_data'] = addslashes($serializedArray); $dbData['newsfeed_timestamp'] = $now; } if (count($dbData)) { if (FALSE === $sql->db_UpdateArray('newsfeed', $dbData, " WHERE newsfeed_id=" . $feedID)) { if (NEWSFEED_DEBUG) { echo NFLAN_48 . "<br /><br />" . var_dump($dbData); } } } unset($rss); } else { if (NEWSFEED_DEBUG) { echo $xml->error; } return FALSE; } } } return e107::unserialize($this->newsList[$feedID]['newsfeed_data']); }
if (USERID == $row['user_id']) { $cookieChange = $newData['user_password']; } } else { $cantProcess++; } } if ($emailGen == 1 && $user_info->canConvert($row['user_password'])) { $user_prefs['email_password'] = $user_info->ConvertPassword($row['user_password'], $row['user_email']); $emailProcess++; } elseif ($emailGen == 2) { unset($user_prefs['email_password']); $emailProcess++; } if (count($user_prefs)) { $newPrefs = e107::getArrayStorage()->serialize($user_prefs); } else { $newPrefs = ''; } if ($newPrefs != $user_prefs) { $newData['user_prefs'] = $newPrefs; } if (count($newData)) { $sql->db_UpdateArray('user', $newData, " WHERE `user_id`={$row['user_id']}"); } } } echo str_replace('--TOTAL--', $recordCount, LAN_PCONV_22) . '<br />'; echo str_replace('--TOTAL--', $saltProcess, LAN_PCONV_24) . '<br />'; echo str_replace('--TOTAL--', $emailProcess, LAN_PCONV_23) . '<br />'; echo str_replace('--TOTAL--', $cantProcess, LAN_PCONV_25) . '<br />';
$allData['data']['user_ban'] = USER_REGISTERED_NOT_VALIDATED; } else { $allData['data']['user_ban'] = USER_VALIDATED; } // Work out data to be written to user audit trail $signup_data = array('user_name', 'user_loginname', 'user_email', 'user_ip'); // foreach (array() as $f) foreach ($signup_data as $f) { $signup_data[$f] = $allData['data'][$f]; // Just copy across selected fields } $allData['data']['user_password'] = $userMethods->HashPassword($savePassword, $allData['data']['user_loginname']); if (vartrue($pref['allowEmailLogin'])) { // Need to create separate password for email login //$allData['data']['user_prefs'] = serialize(array('email_password' => $userMethods->HashPassword($savePassword, $allData['data']['user_email']))); $allData['data']['user_prefs'] = e107::getArrayStorage()->serialize(array('email_password' => $userMethods->HashPassword($savePassword, $allData['data']['user_email']))); } $allData['data']['user_join'] = time(); $allData['data']['user_ip'] = e107::getIPHandler()->getIP(FALSE); if (!vartrue($allData['data']['user_name'])) { $allData['data']['user_name'] = $allData['data']['user_loginname']; $signup_data['user_name'] = $allData['data']['user_loginname']; } // The user_class, user_perms, user_prefs, user_realm fields don't have default value, // so we put apropriate ones, otherwise - broken DB Insert $allData['data']['user_class'] = ''; $allData['data']['user_perms'] = ''; $allData['data']['user_prefs'] = ''; $allData['data']['user_realm'] = ''; if (empty($allData['data']['user_signature'])) { $allData['data']['user_signature'] = '';
/** * Convert object data to a string * * @param boolean $AddSlashes * @param string $node_id optional, if set method will return corresponding value as a string * @param boolean $total include total results property * @return string */ public function toString($AddSlashes = true, $node_id = null, $total = false) { if (null !== $node_id && $this->isNode($node_id)) { return $this->getNode($node_id)->toString($AddSlashes); } return (string) e107::getArrayStorage()->WriteArray($this->toArray($total), $AddSlashes); }
function installCheck($do_one = FALSE) { global $e107; $sql = e107::getDb(); $fl = e107::getFile(); $ns = e107::getRender(); $mes = e107::getMessage(); // Pick up a list of emote packs from the database $pack_local = array(); if ($sql->db_Select("core", "*", "`e107_name` LIKE 'emote_%'")) { while ($row = $sql->db_Fetch()) { $pack_local[substr($row['e107_name'], 6)] = TRUE; } } foreach ($this->packArray as $value) { if (strpos($value, ' ') !== FALSE) { // Highlight any directory names containing spaces - not allowed $msg = "\r\n\t\t\t\t\t<strong>" . EMOLAN_17 . "</strong> " . EMOLAN_18 . ":\r\n\t\t\t\t\t<div>" . LAN_NAME . ": {$value}</div>\r\n\t\t\t\t\t<div>" . EMOLAN_20 . ": " . e_IMAGE_ABS . "emotes/</div>\r\n\t\t\t\t"; $mes->addError($msg); $ns->tablerender(EMOLAN_PAGE_TITLE . ' - ' . EMOLAN_21, $mes->render()); return FALSE; } if (array_key_exists($value, $pack_local)) { unset($pack_local[$value]); } if ($do_one == $value || !$do_one && !$sql->db_Select("core", "*", "e107_name='emote_" . $value . "' ")) { // Pack info not in DB, or to be re-scanned $no_error = TRUE; $File_type = EMOLAN_32 . ":"; // Array of all files in the directory of the selected emote pack $fileArray = $fl->get_files(e_IMAGE . "emotes/" . $value); // We actually want all the files in the directory $confFile = ''; foreach ($fileArray as $k => $file) { if (strstr($file['fname'], ".xml")) { $confFile = array('file' => $file['fname'], 'type' => "xml"); } else { if (strstr($file['fname'], ".pak")) { $confFile = array('file' => $file['fname'], 'type' => "pak"); } else { if (strstr($file['fname'], ".php")) { $confFile = array('file' => $file['fname'], 'type' => "php"); } } } if ($confFile) { unset($fileArray[$k]); break; } } /* .pak file */ if ($confFile['type'] == "pak") { $filename = e_IMAGE . "emotes/" . $value . "/" . $confFile['file']; $pakconf = file($filename); $contentArray = array(); foreach ($pakconf as $line) { if (trim($line) && strstr($line, "=+") && !strstr($line, ".txt") && !strstr($line, ".html") && !strstr($line, "cvs")) { $contentArray[] = $line; } } $confArray = array(); foreach ($contentArray as $pakline) { $tmp = explode("=+:", $pakline); $confIC = str_replace(".", "!", $tmp[0]); $confArray[$confIC] = trim($tmp[2]); } // $tmp = addslashes(serialize($confArray)); $tmp = e107::getArrayStorage()->WriteArray($confArray); $File_type = EMOLAN_22 . ":"; } /* end */ /* .xml file */ if ($confFile['type'] == "xml") { $filename = e_IMAGE . "emotes/" . $value . "/" . $confFile['file']; $contents = file_get_contents($filename); $confArray = array(); $xml_type = 0; if (strpos($contents, "<icon>") !== FALSE && strpos($contents, "<icondef>") !== FALSE) { // xep-0038 format /* Example: <icon> <text>:-)</text> <text>:)</text> <object mime="image/png">happy.png</object> <object mime="audio/x-wav">choir.wav</object> </icon>*/ preg_match_all("#\\<icon>(.*?)\\<\\/icon\\>#si", $contents, $match); $xml_type = 1; // $match[0] - complete emoticon entry // $match[1] - match string and object specification $item_index = 1; } elseif (strpos($contents, "<emoticon") !== FALSE) { // "Original" E107 format (as used on KDE, although they may be changing to XEP-0038) //echo "Decoding standard XML file<br />"; preg_match_all("#\\<emoticon file=\"(.*?)\"\\>(.*?)\\<\\/emoticon\\>#si", $contents, $match); $xml_type = 2; // $match[0] - complete emoticon entry // $match[1] - filename (may or may not not have file extension/suffix) // $match[2] - match string(s) representing emote $item_index = 2; } if ($xml_type) { for ($a = 0; $a < count($match[0]); $a++) { $e_file = ''; switch ($xml_type) { case 1: // xep-0038 // Pull out a file name (only support first image type) - its in $fmatch[1] if (preg_match("#\\<object\\s*?mime\\=[\"\\']image\\/.*?\\>(.*?)\\<\\/object\\>#si", $match[1][$a], $fmatch)) { $e_file = $fmatch[1]; // echo "xep-0038 file: ".$e_file."<br />"; // Pull out all match strings - need to pick out any language definitions for posterity // but currently accept all language strings preg_match_all("#\\<text(?:\\s*?\\>|\\s*?xml\\:lang\\=\"(.*?)\"\\>)(.*?)\\<\\/text\\>#si", $match[1][$a], $match2); // $match2[1] is the languages // $match2[2] is the match strings $codet = implode(" ", $match2[2]); } break; case 2: $e_file = $match[1][$a]; // Now pull out all the 'match' strings preg_match_all("#\\<string\\>(.*?)\\<\\/string\\>#si", $match[2][$a], $match2); $codet = implode(" ", $match2[1]); break; } // $e_file has the emote file name // $match2 has an array of substitution strings $file = ''; foreach ($fileArray as $emote) { // Check that the file exists if (strpos($e_file, ".") === FALSE) { // File extension not specified - accept any file extension for match if (strpos($emote['fname'], $e_file . ".") === 0) { $file = str_replace(".", "!", $emote['fname']); break; } } else { // File extension specified - do simple match if ($emote['fname'] == $e_file) { $file = str_replace(".", "!", $emote['fname']); break; } } } // Only add if the file exists. OK if no definition - might want to be added if ($file) { $confArray[$file] = $codet; } } } else { //echo "Unsupported XML File Format<br /><br />"; $mes->addWarning(EMOLAN_33); $no_error = FALSE; } // Save pack info in the database // $tmp = addslashes(serialize($confArray)); $tmp = e107::getArrayStorage()->WriteArray($confArray); $File_type = EMOLAN_23 . ":"; } if ($confFile['type'] == "php") { include_once e_IMAGE . "emotes/" . $value . "/" . $confFile['file']; $File_type = EMOLAN_24 . ":"; $tmp = $_emoteconf; // Use consistent name } if ($no_error) { if ($do_one) { // Assume existing pack $sql->db_Update("core", "`e107_value`='{$tmp}' WHERE `e107_name`='emote_" . $value . "'"); } else { // Assume new pack $sql->db_Insert("core", "'emote_" . $value . "', '{$tmp}' "); } $mes->addInfo("<strong>{$File_type}</strong> '{$value}'"); } else { // Error occurred $mes->addError(EMOLAN_27 . ": '{$value}'"); } } } if (count($pack_local)) { foreach ($pack_local as $p => $d) { $mes->addInfo(EMOLAN_34 . ":" . $p . EMOLAN_35); $sql->db_Delete("core", "`e107_name` = 'emote_{$p}'"); } } return TRUE; }
public function __get($name) { switch ($name) { case 'tp': $ret = e107::getParser(); break; case 'sql': $ret = e107::getDb(); break; case 'ecache': $ret = e107::getCache(); break; case 'arrayStorage': $ret = e107::getArrayStorage(); break; case 'e_event': $ret = e107::getEvent(); break; case 'ns': $ret = e107::getRender(); break; case 'url': $ret = e107::getUrl(); break; case 'admin_log': $ret = e107::getAdminLog(); break; case 'override': $ret = e107::getSingleton('override', e_HANDLER . 'override_class.php'); break; case 'notify': $ret = e107::getNotify(); break; case 'e_online': $ret = e107::getOnline(); break; case 'eIPHandler': $ret = e107::getIPHandler(); break; case 'user_class': $ret = e107::getUserClass(); break; default: trigger_error('$e107->$' . $name . ' not defined', E_USER_WARNING); return null; break; } $this->{$name} = $ret; return $ret; }
/** * Creates a field type definition from the structure of the table in the DB * * Generate and save a cache file in the e_CACHE_DB directory, * Also update $this->dbFieldDefs[$tableName] - FALSE if error, data if found * * @param string $tableName - name of table sought * * @return boolean TRUE on success, FALSE on not found (some errors intentionally ignored) */ protected function makeTableDef($tableName) { require_once e_HANDLER . 'db_table_admin_class.php'; $dbAdm = new db_table_admin(); $baseStruct = $dbAdm->get_current_table($tableName); $fieldDefs = $dbAdm->parse_field_defs($baseStruct[0][2]); // Required definitions $outDefs = array(); foreach ($fieldDefs as $k => $v) { switch ($v['type']) { case 'field': if (vartrue($v['autoinc'])) { //break; Probably include autoinc fields in array } $baseType = preg_replace('#\\(\\d+?\\)#', '', $v['fieldtype']); // Should strip any length switch ($baseType) { case 'int': case 'shortint': case 'tinyint': $outDefs['_FIELD_TYPES'][$v['name']] = 'int'; break; case 'char': case 'text': case 'varchar': $outDefs['_FIELD_TYPES'][$v['name']] = 'escape'; //XXX toDB() causes serious BC issues. break; } // if($v['name']) if (isset($v['nulltype']) && !isset($v['default'])) { $outDefs['_NOTNULL'][$v['name']] = ''; } break; case 'pkey': case 'ukey': case 'key': case 'ftkey': break; // Do nothing with keys for now // Do nothing with keys for now default: echo "Unexpected field type: {$k} => {$v['type']}<br />"; } } $array = e107::getArrayStorage(); $this->dbFieldDefs[$tableName] = $outDefs; $toSave = $array->WriteArray($outDefs, FALSE); // 2nd parameter to TRUE if needs to be written to DB if (FALSE === file_put_contents(e_CACHE_DB . $tableName . '.php', $toSave)) { // Could do something with error - but mustn't return FALSE - would trigger auto-generated structure $mes = e107::getMessage(); $mes->addDebug("Error writing file: " . e_CACHE_DB . $tableName . '.php'); //Fix for during v1.x -> 2.x upgrade. // echo "Error writing file: ".e_CACHE_DB.$tableName.'.php'.'<br />'; } }
/** * Ensure the tree of userclass data is stored in our object ($this->class_tree). * Only read if its either not present, or the $force flag is set. * Data is cached if enabled * * @param boolean $force - set to TRUE to force a re-read of the info regardless. * @return none */ public function readTree($force = FALSE) { if (isset($this->class_tree) && count($this->class_tree) && !$force) { return; } $e107 = e107::getInstance(); $this->class_tree = array(); $this->class_parents = array(); if ($temp = $e107->ecache->retrieve_sys(UC_CACHE_TAG)) { $this->class_tree = e107::getArrayStorage()->read($temp); unset($temp); } else { $this->sql_r->db_Select('userclass_classes', '*', 'ORDER BY userclass_parent', 'nowhere'); // The order statement should give a consistent return while ($row = $this->sql_r->db_Fetch(MYSQL_ASSOC)) { $this->class_tree[$row['userclass_id']] = $row; $this->class_tree[$row['userclass_id']]['class_children'] = array(); // Create the child array in case needed } // Add in any fixed classes that aren't already defined (they historically didn't have a DB entry, although now its facilitated (and necessary for tree structure) foreach ($this->fixed_classes as $c => $d) { if (!isset($this->class_tree[$c])) { switch ($c) { case e_UC_ADMIN: case e_UC_MAINADMIN: $this->class_tree[$c]['userclass_parent'] = e_UC_NOBODY; break; case e_UC_NEWUSER: $this->class_tree[$c]['userclass_parent'] = e_UC_MEMBER; break; default: $this->class_tree[$c]['userclass_parent'] = e_UC_PUBLIC; } $this->class_tree[$c]['userclass_id'] = $c; $this->class_tree[$c]['userclass_name'] = $d; $this->class_tree[$c]['userclass_description'] = 'Fixed class'; $this->class_tree[$c]['userclass_visibility'] = e_UC_PUBLIC; $this->class_tree[$c]['userclass_editclass'] = e_UC_MAINADMIN; $this->class_tree[$c]['userclass_accum'] = $c; $this->class_tree[$c]['userclass_type'] = UC_TYPE_STD; } } $userCache = e107::serialize($this->class_tree, FALSE); $e107->ecache->set_sys(UC_CACHE_TAG, $userCache); unset($userCache); } // Now build the tree. // There are just two top-level classes - 'Everybody' and 'Nobody' $this->class_parents[e_UC_PUBLIC] = e_UC_PUBLIC; $this->class_parents[e_UC_NOBODY] = e_UC_NOBODY; foreach ($this->class_tree as $uc) { if ($uc['userclass_id'] != e_UC_PUBLIC && $uc['userclass_id'] != e_UC_NOBODY) { if (!isset($this->class_tree[$uc['userclass_parent']])) { echo "Orphaned class record: ID=" . $uc['userclass_id'] . " Name=" . $uc['userclass_name'] . " Parent=" . $uc['userclass_parent'] . "<br />"; } else { // Add to array $this->class_tree[$uc['userclass_parent']]['class_children'][] = $uc['userclass_id']; } } } }
| $Revision: 11678 $ | $Id: links.php 11678 2010-08-22 00:43:45Z e107coders $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { require_once '../../class2.php'; } if (!e107::isInstalled('links_page')) { e107::redirect(); exit; } $link_shortcodes = e107::getScBatch('links_page', TRUE); require_once e_PLUGIN . 'links_page/link_defines.php'; require_once e_HANDLER . "userclass_class.php"; $eArrayStorage = e107::getArrayStorage(); $db = e107::getDb(); $mes = e107::getMessage(); require_once e_HANDLER . "form_handler.php"; $rs = new form(); require_once e_HANDLER . "file_class.php"; $fl = new e_file(); $cobj = e107::getComment(); require_once e_PLUGIN . 'links_page/link_class.php'; $lc = new linkclass(); global $tp; $linkspage_pref = e107::pref('links_page'); $deltest = array_flip($_POST); $from = "0"; if (e_QUERY) { $qs = explode(".", e_QUERY);
function convert_serialized($serializedData) { $arrayData = unserialize($serializedData); return e107::getArrayStorage()->WriteArray($arrayData, FALSE); }