Exemple #1
0
 function logSmartly($type, $status, $issue = '', $opts = false)
 {
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $user_id = $user->get('id');
     $UserIp = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : getenv("REMOTE_ADDR");
     $ref = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : getenv("HTTP_REFERER");
     $post = JRequest::get('post', 2);
     if ($opts) {
         $post['__mighty_defender_info'] = $opts;
     }
     $post = serialize($post);
     $uri =& JURI::getInstance();
     $q = "SELECT `id` FROM #__jdefender_log WHERE `ip` = " . $db->Quote($UserIp) . " AND `url` = " . $db->Quote($uri->toString()) . ' AND `type` = ' . $db->Quote($type) . ' AND status = ' . $db->Quote($status) . ' AND `post` = ' . $db->Quote($post) . " AND `issue` = " . $db->Quote($issue) . ' AND `ctime` + INTERVAL 1 HOUR > NOW()';
     $db->setQuery($q);
     $id = $db->loadResult();
     if ($id) {
         $db->setQuery("UPDATE #__jdefender_log SET `ctime` = NOW(), `total` = `total` + 1 WHERE `id` = " . (int) $id);
         $db->query();
     } else {
         JD_Log_Helper::log($type, $status, $issue, $opts);
     }
 }