亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

快瘋了 都寫到這里了?。。。。。。。。?!

回到login 驗證碼就掛掉了,image.func.php里可以調用verifyImage函數,到了getVerify就不可以調用了 - - 瘋了?

<?php?
require_once?'string.func.php';
//通過GD庫做驗證碼
function?verifyImage($type=1,$length=4,$pixel=0,$line=0,$sess_name?=?"verify"){
	session_start();
	//創建畫布
	$width?=?80;
	$height?=?28;
	$image?=?imagecreatetruecolor?(?$width,?$height?);
	$white?=?imagecolorallocate?(?$image,?255,?255,?255?);
	$black?=?imagecolorallocate?(?$image,?0,?0,?0?);
	//用填充矩形填充畫布
	imagefilledrectangle?(?$image,?1,?1,?$width?-?2,?$height?-?2,?$white?);
	$chars?=?buildRandomString?(?$type,?$length?);
	$_SESSION?[$sess_name]?=?$chars;
	//$fontfiles?=?array?("MSYH.TTF",?"MSYHBD.TTF",?"SIMLI.TTF",?"SIMSUN.TTC",?"SIMYOU.TTF",?"STZHONGS.TTF"?);
	$fontfiles?=?array?("SIMYOU.TTF"?);
	//由于字體文件比較大,就只保留一個字體,如果有需要的同學可以自己添加字體,字體在你的電腦中的fonts文件夾里有,直接運行輸入fonts就能看到相應字體
	for($i?=?0;?$i?<?$length;?$i?++)?{
		$size?=?mt_rand?(?14,?18?);
		$angle?=?mt_rand?(?-?15,?15?);
		$x?=?5?+?$i?*?$size;
		$y?=?mt_rand?(?20,?26?);
		$fontfile?=?"../fonts/"?.?$fontfiles?[mt_rand?(?0,?count?(?$fontfiles?)?-?1?)];
		$color?=?imagecolorallocate?(?$image,?mt_rand?(?50,?90?),?mt_rand?(?80,?200?),?mt_rand?(?90,?180?)?);
		$text?=?substr?(?$chars,?$i,?1?);
		imagettftext?(?$image,?$size,?$angle,?$x,?$y,?$color,?$fontfile,?$text?);
	}
	if?($pixel)?{
		for($i?=?0;?$i?<?50;?$i?++)?{
			imagesetpixel?(?$image,?mt_rand?(?0,?$width?-?1?),?mt_rand?(?0,?$height?-?1?),?$black?);
		}
	}
	if?($line)?{
		for($i?=?1;?$i?<?$line;?$i?++)?{
			$color?=?imagecolorallocate?(?$image,?mt_rand?(?50,?90?),?mt_rand?(?80,?200?),?mt_rand?(?90,?180?)?);
			imageline?(?$image,?mt_rand?(?0,?$width?-?1?),?mt_rand?(?0,?$height?-?1?),?mt_rand?(?0,?$width?-?1?),?mt_rand?(?0,?$height?-?1?),?$color?);
		}
	}
	header?(?"content-type:image/gif"?);
	imagegif?(?$image?);
	imagedestroy?(?$image?);
}
/**
?*?生成縮略圖
?*?@param?string?$filename
?*?@param?string?$destination
?*?@param?int?$dst_w
?*?@param?int?$dst_h
?*?@param?bool?$isReservedSource
?*?@param?number?$scale
?*?@return?string
?*/
function?thumb($filename,$destination=null,$dst_w=null,$dst_h=null,$isReservedSource=true,$scale=0.5){
	list($src_w,$src_h,$imagetype)=getimagesize($filename);
	if(is_null($dst_w)||is_null($dst_h)){
		$dst_w=ceil($src_w*$scale);
		$dst_h=ceil($src_h*$scale);
	}
	$mime=image_type_to_mime_type($imagetype);
	$createFun=str_replace("/",?"createfrom",?$mime);
	$outFun=str_replace("/",?null,?$mime);
	$src_image=$createFun($filename);
	$dst_image=imagecreatetruecolor($dst_w,?$dst_h);
	imagecopyresampled($dst_image,?$src_image,?0,0,0,0,?$dst_w,?$dst_h,?$src_w,?$src_h);
	if($destination&&!file_exists(dirname($destination))){
		mkdir(dirname($destination),0777,true);
	}
	$dstFilename=$destination==null?getUniName().".".getExt($filename):$destination;
	$outFun($dst_image,$dstFilename);
	imagedestroy($src_image);
	imagedestroy($dst_image);
	if(!$isReservedSource){
		unlink($filename);
	}
	return?$dstFilename;
}

/**
?*添加文字水印
?*?@param?string?$filename
?*?@param?string?$text
?*?@param?string??$fontfile
?*/
function?waterText($filename,$text="imooc.com",$fontfile="MSYH.TTF"){
	$fileInfo?=?getimagesize?(?$filename?);
	$mime?=?$fileInfo?['mime'];
	$createFun?=?str_replace?(?"/",?"createfrom",?$mime?);
	$outFun?=?str_replace?(?"/",?null,?$mime?);
	$image?=?$createFun?(?$filename?);
	$color?=?imagecolorallocatealpha?(?$image,?255,?0,?0,?50?);
	$fontfile?=?"../fonts/{$fontfile}";
	imagettftext?(?$image,?14,?0,?0,?14,?$color,?$fontfile,?$text?);
	$outFun?(?$image,?$filename?);
	imagedestroy?(?$image?);
}

/**
?*添加圖片水印
?*?@param?string?$dstFile
?*?@param?string?$srcFile
?*?@param?int?$pct
?*/
function?waterPic($dstFile,$srcFile="../images/logo.jpg",$pct=30){
	$srcFileInfo?=?getimagesize?(?$srcFile?);
	$src_w?=?$srcFileInfo?[0];
	$src_h?=?$srcFileInfo?[1];
	$dstFileInfo?=?getimagesize?(?$dstFile?);
	$srcMime?=?$srcFileInfo?['mime'];
	$dstMime?=?$dstFileInfo?['mime'];
	$createSrcFun?=?str_replace?(?"/",?"createfrom",?$srcMime?);
	$createDstFun?=?str_replace?(?"/",?"createfrom",?$dstMime?);
	$outDstFun?=?str_replace?(?"/",?null,?$dstMime?);
	$dst_im?=?$createDstFun?(?$dstFile?);
	$src_im?=?$createSrcFun?(?$srcFile?);
	imagecopymerge?(?$dst_im,?$src_im,?0,?0,?0,?0,?$src_w,?$src_h,?$pct?);
//	header?(?"content-type:"?.?$dstMime?);
	$outDstFun?(?$dst_im,?$dstFile?);
	imagedestroy?(?$src_im?);
	imagedestroy?(?$dst_im?);
}

login.php
<!doctype?html>
<html>
<head>
<meta?charset="utf-8">
<title>登陸</title>
<link?type="text/css"?rel="stylesheet"?href="../styles/reset.css">
<link?type="text/css"?rel="stylesheet"?href="../styles/main.css">
<!--[if?IE?6]>
<script?type="text/javascript"?src="../js/DD_belatedPNG_0.0.8a-min.js"></script>
<script?type="text/javascript"?src="../js/ie6Fixpng.js"></script>
<![endif]-->
</head>

<body>
<div?class="headerBar">
	<div?class="logoBar?login_logo">
		<div?class="comWidth">
			<div?class="logo?fl">
				<a?href="#"><img?src="../images/logo.jpg"?alt="慕課網"></a>
			</div>
			<h3?class="welcome_title">歡迎登陸</h3>
		</div>
	</div>
</div>

<div?class="loginBox">
	<div?class="login_cont">
	<form?action="doLogin.php"?method="post">
			<ul?class="login">
				<li?class="l_tit">管理員帳號</li>
				<li?class="mb_10"><input?type="text"??name="username"?placeholder="請輸入管理員帳號"class="login_input?user_icon"></li>
				<li?class="l_tit">密碼</li>
				<li?class="mb_10"><input?type="password"??name="password"?class="login_input?password_icon"></li>
				<li?class="l_tit">驗證碼</li>
				<li?class="mb_10"><input?type="text"??name="verify"?class="login_input?password_icon"></li>
				<img?src="getVerify.php"?alt=""?/>
				<li?class="autoLogin"><input?type="checkbox"?id="a1"?class="checked"?name="autoFlag"?value="1"><label?for="a1">自動登陸(一周內自動登陸)</label></li>
				<li><input?type="submit"?value=""?class="login_btn"></li>
			</ul>
		</form>
	</div>
</div>

<div?class="hr_25"></div>
<div?class="footer">
	<p><a?href="#">慕課簡介</a><i>|</i><a?href="#">慕課公告</a><i>|</i>?<a?href="#">招納賢士</a><i>|</i><a?href="#">聯系我們</a><i>|</i>客服熱線:400-675-1234</p>
	<p>Copyright?&copy;?2006?-?2014?慕課版權所有&nbsp;&nbsp;&nbsp;京ICP備09037834號&nbsp;&nbsp;&nbsp;京ICP證B1034-8373號&nbsp;&nbsp;&nbsp;某市公安局XX分局備案編號:123456789123</p>
	<p?class="web"><a?href="#"><img?src="../images/webLogo.jpg"?alt="logo"></a><a?href="#"><img?src="../images/webLogo.jpg"?alt="logo"></a><a?href="#"><img?src="../images/webLogo.jpg"?alt="logo"></a><a?href="#"><img?src="../images/webLogo.jpg"?alt="logo"></a></p>
</div>
</body>
</html>

<?php?

require_once '../include.php';

verifyImage();


正在回答

4 回答

我之前也是,你試試把include里面都加上dirname(__FILE__).

即最后變成 ?require_once (dirname(__FILE__).'/'.'../include.php');

貌似是嵌套引用時,../是根據當前文件目錄設定的,因此嵌套進第二個文件時,../的計算還是上一個的,所以

用dirname(_FILE_)計算一下當前目錄

0 回復 有任何疑惑可以回復我~

include.php 中設置路徑對了嘛 ? 引用了 image.func.php 了嘛?


0 回復 有任何疑惑可以回復我~

不可能吧,你是不是沒有添加字體文件啊。image.func.php沒有調用verifyIamge,只是寫了而已。

0 回復 有任何疑惑可以回復我~

我現在不得不把驗證碼干掉了- -?

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
手把手教你實現電商網站后臺開發
  • 參與學習       117253    人
  • 解答問題       2101    個

手把手教你用PHP搭建電子商務平臺,由淺入深教你搭建電商系統

進入課程

快瘋了 都寫到這里了!?。。。。。。。?!

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號