当前位置: 首页>>代码示例>>PHP>>正文


PHP DataUtil::is_serialized方法代码示例

本文整理汇总了PHP中DataUtil::is_serialized方法的典型用法代码示例。如果您正苦于以下问题:PHP DataUtil::is_serialized方法的具体用法?PHP DataUtil::is_serialized怎么用?PHP DataUtil::is_serialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataUtil的用法示例。


在下文中一共展示了DataUtil::is_serialized方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upgrade

 /**
  * upgrade the blocks module
  *
  * @param string $oldversion version being upgraded
  *
  * @return bool true if successful, false otherwise
  */
 public function upgrade($oldversion)
 {
     // Upgrade dependent on old version number
     switch ($oldversion) {
         case '3.8.1':
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
         case '3.8.2':
         case '3.9.0':
             $blocks = $this->entityManager->getRepository('ZikulaBlocksModule:BlockEntity')->findAll();
             /** @var \Zikula\Module\BlocksModule\Entity\BlockEntity $block */
             foreach ($blocks as $block) {
                 $content = $block->getContent();
                 if (\DataUtil::is_serialized($content)) {
                     $content = unserialize($content);
                     foreach ($content as $k => $item) {
                         if (is_string($item)) {
                             if (strpos($item, 'blocks_block_extmenu_topnav.tpl') !== false) {
                                 $content[$k] = str_replace('blocks_block_extmenu_topnav.tpl', 'Block/Extmenu/topnav.tpl', $item);
                             } elseif (strpos($item, 'blocks_block_extmenu.tpl') !== false) {
                                 $content[$k] = str_replace('blocks_block_extmenu.tpl', 'Block/Extmenu/extmenu.tpl', $item);
                             } elseif (strpos($item, 'menutree/blocks_block_menutree_') !== false) {
                                 $content[$k] = str_replace('menutree/blocks_block_menutree_', 'Block/Menutree/', $item);
                             }
                         }
                     }
                     $block->setContent(serialize($content));
                 }
             }
             $this->entityManager->flush();
             // check if request is available (#2073)
             $templateWarning = $this->__('Warning: Block template locations modified, you may need to fix your template overrides if you have any.');
             if (is_object($this->request) && method_exists($this->request, 'getSession') && is_object($this->request->getSession())) {
                 $this->request->getSession()->getFlashBag()->add(\Zikula_Session::MESSAGE_WARNING, $templateWarning);
             } else {
                 \LogUtil::registerWarning($templateWarning);
             }
         case '3.9.1':
             // future upgrade routines
     }
     // Update successful
     return true;
 }
开发者ID:rmaiwald,项目名称:core,代码行数:49,代码来源:BlocksModuleInstaller.php

示例2: header

if (!$f) {
    header('HTTP/1.0 404 Not Found');
    exit;
}
// clean $f
$f = preg_replace('`/`', '', $f);
// set full path to the file
$f = $ZConfig['System']['temp'] . '/Theme_cache/' . $f;
if (!is_readable($f)) {
    header('HTTP/1.0 400 Bad request');
    die('ERROR: Requested file not readable.');
}
// child lock
$signingKey = md5(serialize($ZConfig['DBInfo']['databases']['default']));
$contents = file_get_contents($f);
if (!DataUtil::is_serialized($contents, false)) {
    header('HTTP/1.0 500 Internal error');
    die('ERROR: Corrupted file.');
}
$dataArray = unserialize($contents);
if (!isset($dataArray['contents']) || !isset($dataArray['ctype']) || !isset($dataArray['lifetime']) || !isset($dataArray['gz']) || !isset($dataArray['signature'])) {
    header('HTTP/1.0 500 Interal error');
    die('ERROR: Invalid data.');
}
// check signature
if (md5($dataArray['contents'] . $dataArray['ctype'] . $dataArray['lifetime'] . $dataArray['gz'] . $signingKey) != $dataArray['signature']) {
    header('HTTP/1.0 500 Interal error');
    die('ERROR: File has been altered.');
}
// gz handlers if requested
if ($dataArray['gz']) {
开发者ID:projectesIF,项目名称:Sirius,代码行数:31,代码来源:jcss.php

示例3: varsFromContent

 /**
  * Extract an array of config variables out of the content field of a block.
  *
  * @param string $content The content from the db.
  *
  * @return array
  */
 public static function varsFromContent($content)
 {
     // Try to unserialize first
     if (DataUtil::is_serialized($content, false)) {
         // Serialised content
         $vars = unserialize($content);
         if ($vars !== false && is_array($vars)) {
             return $vars;
         }
     }
     // Unserialised content
     $links = explode("\n", $content);
     $vars = array();
     foreach ($links as $link) {
         $link = trim($link);
         if ($link) {
             $var = explode(':=', $link);
             if (isset($var[1])) {
                 $vars[$var[0]] = $var[1];
             }
         }
     }
     return $vars;
 }
开发者ID:rmaiwald,项目名称:core,代码行数:31,代码来源:BlockUtil.php

示例4: smarty_function_duditemdisplay


//.........这里部分代码省略.........
        }

        $output = DateUtil::getTimezoneText($uservalue);
        if (!$output) {
            return '';
        }


    } elseif ($item['prop_displaytype'] == 2) {
        // checkbox
        $default = array('No', 'Yes');
        $output  = array_splice(explode('@@', $item['prop_listoptions']), 1);
        if (!is_array($output) || count($output) < 2) {
            $output = $default;
        }
        $output = isset($output[(int)$uservalue]) && !empty($output[(int)$uservalue]) ? __($output[(int)$uservalue], $dom) : __($default[(int)$uservalue], $dom);


    } elseif ($item['prop_displaytype'] == 3) {
        // radio
        $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));

        // process the user value and get the translated label
        $output = isset($options[$uservalue]) ? $options[$uservalue] : $default;


    } elseif ($item['prop_displaytype'] == 4) {
        // select
        $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));

        // process the user values and get the translated label
        $uservalue = @unserialize($uservalue);

        $output = array();
        foreach ((array)$uservalue as $id) {
            if (isset($options[$id])) {
                $output[] = $options[$id];
            }
        }


    } elseif (!empty($uservalue) && $item['prop_displaytype'] == 5) {
        // date
        $format = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));
        //! This is from the core domain (datebrief)
        $format = !empty($format) ? $format : __('%b %d, %Y');

        $output = DateUtil::getDatetime(strtotime($uservalue), $format);


    } elseif ($item['prop_displaytype'] == 7) {
        // multicheckbox
        $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));

        // process the user values and get the translated label
        $uservalue = @unserialize($uservalue);

        $output = array();
        foreach ((array)$uservalue as $id) {
            if (isset($options[$id])) {
                $output[] = $options[$id];
            }
        }


    } elseif ($item['prop_attribute_name'] == 'url') {
        // url
        if (!empty($uservalue) && $uservalue != 'http://') {
            //! string to describe the user's site
            $output = '<a href="'.DataUtil::formatForDisplay($uservalue).'" title="'.__f("%s's site", $userinfo['uname'], $dom).'" rel="nofollow">'.DataUtil::formatForDisplay($uservalue).'</a>';
        }

    } elseif (empty($uservalue)) {
        // process the generics
        $output = $default;


    } elseif (DataUtil::is_serialized($uservalue) || is_array($uservalue)) {
        // serialized data
        $uservalue = !is_array($uservalue) ? unserialize($uservalue) : $uservalue;
        $output = array();
        foreach ((array)$uservalue as $option) {
            $output[] = __($option, $dom);
        }


    } else {
        // a string
        $output .= __($uservalue, $dom);
    }


    // omit this field if is empty after the process
    if (empty($output)) {
        return '';
    }

    return $render->assign('output', is_array($output) ? $output : array($output))
        ->fetch($template);
}
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:function.duditemdisplay.php

示例5: upgrade


//.........这里部分代码省略.........
             if (!ModUtil::registerHook('zikula', 'systeminit', 'GUI', 'scribite', 'user', 'run')) {
                 LogUtil::registerError($this->__('Error creating Hook!'));
                 return '2.2';
             }
             ModUtil::apiFunc('Modules', 'admin', 'enablehooks', array('callermodname' => 'zikula', 'hookmodname' => 'scribite'));
             LogUtil::registerStatus($this->__('<strong>scribite!</strong> was activated as core hook. You can check settings <a href="index.php?module=Modules&type=admin&func=hooks&id=0">here</a>!<br />The template plugin from previous versions of scribite! can be removed from templates.'));
         case '3.0':
             //create new module vars for Newsletter and Web_Links
             $record = array(array('modname' => 'Newsletter', 'modfuncs' => 'a:1:{i:0;s:11:"add_message";}', 'modareas' => 'a:1:{i:0;s:7:"message";}', 'modeditor' => '-'), array('modname' => 'crpVideo', 'modfuncs' => 'a:2:{i:0;s:3:"new";i:1;s:6:"modify";}', 'modareas' => 'a:1:{i:0;s:13:"video_content";}', 'modeditor' => '-'), array('modname' => 'Web_Links', 'modfuncs' => 'a:3:{i:0;s:8:"linkview";i:1;s:7:"addlink";i:2;s:17:"modifylinkrequest";}', 'modareas' => 'a:1:{i:0;s:11:"description";}', 'modeditor' => '-'));
             DBUtil::insertObjectArray($record, 'scribite', 'mid');
             // set vars for YUI Rich Text Editor
             if (!$this->getVar('yui_type')) {
                 $this->setVar('yui_type', 'Simple');
             }
             if (!$this->getVar('yui_width')) {
                 $this->setVar('yui_width', 'auto');
             }
             if (!$this->getVar('yui_height')) {
                 $this->setVar('yui_height', '300');
             }
             if (!$this->getVar('yui_dombar')) {
                 $this->setVar('yui_dombar', true);
             }
             if (!$this->getVar('yui_animate')) {
                 $this->setVar('yui_animate', true);
             }
             if (!$this->getVar('yui_collapse')) {
                 $this->setVar('yui_collapse', true);
             }
         case '3.1':
             // modify Profile module
             $originalconfig = ModUtil::apiFunc('Scribite', 'user', 'getModuleConfig', array('modulename' => "Profile"));
             $newconfig = array('mid' => $originalconfig['mid'], 'modulename' => 'Profile', 'modfuncs' => "modify", 'modareas' => "prop_signature,prop_extrainfo,prop_yinterests", 'modeditor' => $originalconfig['modeditor']);
             $modupdate = ModUtil::apiFunc('Scribite', 'admin', 'editmodule', $newconfig);
         case '3.2':
             // set new editors folder
             $this->setVar('editors_path', 'modules/scribite/pnincludes');
             LogUtil::registerStatus($this->__('<strong>Caution!</strong><br />All editors have moved to /modules/scribite/pnincludes in preparation for upcoming features of Zikula. Please check all your settings!<br />If you have adapted files from editors you have to check them too.<br /><br /><strong>Dropped support for FCKeditor and TinyMCE</strong><br />For security reasons these editors will not be supported anymore. Please change editors to an other editor.'));
         case '4.0':
         case '4.1':
         case '4.2':
             $this->setVar('nicedit_xhtml', 1);
         case '4.2.1':
             if (!$this->getVar('ckeditor_language')) {
                 $this->setVar('ckeditor_language', 'en');
             }
             if (!$this->getVar('ckeditor_barmode')) {
                 $this->setVar('ckeditor_barmode', 'Full');
             }
             if (!$this->getVar('ckeditor_width')) {
                 $this->setVar('ckeditor_width', '"70%"');
             }
             if (!$this->getVar('ckeditor_height')) {
                 $this->setVar('ckeditor_height', '400');
             }
         case '4.2.2':
             // this renames the table and the columns per new z1.3.0 standards
             $this->renameColumns();
             EventUtil::registerPersistentModuleHandler('Scribite', 'core.postinit', array('Scribite_Listeners', 'coreinit'));
             $this->setVar('editors_path', 'modules/Scribite/includes');
             LogUtil::registerStatus($this->__('<strong>Caution!</strong><br />All editors have moved to /modules/Scribite/includes.<br />If you have adapted files from editors you have to check them too.'));
         case '4.2.3':
             //set vars for markitup
             if (!$this->getVar('markitup_width')) {
                 $this->setVar('markitup_width', '650px');
             }
             if (!$this->getVar('markitup_height')) {
                 $this->setVar('markitup_height', '400px');
             }
             // remove fckeditor (was deprecated in 4.1)
             $this->delVar('fckeditor_language');
             $this->delVar('fckeditor_barmode');
             $this->delVar('fckeditor_width');
             $this->delVar('fckeditor_height');
             $this->delVar('fckeditor_autolang');
             // update module assignments to correct removed and deprecated editors
             $dbtable = DBUtil::getTables();
             $columns = $dbtable['scribite_column'];
             $sql = "UPDATE `{$dbtable['scribite']}` SET `{$columns['modeditor']}`='-' WHERE `{$columns['modeditor']}`='fckeditor' OR `{$columns['modeditor']}`='tinymce' OR `{$columns['modeditor']}`='openwysiwyg'";
             DBUtil::executeSQL($sql);
             // reset modules
             $this->resetModuleConfig('News');
             $this->resetModuleConfig('Pages');
             $this->resetModuleConfig('ContentExpress');
             $this->resetModuleConfig('Mediashare');
             // correct possible serialized data corruption
             if (!DataUtil::is_serialized($this->getVar('xinha_activeplugins'))) {
                 $this->delVar('xinha_activeplugins');
             }
             // relocate xinha styles
             $this->setVar('xinha_style', 'modules/Scribite/style/xinha/editor.css');
             // remove content settings
             DBUtil::deleteObjectById('scribite', 'content', 'modname');
         case '4.3.0':
             /* reimplement TinyMCE */
             // future updates
             // notice - remove openwysiwyg vars @>4.3.0
     }
     return true;
 }
开发者ID:rmaiwald,项目名称:Scribite,代码行数:101,代码来源:Installer.php

示例6: upgrade113XTablesTo220Tables


//.........这里部分代码省略.........
        $obaColumn = $dbinfoSystem['objectdata_attributes_column'];

        $limitNumRows = 100;
        $limitOffset = 0;
        $updated = true;
        $userCount = DBUtil::selectObjectCount('users_temp');
        // Pass through the users_temp table in chunks of 100
        //  * ensure unames and email addresses are lower case,
        while ($limitOffset < $userCount) {
            $userTempArray = DBUtil::selectObjectArray('users_temp', '', '', $limitOffset, $limitNumRows, '', null, null,
                array('tid', 'type', 'uname', 'email', 'pass', 'hash_method', 'dynamics', 'comment'));
            $userArray = array();
            if (!empty($userTempArray) && is_array($userTempArray)) {
                foreach ($userTempArray as $key => $userTempOpj) {
                    // type == 1: User registration pending approval (moderation)
                    if ($userTempArray[$key]['type'] == 1) {
                        $userObj = array();

                        // Ensure uname and email are lower case
                        $userObj['uname'] = mb_strtolower($userTempArray[$key]['uname']);
                        $userObj['email'] = mb_strtolower($userTempArray[$key]['email']);

                        // Convert pass to salted pass with embedded hash method, leave salt blank
                        $userObj['pass'] = $userTempArray[$key]['hash_method'] . '$$' . $userTempArray[$key]['pass'];

                        $userObj['approved_by'] = 0;
                        $userObj['activated'] = Users_Constant::ACTIVATED_PENDING_REG;

                        if (!empty($userTempArray[$key]['dynamics'])) {
                            $userObj['__ATTRIBUTES__'] = unserialize($userTempArray[$key]['dynamics']);
                        } else {
                            $userObj['__ATTRIBUTES__'] = array();
                        }

                        if (isset($userObj['dynamics']) && !empty($userObj['dynamics'])) {
                            if (DataUtil::is_serialized($userObj['dynamics'])) {
                                $dynamics = @unserialize($userObj['dynamics']);
                                if (!empty($dynamics) && is_array($dynamics)) {
                                    foreach ($dynamics as $key => $value) {
                                        $userObj['__ATTRIBUTES__'][$key] = $value;
                                    }
                                }
                            }
                        }

                        $userObj['__ATTRIBUTES__']['_Users_isVerified'] = 0;

                        if ($legalModuleActive) {
                            $userRegDateTime = new DateTime($userArray[$key]['user_regdate'], new DateTimeZone('UTC'));
                            $policyDateTimeStr = $userRegDateTime->format(DATE_ISO8601);

                            if ($termsOfUseActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_termsOfUseAccepted'] = $policyDateTimeStr;
                            }
                            if ($privacyPolicyActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_privacyPolicyAccepted'] = $policyDateTimeStr;
                            }
                            if ($agePolicyActive) {
                                $userObj['__ATTRIBUTES__']['_Legal_agePolicyConfirmed'] = $policyDateTimeStr;
                            }
                        }

                        $userArray[] = $userObj;
                    } else {
                        throw new Zikula_Exception_Fatal($this->__f('Unknown users_temp record type: %1$s', array($userTempArray[$key]['type'])));
                    }
                }
            }
            if (!DBUtil::insertObjectArray($userArray, 'users', 'uid', false)) {
                $updated = false;
                break;
            }
            $limitOffset += $limitNumRows;
        }
        if (!$updated) {
            return false;
        }

        // Done upgrading. Let's lose some old fields and tables we no longer need.
        DBUtil::dropColumn('users', $usersOldFieldsDB);
        DBUtil::dropTable('users_temp');

        // Reset the system tables to the new table definitons, so the rest of the
        // system upgrade goes smoothly.
        $dbinfoSystem = $serviceManager['dbtables'];
        foreach ($dbinfo113X as $key => $value) {
            unset($dbinfoSystem[$key]);
        }
        foreach ($dbinfo220 as $key => $value) {
            $dbinfoSystem[$key] = $value;
        }
        $serviceManager['dbtables'] = $dbinfoSystem;

        // Update users table for data type change of activated field.
        if (!DBUtil::changeTable('users')) {
            return false;
        }

        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:Installer.php

示例7: smarty_function_duditemmodify


//.........这里部分代码省略.........
        return $render->fetch('profile_dudedit_select.tpl');
    }

    switch ($item['prop_displaytype'])
    {
        case 0: // TEXT
            $type = 'text';
            break;

        case 1: // TEXTAREA
            $type = 'textarea';
            break;

        case 2: // CHECKBOX
            $type = 'checkbox';

            $editlabel = array_splice(explode('@@', $item['prop_listoptions']), 0, 1);
            if (!empty($editlabel[0])) {
                $render->assign('proplabeltext', __($editlabel[0], $dom));
            }
            break;

        case 3: // RADIO
            $type = 'radio';

            $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));

            $render->assign('listoptions', array_keys($options));
            $render->assign('listoutput', array_values($options));
            break;

        case 4: // SELECT
            $type = 'select';
            if (DataUtil::is_serialized($uservalue)) {
                $render->assign('value', unserialize($uservalue));
            }

            // multiple flag is the first field
            $options = explode('@@', $item['prop_listoptions'], 2);
            $selectmultiple = $options[0] ? ' multiple="multiple"' : '';
            $render->assign('selectmultiple', $selectmultiple);

            $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));

            $render->assign('listoptions', array_keys($options));
            $render->assign('listoutput', array_values($options));
            break;

        case 5: // DATE
            $type = 'date';

            // gets the format to use
            $format = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item));
            
            switch (trim(strtolower($format)))
            {
                case 'datelong':
                    //! This is from the core domain (datelong)
                    $format = __('%A, %B %d, %Y');
                    break;
                case 'datebrief':
                    //! This is from the core domain (datebrief)
                    $format = __('%b %d, %Y');
                    break;
                case 'datestring':
                    //! This is from the core domain (datestring)
开发者ID:projectesIF,项目名称:Sirius,代码行数:67,代码来源:function.duditemmodify.php

示例8: upgrade

 /**
  * upgrade the blocks module
  *
  * @param string $oldversion version being upgraded
  *
  * @return bool true if successful, false otherwise
  */
 public function upgrade($oldversion)
 {
     // Upgrade dependent on old version number
     switch ($oldversion) {
         case '3.8.1':
             $HookContainer = new HookContainer($this->getTranslator());
             HookUtil::registerSubscriberBundles($HookContainer->getHookSubscriberBundles());
         case '3.8.2':
         case '3.9.0':
             $blocks = $this->entityManager->getRepository('ZikulaBlocksModule:BlockEntity')->findAll();
             /** @var \Zikula\BlocksModule\Entity\BlockEntity $block */
             foreach ($blocks as $block) {
                 $content = $block->getContent();
                 if (\DataUtil::is_serialized($content)) {
                     $content = unserialize($content);
                     foreach ($content as $k => $item) {
                         if (is_string($item)) {
                             if (strpos($item, 'blocks_block_extmenu_topnav.tpl') !== false) {
                                 $content[$k] = str_replace('blocks_block_extmenu_topnav.tpl', 'Block/Extmenu/topnav.tpl', $item);
                             } elseif (strpos($item, 'blocks_block_extmenu.tpl') !== false) {
                                 $content[$k] = str_replace('blocks_block_extmenu.tpl', 'Block/Extmenu/extmenu.tpl', $item);
                             } elseif (strpos($item, 'menutree/blocks_block_menutree_') !== false) {
                                 $content[$k] = str_replace('menutree/blocks_block_menutree_', 'Block/Menutree/', $item);
                             }
                         }
                     }
                     $block->setContent(serialize($content));
                 }
             }
             $this->entityManager->flush();
             // check if request is available (#2073)
             $templateWarning = $this->__('Warning: Block template locations modified, you may need to fix your template overrides if you have any.');
             if (is_object($this->container->get('request')) && method_exists($this->container->get('request'), 'getSession') && is_object($this->container->get('request')->getSession())) {
                 $this->addFlash(\Zikula_Session::MESSAGE_WARNING, $templateWarning);
             } else {
                 \LogUtil::registerWarning($templateWarning);
             }
         case '3.9.1':
             // make all content fields of blocks serialized.
             $sql = "SELECT * FROM blocks";
             $blocks = $this->entityManager->getConnection()->fetchAll($sql);
             foreach ($blocks as $block) {
                 if (!\DataUtil::is_serialized($block['content'])) {
                     $serializedContent = addslashes(serialize($block['content']));
                     $this->entityManager->getConnection()->executeQuery("UPDATE blocks SET content = '{$serializedContent}' WHERE bid = {$block['bid']}");
                 }
             }
             $this->schemaTool->update($this->entities);
             $blocks = $this->entityManager->getRepository('ZikulaBlocksModule:BlockEntity')->findAll();
             $installerHelper = new InstallerHelper();
             /** @var \Zikula\BlocksModule\Entity\BlockEntity $block */
             foreach ($blocks as $block) {
                 $block->setFilters($installerHelper->upgradeFilterArray($block->getFilters()));
                 $block->setBlocktype(preg_match('/.*Block$/', $block->getBkey()) ? substr($block->getBkey(), 0, -5) : $block->getBkey());
                 $block->setBkey($installerHelper->upgradeBkeyToFqClassname($this->container->get('kernel'), $block));
             }
             $this->entityManager->flush();
             $collapseable = $this->getVar('collapseable');
             $this->setVar('collapseable', (bool) $collapseable);
         case '3.9.2':
             // future upgrade routines
     }
     // Update successful
     return true;
 }
开发者ID:Silwereth,项目名称:core,代码行数:72,代码来源:BlocksModuleInstaller.php


注:本文中的DataUtil::is_serialized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。