Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
progressbar.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * progress bar tool
9  *
10  * @author Anakeen 2000
11  * @version $Id: progressbar.php,v 1.3 2007/02/16 07:38:55 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage CORE
15  */
16 /**
17  */
18 
19 function progressbar(&$action)
20 {
21  $fbar = GetHttpVars("bar");
22 
23  $action->lay->set("bar", $fbar);
24 }
25 
27 {
28  $fbar = GetHttpVars("bar");
29  static $lastline;
30 
31  if ($fbar) {
32  $rf = file($fbar);
33  // if (count($rf) > 0) {
34  $ffbar = fopen("$fbar.lck", "w");
35  if ($ffbar) fclose($ffbar);
36  //}
37 
38  }
39  $texts = array();
40  $reste = 0;
41  $total = 0;
42 
43  if ($rf) {
44  foreach ($rf as $line) {
45  if (preg_match("|([0-9\-]+)/([0-9\-]+)/(.*)|", $line, $reg)) {
46  $texts[] = addslashes(trim($reg[3]));
47  if (intval($reg[2]) >= 0) $total = intval($reg[2]);
48  if (intval($reg[1]) >= 0) $reste = intval($reg[1]);
49  }
50  }
51  // $action->lay->set("text",trim(addslashes($text)));
52  $action->lay->set("texts", "['" . implode("','", ($texts)) . "']");
53  $action->lay->set("reste", $reste);
54  $action->lay->set("done", $total - $reste);
55  $action->lay->set("total", $total);
56  if ($total > 0) {
57  $action->lay->set("pc", round(($total - $reste) / $total * 100) . "%");
58  $action->lay->set("pc1", round(($total - $reste) / $total * 100));
59  } else $action->lay->set("pc", "100%");
60  $action->lay->set("waiting", 0);
61  } else {
62  $action->lay->set("waiting", 1);
63  }
64  unlink($fbar);
65 }
66 ?>
← centre documentaire © anakeen - published under CC License - Dynacase