Exemple #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>');
     }
 }
 /**
  * Respond to the browser according to the data received.
  *
  * @param  array  $response  Response received.
  * @param  array  $data      Data received from the beat.
  * @param  string $screen_id Identifier of the screen the heartbeat occurred on.
  * @return array             Response with new data.
  */
 public static function respond_to_received($response = array(), $data = array(), $screen_id = '')
 {
     $interval = SucuriScanOption::get_option(':heartbeat_interval');
     if ($interval == 'slow' || $interval == 'fast' || $interval == 'standard') {
         $response['heartbeat_interval'] = $interval;
     } else {
         SucuriScanOption::delete_option(':heartbeat_interval');
     }
     return $response;
 }