function create_random_string($length, $type = 'mixed') { if (!in_array($type, array('mixed', 'chars', 'digits'))) { return false; } $chars_pattern = 'abcdefghijklmnopqrstuvwxyz'; $mixed_pattern = '1234567890' . $chars_pattern; $rand_value = ''; while (strlen($rand_value) < $length) { if ($type == 'digits') { $rand_value .= _rand(0, 9); } elseif ($type == 'chars') { $rand_value .= substr($chars_pattern, _rand(0, 25), 1); } else { $rand_value .= substr($mixed_pattern, _rand(0, 35), 1); } } return $rand_value; }
<?php $rows_type = $mysql->query("select * from `typedata` order by `id` desc"); //print_r($rows_type); //$count_type=count($rows_type); foreach ($rows_type as $v_type) { echo "<a href=\"?type={$v_type['id']}\" class=\"btn\">{$v_type['name']}</a>"; } ?> </div> </div> </div> </header> <div class="list_content"> <?php //转发多域名支持 $rand_sitehead = _rand(6); $arr_sharesite = explode('#', $config['sharesite']); $rand = array_rand($arr_sharesite); $sharesite = $arr_sharesite[$rand]; $sharesite = str_replace('*', $rand_sitehead, $sharesite); //fan foreach ($rows as $row) { $row_pic = str_replace('[weixin]', 'http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=135&h=90&url=', $row['pic']); if ($row['pv_max'] == '-1') { $pv_max = '无限投放'; } else { $pv_max = $row['pv_max']; } if ($row['top'] == 1) { print <<<div <section class="middle_mode has_action">
function encrypt_string($plain) { $password = ''; for ($i = 0; $i < 10; $i++) { $password .= _rand(); } $salt = substr(md5($password), 0, 2); $password = md5($salt . $plain) . ':' . $salt; return $password; }
function randomQueryMulti($query) { $resource = $this->simpleQuery($query); $num_rows = $this->numberOfRows($resource); if ($num_rows > 0) { $random_row = _rand(0, $num_rows - 1); $this->dataSeek($random_row, $resource); return $resource; } else { return false; } }
/** * _code() 调用生成一张验证码图片 * @access public * @param number $width 图片宽度 * @param number $height 图片高度 * @param number $code_count 验证码位数 * @param string $border 是否需要边框 * @return 打印一张验证码图片 */ function _code($width = 75, $height = 25, $code_count = 4, $border = false) { for ($i = 0; $i < $code_count; $i++) { $code .= dechex(mt_rand(0, 15)); } $_SESSION['code'] = $code; $image = @imagecreatetruecolor($width, $height); // 创建白色画笔 $white = imagecolorallocate($image, 255, 255, 255); imagefill($image, 0, 0, $white); // 创建黑色画笔 $black = imagecolorallocate($image, 0, 0, 0); if ($border) { // 创建边框 imagerectangle($image, 0, 0, $width - 1, $height - 1, $black); } // 随机画六条直线 for ($line = 0; $line < 6; $line++) { $line_rnd_color = imagecolorallocate($image, _rand(255), _rand(255), _rand(255)); imageline($image, _rand($width), _rand($height), _rand($width), _rand($height), $line_rnd_color); } // 随机打印雪花 for ($snow = 0; $snow < 100; $snow++) { $snow_rnd_color = imagecolorallocate($image, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255)); imagestring($image, 1, _rand($width), _rand($height), '*', $snow_rnd_color); } //打印验证码 for ($code_index = 0; $code_index < $code_count; $code_index++) { $code_rnd_color = imagecolorallocate($image, _rand(100), _rand(150), _rand(200)); imagestring($image, mt_rand(3, 5), $code_index * $width / 4 + _rand(10), _rand($height / 2), $_SESSION['code'][$code_index], $color); } imagepng($image); imagedestroy($image); }