Created
October 13, 2010 21:37
-
-
Save anonymous/624964 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// The gChart PHP library is required in order to make this work. You can download it from http://code.google.com/p/gchartphp/ | |
// Make sure you put it in the same directory as this script | |
ini_set('display_errors','1'); | |
$server_address = 'http://142.132.138.20:8983'; | |
require ('gChart.php'); | |
if ( isset($_GET['query'])) { | |
$query = 'mimetype:' . strtolower($_GET['query']) . '*'; | |
} else { | |
$query = '*:*'; | |
} | |
?> | |
<html> | |
<head> | |
<title>Chart of Files</title> | |
<style type="text/css"> | |
img { display:block; } | |
</style> | |
</head> | |
<body> | |
<h2>Files by MIME Type</h2> | |
<?php | |
$dataXMLURL = $server_address . '/solr/select?indent=on&version=2.2&q=' . $query . '&fq=&start=0&rows=50&fl=*,score&qt=standard&wt=xml&explainOther=&hl.fl=&facet=true&facet.field=mimetype'; | |
$xml = simplexml_load_file($dataXMLURL); | |
$FileTypeName = array(); | |
$countFileType = array(); | |
foreach($xml->xpath('//lst[@name="mimetype"]/int') as $item ) { | |
if ($item != 0) { | |
$countFileType[] = $item; | |
$FileTypeName[]= $item['name']; | |
} | |
} | |
$piChart = new gPieChart(700,400); | |
$piChart->addDataSet($countFileType); | |
$piChart->setLegend($FileTypeName); | |
$piChart->setLabels($FileTypeName); | |
$piChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa")); | |
?> | |
<ul> | |
<li><a href="files_chart.php">All Files</a></li> | |
<li><a href="files_chart.php?query=Text" id="type">Text Files</a></li> | |
<li><a href="files_chart.php?query=Image" id="type">Image Files</a></li> | |
<li><a href="files_chart.php?query=Audio" id="type">Audio Files</a></li> | |
</ul> | |
<div id="mime-chart"> | |
<?php | |
if (isset($_GET['query'])) { | |
echo '<h2>' . $_GET['query'] . ' MIME Types</h2>'; | |
} else { | |
echo '<h2>All MIME Types</h2>'; | |
} | |
?> | |
<img src="<?php print $piChart->getUrl(); ?>" /> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment