%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /dom495844/wp-content/plugins/user-role-editor-pro/pro/includes/classes/
Upload File :
Create Path :
Current File : //dom495844/wp-content/plugins/user-role-editor-pro/pro/includes/classes/utils.php

<?php
/**
 * Project: User Role Editor plugin
 * Author: Vladimir Garagulya
 * Author email: support@role-editor.com
 * Author URI: https://www.role-editor.com
 * Some parts of code were written by Janis Elsts (Broken Link Checker plugin)
 * License: GPL v2+
 * 
 * General useful stuff
 */
class URE_Utils {

    private static $execution_start_time = 0.0;
    
    /**
     * Get the server's load averages.   
     * Returns an array with three samples - the 1 minute avg, the 5 minute avg, and the 15 minute avg.
     *
     * @param integer $cache How long the load averages may be cached, in seconds. Set to 0 to get maximally up-to-date data.
     * @return array|null Array, or NULL if retrieving load data is impossible (e.g. when running on a Windows box). 
     */
    public static function get_server_load($cache = 5) {
        static $cached_load = null;
        static $cached_when = 0;

        if (!empty($cache) && ((time() - $cached_when) <= $cache)) {
            return $cached_load;
        }

        $load = null;

        if (function_exists('sys_getloadavg')) {
            $load = sys_getloadavg();
        } else {
            $loadavg_file = '/proc/loadavg';
            if (@is_readable($loadavg_file)) {
                $load = explode(' ', file_get_contents($loadavg_file));
                $load = array_map('floatval', $load);
            }
        }

        $cached_load = $load;
        $cached_when = time();
        
        return $load;
        
    }
    // end of get_server_load()
    
    public static function microtime_float()	{
        list($usec, $sec) = explode(" ", microtime());
        
        return ((float)$usec + (float)$sec);
    }
    // end of microtime_float()
    
    
   /**
     * Check if server is currently too overloaded to run the link checker.
     *
     * @return bool
     */
    public static function server_too_busy() {        

        $loads = self::get_server_load();
        if (empty($loads)) {
            return false;
        }
        $one_minute = floatval(reset($loads));

        return $one_minute > 0.70;
    }
    // end of server_too_busy()

    
    public static function start_timer(){
        
        self::$execution_start_time = self::microtime_float();
        
    }
    // end of start_timer()
    
    
    public static function get_execution_time() {
        
        $execution_time = self::microtime_float() - self::$execution_start_time;
        
        return $execution_time;
    }
    // end of get_execution_time()
    
    
    /**
     * Sleep long enough to maintain the required $ratio between $elapsed_time and total runtime.
     *
     * For example, if $ratio is 0.25 and $elapsed_time is 1 second, this method will sleep for 3 seconds.
     * Total runtime = 1 + 3 = 4, ratio = 1 / 4 = 0.25.
     *
     * @param float $elapsed_time
     * @param float $ratio
     */
    public static function sleep_to_maintain_ratio($ratio) {
        if (($ratio<=0) || ($ratio>1)) {
            return;
        }
        $sleep_time = self::get_execution_time() * ((1 / $ratio) - 1);
        if ($sleep_time > 0.0001) {
            usleep($sleep_time * 1000000);
        }
    }
    // end of sleep_to_maintain_ratio()

    
    /**
     * Return 1st integer from the string, if it follows just after the key. Spaces are ignored;
     * $key - key substring after which we should extract the integer     
     * @param string $key - key substring after which we should extract the integer
     * @param type $haystack - string from which we should extract the integer
     * @return integer 
     */     
    public static function get_int_after_key( $key, $haystack ) {
       
        $key_pos = strpos( $haystack, $key );
        if ( $key_pos===false ) {
            return 0;
        }
        
        $key_pos += strlen( $key );
        $length = strlen( $haystack );
        $str = '';
        while( $key_pos < $length ) {
            $alpha = substr( $haystack, $key_pos, 1 );
            $key_pos++;
            if ( $alpha==' ' ) {
                continue;
            }
            if ( !ctype_digit($alpha) ) {
                break;
            }
            $str .= $alpha;            
        }
        
        $value = (int) $str;
        
        return $value;
    }
    // end of get_int_after_key()
    
    
    public static function filter_int_array($input_array) {
        
        $output_arr = array();
        if (empty($input_array)) {
            return $output_arr;
        }        
        foreach($input_array as $value) {
            $int_value = (int) $value;  // save integer not zero values only
            if ($int_value>0) {
                $output_arr[] = $int_value;
            }
        }    
        
        return $output_arr;
    }
    // end of filter_int_array()
    
    
    public static function filter_int_array_to_str($input_array) {
        
        $output_arr = self::filter_int_array($input_array);        
        $output_str = implode(', ', $output_arr);
        
        return $output_str;
    }
    // end of filter_int_array_to_str()
    
    
    public static function filter_int_array_from_str( $input_str ) {
        
        $output_arr0 = explode(',', (string) $input_str );
        $output_arr = self::filter_int_array( $output_arr0 );
        
        return $output_arr;
    }
    // end of filter_int_array_from_str()
    
    
    /**
     * Extract and filter integer value from the comma separated string variable at the $_POST array
     * @param string $post_field - variable name at the $_POST array
     * @return array
     */
    public static function filter_int_list_from_post($post_field) {
        
        $data = array();
        if (!isset($_POST[$post_field]) || empty($_POST[$post_field])) {
            return $data;
        }    
        
        $list = explode(',', trim( $_POST[$post_field] ) );
        if ( count( $list )>0 ) {
            $data = URE_Utils::filter_int_array( $list );
        }            
        
        return $data;
    }
    // end of filter_int_list_from_post()

    
    public static function concat_with_comma($value, $value1) {
        if (!empty($value1)) {
            if (!empty($value)) {
                $value .= ', ';
            }
            $value .= $value1;
        }
        
        return $value;
    }
    // end of concat_strings_with_comma()
    
    
    public static function validate_int_values_unique($value) {
        
        $value = URE_Utils::filter_int_array_from_str($value);
        $value = array_unique($value);
        $value = implode(',', $value);
    
        return $value;
    }
    // edn of validate_int_values_unique()
            
    
    public function log($message) {
        echo PHP_EOL . "\033[1;34m" .$message . "\033[0m". PHP_EOL;
    }
    // end of log()

}
// end of URE_Utils class

Zerion Mini Shell 1.0
Page not found - Broad Street Financial
[et_pb_section fb_built=”1″ theme_builder_area=”post_content” _builder_version=”4.20.0″ _module_preset=”default”][et_pb_row _builder_version=”4.20.0″ _module_preset=”default” theme_builder_area=”post_content”][et_pb_column _builder_version=”4.20.0″ _module_preset=”default” type=”4_4″ theme_builder_area=”post_content”][et_pb_text _builder_version=”4.20.0″ _module_preset=”default” theme_builder_area=”post_content” hover_enabled=”0″ sticky_enabled=”0″]

Page Not Found

Sorry the requested page you are looking for is missing or has been moved.

Please check out our site and see if you can find what you are looking for.

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]