Advertisement
SkullCrack

/Graf/ vykresli2.php

Jun 27th, 2011
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.84 KB | None | 0 0
  1. <?php
  2. include ("./jpgraph.php");
  3. include ("./jpgraph_line.php");
  4.  
  5.  
  6. include 'config.php';
  7.  
  8. mysql_connect($db_server,$db_user,$db_pass) or die("Nelze se připojit k MySQL: " . mysql_error());
  9. mysql_select_db($mangos_db);
  10.  
  11. $data = mysql_query("select `aliance`,`horda` from `check` where `server`='1'")or die("Nelze se připojit k MySQL: " . mysql_error());
  12. $stop=mysql_num_rows($data);
  13. mysql_free_result($data);
  14.  
  15. $start=$stop-4320;
  16.  
  17. if ($start < 0)
  18.    $start = 0;
  19.    
  20. $data = mysql_query("select `aliance`,`horda`,TIME(`date`) as `datum` from `check` where `server`='1' limit $start,$stop")or die("Nelze se připojit k MySQL: " . mysql_error());
  21.  
  22. $i=0;
  23.  
  24. while($row=mysql_fetch_array($data))
  25. {
  26.   $horda[$i]=$row[horda];
  27.   $ali[$i]=$row[aliance];
  28.   //if ($i%360 == 0) // viz tick interval, mensi vyuziti pameti (funguje s i bez)
  29.   $timestamps[$i]=$row[datum];
  30.   $i++;
  31. }
  32.  
  33. $horda[$i]=1;
  34. $ali[$i]=1;
  35. $timestamps[$i] = 1;
  36.  
  37.  
  38. // Create the graph. These two calls are always required
  39. $graph = new Graph(1024,320,"auto");   
  40. $graph->img->SetMargin(40,40,40,40);
  41. $graph->SetScale("textlin");
  42. $graph->SetShadow();
  43.  
  44. // Create the linear plots for each category
  45. $dplot[] = new LinePLot($horda);
  46. $dplot[] = new LinePLot($ali);
  47.  
  48. $dplot[0]->SetFillColor("red");
  49. $dplot[1]->SetFillColor("blue");
  50.  
  51. // Create the accumulated graph
  52. $accplot = new AccLinePlot($dplot);
  53.  
  54. // Add the plot to the graph
  55. $graph->Add($accplot);
  56.  
  57. $graph->xaxis->SetTextTickInterval(360);
  58. $graph->xaxis->SetTickLabels($timestamps);
  59.  
  60. $date = date("H:i:s");
  61.  
  62. $graph->title->Set("Denni Graf $jmeno_serveru");
  63. $graph->xaxis->title->Set($date);
  64. $graph->yaxis->title->Set("Online Players");
  65.  
  66. $graph->title->SetFont(FF_FONT1,FS_BOLD);
  67. $graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
  68. $graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
  69.  
  70. // Display the graph
  71. $graph->Stroke();
  72. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement