List of commits:
Subject Hash Author Date (UTC)
rg_template_eval_cond: now supports more operations 2155bedec6e82343d84c8c504c0beb68fdf01dea Catalin(ux) M. BOIE 2017-07-10 20:55:48
Minor corrections dc3ce904f00ce5903ac5614ac870a0529d22ee4a Catalin(ux) M. BOIE 2017-07-10 20:55:03
state_get: Return empty if the state table does not exists 35822bff104ba2133f29a0a69cff4603d990a721 Catalin(ux) M. BOIE 2017-07-09 19:18:11
duilder: add 'samples' dir to the docs 8762f7dbfcec1f3ed5d6d7ba7dbf0ed547a894b7 Catalin(ux) M. BOIE 2017-07-09 06:54:06
Bump version to 0.70 a3524c87b21d22d734626503683e80e51abd574c Catalin(ux) M. BOIE 2017-07-09 06:40:24
Added nginx next to apache 982e6536f5204a07c939b01229784a46c18cdada Catalin(ux) M. BOIE 2017-07-09 06:38:55
rg_exec: when stdout closes, we should not try to get input anymore from the external program b550d45c19c48235eddbd5b6fdcadcec2689065b Catalin(ux) M. BOIE 2017-07-09 06:38:32
Small corrections 68c2120f6bb1cd04e3c35b18fee8c2ce89c525bb Catalin(ux) M. BOIE 2017-07-09 06:36:59
tests: deal with the case when ControlMaster is not 'no' 7fc439c93b2e9df218292d20fbe50606d770955f Catalin(ux) M. BOIE 2017-07-09 06:35:36
Do not use http_host anymore af14b07381106cbc015aa6620d587b7e64ce7ed5 Catalin(ux) M. BOIE 2017-07-09 06:34:32
ssh_host and git_host must not depend on http host 4677add26d7c03541cdd412d9fdc420ec79867b2 Catalin(ux) M. BOIE 2017-07-09 06:31:52
TODO: some updates 5b264972f3127c9fcceab83014598957d4dd38b1 Catalin(ux) M. BOIE 2017-07-09 06:30:32
duilder: add also samples directory e5c3dc7c1dc5db3062705838082d96e0579e42db Catalin(ux) M. BOIE 2017-07-09 06:29:34
More debugging added to webhooks 87d72dd3b50917b04e072d95ca22a0d639853701 Catalin(ux) M. BOIE 2017-07-09 06:28:38
Anonymize also admin init parameters 18786c9c9c1329e08f07120aa8a8d93a9630989b Catalin(ux) M. BOIE 2017-07-06 18:37:28
Activate the caching also for HTTP/2.0 063b7e36532874272048f1d193176499e834b0a0 Catalin(ux) M. BOIE 2017-07-06 18:24:34
Improve host name auto-detection problems to work in VM env b56dd82ac1db3ca2cc4478af65b27909f05dd228 Catalin(ux) M. BOIE 2017-07-06 17:58:10
compare: added number of lines c847d9da61749de86ffa0199f26cd68f4b80cc3a Catalin(ux) M. BOIE 2017-07-06 17:53:57
Added a make target to compute the number of lines 8695380c12480b1b7b8bc9c5f1ec63a115742d9f Catalin(ux) M. BOIE 2017-07-06 17:53:16
tests: fixed wh_http - time race closed 8f182423103c8fc2a4be10840b08be0564e2c814 Catalin(ux) M. BOIE 2017-07-02 07:01:12
Commit 2155bedec6e82343d84c8c504c0beb68fdf01dea - rg_template_eval_cond: now supports more operations
Author: Catalin(ux) M. BOIE
Author date (UTC): 2017-07-10 20:55
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2017-07-10 20:55
Parent(s): dc3ce904f00ce5903ac5614ac870a0529d22ee4a
Signing key:
Tree: ae07486a92f1ff9ce876db6660167be8ea0c26cd
File Lines added Lines deleted
inc/util.inc.php 38 25
tests/util.php 29 0
File inc/util.inc.php changed (mode: 100644) (index 8177480..41d439d)
... ... function rg_template_tree_lookup($var, &$data, $xss_protection)
576 576
577 577 /* /*
578 578 * Evaluates a condition * Evaluates a condition
579 * Returns FALSE on error, 0 for TRUE and 1 for FALSE
579 580 */ */
580 581 function rg_template_eval_cond($cond, &$data) function rg_template_eval_cond($cond, &$data)
581 582 { {
582 $t = explode('!=', $cond);
583 if (count($t) == 2) {
584 $negate = TRUE;
585 } else {
586 $t = explode('==', $cond);
587 if (count($t) != 2) {
588 rg_log("invalid condition [$cond]!");
589 return FALSE;
590 }
591 $negate = FALSE;
583 while (strpos($cond, ' '))
584 $cond = str_replace(' ', ' ', $cond);
585
586 $t = explode(' ', $cond);
587 if (count($t) != 3) {
588 rg_util_set_error('invalid condition: ' . $cond
589 . ' (not 3 tokens)');
590 return FALSE;
592 591 } }
593 592
594 $left = trim($t[0]);
595 $left = rg_template_string($left, 0, $data, FALSE);
593 $left = rg_template_string($t[0], 0, $data, FALSE);
594 $op = $t[1];
595 $right = rg_template_string($t[2], 0, $data, FALSE);
596 596
597 $right = trim($t[1]);
598 $right = rg_template_string($right, 0, $data, FALSE);
597 if (strcmp($op, '==') == 0)
598 return strcmp($left, $right) == 0 ? 1 : 0;
599 599
600 $ret = strcmp($left, $right);
601 if ($ret === 0) {
602 if ($negate === TRUE)
603 return FALSE;
604 } else {
605 if (!$negate)
606 return FALSE;
607 }
600 if (strcmp($op, '!=') == 0)
601 return strcmp($left, $right) != 0 ? 1 : 0;
608 602
609 return TRUE;
603 $ileft = intval($left);
604 $iright = intval($right);
605
606 if (strcmp($op, '>=') == 0)
607 return $ileft >= $iright ? 1 : 0;
608
609 if (strcmp($op, '>') == 0)
610 return $ileft > $iright ? 1 : 0;
611
612 if (strcmp($op, '<=') == 0)
613 return $ileft <= $iright ? 1 : 0;
614
615 if (strcmp($op, '<') == 0)
616 return $ileft < $iright ? 1 : 0;
617
618 rg_util_set_error('unknown condition: ' . $cond);
619 return FALSE;
610 620 } }
611 621
612 622 /* /*
 
... ... function rg_template_string_if(&$s, $off, &$data, &$next, $xss_protection)
717 727
718 728 $cond = substr($s, $off, $pos - $off); $off = $pos + 1; $cond = substr($s, $off, $pos - $off); $off = $pos + 1;
719 729 $eval_cond = rg_template_eval_cond($cond, $data); $eval_cond = rg_template_eval_cond($cond, $data);
720 //rg_log("DEBUG: cond=[$cond] eval_cond=" . ($eval_cond ? "true" : "false"));
730 if ($eval_cond === FALSE) {
731 rg_prof_end('template_string_if');
732 return -1;
733 }
721 734
722 735 // TODO: Between ')' and '{{' must be only space, else ignore anything?? // TODO: Between ')' and '{{' must be only space, else ignore anything??
723 736
 
... ... function rg_template_string_if(&$s, $off, &$data, &$next, $xss_protection)
731 744 } }
732 745
733 746 $x = ''; $x = '';
734 if ($eval_cond === TRUE) {
747 if ($eval_cond === 1) {
735 748 $x = substr($s, $true_start, $true_end - $true_start + 1); $x = substr($s, $true_start, $true_end - $true_start + 1);
736 749 } else { } else {
737 750 if ($false_start != -1) if ($false_start != -1)
File tests/util.php changed (mode: 100644) (index 1a22a8c..4a7cdec)
... ... $rg_no_db = TRUE;
14 14 require_once("common.php"); require_once("common.php");
15 15
16 16
17 rg_log('');
18 rg_log_enter('Testing rg_template_eval_cond');
19
20 $a = array('a' => 100, 'b' => 200);
21
22 $cond = '1 >= 100';
23 $r = rg_template_eval_cond($cond, $a);
24 if (($r === FALSE) || ($r === 1)) {
25 rg_log('Error for ' . $cond . '!');
26 exit(1);
27 }
28
29 $cond = '@@a@@ == 100';
30 $r = rg_template_eval_cond($cond, $a);
31 if (($r === FALSE) || ($r === 0)) {
32 rg_log('Error for ' . $cond . '!');
33 exit(1);
34 }
35
36 $cond = '-100 != -100';
37 $r = rg_template_eval_cond($cond, $a);
38 if (($r === FALSE) || ($r === 1)) {
39 rg_log('Error for ' . $cond . '!');
40 exit(1);
41 }
42
43 rg_log_exit();
44
45
17 46 rg_log("Testing template_tree_lookup1"); rg_log("Testing template_tree_lookup1");
18 47 $var = 'a::b'; $var = 'a::b';
19 48 $e = '<'; $e = '<';
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main