tiny-slitaz view step4.php @ rev 14
step4.php: multiple checkbox support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Feb 15 22:04:29 2016 +0100 (2016-02-15) |
parents | 26cfc967375f |
children | c53990da4741 |
line source
1 <?php
3 if (isset($_POST['packages']) && !isset($_POST['toconfigure'])) {
4 $_POST['toconfigure'] = shell_exec("./helper --depends ".
5 $_POST['tmp_dir']." ".$_POST['packages']);
6 }
8 if (isset($_POST['configuring'])) {
9 $pkg = $_POST['configuring'];
10 $fp = fopen($_POST['tmp_dir']."vars","w");
11 foreach ($_POST as $key => $val) {
12 if (in_array($key, $usedvars)) continue;
13 if (is_array($val)) $val = implode(",",$val);
14 fwrite($fp,"export ".$key."='".$val."'\n");
15 }
16 fclose($fp);
17 shell_exec("sudo ./helper --post-install $pkg ".$_POST['tmp_dir']);
18 }
20 if (isset($_POST['suggested'])) {
21 foreach ($_POST['suggested'] as $pkg) {
22 $_POST['toconfigure'] .= " ".$pkg;
23 }
24 unset($_POST['suggested']);
25 }
27 $output = '';
28 if (!empty($_POST['toconfigure'])) {
29 $pkgs = explode(" ",$_POST['toconfigure']);
30 foreach ($pkgs as $key => $pkg) {
31 shell_exec("sudo ./helper --pre-install $pkg ".$_POST['tmp_dir']);
32 $output = shell_exec("./helper --get-form $pkg ".
33 $_POST['tmp_dir']);
34 unset($pkgs[$key]);
35 $_POST['toconfigure'] = implode(" ", $pkgs);
36 $suggested = shell_exec("./helper --get-suggested $pkg ".
37 $_POST['tmp_dir']);
38 if ($output == "" && $suggested == "") {
39 shell_exec("sudo ./helper --post-install $pkg ".
40 $_POST['tmp_dir']);
41 continue;
42 }
43 ?>
45 <div class="box">
46 <h3>[Step 4/5] <?php echo $pkg; ?> configuration</h3>
48 <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
50 <input name="configuring" value="<?php echo $pkg; ?>" type="hidden" />
51 <div class="large">
52 <?php
53 echo $output;
54 post_hidden();
55 if ($suggested != "") {
56 $output = "suggested";
57 ?>
58 <hr />
59 <p>
60 You may want to install the following package(s) too:
61 </p>
62 <ol>
63 <?php foreach (explode(" ", $suggested) as $pkg)
64 if (!strstr(" ".$_POST['packages']." ",
65 " ".$pkg." ")) { ?>
66 <li>
67 <input type="checkbox" name="suggested[]" value="<?php echo $pkg; ?>" checked="checked" /> <?php echo $pkg; ?>
68 </li>
69 <?php } ?>
70 </ol>
71 <?php } ?>
72 </div>
74 <div align="center">
75 <input name="continue" value="Continue" type="submit" />
76 </div>
78 </form>
79 </div>
81 <?php
82 echo shell_exec("./helper --get-note $pkg ".$_POST['tmp_dir']);
83 break;
84 }
86 }
87 ?>