/** * Store a rating * * @param int $rate either -1 or +1 * @param string $page page to rate */ public function rate($rate, $page) { if ($rate < -1) { $rate = -1; } if ($rate > 1) { $rate = 1; } $sqlite = $this->getDBHelper(); if (!$sqlite) { return; } // ignore any bot accesses if (!class_exists('Jaybizzle\\CrawlerDetect\\CrawlerDetect')) { require __DIR__ . '/CrawlerDetect.php'; } $CrawlerDetect = new Jaybizzle\CrawlerDetect\CrawlerDetect(); if ($CrawlerDetect->isCrawler()) { return; } $translation = plugin_load('helper', 'translation'); if (!$translation) { $lang = ''; } else { $lang = $translation->getLangPart($page); } $date = date('Y-m-d'); $sql = "INSERT OR REPLACE INTO ratings (page, rater, lang, date, value) VALUES (?, ?, ?, ?, ?)"; $sqlite->query($sql, $page, $this->userID(), $lang, $date, $rate); }
/** * Detect if current visitor is likely a bot * * @since 0.4.0 * * @return bool */ function ingot_is_bot() { $is_bot = false; $detect = new \Jaybizzle\CrawlerDetect\CrawlerDetect(); if ($detect->isCrawler()) { $is_bot = true; } /** * Override bot detection * * @since 0.4.0 * * @param bool $is_bot Whether to treat current visitor as bot or not */ return (bool) apply_filters('ingot_is_bot', $is_bot); }