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


PHP parse_action函数代码示例

本文整理汇总了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);
    }
}
开发者ID:PunkAvail,项目名称:ThinkWechat,代码行数:67,代码来源:function.php

示例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);
}
开发者ID:newbacknew,项目名称:owloo.com,代码行数:33,代码来源:fb_bot.php

示例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);
    }
}
开发者ID:h136799711,项目名称:baseItboye,代码行数:70,代码来源:function.php

示例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);
    }
}
开发者ID:commiunty,项目名称:Mytest,代码行数:40,代码来源:function.php


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