function searchForParents() { $query = "SELECT bug_id,bug_error_regexp,bug_stack_regexp FROM " . TBUGS; $result = mysql_query($query) or die('MySQL Query Error! ' . mysql_error()); while ($row = mysql_fetch_array($result)) { $bug_text = $this->xml_decode($this->text); $bug_stack = $this->xml_decode($this->stack); if (ereg($row['bug_error_regexp'], $bug_text) && ereg_mline($row['bug_stack_regexp'], $bug_stack)) { $this->bug = $row['bug_id']; return $row['bug_id']; } } return 0; }
function actions() { if (isset($_POST['submit'])) { switch ($_POST['submit']) { case 'Save': foreach ($_POST as $key => $value) { $_POST[$key] = stripslashes($value); } $this->name = isset($_POST['name']) ? $_POST['name'] : $this->name; if (isset($_POST['flag']) && $_POST['flag'] != $this->flag) { $this->flag = $_POST['flag']; $this->lastupdate = mktime(); foreach ($this->bugs as $id) { $report = new BugReport(); $report->loaddb($id); $report->updated($this->flag); } } $this->developer = isset($_POST['developer']) ? $_POST['developer'] : $this->developer; $this->desc = isset($_POST['desc']) ? $_POST['desc'] : $this->desc; $this->error_regexp = isset($_POST['error_regexp']) ? $_POST['error_regexp'] : $this->error_regexp; $this->stack_regexp = isset($_POST['stack_regexp']) ? $_POST['stack_regexp'] : $this->stack_regexp; $this->update2db(); break; case 'Delete': $this->deletedb(); $this->msg('Bug deleted!', true); break; case 'Search': $query = "UPDATE " . TBUGREPORTS . " SET bug_parent='0' WHERE bug_parent='" . $this->_id . "'"; mysql_query($query) or die('MySQL Query Error! ' . mysql_error()); $query = "SELECT bug_id,bug_text,bug_stack FROM " . TBUGREPORTS . " WHERE bug_parent='0'"; $result = mysql_query($query) or die('MySQL Query Error! ' . mysql_error()); $found = 0; while ($row = mysql_fetch_array($result)) { $bug_text = $this->xml_decode($row['bug_text']); $bug_stack = $this->xml_decode($row['bug_stack']); if (ereg($this->error_regexp, $bug_text) && ereg_mline($this->stack_regexp, $bug_stack)) { $query = "UPDATE " . TBUGREPORTS . " SET bug_parent='" . $this->_id . "' WHERE bug_id='" . $row['bug_id'] . "'"; mysql_query($query) or die('MySQL Query Error! ' . mysql_error()); $this->bugs[] = $row['bug_id']; $found++; } } $this->msg("Found " . $found . " bug reports!", false); break; case 'Preview': $this->stack_regexp = stripslashes($_POST['stack_regexp']); $this->error_regexp = stripslashes($_POST['error_regexp']); $query = "SELECT bug_id,bug_text,bug_stack FROM " . TBUGREPORTS . " WHERE bug_parent='0' OR bug_parent='" . $this->_id . "'"; $result = mysql_query($query) or die('MySQL Query Error! ' . mysql_error()); $found = 0; $bugs = array(); while ($row = mysql_fetch_array($result)) { $bug_text = $this->xml_decode($row['bug_text']); $bug_stack = $this->xml_decode($row['bug_stack']); if (ereg($this->error_regexp, $bug_text) && ereg_mline($this->stack_regexp, $bug_stack)) { if (count($bugs) < 10) { $bugs[] = $row['bug_id']; } $found++; } } $this->msg("Found " . $found . " bug reports!", false); $str = ''; foreach ($bugs as $id) { $str .= '<a href="?show=bugreport&id=' . $id . '">' . $id . '</a> '; } $this->msg("Preview: " . $str, false); break; } } }