$max && is_writable ($dir_file)) /* The file must be writable. */ if ($log = preg_replace ("/\.log$/i", "", $dir_file)) /* Strip .log before renaming. */ rename ($dir_file, $log . "-ARCHIVED-" . date ("m-d-Y") . "-" . time () . ".log"); } /**/ if (($counter = $counter + 1) > 25) /* Up to 25 files at a time. */ break; /* Stop for now. */ } } } /**/ return true; } /** * Removes expired Transients inserted into the database by s2Member. * * This routine is staggered to conserve resources. * Only 5 Transients are deleted each time. * * This is called by s2Member's Auto-EOT System, every 10 minutes. * * @package s2Member\Utilities * @since 3.5 * * @param bool $stagger Optional. Defaults to true. If false, the routine will run, regardless. * @return bool Always returns true. */ public static function cleanup_expired_s2m_transients ($stagger = TRUE) { global $wpdb; /* Will need this for database cleaning. */ /**/ if (!$stagger || is_float ($stagger = time () / 2)) /* Stagger this routine? */ { if (is_array ($expired_s2m_transients = $wpdb->get_results ("SELECT * FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '" . esc_sql (like_escape ("_transient_timeout_s2m_")) . "%' AND `option_value` < '" . esc_sql (time ()) . "' LIMIT 5")) && !empty ($expired_s2m_transients)) { foreach ($expired_s2m_transients as $expired_s2m_transient) /* Delete the _timeout, and also the Transient entry name itself. */ if (($id = $expired_s2m_transient->option_id) && ($name = preg_replace ("/_transient_timeout_/i", "_transient_", $expired_s2m_transient->option_name, 1))) $wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_id` = '" . esc_sql ($id) . "' OR `option_name` = '" . esc_sql ($name) . "'"); } } /**/ return true; } } } ?>