예제 #1
0
 /**
  * Create a folder in the WordPress upload directory where the plugin will
  * store all the temporal or dynamic information.
  *
  * @return void
  */
 public static function create_datastore_folder()
 {
     $directory = SucuriScan::datastore_folder_path();
     if (!file_exists($directory)) {
         @mkdir($directory, 0755, true);
     }
     if (file_exists($directory)) {
         // Create last-logins datastore file.
         sucuriscan_lastlogins_datastore_exists();
         // Create a htaccess file to deny access from all.
         @file_put_contents($directory . '/.htaccess', "Order Deny,Allow\nDeny from all\n", LOCK_EX);
         // Create an index.html to avoid directory listing.
         @file_put_contents($directory . '/index.html', '<!-- Prevent the directory listing. -->', LOCK_EX);
     } else {
         SucuriScanOption::delete_option(':datastore_path');
         SucuriScanInterface::error('Data folder does not exists and could not be created. Try to <a href="' . SucuriScanTemplate::get_url('settings') . '">click this link</a> to see
             if the plugin is able to fix this error automatically, if this message
             reappears you will need to either change the location of the directory from
             the plugin general settings page or create this directory manually and give
             it write permissions: <code>' . $directory . '</code>');
     }
 }
예제 #2
0
 public static function cachePage($nonce)
 {
     $params = array();
     $fpath = SucuriScan::datastore_folder_path('sucuri-sitecheck.php');
     if ($nonce) {
         // Reset SiteCheck results cache.
         if (SucuriScanRequest::post(':sitecheck_cache')) {
             if (file_exists($fpath)) {
                 if (@unlink($fpath)) {
                     $message = 'Malware scanner cache was successfully reset.';
                     SucuriScanEvent::report_debug_event($message);
                     SucuriScanInterface::info($message);
                 } else {
                     SucuriScanInterface::error('Count not reset the cache, delete manually.');
                 }
             } else {
                 SucuriScanInterface::error('The cache file does not exists.');
             }
         }
     }
     $params['SiteCheck.CacheSize'] = SucuriScan::human_filesize(@filesize($fpath));
     $params['SiteCheck.CacheLifeTime'] = SUCURISCAN_SITECHECK_LIFETIME;
     return SucuriScanTemplate::getSection('settings-sitecheck-cache', $params);
 }