public static function execute( $params ) {

		// Remove export log file
		unlink( ai1wm_export_path( $params ) );

		// Get storage iterator
		$iterator = new RecursiveIteratorIterator(
			new Ai1wm_Recursive_Directory_Iterator( ai1wm_storage_path( $params ) ),
			RecursiveIteratorIterator::CHILD_FIRST
		);

		// Remove files and directories
		foreach ( $iterator as $item ) {
			if ( $item->isDir() ) {
				rmdir( $item->getPathname() );
			} else {
				unlink( $item->getPathname() );
			}
		}

		// Remove storage path
		rmdir( ai1wm_storage_path( $params ) );

		exit;
	}
 public static function export($params = array())
 {
     global $wp_filter;
     // Set error handler
     @set_error_handler('Ai1wm_Handler::error');
     // Set params
     if (empty($params)) {
         $params = ai1wm_urldecode($_REQUEST);
     }
     // Set priority
     $priority = 5;
     if (isset($params['priority'])) {
         $priority = (int) $params['priority'];
     }
     // Set secret key
     $secret_key = null;
     if (isset($params['secret_key'])) {
         $secret_key = $params['secret_key'];
     }
     // Verify secret key by using the value in the database, not in cache
     if ($secret_key !== get_option(AI1WM_SECRET_KEY)) {
         Ai1wm_Status::error(sprintf(__('Unable to authenticate your request with secret_key = "%s"', AI1WM_PLUGIN_NAME), $secret_key), __('Unable to export', AI1WM_PLUGIN_NAME));
         exit;
     }
     // Get hook
     if (isset($wp_filter['ai1wm_export']) && ($filters = $wp_filter['ai1wm_export']) && ksort($filters)) {
         while ($hooks = current($filters)) {
             if ($priority === key($filters)) {
                 foreach ($hooks as $hook) {
                     try {
                         $params = call_user_func_array($hook['function'], array($params));
                     } catch (Exception $e) {
                         Ai1wm_Status::error($e->getMessage(), __('Unable to export', AI1WM_PLUGIN_NAME));
                         exit;
                     }
                 }
                 // Set completed
                 $completed = true;
                 if (isset($params['completed'])) {
                     $completed = (bool) $params['completed'];
                 }
                 // Log request
                 if (empty($params['priority']) || is_file(ai1wm_export_path($params))) {
                     Ai1wm_Log::export($params);
                 }
                 // Do request
                 if ($completed === false || ($next = next($filters)) && ($params['priority'] = key($filters))) {
                     // Check the status, maybe we need to stop it
                     if (!is_file(ai1wm_export_path($params))) {
                         exit;
                     }
                     return Ai1wm_Http::get(admin_url('admin-ajax.php?action=ai1wm_export'), $params);
                 }
             }
             next($filters);
         }
     }
 }
 public static function post($url, $params = array())
 {
     // Check the status, maybe we need to stop it
     if (!is_file(ai1wm_export_path($params)) && !is_file(ai1wm_import_path($params))) {
         exit;
     }
     // Get IP address
     $ip = get_option(AI1WM_URL_IP);
     // HTTP request
     Ai1wm_Http::request($url, $ip, $params);
 }
	public static function export( $params ) {
		$data = array();

		// Add date
		$data[] = date( 'M d Y H:i:s' );

		// Add params
		$data[] = json_encode( $params );

		// Add empty line
		$data[] = PHP_EOL;

		// Write log data
		if ( $handle = fopen( ai1wm_export_path( $params ), 'a' ) ) {
			fwrite( $handle, implode( PHP_EOL, $data ) );
			fclose( $handle );
		}
	}