/**
 * Returns the html for binary log information.
 *
 * @param Array $url_params links parameters
 *
 * @return string
 */
function PMA_getLogInfo($url_params)
{
    /**
     * Need to find the real end of rows?
     */
    if (!isset($_REQUEST['pos'])) {
        $pos = 0;
    } else {
        /* We need this to be a integer */
        $pos = (int) $_REQUEST['pos'];
    }
    $sql_query = 'SHOW BINLOG EVENTS';
    if (!empty($_REQUEST['log'])) {
        $sql_query .= ' IN \'' . $_REQUEST['log'] . '\'';
    }
    $sql_query .= ' LIMIT ' . $pos . ', ' . (int) $GLOBALS['cfg']['MaxRows'];
    /**
     * Sends the query
     */
    $result = $GLOBALS['dbi']->query($sql_query);
    /**
     * prepare some vars for displaying the result table
     */
    // Gets the list of fields properties
    if (isset($result) && $result) {
        $num_rows = $GLOBALS['dbi']->numRows($result);
    } else {
        $num_rows = 0;
    }
    if (empty($_REQUEST['dontlimitchars'])) {
        $dontlimitchars = false;
    } else {
        $dontlimitchars = true;
        $url_params['dontlimitchars'] = 1;
    }
    //html output
    $html = PMA_Util::getMessage(PMA_Message::success(), $sql_query);
    $html .= '<table cellpadding="2" cellspacing="1" id="binlogTable">' . '<thead>' . '<tr>' . '<td colspan="6" class="center">';
    $html .= PMA_getNavigationRow($url_params, $pos, $num_rows, $dontlimitchars);
    $html .= '</td>' . '</tr>' . '<tr>' . '<th>' . __('Log name') . '</th>' . '<th>' . __('Position') . '</th>' . '<th>' . __('Event type') . '</th>' . '<th>' . __('Server ID') . '</th>' . '<th>' . __('Original position') . '</th>' . '<th>' . __('Information') . '</th>' . '</tr>' . '</thead>' . '<tbody>';
    $html .= PMA_getAllLogItemInfo($result, $dontlimitchars);
    $html .= '</tbody>' . '</table>';
    return $html;
}
 /**
  * Test for PMA_getAllLogItemInfo
  *
  * @return void
  */
 public function testPMAGetAllLogItemInfo()
 {
     //Mock DBI
     $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
     $fetchAssoc = array('Info' => 'Info', 'Log_name' => 'Log_name', 'Pos' => 'Pos', 'Event_type' => 'Event_type', 'Server_id' => 'Server_id', 'Orig_log_pos' => 'Orig_log_pos', 'End_log_pos' => 'End_log_pos');
     $dbi->expects($this->at(0))->method('fetchAssoc')->will($this->returnValue($fetchAssoc));
     $dbi->expects($this->at(1))->method('fetchAssoc')->will($this->returnValue(false));
     $GLOBALS['dbi'] = $dbi;
     $GLOBALS['cfg']['LimitChars'] = 2;
     $result = array();
     $dontlimitchars = ";";
     $html = PMA_getAllLogItemInfo($result, $dontlimitchars);
     $value = $fetchAssoc;
     $this->assertContains($value['Log_name'], $html);
     $this->assertContains($value['Pos'], $html);
     $this->assertContains($value['Event_type'], $html);
     $this->assertContains($value['Server_id'], $html);
     $this->assertContains($value['Orig_log_pos'], $html);
     $this->assertContains(htmlspecialchars($value['Info']), $html);
 }