File TODO changed (mode: 100644) (index 7356512..53d1017) |
1 |
1 |
== BEFORE FIRST RELEASE! == |
== BEFORE FIRST RELEASE! == |
2 |
|
[ ] rg_bug_search should be rg_bug_get/load and rg_bug_search to search using |
|
3 |
|
labels/start/end/etc. |
|
|
2 |
|
[ ] Fix @@if problems by parsing template line-by-line with a stack. |
4 |
3 |
[ ] bug_update does not update labels! |
[ ] bug_update does not update labels! |
5 |
4 |
[ ] Integrate remote_add.html. |
[ ] Integrate remote_add.html. |
6 |
|
[ ] If you are not logged in, do not show the save option! |
|
7 |
|
[ ] ml.php in /root/PHP |
|
8 |
|
[ ] Should we expire the reset password token? Why? Somebody can request another |
|
9 |
|
one! |
|
|
5 |
|
[ ] Should we expire the reset password token? Why? |
|
6 |
|
Somebody can request another one! |
10 |
7 |
[ ] All internal error should show a special page? |
[ ] All internal error should show a special page? |
|
8 |
|
[ ] Deleting a SSH key should be done with token. |
|
9 |
|
[ ] All operations must be verified with tokens. |
11 |
10 |
[ ] |
[ ] |
12 |
11 |
|
|
13 |
12 |
|
|
14 |
13 |
== Medium == |
== Medium == |
15 |
|
[ ] Bug rights: add note, anonymous add note, add label. |
|
|
14 |
|
[ ] Bug rights: add note, anonymous add note, add label, add global search. |
16 |
15 |
[ ] Allow user to specify if is on windows/linux/etc. to be able to give |
[ ] Allow user to specify if is on windows/linux/etc. to be able to give |
17 |
16 |
specific hints. Hm. THe user may have multiple OSs. |
specific hints. Hm. THe user may have multiple OSs. |
18 |
17 |
[ ] The selected menu is not colored different. |
[ ] The selected menu is not colored different. |
File inc/bug.inc.php changed (mode: 100644) (index 8ea95d3..1d2c24f) |
... |
... |
function rg_bug_search_load($db, $repo_id, $uid, $name) |
470 |
470 |
"body_string" => "", |
"body_string" => "", |
471 |
471 |
"bugs_per_page" => 25, |
"bugs_per_page" => 25, |
472 |
472 |
"global" => 0, |
"global" => 0, |
|
473 |
|
"for_all_users" => 1, |
473 |
474 |
"standard" => 1 |
"standard" => 1 |
474 |
475 |
); |
); |
475 |
476 |
|
|
|
... |
... |
function rg_bug_search_load($db, $repo_id, $uid, $name) |
491 |
492 |
|
|
492 |
493 |
$e_name = rg_sql_escape($db, $name); |
$e_name = rg_sql_escape($db, $name); |
493 |
494 |
|
|
494 |
|
$sql = "SELECT name, data FROM bug_search" |
|
|
495 |
|
$sql = "SELECT name, data, for_all_users FROM bug_search" |
495 |
496 |
. " WHERE (repo_id = $repo_id OR repo_id = 0)" |
. " WHERE (repo_id = $repo_id OR repo_id = 0)" |
496 |
|
. " AND uid = $uid" |
|
497 |
|
. " AND name = '$e_name'"; |
|
|
497 |
|
. " AND (uid = $uid OR for_all_users = 1)" |
|
498 |
|
. " AND name = '$e_name'" |
|
499 |
|
. " ORDER BY name"; |
498 |
500 |
$res = rg_sql_query($db, $sql); |
$res = rg_sql_query($db, $sql); |
499 |
501 |
if ($res === FALSE) { |
if ($res === FALSE) { |
500 |
502 |
rg_bug_set_error("cannot search load (" . rg_sql_error() . ")"); |
rg_bug_set_error("cannot search load (" . rg_sql_error() . ")"); |
|
... |
... |
function rg_bug_search_load($db, $repo_id, $uid, $name) |
511 |
513 |
} |
} |
512 |
514 |
$ret = $_data; |
$ret = $_data; |
513 |
515 |
$ret['name'] = $row['name']; //TODO: escape?! |
$ret['name'] = $row['name']; //TODO: escape?! |
|
516 |
|
$ret['for_all_users'] = $row['for_all_users']; |
514 |
517 |
$ret['standard'] = 0; |
$ret['standard'] = 0; |
515 |
518 |
} else { |
} else { |
516 |
519 |
$ret = array(); |
$ret = array(); |
|
... |
... |
function rg_bug_search_save($db, $repo_id, $uid, $q) |
552 |
555 |
else |
else |
553 |
556 |
$e_repo_id = 0; |
$e_repo_id = 0; |
554 |
557 |
|
|
555 |
|
if (empty($old)) { |
|
|
558 |
|
if (isset($q['for_all_users']) && ($q['for_all_users'] == 1)) |
|
559 |
|
$e_for_all_users = 1; |
|
560 |
|
else |
|
561 |
|
$e_for_all_users = 0; |
|
562 |
|
|
|
563 |
|
// We will not overwrite somebody else's search |
|
564 |
|
if (empty($old) || ($old['uid'] != $uid)) { |
556 |
565 |
$sql = "INSERT INTO bug_search (repo_id, uid, name" |
$sql = "INSERT INTO bug_search (repo_id, uid, name" |
557 |
|
. ", data)" |
|
|
566 |
|
. ", data, for_all_users)" |
558 |
567 |
. " VALUES ($e_repo_id, $uid, '$e_name'" |
. " VALUES ($e_repo_id, $uid, '$e_name'" |
559 |
|
. ", '$e_data')"; |
|
|
568 |
|
. ", '$e_data', $e_for_all_users)"; |
560 |
569 |
} else { |
} else { |
561 |
570 |
$sql = "UPDATE bug_search" |
$sql = "UPDATE bug_search" |
562 |
571 |
. " SET data = '$e_data'" |
. " SET data = '$e_data'" |
|
572 |
|
. ", for_all_users = $e_for_all_users" |
563 |
573 |
. " WHERE repo_id = $e_repo_id" |
. " WHERE repo_id = $e_repo_id" |
564 |
574 |
. " AND uid = $uid" |
. " AND uid = $uid" |
565 |
575 |
. " AND name = '$e_name'"; |
. " AND name = '$e_name'"; |
File inc/util.inc.php changed (mode: 100644) (index 94791fa..5bd5931) |
... |
... |
function rg_prepare_image($line) |
370 |
370 |
return preg_replace_callback('/@@IMG:(.*)@@/uU', "rg_image_callback", $line); |
return preg_replace_callback('/@@IMG:(.*)@@/uU', "rg_image_callback", $line); |
371 |
371 |
} |
} |
372 |
372 |
|
|
|
373 |
|
/* |
|
374 |
|
* Helper for rg_replace_conditionals. |
|
375 |
|
* It works at line level. |
|
376 |
|
* @master_block (TRUE / FALSE) is the condition for parent block. |
|
377 |
|
*/ |
|
378 |
|
function rg_replace_conditionals_block($block, &$stack) |
|
379 |
|
{ |
|
380 |
|
rg_log("rg_replace_conditionals_block: block=[$block]" |
|
381 |
|
. " stack=" . rg_array2string($stack)); |
|
382 |
|
|
|
383 |
|
if (!is_string($block)) { |
|
384 |
|
rg_internal_error("Block is not a string!"); |
|
385 |
|
return FALSE; |
|
386 |
|
} |
|
387 |
|
|
|
388 |
|
// Nesting error |
|
389 |
|
// TODO: rg_internal_error? |
|
390 |
|
if (empty($stack)) |
|
391 |
|
return FALSE; |
|
392 |
|
|
|
393 |
|
$cond = array_pop($stack); |
|
394 |
|
$stack[] = $cond; |
|
395 |
|
rg_log("cond is " . ($cond ? "TRUE" : "FALSE")); |
|
396 |
|
|
|
397 |
|
// First, try to match a start of 'if' |
|
398 |
|
$match1 = "@@if\s*\((.*?)\s*==\s*(.*?)\)\s*?{{"; |
|
399 |
|
$match2 = "{{"; |
|
400 |
|
$match3 = "}}"; |
|
401 |
|
$search = $match1 . '|' . $match2 . '|' . $match3; |
|
402 |
|
$r = preg_match('/^(.*?)(' . $search . ')(.*)/su', |
|
403 |
|
$block, $matches); |
|
404 |
|
if ($r === FALSE) |
|
405 |
|
return FALSE; |
|
406 |
|
if ($r === 1) { |
|
407 |
|
rg_log("matches: " . rg_array2string($matches)); |
|
408 |
|
|
|
409 |
|
$ret = ""; |
|
410 |
|
if ($cond) |
|
411 |
|
$ret = $matches[1]; |
|
412 |
|
|
|
413 |
|
$rest = $matches[5]; |
|
414 |
|
if (strcmp($matches[2], "}}") == 0) { |
|
415 |
|
// We pop from stack only at }} and not at {{ |
|
416 |
|
rg_log("}}: Pop the stack!"); |
|
417 |
|
array_pop($stack); |
|
418 |
|
} else if (strcmp($matches[2], "{{") == 0) { |
|
419 |
|
rg_log("{{"); |
|
420 |
|
} else { |
|
421 |
|
$left = trim($matches[3]); |
|
422 |
|
$right = trim($matches[4]); |
|
423 |
|
rg_log("if left=[$left] right=[$right]"); |
|
424 |
|
$new_cond = strcmp($left, $right) == 0 ? TRUE : FALSE; |
|
425 |
|
$not_new_cond = $new_cond ? FALSE : TRUE; |
|
426 |
|
|
|
427 |
|
// We have to respect the outer block condition |
|
428 |
|
// We have to push in reverse order. Remeber, first in, last out |
|
429 |
|
$stack[] = $not_new_cond && $cond; |
|
430 |
|
$stack[] = $new_cond && $cond; |
|
431 |
|
} |
|
432 |
|
|
|
433 |
|
$tmp = rg_replace_conditionals_block($rest, $stack); |
|
434 |
|
if ($tmp === FALSE) |
|
435 |
|
return FALSE; |
|
436 |
|
|
|
437 |
|
rg_log("returning [" . $ret . $tmp . "]"); |
|
438 |
|
return $ret . $tmp; |
|
439 |
|
} |
|
440 |
|
|
|
441 |
|
if ($cond === FALSE) |
|
442 |
|
$block = ""; |
|
443 |
|
|
|
444 |
|
rg_log("returning [$block]"); |
|
445 |
|
return $block; |
|
446 |
|
} |
|
447 |
|
|
373 |
448 |
/* |
/* |
374 |
449 |
* Replace conditionals |
* Replace conditionals |
375 |
|
* @@if(X){{@@A@@}}{{@@B@@}} - if X is 0 will return @@B@@, else @@A@@ |
|
|
450 |
|
* @@if(X == Y){{A}}{{B}} - if X == Y it will return A, else B. |
|
451 |
|
* Do note that there is no ending @@. |
|
452 |
|
* Because of complexity, I choosed to have a restriction: the 'if' is on |
|
453 |
|
* a single line or '@@if(...){{', '}}{{' and '}}' are on separate lines. |
|
454 |
|
* TODO: Also, we must have both branches (both true and false), for now. |
|
455 |
|
* We support nested ifs. |
376 |
456 |
*/ |
*/ |
377 |
|
function rg_prepare_conditionals(&$data, &$what, &$values) |
|
|
457 |
|
function rg_replace_conditionals($block) |
378 |
458 |
{ |
{ |
379 |
|
// we need greedy (!U) here to take care of cascading ifs |
|
380 |
|
// TODO: probably we need to repeat the replace? |
|
381 |
|
$what['false'] = "/@@if\(0\){{(.*)}}{{(.*)}}/su"; |
|
382 |
|
$values['false'] = '$2'; |
|
|
459 |
|
rg_log("rg_replace_conditionals"); |
|
460 |
|
|
|
461 |
|
$ret = array(); |
|
462 |
|
|
|
463 |
|
$stack = array(); |
|
464 |
|
$stack[] = TRUE; |
|
465 |
|
$ret = rg_replace_conditionals_block($block, $stack); |
383 |
466 |
|
|
384 |
|
// For condition, we must be non greedy! |
|
385 |
|
$what['true'] = "/@@if\(.*?\){{(.*)}}{{(.*)}}/su"; |
|
386 |
|
$values['true'] = '$1'; |
|
|
467 |
|
if (empty($stack) || ($stack[0] !== TRUE)) { |
|
468 |
|
rg_internal_error("Template nesting error!"); |
|
469 |
|
return FALSE; |
|
470 |
|
} |
|
471 |
|
|
|
472 |
|
return $ret; |
387 |
473 |
} |
} |
388 |
474 |
|
|
389 |
475 |
function rg_prepare_replace(&$data, &$what, &$values) |
function rg_prepare_replace(&$data, &$what, &$values) |
|
... |
... |
function rg_prepare_replace(&$data, &$what, &$values) |
397 |
483 |
} else { |
} else { |
398 |
484 |
$v = htmlspecialchars($v); |
$v = htmlspecialchars($v); |
399 |
485 |
} |
} |
400 |
|
$what[$k] = "/@@" . $k . "@@/U"; |
|
|
486 |
|
$what[$k] = "/@@" . $k . "@@/uU"; |
401 |
487 |
$values[$k] = $v; |
$values[$k] = $v; |
402 |
488 |
} |
} |
403 |
489 |
} |
} |
404 |
490 |
|
|
405 |
|
$what['DUMP'] = "/@@DUMP@@/U"; |
|
|
491 |
|
$what['DUMP'] = "/@@DUMP@@/uU"; |
406 |
492 |
$values['DUMP'] = htmlspecialchars(print_r($data, TRUE)); |
$values['DUMP'] = htmlspecialchars(print_r($data, TRUE)); |
407 |
493 |
|
|
408 |
494 |
// we replace @@unknown@@ with empty |
// we replace @@unknown@@ with empty |
|
... |
... |
function rg_template_table($dir, $data, $more) |
438 |
524 |
|
|
439 |
525 |
$m_what = array(); $m_values = array(); |
$m_what = array(); $m_values = array(); |
440 |
526 |
rg_prepare_replace($more, $m_what, $m_values); |
rg_prepare_replace($more, $m_what, $m_values); |
441 |
|
rg_prepare_conditionals($more, $m_what, $m_values); |
|
442 |
527 |
|
|
443 |
528 |
if (!is_array($data) || (count($data) == 0)) { |
if (!is_array($data) || (count($data) == 0)) { |
444 |
529 |
$no_data = rg_file_get_contents($xdir . "/nodata.html"); |
$no_data = rg_file_get_contents($xdir . "/nodata.html"); |
445 |
|
return preg_replace($m_what, $m_values, $no_data); |
|
|
530 |
|
$_tmp = preg_replace($m_what, $m_values, $no_data); |
|
531 |
|
return rg_replace_conditionals($_tmp); |
446 |
532 |
} |
} |
447 |
533 |
|
|
448 |
534 |
$head = rg_file_get_contents($xdir . "/header.html"); |
$head = rg_file_get_contents($xdir . "/header.html"); |
|
... |
... |
function rg_template_table($dir, $data, $more) |
460 |
546 |
$what = $m_what; $values = $m_values; |
$what = $m_what; $values = $m_values; |
461 |
547 |
|
|
462 |
548 |
rg_prepare_replace($info, $what, $values); |
rg_prepare_replace($info, $what, $values); |
463 |
|
rg_prepare_conditionals($info, $what, $values); |
|
464 |
549 |
|
|
465 |
550 |
$line = rg_prepare_image($line); |
$line = rg_prepare_image($line); |
466 |
551 |
|
|
|
... |
... |
function rg_template_table($dir, $data, $more) |
473 |
558 |
$body .= preg_replace($what, $values, $line); |
$body .= preg_replace($what, $values, $line); |
474 |
559 |
} |
} |
475 |
560 |
|
|
476 |
|
return $head . $body . $foot; |
|
|
561 |
|
return rg_replace_conditionals($head . $body . $foot); |
477 |
562 |
} |
} |
478 |
563 |
|
|
479 |
564 |
function rg_template($file, $data) |
function rg_template($file, $data) |
|
... |
... |
function rg_template($file, $data) |
493 |
578 |
$values = array(); |
$values = array(); |
494 |
579 |
|
|
495 |
580 |
rg_prepare_replace($data, $what, $values); |
rg_prepare_replace($data, $what, $values); |
496 |
|
rg_prepare_conditionals($data, $what, $values); |
|
497 |
581 |
|
|
498 |
582 |
$body = rg_prepare_image($body); |
$body = rg_prepare_image($body); |
499 |
583 |
|
|
500 |
|
return preg_replace($what, $values, $body); |
|
|
584 |
|
$ret = preg_replace($what, $values, $body); |
|
585 |
|
|
|
586 |
|
return rg_replace_conditionals($ret); |
501 |
587 |
} |
} |
502 |
588 |
|
|
503 |
589 |
/* |
/* |
File tests/util.php changed (mode: 100644) (index e3b7ff7..e78f681) |
... |
... |
if (strcmp($r, $e) != 0) { |
65 |
65 |
exit(1); |
exit(1); |
66 |
66 |
} |
} |
67 |
67 |
|
|
68 |
|
// test rg_template with conditional formating |
|
|
68 |
|
// test rg_template with conditional formating (false) |
69 |
69 |
$data = array("X" => "0", "A" => "Avalue", "B" => "Bvalue"); |
$data = array("X" => "0", "A" => "Avalue", "B" => "Bvalue"); |
70 |
70 |
$r = rg_template("t3/c1", $data); |
$r = rg_template("t3/c1", $data); |
71 |
|
$e = "Bvalue"; |
|
|
71 |
|
$e = "XXBvalueYY"; |
72 |
72 |
if (strcmp($r, $e) != 0) { |
if (strcmp($r, $e) != 0) { |
73 |
73 |
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
74 |
74 |
exit(1); |
exit(1); |
75 |
75 |
} |
} |
76 |
76 |
|
|
77 |
|
// test rg_template with conditional formating |
|
78 |
|
$data = array("X" => "34", "A" => "Avalue", "B" => "Bvalue"); |
|
|
77 |
|
// test rg_template with conditional formating (true) |
|
78 |
|
$data = array("X" => "1", "A" => "Avalue", "B" => "Bvalue"); |
79 |
79 |
$r = rg_template("t3/c1", $data); |
$r = rg_template("t3/c1", $data); |
80 |
|
$e = "Avalue"; |
|
|
80 |
|
$e = "XXAvalueYY"; |
|
81 |
|
if (strcmp($r, $e) != 0) { |
|
82 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
83 |
|
exit(1); |
|
84 |
|
} |
|
85 |
|
|
|
86 |
|
// test rg_template with conditional formating (multiline) |
|
87 |
|
$data = array("X" => "1", "A" => "Avalue", "B" => "Bvalue"); |
|
88 |
|
$r = rg_template("t3/c1", $data); |
|
89 |
|
$e = "XXAvalueYY"; |
|
90 |
|
if (strcmp($r, $e) != 0) { |
|
91 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
92 |
|
exit(1); |
|
93 |
|
} |
|
94 |
|
|
|
95 |
|
// test rg_template with conditional formating (nested 1) |
|
96 |
|
$data = array("X" => "1", "Y" => "1", "A" => "Avalue", "B" => "Bvalue", |
|
97 |
|
"R" => "Rvalue", "T" => "Tvalue"); |
|
98 |
|
$r = rg_template("t3/c3", $data); |
|
99 |
|
$e = "XXRvalueZZYY"; |
|
100 |
|
if (strcmp($r, $e) != 0) { |
|
101 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
102 |
|
exit(1); |
|
103 |
|
} |
|
104 |
|
|
|
105 |
|
// test rg_template with conditional formating (nested 2) |
|
106 |
|
$data = array("X" => "1", "Y" => "0", "A" => "Avalue", "B" => "Bvalue", |
|
107 |
|
"R" => "Rvalue", "T" => "Tvalue"); |
|
108 |
|
$r = rg_template("t3/c3", $data); |
|
109 |
|
$e = "XXTvalueZZYY"; |
|
110 |
|
if (strcmp($r, $e) != 0) { |
|
111 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
112 |
|
exit(1); |
|
113 |
|
} |
|
114 |
|
|
|
115 |
|
rg_log("test rg_template with conditional formating (nested 3)"); |
|
116 |
|
$data = array("X" => "0", "Y" => "1", "A" => "Avalue", "B" => "Bvalue", |
|
117 |
|
"R" => "Rvalue", "T" => "Tvalue"); |
|
118 |
|
$r = rg_template("t3/c3", $data); |
|
119 |
|
$e = "XXBvalueYY"; |
|
120 |
|
if (strcmp($r, $e) != 0) { |
|
121 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
122 |
|
exit(1); |
|
123 |
|
} |
|
124 |
|
|
|
125 |
|
rg_log("test rg_template with conditional formating (nested nested 1)"); |
|
126 |
|
$data = array("X" => "1", "Y" => "1", "Z" => "1"); |
|
127 |
|
$r = rg_template("t3/c4", $data); |
|
128 |
|
$r = preg_replace('/\s/', '', $r); |
|
129 |
|
$e = "XXTRUE_LEVEL_2YY"; |
|
130 |
|
if (strcmp($r, $e) != 0) { |
|
131 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
132 |
|
exit(1); |
|
133 |
|
} |
|
134 |
|
|
|
135 |
|
rg_log("test rg_template with conditional formating (nested nested 2)"); |
|
136 |
|
$data = array("X" => "1", "Y" => "0", "Z" => "1"); |
|
137 |
|
$r = rg_template("t3/c4", $data); |
|
138 |
|
$r = preg_replace('/\s/', '', $r); |
|
139 |
|
$e = "XXFALSE_LEVEL_1YY"; |
|
140 |
|
if (strcmp($r, $e) != 0) { |
|
141 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
142 |
|
exit(1); |
|
143 |
|
} |
|
144 |
|
|
|
145 |
|
rg_log("test rg_template with conditional formating (nested nested 2)"); |
|
146 |
|
$data = array("X" => "0", "Y" => "1", "Z" => "1"); |
|
147 |
|
$r = rg_template("t3/c4", $data); |
|
148 |
|
$r = preg_replace('/\s/', '', $r); |
|
149 |
|
$e = "XXFALSE_LEVEL_0YY"; |
|
150 |
|
if (strcmp($r, $e) != 0) { |
|
151 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
152 |
|
exit(1); |
|
153 |
|
} |
|
154 |
|
|
|
155 |
|
rg_log("test rg_template with conditional formating (nested nested 3)"); |
|
156 |
|
$data = array("X" => "0", "Y" => "0", "Z" => "0"); |
|
157 |
|
$r = rg_template("t3/c5", $data); |
|
158 |
|
$r = preg_replace('/\s/', '', $r); |
|
159 |
|
$e = "XX-X0Y0Z0-YY"; |
|
160 |
|
if (strcmp($r, $e) != 0) { |
|
161 |
|
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
|
162 |
|
exit(1); |
|
163 |
|
} |
|
164 |
|
|
|
165 |
|
rg_log("test rg_template with conditional formating (nested nested 4)"); |
|
166 |
|
$data = array("X" => "0", "Y" => "1", "Z" => "0"); |
|
167 |
|
$r = rg_template("t3/c5", $data); |
|
168 |
|
$r = preg_replace('/\s/', '', $r); |
|
169 |
|
$e = "XX-X0Y1Z0-YY"; |
81 |
170 |
if (strcmp($r, $e) != 0) { |
if (strcmp($r, $e) != 0) { |
82 |
171 |
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; |
83 |
172 |
exit(1); |
exit(1); |