本文整理汇总了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]);
}
}
}