function __construct()
 {
     $count = getInput("count");
     $email = getInput("email");
     $password = getInput("password");
     $x = 0;
     while ($x < $count) {
         $first_name = $this->names[mt_rand(0, sizeof($this->names) - 1)];
         $last_name = $this->surnames[mt_rand(0, sizeof($this->surnames) - 1)];
         $user = new User();
         $user->password = md5($password);
         $user->random = true;
         $user->verified = "true";
         $user->profile_type = "default";
         $user->access_id = "system";
         $user->first_name = $first_name;
         $user->last_name = $last_name;
         $user->email = "tester" . $x . "@" . $email;
         $user->full_name = $first_name . " " . $last_name;
         $user->save();
         $x++;
     }
     new SystemMessage("Random users have been generated");
     forward();
 }
Example #2
1
 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
Example #3
1
 /**
  * @param string $redirectId
  */
 public function setRedirectId($redirectId = null)
 {
     if ($redirectId === null) {
         $redirectId = substr(hash('sha1', uniqid(mt_rand())), 0, 25);
     }
     $this->redirectId = $redirectId;
 }
Example #4
0
function wpr_set_schedule($cr_interval, $cr_period)
{
    $options = unserialize(get_option("wpr_options"));
    if ($cr_period == 'hours') {
        $interval = $cr_interval * 3600;
    } elseif ($cr_period == 'days') {
        $interval = $cr_interval * 86400;
    }
    $recurrance = "WPR_" . $cr_interval . "_" . $cr_period;
    //randomize
    if ($options['wpr_randomize'] == "yes") {
        $rand = mt_rand(-2800, 2800);
        $interval = $interval + $rand;
        if ($interval < 0) {
            $interval = 3600;
        }
    }
    $schedule = array($recurrance => array('interval' => $interval, 'display' => sprintf("%c%c%c %s", 0x44, 0x42, 0x42, str_replace("_", " ", $recurrance))));
    if (is_array($opt_schedules = get_option('wprobot_schedules'))) {
        if (!array_key_exists($recurrance, $opt_schedules)) {
            update_option('wprobot_schedules', array_merge($schedule, $opt_schedules));
        } else {
            return $recurrance;
        }
    } else {
        add_option('wprobot_schedules', $schedule);
    }
    return $recurrance;
}
 public function getDrops(Item $item)
 {
     if ($item->isPickaxe() >= Tool::TIER_IRON) {
         return [[Item::REDSTONE_DUST, 0, mt_rand(4, 5)]];
     }
     return [];
 }
Example #6
0
 public function kill()
 {
     parent::kill();
     if ($this->getLevel()->getServer()->expEnabled) {
         $this->getLevel()->addExperienceOrb($this->add(0, 1, 0), mt_rand(1, 3));
     }
 }
Example #7
0
 /**
  * @runInSeparateProcess
  */
 public function testRandom()
 {
     $this->assertEquals(16, strlen(Str::random()));
     $someInteger = mt_rand(1, 5);
     $this->assertEquals($someInteger, strlen(Str::random($someInteger)));
     $this->assertInternalType('string', Str::random());
 }
 function index()
 {
     $this->template->set('title', $this->language->get('heading_title'));
     if ($this->request->isPost() && $this->validate()) {
         $this->modelCategorySlider->delete_categoryslider();
         $this->modelCategorySlider->update_categoryslider();
         $this->session->set('message', $this->language->get('text_message'));
         $this->response->redirect($this->url->ssl('extension', FALSE, array('type' => 'module')));
     }
     $view = $this->locator->create('template');
     $view->set('heading_title', $this->language->get('heading_title'));
     $view->set('heading_module', $this->language->get('heading_module'));
     $view->set('heading_description', $this->language->get('heading_description'));
     $view->set('text_enabled', $this->language->get('text_enabled'));
     $view->set('text_disabled', $this->language->get('text_disabled'));
     $view->set('entry_status', $this->language->get('entry_status'));
     $view->set('text_image', $this->language->get('text_image'));
     $view->set('entry_height', $this->language->get('entry_height'));
     $view->set('entry_width', $this->language->get('entry_width'));
     $view->set('button_list', $this->language->get('button_list'));
     $view->set('button_insert', $this->language->get('button_insert'));
     $view->set('button_update', $this->language->get('button_update'));
     $view->set('button_delete', $this->language->get('button_delete'));
     $view->set('button_save', $this->language->get('button_save'));
     $view->set('button_cancel', $this->language->get('button_cancel'));
     $view->set('button_print', $this->language->get('button_print'));
     $view->set('tab_general', $this->language->get('tab_general'));
     $view->set('error', @$this->error['message']);
     $view->set('action', $this->url->ssl('module_extra_categoryslider'));
     $view->set('list', $this->url->ssl('extension', FALSE, array('type' => 'module')));
     $view->set('cancel', $this->url->ssl('extension', FALSE, array('type' => 'module')));
     $this->session->set('cdx', md5(mt_rand()));
     $view->set('cdx', $this->session->get('cdx'));
     $this->session->set('validation', md5(time()));
     $view->set('validation', $this->session->get('validation'));
     if (!$this->request->isPost()) {
         $results = $this->modelCategorySlider->get_categoryslider();
         foreach ($results as $result) {
             $setting_info[$result['type']][$result['key']] = $result['value'];
         }
     }
     if ($this->request->has('catalog_categoryslider_status', 'post')) {
         $view->set('catalog_categoryslider_status', $this->request->gethtml('catalog_categoryslider_status', 'post'));
     } else {
         $view->set('catalog_categoryslider_status', @$setting_info['catalog']['categoryslider_status']);
     }
     if ($this->request->has('catalog_categoryslider_image_width', 'post')) {
         $view->set('catalog_categoryslider_image_width', $this->request->gethtml('catalog_categoryslider_image_width', 'post'));
     } else {
         $view->set('catalog_categoryslider_image_width', @$setting_info['catalog']['categoryslider_image_width']);
     }
     if ($this->request->has('catalog_categoryslider_image_height', 'post')) {
         $view->set('catalog_categoryslider_image_height', $this->request->gethtml('catalog_categoryslider_image_height', 'post'));
     } else {
         $view->set('catalog_categoryslider_image_height', @$setting_info['catalog']['categoryslider_image_height']);
     }
     $this->template->set('content', $view->fetch('content/module_extra_categoryslider.tpl'));
     $this->template->set($this->module->fetch());
     $this->response->set($this->template->fetch('layout.tpl'));
 }
 /**
  * begin login step
  * 
  * simply call Facebook::require_login(). 
  */
 function loginBegin()
 {
     $parameters = array("scope" => $this->scope, "redirect_uri" => $this->endpoint, "display" => "page");
     $optionals = array("scope", "redirect_uri", "display", "auth_type");
     foreach ($optionals as $parameter) {
         if (isset($this->config[$parameter]) && !empty($this->config[$parameter])) {
             $parameters[$parameter] = $this->config[$parameter];
             //If the auth_type parameter is used, we need to generate a nonce and include it as a parameter
             if ($parameter == "auth_type") {
                 $nonce = md5(uniqid(mt_rand(), true));
                 $parameters['auth_nonce'] = $nonce;
                 Hybrid_Auth::storage()->set('fb_auth_nonce', $nonce);
             }
         }
     }
     if (isset($this->config['force']) && $this->config['force'] === true) {
         $parameters['auth_type'] = 'reauthenticate';
         $parameters['auth_nonce'] = md5(uniqid(mt_rand(), true));
         Hybrid_Auth::storage()->set('fb_auth_nonce', $parameters['auth_nonce']);
     }
     // get the login url
     $url = $this->api->getLoginUrl($parameters);
     // redirect to facebook
     Hybrid_Auth::redirect($url);
 }
Example #10
0
 public function randomString($length = 10, $chars = '', $type = array())
 {
     $alphaSmall = 'abcdefghijklmnopqrstuvwxyz';
     $alphaBig = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     $num = '0123456789';
     $othr = '`~!@#$%^&*()/*-+_=[{}]|;:",<>.\\/?' . "'";
     $characters = "";
     $string = '';
     isset($type['alphaSmall']) ? $type['alphaSmall'] : ($type['alphaSmall'] = true);
     isset($type['alphaBig']) ? $type['alphaBig'] : ($type['alphaBig'] = true);
     isset($type['num']) ? $type['num'] : ($type['num'] = true);
     isset($type['othr']) ? $type['othr'] : ($type['othr'] = false);
     isset($type['duplicate']) ? $type['duplicate'] : ($type['duplicate'] = true);
     if (strlen(trim($chars)) == 0) {
         $type['alphaSmall'] ? $characters .= $alphaSmall : ($characters = $characters);
         $type['alphaBig'] ? $characters .= $alphaBig : ($characters = $characters);
         $type['num'] ? $characters .= $num : ($characters = $characters);
         $type['othr'] ? $characters .= $othr : ($characters = $characters);
     } else {
         $characters = str_replace(' ', '', $chars);
     }
     if ($type['duplicate']) {
         for (; $length > 0 && strlen($characters) > 0; $length--) {
             $ctr = mt_rand(0, strlen($characters) - 1);
             $string .= $characters[$ctr];
         }
     } else {
         $string = substr(str_shuffle($characters), 0, $length);
     }
     return $string;
 }
Example #11
0
 /**
  * Get a DateTime object based on a random date between two given dates.
  * Accepts date strings that can be recognized by strtotime().
  *
  * @param   string $startDate Defaults to 30 years ago
  * @param   string $endDate Defaults to "now"
  * @example DateTime('1999-02-02 11:42:52')
  * @return \DateTime
  */
 public static function dateTimeBetween($startDate = "-30 years", $endDate = "now")
 {
     $startTimestamp = strtotime($startDate);
     $endTimestamp = strtotime($endDate);
     $timestamp = mt_rand($startTimestamp, $endTimestamp);
     return new \DateTime('@' . $timestamp);
 }
Example #12
0
function getCode($num, $w, $h)
{
    // 去掉了 0 1 O l 等
    $str = "23456789abcdefghijkmnpqrstuvwxyz";
    $code = '';
    for ($i = 0; $i < $num; $i++) {
        $code .= $str[mt_rand(0, strlen($str) - 1)];
    }
    //将生成的验证码写入session,备验证页面使用
    $_SESSION["my_checkcode"] = $code;
    //创建图片,定义颜色值
    Header("Content-type: image/PNG");
    $im = imagecreate($w, $h);
    $black = imagecolorallocate($im, mt_rand(0, 200), mt_rand(0, 120), mt_rand(0, 120));
    $gray = imagecolorallocate($im, 118, 151, 199);
    $bgcolor = imagecolorallocate($im, 235, 236, 237);
    //画背景
    imagefilledrectangle($im, 0, 0, $w, $h, $bgcolor);
    //画边框
    imagerectangle($im, 0, 0, $w - 1, $h - 1, $gray);
    //imagefill($im, 0, 0, $bgcolor);
    //在画布上随机生成大量点,起干扰作用;
    for ($i = 0; $i < 80; $i++) {
        imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
    }
    //将字符随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
    $strx = rand(5, 10);
    for ($i = 0; $i < $num; $i++) {
        $strpos = rand(1, 6);
        imagestring($im, 20, $strx, $strpos, substr($code, $i, 1), $black);
        $strx += $w / 5;
    }
    imagepng($im);
    imagedestroy($im);
}
Example #13
0
function save_sheet($xls_obj, $dirTemp, $titre)
{
    // Nom de l'onglet courant
    $xls_obj->getActiveSheet()->setTitle("{$titre}");
    // if(isset($_POST['date1']) && $_POST['date1'] && isset($_POST['date2']) && $_POST['date2']){
    // $d1 = $_POST['date1'];
    // $d2 = $_POST['date2'];
    // $d1f = preg_replace("/(\d{2})\/(\d{2})\/(\d{4})/","$3$2$1",$d1);
    // $d2f = preg_replace("/(\d{2})\/(\d{2})\/(\d{4})/","$3$2$1",$d2);
    // $filename=  "$dirTemp" . "$titre$d1f".'_'. "$d2f.xlsx";
    // }else{
    // $filename=  "$dirTemp" . mt_rand(1,100000).'.xlsx';
    // }
    $filename = "{$dirTemp}" . mt_rand(1, 100000) . '.xlsx';
    $objWriter = PHPExcel_IOFactory::createWriter($xls_obj, 'Excel2007');
    $objWriter->save($filename);
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Content-Type: application/force-download');
    header('Content-Type: application/octet-stream');
    header('Content-Type: application/download');
    header("Content-Disposition: attachment;filename={$filename}");
    header('Content-Transfer-Encoding: binary');
    $objWriter->save('php://output');
    unlink($filename);
}
Example #14
0
 /**
  * prepare a json rpc request array
  *
  * @param $method
  * @param array $params
  * @return array
  */
 public function prepareRequest($method, array $params = [])
 {
     $request = ['jsonrpc' => '2.0', 'method' => $method, 'id' => mt_rand()];
     $request['params'] = $params ? $params : [];
     /*$request['params'] = array_merge($request['params'], $this->params);*/
     return $request;
 }
Example #15
0
 /**
  * Generate the form key based on IP address
  *
  * @return string md5sum of IP address + unique number
  */
 private function generateFormkey()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     // mt_rand() is better than rand()
     $uniqid = uniqid(mt_rand(), true);
     return md5($ip . $uniqid);
 }
	public function __construct($startTime, $endTime) {
		
		$this->id        = mt_rand (10000, 99999);
		$this->startTime = $startTime;
		$this->endTime   = $endTime;

	$this->monthArray = array(
    '01'        => "Janvier",
    '02'        => "Février",
    '03'        => "Mars",
    '04'        => "Avril",
    '05' 		 => "Mai",
	 '06'        => "Juin",
	 '07'        => "Juillet",
	 '08'        => "Août",
	 '09'        => "Septembre",
	 '10'        => "Octobre",
	 '11'        => "Novembre",
	 '12'        => "Décembre");

	$this->dayArray = array(
    '0'        => "Dimanche",
    '1'        => "Lundi",
    '2'        => "Mardi",
    '3'        => "Mercredi",
    '4' 		   => "Jeudi",
	 '5'        => "Vendredi",
	 '6'        => "Samedi");
	}
Example #17
0
/**
 * Build a secured file with token name
 *
 * @param string $reqkey The reference key
 *
 * @return string The secure key
 */
function buildSecFile($reqkey)
{
    $CI =& get_instance();
    $skey = mt_rand();
    $dir = $CI->config->item('token_dir');
    $file = $skey . '.tok';
    //make the file with the reqkey value in it
    file_put_contents($dir . '/' . $file, $reqkey);
    //do some cleanup - find ones older then the threshold and remove
    $rm = $CI->config->item('token_rm');
    //this is in minutes
    if (is_dir($dir)) {
        if (($h = opendir($dir)) !== false) {
            while (($file = readdir($h)) !== false) {
                if (!in_array($file, array('.', '..'))) {
                    $p = $dir . '/' . $file;
                    if (filemtime($p) < time() - $rm * 60) {
                        unlink($p);
                    }
                }
            }
        }
    }
    return $skey;
}
Example #18
0
 public function getName($type = 1)
 {
     $name = '';
     switch ($type) {
         case 1:
             // 2字
             $name = $this->getXing() . $this->getMing();
             break;
         case 2:
             // 随机2、3个字
             $name = $this->getXing() . $this->getMing();
             if (mt_rand(0, 100) > 50) {
                 $name .= $this->getMing();
             }
             break;
         case 3:
             // 只取姓
             $name = $this->getXing();
             break;
         case 4:
             // 只取名
             $name = $this->getMing();
             break;
         case 0:
         default:
             // 默认情况 1姓+2名
             $name = $this->getXing() . $this->getMing() . $this->getMing();
     }
     return $name;
 }
 function CaptchaSecurityImages($width = '120', $height = '40', $characters = '6')
 {
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.5;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 20, 20, 20);
     $text_color = imagecolorallocate($image, 230, 197, 89);
     $noise_color = imagecolorallocate($image, 0, 0, 0);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     /*for( $i=0; $i<($width*$height)/150; $i++ ) {
     			imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
     		}*/
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $_SESSION['security_code'] = $code;
 }
	function execute( $par ) {
		$this->setHeaders();
		$this->outputHeader();

		// Purge expired entries on one in every 10 queries
		if ( !mt_rand( 0, 10 ) ) {
			Title::purgeExpiredRestrictions();
		}

		$request = $this->getRequest();
		$type = $request->getVal( $this->IdType );
		$level = $request->getVal( $this->IdLevel );
		$sizetype = $request->getVal( 'sizetype' );
		$size = $request->getIntOrNull( 'size' );
		$NS = $request->getIntOrNull( 'namespace' );

		$pager = new ProtectedTitlesPager( $this, array(), $type, $level, $NS, $sizetype, $size );

		$this->getOutput()->addHTML( $this->showOptions( $NS, $type, $level ) );

		if ( $pager->getNumRows() ) {
			$this->getOutput()->addHTML(
				$pager->getNavigationBar() .
					'<ul>' . $pager->getBody() . '</ul>' .
					$pager->getNavigationBar()
			);
		} else {
			$this->getOutput()->addWikiMsg( 'protectedtitlesempty' );
		}
	}
Example #21
0
 protected function initSharedSession()
 {
     $cookie_name = $this->getSharedSessionCookieName();
     if (isset($_COOKIE[$cookie_name])) {
         $data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
         if ($data && !empty($data['domain']) && self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
             // good case
             $this->sharedSessionID = $data['id'];
             return;
         }
         // ignoring potentially unreachable data
     }
     // evil/corrupt/missing case
     $base_domain = $this->getBaseDomain();
     $this->sharedSessionID = md5(uniqid(mt_rand(), true));
     $cookie_value = $this->makeSignedRequest(array('domain' => $base_domain, 'id' => $this->sharedSessionID));
     $_COOKIE[$cookie_name] = $cookie_value;
     if (!headers_sent()) {
         $expire = time() + self::FBSS_COOKIE_EXPIRE;
         setcookie($cookie_name, $cookie_value, $expire, '/', '.' . $base_domain);
     } else {
         // @codeCoverageIgnoreStart
         self::errorLog('Shared session ID cookie could not be set! You must ensure you ' . 'create the Facebook instance before headers have been sent. This ' . 'will cause authentication issues after the first request.');
         // @codeCoverageIgnoreEnd
     }
 }
Example #22
0
 function randNumber($len = 6, $start = false, $end = false)
 {
     mt_srand((double) microtime() * 1000000);
     $start = !$len && $start ? $start : str_pad(1, $len, "0", STR_PAD_RIGHT);
     $end = !$len && $end ? $end : str_pad(9, $len, "9", STR_PAD_RIGHT);
     return mt_rand($start, $end);
 }
Example #23
0
 /**
  * Get the specified number of random bytes.
  *
  * Attempts to use a cryptographically secure (not predictable)
  * source of randomness if available. If there is no high-entropy
  * randomness source available, it will fail. As a last resort,
  * for non-critical systems, define
  * <code>Auth_OpenID_RAND_SOURCE</code> as <code>null</code>, and
  * the code will fall back on a pseudo-random number generator.
  *
  * @param int $num_bytes The length of the return value
  * @return string $bytes random bytes
  */
 function getBytes($num_bytes)
 {
     static $f = null;
     $bytes = '';
     if ($f === null) {
         if (Auth_OpenID_RAND_SOURCE === null) {
             $f = false;
         } else {
             $f = @fopen(Auth_OpenID_RAND_SOURCE, "r");
             if ($f === false) {
                 $msg = 'Define Auth_OpenID_RAND_SOURCE as null to ' . ' continue with an insecure random number generator.';
                 trigger_error($msg, E_USER_ERROR);
             }
         }
     }
     if ($f === false) {
         // pseudorandom used
         $bytes = '';
         for ($i = 0; $i < $num_bytes; $i += 4) {
             $bytes .= pack('L', mt_rand());
         }
         $bytes = substr($bytes, 0, $num_bytes);
     } else {
         $bytes = fread($f, $num_bytes);
     }
     return $bytes;
 }
Example #24
0
 function postContent()
 {
     if (!($user = \Idno\Core\site()->session()->currentUser())) {
         $this->setResponse(403);
         echo 'You must be logged in to approve IndieAuth requests.';
         exit;
     }
     $me = $this->getInput('me');
     $client_id = $this->getInput('client_id');
     $redirect_uri = $this->getInput('redirect_uri');
     $state = $this->getInput('state');
     $scope = $this->getInput('scope');
     if (!empty($me) && parse_url($me, PHP_URL_HOST) == parse_url($user->getURL(), PHP_URL_HOST)) {
         $indieauth_codes = $user->indieauth_codes;
         if (empty($indieauth_codes)) {
             $indieauth_codes = array();
         }
         $code = md5(rand(0, 99999) . time() . $user->getUUID() . $client_id . $state . rand(0, 999999));
         $indieauth_codes[$code] = array('me' => $me, 'redirect_uri' => $redirect_uri, 'scope' => $scope, 'state' => $state, 'client_id' => $client_id, 'issued_at' => time(), 'nonce' => mt_rand(1000000, pow(2, 30)));
         $user->indieauth_codes = $indieauth_codes;
         $user->save();
         if (strpos($redirect_uri, '?') === false) {
             $redirect_uri .= '?';
         } else {
             $redirect_uri .= '&';
         }
         $redirect_uri .= http_build_query(array('code' => $code, 'state' => $state, 'me' => $me));
         $this->forward($redirect_uri);
     }
 }
 public function executeRawQuery($raw_query)
 {
     // NOTE: "[\s<>K]*" allows any number of (properly escaped) comments to
     // appear prior to the allowed keyword, since this connection escapes
     // them as "<K>" (above).
     $keywords = array('INSERT', 'UPDATE', 'DELETE', 'START', 'SAVEPOINT', 'COMMIT', 'ROLLBACK');
     $preg_keywords = array();
     foreach ($keywords as $key => $word) {
         $preg_keywords[] = preg_quote($word, '/');
     }
     $preg_keywords = implode('|', $preg_keywords);
     if (!preg_match('/^[\\s<>K]*(' . $preg_keywords . ')\\s*/i', $raw_query)) {
         throw new AphrontQueryNotSupportedException("Database isolation currently only supports some queries. You are " . "trying to issue a query which does not begin with an allowed " . "keyword (" . implode(', ', $keywords) . "): '" . $raw_query . "'");
     }
     $this->transcript[] = $raw_query;
     // NOTE: This method is intentionally simplified for now, since we're only
     // using it to stub out inserts/updates. In the future it will probably need
     // to grow more powerful.
     $this->allResults = array();
     // NOTE: We jitter the insert IDs to keep tests honest; a test should cover
     // the relationship between objects, not their exact insertion order. This
     // guarantees that IDs are unique but makes it impossible to hard-code tests
     // against this specific implementation detail.
     self::$nextInsertID += mt_rand(1, 10);
     $this->insertID = self::$nextInsertID;
     $this->affectedRows = 1;
 }
Example #26
0
 /**
  *	ВНЕШНИЕ МЕТОДЫ
  */
 function bannerShow($banner_category_id)
 {
     global $AVE_DB;
     mt_rand();
     $output = '';
     $cur_hour = date('G');
     $and_time = "AND ((banner_show_start = '0' AND banner_show_end = '0') OR (banner_show_start <= '" . $cur_hour . "' AND banner_show_end > '" . $cur_hour . "') OR (banner_show_start > banner_show_end AND (banner_show_start BETWEEN banner_show_start AND '" . $cur_hour . "' OR banner_show_end BETWEEN '" . $cur_hour . "' AND banner_show_end)))";
     $and_category = is_numeric($banner_category_id) ? "AND banner_category_id = '" . $banner_category_id . "'" : '';
     $num = $AVE_DB->Query("\r\n\t\t\tSELECT 1\r\n\t\t\tFROM " . PREFIX . "_modul_banners\r\n\t\t\tWHERE banner_status = '1'\r\n\t\t\tAND (banner_max_clicks = '0' OR (banner_clicks < banner_max_clicks AND banner_max_clicks != '0'))\r\n\t\t\tAND (banner_max_views  = '0' OR (banner_views  < banner_max_views  AND banner_max_views  != '0'))\r\n\t\t\t" . $and_time . "\r\n\t\t\t" . $and_category . "\r\n\t\t")->NumRows();
     $zufall = $num ? rand(1, 3) : 3;
     $sql = $AVE_DB->Query("\r\n\t\t\tSELECT\r\n\t\t\t\tId,\r\n\t\t\t\tbanner_file_name,\r\n\t\t\t\tbanner_target,\r\n\t\t\t\tbanner_name,\r\n\t\t\t\tbanner_alt,\r\n\t\t\t\tbanner_width,\r\n\t\t\t\tbanner_height\r\n\t\t\tFROM " . PREFIX . "_modul_banners\r\n\t\t\tWHERE banner_status = '1'\r\n\t\t\tAND (banner_max_clicks = '0' OR (banner_clicks < banner_max_clicks AND banner_max_clicks != '0'))\r\n\t\t\tAND (banner_max_views  = '0' OR (banner_views  < banner_max_views  AND banner_max_views  != '0'))\r\n\t\t\t" . $and_time . "\r\n\t\t\t" . $and_category . "\r\n\t\t\tAND banner_priority <= '" . $zufall . "'\r\n\t\t");
     $num = $sql->NumRows();
     $banner_id = $num == 1 ? 0 : rand(0, $num - 1);
     $sql->DataSeek($banner_id);
     $banner = $sql->FetchAssocArray();
     if (!empty($banner['banner_file_name'])) {
         if (stristr($banner['banner_file_name'], '.swf') === false) {
             $output = '<a target="' . $banner['banner_target'] . '" href="' . ABS_PATH . 'index.php?module=' . BANNER_DIR . '&amp;action=go&amp;id=' . $banner['Id'] . '"><img src="' . ABS_PATH . 'modules/' . BANNER_DIR . '/files/' . $banner['banner_file_name'] . '" alt="' . $banner['banner_name'] . ': ' . $banner['banner_alt'] . '" border="0" /></a>';
         } else {
             $output = '<div style="position:relative;border:0px;width:' . $banner['banner_width'] . 'px;height:' . $banner['banner_height'] . 'px;"><a target="' . $banner['banner_target'] . '" href="' . ABS_PATH . 'index.php?module=' . BANNER_DIR . '&amp;action=go&amp;id=' . $banner['Id'] . '" style="position:absolute;z-index:2;width:' . $banner['banner_width'] . 'px;height:' . $banner['banner_height'] . 'px;_background:red;_filter:alpha(opacity=0);"></a>';
             $output .= '	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' . $banner['banner_width'] . '" height="' . $banner['banner_height'] . '" id="reklama" align="middle">';
             $output .= '		<param name="allowScriptAccess" value="sameDomain" />';
             $output .= '		<param name="movie" value="' . ABS_PATH . 'modules/' . BANNER_DIR . '/files/' . $banner['banner_file_name'] . '" />';
             $output .= '		<param name="quality" value="high" />';
             $output .= '		<param name="wmode" value="opaque">';
             $output .= '		<embed src="' . ABS_PATH . 'modules/' . BANNER_DIR . '/files/' . $banner['banner_file_name'] . '" quality="high" wmode="opaque" width="' . $banner['banner_width'] . '" height="' . $banner['banner_height'] . '" name="reklama" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
             $output .= '	</object>';
             $output .= '</div>';
         }
         if (!empty($banner['Id'])) {
             $AVE_DB->Query("\r\n\t\t\t\t\tUPDATE " . PREFIX . "_modul_banners\r\n\t\t\t\t\tSET banner_views = banner_views + 1\r\n\t\t\t\t\tWHERE Id = '" . $banner['Id'] . "'\r\n\t\t\t\t");
         }
     }
     echo $output;
 }
 function pick($context, $source, $comment)
 {
     if ($this->handlerCount() == 0) {
         return -1;
     }
     return mt_rand(0, $this->handlerCount() - 1);
 }
Example #28
-1
 function getToken($table, $campo, $uc = TRUE, $n = TRUE, $sc = TRUE, $largo = 15)
 {
     $db = new db_core();
     $source = 'abcdefghijklmnopqrstuvwxyz';
     if ($uc == 1) {
         $source .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     }
     if ($n == 1) {
         $source .= '1234567890';
     }
     if ($sc == 1) {
         $source .= '|@#~$%()=^*+[]{}-_';
     }
     $rstr = "";
     while (true) {
         $rstr = "";
         $source = str_split($source, 1);
         for ($i = 1; $i <= $largo; $i++) {
             mt_srand((double) microtime() * 1000000);
             $num = mt_rand(1, count($source));
             $rstr .= $source[$num - 1];
         }
         if (!$db->isExists($table, $campo, $rstr)) {
             break;
         }
     }
     return $rstr;
 }
Example #29
-2
 protected function setUp()
 {
     parent::setUp();
     // Create Basic page node type.
     $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
     $vocabulary = entity_create('taxonomy_vocabulary', array('name' => $this->randomMachineName(), 'description' => $this->randomMachineName(), 'vid' => Unicode::strtolower($this->randomMachineName()), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('page' => 'page'), 'weight' => mt_rand(0, 10)));
     $vocabulary->save();
     // Create a field.
     $field_name = Unicode::strtolower($this->randomMachineName());
     $handler_settings = array('target_bundles' => array($vocabulary->id() => $vocabulary->id()), 'auto_create' => TRUE);
     $this->createEntityReferenceField('node', 'page', $field_name, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
     // Create a time in the past for the archive.
     $time = REQUEST_TIME - 3600;
     $this->addDefaultCommentField('node', 'page');
     for ($i = 0; $i <= 10; $i++) {
         $user = $this->drupalCreateUser();
         $term = $this->createTerm($vocabulary);
         $values = array('created' => $time, 'type' => 'page');
         $values[$field_name][]['target_id'] = $term->id();
         // Make every other node promoted.
         if ($i % 2) {
             $values['promote'] = TRUE;
         }
         $values['body'][]['value'] = \Drupal::l('Node ' . 1, new Url('entity.node.canonical', ['node' => 1]));
         $node = $this->drupalCreateNode($values);
         $comment = array('uid' => $user->id(), 'status' => CommentInterface::PUBLISHED, 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment');
         entity_create('comment', $comment)->save();
     }
     // Some views, such as the "Who's Online" view, only return results if at
     // least one user is logged in.
     $account = $this->drupalCreateUser(array());
     $this->drupalLogin($account);
 }