Advertisement
tpaper

BC html interface. PRE-PRE-ALPHA

Feb 22nd, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2.  
  3. //Bc html interface. Just for fun, it's very ugly,rude and unefficient. But works.
  4. //Enrico Ronconi - 23 feb 2015
  5.  
  6. $timeout = 5;
  7.  
  8. $a = intval($_GET['a']);
  9. $b = intval($_GET['b']);
  10. $c = intval($_GET['c']);
  11.  
  12. $cifre = intval($_GET['cifre']);
  13.  
  14. if($cifre > 1000) die ("Non barare!");
  15.  
  16. $start = microtime(true);
  17. $com = 'echo "scale = '.$cifre.'; a = '.$a.'*10^'.$_GET['ae'].'; b = '.$b.'*10^'.$_GET['be'].'; c = '.$c.'*10^'.$_GET['ce'].'; if ( (b^2-4*a*c) >= 0  ) {\"Radice 1: \"; (-b+sqrt(b^2-4*a*c))/(2*a); \"Radice 2: \"; (-b-sqrt(b^2-4*a*c))/(2*a); } else { \"Nessuna soluzione reale\" }" | timeout -s9 '.$timeout.' bc';
  18. exec($com,$out);
  19. $tempo = round(microtime(true)-$start,4);
  20. echo('
  21. <html>
  22. <body>
  23. Il calcolo ha richiesto circa '.$tempo.' secondi. (Timeout impostato a '.$timeout.' secondi)<p> Risultato: <p>
  24.  
  25. <hline>
  26. <tt> '.str_replace("Radice 2:","</br></br>Radice 2:",str_replace("\\</br>","",implode("</br>",$out))).' </tt>
  27.  
  28. </body>
  29. </html>');
  30.  
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement