Exemplo n.º 1
0
     $return_string = $return_string . "<div id=\"search_page" . $page_no . "\" ";
     if ($page_no == 1) {
         $return_string = $return_string . "style=\"display:block;\"";
     } else {
         $return_string = $return_string . "style=\"display:none;\"";
     }
     $return_string = $return_string . ">" . "<table id=\"search_table\" class=\"report\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" . "<colgroup>" . "<col class=\"num\"/>" . "<col class=\"ProbType\"/>" . "<col class=\"ProbDesc\"/>" . "<col class=\"ProbCategory\"/>" . "<col class=\"ProbLevel\"/>" . "<col class=\"ProbMemo\"/>" . "<col class=\"ProbStatus\"/>" . "<col class=\"ProbAction\"/>" . "</colgroup>" . "<tr>" . "<th>编号</th>" . "<th>类型</th>" . "<th>描述</th>" . "<th>分类</th>" . "<th>难易</th>" . "<th>备注</th>" . "<th>状态</th>" . "<th>动作</th>" . "</tr>";
 }
 if ($page_count < $page_size) {
     $row = mysqli_fetch_assoc($result);
     $ProbId = $row["ProblemId"];
     $ProbType = $row["ProblemType"];
     $ProbTypeStr = get_type_name_from_id($ProbType);
     $ProbDesc = $row["ProblemDesc"];
     $ProbCategory = $row["ProblemCategory"];
     $funcs_id = get_function_id($ProbCategory);
     $funcs_name = get_funcs_name($funcs_id);
     $funcs_name_str = get_funcs_name_str($funcs_name);
     $ProbLevel = $row["ProblemLevel"];
     $ProbLevelStr = get_level_name($ProbLevel);
     $ProbMemo = $row["ProblemMemo"];
     $ProbStatus = $row["Status"];
     $StatusStr = $ProbStatus == 0 ? "下架" : "上架";
     $StatusAction = $ProbStatus == 1 ? "下架" : "上架";
     $page_count_display = $page_count + 1;
     $return_string = $return_string . "<tr>" . "<td>{$page_count_display}</td>" . "<td><span class=\"ProbType fixWidth\">{$ProbTypeStr}</span></td>" . "<td><span class=\"ProbDesc fixWidth\">{$ProbDesc}</span></td>" . "<td><span class=\"ProbCategory fixWidth\">{$funcs_name_str}</span></td>" . "<td><span class=\"ProbLevel fixWidth\">{$ProbLevelStr}</span></td>" . "<td><span class=\"ProbMemo fixWidth\">{$ProbMemo}</span></td>" . "<td>{$StatusStr}</td>" . "<td><A OnClick=\"actionSearchProbs({$ProbId},{$ProbStatus});\">{$StatusAction}</A><br/>" . "<A OnClick=\"modifySearchProbs({$ProbId});\">修改</A><br/>" . "<A OnClick=\"deleteSearchProbs({$ProbId});\">删除</A></td>" . "</tr>";
     $i++;
     $page_count++;
     if ($page_count == $page_size) {
         $return_string = $return_string . "</table>" . "</div>\n";
         $page_no++;
                echo "<Input type=checkbox name=ProbCategoryModify checked value=\"" . $row['FunctionId'] . "\">" . $row['FunctionName'] . '&nbsp;';
            } else {
                echo "<Input type=checkbox name=ProbCategoryModify value=\"" . $row['FunctionId'] . "\">" . $row['FunctionName'] . '&nbsp;';
            }
            $i++;
        }
        echo "</tr>";
    }
}
// Function Other
$func_type = FUNCTION_OTHER;
$str_query = "Select * from functions where FunctionType={$func_type}";
if ($result = mysqli_query($link, $str_query)) {
    $row_number = mysqli_num_rows($result);
    if ($row_number > 0) {
        $func_ids = get_function_id($ProbCategory);
        echo "<tr><th>" . get_func_type_name($func_type) . "</th><td>";
        $i = 0;
        while ($i < $row_number) {
            $row = mysqli_fetch_assoc($result);
            if (in_array($row['FunctionId'], $func_ids)) {
                echo "<Input type=checkbox name=ProbCategoryModify checked value=\"" . $row['FunctionId'] . "\">" . $row['FunctionName'] . '&nbsp;';
            } else {
                echo "<Input type=checkbox name=ProbCategoryModify value=\"" . $row['FunctionId'] . "\">" . $row['FunctionName'] . '&nbsp;';
            }
            $i++;
        }
        echo "</tr>";
    }
}
?>
Exemplo n.º 3
0
function create_processes($datafile, $feeds, $inputs, $apikey)
{
    // Global variables
    global $base_url;
    // Read the processes from file
    $processArray = json_decode(file_get_contents($datafile));
    // Create each process
    foreach ($processArray as $process) {
        $inputId = $inputs[$process->input];
        // Translate process
        $processesStrings = array();
        foreach ($process->processes as $function) {
            // Translate function
            $functionId = get_function_id($function->function);
            // Arguments
            if (!empty($function->arguments)) {
                $argumentsArray = array();
                foreach ($function->arguments as $argument) {
                    // Get the id of the feed name
                    if ($argument->type == "feed") {
                        $argumentsArray[] = $feeds[$argument->value];
                    } else {
                        if ($argument->type == "input") {
                            $argumentsArray[] = $inputs[$argument->value];
                        } else {
                            $argumentsArray[] = strval($argument->value);
                        }
                    }
                }
                $arguments = implode(':', $argumentsArray);
            } else {
                $arguments = "0";
            }
            $translatedFunction = strval($functionId) . ":{$arguments}";
            // Add the translated string
            $processesStrings[] = $translatedFunction;
        }
        $processes = implode(",", $processesStrings);
        // Query
        $postdata = http_build_query(array('processlist' => "{$processes}"));
        $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
        $context = stream_context_create($opts);
        $result = file_get_contents("{$base_url}/input/process/set.json?inputid={$inputId}&apikey={$apikey}", false, $context);
        if ($result == "false" || $result === FALSE) {
            return false;
        }
    }
    return true;
}