Пример #1
0
function PDQ_CreateOpen($name, $lambda)
{
    global $s1;
    // extern char[]
    global $streams;
    // extern int
    global $DEBUG;
    // extern int
    global $c;
    $out_fd = NULL;
    // FILE *
    if ($DEBUG) {
        $out_fd = fopen("PDQ.out", "a");
        fprintf($out_fd, "name : %s  lambda : %f\n", $name, $lambda);
        fclose($out_fd);
    }
    if (strlen($name) > MAXCHARS) {
        $s1 = sprintf("Nodename \"%s\" is longer than %d characters", $name, MAXCHARS);
        errmsg("PDQ_CreateOpen()", $s1);
    }
    create_transaction(OPEN, $name, $lambda);
    $c = ++$streams;
    return $streams;
}
session_start();
if (isset($_SESSION['CURRENT_LOGIN_ID']) && isset($_SESSION['CURRENT_LOGIN_USER'])) {
    require_once 'class/Config.php';
    require_once 'class/Info_commodity.php';
    require_once 'class/commodity/Transaction_state_config.php';
    $commodity_id = (int) $_GET['commodity_id'];
    //连接数据库
    $conn = Config::connect();
    $commodity = new Info_commodity($conn, $commodity_id);
    $commodity_ary = $commodity->get_commodity();
    //判断当前用户是否具有权限: 当当前用户不是发布者
    if ($commodity_ary[Config_commodity::publisher] != $_SESSION['CURRENT_LOGIN_ID']) {
        //更新商品状态
        $commodity->update(Transaction_state_config::acceptor_comfirmed);
        //创建订单
        if (create_transaction($conn, $commodity_ary)) {
            send_msg($commodity_ary);
            include_once 'smarty_init.php';
            $smarty->display("");
        } else {
        }
    } else {
    }
} else {
    include 'Login.php';
}
function send_msg($commodity_ary)
{
    if ($commodity_ary[Config_commodity::course_or_reward] == Commodity_type_Config::course) {
        $content = '尊敬的用户您好,您发布的课程 ' . $commodity_ary[Config_commodity::title] . '已被客户 ' . $_SESSION['CURRENT_LOGIN_USER'] . '选中。请前往领行客户中心查看详情并于客户联系';
    } else {