Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion conf/sample.config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@
'callbacks' => array(
'table' => array(
'date' => function ($x) { $type=''; if ( date('N',strtotime($x)) >= 6) { $type = 'weekend'; } return array($x,$type); },
'checksum' => function ($x) { return array(dec2hex($x), ''); }
)
)

Expand Down
35 changes: 0 additions & 35 deletions docs/classes/Anemometer.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ <h2>Summary</h2>
<section class="row-fluid private">
<section class="span4">
<a href="../classes/Anemometer.html#method_setup_data_for_graph_search" class="">setup_data_for_graph_search()</a><br />
<a href="../classes/Anemometer.html#method_translate_checksum" class="">translate_checksum()</a><br />
<a href="../classes/Anemometer.html#method_alert" class="">alert()</a><br />
<a href="../classes/Anemometer.html#method_display_report_form" class="">display_report_form()</a><br />
<a href="../classes/Anemometer.html#method_footer" class="">footer()</a><br />
Expand Down Expand Up @@ -754,40 +753,6 @@ <h4>Parameters</h4>



</article>
</div>
<aside class="span4 detailsbar">
<h1><i class="icon-arrow-down"></i></h1>
<dl>
</dl>
<h2>Tags</h2>
<table class="table table-condensed">
<tr><td colspan="2"><em>None found</em></td></tr>
</table>
</aside>
</div>

<div class="row-fluid">
<div class="span8 content class">
<a id="method_translate_checksum" name="method_translate_checksum" class="anchor"></a>
<article class="method">
<h3 class="private ">translate_checksum()</h3>
<a href="#source-view" role="button" class="pull-right btn" data-toggle="modal" style="font-size: 1.1em; padding: 9px 14px"><i class="icon-code"></i></a>
<pre class="signature" style="margin-right: 54px;">translate_checksum( <span class="argument">$checksum</span>) </pre>
<p><em></em></p>


<h4>Parameters</h4>
<table class="table table-condensed table-hover">
<tr>
<td></td>
<td>$checksum </td>
<td></td>
</tr>
</table>



</article>
</div>
<aside class="span4 detailsbar">
Expand Down
39 changes: 5 additions & 34 deletions docs/files/Anemometer.php.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,12 @@ class Anemometer {
} else if (get_var('dimension-pivot-'.$checksum_field_name) != null
and get_var("dimension-pivot-{$checksum_field_name}-use-values") != null) {
$values = explode('|',get_var("dimension-pivot-{$checksum_field_name}-use-values"));
for ($i=0; $i<count($values); $i++) {
$values[$i] = $this->translate_checksum($values[$i]);
}
$this->report_obj->set_pivot_values("dimension-pivot-{$checksum_field_name}", $values);
//$_GET["dimension-pivot-{$checksum_field_name}"] = get_var('plot_field');
}

// translate the checksum field from possible hex value
$checksum = $this->translate_checksum(get_var("fact-{$checksum_field_name}"));
$checksum = get_var("fact-{$checksum_field_name}");
if (isset($checksum))
{
// print "setting checksum [$checksum]";
Expand Down Expand Up @@ -268,7 +265,7 @@ class Anemometer {
*/
public function quicksearch() {
$datasource = get_var('datasource');
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$exists = $this->data_model->checksum_exists($checksum);
if (!$exists) {
$this->alert("Unknown checksum: {$checksum}");
Expand Down Expand Up @@ -334,7 +331,7 @@ class Anemometer {
$this->header();

$datasource = get_var('datasource');
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$start = get_var('start') | 0;
$rpp = get_var('rpp');

Expand All @@ -355,39 +352,14 @@ class Anemometer {
$this->footer();
}

private function translate_checksum($checksum)
{
if (!in_array($this->data_model->get_source_type(), array('slow_query_log','default')))
{
return $checksum;
}

if (preg_match('/^[0-9]+$/', $checksum))
{
return $checksum;
}
else if (preg_match('/^[0-9A-Fa-f]+$/', $checksum))
{
return $this->bchexdec($checksum);
}
else if (strlen($checksum) == 0)
{
return null;
}
else
{
throw new Exception("Invalid query checksum");
}
}

/**
* Display a specific query from its checksum value
*
*/
public function show_query() {
$this->header();
$output = 'table';
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$exists = $this->data_model->checksum_exists($checksum);
if (!$exists) {
$this->alert("Unknown checksum: {$checksum}");
Expand Down Expand Up @@ -524,7 +496,7 @@ class Anemometer {
*
*/
public function upd_query() {
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$valid_actions = array('Review', 'Review and Update Comments', 'Update Comments', 'Clear Review');
$submit = get_var('submit');

Expand Down Expand Up @@ -746,4 +718,3 @@ class Anemometer {
}

?>

4 changes: 2 additions & 2 deletions install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ USE slow_query_log;

-- Create the global query review table
CREATE TABLE `global_query_review` (
`checksum` bigint(20) unsigned NOT NULL,
`checksum` char(32) NOT NULL,
`fingerprint` text NOT NULL,
`sample` longtext NOT NULL,
`first_seen` datetime DEFAULT NULL,
Expand All @@ -21,7 +21,7 @@ CREATE TABLE `global_query_review` (
CREATE TABLE `global_query_review_history` (
`hostname_max` varchar(64) NOT NULL,
`db_max` varchar(64) DEFAULT NULL,
`checksum` bigint(20) unsigned NOT NULL,
`checksum` char(32) NOT NULL,
`sample` longtext NOT NULL,
`ts_min` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ts_max` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
Expand Down
38 changes: 5 additions & 33 deletions lib/Anemometer.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,12 @@ public function api()
} else if (get_var('dimension-pivot-'.$checksum_field_name) != null
and get_var("dimension-pivot-{$checksum_field_name}-use-values") != null) {
$values = explode('|',get_var("dimension-pivot-{$checksum_field_name}-use-values"));
for ($i=0; $i<count($values); $i++) {
$values[$i] = $this->translate_checksum($values[$i]);
}
$this->report_obj->set_pivot_values("dimension-pivot-{$checksum_field_name}", $values);
//$_GET["dimension-pivot-{$checksum_field_name}"] = get_var('plot_field');
}

// translate the checksum field from possible hex value
$checksum = $this->translate_checksum(get_var("fact-{$checksum_field_name}"));
$checksum = get_var("fact-{$checksum_field_name}");
if (isset($checksum))
{
// print "setting checksum [$checksum]";
Expand Down Expand Up @@ -268,7 +265,7 @@ public function noconfig()
*/
public function quicksearch() {
$datasource = get_var('datasource');
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$exists = $this->data_model->checksum_exists($checksum);
if (!$exists) {
$this->alert("Unknown checksum: {$checksum}");
Expand Down Expand Up @@ -334,7 +331,7 @@ public function samples() {
$this->header();

$datasource = get_var('datasource');
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$start = get_var('start') | 0;
$rpp = get_var('rpp');

Expand All @@ -355,39 +352,14 @@ public function samples() {
$this->footer();
}

private function translate_checksum($checksum)
{
if (!in_array($this->data_model->get_source_type(), array('slow_query_log','default')))
{
return $checksum;
}

if (preg_match('/^[0-9]+$/', $checksum))
{
return $checksum;
}
else if (preg_match('/^[0-9A-Fa-f]+$/', $checksum))
{
return $this->bchexdec($checksum);
}
else if (strlen($checksum) == 0)
{
return null;
}
else
{
throw new Exception("Invalid query checksum");
}
}

/**
* Display a specific query from its checksum value
*
*/
public function show_query() {
$this->header();
$output = 'table';
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$exists = $this->data_model->checksum_exists($checksum);
if (!$exists) {
$this->alert("Unknown checksum: {$checksum}");
Expand Down Expand Up @@ -524,7 +496,7 @@ public function show_query() {
*
*/
public function upd_query() {
$checksum = $this->translate_checksum(get_var('checksum'));
$checksum = get_var('checksum');
$valid_actions = array('Review', 'Review and Update Comments', 'Update Comments', 'Clear Review');
$submit = get_var('submit');

Expand Down
8 changes: 4 additions & 4 deletions lib/AnemometerModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function get_reviewers() {
*/
public function checksum_exists($checksum) {
$checksum_field_name = $this->get_field_name('checksum');
$query = "SELECT `{$checksum_field_name}` FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`=" . $this->mysqli->real_escape_string($checksum);
$query = "SELECT `{$checksum_field_name}` FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`='" . $this->mysqli->real_escape_string($checksum) . "'";
$result = $this->mysqli->query($query);
check_mysql_error($result, $this->mysqli);
if ($result->num_rows) {
Expand Down Expand Up @@ -227,7 +227,7 @@ function ($x, $y) use ($mysqli) {
}, array_keys($fields), array_values($fields)
)
);
$sql .= " WHERE `{$checksum_field_name}`=" . $this->mysqli->real_escape_string($checksum);
$sql .= " WHERE `{$checksum_field_name}`='" . $this->mysqli->real_escape_string($checksum) . "'";
$res = $this->mysqli->query($sql);
// @todo ... fix this by making it a local method
check_mysql_error($res, $this->mysqli);
Expand All @@ -241,7 +241,7 @@ function ($x, $y) use ($mysqli) {
*/
public function get_query_by_checksum($checksum) {
$checksum_field_name = $this->get_field_name('checksum');
$result = $this->mysqli->query("SELECT * FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`={$checksum}");
$result = $this->mysqli->query("SELECT * FROM `{$this->fact_table}` WHERE `{$checksum_field_name}`='" . $this->mysqli->real_escape_string($checksum) . "'");
check_mysql_error($result, $this->mysqli);
if ($row = $result->fetch_assoc()) {
return $row;
Expand All @@ -265,7 +265,7 @@ public function get_query_samples($checksum, $limit = 1, $offset = 0) {
{
$table = $this->fact_table;
}
$sql = "SELECT * FROM `{$table}` WHERE `{$checksum_field_name}`={$checksum} ORDER BY `{$time_field_name}` DESC LIMIT {$limit} OFFSET {$offset}";
$sql = "SELECT * FROM `{$table}` WHERE `{$checksum_field_name}`='" . $this->mysqli->real_escape_string($checksum) . "' ORDER BY `{$time_field_name}` DESC LIMIT {$limit} OFFSET {$offset}";
return $this->mysqli->query($sql);
}

Expand Down