Ejemplo n.º 1
0
 /**
  * Add a new directory path to the list of ignored paths.
  *
  * @param  string  $directory_path The (full) absolute path of a directory.
  * @return boolean                 TRUE if the directory path was added to the list, FALSE otherwise.
  */
 public static function ignore_directory($directory_path = '')
 {
     $cache = new SucuriScanCache('ignorescanning');
     // Use the checksum of the directory path as the cache key.
     $cache_key = md5($directory_path);
     $resource_type = SucuriScanFileInfo::get_resource_type($directory_path);
     $cache_value = array('directory_path' => $directory_path, 'ignored_at' => self::local_time(), 'resource_type' => $resource_type);
     $cached = $cache->add($cache_key, $cache_value);
     return $cached;
 }
Ejemplo n.º 2
0
 public static function block($users = array())
 {
     if (is_array($users) && !empty($users)) {
         $logs = sucuriscan_get_all_failed_logins();
         $cache = new SucuriScanCache('blockedusers');
         $blocked = $cache->getAll();
         foreach ($users as $user) {
             if (array_key_exists($user, $blocked)) {
                 continue;
             }
             $firstAttempt = self::firstAttempt($logs, $user);
             $lastAttempt = self::lastAttempt($logs, $user);
             $data = array('username' => $user, 'blocked_at' => time(), 'first_attempt' => $firstAttempt, 'last_attempt' => $lastAttempt);
             $cache->add(md5($user), $data);
         }
     }
 }