Beispiel #1
0
function evaluateAst(array $ast, array $env)
{
    $value = null;
    foreach ($ast as $sexpr) {
        $value = evaluate($sexpr, $env);
    }
    return $value;
}
 /**
  * Applies the Action to the target.
  *
  * @param SugarBean $target
  */
 function fire(&$target)
 {
     require_once 'modules/Home/quicksearchQuery.php';
     require_once 'include/QuickSearchDefaults.php';
     $json = getJSONobj();
     $userName = Parser::evaluate($this . expr, $target) . evaluate();
     $qsd = QuickSearchDefaults::getQuickSearchDefaults();
     $data = $qsd->getQSUser();
     $data['modules'] = array("Users");
     $data['conditions'][0]['value'] = $userName;
     $qs = new quicksearchQuery();
     $result = $qs->query($data);
     $resultBean = $json->decodeReal($result);
     print_r($resultBean);
 }
Beispiel #3
0
function evaluate($my_jfile)
{
    foreach ($my_jfile as $p => $value) {
        if (is_array($value) && sizeof($value) > 1) {
            // check if the value of the element is of type children that is an array and if it is an empty or not array
            for ($i = 0; $i < sizeof($value); $i++) {
                // for each child call the same function
                evaluate($my_jfile->children[$i]);
            }
        } else {
            if ($p == "type" && $value == "Manual") {
                // if the type of the child that has not more children unchecked is manual then print it
                echo $my_jfile->node_id . "\n";
            }
        }
    }
}
Beispiel #4
0
function evaluate($expression)
{
    $result = $workingNum = $bracketNum = 0;
    $prevOp = "";
    $expArr = str_split($expression);
    $result = $expArr[0];
    for ($cnt = 0; $cnt < count($expArr); $cnt++) {
        if ($expArr[$cnt] == "+") {
            $prevOp = "+";
        } elseif ($expArr[$cnt] == "-") {
            $prevOp = "-";
        } elseif ($expArr[$cnt] == "(") {
            for ($brCnt = $cnt; $brCnt < count($expArr); $brCnt++) {
                if ($expArr[$brCnt] == ")") {
                    $inExp = "";
                    for ($inCnt = $cnt + 1; $inCnt < $brCnt; $inCnt++) {
                        $inExp = $inExp . $expArr[$inCnt];
                    }
                    $bracketNum = evaluate($inExp);
                    if ($prevOp == "+") {
                        $result = $result + $bracketNum;
                    } elseif ($prevOp == "-") {
                        $result = $result - $bracketNum;
                    }
                    $cnt = $brCnt + 1;
                    break;
                }
            }
            if ($expArr[$cnt] == "+") {
                $prevOp = "+";
            } elseif ($expArr[$cnt] == "-") {
                $prevOp = "-";
            }
        } else {
            $workingNum = $expArr[$cnt];
            if ($prevOp == "+") {
                $result = $result + $workingNum;
            } elseif ($prevOp == "-") {
                $result = $result - $workingNum;
            }
        }
    }
    return $result;
}
Beispiel #5
0
    // the rest
    if ($inPart == true) {
        if ($includePart == false) {
            continue;
        }
        if (preg_match("/(\\s\t)*&([a-z0-9\\.-]+);/", $line, $matches)) {
            if ($sections) {
                echo "Including " . $matches[2] . "? ";
                if ($include = inString($sections, $matches[2])) {
                    echo "YES\n";
                } else {
                    echo "NO\n";
                }
            } else {
                if ($hasReadline) {
                    $include = evaluate(readline("Include " . $matches[2] . "? [NO] "));
                }
            }
            if ($include == true) {
                $partStack[] = $line;
            }
        }
    } else {
        $newFile .= $line;
    }
}
file_put_contents("manual.xml.in", $newFile);
// {{{ Run the build scripts
$cmd = "make " . $format;
passthru($cmd);
// }}}
Beispiel #6
0
function checkStatus($pp_kod)
{
    $query = "SELECT pp_rs_kod,pp_rs_kod_lab,pp_status_nopayment FROM p_product\n            WHERE pp_kod='{$pp_kod}'";
    $result = selQuery($query);
    $row = mysqli_fetch_assoc($result);
    $main = $row['pp_rs_kod'];
    $lab = $row['pp_rs_kod_lab'];
    $payment = $row['pp_status_nopayment'];
    if ($main == 1105) {
        if ($lab == 9002) {
            return "APPROVED : WAITING FOR PRODUCT/API";
        } else {
            return "REJECTED : WAITING FOR PRODUCT/API";
        }
    } else {
        if ($payment == 1) {
            return "PENDING PAYMENT";
        } else {
            if ($lab == 402) {
                if (evaluate($pp_kod, $_SESSION['ru_kod']) == 0) {
                    return "APPLICATION IN LAB";
                } else {
                    return "APPLICATION IN EVALUATOR TRAY";
                }
            } else {
                return "APPROVED PAYMENT";
            }
        }
    }
}
Beispiel #7
0
echo $_POST["sub_equation"];
?>
" />
			<input type="submit" name="sub_button" value="Solve it!" />
		</form>
		<br />

<?php 
if ($_POST["sub_equation"]) {
    ?>
  			<b>The answer is:</b><br />
			<?php 
    echo $_POST["sub_equation"];
    ?>
 = <b><?php 
    echo evaluate($_POST["sub_equation"]);
    ?>
</b>
<?php 
}
?>

		<script type="text/javascript">
			var eqElement = document.getElementById('equInput');
			
			eqElement.focus();
			eqElement.value = eqElement.value;
		</script>
  	</body>
</html>
Beispiel #8
0
 public function do_eval($source)
 {
     $fmt_source = "(begin {$source} )";
     $tokens = scm_tokenize($fmt_source);
     $this->_rnode = STParse($tokens);
     $this->_scope = new STScope(null);
     return evaluate($this->_rnode, $this->_scope);
 }
Beispiel #9
0
function tpl($path, $data = array())
{
    $path = "src/view/{$path}.html";
    if (file_exists($path)) {
        $c = file_get_contents($path);
        $c = preg_replace_callback('/\\{\\{\\s*(.+?)\\s*\\}\\}/', function ($m) {
            return '<?php echo LANG(\'' . addslashes($m[1]) . '\');?>';
        }, $c);
        $c = preg_replace_callback('/\\<%([\\-\\=])\\s*(.+?)%\\s*\\>/s', function ($m) {
            $c = $m[2];
            if ($c[0] == '$') {
                $c = "isset({$c})?{$c}:''";
            }
            if ($m[1] == '-') {
                $c = 'htmlentities(' . $c . ')';
            }
            return '<?php echo ' . $c . ';?>';
        }, $c);
        $c = preg_replace('/\\<%(.+?)%\\>/s', '<?php $1; ?>', $c);
        $eval = '';
        if (is_array($data)) {
            foreach (array_keys($data) as $____) {
                $eval .= '$' . $____ . '=' . '$ROOT[\'' . $____ . '\'];';
            }
        }
        $eval .= '?>' . $c;
        ob_start();
        evaluate($eval, $data);
        $ret = ob_get_contents();
        ob_end_clean();
        return $ret;
    } else {
        return " ERROR: {$path} not found ";
    }
}
Beispiel #10
0
 public static function evaluateExpression($_input)
 {
     try {
         $_input = scenarioExpression::setTags($_input);
         $result = evaluate($_input);
         if (is_bool($result) || is_numeric($result)) {
             return $result;
         }
         return $_input;
     } catch (Exception $exc) {
         return $_input;
     }
 }
Beispiel #11
0
<?php

session_start();
/**
 * content
 * transaction_id
 * score1
 * score2
 * score3 
 */
//$_SESSION['CURRENT_LOGIN_ID'] = 1;
if (isset($_SESSION['CURRENT_LOGIN_ID'])) {
    evaluate();
} else {
    include 'Login.php';
}
function evaluate()
{
    require_once 'class/Injection.php';
    require_once 'class/Config_evaluation.php';
    require_once 'class/DBtraverser.php';
    require_once 'class/Config.php';
    require_once 'class/Config_transaction.php';
    include 'smarty_init.php';
    $content = '';
    //    $content = Injection::excute('content');  //评价内容
    $transaction_id = (int) $_REQUEST['transaction_id'];
    //评价交易单
    $evaluater_id = $_SESSION['CURRENT_LOGIN_ID'];
    //评价人ID
    $score1 = $_REQUEST['score1'];
Beispiel #12
0
 public static function getHistoryFromCalcul($_strcalcul, $_dateStart = null, $_dateEnd = null, $_allowZero = true)
 {
     $now = strtotime('now');
     $archiveTime = (config::byKey('historyArchiveTime') + 1) * 3600;
     $packetTime = config::byKey('historyArchivePackage') * 3600;
     $value = array();
     $cmd_histories = array();
     preg_match_all("/#([0-9]*)#/", $_strcalcul, $matches);
     if (count($matches[1]) > 0) {
         foreach ($matches[1] as $cmd_id) {
             if (is_numeric($cmd_id)) {
                 $cmd = cmd::byId($cmd_id);
                 if (is_object($cmd) && $cmd->getIsHistorized() == 1) {
                     $prevDatetime = null;
                     $prevValue = 0;
                     $histories_cmd = $cmd->getHistory($_dateStart, $_dateEnd);
                     $histories_cmd_count = count($histories_cmd);
                     for ($i = 0; $i < $histories_cmd_count; $i++) {
                         if (!isset($cmd_histories[$histories_cmd[$i]->getDatetime()])) {
                             $cmd_histories[$histories_cmd[$i]->getDatetime()] = array();
                         }
                         if (!isset($cmd_histories[$histories_cmd[$i]->getDatetime()]['#' . $cmd_id . '#'])) {
                             if ($prevDatetime != null) {
                                 $datetime = strtotime($histories_cmd[$i]->getDatetime());
                                 while ($now - strtotime($prevDatetime) > $archiveTime && strtotime($prevDatetime) < $datetime) {
                                     $prevDatetime = date('Y-m-d H:00:00', strtotime($prevDatetime) + $packetTime);
                                     if ($_allowZero) {
                                         $cmd_histories[$prevDatetime]['#' . $cmd_id . '#'] = 0;
                                     } else {
                                         $cmd_histories[$prevDatetime]['#' . $cmd_id . '#'] = $prevValue;
                                     }
                                 }
                                 while ($now - strtotime($prevDatetime) > 300 && strtotime($prevDatetime) < $datetime) {
                                     $prevDatetime = date('Y-m-d H:i:00', strtotime($prevDatetime) + 300);
                                     $cmd_histories[$prevDatetime]['#' . $cmd_id . '#'] = $prevValue;
                                 }
                             }
                             $cmd_histories[$histories_cmd[$i]->getDatetime()]['#' . $cmd_id . '#'] = $histories_cmd[$i]->getValue();
                         }
                         $prevDatetime = $histories_cmd[$i]->getDatetime();
                         $prevValue = $histories_cmd[$i]->getValue();
                     }
                 }
             }
         }
         foreach ($cmd_histories as $datetime => $cmd_history) {
             $datetime = floatval(strtotime($datetime . " UTC"));
             $calcul = template_replace($cmd_history, $_strcalcul);
             try {
                 $result = floatval(evaluate($calcul));
                 $value[$datetime] = $result;
             } catch (Exception $e) {
             }
         }
     } else {
         $value = $_strcalcul;
     }
     if (is_array($value)) {
         ksort($value);
     }
     return $value;
 }
Beispiel #13
0
                $c = "</sup> ";
            }
        }
        if ($c == "^") {
            $c = "<sup>";
            $mode = "power";
        } elseif ($c == " ") {
            $c = "";
        }
        $res .= $c;
    }
    return $res;
}
if (isset($_POST['answer'])) {
    $index = $_POST['index'] * 1;
    $correct = evaluate($question[$index], $_POST['answer']);
} else {
    mt_srand();
    $index = mt_rand(1, count($question) - 1);
}
$seed = 7;
mt_srand($seed);
srand($seed);
?>
<html>
<head>
<script src="jquery-1.11.1.min.js"></script>
<title>Math Quiz</title>
<link rel="stylesheet" href='style.css'></link>
</head>
<body>
Beispiel #14
0
function compile($code, $delimiter, $app)
{
    global $mycode;
    global $output;
    global $int;
    global $intval;
    global $arr;
    global $sourcecode;
    global $ifdone;
    global $ifpresent;
    global $uservardone;
    $output = "";
    $mytokens = array("लिखो", "पूर्ण", "=", "निवेश", "\$", "अगर", "वरना", "जबतक");
    $mynums = array("१", "२", "३", "४", "५", "६", "७", "८", "९", "०");
    $mycode = $code;
    if (strcmp($app, "whole") == 0) {
        $sourcecode = $code;
    }
    $temp = explode($delimiter, $mycode);
    foreach ($temp as $value) {
        foreach ($mytokens as $token) {
            if (strstr($value, $token)) {
                switch ($token) {
                    case "लिखो":
                        //to print output
                        // $flag=0;
                        $pos = stripos($value, "लिखो");
                        if ($pos == 2 || $pos == 0) {
                            $pos = $pos + strlen("लिखो");
                            $output = substr($value, $pos);
                            //output shown as shown in echo
                            //                                $tempoutput=stripslashes(substr($value,$pos));
                            $i = 0;
                            if (strstr($value, "\$")) {
                                //                                        echo "idhar $value<br/>";
                                $output = evaluate($output);
                            }
                            $output = hindiDig($output);
                            echo <<<_END
                                            <script type="text/javascript">
                                                \$(function(){
                                                \$(".code-output-area").append("{$output}<br/>");
                                                })
                                             </script>
_END;
                        }
                        break;
                    case "पूर्ण":
                        //variable declaration
                        if (!strstr($value, "=") && strpos($value, "पूर्ण") >= 0) {
                            $pos = stripos($value, "पूर्ण");
                            $pos = $pos + strlen("पूर्ण");
                            $int[$arr] = substr($value, $pos);
                            $intval[$arr] = 0;
                            //                                    echo "New variable declared $int[$arr] with no value<br/>";
                            $arr++;
                        }
                        break;
                    case "=":
                        if (!(strstr($value, "अगर") || strstr($value, "जबतक") || strstr($value, "वरना"))) {
                            $flag = 0;
                            $i = 0;
                            $delimiteq = explode("=", $value);
                            //delimiting equalto sign
                            //                                    echo $delimiteq[0]." ".$delimiteq[1]."<br/>";
                            if (strstr($delimiteq[1], "\$")) {
                                $delimiteq[1] = evaluate($delimiteq[1]);
                            }
                            if (strstr($delimiteq[0], "पूर्ण")) {
                                $delimitpoorn = explode("पूर्ण", $delimiteq[0]);
                                //delimiting पूर्ण
                                foreach ($int as $variables) {
                                    if ($delimitpoorn[1] == $variables) {
                                        $flag = 1;
                                    }
                                }
                                if ($flag == 1) {
                                    echo "Variable already declared<br/>";
                                } else {
                                    //new declaration
                                    $int[$arr] = $delimitpoorn[1];
                                    if (strlen($delimiteq[1]) > 0) {
                                        $intval[$arr] = $delimiteq[1];
                                        //                                            echo "New variable declared $delimitpoorn[1] with value $delimiteq[1]<br/>";
                                    } else {
                                        $intval[$arr] = 0;
                                        //                                                echo "New variable declared $delimitpoorn[1] with no value <br/>";
                                    }
                                    $arr++;
                                    //
                                }
                            } else {
                                $i = 0;
                                $flag = 0;
                                foreach ($int as $variables) {
                                    //                                            echo "$delimiteq[0]<br/>";
                                    //                                            echo "$variables<br/>";
                                    if (strnatcmp($variables, $delimiteq[0]) == 0) {
                                        $intval[$i] = $delimiteq[1];
                                        $flag = 1;
                                        break;
                                    }
                                    $i++;
                                }
                                if ($flag == 1) {
                                } else {
                                    echo "variable {$delimiteq['0']} not declared. Please declare<br/>";
                                }
                            }
                        }
                        break;
                    case "निवेश":
                        $flag = 0;
                        $pos = stripos($value, "निवेश");
                        $pos = $pos + strlen("निवेश");
                        $input = substr($value, $pos);
                        //                                    echo "inputting into $input<br/>";
                        foreach ($int as $variables) {
                            if ($input == $variables) {
                                $flag = 1;
                            }
                        }
                        $input = trim($input);
                        if ($flag == 0) {
                            echo "variable {$input} not declared<br/>";
                        } elseif (!isset($_POST[$input])) {
                            echo <<<_END
                                        <script type="text/javascript">
                                            \$(function(){
                                            \$(".code-output-area").append("<input class='variables' id='{$input}' type='text' name='{$input}'/><br/>");
                                            })
                                         </script>
_END;
                        }
                        break;
                    case "अगर":
                        $pos = stripos($value, "अगर");
                        $pos = $pos + strlen("अगर");
                        $exp = substr($value, $pos);
                        //                                        echo "Executing if statement $exp <br/>";
                        $end = strpos($value, "{");
                        $beg = $pos;
                        $ifcondition = substr($value, $beg, $end - $beg);
                        //                                        echo "now if condition is $ifcondition<br/>";
                        $ifcondition = evaluate($ifcondition);
                        //returns 1 if true, else null
                        $ifcondition = evalExp($ifcondition);
                        //returns 1 if true, else null
                        $ifpresent = 1;
                        //                                        echo "now again if condition is $ifcondition<br/>";
                        if ($ifcondition == 1) {
                            $beg = strpos($value, "{") + strlen("{");
                            $end = strpos($value, "}");
                            $ifblock = substr($value, $beg, $end - $beg);
                            //                                            echo "if block contains $ifblock<br/>";
                            compile($ifblock, ":", "thread");
                            $ifdone = 1;
                        }
                        break;
                    case "वरना":
                        if ($ifdone == 0 && $ifpresent == 1) {
                            $beg = strpos($value, "{") + strlen("{");
                            $end = strpos($value, "}");
                            $elseblock = substr($value, $beg, $end - $beg);
                            //                                            echo "else block contains $elseblock<br/>";
                            compile($elseblock, ":", "thread");
                            $ifpresent = 0;
                            $ifdone = 0;
                        } else {
                            echo "no if statement defined<br/>";
                        }
                        break;
                    case "जबतक":
                        looping($value);
                        break;
                        //
                }
            }
        }
        $count = count($_POST);
        $count--;
        //to eliminate $mycode from the counting list
        foreach ($_POST as $key => $inputs) {
            if (strcmp($inputs, $mycode) != 0 && $count != 0) {
                //                        echo "$inputs into $key<br/>";
                $e = 0;
                foreach ($int as $varname) {
                    //           echo "going thru variable $varname and input variable $key<br/>";
                    if (strnatcmp($varname, $key) == 0) {
                        $uservardone = 1;
                        $intval[$e] = engDig($inputs);
                        //             echo "updating value of variable $varname with user input $inputs<br/>";
                    }
                    $e++;
                }
                $count--;
            }
        }
    }
    //            $g=0;
    //                echo "all variables with their values<br/>";
    //            foreach($int as $variables)
    //            {
    //                echo "$variables has value $intval[$g]<br/>";
    //                $g++;
    //            }
}
Beispiel #15
0
}
header('Content-Type: application/json');
$user = new User();
$item = new Item();
$ui = new UserItem();
$max_participations = 1;
switch (@$_POST['method']) {
    case 'save_user':
        $name = $_POST['nombre'];
        $lastname = $_POST['apellido'];
        $mail = $_POST['mail'];
        $phone = $_POST['telefono'];
        evaluate($name, 'nombre');
        evaluate($lastname, 'apellido');
        evaluate($mail, 'correo', 'isEmail');
        evaluate($phone, 'teléfono', 'isPhone');
        $id = $user->exist($mail);
        if (!$id) {
            $id = $user->create($name, $lastname, $mail, $phone);
        }
        if ($ui->num_of_participations($id) >= $max_participations) {
            fail("Has llegado al límite de participaciones por usuario, gracias por tu interés");
        }
        $_SESSION['id'] = base64_encode($id);
        response($id);
        break;
    case 'play':
        $id = base64_decode($_SESSION['id']);
        if ($ui->num_of_participations($id) >= $max_participations) {
            fail("Has llegado al límite de participaciones por usuario, gracias por tu interés");
        }
Beispiel #16
0
 public function formatValue($_value, $_quote = false)
 {
     if (trim($_value) == '' && $_value !== false && $_value !== 0) {
         return '';
     }
     $_value = trim(trim($_value), '"');
     if (@strpos(strtolower($_value), 'error::') !== false) {
         return $_value;
     }
     if ($this->getType() == 'info') {
         switch ($this->getSubType()) {
             case 'string':
                 if ($_quote) {
                     return '"' . $_value . '"';
                 }
                 return $_value;
             case 'other':
                 if ($_quote) {
                     return '"' . $_value . '"';
                 }
                 return $_value;
             case 'binary':
                 if ($this->getConfiguration('calculValueOffset') != '') {
                     try {
                         $_value = evaluate(str_replace('#value#', $_value, $this->getConfiguration('calculValueOffset')));
                     } catch (Exception $ex) {
                     }
                 }
                 $value = strtolower($_value);
                 if ($value == 'on' || $value == 'high' || $value == 'true' || $value === true) {
                     return 1;
                 }
                 if ($value == 'off' || $value == 'low' || $value == 'false' || $value === false) {
                     return 0;
                 }
                 if (is_numeric(intval($_value)) && intval($_value) > 1 || $_value === true || $_value == 1) {
                     return 1;
                 }
                 return 0;
             case 'numeric':
                 $_value = floatval(str_replace(',', '.', $_value));
                 if ($this->getConfiguration('calculValueOffset') != '') {
                     try {
                         $_value = evaluate(str_replace('#value#', $_value, $this->getConfiguration('calculValueOffset')));
                     } catch (Exception $ex) {
                     }
                 }
                 if ($this->getConfiguration('historizeRound') !== '' && is_numeric($this->getConfiguration('historizeRound')) && $this->getConfiguration('historizeRound') >= 0) {
                     $_value = round($_value, $this->getConfiguration('historizeRound'));
                 }
                 if ($_value > $this->getConfiguration('maxValue', $_value) && $this->getConfiguration('maxValueReplace') == 1) {
                     $_value = $this->getConfiguration('maxValue', $_value);
                 }
                 if ($_value < $this->getConfiguration('minValue', $_value) && $this->getConfiguration('minValueReplace') == 1) {
                     $_value = $this->getConfiguration('minValue', $_value);
                 }
                 return floatval($_value);
         }
     }
     return $_value;
 }
Beispiel #17
0
<?php

/**
 * A very simple executable script to train and use the LanguageDetector
 * class. For now it will not use a more complex (and better) structure like
 * Symfony\Console\Application but it will be a self contained little script.
 */
include "vendor/autoload.php";
try {
    $command = isset($_POST['command']) ? $_POST['command'] : "";
    switch ($command) {
        case "train":
            train($argv);
            break;
        case "evaluate":
            evaluate($argv);
            break;
        case "classify":
            classify($argv);
            break;
        case "help":
        default:
            help();
            break;
    }
} catch (Exception $e) {
    echo PHP_EOL, $e->getMessage(), PHP_EOL, PHP_EOL;
}
/**
 * Just echo a simple help message
 */
 public function execute(&$scenario = null)
 {
     if ($this->getOptions('enable', 1) == 0) {
         return;
     }
     $message = '';
     try {
         if ($this->getType() == 'element') {
             $element = scenarioElement::byId($this->getExpression());
             if (is_object($element)) {
                 $this->setLog($scenario, __('Exécution d\'un bloc élément : ', __FILE__) . $this->getExpression());
                 return $element->execute($scenario);
             }
             return;
         }
         $options = $this->getOptions();
         if (isset($options['enable'])) {
             unset($options['enable']);
         }
         if (is_array($options) && $this->getExpression() != 'wait') {
             foreach ($options as $key => $value) {
                 $options[$key] = str_replace('"', '', self::setTags($value, $scenario));
             }
         }
         if ($this->getType() == 'action') {
             if ($this->getExpression() == 'icon') {
                 if ($scenario != null) {
                     $options = $this->getOptions();
                     $this->setLog($scenario, __('Changement de l\'icone du scénario : ', __FILE__) . $options['icon']);
                     $scenario->setDisplay('icon', $options['icon']);
                     $scenario->save();
                 }
                 return;
             } else {
                 if ($this->getExpression() == 'wait') {
                     if (!isset($options['condition'])) {
                         return;
                     }
                     $result = false;
                     $occurence = 0;
                     $limit = isset($options['timeout']) && is_numeric($options['timeout']) ? $options['timeout'] : 7200;
                     while ($result !== true) {
                         $expression = self::setTags($options['condition'], $scenario);
                         $result = evaluate($expression);
                         if ($occurence > $limit) {
                             $this->setLog($scenario, __('[Wait] Condition valide par dépassement de temps', __FILE__));
                             return;
                         }
                         $occurence++;
                         sleep(1);
                     }
                     $this->setLog($scenario, __('[Wait] Condition valide : ', __FILE__) . $expression);
                     return;
                 } else {
                     if ($this->getExpression() == 'sleep') {
                         if (isset($options['duration'])) {
                             try {
                                 $options['duration'] = evaluate($options['duration']);
                             } catch (Exception $e) {
                             }
                             if (is_numeric($options['duration']) && $options['duration'] > 0) {
                                 $this->setLog($scenario, __('Pause de ', __FILE__) . $options['duration'] . __(' seconde(s)', __FILE__));
                                 if ($options['duration'] < 1) {
                                     return usleep($options['duration'] * 1000);
                                 } else {
                                     return sleep($options['duration']);
                                 }
                             }
                         }
                         $this->setLog($scenario, __('Aucune durée trouvée pour l\'action sleep ou la durée n\'est pas valide : ', __FILE__) . $options['duration']);
                         return;
                     } else {
                         if ($this->getExpression() == 'stop') {
                             if ($scenario != null) {
                                 $this->setLog($scenario, __('Arret du scénario', __FILE__));
                                 $scenario->setState('stop');
                                 $scenario->setPID('');
                                 $scenario->persistLog();
                                 $scenario->save();
                             }
                             die;
                         } else {
                             if ($this->getExpression() == 'log') {
                                 if ($scenario != null) {
                                     $scenario->setLog('Log : ' . $options['message']);
                                     if ($scenario->getConfiguration('speedPriority', 0) == 1) {
                                         $scenario->persistLog();
                                     }
                                 }
                                 return;
                             } else {
                                 if ($this->getExpression() == 'message') {
                                     message::add('scenario', $options['message']);
                                     return;
                                 } else {
                                     if ($this->getExpression() == 'equipement') {
                                         $eqLogic = eqLogic::byId(str_replace(array('#eqLogic', '#'), '', $this->getOptions('eqLogic')));
                                         if (!is_object($eqLogic)) {
                                             throw new Exception(__('Action sur l\'équipement impossible. Equipement introuvable - Vérifiez l\'id : ', __FILE__) . $this->getOptions('eqLogic'));
                                         }
                                         switch ($this->getOptions('action')) {
                                             case 'show':
                                                 $this->setLog($scenario, __('Equipement visible : ', __FILE__) . $eqLogic->getHumanName());
                                                 $eqLogic->setIsVisible(1);
                                                 $eqLogic->save();
                                                 break;
                                             case 'hide':
                                                 $this->setLog($scenario, __('Equipement masqué : ', __FILE__) . $eqLogic->getHumanName());
                                                 $eqLogic->setIsVisible(0);
                                                 $eqLogic->save();
                                                 break;
                                             case 'deactivate':
                                                 $this->setLog($scenario, __('Equipement désactivé : ', __FILE__) . $eqLogic->getHumanName());
                                                 $eqLogic->setIsEnable(0);
                                                 $eqLogic->save();
                                                 break;
                                             case 'activate':
                                                 $this->setLog($scenario, __('Equipement activé : ', __FILE__) . $eqLogic->getHumanName());
                                                 $eqLogic->setIsEnable(1);
                                                 $eqLogic->save();
                                                 break;
                                         }
                                         return;
                                     } else {
                                         if ($this->getExpression() == 'say') {
                                             $this->setLog($scenario, __('Je dis : ', __FILE__) . $options['message']);
                                             nodejs::pushUpdate('jeedom::say', $options['message']);
                                             return;
                                         } else {
                                             if ($this->getExpression() == 'gotodesign') {
                                                 $this->setLog($scenario, __('Changement design : ', __FILE__) . $options['plan_id']);
                                                 nodejs::pushUpdate('jeedom::gotoplan', $options['plan_id']);
                                                 return;
                                             } else {
                                                 if ($this->getExpression() == 'return') {
                                                     $this->setLog($scenario, __('Je vais retourner : ', __FILE__) . $options['message']);
                                                     $scenario->setReturn($scenario->getReturn() . $options['message']);
                                                     return;
                                                 } else {
                                                     if ($this->getExpression() == 'scenario') {
                                                         if ($scenario != null && $this->getOptions('scenario_id') == $scenario->getId()) {
                                                             $actionScenario =& $scenario;
                                                         } else {
                                                             $actionScenario = scenario::byId($this->getOptions('scenario_id'));
                                                         }
                                                         if (!is_object($actionScenario)) {
                                                             throw new Exception($scenario, __('Action sur scénario impossible. Scénario introuvable - Vérifiez l\'id : ', __FILE__) . $this->getOptions('scenario_id'));
                                                         }
                                                         switch ($this->getOptions('action')) {
                                                             case 'start':
                                                                 $this->setLog($scenario, __('Lancement du scénario : ', __FILE__) . $actionScenario->getName());
                                                                 if ($scenario != null) {
                                                                     $actionScenario->launch(false, __('Lancement provoqué par le scénario  : ', __FILE__) . $scenario->getHumanName());
                                                                 } else {
                                                                     $actionScenario->launch(false, __('Lancement provoqué', __FILE__));
                                                                 }
                                                                 break;
                                                             case 'stop':
                                                                 $this->setLog($scenario, __('Arrêt forcé du scénario : ', __FILE__) . $actionScenario->getName());
                                                                 $actionScenario->stop();
                                                                 break;
                                                             case 'deactivate':
                                                                 $this->setLog($scenario, __('Désactivation du scénario : ', __FILE__) . $actionScenario->getName());
                                                                 $actionScenario->setIsActive(0);
                                                                 $actionScenario->save();
                                                                 break;
                                                             case 'activate':
                                                                 $this->setLog($scenario, __('Activation du scénario : ', __FILE__) . $actionScenario->getName());
                                                                 $actionScenario->setIsActive(1);
                                                                 $actionScenario->save();
                                                                 break;
                                                         }
                                                         return;
                                                     } else {
                                                         if ($this->getExpression() == 'variable') {
                                                             $options['value'] = self::setTags($options['value']);
                                                             try {
                                                                 $result = evaluate($options['value']);
                                                                 if (!is_numeric($result)) {
                                                                     $result = $options['value'];
                                                                 }
                                                             } catch (Exception $ex) {
                                                                 $result = $options['value'];
                                                             }
                                                             $message = __('Affectation de la variable ', __FILE__) . $this->getOptions('name') . __(' => ', __FILE__) . $options['value'] . ' = ' . $result;
                                                             $this->setLog($scenario, $message);
                                                             $dataStore = new dataStore();
                                                             $dataStore->setType('scenario');
                                                             $dataStore->setKey($this->getOptions('name'));
                                                             $dataStore->setValue($result);
                                                             $dataStore->setLink_id(-1);
                                                             $dataStore->save();
                                                             return;
                                                         } else {
                                                             $cmd = cmd::byId(str_replace('#', '', $this->getExpression()));
                                                             if (is_object($cmd)) {
                                                                 if ($cmd->getSubtype() == 'slider' && isset($options['slider'])) {
                                                                     $options['slider'] = evaluate($options['slider']);
                                                                 }
                                                                 if (is_array($options) && count($options) != 0) {
                                                                     $this->setLog($scenario, __('Exécution de la commande ', __FILE__) . $cmd->getHumanName() . __(" avec comme option(s) : \n", __FILE__) . print_r($options, true));
                                                                 } else {
                                                                     $this->setLog($scenario, __('Exécution de la commande ', __FILE__) . $cmd->getHumanName());
                                                                 }
                                                                 if (is_object($scenario) && $scenario->getConfiguration('cmdNoWait', 0) == 1) {
                                                                     $options['speedAndNoErrorReport'] = true;
                                                                 }
                                                                 return $cmd->execCmd($options);
                                                             }
                                                             $this->setLog($scenario, __('[Erreur] Aucune commande trouvée pour ', __FILE__) . $this->getExpression());
                                                             return;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if ($this->getType() == 'condition') {
                 $expression = self::setTags($this->getExpression(), $scenario, true);
                 $message = __('Evaluation de la condition : [', __FILE__) . $expression . '] = ';
                 $result = evaluate($expression);
                 if (is_bool($result)) {
                     if ($result) {
                         $message .= __('Vrai', __FILE__);
                     } else {
                         $message .= __('Faux', __FILE__);
                     }
                 } else {
                     $message .= $result;
                 }
                 $this->setLog($scenario, $message);
                 return $result;
             } else {
                 if ($this->getType() == 'code') {
                     $this->setLog($scenario, __('Exécution d\'un bloc code', __FILE__));
                     return eval($this->getExpression());
                 }
             }
         }
     } catch (Exception $e) {
         $this->setLog($scenario, $message . $e->getMessage());
     }
 }
Beispiel #19
0
    echo '<Br><a href="dash.php">Continue-></a>';
    if ($myo->Update($quizid, array('marks' => $mark), array('student_id' => $studentid))) {
        print_r('Marks');
    } else {
        die('fatal');
    }
}
// evaluate($s,$id,$quizid);
// include('mathing.php');
$my = new MySQL();
$name = $_POST['title'];
unset($_POST['title']);
$i = 1;
$in = array();
// var_dump($_POST);
// print_r('expression');
foreach ($_POST as $key => $value) {
    $ss = 'col' . $i;
    $i++;
    $in[$ss] = $value;
}
evaluate($_POST, 12, 4);
// var_dump($in);
// if($my->Insert($name,$in))
// 	print_r('<p>Response Recorded!</p>');
// header("Location: dash.php");
?>


</body>
</html>