コード例 #1
0
<?php

// This file has diverse symbol declarations and requirements, and can be used
// to test changes to phutil_symbols.php.
/**
 * @phutil-external-symbol function ext_func
 * @phutil-external-symbol class ExtClass
 * @phutil-external-symbol interface ExtInterface
 */
ext_func();
new ExtClass();
class L implements ExtInterface
{
}
function f()
{
}
function () {
    // Anonymous function.
};
g();
$g();
${$g}();
X::f();
call_user_func();
call_user_func('h');
call_user_func($var);
class A
{
}
class C extends B
コード例 #2
0
ファイル: custom_form.php プロジェクト: laiello/mystep-cms
function build_page($method)
{
    global $mystep, $req, $db, $setting, $id, $mid, $record, $tpl_tmp;
    $tpl_info = array("idx" => "main", "style" => "../plugin/" . basename(realpath(dirname(__FILE__))), "path" => ROOT_PATH . "/" . $setting['path']['template']);
    if ($method == "list" || $method == "add" || $method == "edit") {
        $tpl_info['style'] .= "/tpl/";
    } else {
        $tpl_info['style'] .= "/setting/";
    }
    $tpl = $mystep->getInstance("MyTpl", $tpl_info);
    if ($method == "edit_data") {
        $tpl_info['idx'] = $mid . "_edit_data";
    } elseif ($method == "list_data") {
        $tpl_info['idx'] = $mid . "_list_data";
    } else {
        $tpl_info['idx'] = $method;
    }
    $tpl_tmp = $mystep->getInstance("MyTpl", $tpl_info);
    if ($method == "confirm") {
        global $para;
        $record = $db->record($setting['db']['pre'] . "custom_form_" . $mid, "*", array("id", "n=", $id));
        if ($record === false || !file_exists("setting/{$mid}.php")) {
            $tpl->Set_Variable('main', showInfo("指定的记录不存在或配置文件缺失!", 0));
            $mystep->show($tpl);
            $mystep->pageEnd(false);
        }
        if (function_exists("ext_func")) {
            ext_func();
        }
        $db->update($setting['db']['pre'] . "custom_form_" . $mid, array("mailed" => 1), array("id", "n=", $record['id']));
        include "setting/" . $mid . ".php";
        $tpl_info['idx'] = "{$mid}_mail_" . (empty($record['name']) && !empty($record['name_en']) ? "en" : "cn");
        $tpl_tmp->ClearError();
        $tpl_tmp->init($tpl_info);
        if (empty($record['name'])) {
            $record['name'] = $record['name_en'];
        }
        $tpl_tmp->Set_Variables($record, 'record');
        $custom_form = $db->record($setting['db']['pre'] . "custom_form", "*", array("mid", "n=", $mid));
        $tpl_tmp->Set_Variables($custom_form);
        $tpl_tmp->allow_script = true;
    } elseif ($method == "list_data") {
        $page = $req->getGet("page");
        $order = $req->getGet("order");
        $tpl_tmp->Set_Variable('order', $order);
        $order_type = $req->getGet("order_type");
        if (empty($order_type)) {
            $order_type = "desc";
        }
        include_once "setting/{$mid}.php";
        $condition = array();
        if (!empty($keyword)) {
            if (is_numeric($keyword)) {
                $condition[] = array("id", "n=", $keyword, "or");
            }
            foreach ($para as $key => $value) {
                if ($para[$key]['search'] == 'true') {
                    switch ($para[$key]['type']) {
                        case "file":
                        case "textarea":
                            $condition[] = array($key, "like", $keyword, "or");
                            break;
                        case "radio":
                        case "select":
                            $condition[] = array($key, "=", $keyword, "or");
                            break;
                        case "text":
                            if ($para[$key]['format'] == "digital" || $para[$key]['format'] == "number") {
                                $condition[] = array($key, "=", $keyword, "or");
                            } else {
                                $condition[] = array($key, "like", $keyword, "or");
                            }
                            break;
                        case "checkbox":
                            break;
                        default:
                            $condition[] = array($key, "=", $keyword, "or");
                            break;
                    }
                }
            }
        }
        $key_file = array();
        foreach ($para as $key => $value) {
            if ($para[$key]['type'] == 'file') {
                $key_file[] = $key;
            }
        }
        //navigation
        $counter = $db->result($setting['db']['pre'] . "custom_form_" . $mid, "count(*)", $condition);
        list($page_arr, $page_start, $page_size) = GetPageList($counter, "?mid={$mid}&keyword={$keyword}&order={$order}&order_type={$order_type}", $page);
        $tpl_tmp->Set_Variables($page_arr);
        //main list
        if (empty($order)) {
            $order = "id";
        }
        $the_order = array();
        $the_order[] = "{$order} {$order_type}";
        if ($order != "id") {
            $the_order[] = "id " . $order_type;
        }
        $db->select($setting['db']['pre'] . "custom_form_" . $mid, "*", $condition, array("order" => $the_order, "limit" => "{$page_start}, {$page_size}"));
        while ($record = $db->GetRS()) {
            HtmlTrans(&$record);
            if (function_exists("ext_func")) {
                ext_func();
            }
            if (empty($record['name']) && !empty($record['name_en'])) {
                $record['name'] = $record['name_en'];
            }
            if (empty($record['company']) && !empty($record['company_en'])) {
                $record['company'] = $record['company_en'];
            }
            foreach ($key_file as $key) {
                if (empty($record[$key])) {
                    continue;
                }
                $cur_file = explode("::", $record[$key]);
                if (strpos($cur_file[1], "image") !== false) {
                    $record[$key] = '<a href="file.php?mid=' . $mid . '&id=' . $record['id'] . '&f=' . $key . '" target="_blank"><img src="file.php?mid=' . $mid . '&id=' . $record['id'] . '&f=' . $key . '" width="120" alt="' . $cur_file[0] . '" /></a>';
                } else {
                    $record[$key] = '<a href="file.php?mid=' . $mid . '&id=' . $record['id'] . '&f=' . $key . '" target="_blank">' . $cur_file[0] . '</a>';
                }
            }
            $record['confirm'] = "";
            if ($record['mailed'] != "已发") {
                $record['confirm'] = ' &nbsp;<a href="?method=confirm&mid=' . $mid . '&id=' . $record['id'] . '">确认</a>';
            }
            $tpl_tmp->Set_Loop('record', $record);
        }
        $tpl_tmp->Set_Variable('custom_form_name', $db->result($setting['db']['pre'] . "custom_form", "name", array("mid", "n=", $mid)));
        $tpl_tmp->Set_Variable('title', '表单信息浏览');
        $tpl_tmp->Set_Variable('keyword', $keyword);
        $tpl_tmp->Set_Variable('order_type_org', $order_type);
        $order_type = $order_type == "asc" ? "desc" : "asc";
        $tpl_tmp->Set_Variable('order_type', $order_type);
        $tpl_tmp->Set_Variable('keyword', $keyword);
    } elseif ($method == "edit_data") {
        global $para, $record;
        $keyword = mysql_real_escape_string($req->getGet("keyword"));
        $record = $db->record($setting['db']['pre'] . "custom_form_" . $mid, "*", array("id", "n=", $id));
        if ($record === false || !file_exists("setting/{$mid}.php")) {
            $tpl->Set_Variable('main', showInfo("指定的记录不存在或配置文件缺失!", 0));
            $mystep->show($tpl);
            $mystep->pageEnd(false);
        }
        HtmlTrans(&$record);
        if (function_exists("ext_func")) {
            ext_func();
        }
        $tpl_tmp->Set_Variables($record, "record");
        $tpl_tmp->Set_Variable('custom_form_name', $db->result($setting['db']['pre'] . "custom_form", "name", array("mid", "n=", $mid)));
        $tpl_tmp->Set_Variable('title', '表单信息更新');
        $tpl_tmp->Set_Variable('method', 'edit_data');
        $tpl_tmp->Set_Variable('keyword', $keyword);
        include "setting/{$mid}.php";
        $tpl_tmp->allow_script = true;
    } elseif ($method == "list") {
        $db->select($setting['db']['pre'] . "custom_form", "*", "", array("order" => "mid desc"));
        while ($record = $db->GetRS()) {
            HtmlTrans(&$record);
            if ($record['web_id'] == 0) {
                $record['web_id'] = "仅管理面板";
            } elseif ($record['web_id'] == 255) {
                $record['web_id'] = "全部子站";
            } else {
                $webinfo = getParaInfo("website", "web_id", $record['web_id']);
                $record['web_id'] = $webinfo['name'];
            }
            $record['link_submit'] = getUrl("cf_submit", $record['mid']);
            $record['link_list'] = getUrl("cf_list", $record['mid']);
            $tpl_tmp->Set_Loop('record', $record);
        }
        $tpl_tmp->Set_Variable('title', '表单浏览');
        $tpl_tmp->Set_Variable('order_type_org', $order_type);
        $order_type = $order_type == "asc" ? "desc" : "asc";
        $tpl_tmp->Set_Variable('order_type', $order_type);
        global $admin_cat;
        $tpl_tmp->Set_Variable('admin_cat', toJson($admin_cat, $setting['gen']['charset']));
    } elseif ($method == "edit") {
        $record = $db->record($setting['db']['pre'] . "custom_form", "*", array("mid", "n=", $mid));
        if ($record === false) {
            $tpl->Set_Variable('main', showInfo("指定的记录不存在!", 0));
            $mystep->show($tpl);
            $mystep->pageEnd(false);
        }
        if (function_exists("ext_func")) {
            ext_func();
        }
        $tpl_tmp->Set_Variables($record);
        $tpl_tmp->Set_Variable('title', '修改表单项目');
        $tpl_tmp->Set_Variable('method', 'edit');
        $max_count = count($GLOBALS['website']);
        for ($i = 0; $i < $max_count; $i++) {
            $tpl_tmp->Set_Loop("website", $GLOBALS['website'][$i]);
        }
        include "setting/{$mid}.php";
        $tpl_tmp->Set_Variable('cf_item', toJson($para, $setting['gen']['charset']));
        $tpl_tmp->Set_Variable('tpl_cf_submit_cn', htmlspecialchars(GetFile("setting/{$mid}_cf_submit_cn.tpl")));
        $tpl_tmp->Set_Variable('tpl_cf_submit_en', htmlspecialchars(GetFile("setting/{$mid}_cf_submit_en.tpl")));
        $tpl_tmp->Set_Variable('tpl_cf_print_cn', htmlspecialchars(GetFile("setting/{$mid}_cf_print_cn.tpl")));
        $tpl_tmp->Set_Variable('tpl_cf_print_en', htmlspecialchars(GetFile("setting/{$mid}_cf_print_en.tpl")));
        $tpl_tmp->Set_Variable('tpl_cf_list_cn', htmlspecialchars(GetFile("setting/{$mid}_cf_list_cn.tpl")));
        $tpl_tmp->Set_Variable('tpl_cf_list_en', htmlspecialchars(GetFile("setting/{$mid}_cf_list_en.tpl")));
        $tpl_tmp->Set_Variable('tpl_block_cf_list_cn', htmlspecialchars(GetFile("setting/{$mid}_block_cf_list_cn.tpl")));
        $tpl_tmp->Set_Variable('tpl_block_cf_list_en', htmlspecialchars(GetFile("setting/{$mid}_block_cf_list_en.tpl")));
        $tpl_tmp->Set_Variable('tpl_mail_cn', htmlspecialchars(GetFile("setting/{$mid}_mail_cn.tpl")));
        $tpl_tmp->Set_Variable('tpl_mail_en', htmlspecialchars(GetFile("setting/{$mid}_mail_en.tpl")));
        $tpl_tmp->Set_Variable('tpl_edit_data', htmlspecialchars(GetFile("setting/{$mid}_edit_data.tpl")));
        $tpl_tmp->Set_Variable('tpl_list_data', htmlspecialchars(GetFile("setting/{$mid}_list_data.tpl")));
        $tpl_tmp->Set_Variable('ext_script', htmlspecialchars(GetFile("setting/{$mid}_ext_script.php")));
    } elseif ($method == "add") {
        $tpl_tmp->Set_Variable('title', '添加表单');
        $tpl_tmp->Set_Variable('method', 'add');
        $max_count = count($GLOBALS['website']);
        for ($i = 0; $i < $max_count; $i++) {
            $tpl_tmp->Set_Loop("website", $GLOBALS['website'][$i]);
        }
        if (file_exists("setting/" . $mid . ".php")) {
            include "setting/" . $mid . ".php";
            $tpl_tmp->Set_Variable('tpl_cf_submit_cn', htmlspecialchars(GetFile("setting/" . $mid . "_cf_submit_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_submit_en', htmlspecialchars(GetFile("setting/" . $mid . "_cf_submit_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_print_cn', htmlspecialchars(GetFile("setting/" . $mid . "_cf_print_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_print_en', htmlspecialchars(GetFile("setting/" . $mid . "_cf_print_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_list_cn', htmlspecialchars(GetFile("setting/" . $mid . "_cf_list_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_list_en', htmlspecialchars(GetFile("setting/" . $mid . "_cf_list_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_block_cf_list_cn', htmlspecialchars(GetFile("setting/" . $mid . "_block_cf_list_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_block_cf_list_en', htmlspecialchars(GetFile("setting/" . $mid . "_block_cf_list_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_mail_cn', htmlspecialchars(GetFile("setting/" . $mid . "_mail_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_mail_en', htmlspecialchars(GetFile("setting/" . $mid . "_mail_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_edit_data', htmlspecialchars(GetFile("setting/" . $mid . "_edit_data.tpl")));
            $tpl_tmp->Set_Variable('tpl_list_data', htmlspecialchars(GetFile("setting/" . $mid . "_list_data.tpl")));
            $tpl_tmp->Set_Variable('ext_script', htmlspecialchars(GetFile("setting/" . $mid . "_ext_script.php")));
        } else {
            include "setting/default.php";
            $tpl_tmp->Set_Variable('tpl_cf_submit_cn', htmlspecialchars(GetFile("tpl/default_cf_submit_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_submit_en', htmlspecialchars(GetFile("tpl/default_cf_submit_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_print_cn', htmlspecialchars(GetFile("tpl/default_cf_print_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_print_en', htmlspecialchars(GetFile("tpl/default_cf_print_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_list_cn', htmlspecialchars(GetFile("tpl/default_cf_list_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_cf_list_en', htmlspecialchars(GetFile("tpl/default_cf_list_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_block_cf_list_cn', htmlspecialchars(GetFile("tpl/block_cf_list_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_block_cf_list_en', htmlspecialchars(GetFile("tpl/block_cf_list_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_mail_cn', htmlspecialchars(GetFile("tpl/default_mail_cn.tpl")));
            $tpl_tmp->Set_Variable('tpl_mail_en', htmlspecialchars(GetFile("tpl/default_mail_en.tpl")));
            $tpl_tmp->Set_Variable('tpl_edit_data', htmlspecialchars(GetFile("tpl/edit_data.tpl")));
            $tpl_tmp->Set_Variable('tpl_list_data', htmlspecialchars(GetFile("tpl/list_data.tpl")));
            $tpl_tmp->Set_Variable('ext_script', htmlspecialchars(GetFile("setting/ext_script.php")));
        }
        $tpl_tmp->Set_Variable('cf_item', toJson($para, $setting['gen']['charset']));
        if (function_exists("ext_func")) {
            ext_func();
        }
    }
    $tpl_tmp->Set_Variable('mid', $mid);
    $tpl->Set_Variable('path_admin', $setting['path']['admin']);
    $tpl->Set_Variable('main', $tpl_tmp->Get_Content('$setting, $para'));
    $db->Free();
    unset($tpl_tmp);
    $mystep->show($tpl);
    return;
}