本文整理匯總了PHP中parse_action函數的典型用法代碼示例。如果您正苦於以下問題:PHP parse_action函數的具體用法?PHP parse_action怎麽用?PHP parse_action使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了parse_action函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: action_log
/**
* 記錄行為日誌,並執行該行為的規則
*
* @param string $action
* 行為標識
* @param string $model
* 觸發行為的模型名
* @param int $record_id
* 觸發行為的記錄id
* @param int $user_id
* 執行行為的用戶id
* @return boolean
* @author huajie <banhuajie@163.com>
*/
function action_log($action = null, $model = null, $record_id = null, $user_id = null)
{
// 參數檢查
if (empty($action) || empty($model) || empty($record_id)) {
return '參數不能為空';
}
if (empty($user_id)) {
$user_id = is_login();
}
// 查詢行為,判斷是否執行
$action_info = M('Action')->getByName($action);
if ($action_info['status'] != 1) {
return '該行為被禁用或刪除';
}
// 插入行為日誌
$data['action_id'] = $action_info['id'];
$data['user_id'] = $user_id;
$data['action_ip'] = ip2long(get_client_ip());
$data['model'] = $model;
$data['record_id'] = $record_id;
$data['create_time'] = NOW_TIME;
// 解析日誌規則,生成日誌備注
if (!empty($action_info['log'])) {
if (preg_match_all('/\\[(\\S+?)\\]/', $action_info['log'], $match)) {
$log['user'] = $user_id;
$log['record'] = $record_id;
$log['model'] = $model;
$log['time'] = NOW_TIME;
$log['data'] = array('user' => $user_id, 'model' => $model, 'record' => $record_id, 'time' => NOW_TIME);
foreach ($match[1] as $value) {
$param = explode('|', $value);
if (isset($param[1])) {
$replace[] = call_user_func($param[1], $log[$param[0]]);
} else {
$replace[] = $log[$param[0]];
}
}
$data['remark'] = str_replace($match[0], $replace, $action_info['log']);
} else {
$data['remark'] = $action_info['log'];
}
} else {
// 未定義日誌規則,記錄操作url
$data['remark'] = '操作url:' . $_SERVER['REQUEST_URI'];
}
M('ActionLog')->add($data);
if (!empty($action_info['rule'])) {
// 解析行為
$rules = parse_action($action, $user_id);
// 執行行為
$res = execute_action($rules, $action_info['id'], $user_id);
}
}
示例2: update
function update($status)
{
$html = grab_home();
$form_action = parse_action($html);
$inputs = parse_inputs($html);
$post_params = "status={$status}&";
foreach ($inputs as $input) {
$post_params .= $input->getAttribute('name') . '=' . urlencode($input->getAttribute('value')) . '&';
}
if ($GLOBALS['debug']) {
echo "\nStatus update form action: {$form_action}\n";
echo "\nStatus update params: {$post_params}\n";
}
/*
* post the update
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_COOKIEFILE, $GLOBALS['cookies']);
curl_setopt($ch, CURLOPT_USERAGENT, $GLOBALS['uagent']);
curl_setopt($ch, CURLOPT_URL, $form_action);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$updated = curl_exec($ch);
if ($GLOBALS['debug']) {
echo $updated;
}
curl_close($ch);
}
示例3: action_log
/**
* 記錄行為日誌,並執行該行為的規則
* @param string $action 行為標識
* @param string $model 觸發行為的模型名
* @param int $record_id 觸發行為的記錄id
* @param int $user_id 執行行為的用戶id
* @return boolean
*/
function action_log($action = null, $model = null, $record_id = null, $user_id = null)
{
//參數檢查
if (empty($action) || empty($model) || empty($record_id)) {
return '參數不能為空';
}
if (empty($user_id)) {
$user_id = is_login();
}
//查詢行為,判斷是否執行
$action_info = apiCall(\Admin\Api\ActionApi::GET_INFO, array(array("name" => $action)));
if ($action_info['status'] && is_array($action_info['info']) && $action_info['info']['status'] != 1) {
return '該行為被禁用或刪除';
}
$action_info = $action_info['info'];
//插入行為日誌
$data['action_id'] = $action_info['id'];
$data['user_id'] = $user_id;
$data['action_ip'] = ip2long(get_client_ip());
$data['model'] = $model;
$data['record_id'] = $record_id;
$data['create_time'] = NOW_TIME;
//解析日誌規則,生成日誌備注
if (!empty($action_info['log'])) {
if (preg_match_all('/\\[(\\S+?)\\]/', $action_info['log'], $match)) {
//匹配[],獲取[]裏的字符串
$log['user'] = $user_id;
$log['record'] = $record_id;
$log['model'] = $model;
$log['time'] = NOW_TIME;
$log['data'] = array('user' => $user_id, 'model' => $model, 'record' => $record_id, 'time' => NOW_TIME);
$replace = array();
foreach ($match[1] as $value) {
$param = explode('|', $value);
//分割字符串通過|
if (isset($param[1])) {
$replace[] = call_user_func($param[1], $log[$param[0]]);
//調用函數
} else {
$replace[] = $log[$param[0]];
}
}
$data['remark'] = str_replace($match[0], $replace, $action_info['log']);
} else {
$data['remark'] = $action_info['log'];
}
} else {
//未定義日誌規則,記錄操作url
$data['remark'] = '操作url:' . $_SERVER['REQUEST_URI'];
}
$result = apiCall(\Admin\Api\ActionLogApi::ADD, array($data));
if (!$result['status']) {
LogRecord("記錄操作日誌失敗!", $result['info']);
}
// M('ActionLog','common_')->add($data);
if (!empty($action_info['rule'])) {
//解析行為
$rules = parse_action($action, $user_id);
//執行行為
$res = execute_action($rules, $action_info['id'], $user_id);
}
}
示例4: action_log
/**
* 記錄行為日誌,並執行該行為的規則
* @param string $action 行為標識
* @param string $model 觸發行為的模型名
* @param int $record_id 觸發行為的記錄id
* @param int $user_id 執行行為的用戶id
* @return boolean
* @author huajie <banhuajie@163.com>
*/
function action_log($action = null, $model = null, $record_id = null, $user_id = null)
{
//參數檢查
if (empty($action) || empty($model) || empty($record_id)) {
return '參數不能為空';
}
if (empty($user_id)) {
$user_id = is_login();
}
//查詢行為,判斷是否執行
$action_info = M('Action')->getByName($action);
if ($action_info['status'] != 1) {
return '該行為被禁用或刪除';
}
//插入行為日誌
$data['action_id'] = $action_info['id'];
$data['user_id'] = $user_id;
$data['action_ip'] = ip2long(get_client_ip());
$data['model'] = $model;
$data['record_id'] = $record_id;
$data['create_time'] = NOW_TIME;
//係統日誌記錄操作url參數
$data['remark'] = '操作url:' . $_SERVER['REQUEST_URI'];
M('ActionLog')->add($data);
if (!empty($action_info['rule'])) {
//解析行為
$rules = parse_action($action, $user_id);
//執行行為
$res = execute_action($rules, $action_info['id'], $user_id);
}
}