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


PHP Hash::save方法代码示例

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


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

示例1: foreach

 /**
  * Check in script for clients
  *
  * Clients check in client data using $_POST
  *
  * @author AvB
  **/
 function check_in()
 {
     if (!isset($_POST['items'])) {
         $this->error("No items in POST");
     }
     $arr = @unserialize($_POST['items']);
     if (!is_array($arr)) {
         $this->error("Could not parse items, not a proper serialized file");
     }
     foreach ($arr as $name => $val) {
         // Skip items without data
         if (!isset($val['data'])) {
             continue;
         }
         // Rename legacy InventoryItem to inventory
         $name = str_ireplace('InventoryItem', 'inventory', $name);
         alert("starting: {$name}");
         // All models are lowercase
         $name = strtolower($name);
         if (preg_match('/[^\\da-z_]/', $name)) {
             $this->msg("Model has an illegal name: {$name}");
             continue;
         }
         // All models should be part of a module
         if (substr($name, -6) == '_model') {
             $module = substr($name, 0, -6);
         } else {
             $module = $name;
             $name = $module . '_model';
         }
         $model_path = APP_PATH . "modules/{$module}/";
         // Capitalize classname
         $classname = ucfirst($name);
         // Todo: prevent admin and user models, sanitize $name
         if (!file_exists($model_path . $name . '.php')) {
             $this->msg("Model not found: {$name}");
             continue;
         }
         require_once $model_path . $name . '.php';
         if (!class_exists($classname, false)) {
             $this->msg("Class not found: {$classname}");
             continue;
         }
         // Load model
         $class = new $classname($_POST['serial']);
         if (!method_exists($class, 'process')) {
             $this->msg("No process method in: {$classname}");
             continue;
         }
         try {
             $class->process($val['data']);
             // Store hash
             $hash = new Hash($_POST['serial'], $module);
             $hash->hash = $val['hash'];
             $hash->timestamp = time();
             $hash->save();
         } catch (Exception $e) {
             $this->msg("An error occurred while processing: {$classname}");
             $this->msg("Error: " . $e->getMessage());
         }
         // Handle alerts
         foreach ($GLOBALS['alerts'] as $type => $list) {
             foreach ($list as $msg) {
                 $this->msg("{$type}: {$msg}");
             }
             // Remove alert from array
             unset($GLOBALS['alerts'][$type]);
         }
     }
 }
开发者ID:kidistS,项目名称:munkireport-php,代码行数:77,代码来源:report.php


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