getInteger example

$colors = explode(',', $this->config->get('CaptchaColor'));
        } else {
            $colors = explode(',', '255,0,0');
        }

        $black = (int) imagecolorallocate($im(int) $colors[0](int) $colors[1](int) $colors[2]);

        $string = implode(' ', str_split($string));

        if (!empty($font)) {
            for ($i = 0, $iMax = \strlen($string)$i < $iMax; ++$i) {
                $rand1 = Random::getInteger(35, 40);
                $rand2 = Random::getInteger(15, 20);
                $rand3 = Random::getInteger(60, 70);
                imagettftext($im$rand1$rand2($i + 1) * 15, $rand3$black$font$string[$i]);
                imagettftext($im$rand1$rand2(($i + 1) * 15) + 2, $rand3 + 2, $black$font$string[$i]);
            }
            for ($i = 0; $i < 8; ++$i) {
                imageline($im, Random::getInteger(30, 70), Random::getInteger(0, 50), Random::getInteger(100, 150),
                    Random::getInteger(20, 100)$black);
                imageline($im, Random::getInteger(30, 70), Random::getInteger(0, 50), Random::getInteger(100, 150),
                    Random::getInteger(20, 100)$black);
            }
        }
$this->_slowBackend->___expire($id);
    }

    private function _getFastFillingPercentage($mode)
    {

        if ($mode == 'saving') {
            // mode saving             if ($this->_fastBackendFillingPercentage === null) {
                $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
            } else {
                $rand = Shopware\Components\Random::getInteger(1, $this->_options['stats_update_factor']);
                if ($rand == 1) {
                    // we force a refresh                     $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
                }
            }
        } else {
            // mode loading             // we compute the percentage only if it's not available in cache             if ($this->_fastBackendFillingPercentage === null) {
                $this->_fastBackendFillingPercentage = $this->_fastBackend->getFillingPercentage();
            }
        }
return mb_substr(rtrim(base64_encode($bytes), '='), 0, $length, '8bit');
        }

        $listLen = mb_strlen($charlist, '8bit');

        if ($listLen === 1) {
            return str_repeat($charlist$length);
        }

        $result = '';
        for ($i = 0; $i < $length; ++$i) {
            $pos = static::getInteger(0, $listLen - 1);
            $result .= $charlist[$pos];
        }

        return $result;
    }

    /** * Generate a random alphanumeric string of specified length. * * Charlist: a-zA-Z0-9 * * @param int $length * * @throws DomainException * * @return string */
return false;
    }

    /** * Deal with the automatic vacuum process * * @return void */
    private function _automaticVacuum()
    {
        if ($this->_options['automatic_vacuum_factor'] > 0) {
            $rand = Shopware\Components\Random::getInteger(1, $this->_options['automatic_vacuum_factor']);
            if ($rand == 1) {
                $this->_query('VACUUM');
            }
        }
    }

    /** * Register a cache id with the given tag * * @param string $id Cache id * @param string $tag Tag * @return boolean True if no problem */

    }

    /** * Default callback for generating filenames * * @param Zend_Mail_Transport_File File transport instance * @return string */
    public function defaultCallback($transport)
    {
        return 'ZendMail_' . $_SERVER['REQUEST_TIME'] . '_' . Shopware\Components\Random::getInteger(0, PHP_INT_MAX) . '.tmp';
    }
}
if ($this->_options['automatic_serialization']) {
            // we need to serialize datas before storing them             $data = serialize($data);
        } else {
            if (!is_string($data)) {
                Zend_Cache::throwException('Datas must be string or set automatic_serialization = true');
            }
        }

        // automatic cleaning         if ($this->_options['automatic_cleaning_factor'] > 0) {
            $rand = Shopware\Components\Random::getInteger(1, $this->_options['automatic_cleaning_factor']);
            if ($rand == 1) {
                // new way || deprecated way                 if ($this->_extendedBackend || method_exists($this->_backend, 'isAutomaticCleaningAvailable')) {
                    $this->_log('Zend_Cache_Core::save(): automatic cleaning running', 7);
                    $this->clean(Zend_Cache::CLEANING_MODE_OLD);
                } else {
                    $this->_log('Zend_Cache_Core::save(): automatic cleaning is not available/necessary with current backend', 4);
                }
            }
        }

        
return;
        }

        $args->getSubject()->View()->assign('sLastArticlesShow', true);
    }

    /** * Removes entries from s_emarketing_lastarticles which are older than allowed by the configuration */
    private function cleanupLastProducts()
    {
        if (Random::getInteger(0, 100) === 0) {
            $time = (int) $this->container->get(Shopware_Components_Config::class)->get('lastarticles_time', 15);

            $sql = 'DELETE FROM s_emarketing_lastarticles WHERE `time` < DATE_SUB(CONCAT_WS(" ", CURDATE(), ?), INTERVAL ? DAY)';
            $this->container->get(\Doctrine\DBAL\Connection::class)->executeQuery($sql['00:00:00', $time]);

            $this->container->get('events')->notify('Shopware_Plugins_LastArticles_ResetLastArticles', ['subject' => $this]);
        }
    }

    /** * Creates a new s_emarketing_lastarticles entry for the passed article id. * * @param int $productId */

    public static function isInteger($value, array $options = array())
    {
        if (!self::isNumber($value$options)) {
            return false;
        }

        if (self::getInteger($value$options) == self::getFloat($value$options)) {
            return true;
        }

        return false;
    }

    /** * Converts a format string from PHP's date format to ISO format * Remember that Zend Date always returns localized string, so a month name which returns the english * month in php's date() will return the translated month name with this function... use 'en' as locale * if you are in need of the original english names * * The conversion has the following restrictions: * 'a', 'A' - Meridiem is not explicit upper/lowercase, you have to upper/lowercase the translated value yourself * * @param string $format Format string in PHP's date format * @return string Format string in ISO format */
return mb_substr(rtrim(base64_encode($bytes), '='), 0, $length, '8bit');
        }

        $listLen = mb_strlen($charlist, '8bit');

        if ($listLen === 1) {
            return str_repeat($charlist$length);
        }

        $result = '';
        for ($i = 0; $i < $length; ++$i) {
            $pos = static::getInteger(0, $listLen - 1);
            $result .= $charlist[$pos];
        }

        return $result;
    }

    /** * @see https://tools.ietf.org/html/rfc4648 */
    public static function getBase64UrlString(int $length): string
    {
        

    protected function _createUniqueId()
    {
        $id = '';
        $id .= function_exists('microtime') ? microtime(true) : (time() . ' ' . Shopware\Components\Random::getInteger(0, 100000));
        $id .= '.' . (function_exists('posix_getpid') ? posix_getpid() : Shopware\Components\Random::getInteger(50, 65535));
        $id .= '.' . php_uname('n');

        return $id;
    }

    /** * open a temporary maildir file * * makes sure tmp/ exists and create a file with a unique name * you should close the returned filehandle! * * @param string $folder name of current folder without leading . * @return array array('dirname' => dir of maildir folder, 'uniq' => unique id, 'filename' => name of create file * 'handle' => file opened for writing) * @throws Zend_Mail_Storage_Exception */


    /** * replaced all matching patterns * * @param array<string|int> $range */
    private function replaceAllMatchingPatterns(string $generatedCode, array $range, string $pattern): string
    {
        $allPatternsReplaced = false;
        while (!$allPatternsReplaced) {
            $generatedCode = (string) preg_replace('/\\' . $pattern . '/', (string) $range[Random::getInteger(1, \count($range) - 1)]$generatedCode, 1);
            $allPatternsReplaced = substr_count($generatedCode$pattern) == 0;
        }

        return $generatedCode;
    }

    /** * helper method to fast delete all voucher codes */
    private function deleteAllVoucherCodesById(int $voucherId): void
    {
        
$time = time();

        if ($this->_from !== null) {
            $user = $this->_from;
        } elseif (isset($_SERVER['REMOTE_ADDR'])) {
            $user = $_SERVER['REMOTE_ADDR'];
        } else {
            $user = getmypid();
        }

        $rand = Random::getInteger(0, PHP_INT_MAX);

        if ($this->_recipients !== array()) {
            $recipient = array_rand($this->_recipients);
        } else {
            $recipient = 'unknown';
        }

        $hostName = $this->messageIdHostName;
        if (!$hostName) {
            $hostName = (string) ($_SERVER['SERVER_NAME'] ?? '');
        }
        
Home | Imprint | This part of the site doesn't use cookies.