/trunk/ajax_cmd.php |
---|
62,11 → 62,11 |
_err($e->getMessage()); |
} |
$res = @mysql_query('select id from vts_fehlerlog where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
$res = @db_query('select id from vts_fehlerlog where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
if (!$res) _err('mysql query failed'); |
if (mysql_num_rows($res) == 0) _err('Row not found or no permission given.'); |
if (db_num_rows($res) == 0) _err('Row not found or no permission given.'); |
$res = @mysql_query('update vts_fehlerlog set anzahlsolved = anzahl where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
$res = @db_query('update vts_fehlerlog set anzahlsolved = anzahl where (id = '.$_REQUEST['id'].') '.$hardcoded_filters); |
if (!$res) _err('mysql query failed'); |
$out = array(); |
/trunk/db.inc.php |
---|
17,7 → 17,100 |
* limitations under the License. |
*/ |
// Please reply this code with your actual implementation |
// Please replace this code with your actual implementation |
mysql_connect('localhost', 'root', ''); |
mysql_select_db('logviewer'); |
db_connect('localhost', 'root', ''); |
db_select_db('logviewer'); |
# --- |
// Liefert die Anzahl der Zeilen im Ergebnis |
function db_num_rows($result) { |
if (!$result) { |
$err = db_error(); |
throw new Exception("Called db_num_rows() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err")); |
} |
return $result->num_rows; |
} |
// Liefert eine Ergebniszeile als Objekt |
function db_fetch_object($result, $class_name="stdClass", $params=null) { |
if (!$result) { |
$err = db_error(); |
throw new Exception("Called db_fetch_object() with an erroneous argument.".($err == '' ? '' : " Possible cause: $err")); |
} |
if ($params) { |
return $result->fetch_object($class_name, $params); |
} else { |
return $result->fetch_object($class_name); |
} |
} |
// Öffnet eine Verbindung zu einem MySQL-Server |
function db_connect($server=null, $username=null, $password=null, $new_link=false, $client_flags=0) { |
global $vts_mysqli; |
$ary = explode(':', $server); |
$host = $ary[0]; |
$ini_port = ini_get("mysqli.default_port"); |
$port = isset($ary[1]) ? (int)$ary[1] : ($ini_port ? (int)$ini_port : 3306); |
if (is_null($server)) $port = ini_get("mysqli.default_host"); |
if (is_null($username)) $port = ini_get("mysqli.default_user"); |
if (is_null($password)) $port = ini_get("mysqli.default_password"); |
$vts_mysqli = new mysqli($host, $username, $password, /*dbname*/'', $port, ini_get("mysqli.default_socket")); |
return (empty($vts_mysqli->connect_error) && ($vts_mysqli->connect_errno == 0)) ? $vts_mysqli : false; |
} |
// Schließt eine Verbindung zu MySQL |
function db_close($link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_close(). No valid connection to server."); |
return $li->close(); |
} |
// Liefert den Fehlertext der zuvor ausgeführten MySQL Operation |
function db_error($link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_error(). No valid connection to server."); |
return !empty($li->connect_error) ? $li->connect_error : $li->error; |
} |
// Maskiert spezielle Zeichen innerhalb eines Strings für die Verwendung in einer SQL-Anweisung |
function db_real_escape_string($unescaped_string, $link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_real_escape_string(). No valid connection to server."); |
return $li->escape_string($unescaped_string); |
} |
// Sendet eine Anfrage an MySQL |
function db_query($query, $link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_query(). No valid connection to server."); |
return $li->query($query, $resultmode=MYSQLI_STORE_RESULT); |
} |
// Auswahl einer MySQL Datenbank |
function db_select_db($database_name, $link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_select_db(). No valid connection to server."); |
return $li->select_db($database_name); |
} |
// Liefert die ID, die in der vorherigen Abfrage erzeugt wurde |
function db_insert_id($link_identifier=NULL) { |
global $vts_mysqli; |
$li = is_null($link_identifier) ? $vts_mysqli : $link_identifier; |
if (is_null($li)) throw new Exception("Cannot execute db_insert_id(). No valid connection to server."); |
return $li->insert_id; |
} |
/trunk/index.php |
---|
39,6 → 39,10 |
die('<h1>ViaThinkSoft LogViewer - Error</h1><p>'.$e->getMessage().'</p>'); |
} |
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : ''; |
if ($sort == '') $sort = 'anzahl'; |
if (($sort != 'anzahl') && ($sort != 'letzter') && ($sort != 'random')) die('Sort falsch'); |
# Please keep this code synchronized with ajax_cmd.php |
$add_filters = logviewer_additional_filter(); |
$hardcoded_filters = empty($add_filters) ? '' : "and ($add_filters)"; |
46,7 → 50,7 |
# Please keep this code synchronized with ajax_cmd.php |
if (isset($_REQUEST['solveall']) && logviewer_allow_solvemark()) { |
mysql_query("update vts_fehlerlog set anzahlsolved = anzahl where text like '%".mysql_real_escape_string($_REQUEST['solveall'])."%'"); |
db_query("update vts_fehlerlog set anzahlsolved = anzahl where text like '%".db_real_escape_string($_REQUEST['solveall'])."%'"); |
header('location:?sort='.urlencode($sort)); // avoid F5 |
die(); |
} |
65,14 → 69,10 |
$negate = " "; |
} |
$filter_add .= " and text $negate like '".mysql_real_escape_string('%'.$a.'%')."' "; |
$filter_add .= " and text $negate like '".db_real_escape_string('%'.$a.'%')."' "; |
} |
} |
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : ''; |
if ($sort == '') $sort = 'anzahl'; |
if (($sort != 'anzahl') && ($sort != 'letzter') && ($sort != 'random')) die('Sort falsch'); |
?> |
<html> |
133,9 → 133,9 |
?> (<span id="count"><?php |
$res = mysql_query("select count(*) as cnt from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters.";"); |
$row = mysql_fetch_array($res); |
echo $row['cnt']; |
$res = db_query("select count(*) as cnt from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters.";"); |
$row = db_fetch_object($res); |
echo $row->cnt; |
?></span>)</div> |
169,36 → 169,36 |
$odd = true; |
if ($sort == 'letzter') { |
$res = mysql_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by letzter desc, anzahl desc, id asc limit ".COUNT); |
$res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by letzter desc, anzahl desc, id asc limit ".COUNT); |
} else if ($sort == 'anzahl') { |
$res = mysql_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by anzahl desc, letzter desc, id asc limit ".COUNT); |
$res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by anzahl desc, letzter desc, id asc limit ".COUNT); |
} else if ($sort == 'random') { |
$res = mysql_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by RAND() limit ".COUNT); |
$res = db_query("select * from vts_fehlerlog where (anzahl > anzahlsolved) ".$filter_add." ".$hardcoded_filters." order by RAND() limit ".COUNT); |
} |
while ($row = mysql_fetch_array($res)) { |
$text = htmlentities($row['text']); |
while ($row = db_fetch_object($res)) { |
$text = htmlentities($row->text); |
$text = preg_replace('@ ([^ ]{2,}) on line@ismU', ' <a href="?sort='.urlencode($sort).'&filter=\1">\1</a> on line', $text); // TODO: urlencode \1 |
$text = preg_replace('@(at|in) ([^ ]{2,}):(\d+)@ismU', '\1 <a href="?sort='.urlencode($sort).'&filter=\2">\2</a>:\3', $text); // TODO: urlencode \2 |
$anzahl = htmlentities($row['anzahl']); |
if ($row['anzahlsolved'] != 0) $anzahl .= '<br>('.$row['anzahlsolved'].')'; |
$anzahl = htmlentities($row->anzahl); |
if ($row->anzahlsolved != 0) $anzahl .= '<br>('.$row->anzahlsolved.')'; |
$class = $odd ? 'tr_odd' : 'tr_even'; |
$odd = !$odd; |
echo '<tr id="line'.$row['id'].'" class="'.$class.'">'; |
echo '<tr id="line'.$row->id.'" class="'.$class.'">'; |
if (SOURCE_STYLE == 0) { |
// nothing |
} else if (SOURCE_STYLE == 1) { |
echo '<td>'.htmlentities($row['logfile']).'</td>'; |
echo '<td>'.htmlentities($row['modul']).'</td>'; |
echo '<td>'.htmlentities($row->logfile).'</td>'; |
echo '<td>'.htmlentities($row->modul).'</td>'; |
} else { |
$user = preg_match('@/home/(.+)/@sU', $row['logfile'], $m) ? $m[1] : ((strpos($row['logfile'], '/root/') === 0) ? 'root' : ''); |
$user = preg_match('@/home/(.+)/@sU', $row->logfile, $m) ? $m[1] : ((strpos($row->logfile, '/root/') === 0) ? 'root' : ''); |
echo '<td>'.htmlentities($user).'</td>'; |
} |
if (logviewer_allow_solvemark()) echo '<td><a href="javascript:_solve('.$row['id'].')">Solved</a></td>'; |
if (logviewer_allow_solvemark()) echo '<td><a href="javascript:_solve('.$row->id.')">Solved</a></td>'; |
echo '<td>'.$anzahl.'</td>'; |
echo '<td>'.htmlentities($row['letzter']).'</td>'; |
echo '<td>'.htmlentities($row->letzter).'</td>'; |
echo '<td>'.$text.'</td>'; |
echo '</tr>'; |
flush(); |
/trunk/phpstan.neon.dist |
---|
0,0 → 1,17 |
parameters: |
level: 5 |
fileExtensions: |
- php |
- phps |
paths: |
- . |
excludePaths: |
analyseAndScan: |
- .phpstan.tmp |
tmpDir: .phpstan.tmp |
bootstrapFiles: |
- config.inc.php |
ignoreErrors: |
#- '#is always (true|false)\.#' |
#- '#Call to function assert\(\) with false will always evaluate to false\.#' |
#- '#with no typehint specified\.#' |
/trunk/. |
---|
Property changes: |
Modified: svn:ignore |
auth_viathinksoft.de.inc.php |
db_viathinksoft.de.inc.php |
style_viathinksoft.de.css |
+.phpstan.tmp |
+ |