public static function get_special($specialkey, $key1, $key2 = '', $key3 = '') { self::__make(); $tmp = self::$_store->get(self::$_key, $key1, $key2, $key3); $tmp = base64_decode($tmp); $data = unserialize(cge_encrypt::decrypt($specialkey, $tmp)); return $data; }
/** * A utility function to decrypt previously encrypted parameters. * * This method accepts a parameter array (the output from it's companion method) and decrypts the input. * * @param array $params an encrypted associative array with at least one element: _d. * @return array */ public static function decrypt_params($params) { $key = CMS_VERSION . __FILE__; if (!isset($params['_d'])) { return; } $tmp = cge_encrypt::decrypt($key, base64_decode($params['_d'])); $tmp = unserialize($tmp); unset($params['_d']); $tmp = array_merge($params, $tmp); return $tmp; }
/** * A convenience method to decrypt some data * * @see cge_encrypt * @param string $key The encryption key * @param string $data The data to decrypt * @return string The derypted data */ function decrypt($key, $data) { return cge_encrypt::decrypt($key, $data); }
private function _getBulkUsers($uids, $deep = FALSE) { static $_bulkusers = FALSE; if (!is_array($uids) || count($uids) == 0) { return; } if ($_bulkusers == TRUE) { throw new Exception('_getBulkUsers recursion'); } $_bulkusers = TRUE; $need = array(); $needprops = array(); for ($i = 0; $i < count($uids); $i++) { $uid = $uids[$i]; if (!is_array($this->_cached_uid_map) || !isset($this->_cached_uid_map[$uid])) { $need[] = (int) $uid; if ($deep) { $needprops[] = (int) $uid; } } else { if ($deep && !isset($this->_cached_uid_map[$uid]['fprops'])) { $needprops[] = (int) $uid; } } } $db = $this->GetDb(); $uinfo = ''; if (count($need)) { $uquery = 'SELECT * FROM ' . cms_db_prefix() . 'module_feusers_users WHERE id IN ('; $uquery .= implode(',', $need) . ') ORDER BY id'; $uinfo = $db->GetArray($uquery); if (!is_array($uinfo)) { $_bulkusers = FALSE; return; } } $pinfo = ''; if (count($needprops)) { if ($deep && count($needprops)) { $pquery = 'SELECT * FROM ' . cms_db_prefix() . 'module_feusers_properties WHERE userid IN ('; $pquery .= implode(',', $needprops) . ') ORDER BY userid,title'; $pinfo = $db->GetArray($pquery); } } $result = array(); foreach ($uids as $uid) { if (in_array($uid, $need)) { foreach ($uinfo as $urow) { if ($urow['id'] < $uid) { continue; } if ($urow['id'] > $uid) { break; } $this->_cached_uid_map[$uid] = $urow; } } if (!isset($this->_cached_uid_map[$uid])) { $_bulkusers = FALSE; return; // debug message? } if (in_array($uid, $needprops)) { $defns = $this->GetPropertyDefns(); $tmp = array(); for ($i = 0; $i < count($pinfo); $i++) { $prow = $pinfo[$i]; if ($prow['userid'] < $uid) { continue; } if ($prow['userid'] > $uid) { break; } if ($defns[$prow['title']]['encrypt']) { if (!$this->_encryption_key) { $_bulkusers = FALSE; return; } $prow['data'] = trim(cge_encrypt::decrypt($this->_encryption_key, base64_decode($prow['data']))); } $tmp[] = $prow; } $this->_cached_uid_map[$uid]['fprops'] = $tmp; } if ($deep && !isset($this->_cached_uid_map[$uid]['fprops'])) { // debug message ? $_bulkusers = FALSE; return; } $result[$uid] = $this->_cached_uid_map[$uid]; } $_bulkusers = FALSE; return $result; }