Advertisement
SkullCrack

/Graf/ vykresli.php

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