100+ results for 'php mt_rand'

Not the results you expected?

acl0005Test.php (https://github.com/gnomeontherun/joomla-cms.git) PHP · 428 lines

1 <?php

2 /**

3 * @package Joomla.SystemTest

6 * Tests admin login permissions per global configuration permission settings.

7 */

8 require_once 'SeleniumJoomlaTestCase.php';

9

10 class Acl0005Test extends SeleniumJoomlaTestCase

17

18 //Set random salt

19 $salt = mt_rand();

20

21 //Set message to be checked

49 try {

50 $this->assertTrue($this->isElementPresent("link=Log out"));

51 } catch (PHPUnit_Framework_AssertionFailedError $e){

52 array_push($this->verificationErrors, $this->getTraceFiles($e));

53 }

DirectoryResourceTest.php (https://gitlab.com/ViniciusP/project-games) PHP · 166 lines

1 <?php

2

3 /*

14 use Symfony\Component\Config\Resource\DirectoryResource;

15

16 class DirectoryResourceTest extends \PHPUnit_Framework_TestCase

17 {

18 protected $directory;

69 $this->assertFalse($resource->isFresh(time() - 86400), '->isFresh() returns false if the resource has been updated');

70

71 $resource = new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));

72 $this->assertFalse($resource->isFresh(time()), '->isFresh() returns false if the resource does not exist');

73 }

LoginController.php (https://gitlab.com/yutdhidev_labs/webku) PHP · 165 lines

1 <?php

2 namespace App\Http\Controllers;

3 use Illuminate\Http\Request;

36 // $exp = explode(" ",str_replace("'","",$request->name));

37 // $characters = '0123456789';

38 // $pin = mt_rand(1, 999);

39

40 // if(count($exp) > 1){

125

126 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

127 $pin = mt_rand(1000000, 9999999).$characters[rand(0, strlen($characters) - 1)];

128 $string = str_shuffle($pin);

129

db.php (https://github.com/enygma/fuel.git) PHP · 260 lines

1 <?php

2 /**

3 * Fuel

4 *

5 * Fuel is a fast, lightweight, community driven PHP5 framework.

6 *

7 * @package Fuel

10 * @license MIT License

11 * @copyright 2010 Dan Horrigan

12 * @link http://fuelphp.com

13 */

14

156

157 // do some garbage collection

158 if (mt_rand(0,100) < $this->config['gc_probability'])

159 {

160 $expired = $this->time->get_timestamp() - $this->config['expiration_time'];

criterias_document.test.php (https://github.com/cgajardo/repositorium.git) PHP · 238 lines

1 <?php

2 /* CriteriasDocument Test cases generated on: 2011-08-06 19:00:58 : 1312671658*/

3 App::import('Model', 'CriteriasDocument');

58

59 function testGetRandomDocumentsValidated() {

60 $criteria_id = mt_rand(1,$this->criteria_qty);

61 $confirmado = true;

62 $preguntable = true;

80

81 function testGetRandomDocumentsNonValidated() {

82 $criteria_id = mt_rand(1,$this->criteria_qty);

83 $confirmado = false;

84 $preguntable = true;

NodeSaveTest.php (git://github.com/drupal/drupal.git) PHP · 183 lines

1 <?php

2

3 namespace Drupal\node\Tests;

50 ->execute();

51 $max_nid = reset($nids);

52 $test_nid = $max_nid + mt_rand(1000, 1000000);

53 $title = $this->randomMachineName(8);

54 $node = array(

Hash.php (https://bitbucket.org/Ebozavrik/test-application.git) PHP · 271 lines

1 <?php

2 /**

3 * Zend Framework

21

22 /** Zend_Form_Element_Xhtml */

23 require_once 'Zend/Form/Element/Xhtml.php';

24

25 /**

31 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)

32 * @license http://framework.zend.com/license/new-bsd New BSD License

33 * @version $Id: Hash.php 24593 2012-01-05 20:35:02Z matthew $

34 */

35 class Zend_Form_Element_Hash extends Zend_Form_Element_Xhtml

109 {

110 if (null === $this->_session) {

111 require_once 'Zend/Session/Namespace.php';

112 $this->_session = new Zend_Session_Namespace( $this->getSessionName() );

113 }

CryptUtil.php (https://github.com/LamCiuLoeng/BookShare.git) PHP · 109 lines

1 <?php

2

3 /**

5 * library.

6 *

7 * PHP versions 4 and 5

8 *

9 * LICENSE: See the COPYING file included in this distribution.

58 $bytes = '';

59 for ($i = 0; $i < $num_bytes; $i += 4) {

60 $bytes .= pack('L', mt_rand());

61 }

62 $bytes = substr($bytes, 0, $num_bytes);

simple.php (https://github.com/square-one/square-one-cms.git) PHP · 288 lines

1 <?php

2 /**

3 * @package Joomla.Platform

143 for ($i = 0; $i < $length; $i++)

144 {

145 $key .= $salt[mt_rand(0, $saltLength - 1)];

146 }

147

log.php (https://github.com/koto/blog-kotowicz-net-examples.git) PHP · 95 lines

1 <?php

2 require_once 'Upload_Client.php';

63 case 'upload-file':

64 if (!empty($_FILES['contents']) && array_key_exists('fileid', $_POST) && $client->hasFile($_POST['fileid'])) { // process file upload

65 $uniq = "file-" . md5(mt_rand() . uniqid());

66 $match = array();

67 if (preg_match('#\/(jpe?g|gif|png|pdf)$#i', $_POST['type'], $match)) { // images and pdf are "safe" to serve

AdsConversionAction.php (https://gitlab.com/remyvianne/krowkaramel) PHP · 177 lines

1 <?php

2 declare( strict_types=1 );

3

55 public function create_conversion_action(): array {

56 try {

57 $unique = sprintf( '%04x', mt_rand( 0, 0xffff ) );

58

59 $conversion_action_operation = new ConversionActionOperation();

twitter.php (https://bitbucket.org/jonphipps/elefant-vocabhub.git) PHP · 111 lines

1 <?php

2

3 /**

15 ));

16

17 $here = tmhUtilities::php_self ();

18 if (strpos ($here, '?redirect=') === false) {

19 $here .= '?redirect=' . urlencode ($_GET['redirect']);

38 if ($u) {

39 // already have an account, log them in

40 $u->session_id = md5 (uniqid (mt_rand (), 1));

41 $u->expires = gmdate ('Y-m-d H:i:s', time () + 2592000);

42 $try = 0;

43 while (! $u->put ()) {

44 $u->session_id = md5 (uniqid (mt_rand (), 1));

45 $try++;

46 if ($try == 5) {

email.reservation.php (https://gitlab.com/Nightprince/Warcry-CMS) PHP · 235 lines

1 <?php

2 if (!defined('init_engine'))

3 {

17 {

18 //generate the key

19 $key = uniqid(mt_rand(), true) . uniqid(mt_rand(), true);

20

21 //strip dots

NodeSaveTest.php (https://bitbucket.org/diegoe87/challenge-dc.git) PHP · 182 lines

1 <?php

2

3 namespace Drupal\Tests\node\Functional;

50 ->execute();

51 $max_nid = reset($nids);

52 $test_nid = $max_nid + mt_rand(1000, 1000000);

53 $title = $this->randomMachineName(8);

54 $node = [

Upload.php (https://github.com/houdunwang/video.git) PHP · 230 lines

1 <?php

2 /** .-------------------------------------------------------------------

3 * | Software: [HDCMS framework]

8 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.

9 * '-------------------------------------------------------------------*/

10 namespace hdphp\upload;

11

12 class Upload {

93 */

94 private function save( $file ) {

95 $fileName = mt_rand( 1, 9999 ) . time() . "." . $file['ext'];

96 $filePath = $this->path . '/' . $fileName;

97 if ( ! move_uploaded_file( $file ['tmp_name'], $filePath ) && is_file( $filePath ) ) {

198 switch ( $error ) {

199 case UPLOAD_ERR_INI_SIZE :

200 $this->error = '上传文件超过PHP.INI配置文件允许的大小';

201 break;

202 case UPLOAD_ERR_FORM_SIZE :

string_helper.php (https://github.com/holsinger/openfloor.git) PHP · 154 lines

1 <?php if (!defined('BASEPATH')) exit('No direct script access allowed');

2 /**

3 * CodeIgniter

4 *

5 * An open source application development framework for PHP 4.3.2 or newer

6 *

7 * @package CodeIgniter

56 * except those found in http://

57 *

58 * http://www.some-site.com//index.php

59 *

60 * becomes:

61 *

62 * http://www.some-site.com/index.php

63 *

64 * @access public

Math.php (https://github.com/jaws-project/jaws.git) PHP · 125 lines

1 <?php

2 /**

3 * Math captcha

6 * @package Core

7 * @author Pablo Fischer <pablo@pablo.com.mx>

8 * @author Ali Fazelzadeh <afz@php.net>

9 * @copyright 2006-2022 Jaws Development Group

10 * @license http://www.gnu.org/copyleft/lesser.html

51 function randomEquation()

52 {

53 $fnum = mt_rand(1, 9);

54 $snum = mt_rand(1, 9);

55 $oprt = mt_rand(0, 2);

56 $utf8_offset = $this->app->registry->fetch('captcha_math_offset', 'Policy');

57 $operations = array(

function_happyhour.php (https://github.com/cybernet/CyBerFuN-CoDeX.git) PHP · 101 lines

1 <?php

2 if(!defined('PUBLIC_ACCESS')) die('Fuck off - You cant access scripts directly fool !');

3 //made by putyn @tbdev 06.11.2008

8 {

9 $nextDay = date("Y-m-d" , time()+86400 );

10 $nextHoura = mt_rand(0,2);

11 if ($nextHoura == 2)

12 $nextHourb = mt_rand(0,3);

13 else

14 $nextHourb = mt_rand(0,9);

15 $nextHour = $nextHoura.$nextHourb;

16 $nextMina = mt_rand(0,5);

17 $nextMinb = mt_rand(0,9);

18 $nextMin = $nextMina.$nextMinb;

19 $happyHour = $nextDay." ".$nextHour.":".$nextMin."";

Guid.php (https://github.com/WebTricks/WebTricks-CMS.git) PHP · 208 lines

1 <?php

2 /**

3 * WebTricks - PHP Framework

95 for ($i = 0; $i < 16; $i++) {

96 if ($i == 6) { // Version field (version 4)

97 $b = mt_rand(0, 15) | 64;

98 } else if ($i == 8) { // Variant field (type 2)

99 $b = mt_rand(0, 63) | 128;

100 } else {

101 $b = mt_rand(0, 255);

102 }

103 $bytes[] = $b;

acl0001Test.php (https://github.com/chdemko/joomla-cms.git) PHP · 288 lines

1 <?php

2 /**

3 * @version $Id$

7 * Creates test group and assigns priviledges with the ACL.

8 */

9 require_once 'SeleniumJoomlaTestCase.php';

10

11 class Acl0001Test extends SeleniumJoomlaTestCase

21 $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-users']"), 'User manager should be visible');

22 }

23 catch (PHPUnit_Framework_AssertionFailedError $e)

24 {

25 array_push($this->verificationErrors, $this->getTraceFiles($e));

30 $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-groups']"), 'Groups should be visible');

31 }

32 catch (PHPUnit_Framework_AssertionFailedError $e)

33 {

34 array_push($this->verificationErrors, $this->getTraceFiles($e));

OrderSearchControllerTest.php (https://github.com/ladybirdweb/agorainvoicing.git) PHP · 167 lines

1 <?php

2

3 namespace Tests\Unit\Admin\Order;

162 $product = Product::create(['name'=>'Helpdesk'.$version]);

163 $order = Order::create(['client'=> $this->user->id, 'order_status' => 'executed',

164 'product'=> $product->id, 'number'=> mt_rand(100000, 999999), ]);

165 Subscription::create(['order_id'=>$order->id, 'product_id'=> $product->id, 'version'=>$version]);

166 }

voucher.php (https://bitbucket.org/jojoluzifer/gold-light-project.git) PHP · 263 lines

1 <?php

2 class ControllerAccountVoucher extends Controller {

3 private $error = array();

13

14 if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {

15 $this->session->data['vouchers'][mt_rand()] = array(

16 'description' => sprintf($this->language->get('text_for'), $this->currency->format($this->currency->convert($this->request->post['amount'], $this->currency->getCode(), $this->config->get('config_currency'))), $this->request->post['to_name']),

17 'to_name' => $this->request->post['to_name'],

class.wp-pass.php (https://bitbucket.org/Red54/dianjihun.git) PHP · 141 lines

1 <?php

2 // Last sync [WP10712] - Refactored into a class from wp-incldues/pluggable.php

10 *

11 * @since WP 2.5

12 * @global object $wp_hasher PHPass object

13 * @uses PasswordHash::HashPassword

14 *

20

21 if ( empty($wp_hasher) ) {

22 require_once( BACKPRESS_PATH . 'class.passwordhash.php');

23 // By default, use the portable hash from phpass

32 *

33 * Maintains compatibility between old version and the new cookie authentication

34 * protocol using PHPass library. The $hash parameter is the encrypted password

35 * and the function compares the plain text password when encypted similarly

36 * against the already encrypted password to see if they match.

doomcounter.php (https://github.com/Xkeeper0/jul.git) PHP · 163 lines

1 <?php

2

3 if (!$_GET['notice']) {

14

15 # for ($i = 0; $i < 10; $i++) {

16 # $offsets[$i] = mt_rand(-1, 3);

17 # }

18

92 for ($y = 0; $y < 19; $y++) {

93 $xofs = 0;

94 if (mt_rand(0, 10) < 1) {

95 // $xofs = mt_rand(-15, 15);

96 $xofs = mt_rand(-1, 1);

97 // $xofs = 1;

98 }

Profiler.php (https://gitlab.com/fabian.morales/marlon_becerra) PHP · 295 lines

1 <?php

2

3 /*

176 * @return array An array of tokens

177 *

178 * @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats

179 */

180 public function find($ip, $url, $limit, $method, $start, $end)

198 }

199

200 $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));

201 $profile->setTime(time());

202 $profile->setUrl($request->getUri());

DiscISAM.php (https://github.com/Borluse/ProjetOption.git) PHP · 143 lines

1 <?php

2 /**

3 * PHPExcel

4 *

5 * Copyright (c) 2006 - 2010 PHPExcel

22 * @package PHPExcel_CachedObjectStorage

23 * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)

24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL

25 * @version 1.7.3c, 2010-06-01

32 * @category PHPExcel

33 * @package PHPExcel_CachedObjectStorage

34 * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)

35 */

36 class PHPExcel_CachedObjectStorage_DiscISAM extends PHPExcel_CachedObjectStorage_CacheBase implements PHPExcel_CachedObjectStorage_ICache {

37

38 private $_fileName = null;

peering2.php (https://github.com/mbj/zguide.git) PHP · 202 lines

1 <?php

2 /*

3 * Broker peering simulation (part 2)

5 * @author Ian Barber <ian(dot)barber(at)gmail(dot)com>

6 */

7 include "zmsg.php";

8

9 define("NBR_CLIENTS", 10);

21 $client->send("HELLO");

22 $reply = $client->recv();

23 printf("I: client status: %s%s", $reply, PHP_EOL);

24 }

25 }

40

41 sleep(1);

42 $zmsg->body_fmt("OK - %04x", mt_rand(0, 0x10000));

43 $zmsg->send();

44 }

index.php (https://code.google.com/p/maxsite/) PHP · 148 lines

1 <?php if (!defined('BASEPATH')) exit('No direct script access allowed');

2

3 /**

140

141 $text = explode("\n", $text);

142 $out = trim($text[ mt_rand(0, count($text) - 1) ] );

143

144 return $arg['header'] . $arg['block_start'] . $out . $arg['block_end'];

ProxmoxController.php (https://github.com/MercyCloudTeam/TomatoIDC.git) PHP · 212 lines

1 <?php

2

3 namespace App\Http\Controllers\Server;

153 $node = $configure->customip ?? "pve";

154 $osTemplate = $configure->template ?? null;

155 $vmid = mt_rand(10,99).substr(time(),7).mt_rand(100,999);

156 $param['form_params']=[

157 'ostemplate'=>$osTemplate,

file.php (https://github.com/akutaktau/feedmalaya.git) PHP · 351 lines

1 <?php

2 /**

3 * Fuel

4 *

5 * Fuel is a fast, lightweight, community driven PHP5 framework.

6 *

7 * @package Fuel

10 * @license MIT License

11 * @copyright 2010 - 2011 Fuel Development Team

12 * @link http://fuelphp.com

13 */

14

166

167 // do some garbage collection

168 if (mt_rand(0,100) < $this->config['gc_probability'])

169 {

170 if ($handle = opendir($this->config['path']))

User.php (https://gitlab.com/gothcon/cthulhu) PHP · 217 lines

1 <?php

2 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "ReadWriteEntity.php");

133 for($i = 0; $i < $length;$i++)

134 {

135 $string .= $allchar[mt_rand(0,$allCharCount-1)];

136 }

137 return $string;

Request.php (https://github.com/friendica/friendica-addons.git) PHP · 289 lines

1 <?php

2

3 /**

31 ) {

32 $parameters = array_merge(

33 Util::parseParameters(parse_url($httpUrl, PHP_URL_QUERY)),

34 $parameters

35 );

285 public static function generateNonce(): string

286 {

287 return md5(microtime() . mt_rand());

288 }

289 }

menu0002Test.php (https://github.com/mathc/joomla-cms.git) PHP · 227 lines

1 <?php

2 /**

3 * @version $Id$

7 * Creates test group and assigns priviledges with the ACL.

8 */

9 require_once 'SeleniumJoomlaTestCase.php';

10

11 class Menu0002 extends SeleniumJoomlaTestCase

138 $this->waitForPageToLoad("30000");

139

140 $saltGroup = mt_rand();

141

142 $this->type("jform_title", "Test Menu Item" . $saltGroup);

class-fs-user-lock.php (https://github.com/livinglab/openlab.git) PHP · 126 lines

1 <?php

2 /**

3 * @package Freemius

51 private function __construct() {

52 $this->_wp_user_id = Freemius::get_current_wp_user_id();

53 $this->_thread_id = mt_rand( 0, 32000 );

54 }

55

Cache.php (https://github.com/imr/horde.git) PHP · 421 lines

1 <?php

2 /**

3 * A cache backend for Kolab storage list handlers.

4 *

5 * PHP version 5

6 *

7 * @category Kolab

9 * @author Gunnar Wrobel <wrobel@pardus.de>

10 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1

11 * @link http://pear.horde.org/index.php?package=Kolab_Storage

12 */

13

24 * @author Gunnar Wrobel <wrobel@pardus.de>

25 * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1

26 * @link http://pear.horde.org/index.php?package=Kolab_Storage

27 */

28 class Horde_Kolab_Storage_List_Cache

Liquid.php (https://gitlab.com/Skull3x/ClearSky) PHP · 437 lines

1 <?php

2 namespace pocketmine\block;

3

213 }

214

215 if($this instanceof Lava and $decay < 8 and $k < 8 and $k > 1 and mt_rand(0, 4) !== 0){

216 $k = $decay;

217 $flag = false;

PHP.php (https://gitlab.com/link233/bootmw) PHP · 241 lines

1 <?php

2

3 namespace Cdb\Writer;

8

9 /**

10 * This is a port of D.J. Bernstein's CDB to PHP. It's based on the copy that

11 * appears in PHP 5.3. Changes are:

35 * CDB writer class

36 */

37 class PHP extends Writer {

38 protected $hplist;

39

47 public function __construct( $fileName ) {

48 $this->realFileName = $fileName;

49 $this->tmpFileName = $fileName . '.tmp.' . mt_rand( 0, 0x7fffffff );

50 $this->handle = fopen( $this->tmpFileName, 'wb' );

51 if ( !$this->handle ) {

PrettyPrinterAbstract.php (https://gitlab.com/oytunistrator/92five) PHP · 262 lines

118 * Preprocesses the top-level nodes to initialize pretty printer state.

119 *

120 * @param PHPParser_Node[] $nodes Array of nodes

121 */

122 protected function preprocessNodes(array $nodes) {

133 * Pretty prints an array of nodes (statements) and indents them optionally.

134 *

135 * @param PHPParser_Node[] $nodes Array of nodes

136 * @param bool $indent Whether to indent the printed nodes

137 *

168 }

169

170 protected function pInfixOp($type, PHPParser_Node $leftNode, $operatorString, PHPParser_Node $rightNode) {

171 list($precedence, $associativity) = $this->precedenceMap[$type];

172

test.php (https://github.com/trueos/lumina.git) PHP · 224 lines

19 public function __construct()

20 {

21 $this->uniqId = '<php-mail-' . md5(microtime()) . mt_rand() . '@git.php.net>';

22 }

23

24 /**

25 * Return unique id of mail

26 * @return string unique Id of message in format: '<php-mail-...@git.php.net';

27 */

28 public function getId()

33 /**

34 * Add parent mail for this mail

35 * @param string $uniqId unique Id of message in format: '<php-mail-...@git.php.net';

36 */

37 public function addReplyTo($uniqId)

redirect.php (https://github.com/ot2sen/Molajo.git) PHP · 300 lines

1 <?php

2 /**

3 * @version controller.php

133 if (MolajoFactory::getApplication()->getName() == 'site') {

134 if ($this->id == 0) {

135 $this->redirectSuccess = 'index.php';

136 } else {

137 $this->redirectSuccess = 'index.php?option='.JRequest::getCmd('option').'&view='.JRequest::getCmd('DefaultView').'&id='.$this->id.$extension.$component_specific;

138 }

139 } else {

140 $this->redirectSuccess = 'index.php?option='.JRequest::getCmd('option').'&view='.JRequest::getCmd('DefaultView').'&id='.$this->id.$extension.$component_specific;

141 }

142 $this->redirectReturn = $this->redirectSuccess;

146 /** multiple controller tasks **/

147 if (JRequest::getCmd('controller') == JRequest::getCmd('DefaultView')) {

148 $this->redirectSuccess = 'index.php?option='.JRequest::getCmd('option').'&view='.JRequest::getCmd('DefaultView').$extension.$component_specific;

149 $this->redirectReturn = $this->redirectSuccess;

150 return;

SecureRandom.php (https://gitlab.com/TouirMohamedMarwen/Symfony2) PHP · 114 lines

1 <?php

2

3 /*

44

45 // determine whether to use OpenSSL

46 if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 50304) {

47 $this->useOpenSsl = false;

48 } elseif (!function_exists('openssl_random_pseudo_bytes')) {

83 list($this->seed, $this->seedLastUpdatedAt) = $this->readSeed();

84 } else {

85 $this->seed = uniqid(mt_rand(), true);

86 $this->updateSeed();

87 }

91 while (strlen($bytes) < $nbBytes) {

92 static $incr = 1;

93 $bytes .= hash('sha512', $incr++.$this->seed.uniqid(mt_rand(), true).$nbBytes, true);

94 $this->seed = base64_encode(hash('sha512', $this->seed.$bytes.$nbBytes, true));

95 $this->updateSeed();

PaymentMethodConfigurationAccessControlHandlerTest.php (https://gitlab.com/Drulenium-bot/payment) PHP · 357 lines

1 <?php

2

3 namespace Drupal\Tests\payment\Unit\Entity\PaymentMethodConfiguration;

24 * The module handler.

25 *

26 * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject

27 */

28 protected $moduleHandler;

82 * Gets a mock payment method configuration.

83 *

84 * @return \Drupal\payment\Entity\PaymentMethodConfiguration|\PHPUnit_Framework_MockObject_MockObject

85 */

86 protected function getMockPaymentMethodConfiguration() {

140 */

141 public function testCheckAccessWithOwnPermission() {

142 $owner_id = mt_rand();

143 $operation = $this->randomMachineName();

144 $account = $this->getMock(AccountInterface::class);

FileDownloaderTest.php (https://gitlab.com/yousafsyed/easternglamor) PHP · 215 lines

1 <?php

2

3 /*

16 use Composer\Util\Filesystem;

17

18 class FileDownloaderTest extends \PHPUnit_Framework_TestCase

19 {

20 protected function getDownloader($io = null, $config = null, $eventDispatcher = null, $cache = null, $rfs = null, $filesystem = null)

104

105 do {

106 $path = sys_get_temp_dir().'/'.md5(time().mt_rand());

107 } while (file_exists($path));

108

189

190 do {

191 $path = sys_get_temp_dir().'/'.md5(time().mt_rand());

192 } while (file_exists($path));

193

dropdownAllItems.php (https://github.com/glpi-project/glpi.git) PHP · 96 lines

1 <?php

2 /**

3 * ---------------------------------------------------------------------

31 */

32

33 include ('../inc/includes.php');

34

35 header("Content-Type: text/html; charset=UTF-8");

41 if ($_POST["idtable"] && class_exists($_POST["idtable"])) {

42 // Link to user for search only > normal users

43 $link = "getDropdownValue.php";

44

45 if ($_POST["idtable"] == 'User') {

46 $link = "getDropdownUsers.php";

47 }

48

SalesTest.php (https://gitlab.com/crazybutterfly815/magento2) PHP · 127 lines

1 <?php

2 /**

3 * Copyright © 2016 Magento. All rights reserved.

14 * @magentoAppArea adminhtml

15 */

16 class SalesTest extends \PHPUnit_Framework_TestCase

17 {

18 const MAIN_WEBSITE = 1;

54 )->createBlock(

55 \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales::class,

56 'sales_' . mt_rand(),

57 ['coreRegistry' => $this->coreRegistry]

58 )->setTemplate(

Profiler.php (https://github.com/AJenbo/ubuntudanmark.dk.git) PHP · 287 lines

1 <?php

2

3 /*

168 * @return array An array of tokens

169 *

170 * @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats

171 */

172 public function find($ip, $url, $limit, $method, $start, $end)

190 }

191

192 $profile = new Profile(substr(sha1(uniqid(mt_rand(), true)), 0, 6));

193 $profile->setTime(time());

194 $profile->setUrl($request->getUri());

generar_datos.php (https://bitbucket.org/clcena/mongodb.git) PHP · 84 lines

1 <?php

2 require('dbconnection.php');

33 {

34 $length = count($array);

35 $randomIndex = mt_rand(0, $length - 1);

36

37 return $array[$randomIndex];

40 function getRandomTimestamp()

41 {

42 $randomDigit = mt_rand(0, 6) * -1;

43 return strtotime($randomDigit . ' día');

44 }

66

67 $publishedAt = new MongoDate(getRandomTimestamp());

68 $rating = mt_rand(1, 10);

69

70 return array('titulo' => $titulo, 'autor' => $autor, 'categoria' => $categoria,

Main.php (https://gitlab.com/Skull3x/Pocketmine-MP-Plugins) PHP · 279 lines

1 <?php

2 /**

3 * RandomDropper Copyright (C) 2015 CDFalcon

161 $event->setCancelled();

162

163 switch(mt_rand(1, 10)){

164 case 1:

165 if(count($this->item) > 0){

166 $r = mt_rand(0, count($this->item)-1);

167 $item = $this->item[$r];

168 $player->getLevel()->dropItem($block, new Item($item["id"], $item["damage"], 1));

174 case 2:

175 if(count($this->item) > 0){

176 $r = mt_rand(0, count($this->item)-1);

177 $item = $this->item[$r];

178 $player->getLevel()->dropItem($block, new Item($item["id"], $item["damage"], 1));

Attribute.php (https://github.com/sunsetsystems/openemr.git) PHP · 370 lines

1 <?php

2 /**

3 * Zend Framework (http://framework.zend.com/)

256 return $password;

257 case self::PASSWORD_HASH_SSHA:

258 $salt = substr(sha1(uniqid(mt_rand(), true), true), 0, 4);

259 $rawHash = sha1($password . $salt, true) . $salt;

260 $method = '{SSHA}';

265 break;

266 case self::PASSWORD_HASH_SMD5:

267 $salt = substr(sha1(uniqid(mt_rand(), true), true), 0, 4);

268 $rawHash = md5($password . $salt, true) . $salt;

269 $method = '{SMD5}';

AbstractMessage.php (https://github.com/jtai/zf2.git) PHP · 96 lines

1 <?php

2 /**

3 * Zend Framework

84 return sprintf(

85 '%08X-%04X-%04X-%02X%02X-%012X',

86 mt_rand(),

87 mt_rand(0, 65535),

88 bindec(substr_replace(

89 sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4)

90 ),

91 bindec(substr_replace(sprintf('%08b', mt_rand(0, 255)), '01', 5, 2)),

92 mt_rand(0, 255),

93 mt_rand()

Ground.php (https://bitbucket.org/Sett/evolution.git) PHP · 71 lines

1 <?php

2 namespace app\modifiers\land;

3

62 }

63

64 $ground->current_square = mt_rand(1, $ground->max_square);

65 $ground->created = time();

66 $ground->changed = time();

stress_test.php (https://github.com/md-tech/openemr.git) PHP · 419 lines

53 for ( $i = 1; $i <= $items; $i++ )

54 {

55 $return[] = $keys[mt_rand (0, $max)];

56 }

57

60

61 // require gacl

62 require_once (dirname (__FILE__) . '/../admin/gacl_admin.inc.php');

63

64 /*

291 for ( $i = $start; $i <= $max; $i++ )

292 {

293 $rand_aco_key = array_mt_rand ($aco_list, mt_rand (2, 10));

294 $rand_aro_key = array_mt_rand ($aro_groups, mt_rand(2,10));

295 $rand_axo_key = array_mt_rand ($axo_groups, mt_rand(2,10));

296

297 $aco_array = array ();

rtdealer.php (https://github.com/zetaben/zguide.git) PHP · 77 lines

1 <?php

2 /*

3 * Custom routing Router to Dealer (XREP to XREQ)

19 $request = $worker->recv();

20 if($request == 'END') {

21 printf ("A received: %d%s", $total, PHP_EOL);

22 break;

23 }

37 $request = $worker->recv();

38 if($request == 'END') {

39 printf ("B received: %d%s", $total, PHP_EOL);

40 break;

41 }

59 for ($task_nbr = 0; $task_nbr != 10; $task_nbr++) {

60 // Send two message parts, first the address...

61 if(mt_rand(0, 2) > 0) {

62 $client->send("A", ZMQ::MODE_SNDMORE);

63 } else {

dropdownMassiveActionAddActor.php (https://github.com/ardowz/glpi-itams.git) PHP · 51 lines

1 <?php

2 /*

3 * @version $Id: dropdownMassiveActionAddActor.php 14684 2011-06-11 06:32:40Z remi $

36 $AJAX_INCLUDE = 1;

37 define('GLPI_ROOT','..');

38 include (GLPI_ROOT."/inc/includes.php");

39

40 header("Content-Type: text/html; charset=UTF-8");

44

45 if ($_POST["actortype"] > 0) {

46 $rand = mt_rand();

47 Ticket::showActorAddForm($_POST["actortype"], $rand, $_SESSION['glpiactive_entity'], false);

48 echo "&nbsp;<input type='submit' name='add_actor' class='submit' value=\"".$LANG['buttons'][2]."\">";

PhpdocToCommentFixerTest.php (git://github.com/fabpot/PHP-CS-Fixer.git) PHP · 533 lines

1 <?php

2

3 /*

4 * This file is part of PHP CS Fixer.

5 *

6 * (c) Fabien Potencier <fabien@symfony.com>

16

17 /**

18 * @author Ceeram <ceeram@cakephp.org>

19 */

20 class PhpdocToCommentFixerTest extends AbstractFixerTestBase

29

30 /**

31 * @requires PHP 5.4

32 * @dataProvider provideTraits

33 */

dropdownMassiveActionAddActor.php (https://github.com/ardowz/Thesis-SideB.git) PHP · 51 lines

1 <?php

2 /*

3 * @version $Id: dropdownMassiveActionAddActor.php 14815 2011-06-29 07:27:02Z remi $

36 $AJAX_INCLUDE = 1;

37 define('GLPI_ROOT','..');

38 include (GLPI_ROOT."/inc/includes.php");

39

40 header("Content-Type: text/html; charset=UTF-8");

44

45 if ($_POST["actortype"] > 0) {

46 $rand = mt_rand();

47 Ticket::showActorAddForm($_POST["actortype"], $rand, $_SESSION['glpiactive_entity'], false);

48 echo "&nbsp;<input type='submit' name='add_actor' class='submit' value=\"".$LANG['buttons'][2]."\">";

CustomOptions.php (https://gitlab.com/LisovyiEvhenii/ismextensions) PHP · 386 lines

1 <?php

2 /**

3 * Magento

8 * that is bundled with this package in the file LICENSE.txt.

9 * It is also available through the world-wide-web at this URL:

10 * http://opensource.org/licenses/osl-3.0.php

11 * If you did not receive a copy of the license and are unable to

12 * obtain it through the world-wide-web, please send an email

22 * @package Tests_Functional

23 * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)

24 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)

25 */

26

64 $preset = [];

65 if (isset($data['preset'])) {

66 $preset = $this->replaceData($this->getPreset($data['preset']), mt_rand());

67 unset($data['preset']);

68 }

Profiler.php (https://github.com/Shumkov/TimeRanger.git) PHP · 251 lines

1 <?php

2

3 class TimeRanger_Profiler

29 {

30 if (self::$_enabled) {

31 require_once 'TimeRanger/Exception.php';

32 throw new TimeRanger_Exception('Profiler already started');

33 }

34

35 if ($probability !== false && !is_integer($probability) && $probability <= 0) {

36 require_once 'TimeRanger/Exception.php';

37 throw new TimeRanger_Exception('Probability must be a positive integer or false');

38 }

40 if (!self::$_instance) {

41 if (!extension_loaded('xhprof')) {

42 require_once 'TimeRanger/Exception.php';

43 throw new TimeRanger_Exception("The xhprof extension is required: http://pecl.php.net/package/xhprof");

LibraryInstallerTest.php (git://github.com/composer/composer.git) PHP · 290 lines

1 <?php

2

3 /*

285 {

286 return $this->getMockBuilder('Composer\Package\Package')

287 ->setConstructorArgs(array(md5(mt_rand()), '1.0.0.0', '1.0.0'))

288 ->getMock();

289 }

function.ViMbAdmin_Messages.php (https://github.com/basilgohar/ViMbAdmin.git) PHP · 138 lines

1 <?php

2

3 /**

63 foreach( $messages as $oneMessage )

64 {

65 if( isset( $params['randomid'] ) && $params['randomid'] ) $count = mt_rand();

66

67 $items = $oneMessage->getMessage();

functions.php (http://xrnx.googlecode.com/svn/trunk/) PHP · 124 lines

1 <?php

2

3 // ----------------------------------------------------------------------------

89 else {

90 // Detect by creating a temporary file

91 $temp_file = tempnam(md5(uniqid(mt_rand(), true)), '');

92 if ($temp_file) {

93 $temp_dir = realpath(dirname($temp_file));

bar-002.php (https://github.com/goldoraf/OBM.git) PHP · 80 lines

1 <?php

2 /*

3 * This work is hereby released into the Public Domain.

8 */

9

10 require_once "../../BarPlot.class.php";

11

12 $graph = new Graph(280, 280);

49

50 for($i = 0; $i < 6; $i++) {

51 $x[] = (cos($i * M_PI / 100) / ($n + 1) * mt_rand(600, 900) / 1000 - 0.5) * (($n%2) ? -0.5 : 1) + (($n%2) ? -0.4 : 0);

52 }

53

Files.php (https://github.com/jaws-project/jaws.git) PHP · 282 lines

1 <?php

2 /**

3 * Directory Gadget

20 $data['parent'] = (int)$data['parent'];

21 if (!$data['public']) {

22 $data['key'] = mt_rand(1000, 9999999999);

23 }

24 $data['create_time'] = $data['update_time'] = time();

StartSession.php (https://gitlab.com/kimting254/wbms) PHP · 248 lines

1 <?php namespace Illuminate\Session\Middleware;

2

3 use Closure;

51 // If a session driver has been configured, we will need to start the session here

52 // so that the data is ready for an application. Note that the Laravel sessions

53 // do not make use of PHP "native" sessions in any way since they are crappy.

54 if ($this->sessionConfigured())

55 {

163 protected function configHitsLottery(array $config)

164 {

165 return mt_rand(1, $config['lottery'][1]) <= $config['lottery'][0];

166 }

167

openid.php (https://bitbucket.org/jonphipps/elefant-vocabhub.git) PHP · 85 lines

1 <?php

2

3 /**

48 if ($u) {

49 // already have an account, log them in

50 $u->session_id = md5 (uniqid (mt_rand (), 1));

51 $u->expires = gmdate ('Y-m-d H:i:s', time () + 2592000);

52 $try = 0;

53 while (! $u->put ()) {

54 $u->session_id = md5 (uniqid (mt_rand (), 1));

55 $try++;

56 if ($try == 5) {

ChangelogTest.php (https://gitlab.com/svillegas/magento2) PHP · 277 lines

1 <?php

2 /**

3 * Copyright © 2016 Magento. All rights reserved.

6 namespace Magento\Framework\Mview\Test\Unit\View;

7

8 class ChangelogTest extends \PHPUnit_Framework_TestCase

9 {

10 /**

16 * Mysql PDO DB adapter mock

17 *

18 * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\DB\Adapter\Pdo\Mysql

19 */

20 protected $connectionMock;

236 $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");

237 $this->model->setViewId('viewIdtest');

238 $this->model->getList(mt_rand(1, 200), mt_rand(201, 400));

239 }

240

FormJSAddMoreTest.php (https://gitlab.com/andecode/theme-spark) PHP · 128 lines

1 <?php

2

3 namespace Drupal\Tests\field\FunctionalJavascript;

44 'label' => $this->randomMachineName() . '_label',

45 'description' => '[site:name]_description',

46 'weight' => mt_rand(0, 127),

47 'settings' => [

48 'test_field_setting' => $this->randomMachineName(),

Color.php (https://github.com/fzaninotto/Faker.git) PHP · 143 lines

1 <?php

2

3 namespace Faker\Provider;

48 public static function hexColor()

49 {

50 return '#' . str_pad(dechex(mt_rand(1, 16777215)), 6, '0', STR_PAD_LEFT);

51 }

52

56 public static function safeHexColor()

57 {

58 $color = str_pad(dechex(mt_rand(0, 255)), 3, '0', STR_PAD_LEFT);

59

60 return '#' . $color[0] . $color[0] . $color[1] . $color[1] . $color[2] . $color[2];

security.test.php (https://github.com/GunioRobot/findTwitter.git) PHP · 163 lines

1 <?php

2 /* SVN FILE: $Id$ */

3 /**

8 * PHP versions 4 and 5

9 *

10 * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>

11 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)

12 *

16 * @filesource

17 * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)

18 * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests

19 * @package cake

20 * @subpackage cake.tests.cases.libs

21 * @since CakePHP(tm) v 1.2.0.5432

22 * @version $Revision$

23 * @modifiedby $LastChangedBy$

UpdateApiEntityDefinitionUpdateTest.php (https://gitlab.com/reasonat/test8) PHP · 209 lines

1 <?php

2

3 namespace Drupal\system\Tests\Entity\Update;

55 public function testSingleUpdates() {

56 // Create a test entity.

57 $user_ids = [mt_rand(), mt_rand()];

58 $entity = EntityTest::create(['name' => $this->randomString(), 'user_id' => $user_ids]);

59 $entity->save();

106 public function testMultipleUpdates() {

107 // Create a test entity.

108 $user_ids = [mt_rand(), mt_rand()];

109 $entity = EntityTest::create(['name' => $this->randomString(), 'user_id' => $user_ids]);

110 $entity->save();

137 function testStatusReport() {

138 // Create a test entity.

139 $entity = EntityTest::create(['name' => $this->randomString(), 'user_id' => mt_rand()]);

140 $entity->save();

141

acl0001Test.php (https://github.com/gnomeontherun/joomla-cms.git) PHP · 288 lines

1 <?php

2 /**

3 * @package Joomla.SystemTest

6 * Creates test group and assigns priviledges with the ACL.

7 */

8 require_once 'SeleniumJoomlaTestCase.php';

9

10 class Acl0001Test extends SeleniumJoomlaTestCase

20 $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-users']"), 'User manager should be visible');

21 }

22 catch (PHPUnit_Framework_AssertionFailedError $e)

23 {

24 array_push($this->verificationErrors, $this->getTraceFiles($e));

29 $this->assertTrue($this->isElementPresent("//ul[@id='menu-com-users-groups']"), 'Groups should be visible');

30 }

31 catch (PHPUnit_Framework_AssertionFailedError $e)

32 {

33 array_push($this->verificationErrors, $this->getTraceFiles($e));

TestDirHelper.php (https://github.com/Weltraumschaf/ebnf.git) PHP · 83 lines

1 <?php

2 /**

3 * This program is free software: you can redistribute it and/or modify

52 */

53 public function __construct($baseDir = self::DEFAULT_BASE_DIR) {

54 $this->dirName = $baseDir . DIRECTORY_SEPARATOR . "ebnf_test_files_" . mt_rand();

55 }

56

EntityPopulator.php (https://gitlab.com/sarelvdwalt/Faker) PHP · 197 lines

1 <?php

2

3 namespace Faker\ORM\Doctrine;

128 }

129

130 return $inserted[$relatedClass][mt_rand(0, count($inserted[$relatedClass]) - 1)];

131 }

132

190 $id = null;

191 do {

192 $id = mt_rand();

193 } while (in_array($id, $ids));

194

6vip.php (https://gitlab.com/phamngsinh/baitaplon_sinhvien) PHP · 172 lines

1 <?php

2 /**

3 * @package JohnCMS

16 $textl = 'Tôm cua cá';

17 $rootpath = '../';

18 require_once ("../incfiles/core.php");

19 require_once ("../incfiles/head.php");

23

24

25 $rand = mt_rand(100, 999);

26 $balans_plus = "1800";

27 $balans_minus = "300";

37

38

39 echo '<a href="6vip.php?act=go&amp;thimble=1&amp;rand=' . $rand .

40 '"><img src="nai.gif" alt=""/></a>

41 <a href="6vip.php?act=go&amp;thimble=2&amp;rand=' . $rand .

CourseController.php (https://bitbucket.org/coderpick/bdtutorial.git) PHP · 183 lines

1 <?php

2

3 namespace App\Http\Controllers\Admin;

176 // $slug = str_slug($value);

177 if (Course::withTrashed()->where('slug', $slug)->exists()) {

178 $slug = $slug . mt_rand(10, 99);

179 $this->_slug($slug);

180 }

CounterBalance.php (https://bitbucket.org/maxpanzer/cred_katherine.git) PHP · 79 lines

1 <?php

2

3 class CounterBalance{

41

42 private function __construct(){

43 $this->counterBalance = mt_rand(1, 4);

44 }

45

FilesystemTestCase.php (git://github.com/symfony/symfony.git) PHP · 180 lines

1 <?php

2

3 /*

12 namespace Symfony\Component\Filesystem\Tests;

13

14 use PHPUnit\Framework\TestCase;

15 use Symfony\Component\Filesystem\Filesystem;

16

74 $this->umask = umask(0);

75 $this->filesystem = new Filesystem();

76 $this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand();

77 mkdir($this->workspace, 0777, true);

78 $this->workspace = realpath($this->workspace);

159 }

160

161 // https://bugs.php.net/69473

162 if ($relative && '\\' === \DIRECTORY_SEPARATOR && 1 === PHP_ZTS) {

store.php (https://github.com/brion/mediawiki-svn.git) PHP · 77 lines

1 <?php

2

3 /**

7 */

8

9 require( dirname( __FILE__ ) . '/WebStoreStart.php' );

10

11 class WebStoreStore extends WebStoreCommon {

17 echo <<<EOT

18 <html>

19 <head><title>store.php Test Interface</title></head>

20 <body>

21 <form method="post" action="store.php" enctype="multipart/form-data" >

53

54 // Pick a random temporary path

55 $destRel = $timestamp . '/' . md5( mt_rand() . mt_rand() . mt_rand() ) . $extension;

56 if ( !@move_uploaded_file( $srcFile, "{$this->tmpDir}/$destRel" ) ) {

57 $this->error( 400, 'webstore_move_uploaded', $srcFile, "{$this->tmpDir}/$destRel" );

ContentTranslationSyncUnitTest.php (https://gitlab.com/mohamed_hussein/prodt) PHP · 260 lines

1 <?php

2

3 namespace Drupal\Tests\content_translation\Kernel;

115 $unchanged_items = $this->unchangedFieldValues[$sync_langcode];

116 $field_values = $this->unchangedFieldValues;

117 $sync_delta = mt_rand(0, count($field_values[$sync_langcode]) - 1);

118 unset($field_values[$sync_langcode][$sync_delta]);

119 // Renumber deltas to start from 0.

functions.php (https://github.com/carlic578/airpic.git) PHP · 140 lines

1 <?php

2

3 function checkForSession()

59 {

60 mt_srand();

61 $number = mt_rand()+time();

62 $temp = hash("sha512",$number);

63 return substr($temp, 0, 40);

120 {

121 $host = $_SERVER["HTTP_HOST"];

122 $path = rtrim(dirname($_SERVER["PHP_SELF"]), "/\\");

123 $goto = sprintf("Location: http://%s%s/%s", $host, $path, $navigateTo);

124 header($goto);

jssdk.php (https://gitlab.com/0072016/0072016-wechat) PHP · 94 lines

1 <?php

2 $mypath=$_SERVER['DOCUMENT_ROOT'] . '/wechat';

3 require_once $mypath.'/class/interfaceHandler.php';

46 $str = "";

47 for ($i = 0; $i < $length; $i++) {

48 $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);

49 }

50 return $str;

winners.blade.php (https://gitlab.com/urbanjunglestudio/whambush-website) PHP · 126 lines

4 <script src="{{ asset('js/admin/jquery-ui.custom/jquery-ui.js') }}"></script>

5 <link rel="stylesheet" href="{{ asset('js/admin/jquery-ui.custom/jquery-ui.css') }}">

6 <script src=<?php echo asset('js/admin/winners.js'); echo "?rand=".mt_rand();?>></script>

7 @stop

8

34 <div id="_number_of_missions" class="styled-select">

35 {!! Form::label('_number_of_missions', 'Max number of missions to print out:') !!}

36 <?php

37 $thelist = array();

38 for ($i=1; $i < 100; $i++) {

43 <label>&nbsp-&nbsp</label>

44 {!! Form::label('_number_of_entries', 'Number of entries / mission:') !!}

45 <?php

46 $thelist = array('default' => 'default', 'all' => 'all');

47 for ($i=1; $i < 50; $i++) {

AggregateCache.class.php (https://github.com/pupkinV/onphp-framework.git) PHP · 130 lines

1 <?php

2 /****************************************************************************

3 * Copyright (C) 2005-2008 by Anton E. Lebedevich, Konstantin V. Arkhipov *

88

89 $selectedLabel =

90 $zeroDistances[mt_rand(0, count($zeroDistances) - 1)];

91

92 } else {

93

94 // weighted random level selection

95 $sum = mt_rand() * array_sum($weights) / mt_getrandmax();

96 $peerLevel = null;

97 foreach ($weights as $level => $weight) {

109 }

110

111 $selectedLabel = $selectedPeers[mt_rand(0, count($selectedPeers) - 1)];

112 }

113

cachebench.php (https://github.com/glpi-project/glpi.git) PHP · 173 lines

1 <?php

2 /**

3 * ---------------------------------------------------------------------

31 */

32

33 if (PHP_SAPI != 'cli') {

34 echo "This script must be run from command line";

35 exit();

39 define('COUNT', 1024);

40

41 require __DIR__ . '/../inc/includes.php';

42

43 // To bypass various right checks

44 $_SESSION['glpishowallentities'] = 1;

45 $_SESSION['glpicronuserrunning'] = "cron_phpunit";

46 $_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;

47 $_SESSION['glpiactiveentities'] = [0];

MiradouAuth.php (https://github.com/cybfr/famille.miradou.com.git) PHP · 154 lines

1 <?php

2 class MiradouAuth {

3 private $AuthRealm;

66 return "Cette adresse ($mailToAddr) n'est pas enregistrée, contactez le ouaibmestre";

67 }

68 $key = sha1 ( $mailToAddr . microtime ( true ) . mt_rand ( 10000, 90000 ) );

69 $query = "

70 REPLACE INTO `famille`.`pwresetrequests` SET

SwimRenderingManagerTest.php (https://gitlab.com/src-run/teavee-scribble-down-bundle) PHP · 74 lines

1 <?php

2

3 /*

44 $manager = static::$staticContainer->get('s.teavee_scribble_down');

45

46 $rand1 = mt_rand(10000, 40000);

47 $rand2 = mt_rand(50000, 100000);

Submission.php (https://github.com/Bumblebee-Project/acpi-www.git) PHP · 200 lines

1 <?php

2 /**

3 * @license http://www.gnu.org/licenses/gpl.html GPLv3

181 $db = Database::getInstance();

182 // generate a 160-bit random string. @Mathematicans, any errors here?

183 $claim_key = str_shuffle(sha1(time() . '-' . mt_rand()));

184

185 $stmt_gen_key = $db->prepare('INSERT INTO submission_claim SET

Wolf.php (https://github.com/TuranicTeam/Altay.git) PHP · 152 lines

1 <?php

2

3 /*

44 use pocketmine\network\mcpe\protocol\ActorEventPacket;

45 use pocketmine\Player;

46 use function mt_rand;

47

48 class Wolf extends Tamable{

99 }

100

101 if(mt_rand(0, 2) == 0){

102 $this->setOwningEntity($player);

103 $this->setTamed();

test-deprecated.php (https://gitlab.com/aristath/maera) PHP · 55 lines

22

23 public function test_kirki_sanitize_hex() {

24 $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);

25 $this->assertEquals( kirki_sanitize_hex( $random_color ), Kirki_Color::sanitize_hex( $random_color ) );

26 }

27

28 public function test_kirki_get_rgb() {

29 $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);

30 $this->assertEquals( kirki_get_rgb( $random_color ), Kirki_Color::get_rgb( $random_color ) );

31 }

32

33 public function test_kirki_get_rgba() {

34 $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);

35 $this->assertEquals( kirki_get_rgba( $random_color ), Kirki_Color::get_rgba( $random_color ) );

36 }

LocaleScannerTest.php (https://github.com/FabienD/symfony.git) PHP · 90 lines

1 <?php

2

3 /*

12 namespace Symfony\Component\Intl\Tests\Data\Util;

13

14 use PHPUnit\Framework\TestCase;

15 use Symfony\Component\Filesystem\Filesystem;

16 use Symfony\Component\Intl\Data\Util\LocaleScanner;

35 protected function setUp(): void

36 {

37 $this->directory = sys_get_temp_dir().'/LocaleScannerTest/'.mt_rand(1000, 9999);

38 $this->filesystem = new Filesystem();

39 $this->scanner = new LocaleScanner();

AdmingeneratorMenuBuilder.php (https://bitbucket.org/ajalovec/admingeneratorgeneratorbundle.git) PHP · 130 lines

1 <?php

2

3 namespace Admingenerator\GeneratorBundle\Menu;

117 // generate unique divider name

118 do {

119 $name = 'divider'.mt_rand();

120 } while (in_array($name, $this->dividers));

121

PrettyPrinterAbstract.php (https://gitlab.com/x33n/PHP-Parser) PHP · 268 lines

1 <?php

2

3 namespace PhpParser;

4

5 use PhpParser\Node\Expr;

6 use PhpParser\Node\Stmt;

77

78 public function __construct() {

79 $this->noIndentToken = '_NO_INDENT_' . mt_rand();

80 }

81

105

106 /**

107 * Pretty prints a file of statements (includes the opening <?php tag if it is required).

108 *

109 * @param Node[] $stmts Array of statements

LockBackendAbstract.php (https://gitlab.com/geeta7/drupal) PHP · 79 lines

1 <?php

2

3 /**

73 public function getLockId() {

74 if (!isset($this->lockId)) {

75 $this->lockId = uniqid(mt_rand(), TRUE);

76 }

77 return $this->lockId;

Request.php (https://github.com/sgtcarneiro/horde.git) PHP · 198 lines

1 <?php

2 /**

3 * Copyright 2008-2011 The Horde Project (http://www.horde.org/)

4 *

5 * @author Chuck Hagenbuch <chuck@horde.org>

6 * @license http://opensource.org/licenses/bsd-license.php BSD

7 * @category Horde

8 * @package Oauth

13 *

14 * @author Chuck Hagenbuch <chuck@horde.org>

15 * @license http://opensource.org/licenses/bsd-license.php BSD

16 * @category Horde

17 * @package Oauth

117 {

118 $mt = microtime();

119 $rand = mt_rand();

120

121 return hash('md5', microtime() . mt_rand());

geolib.php (https://gitlab.com/ElvisAns/tiki) PHP · 206 lines

1 <?php

2

3 // (c) Copyright by authors of the Tiki Wiki CMS Groupware Project

166 return ["lon" => 0, "lat" => 0];

167 }

168 $geo["lon"] = $geo["lon"] + mt_rand(0, 10000) / 8000;

169 $geo["lat"] = $geo["lat"] + mt_rand(0, 10000) / 10000;

crypt.php (https://bitbucket.org/pastor399/newcastleunifc.git) PHP · 238 lines

1 <?php

2 /**

3 * @package Joomla.Platform

121 /*

122 * if a secure randomness generator exists and we don't

123 * have a buggy PHP version use it.

124 */

125 if (function_exists('openssl_random_pseudo_bytes')

126 && (version_compare(PHP_VERSION, '5.3.4') >= 0 || IS_WIN))

127 {

128 $sslStr = openssl_random_pseudo_bytes($length, $strong);

147 $handle = null;

148

149 // This is PHP 5.3.3 and up

150 if (function_exists('stream_set_read_buffer') && @is_readable('/dev/urandom'))

151 {

Upgrade2_0_0_2.php (https://github.com/BranchesWebDesign/development.git) PHP · 191 lines

1 <?php

2

3 /**

144 }

145

146 $send_time = (int)(time() + $message["send_after"] - $message["send_after_plus_minus"] + mt_rand(0, $message["send_after_plus_minus"]*2));

147

148 $wpdb->insert(

UserRepository.php (https://bitbucket.org/ghanu/chope.git) PHP · 362 lines

1 <?php

2

3 namespace App\Repositories\Backend\Auth;

109 'password' => Hash::make($data['password']),

110 'active' => isset($data['active']) && $data['active'] == '1' ? 1 : 0,

111 'confirmation_code' => md5(uniqid(mt_rand(), true)),

112 'confirmed' => isset($data['confirmed']) && $data['confirmed'] == '1' ? 1 : 0,

113 ]);

Template.php (https://gitlab.com/koodersmiikka/operaatio-terveys) PHP · 361 lines

1 <?php

2

3 namespace Concrete\Core\Gathering\Item\Template;

215 $wt = $this->getGatheringItemTemplateMaximumSlotWidth($item);

216

217 return mt_rand($wb, $wt);

218 }

219

243 $ht = $this->getGatheringItemTemplateMaximumSlotHeight($item);

244

245 return mt_rand($hb, $ht);

246 }

247

FormLibrary.class.php (https://bitbucket.org/chamilo/chamilo-dev/) PHP · 200 lines

1 <?php

2 require_once Path :: get_plugin_path() . 'FormLibrary/Rules/Rule.class.php';

3 require_once Path :: get_plugin_path() . 'FormLibrary/ElementStorage/ElementStorage.class.php';

4 require_once Path :: get_plugin_path() . 'FormLibrary/Elements/Element.class.php';

5 require_once Path :: get_plugin_path() . 'FormLibrary/Containers/Container.class.php';

6 require_once Path :: get_plugin_path() . 'FormLibrary/Renderer/Render.class.php';

7 require_once Path :: get_plugin_path() . 'FormLibrary/Elements/CustomElements/form_library_html_editor.class.php';

8 /*

9 * Main class to create forms

31 //Set a unique name for the form

32 {

33 $a = "FormLibrary_" . mt_rand();

34 }

35

Generator.php (https://github.com/churchillyik/TRSimu.git) PHP · 202 lines

1 <?php

2 // 生成器类

3 class Generator

15 for ($i = 0; $i < $length; $i++)

16 {

17 $randnum = mt_rand(0, 61);

18 if ($randnum < 10)

19 {

FileServ.php (https://bitbucket.org/jasechen/ea-alfa-api.git) PHP · 286 lines

1 <?php

2

3 namespace App\Services;

75 $savePath = public_path('gallery/' . $parentType);

76

77 $filename = Carbon::now()->timestamp . mt_rand(100000, 999999);

78 $fileExtension = empty($extension) ? $file->extension() : $extension;

79

variable.php (https://github.com/Yacodo/atoum.git) PHP · 219 lines

1 <?php

2

3 namespace mageekguy\atoum\asserters;

76 $this->fail(

77 ($failMessage !== null ? $failMessage : sprintf($this->getLocale()->_('%s is not equal to %s'), $this, $this->getTypeOf($value))) .

78 PHP_EOL .

79 $diff->setReference($value)->setData($this->value)

80 );

114 $this->fail(

115 ($failMessage !== null ? $failMessage : sprintf($this->getLocale()->_('%s is not identical to %s'), $this, $this->getTypeOf($value))) .

116 PHP_EOL .

117 $diff->setReference($value)->setData($this->value)

118 );

187 {

188 $tmp = $reference;

189 $reference = uniqid(mt_rand());

190 $isReference = ($this->value === $reference);

191 $reference = $tmp;

StoreTest.php (https://github.com/easybib/php-openid.git) PHP · 298 lines

1 <?php

2 /**

3 * Tests_Auth_OpenID_Store

4 */

5 require_once dirname(__FILE__) . '/../Store.php';

6

7 /**

14 function test_memstore()

15 {

16 require_once 'Tests/Auth/OpenID/MemStore.php';

17 $store = new Tests_Auth_OpenID_MemStore();

18 $this->_testStore($store);

23 function test_filestore()

24 {

25 require_once 'Auth/OpenID/Store/File.php';

26

27 $temp_dir = _Auth_OpenID_mkdtemp();

UserTableSeeder.php (https://gitlab.com/Ankit77/motiv8) PHP · 55 lines

1 <?php

2

3 use Carbon\Carbon as Carbon;

31 'email' => 'info@webdevelopmentpark.com',

32 'password' => bcrypt('123456'),

33 'confirmation_code' => md5(uniqid(mt_rand(), true)),

34 'confirmed' => true,

35 'created_at' => Carbon::now(),

40 'email' => 'aniljmk@gmail.com',

41 'password' => bcrypt('123456'),

42 'confirmation_code' => md5(uniqid(mt_rand(), true)),

43 'confirmed' => true,

44 'created_at' => Carbon::now(),

cls_session.php (https://github.com/xnsimon/dmk.git) PHP · 290 lines

1 <?php

2

3 /**

11 * ============================================================================

12 * $Author: liuhui $

13 * $Id: cls_session.php 17063 2010-03-25 06:35:46Z liuhui $

14 */

15

122 function gen_session_id()

123 {

124 $this->session_id = md5(uniqid(mt_rand(), true));

125

126 return $this->insert_session();

234

235 /* 随机对 sessions_data 的库进行删除操作 */

236 if (mt_rand(0, 2) == 2)

237 {

238 $this->db->query('DELETE FROM ' . $this->session_data_table . ' WHERE expiry < ' . ($this->_time - $this->max_life_time));