Ejemplo n.º 1
0
function buildVariableEnv($uid, $gid, $tid, &$vardisp, &$bounds, &$privilege, &$tree, &$condensed, &$autoDisplay)
{
    $result = sqlquery("SELECT view_row.name AS user_name, variable.name AS var_name, path, warning_bound, error_bound, alarm_order, view_row.filter as varfilter, view_table.filter as viewfilter, display, auto_display, view_row.vid AS vid " . "FROM variable, view_row, view_table " . "WHERE variable.command='variable' AND (view_table.uid='{$uid}' OR view_table.uid='{$gid}') AND view_table.tid='{$tid}' AND view_row.tid='{$tid}' AND variable.vid=view_row.vid ORDER BY view_row.ordering");
    while ($result && ($arr = sqlfetch($result))) {
        $vid = $arr["vid"];
        if (!hasAccessToVariable($vid)) {
            continue;
        }
        $path = $arr["path"];
        if ($arr["varfilter"] != "" && ($path = filterPath($path, $arr["varfilter"])) == "") {
            continue;
        }
        if ($arr["viewfilter"] != "" && ($path = filterPath($path, $arr["viewfilter"])) == "") {
            continue;
        }
        $condensed = $arr["display"] == "condensed";
        $autoDisplay = $arr["auto_display"] == "auto";
        $varName = getVarName($path);
        $vardisp[$varName] = $arr["user_name"];
        $bounds[$varName] = array($arr["warning_bound"], $arr["error_bound"], $arr["alarm_order"]);
        $privilege[$varName] = getVariableRight($vid);
        $address = explode(".", $path);
        //echo "add to tree address $path<br>\n";
        if (!isset($numsteps)) {
            $numsteps = count($address);
        }
        if ($numsteps != count($address)) {
            echo "Invalid table <b>{$tid}</b>, contains different variable path length (typically, mixed shard/server/service variables with entity variables)\n";
            return;
        }
        addToNode($tree, $address, 0);
    }
}
Ejemplo n.º 2
0
function jsCodeConfusion($content)
{
    $splStr = '';
    $i = '';
    $YesJs = '';
    $YesWord = '';
    $Sx = '';
    $s = '';
    $Wc = '';
    $Zc = '';
    $s1 = '';
    $AspCode = '';
    $SYHCount = '';
    $UpWord = '';
    $UpWordn = '';
    $tempS = '';
    $DimList = '';
    $YesFunction = '';
    //函数是否为真
    $StartFunction = '';
    //开始函数 目的是为了让function default 处理函数后面没有()   20150218
    $StartFunction = false;
    //默认开始函数为假
    //If nType="" Then  nType  = 0
    $yesJs = false;
    //是ASP 默认为假
    $YesFunction = false;
    //是函数 默认为假
    $YesWord = false;
    //是单词 默认为假
    $SYHCount = 0;
    //双引号默认为0
    $splStr = aspSplit($content, vbCrlf());
    //分割行
    $wcType = '';
    //输入文本类型,如 " 或 '
    $isAddToSYH = '';
    //是否累加双引号
    $beforeStr = '';
    $afterStr = '';
    $endCode = '';
    $nSYHCount = '';
    //循环分行
    foreach ($splStr as $key => $s) {
        //循环每个字符
        for ($i = 1; $i <= len($s); $i++) {
            $Sx = mid($s, $i, 1);
            //Asp开始
            if ($Sx == '<' && $Wc == '') {
                //输出文本必需为空 Wc为输出内容 如"<%" 排除 修改于20140412
                if (mid($s, $i + 1, 6) == 'script') {
                    $yesJs = true;
                    //ASP为真
                    $i = $i + 1;
                    //加1而不能加2,要不然<%function Test() 就截取不到
                    $Sx = mid($s, $i, 1);
                    $AspCode = $AspCode . '<';
                }
                //ASP结束
            } else {
                if ($Sx == '<' && mid($s, $i + 1, 8) == '/script>' && $Wc == '') {
                    //Wc为输出内容
                    $yesJs = false;
                    //ASP为假
                    $i = $i + 1;
                    //不能加2,只能加1,因为这里定义ASP为假,它会在下一次显示上面的 'ASP运行为假
                    $Sx = mid($s, $i, 8);
                    $AspCode = $AspCode . '/script>';
                }
            }
            if ($yesJs == true) {
                $beforeStr = right(replace(mid($s, 1, $i - 1), ' ', ''), 1);
                //上一个字符
                $afterStr = left(replace(mid($s, $i + 1, -1), ' ', ''), 1);
                //下一个字符
                $endCode = mid($s, $i + 1, -1);
                //当前字符往后面代码 一行
                //输入文本
                if ($sx == '"' || $sx == '\'' && $wcType == '' || $sx == $wcType || $wc != '') {
                    $isAddToSYH = true;
                    //这是一种简单的方法,等完善(20150914)
                    if ($isAddToSYH == true && $beforeStr == '\\') {
                        if (len($wc) >= 1) {
                            if (isStrTransferred($wc) == true) {
                                //为转义字符为真
                                //call echo(wc,isStrTransferred(wc))
                                $isAddToSYH = false;
                            }
                        } else {
                            $isAddToSYH = false;
                        }
                        //call echo(wc,isAddToSYH)
                    }
                    if ($wc == '') {
                        $wcType = $sx;
                    }
                    //双引号累加
                    if ($sx == $wcType && $isAddToSYH == true) {
                        $nSYHCount = $nSYHCount + 1;
                    }
                    //排除上一个字符为\这个转义字符(20150914)
                    //判断是否"在最后
                    if ($nSYHCount % 2 == 0 && $beforeStr != '\\') {
                        if (mid($s, $i + 1, 1) != $wcType) {
                            $wc = $wc . $sx;
                            $AspCode = $AspCode . $wc;
                            //行代码累加
                            //call echo("wc",wc)
                            $nSYHCount = 0;
                            $wc = '';
                            //清除
                            $wcType = '';
                        } else {
                            $wc = $wc . $sx;
                        }
                    } else {
                        $wc = $wc . $sx;
                    }
                } else {
                    if ($Sx == '\'') {
                        //注释则退出
                        $AspCode = $AspCode . mid($s, $i, -1);
                        break;
                        //字母
                    } else {
                        if (checkABC($Sx) == true || $Sx == '_' && $Zc != '' || $Zc != '') {
                            $Zc = $Zc . $Sx;
                            $s1 = lCase(mid($s . ' ', $i + 1, 1));
                            if (inStr('abcdefghijklmnopqrstuvwxyz0123456789', $s1) == 0 && ($s1 == '_' && $Zc != '')) {
                                //最简单判断
                                $tempS = mid($s, $i + 1, -1);
                                if (inStr('|function|sub|', '|' . lCase($Zc) . '|')) {
                                    //函数开始
                                    if ($YesFunction == false && lCase($UpWord) != 'end') {
                                        $YesFunction = true;
                                        $DimList = getFunDimName($tempS);
                                        $StartFunction = true;
                                    } else {
                                        if ($YesFunction == true && lCase($UpWord) == 'end') {
                                            //获得上一个单词
                                            $YesFunction = false;
                                        }
                                    }
                                } else {
                                    if ($YesFunction == true && lCase($Zc) == 'var') {
                                        $DimList = $DimList . ',' . getVarName($tempS);
                                    } else {
                                        if ($YesFunction == true) {
                                            //排除函数后面每一个名称
                                            if ($StartFunction == false) {
                                                $Zc = replaceDim2($DimList, $Zc);
                                            }
                                            $StartFunction = false;
                                        }
                                    }
                                }
                                $UpWord = $Zc;
                                //记住当前单词
                                $AspCode = $AspCode . $Zc;
                                $Zc = '';
                            }
                        } else {
                            $AspCode = $AspCode . $Sx;
                        }
                    }
                }
            } else {
                $AspCode = $AspCode . $Sx;
            }
            doEvents();
        }
        $AspCode = aspRTrim($AspCode);
        //去除右边空格
        $AspCode = $AspCode . vbCrlf();
        //Asp换行
        doEvents();
    }
    $jsCodeConfusion = $AspCode;
    return @$jsCodeConfusion;
}
Ejemplo n.º 3
0
/**
 * @var Behat\Behat\Definition\Loader\ClosuredDefinitionLoader $steps
 */
$steps->Given('/^that (.*) of the request is "([^"]*)"$/', function (FeatureContext $world, $fieldName, $fieldValue) {
    $fieldValue = strtr($fieldValue, $world->getNodeReplaceList());
    $world->setData(getVarName($fieldName), $fieldValue);
});
$steps->Given('/^in the response (.*) of the user is "([^"]*)"$/', function (FeatureContext $world, $fieldName, $fieldValue) {
    return array(new Step\Then(sprintf('field "%s" in the response should be "%s"', getVarName($fieldName), $fieldValue)));
});
/**
 * A demostration showing how to access sub-context and how to make assertions from under closured context.
 */
$steps->Given('/^in the response there should be no field called "([^"]*)"$/', function (FeatureContext $world, $fieldName) {
    $responseData = json_decode($world->getSubcontext('RestContext')->getResponse()->getBody(true));
    assertObjectNotHasAttribute($fieldName, $responseData);
});
$steps->Then('/^I\'m changing (.*) of the user to "([^"]*)"$/', function (FeatureContext $world, $fieldName, $fieldValue) {
    $world->setData(getVarName($fieldName), $fieldValue);
});
$steps->Given('/^the response should be:$/', function ($world, $table) {
    $responseData = json_decode($world->getSubcontext('RestContext')->getResponse()->getBody(true), true);
    $assertData = [];
    $hash = $table->getHash();
    foreach ($hash as $row) {
        $assertData[] = $row['name'];
    }
    if (array_diff($assertData, $responseData)) {
        throw new \Exception('Content is not equals');
    }
});
Ejemplo n.º 4
0
function getnerateIDAOObjects($ret)
{
    for ($i = 0; $i < count($ret); $i++) {
        if (!doesTableContainPK($ret[$i])) {
            continue;
        }
        $tableName = $ret[$i][0];
        $clazzName = getClazzName($tableName);
        $tab = getFields($tableName);
        $parameterSetter = "\n";
        $insertFields = "";
        $updateFields = "";
        $questionMarks = "";
        $readRow = "\n";
        $pk = '';
        $pks = array();
        $queryByField = '';
        $deleteByField = '';
        for ($j = 0; $j < count($tab); $j++) {
            if ($tab[$j][3] == 'PRI') {
                $pk = $tab[$j][0];
                $c = count($pks);
                $pks[$c] = $tab[$j][0];
            } else {
                $insertFields .= $tab[$j][0] . ", ";
                $updateFields .= $tab[$j][0] . " = ?, ";
                $questionMarks .= "?, ";
                if (isColumnTypeNumber($tab[$j][1])) {
                    $parameterSetter .= "\t\t\$sqlQuery->setNumber(\$" . getVarName($tableName) . "->get" . camelize(getVarNameWithS($tab[$j][0])) . "());\n";
                } else {
                    $parameterSetter .= "\t\t" . '$sqlQuery->set($' . getVarName($tab[$j][0]) . ');' . "\n";
                }
                $queryByField .= "\tpublic function queryBy" . getClazzName($tab[$j][0]) . "(\$value);\n\n";
                $deleteByField .= "\tpublic function deleteBy" . getClazzName($tab[$j][0]) . "(\$value);\n\n";
            }
            $readRow .= "\t\t\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . " = \$row['" . $tab[$j][0] . "'];\n";
        }
        if ($pk == '') {
            continue;
        }
        if (count($pks) == 1) {
            $template = new Template('templates/IDAO.tpl');
        } else {
            $template = new Template('templates/IDAO_with_complex_pk.tpl');
        }
        $template->set('dao_clazz_name', $clazzName);
        $template->set('domain_clazz_name', getDTOName($tableName));
        $template->set('dao_clazz_name_singular', plural2singular($clazzName));
        $template->set('table_name', $tableName);
        $template->set('var_name', getVarName($tableName));
        $s = '';
        $s2 = '';
        $s3 = '';
        $s4 = '';
        $insertFields2 = $insertFields;
        $questionMarks2 = $questionMarks;
        for ($z = 0; $z < count($pks); $z++) {
            $questionMarks2 .= ', ?';
            if ($z > 0) {
                $s .= ', ';
                $s2 .= ' AND ';
                $s3 .= "\t\t";
            }
            $insertFields2 .= ', ' . getVarNameWithS($pks[$z]);
            $s .= '$' . getVarNameWithS($pks[$z]);
            $s2 .= getVarNameWithS($pks[$z]) . ' = ? ';
            $s3 .= '$sqlQuery->setNumber(' . getVarName($pks[$z]) . ');';
            $s3 .= "\n";
            $s4 .= "\n\t\t";
            $s4 .= '$sqlQuery->setNumber($' . getVarName($tableName) . '->' . getVarNameWithS($pks[$z]) . ');';
            $s4 .= "\n";
        }
        $template->set('question_marks2', $questionMarks2);
        $template->set('insert_fields2', $insertFields2);
        $template->set('pk_set_update', $s4);
        $template->set('pk_set', $s3);
        $template->set('pk_where', $s2);
        $template->set('pks', $s);
        $insertFields = substr($insertFields, 0, strlen($insertFields) - 2);
        $updateFields = substr($updateFields, 0, strlen($updateFields) - 2);
        $questionMarks = substr($questionMarks, 0, strlen($questionMarks) - 2);
        $template->set('pk', $pk);
        $template->set('insert_fields', $insertFields);
        $template->set('read_row', $readRow);
        $template->set('update_fields', $updateFields);
        $template->set('question_marks', $questionMarks);
        $template->set('parameter_setter', $parameterSetter);
        $template->set('read_row', $readRow);
        $template->set('date', date("Y-m-d H:i"));
        $template->set('queryByFieldFunctions', $queryByField);
        $template->set('deleteByFieldFunctions', $deleteByField);
        $template->write('generated/class/dao/' . $clazzName . 'DAO.class.php');
    }
}
Ejemplo n.º 5
0
function generateIDAOObjects($ret)
{
    for ($i = 0; $i < count($ret); $i++) {
        if (!doesTableContainPK($ret[$i])) {
            continue;
        }
        $tableName = $ret[$i][0];
        $clazzName = getClazzName($tableName);
        $tab = getFields($tableName);
        $nullReplacer = "\n";
        $parameterSetter = "\n";
        $insertFields = "";
        $updateFields = "";
        $questionMarks = "";
        $readRow = "\n";
        $pk = '';
        $pks = array();
        $queryByField = '';
        $deleteByField = '';
        //RJG - Default for no primary key the first column - so that views and tables without a primary key appear
        //Assume the first field is the primary key
        $primary_found = false;
        for ($j = 0; $j < count($tab); $j++) {
            if ($tab[$j][3] == 'PRI') {
                $primary_found = true;
            }
        }
        if (!$primary_found) {
            $tab[0][3] = 'PRI';
        }
        //RJG End
        for ($j = 0; $j < count($tab); $j++) {
            if ($tab[$j][3] == 'PRI') {
                $pk = $tab[$j][0];
                $c = count($pks);
                $pks[$c] = $tab[$j][0];
            } else {
                $insertFields .= $tab[$j][0] . ", ";
                $updateFields .= $tab[$j][0] . " = ?, ";
                $questionMarks .= "?, ";
                //RJG - to handle insert and update with nulls
                $nullReplacer .= "\t\t\$qpos = strpos(\$sql, '?', \$qpos + 1);\n\t\tif ((!isset(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . ")) || is_null(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . "))\n\t\t\t\$sql = substr_replace(\$sql, 'NULL', \$qpos, 1);\n";
                if (isColumnTypeNumber($tab[$j][1])) {
                    $parameterSetter .= "\t\tif ((isset(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . ")) && (!is_null(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . ")))\n\t\t\t\$sqlQuery->setNumber(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . ");\n";
                } else {
                    $parameterSetter .= "\t\tif ((isset(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . ")) && (!is_null(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . ")))\n\t\t\t\$sqlQuery->set(\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . ");\n";
                }
                //RJG End
                $queryByField .= "\tpublic function queryBy" . getClazzName($tab[$j][0]) . "(\$value);\n\n";
                $deleteByField .= "\tpublic function deleteBy" . getClazzName($tab[$j][0]) . "(\$value);\n\n";
            }
            $readRow .= "\t\t\$" . getVarName($tableName) . "->" . getVarNameWithS($tab[$j][0]) . " = \$row['" . $tab[$j][0] . "'];\n";
        }
        if ($pk == '') {
            continue;
        }
        if (count($pks) == 1) {
            $template = new Template('templates/IDAO.tpl');
        } else {
            $template = new Template('templates/IDAO_with_complex_pk.tpl');
        }
        $template->set('dao_clazz_name', $clazzName);
        $template->set('table_name', $tableName);
        $template->set('var_name', getVarName($tableName));
        $s = '';
        $s2 = '';
        $s3 = '';
        $s4 = '';
        $insertFields2 = $insertFields;
        $questionMarks2 = $questionMarks;
        for ($z = 0; $z < count($pks); $z++) {
            $questionMarks2 .= ', ?';
            if ($z > 0) {
                $s .= ', ';
                $s2 .= ' AND ';
                $s3 .= "\t\t";
            }
            $insertFields2 .= ', ' . getVarNameWithS($pks[$z]);
            $s .= '$' . getVarNameWithS($pks[$z]);
            $s2 .= getVarNameWithS($pks[$z]) . ' = ? ';
            $s3 .= '$sqlQuery->setNumber(' . getVarName($pks[$z]) . ');';
            $s3 .= "\n";
            $s4 .= "\n\t\t";
            $s4 .= '$sqlQuery->setNumber($' . getVarName($tableName) . '->' . getVarNameWithS($pks[$z]) . ');';
            $s4 .= "\n";
        }
        $template->set('question_marks2', $questionMarks2);
        $template->set('insert_fields2', $insertFields2);
        $template->set('pk_set_update', $s4);
        $template->set('pk_set', $s3);
        $template->set('pk_where', $s2);
        $template->set('pks', $s);
        $insertFields = substr($insertFields, 0, strlen($insertFields) - 2);
        $updateFields = substr($updateFields, 0, strlen($updateFields) - 2);
        $questionMarks = substr($questionMarks, 0, strlen($questionMarks) - 2);
        $template->set('pk', $pk);
        $template->set('insert_fields', $insertFields);
        $template->set('read_row', $readRow);
        $template->set('update_fields', $updateFields);
        $template->set('question_marks', $questionMarks);
        $template->set('null_replacer', $nullReplacer);
        $template->set('parameter_setter', $parameterSetter);
        $template->set('read_row', $readRow);
        $template->set('date', date("Y-m-d H:i"));
        $template->set('queryByFieldFunctions', $queryByField);
        $template->set('deleteByFieldFunctions', $deleteByField);
        $template->write('modelo/class/dao/' . $clazzName . 'DAO.class.php');
    }
}