Code:
<?php
function updateDB($os, $section, $query, $text, $raw = '')
{
global $vbulletin;
$dateline = time();
$string = substr($text, 0, 20);
$snippet = trim(preg_replace('/\s+/', ' ', $string));
$token = $os . '_' . $section . '_' . $query;
if (strlen($token) >= 1) {
$sql = 'INSERT INTO neo_man_page_entry
(os, section, query, text, formatted, token, strlen, dateline )
VALUES
("' .
htmlentities($os, ENT_QUOTES) . '","' .
htmlentities($section, ENT_QUOTES) . '","' .
htmlentities($query, ENT_QUOTES) . '","' .
htmlentities($text, ENT_QUOTES) . '","' .
htmlentities($raw, ENT_QUOTES) . '","' .
htmlentities($token, ENT_QUOTES) . '",' .
strlen($raw) . ',' .
$dateline . ')
ON DUPLICATE KEY UPDATE
dateline = ' . $dateline . ',hits = hits +1';
$status = $vbulletin->db->query_write($sql);
return $status;
} else {
$file = '/var/log/apache2/debug/neo_update_mandb_entry_error.log';
$uid = $vbulletin->userinfo['userid'];
$text = $raw = "unknown";
error_log(date(DATE_RFC822) . " UID " . $uid . ' token ' . $token . ' len ' . strlen($text) . ' snip ' . $snippet . "\n", 3, $file);
return -1;
}
}