本文整理汇总了PHP中safe_unserialize函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_unserialize函数的具体用法?PHP safe_unserialize怎么用?PHP safe_unserialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safe_unserialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSafeUnserialize
/**
* @group Core
*/
public function testSafeUnserialize()
{
/*
* serialize() uses its internal machine representation when floats expressed in E-notation,
* which may vary between php versions, OS, and hardware platforms
*/
$testData = -5.0E+142;
// intentionally disabled; this doesn't work
// $this->assertEquals( safe_serialize($testData), serialize($testData) );
$this->assertEquals($testData, unserialize(safe_serialize($testData)));
$this->assertSame($testData, safe_unserialize(safe_serialize($testData)));
// workaround: cast floats into strings
$this->assertSame($testData, safe_unserialize(serialize($testData)));
$unserialized = array('announcement' => true, 'source' => array(array('filename' => 'php-5.3.3.tar.bz2', 'name' => 'PHP 5.3.3 (tar.bz2)', 'md5' => '21ceeeb232813c10283a5ca1b4c87b48', 'date' => '22 July 2010'), array('filename' => 'php-5.3.3.tar.gz', 'name' => 'PHP 5.3.3 (tar.gz)', 'md5' => '5adf1a537895c2ec933fddd48e78d8a2', 'date' => '22 July 2010')), 'date' => '22 July 2010', 'version' => '5.3.3');
$serialized = 'a:4:{s:12:"announcement";b:1;s:6:"source";a:2:{i:0;a:4:{s:8:"filename";s:17:"php-5.3.3.tar.bz2";s:4:"name";s:19:"PHP 5.3.3 (tar.bz2)";s:3:"md5";s:32:"21ceeeb232813c10283a5ca1b4c87b48";s:4:"date";s:12:"22 July 2010";}i:1;a:4:{s:8:"filename";s:16:"php-5.3.3.tar.gz";s:4:"name";s:18:"PHP 5.3.3 (tar.gz)";s:3:"md5";s:32:"5adf1a537895c2ec933fddd48e78d8a2";s:4:"date";s:12:"22 July 2010";}}s:4:"date";s:12:"22 July 2010";s:7:"version";s:5:"5.3.3";}';
$this->assertSame($unserialized, unserialize($serialized));
$this->assertEquals($serialized, serialize($unserialized));
$this->assertSame($unserialized, safe_unserialize($serialized));
$this->assertEquals($serialized, safe_serialize($unserialized));
$this->assertSame($unserialized, safe_unserialize(safe_serialize($unserialized)));
$this->assertEquals($serialized, safe_serialize(safe_unserialize($serialized)));
$a = 'O:31:"Test_Piwik_Cookie_Phantom_Class":0:{}';
$this->assertFalse(safe_unserialize($a), "test: unserializing an object where class not (yet) defined");
$a = 'O:28:"Test_Piwik_Cookie_Mock_Class":0:{}';
$this->assertFalse(safe_unserialize($a), "test: unserializing an object where class is defined");
$a = 'a:1:{i:0;O:28:"Test_Piwik_Cookie_Mock_Class":0:{}}';
$this->assertFalse(safe_unserialize($a), "test: unserializing nested object where class is defined");
$a = 'a:2:{i:0;s:4:"test";i:1;O:28:"Test_Piwik_Cookie_Mock_Class":0:{}}';
$this->assertFalse(safe_unserialize($a), "test: unserializing another nested object where class is defined");
$a = 'O:28:"Test_Piwik_Cookie_Mock_Class":1:{s:34:"' . "" . 'Test_Piwik_Cookie_Mock_Class' . "" . 'name";s:4:"test";}';
$this->assertFalse(safe_unserialize($a), "test: unserializing object with member where class is defined");
// arrays and objects cannot be used as keys, i.e., generates "Warning: Illegal offset type ..."
$a = 'a:2:{i:0;a:0:{}O:28:"Test_Piwik_Cookie_Mock_Class":0:{}s:4:"test";';
$this->assertFalse(safe_unserialize($a), "test: unserializing with illegal key");
}
示例2: oauth_init
/**
* plugin initialization
*/
function oauth_init()
{
global $conf, $page, $hybridauth_conf, $template;
load_language('plugin.lang', OAUTH_PATH);
$conf['oauth'] = safe_unserialize($conf['oauth']);
// check config
if (defined('IN_ADMIN')) {
if (empty($hybridauth_conf) and strpos(@$_GET['page'], 'plugin-oAuth') === false) {
$page['warnings'][] = '<a href="' . OAUTH_ADMIN . '">' . l10n('Social Connect: You need to configure the credentials') . '</a>';
}
if (!function_exists('curl_init')) {
$page['warnings'][] = l10n('Social Connect: PHP Curl extension is needed');
}
}
// in case of registration aborded
if (script_basename() == 'index' and ($oauth_id = pwg_get_session_var('oauth_new_user')) !== null) {
pwg_unset_session_var('oauth_new_user');
if ($oauth_id[0] == 'Persona') {
oauth_assign_template_vars(get_gallery_home_url());
$template->block_footer_script(null, 'navigator.id.logout();');
} else {
require_once OAUTH_PATH . 'include/hybridauth/Hybrid/Auth.php';
try {
$hybridauth = new Hybrid_Auth($hybridauth_conf);
$adapter = $hybridauth->getAdapter($oauth_id[0]);
$adapter->logout();
} catch (Exception $e) {
}
}
}
}
示例3: install
function install($plugin_version, &$errors = array())
{
global $conf;
if (empty($conf['guestbook'])) {
conf_update_param('guestbook', $this->default_conf, true);
} else {
$old_conf = safe_unserialize($conf['guestbook']);
if (!isset($old_conf['guest_can_view'])) {
$old_conf['guest_can_view'] = true;
$old_conf['guest_can_add'] = true;
}
if (!isset($old_conf['menu_link'])) {
$old_conf['menu_link'] = true;
}
conf_update_param('guestbook', $old_conf, true);
}
pwg_query('
CREATE TABLE IF NOT EXISTS `' . $this->table . '` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`date` datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
`author` varchar(255) NOT NULL,
`author_id` smallint(5) DEFAULT NULL,
`anonymous_id` varchar(45) NOT NULL,
`email` varchar(255) DEFAULT NULL,
`website` varchar(255) DEFAULT NULL,
`content` longtext NOT NULL,
`rate` float(5,2) unsigned DEFAULT NULL,
`validated` enum("true","false") NOT NULL DEFAULT "false",
`validation_date` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;');
}
示例4: oneClickResults
public function oneClickResults()
{
Piwik_API_Request::reloadAuthUsingTokenAuth($_POST);
Piwik::checkUserIsSuperUser();
$view = Piwik_View::factory('update_one_click_results');
$view->coreError = Piwik_Common::getRequestVar('error', '', 'string', $_POST);
$view->feedbackMessages = safe_unserialize(Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('messages', '', 'string', $_POST)));
echo $view->render();
}
示例5: install
function install($plugin_version, &$errors = array())
{
global $conf;
if (empty($conf['sortorders'])) {
conf_update_param('sortorders', $this->default_conf, true);
} else {
$old_conf = safe_unserialize($conf['sortorders']);
conf_update_param('sortorders', $old_conf, true);
}
}
示例6: activate
function activate($theme_version, &$errors = array())
{
global $conf, $prefixeTable;
if (empty($conf['smartpocket'])) {
conf_update_param('smartpocket', $this->default_conf, true);
} elseif (count(safe_unserialize($conf['smartpocket'])) != 2) {
$conff = safe_unserialize($conf['smartpocket']);
$config = array('loop' => !empty($conff['loop']) ? $conff['loop'] : true, 'autohide' => !empty($conff['autohide']) ? $conff['autohide'] : 5000);
conf_update_param('smartpocket', $config, true);
}
$this->installed = true;
}
示例7: _retrieveCurrentValue
function _retrieveCurrentValue() {
$this->current_value = PHP_VERSION;
$url = 'http://php.net/releases/?serialize=1&version=5';
$timeout = Piwik_UpdateCheck::SOCKET_TIMEOUT;
try {
$latestVersion = Piwik_Http::sendHttpRequest($url, $timeout);
$versionInfo = safe_unserialize($latestVersion);
$this->recommended_value = $versionInfo['version'];
} catch(Exception $e) {
$this->recommended_value = '';
}
}
示例8: install
function install($plugin_version, &$errors = array())
{
global $conf;
if (empty($conf['oauth'])) {
conf_update_param('oauth', $this->default_conf, true);
} else {
$conf['oauth'] = safe_unserialize($conf['oauth']);
if (!isset($conf['oauth']['allow_merge_accounts'])) {
$conf['oauth']['allow_merge_accounts'] = true;
conf_update_param('oauth', $conf['oauth']);
}
}
$result = pwg_query('SHOW COLUMNS FROM `' . USER_INFOS_TABLE . '` LIKE "oauth_id";');
if (!pwg_db_num_rows($result)) {
pwg_query('ALTER TABLE `' . USER_INFOS_TABLE . '` ADD `oauth_id` VARCHAR(255) DEFAULT NULL;');
}
// move field from users table to user_infos
$result = pwg_query('SHOW COLUMNS FROM `' . USERS_TABLE . '` LIKE "oauth_id";');
if (pwg_db_num_rows($result)) {
$query = '
UPDATE `' . USER_INFOS_TABLE . '` AS i
SET oauth_id = (
SELECT oauth_id
FROM `' . USERS_TABLE . '` AS u
WHERE u.' . $conf['user_fields']['id'] . ' = i.user_id
)
;';
pwg_query($query);
pwg_query('ALTER TABLE `' . USERS_TABLE . '` DROP `oauth_id`;');
}
// add 'total' and 'enabled' fields in hybridauth conf file
if (file_exists($this->file)) {
$hybridauth_conf = (include $this->file);
if (!isset($hybridauth_conf['total'])) {
$enabled = array_filter($hybridauth_conf['providers'], create_function('$p', 'return $p["enabled"];'));
$hybridauth_conf['total'] = count($hybridauth_conf['providers']);
$hybridauth_conf['enabled'] = count($enabled);
$content = "<?php\ndefined('PHPWG_ROOT_PATH') or die('Hacking attempt!');\n\nreturn ";
$content .= var_export($hybridauth_conf, true);
$content .= ";\n?>";
file_put_contents($this->file, $content);
}
}
}
示例9: test_safeSerialize
function test_safeSerialize()
{
$tests = array('null' => null, 'bool false' => false, 'bool true' => true, 'negative int' => -42, 'zero' => 0, 'positive int' => 42, 'float' => 1.25, 'empty string' => '', 'nul in string' => "", 'carriage return in string' => "first line\r\nsecond line", 'utf7 in string' => 'hello, world', 'utf8 in string' => '是', 'empty array' => array(), 'single element array' => array("test"), 'associative array' => array("alpha", 2 => "beta"), 'mixed keys' => array('first' => 'john', 'last' => 'doe', 10 => 'age'), 'nested arrays' => array('top' => array('middle' => 2, array('bottom'), 'last'), 'the end' => true), 'array confusion' => array('"', "'", '}', ';', ':'));
foreach ($tests as $id => $testData) {
$this->assertEqual(safe_serialize($testData), serialize($testData), $id);
}
foreach ($tests as $id => $testData) {
$this->assertEqual(unserialize(safe_serialize($testData)), $testData, $id);
$this->assertTrue(safe_unserialize(safe_serialize($testData)) === $testData, $id);
$this->assertTrue(safe_unserialize(serialize($testData)) === $testData, $id);
}
/*
* serialize() uses its internal maachine representation when floats expressed in E-notation,
* which may vary between php versions, OS, and hardware platforms
*/
$testData = $tests['exp float'] = -5.0E+142;
// intentionally disabled; this doesn't work
// $this->assertEqual( safe_serialize($testData), serialize($testData) );
$this->assertEqual(unserialize(safe_serialize($testData)), $testData);
$this->assertTrue(safe_unserialize(safe_serialize($testData)) === $testData);
// workaround: cast floats into strings
$this->assertTrue((string) safe_unserialize(serialize($testData)) === (string) $testData);
$unserialized = array('announcement' => true, 'source' => array(array('filename' => 'php-5.3.3.tar.bz2', 'name' => 'PHP 5.3.3 (tar.bz2)', 'md5' => '21ceeeb232813c10283a5ca1b4c87b48', 'date' => '22 July 2010'), array('filename' => 'php-5.3.3.tar.gz', 'name' => 'PHP 5.3.3 (tar.gz)', 'md5' => '5adf1a537895c2ec933fddd48e78d8a2', 'date' => '22 July 2010')), 'date' => '22 July 2010', 'version' => '5.3.3');
$serialized = 'a:4:{s:12:"announcement";b:1;s:6:"source";a:2:{i:0;a:4:{s:8:"filename";s:17:"php-5.3.3.tar.bz2";s:4:"name";s:19:"PHP 5.3.3 (tar.bz2)";s:3:"md5";s:32:"21ceeeb232813c10283a5ca1b4c87b48";s:4:"date";s:12:"22 July 2010";}i:1;a:4:{s:8:"filename";s:16:"php-5.3.3.tar.gz";s:4:"name";s:18:"PHP 5.3.3 (tar.gz)";s:3:"md5";s:32:"5adf1a537895c2ec933fddd48e78d8a2";s:4:"date";s:12:"22 July 2010";}}s:4:"date";s:12:"22 July 2010";s:7:"version";s:5:"5.3.3";}';
$this->assertTrue(unserialize($serialized) === $unserialized);
$this->assertEqual(serialize($unserialized), $serialized);
$this->assertTrue(safe_unserialize($serialized) === $unserialized);
$this->assertEqual(safe_serialize($unserialized), $serialized);
$this->assertTrue(safe_unserialize(safe_serialize($unserialized)) === $unserialized);
$this->assertEqual(safe_serialize(safe_unserialize($serialized)), $serialized);
$a = 'O:31:"Test_Piwik_Cookie_Phantom_Class":0:{}';
$this->assertFalse(safe_unserialize($a), "test: unserializing an object where class not (yet) defined");
$a = 'O:28:"Test_Piwik_Cookie_Mock_Class":0:{}';
$this->assertFalse(safe_unserialize($a), "test: unserializing an object where class is defined");
$a = 'a:1:{i:0;O:28:"Test_Piwik_Cookie_Mock_Class":0:{}}';
$this->assertFalse(safe_unserialize($a), "test: unserializing nested object where class is defined");
$a = 'a:2:{i:0;s:4:"test";i:1;O:28:"Test_Piwik_Cookie_Mock_Class":0:{}}';
$this->assertFalse(safe_unserialize($a), "test: unserializing another nested object where class is defined");
$a = 'O:28:"Test_Piwik_Cookie_Mock_Class":1:{s:34:"' . "" . 'Test_Piwik_Cookie_Mock_Class' . "" . 'name";s:4:"test";}';
$this->assertFalse(safe_unserialize($a), "test: unserializing object with member where class is defined");
// arrays and objects cannot be used as keys, i.e., generates "Warning: Illegal offset type ..."
$a = 'a:2:{i:0;a:0:{}O:28:"Test_Piwik_Cookie_Mock_Class":0:{}s:4:"test";';
$this->assertFalse(safe_unserialize($a), "test: unserializing with illegal key");
}
示例10: install
function install($plugin_version, &$errors = array())
{
global $conf;
// add a new column to existing table
$result = pwg_query('SHOW COLUMNS FROM `' . CATEGORIES_TABLE . '` LIKE "polaroid_active";');
if (!pwg_db_num_rows($result)) {
pwg_query('ALTER TABLE `' . CATEGORIES_TABLE . '` ADD `polaroid_active` enum(\'true\', \'false\') default \'false\';');
}
$config = array('apply_to_albums' => 'all');
// load existing config parameters
if (!empty($conf['polaroid'])) {
$conf['polaroid'] = safe_unserialize($conf['polaroid']);
foreach ($conf['polaroid'] as $key => $value) {
$config[$key] = $value;
}
}
conf_update_param('polaroid', $config, true);
$this->installed = true;
}
示例11: install
function install($plugin_version, &$errors = array())
{
global $conf;
// Configuration
if (!isset($conf['forecast_conf']) || empty($conf['forecast_conf'])) {
$this->default_config['last_clean'] = time();
conf_update_param('forecast_conf', $this->default_config, true);
$q = 'UPDATE ' . CONFIG_TABLE . ' SET `comment` = "Configuration settings for piwigo-forecast plugin" WHERE `param` = "forecast_conf";';
pwg_query($q);
} else {
$current_conf = safe_unserialize($conf['forecast_conf']);
conf_update_param('forecast_conf', array_merge($this->default_config, $current_conf), true);
}
// Create MySQL View
$q = 'DROP VIEW IF EXISTS `forecast`;';
pwg_query($q);
$q = 'CREATE VIEW forecast AS SELECT `id`, `latitude`, `longitude`, UNIX_TIMESTAMP( IFNULL(`date_creation`, `date_available`) ) as `date` FROM ' . IMAGES_TABLE . ' WHERE `latitude` IS NOT NULL AND `longitude` is NOT NULL;';
pwg_query($q);
}
示例12: install
function install($plugin_version, &$errors = array())
{
global $conf;
// configuration
if (!isset($conf['cdnplus_conf']) || empty($conf['cdnplus_conf'])) {
$this->default_config['last_clean'] = time();
/* Generate file_ext from current ext supported */
$filetypes_arr = array_fill_keys(array_intersect_key($conf['file_ext'], array_unique(array_map('strtolower', $conf['file_ext']))), false);
$this->default_config['cdn_1']['filetypes'] = $filetypes_arr;
$this->default_config['cdn_2']['filetypes'] = $filetypes_arr;
$this->default_config['cdn_3']['filetypes'] = $filetypes_arr;
$this->default_config['cdn_4']['filetypes'] = $filetypes_arr;
$this->default_config['cdn_5']['filetypes'] = $filetypes_arr;
conf_update_param('cdnplus_conf', $this->default_config, true);
$q = 'UPDATE ' . CONFIG_TABLE . ' SET `comment` = "Configuration settings for piwigo-cdnplus plugin" WHERE `param` = "cdnplus_conf";';
pwg_query($q);
} else {
$new_conf = safe_unserialize($conf['cdnplus_conf']);
conf_update_param('cdnplus_conf', $new_conf, true);
}
}
示例13: Login2
function Login2()
{
global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;
// Load cookie authentication stuff.
require_once $sourcedir . '/Subs-Auth.php';
if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest']) {
if (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\\{i:0;(i:\\d{1,6}|s:[1-8]:"\\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\\d{1,14};(i:3;i:\\d;)?\\}$~', $_COOKIE[$cookiename]) === 1) {
list(, , $timeout) = safe_unserialize($_COOKIE[$cookiename]);
} elseif (isset($_SESSION['login_' . $cookiename])) {
list(, , $timeout) = safe_unserialize($_SESSION['login_' . $cookiename]);
} else {
trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
}
$user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
setLoginCookie($timeout - time(), $user_info['id'], sha1($user_settings['passwd'] . $user_settings['password_salt']));
redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
} elseif (isset($_GET['sa']) && $_GET['sa'] == 'check') {
// Strike! You're outta there!
if ($_GET['member'] != $user_info['id']) {
fatal_lang_error('login_cookie_error', false);
}
// Some whitelisting for login_url...
if (empty($_SESSION['login_url'])) {
redirectexit();
} else {
// Best not to clutter the session data too much...
$temp = $_SESSION['login_url'];
unset($_SESSION['login_url']);
redirectexit($temp);
}
}
// Beyond this point you are assumed to be a guest trying to login.
if (!$user_info['is_guest']) {
redirectexit();
}
// Are you guessing with a script?
spamProtection('login');
// Set the login_url if it's not already set (but careful not to send us to an attachment).
if (empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0) {
$_SESSION['login_url'] = $_SESSION['old_url'];
}
// Been guessing a lot, haven't we?
if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3) {
fatal_lang_error('login_threshold_fail', 'critical');
}
// Set up the cookie length. (if it's invalid, just fall through and use the default.)
if (isset($_POST['cookieneverexp']) || !empty($_POST['cookielength']) && $_POST['cookielength'] == -1) {
$modSettings['cookieTime'] = 3153600;
} elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 || $_POST['cookielength'] <= 525600)) {
$modSettings['cookieTime'] = (int) $_POST['cookielength'];
}
loadLanguage('Login');
// Load the template stuff - wireless or normal.
if (WIRELESS) {
$context['sub_template'] = WIRELESS_PROTOCOL . '_login';
} else {
loadTemplate('Login');
$context['sub_template'] = 'login';
}
// Set up the default/fallback stuff.
$context['default_username'] = isset($_POST['user']) ? preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($_POST['user'])) : '';
$context['default_password'] = '';
$context['never_expire'] = $modSettings['cookieTime'] == 525600 || $modSettings['cookieTime'] == 3153600;
$context['login_errors'] = array($txt['error_occured']);
$context['page_title'] = $txt['login'];
// Add the login chain to the link tree.
$context['linktree'][] = array('url' => $scripturl . '?action=login', 'name' => $txt['login']);
if (!empty($_POST['openid_identifier']) && !empty($modSettings['enableOpenID'])) {
require_once $sourcedir . '/Subs-OpenID.php';
if (($open_id = smf_openID_validate($_POST['openid_identifier'])) !== 'no_data') {
return $open_id;
}
}
// You forgot to type your username, dummy!
if (!isset($_POST['user']) || $_POST['user'] == '') {
$context['login_errors'] = array($txt['need_username']);
return;
}
// Hmm... maybe 'admin' will login with no password. Uhh... NO!
if ((!isset($_POST['passwrd']) || $_POST['passwrd'] == '') && (!isset($_POST['hash_passwrd']) || strlen($_POST['hash_passwrd']) != 40)) {
$context['login_errors'] = array($txt['no_password']);
return;
}
// No funky symbols either.
if (preg_match('~[<>&"\'=\\\\]~', preg_replace('~(&#(\\d{1,7}|x[0-9a-fA-F]{1,6});)~', '', $_POST['user'])) != 0) {
$context['login_errors'] = array($txt['error_invalid_characters_username']);
return;
}
// And if it's too long, trim it back.
if ($smcFunc['strlen']($_POST['user']) > 80) {
$_POST['user'] = $smcFunc['substr']($_POST['user'], 0, 79);
$context['default_username'] = preg_replace('~&#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($_POST['user']));
}
// Are we using any sort of integration to validate the login?
if (in_array('retry', call_integration_hook('integrate_validate_login', array($_POST['user'], isset($_POST['hash_passwrd']) && strlen($_POST['hash_passwrd']) == 40 ? $_POST['hash_passwrd'] : null, $modSettings['cookieTime'])), true)) {
$context['login_errors'] = array($txt['login_hash_error']);
$context['disable_login_hashing'] = true;
return;
//.........这里部分代码省略.........
示例14: oneClickResults
public function oneClickResults()
{
Request::reloadAuthUsingTokenAuth($_POST);
Piwik::checkUserIsSuperUser();
$view = new View('@CoreUpdater/oneClickResults');
$view->coreError = Common::getRequestVar('error', '', 'string', $_POST);
$view->feedbackMessages = safe_unserialize(Common::unsanitizeInputValue(Common::getRequestVar('messages', '', 'string', $_POST)));
return $view->render();
}
示例15: loadContentFromCookie
/**
* Load the cookie content into a php array.
* Parses the cookie string to extract the different variables.
* Unserialize the array when necessary.
* Decode the non numeric values that were base64 encoded.
*/
protected function loadContentFromCookie()
{
$cookieStr = $this->extractSignedContent($_COOKIE[$this->name]);
if ($cookieStr === false) {
return;
}
$values = explode(self::VALUE_SEPARATOR, $cookieStr);
foreach ($values as $nameValue) {
$equalPos = strpos($nameValue, '=');
$varName = substr($nameValue, 0, $equalPos);
$varValue = substr($nameValue, $equalPos + 1);
// no numeric value are base64 encoded so we need to decode them
if (!is_numeric($varValue)) {
$tmpValue = base64_decode($varValue);
$varValue = safe_unserialize($tmpValue);
// discard entire cookie
// note: this assumes we never serialize a boolean
if ($varValue === false && $tmpValue !== 'b:0;') {
$this->value = array();
unset($_COOKIE[$this->name]);
break;
}
}
$this->value[$varName] = $varValue;
}
}