本文整理汇总了PHP中IPSLib::isSerialized方法的典型用法代码示例。如果您正苦于以下问题:PHP IPSLib::isSerialized方法的具体用法?PHP IPSLib::isSerialized怎么用?PHP IPSLib::isSerialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPSLib
的用法示例。
在下文中一共展示了IPSLib::isSerialized方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFromSqlJoin
/**
* Sets internal data based on data fetched from a join
* @param array $data
*/
public function setFromSqlJoin($data, $app = '')
{
$app = $app ? $app : IPS_APP_COMPONENT;
$data = $this->_fetchModule($app)->convertData($data);
$_key = array();
$_data = array();
/* Check key */
if (empty($data['item_key'])) {
return $data;
}
foreach ($this->_dbFields as $field) {
if (isset($data[$field])) {
$_data[$field] = $data[$field];
unset($data[$field]);
}
}
if (count($_data) && empty($_data['item_is_deleted'])) {
if (IPSLib::isSerialized($_data['item_read_array'])) {
$_data['item_read_array'] = unserialize($_data['item_read_array']);
}
$this->_itemMarkers[$app][$_data['item_key']] = $_data;
}
/* Recommend you always use the returned array as it removes the marking data to reduce memory footprint */
return $data;
}
示例2: _showAddForumDialog
/**
* Show the add forum dialog
*/
protected function _showAddForumDialog()
{
$type = trim($this->request['type']);
$rules = $this->archiveWriter->getRulesFromDb();
$current = array();
if (IPSLib::isSerialized($rules[$type]['forum']['text'])) {
$current = unserialize($rules[$type]['forum']['text']);
}
$multiSelect = $this->registry->class_forums->forumsForumJump(1, 0, 1, $current, true);
$this->returnHtml($this->html->showAddForumDialog($multiSelect, $type));
}
示例3: save
/**
* Save the form
*
* @return @e void [Outputs to screen]
*/
protected function save()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$name = trim(IPSText::alphanumericalClean($this->request['name']));
$this->hookId = intval($this->request['id']);
$this->hook = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $this->hookId));
$this->data = IPSLib::isSerialized($this->hook['hook_extra_data']) ? unserialize($this->hook['hook_extra_data']) : array('display' => array());
$output = '';
//-----------------------------------------
// Got a hook?
//-----------------------------------------
if (!$this->hook['hook_id']) {
$this->returnJsonError($this->lang->words['hook_cannot_load']);
}
//-----------------------------------------
// Run the proper operation
//-----------------------------------------
switch ($name) {
case 'settings':
$_settingGroups = $this->hooksFunctions->getSettingGroups();
$_settings = $this->hooksFunctions->getSettings();
$toSave = array();
$toDisplay = array();
$toSave['settingGroups'] = array();
$toSave['settings'] = array();
if (is_array($this->request['setting_groups']) and count($this->request['setting_groups'])) {
$toSave['settingGroups'] = $this->request['setting_groups'];
foreach ($_settingGroups as $data) {
if (in_array($data[0], $toSave['settingGroups'])) {
$toDisplay['settingGroups'][] = $data[1];
}
}
}
if (is_array($this->request['settings']) and count($this->request['settings'])) {
$toSave['settings'] = $this->request['settings'];
foreach ($_settings as $data) {
if (in_array($data[0], $toSave['settings'])) {
$toDisplay['settings'][] = $data[1];
}
}
}
if (count($toSave['settingGroups'])) {
$this->data['settingGroups'] = $toSave['settingGroups'];
} else {
unset($this->data['settingGroups']);
}
if (count($toSave['settings'])) {
$this->data['settings'] = $toSave['settings'];
} else {
unset($this->data['settings']);
}
if (count($toDisplay['settingGroups'])) {
$output .= "{$this->lang->words['hook_setting_groups']} " . implode(', ', $toDisplay['settingGroups']);
}
if (count($toDisplay['settings'])) {
if (count($toDisplay['settingGroups'])) {
$output .= '<br />';
}
$output .= "{$this->lang->words['hook_settings']} " . implode(', ', $toDisplay['settings']);
}
if ($output) {
$this->data['display']['settings'] = $output;
} else {
$output = $this->lang->words['hook_no_settings'];
if (isset($this->data['display']['settings'])) {
unset($this->data['display']['settings']);
}
}
break;
case 'language':
$_langFiles = $this->hooksFunctions->getLanguageFiles();
$ids = array();
$files = array();
$strings = array();
$toDisplay = array();
$this->data['language'] = array();
foreach ($_POST as $k => $v) {
if (preg_match("/^language_(\\d+)\$/", $k, $matches)) {
$files[$matches[1]] = $v;
$strings[$matches[1]] = $this->request['strings_' . $matches[1]];
$ids[$matches[1]] = $matches[1];
}
}
foreach ($ids as $id) {
if ($files[$id] and $strings[$id]) {
$this->data['language'][$files[$id]] = $strings[$id];
$toDisplay[] = "{$this->lang->words['hook_from']} {$files[$id]}: " . implode(', ', $strings[$id]);
}
}
if (!count($this->data['language'])) {
unset($this->data['language']);
}
if (count($toDisplay)) {
//.........这里部分代码省略.........
示例4: editPost
/**
* Edit a post
*
* Usage:
* $post->setForumID(1);
* $post->setTopicID(5);
* $post->setPostID(100);
* $post->setAuthor( $member );
*
* $post->setPostContent( "Hello [b]there![/b]" );
* # Optional: No bbcode, etc parsing will take place
* # $post->setPostContentPreFormatted( "Hello <b>there!</b>" );
* $post->editPost();
*
* Exception Error Codes:
* NO_POSTING_PPD : No post ID set
* NO_CONTENT : No post content set
* CONTENT_TOO_LONG : Post is too long
*
* @return mixed
*/
public function editPost()
{
//-----------------------------------------
// Global checks and functions
//-----------------------------------------
try {
$this->globalSetUp();
} catch (Exception $error) {
$e = $error->getMessage();
if ($e != 'NO_POSTING_PPD') {
$this->_postErrors = $error->getMessage();
}
}
if ($this->_bypassPermChecks !== TRUE && IPSMember::isOnModQueue($this->getAuthor()) === NULL) {
$this->_postErrors = 'warnings_restrict_post_perm';
}
if (!$this->getPostContent() and !$this->getPostContentPreFormatted()) {
$this->_postErrors = 'NO_CONTENT';
}
//-----------------------------------------
// Get topic
//-----------------------------------------
try {
$topic = $this->editSetUp();
} catch (Exception $error) {
$this->_postErrors = $error->getMessage();
}
//-----------------------------------------
// Parse the post, and check for any errors.
//-----------------------------------------
$post = $this->compilePostData();
//-----------------------------------------
// Do we have a valid post?
//-----------------------------------------
if (strlen(trim(IPSText::removeControlCharacters(IPSText::br2nl($post['post'])))) < 1) {
$this->_postErrors = 'NO_CONTENT';
}
if (IPSText::mbstrlen($post['post']) > $this->settings['max_post_length'] * 1024) {
$this->_postErrors = 'CONTENT_TOO_LONG';
}
if ($this->_postErrors != "") {
//-----------------------------------------
// Show the form again
//-----------------------------------------
return FALSE;
}
//-----------------------------------------
// Ajax specifics
//-----------------------------------------
if ($this->getIsAjax() === TRUE) {
# Prevent polls from being edited
$this->can_add_poll = 0;
# Prevent titles from being edited
$this->edit_title = 0;
# Prevent open time from being edited
$this->can_set_open_time = 0;
# Prevent close time from being edited
$this->can_set_close_time = 0;
# Set Settings
$this->setSettings(array('enableSignature' => $this->_originalPost['use_sig'] ? 1 : 0, 'enableEmoticons' => $this->_originalPost['use_emo'] ? 1 : 0, 'post_htmlstatus' => $this->getSettings('post_htmlstatus')));
if (!$this->getAuthor('g_append_edit')) {
$this->request['add_edit'] = ($this->_originalPost['append_edit'] or !$this->getAuthor('g_append_edit') ? 1 : 0);
}
}
//-----------------------------------------
// Compile the poll
//-----------------------------------------
if ($this->can_add_poll) {
//-----------------------------------------
// Load the poll from the DB
//-----------------------------------------
$this->poll_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'polls', 'where' => "tid=" . intval($topic['tid'])));
$this->poll_answers = !empty($this->poll_data['choices']) && IPSLib::isSerialized($this->poll_data['choices']) ? IPSLib::safeUnserialize(stripslashes($this->poll_data['choices'])) : array();
}
//-----------------------------------------
// Compile the poll
//-----------------------------------------
$this->poll_questions = $this->compilePollData();
if ($this->_postErrors != "" or $this->getIsPreview() === TRUE) {
//.........这里部分代码省略.........
示例5: getSessionBySkinId
/**
* Get a user's session
* @param int $skinSetId
*/
public function getSessionBySkinId($skinSetId)
{
$session = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_generator_sessions', 'where' => 'sg_skin_set_id=' . intval($skinSetId)));
if (!empty($session['sg_session_id'])) {
if (IPSLib::isSerialized($session['sg_data'])) {
$session['sg_data_array'] = unserialize($session['sg_data']);
if (IPSLib::isSerialized($session['sg_data_array']['set_skin_gen_data'])) {
$session['skin_gen_data'] = unserialize($session['sg_data_array']['set_skin_gen_data']);
}
}
return $session;
} else {
return false;
}
}
示例6: rebuildMobileSkinUserAgentsFromSetDataXml
/**
* Rebuilds the mobile user agents from the skin set data
*/
public function rebuildMobileSkinUserAgentsFromSetDataXml()
{
/* Init */
$mobileSkinSet = $this->fetchSkinData($this->fetchSetIdByKey('mobile', true), true);
$xmlData = array();
/* Grab xml */
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML('UTF-8');
/* Skin Set Data */
$xml->load(IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml');
foreach ($xml->fetchElements('set') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
if ($data['set_key'] == 'mobile') {
$xmlData = $data;
break;
}
}
/* Update */
if ($xmlData['set_key'] && IPSLib::isSerialized($xmlData['set_locked_uagent']) && IPSLib::isSerialized($mobileSkinSet['set_locked_uagent'])) {
$new = unserialize($xmlData['set_locked_uagent']);
$old = unserialize($mobileSkinSet['set_locked_uagent']);
/* Merge them */
foreach ($new['groups'] as $group) {
if (!in_array($group, $old['groups'])) {
$old['groups'][] = $group;
}
}
foreach ($new['uagents'] as $agent => $version) {
if (!in_array($agent, $new['uagents'])) {
$old['uagents'][$agent] = $version;
}
}
}
if (is_array($old) && count($old)) {
$this->DB->update('skin_collections', array('set_locked_uagent' => serialize($old)), "set_key='mobile'");
}
}
示例7: get
/**
* Return a cached item
* @param string $key
*/
public function get($key)
{
$data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'cache_simple', 'where' => 'cache_id=\'' . $this->DB->addSlashes($this->_makeId($key)) . '\' AND cache_perm_key=\'' . $this->DB->addSlashes($this->_makePermKey()) . '\''));
if (!empty($data['cache_id'])) {
if (!$this->_isStale($data)) {
/* Do we need to unserialize this? */
$data['cache_data'] = IPSLib::isSerialized($data['cache_data']) ? unserialize($data['cache_data']) : $data['cache_data'];
return array('data' => $data['cache_data'], 'time' => $data['cache_time']);
}
}
return null;
}
示例8: checkHookRequirements
/**
* Check if the hook meets all the requirements
*
* @param mixed $hook Can be an hook ID or an array of the hook data
* @return @e array Errors found
*/
public function checkHookRequirements($hook)
{
/* Init vars */
$hookData = array();
$reqsData = array();
$errors = array();
/* We already have some data? */
if (is_array($hook) && count($hook)) {
$hookData = $hook;
} elseif (is_int($hook)) {
$hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook));
}
/* Requirements are still serialized? */
if (IPSLib::isSerialized($hookData['hook_requirements'])) {
$hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
}
/* Make our var shorter... */
$reqsData =& $hookData['hook_requirements'];
/* Old data? - @todo: remove this check around 3.3(4?) */
if (!isset($reqsData['required_applications']['core']) && isset($reqsData['hook_ipb_version_min']) && ($reqsData['hook_ipb_version_min'] > 0 || $reqsData['hook_ipb_version_max'] > 0)) {
$reqsData['hook_ipb_version_min'] = $reqsData['hook_ipb_version_min'] < 30000 ? 30000 : $reqsData['hook_ipb_version_min'];
$reqsData['required_applications']['core'] = array('min_version' => intval($reqsData['hook_ipb_version_min']), 'max_version' => intval($reqsData['hook_ipb_version_max']));
}
//-----------------------------------------
// Let's start checking requirements
//-----------------------------------------
/* PHP */
if ($reqsData['hook_php_version_min'] or $reqsData['hook_php_version_max']) {
if ($reqsData['hook_php_version_min'] and version_compare(PHP_VERSION, $reqsData['hook_php_version_min'], '<') == true) {
$errors['php_min'] = sprintf($this->lang->words['h_phpold'], $reqsData['hook_php_version_min']);
}
if ($reqsData['hook_php_version_max'] and version_compare(PHP_VERSION, $reqsData['hook_php_version_max'], '>') == true) {
$errors['php_max'] = sprintf($this->lang->words['h_phpnew'], $reqsData['hook_php_version_max']);
}
}
/* Additional applications */
if (is_array($reqsData['required_applications']) && count($reqsData['required_applications'])) {
/* Get the setup class */
require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
/*noLibHook*/
/* Loop through all apps */
foreach ($reqsData['required_applications'] as $appKey => $appData) {
/* Versions file doesn't exist? */
if (!is_file(IPSLib::getAppDir($appKey) . '/xml/versions.xml')) {
$errors[$appKey . '_app'] = sprintf($this->lang->words['hook_require_appnotfound'], $appData['app_name']);
} elseif (!IPSLib::appIsInstalled($appKey)) {
$errors[$appKey . '_app'] = sprintf($this->lang->words['hook_require_appdisabled'], ipsRegistry::$applications[$appKey]['app_title']);
} elseif ($appData['min_version'] or $appData['max_version']) {
/* Fetch and check versions */
if (!isset($this->cachedVersions[$appKey])) {
$this->cachedVersions[$appKey] = IPSSetUp::fetchXmlAppVersions($appKey);
}
$versions = $this->cachedVersions[$appKey];
if (is_array($versions) && count($versions)) {
if (!isset($this->cachedUpgradeInfo[$appKey])) {
$_key = in_array($appKey, array('forums', 'members')) ? 'core' : $appKey;
$this->cachedUpgradeInfo[$_key] = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'upgrade_history', 'where' => "upgrade_app='{$_key}'", 'order' => 'upgrade_version_id DESC', 'limit' => array(1)));
/* Extra caching for the three core apps */
if (in_array($appKey, array('core', 'forums', 'members'))) {
$this->cachedUpgradeInfo['core'] = $this->cachedUpgradeInfo[$_key];
$this->cachedUpgradeInfo['forums'] = $this->cachedUpgradeInfo[$_key];
$this->cachedUpgradeInfo['members'] = $this->cachedUpgradeInfo[$_key];
}
}
/* Do we meet tha requirements? */
if ($appData['min_version'] and $this->cachedUpgradeInfo[$appKey]['upgrade_version_id'] < $appData['min_version']) {
$errors[$appKey . '_min'] = sprintf($this->lang->words['hook_require_tooold'], isset($versions[$appData['min_version']]) ? $versions[$appData['min_version']] : $appData['min_version']);
}
if ($appData['max_version'] and $this->cachedUpgradeInfo[$appKey]['upgrade_version_id'] > $appData['max_version']) {
$errors[$appKey . '_max'] = sprintf($this->lang->words['hook_require_toonew'], isset($versions[$appData['max_version']]) ? $versions[$appData['max_version']] : $appData['max_version']);
}
}
}
}
}
return $errors;
}
示例9: _formatCachedData
/**
* Formats cached data
* @param array $tags
* @return array
*/
protected function _formatCachedData($tags)
{
if (!is_array($tags) or !count($tags) or empty($tags['tag_cache_text'])) {
return null;
}
/* Unserialise */
if (!IPSLib::isSerialized($tags['tag_cache_text'])) {
return null;
}
$tagData = unserialize($tags['tag_cache_text']);
$tagData['formatted'] = array();
if (is_array($tagData['tags']) and count($tagData['tags'])) {
$tagData['formatted'] = $this->formatTagsForDisplay($tagData['tags'], $tags['tag_cache_key']);
$tagData['formatted']['prefix'] = false;
} else {
return null;
}
if (!empty($tagData['prefix'])) {
$tagData['formatted']['prefix'] = $this->registry->output->getTemplate($this->skin())->tagPrefix($tagData['prefix'], $this->getApp(), $this->getSearchSection());
}
return $tagData;
}
示例10: _buildQueryBit
/**
* Build a WHERE segment
* @param string $key
* @param data $data
* @param boolean $archiveOn Archive = true, skip = false
*/
protected function _buildQueryBit($key, $data, $archiveOn)
{
$strOp = $archiveOn ? '=' : '!=';
$inOp = $archiveOn ? 'IN' : 'NOT IN';
switch ($key) {
case 'state':
if ($data['value'] != '' && $data['value'] != '-') {
return $this->getDbFieldFromKey($key) . $strOp . "'" . $data['value'] . "'";
}
break;
case 'pinned':
case 'approved':
case 'poll':
if ($data['value'] != '' && $data['value'] != '-') {
return $this->getDbFieldFromKey($key) . $strOp . intval($data['value']);
}
break;
case 'post':
case 'view':
case 'rating':
if (is_numeric($data['text']) && $data['text'] > 0) {
return $this->getDbFieldFromKey($key) . $data['value'] . intval($data['text']);
}
break;
case 'lastpost':
if (is_numeric($data['text']) && $data['text'] > 0) {
switch ($data['unit']) {
case 'd':
$seconds = 86400;
break;
case 'm':
$seconds = 2592000;
break;
case 'y':
$seconds = 31536000;
break;
}
$time = IPS_UNIX_TIME_NOW - $seconds * intval($data['text']);
/* Switch around for skipping */
$data['value'] = $archiveOn ? $data['value'] : ($data['value'] == '>' ? '<' : '>');
return $this->getDbFieldFromKey($key) . ' ' . $data['value'] . ' ' . $time;
}
break;
case 'forum':
case 'member':
if ($data['text']) {
if (IPSLib::isSerialized($data['text'])) {
$ids = unserialize($data['text']);
} else {
$ids = array();
}
$inOp = $data['value'] == '+' ? 'IN' : 'NOT IN';
if (is_array($ids) && count($ids)) {
return $this->getDbFieldFromKey($key) . ' ' . $inOp . '(' . implode(',', $ids) . ')';
}
}
break;
}
return null;
}
示例11: getRestoreData
/**
* Get restore data
*/
public function getRestoreData()
{
$data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_archive_restore'));
if (IPSLib::isSerialized($data['restore_manual_tids'])) {
$data['restore_manual_tids'] = unserialize($data['restore_manual_tids']);
} else {
$data['restore_manual_tids'] = array();
}
return $data;
}
示例12: setToMemberCache
/**
* Sets items to the cache
* @param MIXED (int or memberData ) $member
* @param array $store
*/
public static function setToMemberCache($member, $store)
{
$cache = array();
if (is_integer($member)) {
$member = self::load($member, 'core');
} elseif ($member['member_id'] and !isset($member['members_cache'])) {
$member = self::load($member['member_id'], 'core');
}
/* Check */
if (empty($member['member_id']) or !is_array($store)) {
return false;
}
/* fetch current cache */
if (IPSLib::isSerialized($member['members_cache'])) {
$cache = IPSLib::safeUnserialize($member['members_cache']);
}
/* loop and update */
foreach ($store as $k => $v) {
$cache[$k] = $v;
}
/* Save */
ipsRegistry::DB()->update('members', array('members_cache' => serialize($cache)), 'member_id=' . $member['member_id']);
/* Update local cache */
if (self::$data['member_id'] == $member['member_id']) {
self::$data['_cache'] = $cache;
self::$data['members_cache'] = serialize($cache);
}
}
示例13: _archiveRules
/**
* Archive Rules overview
*
* @return @e void
*/
protected function _archiveRules()
{
/* Get archive count so far */
$counts = $this->archiveWriter->getArchivePossibleCount();
$rules = $this->archiveWriter->getRulesFromDb();
if ($counts['count'] < 1) {
$textString = $this->lang->words['archive_no_query'];
} else {
$textString = sprintf($this->lang->words['archive_x_query'], $counts['percentage'], $this->lang->formatNumber($counts['count']), $this->lang->formatNumber($counts['total']));
}
/* Post process */
foreach (array('archive', 'skip') as $type) {
if (!empty($rules[$type]['forum']['text'])) {
$ids = IPSLib::isSerialized($rules[$type]['forum']['text']) ? unserialize($rules[$type]['forum']['text']) : array();
if (count($ids)) {
foreach ($ids as $fid) {
$data = $this->registry->class_forums->getForumbyId($fid);
if ($data['id']) {
$rules[$type]['forum']['_parseData'][$fid] = array('data' => $this->registry->class_forums->getForumbyId($fid), 'nav' => $this->html->buildForumNav($this->registry->class_forums->forumsBreadcrumbNav($fid, 'showforum=', true)));
}
}
}
}
if (!empty($rules[$type]['member']['text'])) {
$ids = IPSLib::isSerialized($rules[$type]['member']['text']) ? unserialize($rules[$type]['member']['text']) : array();
if (count($ids)) {
$members = IPSMember::load($ids, 'all');
foreach ($members as $id => $data) {
$members[$id] = IPSMember::buildProfilePhoto($members[$id]);
$members[$id]['photoTag'] = IPSMember::buildPhotoTag($members[$id], 'inset');
}
foreach ($ids as $fid) {
$rules[$type]['member']['_parseData']['count'] = count($members);
$rules[$type]['member']['_parseData']['data'] = $members;
}
}
}
}
/* Show rules page */
$this->registry->output->html .= $this->html->archiveRules(IPSText::jsonEncodeForTemplate($rules), $textString);
}
示例14: getLikeData
/**
* Gets 'like' data for this item
*
* @param array ( id, type, app )
* @return array
*
*/
public function getLikeData($data)
{
$store = array('cache_data' => array());
$expired = false;
if (IPSLib::isSerialized($data['rep_like_cache'])) {
$store = unserialize($data['rep_like_cache']);
if (empty($store['cache_expire']) or time() >= $store['cache_expire']) {
$expired = true;
$store = array();
}
}
if (!isset($data['rep_like_cache']) or $expired === true) {
unset($data['rep_like_cache']);
$store = $this->getLikeRawData($data);
$this->DB->replace('reputation_cache', array('app' => $data['app'], 'type' => $data['type'], 'type_id' => $data['id'], 'rep_points' => intval($store['cache_data']['count']), 'cache_date' => time(), 'rep_like_cache' => serialize($store)), array('app', 'type', 'type_id'));
}
return $store['cache_data'];
}