Your project should not use insecure random number functions 58

More information: https://insight.symfony.com/what-we-analyse/php.use_insecure_random_function

New rule! We've recently added this rule to Insight. Don't be surprised to see new suggestions even though the codebase didn't change.
  1. public function check(): bool
  2. {
  3. $CLICSHOPPING_MessageStack = Registry::get('MessageStack');
  4. if (isset($_GET[$this->_file])) {
  5. $temp_filename = 'temp_' . mt_rand(100000, 999999);
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. while (file_exists(CLICSHOPPING::BASE_DIR . 'Work/Temp/' . $temp_filename)) {
  7. $temp_filename = 'temp_' . mt_rand(100000, 999999);
  8. }
  1. if (isset($_GET[$this->_file])) {
  2. $temp_filename = 'temp_' . mt_rand(100000, 999999);
  3. while (file_exists(CLICSHOPPING::BASE_DIR . 'Work/Temp/' . $temp_filename)) {
  4. $temp_filename = 'temp_' . mt_rand(100000, 999999);
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  5. }
  6. $input = fopen('php://input', 'r');
  7. $size = file_put_contents(CLICSHOPPING::BASE_DIR . 'Work/Temp/' . $temp_filename, $input);
  1. $CLICSHOPPING_MessageStack = Registry::get('MessageStack');
  2. if ($this->_replace === true) {
  3. while (file_exists($this->_destination . DIRECTORY_SEPARATOR . $this->getFilename())) {
  4. $salt = md5(rand(1, 100000));
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  5. $salt = substr($salt, 0, 10);
  6. $this->setFilename($salt . '_' . $this->getFilename());
  7. }
  8. }
  1. // Boucle infinie pour l'envoi des événements
  2. while (true) {
  3. try {
  4. // Simulate random failure before computing data
  5. if ($sim_fail_rate > 0 && mt_rand(0, mt_getrandmax()) / mt_getrandmax() < $sim_fail_rate) {
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. throw new \Exception('Simulated failure');
  7. }
  8. // Récupérer les données de performance
  9. $data = $monitor->getPerformanceData($range);
  1. $data['metrics']['error_frequency'] = max(0.0, (float)$sim_error_pct);
  2. }
  3. }
  4. // Optionally force a random connection drop to test auto-reconnect
  5. if ($sim_drop && (mt_rand(1, 100) <= 5)) { // ~5% chance per tick
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. // Flush a final event then terminate the connection
  7. echo "event: error\n";
  8. echo "data: {\"error\":\"Simulated connection drop\"}\n\n";
  9. ob_flush();
  10. flush();
  1. $code_length = max(4, min(8, $code_length)); // Limiter entre 4 et 8
  2. $verification_code = '';
  3. for ($i = 0; $i < $code_length; $i++) {
  4. $verification_code .= mt_rand(0, 9);
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  5. }
  6. $expiry_minutes = defined('EMAIL_VERIFICATION_CODE_EXPIRY') ? (int)EMAIL_VERIFICATION_CODE_EXPIRY : 15;
  7. $expiry_time = date('Y-m-d H:i:s', time() + ($expiry_minutes * 60));
  1. */
  2. private function generateObjectiveId(): string
  3. {
  4. return sprintf(
  5. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0xffff),
  9. mt_rand(0, 0x0fff) | 0x4000,
  10. mt_rand(0, 0x3fff) | 0x8000,
  11. mt_rand(0, 0xffff),
  1. private function generateObjectiveId(): string
  2. {
  3. return sprintf(
  4. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0x0fff) | 0x4000,
  9. mt_rand(0, 0x3fff) | 0x8000,
  10. mt_rand(0, 0xffff),
  11. mt_rand(0, 0xffff),
  1. {
  2. return sprintf(
  3. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0x0fff) | 0x4000,
  8. mt_rand(0, 0x3fff) | 0x8000,
  9. mt_rand(0, 0xffff),
  10. mt_rand(0, 0xffff),
  11. mt_rand(0, 0xffff)
  1. return sprintf(
  2. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  3. mt_rand(0, 0xffff),
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0x0fff) | 0x4000,
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0x3fff) | 0x8000,
  8. mt_rand(0, 0xffff),
  9. mt_rand(0, 0xffff),
  10. mt_rand(0, 0xffff)
  11. );
  1. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  2. mt_rand(0, 0xffff),
  3. mt_rand(0, 0xffff),
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0x0fff) | 0x4000,
  6. mt_rand(0, 0x3fff) | 0x8000,
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0xffff),
  9. mt_rand(0, 0xffff)
  10. );
  11. }
  1. mt_rand(0, 0xffff),
  2. mt_rand(0, 0xffff),
  3. mt_rand(0, 0xffff),
  4. mt_rand(0, 0x0fff) | 0x4000,
  5. mt_rand(0, 0x3fff) | 0x8000,
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0xffff)
  9. );
  10. }
  1. mt_rand(0, 0xffff),
  2. mt_rand(0, 0xffff),
  3. mt_rand(0, 0x0fff) | 0x4000,
  4. mt_rand(0, 0x3fff) | 0x8000,
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff)
  8. );
  9. }
  10. /**
  1. mt_rand(0, 0xffff),
  2. mt_rand(0, 0x0fff) | 0x4000,
  3. mt_rand(0, 0x3fff) | 0x8000,
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff)
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. );
  8. }
  9. /**
  10. * Get the objective ID
  1. */
  2. private function generateEventId(): string
  3. {
  4. return sprintf(
  5. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0xffff),
  9. mt_rand(0, 0x0fff) | 0x4000,
  10. mt_rand(0, 0x3fff) | 0x8000,
  11. mt_rand(0, 0xffff),
  1. private function generateEventId(): string
  2. {
  3. return sprintf(
  4. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0x0fff) | 0x4000,
  9. mt_rand(0, 0x3fff) | 0x8000,
  10. mt_rand(0, 0xffff),
  11. mt_rand(0, 0xffff),
  1. {
  2. return sprintf(
  3. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0x0fff) | 0x4000,
  8. mt_rand(0, 0x3fff) | 0x8000,
  9. mt_rand(0, 0xffff),
  10. mt_rand(0, 0xffff),
  11. mt_rand(0, 0xffff)
  1. return sprintf(
  2. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  3. mt_rand(0, 0xffff),
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0x0fff) | 0x4000,
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0x3fff) | 0x8000,
  8. mt_rand(0, 0xffff),
  9. mt_rand(0, 0xffff),
  10. mt_rand(0, 0xffff)
  11. );
  1. '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  2. mt_rand(0, 0xffff),
  3. mt_rand(0, 0xffff),
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0x0fff) | 0x4000,
  6. mt_rand(0, 0x3fff) | 0x8000,
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0xffff),
  9. mt_rand(0, 0xffff)
  10. );
  11. }
  1. mt_rand(0, 0xffff),
  2. mt_rand(0, 0xffff),
  3. mt_rand(0, 0xffff),
  4. mt_rand(0, 0x0fff) | 0x4000,
  5. mt_rand(0, 0x3fff) | 0x8000,
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff),
  8. mt_rand(0, 0xffff)
  9. );
  10. }
  1. mt_rand(0, 0xffff),
  2. mt_rand(0, 0xffff),
  3. mt_rand(0, 0x0fff) | 0x4000,
  4. mt_rand(0, 0x3fff) | 0x8000,
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff),
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. mt_rand(0, 0xffff)
  8. );
  9. }
  10. /**
  1. mt_rand(0, 0xffff),
  2. mt_rand(0, 0x0fff) | 0x4000,
  3. mt_rand(0, 0x3fff) | 0x8000,
  4. mt_rand(0, 0xffff),
  5. mt_rand(0, 0xffff),
  6. mt_rand(0, 0xffff)
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. );
  8. }
  9. /**
  10. * Get security statistics for dashboard
  1. *
  2. * @return string The temporary password.
  3. */
  4. private function generateTemporaryPassword(): string
  5. {
  6. return substr(md5(uniqid(rand(), true)), 0, 8);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. }
  8. /**
  9. * Inserts the primary customer record into the :table_customers table.
  10. *
  1. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  2. $charactersLength = strlen($characters);
  3. $randomString = '';
  4. for ($i = 0; $i < $length; $i++) {
  5. $randomString .= $characters[rand(0, $charactersLength - 1)];
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. }
  7. return $randomString;
  8. }
  9. /**
  1. * @return string The sanitized or generated product model.
  2. */
  3. public function getProductModel(): string
  4. {
  5. if (empty($_POST['products_model'])) {
  6. $rand = rand();
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. $products_model = \defined('CONFIGURATION_PREFIX_MODEL') ? CONFIGURATION_PREFIX_MODEL . $rand : '';
  8. } else {
  9. $products_model = HTML::sanitize($_POST['products_model']);
  10. }
  1. *
  2. * @return string Returns the anti-spam numeric confirmation string for display or verification purposes.
  3. */
  4. public static function getConfirmationNumericAntiSpam(): string
  5. {
  6. $random_number = rand(1, 200);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. $number = $random_number + 3;
  8. $antispam = ' (' . $random_number . ' + ' . CLICSHOPPING::getDef('text_antispam') . ') x 1';
  9. $_SESSION['createResponseAntiSpam'] = md5($number);
  1. *
  2. * @return string The temporary password.
  3. */
  4. private function generateTemporaryPassword(): string
  5. {
  6. return substr(md5(uniqid(rand(), true)), 0, 8);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by clicshopping
  7. }
  8. /**
  9. * Inserts the primary customer record into the :table_customers table.
  10. *
  1. $error = true;
  2. $CLICSHOPPING_MessageStack->add($CLICSHOPPING_Customers->getDef('error_email_address_exist'), 'error');
  3. }
  4. if ($error === false) {
  5. $customers_password = 'clicshopping_' . rand(5, 500);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. // Autorisation aux clients de modifier informations societe et adresse principal + Ajout adresse
  7. if ($customers_modify_company !== 1) {
  8. $customers_modify_company = 0;
  9. }
  1. */
  2. public function getPerformanceData(string $range = '24h'): array
  3. {
  4. // Generate current metrics
  5. $metrics = [
  6. 'request_rate' => rand(20, 80),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'average_latency' => rand(100, 300),
  8. 'error_frequency' => rand(0, 10),
  9. 'uptime_percentage' => rand(95, 100),
  10. 'total_requests' => rand(1000, 5000)
  11. ];
  1. public function getPerformanceData(string $range = '24h'): array
  2. {
  3. // Generate current metrics
  4. $metrics = [
  5. 'request_rate' => rand(20, 80),
  6. 'average_latency' => rand(100, 300),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'error_frequency' => rand(0, 10),
  8. 'uptime_percentage' => rand(95, 100),
  9. 'total_requests' => rand(1000, 5000)
  10. ];
  1. {
  2. // Generate current metrics
  3. $metrics = [
  4. 'request_rate' => rand(20, 80),
  5. 'average_latency' => rand(100, 300),
  6. 'error_frequency' => rand(0, 10),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'uptime_percentage' => rand(95, 100),
  8. 'total_requests' => rand(1000, 5000)
  9. ];
  10. // Store current metrics for persistence
  1. // Generate current metrics
  2. $metrics = [
  3. 'request_rate' => rand(20, 80),
  4. 'average_latency' => rand(100, 300),
  5. 'error_frequency' => rand(0, 10),
  6. 'uptime_percentage' => rand(95, 100),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'total_requests' => rand(1000, 5000)
  8. ];
  9. // Store current metrics for persistence
  10. $this->historyStorage->storeMetrics($metrics);
  1. $metrics = [
  2. 'request_rate' => rand(20, 80),
  3. 'average_latency' => rand(100, 300),
  4. 'error_frequency' => rand(0, 10),
  5. 'uptime_percentage' => rand(95, 100),
  6. 'total_requests' => rand(1000, 5000)
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. ];
  8. // Store current metrics for persistence
  9. $this->historyStorage->storeMetrics($metrics);
  1. for ($i = 0; $i < $points; $i++) {
  2. $timestamp = $baseTime - ($i * $interval);
  3. $history[] = [
  4. 'timestamp' => $timestamp,
  5. 'latency' => rand(50, 200),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. 'error_rate' => rand(0, 5),
  7. 'requests' => rand(10, 50),
  8. 'uptime' => rand(95, 100)
  9. ];
  10. }
  1. for ($i = 0; $i < $points; $i++) {
  2. $timestamp = $baseTime - ($i * $interval);
  3. $history[] = [
  4. 'timestamp' => $timestamp,
  5. 'latency' => rand(50, 200),
  6. 'error_rate' => rand(0, 5),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'requests' => rand(10, 50),
  8. 'uptime' => rand(95, 100)
  9. ];
  10. }
  1. $timestamp = $baseTime - ($i * $interval);
  2. $history[] = [
  3. 'timestamp' => $timestamp,
  4. 'latency' => rand(50, 200),
  5. 'error_rate' => rand(0, 5),
  6. 'requests' => rand(10, 50),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'uptime' => rand(95, 100)
  8. ];
  9. }
  10. return array_reverse($history);
  1. $history[] = [
  2. 'timestamp' => $timestamp,
  3. 'latency' => rand(50, 200),
  4. 'error_rate' => rand(0, 5),
  5. 'requests' => rand(10, 50),
  6. 'uptime' => rand(95, 100)
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. ];
  8. }
  9. return array_reverse($history);
  10. }
  1. {
  2. $now = time();
  3. for ($i = 100; $i > 0; $i--) {
  4. $this->performanceHistory[] = [
  5. 'timestamp' => $now - ($i * 900), // Every 15 minutes
  6. 'requests' => rand(100, 1000),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'latency' => rand(50, 200),
  8. 'error_rate' => rand(0, 5),
  9. 'status' => rand(1, 100) > 98 ? 'down' : 'up'
  10. ];
  11. }
  1. $now = time();
  2. for ($i = 100; $i > 0; $i--) {
  3. $this->performanceHistory[] = [
  4. 'timestamp' => $now - ($i * 900), // Every 15 minutes
  5. 'requests' => rand(100, 1000),
  6. 'latency' => rand(50, 200),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'error_rate' => rand(0, 5),
  8. 'status' => rand(1, 100) > 98 ? 'down' : 'up'
  9. ];
  10. }
  11. }
  1. for ($i = 100; $i > 0; $i--) {
  2. $this->performanceHistory[] = [
  3. 'timestamp' => $now - ($i * 900), // Every 15 minutes
  4. 'requests' => rand(100, 1000),
  5. 'latency' => rand(50, 200),
  6. 'error_rate' => rand(0, 5),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'status' => rand(1, 100) > 98 ? 'down' : 'up'
  8. ];
  9. }
  10. }
  11. }
  1. $this->performanceHistory[] = [
  2. 'timestamp' => $now - ($i * 900), // Every 15 minutes
  3. 'requests' => rand(100, 1000),
  4. 'latency' => rand(50, 200),
  5. 'error_rate' => rand(0, 5),
  6. 'status' => rand(1, 100) > 98 ? 'down' : 'up'
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. ];
  8. }
  9. }
  10. }
  1. */
  2. private function getTotalRequests(): int
  3. {
  4. // In a real implementation, this would query the database
  5. // For simulation, return a random number
  6. return rand(100, 1000);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. }
  8. /**
  9. * Gets the error count (simulated).
  10. *
  1. * @return int The error count.
  2. */
  3. private function getErrorCount(): int
  4. {
  5. // Simulate low error count for healthy status
  6. return rand(0, 5);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. }
  8. /**
  9. * Gets the average response time (simulated).
  10. *
  1. *
  2. * @return float The average response time in milliseconds.
  3. */
  4. private function getAverageResponseTime(): float
  5. {
  6. return round(rand(100, 800) / 10, 2);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. }
  8. /**
  9. * Gets the requests per minute (simulated).
  10. *
  1. *
  2. * @return int The number of requests per minute.
  3. */
  4. private function getRequestsPerMinute(): int
  5. {
  6. return rand(10, 100);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. }
  8. /**
  9. * Gets memory usage information.
  10. *
  1. * @return float The CPU usage percentage.
  2. */
  3. private function getCpuUsage(): float
  4. {
  5. // Simulate CPU usage
  6. return round(rand(10, 80) / 10, 1);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. }
  8. /**
  9. * Gets disk space information.
  10. *
  1. // Simulate response time history
  2. $history = [];
  3. for ($i = 0; $i < 24; $i++) {
  4. $history[] = [
  5. 'hour' => $i,
  6. 'avg_response_time' => rand(100, 800) / 10
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. ];
  8. }
  9. return $history;
  10. }
  1. private function getErrorTrends(): array
  2. {
  3. // Simulate error trends
  4. return [
  5. 'hourly' => array_map(function ($hour) {
  6. return ['hour' => $hour, 'errors' => rand(0, 5)];
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. }, range(0, 23)),
  8. 'daily' => array_map(function ($day) {
  9. return ['day' => $day, 'errors' => rand(0, 50)];
  10. }, range(1, 7))
  11. ];
  1. return [
  2. 'hourly' => array_map(function ($hour) {
  3. return ['hour' => $hour, 'errors' => rand(0, 5)];
  4. }, range(0, 23)),
  5. 'daily' => array_map(function ($day) {
  6. return ['day' => $day, 'errors' => rand(0, 50)];
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. }, range(1, 7))
  8. ];
  9. }
  10. /**
  1. */
  2. private function getUsagePatterns(): array
  3. {
  4. return [
  5. 'peak_hours' => [9, 10, 11, 14, 15, 16],
  6. 'avg_concurrent_users' => rand(10, 100),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. 'most_used_endpoints' => [
  8. '/api/chat' => rand(100, 500),
  9. '/api/status' => rand(50, 200),
  10. '/api/health' => rand(20, 100)
  11. ]
  1. {
  2. return [
  3. 'peak_hours' => [9, 10, 11, 14, 15, 16],
  4. 'avg_concurrent_users' => rand(10, 100),
  5. 'most_used_endpoints' => [
  6. '/api/chat' => rand(100, 500),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. '/api/status' => rand(50, 200),
  8. '/api/health' => rand(20, 100)
  9. ]
  10. ];
  11. }
  1. return [
  2. 'peak_hours' => [9, 10, 11, 14, 15, 16],
  3. 'avg_concurrent_users' => rand(10, 100),
  4. 'most_used_endpoints' => [
  5. '/api/chat' => rand(100, 500),
  6. '/api/status' => rand(50, 200),
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. '/api/health' => rand(20, 100)
  8. ]
  9. ];
  10. }
  1. 'peak_hours' => [9, 10, 11, 14, 15, 16],
  2. 'avg_concurrent_users' => rand(10, 100),
  3. 'most_used_endpoints' => [
  4. '/api/chat' => rand(100, 500),
  5. '/api/status' => rand(50, 200),
  6. '/api/health' => rand(20, 100)
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. ]
  8. ];
  9. }
  10. /**
  1. * @param array $data The order data.
  2. * @return void
  3. */
  4. protected function createOrder(array $data): void
  5. {
  6. $orderId = rand(1000, 9999);
    The function rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  7. $this->message->sendSuccess(['action' => 'create_order', 'order_id' => $orderId]);
  8. }
  9. /**
  10. * Updates an existing order. Placeholder method.
  1. } catch (Exception $e) {
  2. if ($secure === true) {
  3. throw $e;
  4. }
  5. $result = mt_rand($min, $max);
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. }
  7. return $result;
  8. }
  1. $code_length = max(4, min(8, $code_length)); // Limiter entre 4 et 8
  2. $verification_code = '';
  3. for ($i = 0; $i < $code_length; $i++) {
  4. $verification_code .= mt_rand(0, 9);
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  5. }
  6. $expiry_minutes = defined('EMAIL_VERIFICATION_CODE_EXPIRY') ? (int)EMAIL_VERIFICATION_CODE_EXPIRY : 15;
  7. $expiry_time = date('Y-m-d H:i:s', time() + ($expiry_minutes * 60));
  1. $code_length = max(4, min(8, $code_length)); // Limiter entre 4 et 8
  2. $verification_code = '';
  3. for ($i = 0; $i < $code_length; $i++) {
  4. $verification_code .= mt_rand(0, 9);
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  5. }
  6. $expiry_minutes = defined('EMAIL_VERIFICATION_CODE_EXPIRY') ? (int)EMAIL_VERIFICATION_CODE_EXPIRY : 15;
  7. $expiry_time = date('Y-m-d H:i:s', time() + ($expiry_minutes * 60));
  1. $code_length = defined('EMAIL_VERIFICATION_CODE_LENGTH') ? (int)EMAIL_VERIFICATION_CODE_LENGTH : 6;
  2. $code_length = max(4, min(8, $code_length));
  3. $verification_code = '';
  4. for ($i = 0; $i < $code_length; $i++) {
  5. $verification_code .= mt_rand(0, 9);
    The function mt_rand() is not cryptographically secure. Use random_int() or random_bytes() instead.
    Last edited by ClicShopping
  6. }
  7. // Durée d'expiration
  8. $expiry_minutes = defined('EMAIL_VERIFICATION_CODE_EXPIRY') ? (int)EMAIL_VERIFICATION_CODE_EXPIRY : 15;