3 // Ryzom Core MMORPG framework - Error Reporter
5 // Copyright (C) 2015 Laszlo Kis-Adam
6 // Copyright (C) 2010 Ryzom Core <http://ryzomcore.org/>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 require_once( 'config.inc.php' );
22 require_once( 'log.inc.php' );
24 /// Example web application that takes bug reports from the bug reporter Qt app
25 class BugReportGatherApp
28 private $logger = NULL;
30 function __construct()
32 $this->logger
= new Logger();
35 private function logPOSTVars()
41 if( isset( $_POST[ 'report' ] ) )
42 $report = $_POST[ 'report' ];
44 if( isset( $_POST[ 'descr' ] ) )
45 $descr = $_POST[ 'descr' ];
47 if( isset( $_POST[ 'email' ] ) )
48 $email = $_POST[ 'email' ];
50 $this->logger
->log( 'report: ' . "\n" . $report );
51 $this->logger
->log( 'description: ' . "\n" . $descr );
52 $this->logger
->log( 'email: ' . "\n" . $email );
55 private function buildQuery()
61 if( isset( $_POST[ 'report' ] ) )
62 $report = $_POST[ 'report' ];
64 if( isset( $_POST[ 'descr' ] ) )
65 $descr = $_POST[ 'descr' ];
67 if( isset( $_POST[ 'email' ] ) )
68 $email = $_POST[ 'email' ];
70 $report = $this->db
->real_escape_string( $report );
71 $descr = $this->db
->real_escape_string( $descr );
72 $email = $this->db
->real_escape_string( $email );
75 $q = "INSERT INTO `bugs` (`report`,`description`,`email`) VALUES (";
83 public function exec()
85 //$this->logPOSTVars();
87 $this->db
= new mysqli( BugReportConfig
::$dbhost, BugReportConfig
::$dbuser, BugReportConfig
::$dbpw, BugReportConfig
::$dbdb, BugReportConfig
::$dbport );
88 if( mysqli_connect_error() )
90 $this->logger
->log( "Connection error :(" );
91 $this->logger
->log( mysqli_connect_error() );
95 $q = $this->buildQuery();
96 $result = $this->db
->query( $q );
97 if( $result !== TRUE )
99 $this->logger
->log( "Query failed :(" );
100 $this->logger
->log( 'Query: ' . $q );
101 $this->logPOSTVars();
109 $app = new BugReportGatherApp();