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