function code() { $fontSize = 20; //定义字体大小 $length = 5; //定义字符串长度 $strNum = GetVerify($length); //获取一个随机字符串 $_SESSION['verify'] = $strNum; //付值给session $width = 90; //定义图片宽度 $height = 30; //定义图片高度 $im = imagecreate($width, $height); //生成一张指定宽高的图片 $backgroundcolor = imagecolorallocate($im, 255, 255, 255); //生成背景色 $frameColor = imageColorAllocate($im, 150, 150, 150); //生成边框色 $font = './system/fonts/arial.ttf'; //提取字体文件,开始写字 for ($i = 0; $i < $length; $i++) { $charY = ($height + 9) / 2 + rand(-1, 1); //定义字符Y坐标 $charX = $i * 15 + 8; //定义字符X坐标 //生成字符颜色 $text_color = imagecolorallocate($im, mt_rand(50, 200), mt_rand(50, 128), mt_rand(50, 200)); $angle = rand(-20, 20); //生成字符角度 //写入字符 imageTTFText($im, $fontSize, $angle, $charX, $charY, $text_color, $font, $strNum[$i]); } for ($i = 0; $i <= 5; $i++) { //循环画背景线 $linecolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); $linex = mt_rand(1, $width - 1); $liney = mt_rand(1, $height - 1); imageline($im, $linex, $liney, $linex + mt_rand(0, 4) - 2, $liney + mt_rand(0, 4) - 2, $linecolor); } for ($i = 0; $i <= 32; $i++) { //循环画背景点,生成麻点效果 $pointcolor = imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); imagesetpixel($im, mt_rand(1, $width - 1), mt_rand(1, $height - 1), $pointcolor); } imagerectangle($im, 0, 0, $width - 1, $height - 1, $frameColor); //画边框 //ob_clean(); //header('Content-type: image/png'); imagepng($im); imagedestroy($im); return $strNum; }
$img = @opendir("{$imgdir}/face"); while ($imgname = @readdir($img)) { if ($imgname != '.' && $imgname != '..' && $imgname != '' && preg_match('/\\.(gif|jpg|png|bmp)$/i', $imgname)) { $num++; $imgname_array[] = $imgname; if ($num >= 10) { break; } } } @closedir($img); //flash头像上传参数 if ($db_ifupload && $_G['upload']) { list($db_upload, $db_imglen, $db_imgwidth, $db_imgsize) = explode("\t", $db_upload); $pwServer['HTTP_USER_AGENT'] = 'Shockwave Flash'; $swfhash = GetVerify($winduid); $upload_param = rawurlencode($db_bbsurl . '/job.php?action=uploadicon&verify=' . $swfhash . '&uid=' . $winduid . '&'); $save_param = rawurlencode($db_bbsurl . '/job.php?action=uploadicon&step=2&'); $default_pic = rawurlencode("{$db_picpath}/facebg.jpg"); $icon_encode_url = 'up=' . $upload_param . '&saveFace=' . $save_param . '&url=' . $default_pic . '&PHPSESSID=' . $sid . '&' . 'imgsize=' . $db_imgsize . '&'; } else { $icon_encode_url = ''; } if ($userdb['timedf']) { $temptimedf = str_replace('.', '_', abs($userdb['timedf'])); $userdb['timedf'] < 0 ? ${'zone_0' . $temptimedf} = 'selected' : (${'zone_' . $temptimedf} = 'selected'); } $ubinding = array(); $query = $db->query("SELECT m.uid,m.username,m.groupid,m.memberid,m.regdate,mb.postnum FROM pw_userbinding u1 LEFT JOIN pw_userbinding u2 ON u1.id=u2.id LEFT JOIN pw_members m ON m.uid=u2.uid LEFT JOIN pw_memberdata mb ON m.uid=mb.uid WHERE u1.uid=" . pwEscape($winduid)); while ($rt = $db->fetch_array($query)) { if ($rt['uid'] != $winduid) {
<?php !defined('P_W') && exit('Forbidden'); echo $verifyhash . "\t" . GetVerify($onlineip . $winddb['regdate'] . $fid . $tid); ajax_footer();
PwUpload::movetoftp($middleFile, $middleDir . $filename); $s_ifthumb && PwUpload::movetoftp($smallFile, $smallDir . $filename); } pwFtpClose($GLOBALS['ftp']); $user_a = explode('|', $winddb['icon']); $user_a[2] = $img_w; $user_a[3] = $img_h; $usericon = setIcon("{$udir}/{$winduid}.{$ext}", 3, $user_a); $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $userService->update($winduid, array('icon' => $usericon)); //* $db->update("DELETE FROM pw_datastore WHERE skey=". S::sqlEscape("UID_".$winduid). " LIMIT 1"); //job sign initJob($winduid, "doUpdateAvatar"); if ($from != 'reg') { refreshto('profile.php?action=modify&info_type=face', 'upload_icon_success'); } $jobService = L::loadclass('job', 'job'); $jobs = $jobService->getJobByJobName('doUpdateAvatar'); foreach ($jobs as $value) { if (!S::isArray($value)) { continue; } $jobService->jobGainController($winduid, $value['id']); } $verifyhash = GetVerify($winduid); refreshto("{$db_registerfile}?step=finish&option=2&verify={$verifyhash}", 'upload_icon_success'); } else { Showmsg('upload_icon_fail'); } }
<?php session_start(); function GetVerify($length) { //$strings = Array('3','4','5','6','7','a','b','c','d','e','f','h','i','j','k','m','n','p','r','s','t','u','v','w','x','y'); $strings = Array('1','2','3','4','5','6','7','8','9','10'); $chrNum = ""; $count = count($strings); for ($i = 1; $i <= $length; $i++) { //ѭȡַַ $chrNum .= $strings[rand(0,$count-1)]; } return $chrNum; } $fontSize = 18; //С $length = 4; //ַ $strNum = GetVerify($length); //ȡһַ $_SESSION['verifys'] = $strNum; //ֵsession $width = 80; //ͼƬ $height = 25; //ͼƬ߶ $im = imagecreate($width,$height); //һָߵͼƬ $backgroundcolor = imagecolorallocate ($im, 255, 255, 255); //ɱɫ $frameColor = imageColorAllocate($im, 150, 150, 150); //ɱ߿ɫ $font = realpath("./Plugs/ARIAL.TTF"); //ȡļʼд for($i = 0; $i < $length; $i++) { $charY = ($height+9)/2 + rand(-1,1); //ַY $charX = $i*15+22; //ַX //ַɫ $text_color = imagecolorallocate($im, mt_rand(50, 200), mt_rand(50, 128), mt_rand(50, 200)); $angle = rand(-20,20); //ַǶ //дַ imageTTFText($im, $fontSize, $angle, $charX, $charY, $text_color, $font, $strNum[$i]);
<?php !function_exists('readover') && exit('Forbidden'); if (empty($_GET['step'])) { list($db_upload, $db_imglen, $db_imgwidth, $db_imgsize) = explode("\t", $db_upload); S::gp(array('uid', 'verify')); $swfhash = GetVerify($uid); checkVerify('swfhash'); $db_uploadfiletype = array(); $db_uploadfiletype['gif'] = $db_uploadfiletype['jpg'] = $db_uploadfiletype['bmp'] = $db_uploadfiletype['png'] = $db_imgsize; L::loadClass('upload', '', false); $pwupload = new PwUpload(new FaceUpload()); $pwupload->upload($uid); $uploaddb = $pwupload->getAttachs(); echo $db_bbsurl . '/' . $attachpath . '/' . $uploaddb['fileuploadurl'] . '?' . $timestamp; exit; } else { require_once R_P . 'require/functions.php'; L::loadClass('upload', '', false); $ext = strtolower(substr(strrchr($_GET['filename'], '.'), 1)); $udir = str_pad(substr($winduid, -2), 2, '0', STR_PAD_LEFT); $source = PwUpload::savePath($db_ifftp, "{$winduid}_tmp.{$ext}", "upload/{$udir}/"); if (!file_exists($source)) { Showmsg('undefined_action'); } $data = $_SERVER['HTTP_RAW_POST_DATA'] ? $_SERVER['HTTP_RAW_POST_DATA'] : file_get_contents('php://input'); if ($data) { require_once R_P . 'require/showimg.php'; $filename = "{$winduid}.jpg"; $normalDir = "upload/{$udir}/"; $middleDir = "upload/middle/{$udir}/";
$_G['uploadtype'] && ($db_uploadfiletype = $_G['uploadtype']); $db_uploadfiletype = !empty($db_uploadfiletype) ? is_array($db_uploadfiletype) ? $db_uploadfiletype : unserialize($db_uploadfiletype) : array(); $filetype = ''; foreach ($db_uploadfiletype as $key => $value) { $filetype .= ($filetype ? ',' : '') . $key . ':' . $value; } $pwServer['HTTP_USER_AGENT'] = 'Shockwave Flash'; $swfhash = GetVerify($winduid); echo pwJsonEncode(array('uid' => $winduid, 'step' => 2, 'verify' => $swfhash)); } else { define('AJAX', 1); S::gp(array('uid', 'type', 'verify', 'ua'), 'P'); S::gp(array('type')); $uid = intval($uid); !$ua && ($pwServer['HTTP_USER_AGENT'] = 'Shockwave Flash'); $swfhash = GetVerify($uid ? $uid : ''); checkVerify('verify'); if (!$db_allowupload) { showExtraMsg('upload_close'); } $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $winddb = $userService->get($uid); //groupid,memberid !$winddb && showExtraMsg('not_login'); $groupid = $winddb['groupid'] == '-1' ? $winddb['memberid'] : $winddb['groupid']; if (file_exists(D_P . "data/groupdb/group_{$groupid}.php")) { //* require_once pwCache::getPath(S::escapePath(D_P . "data/groupdb/group_$groupid.php")); pwCache::getData(S::escapePath(D_P . "data/groupdb/group_{$groupid}.php")); } else { //* require_once pwCache::getPath(D_P . 'data/groupdb/group_1.php');