计算字符串的长度(汉字按照两个字符计算)
*
* @param string $str 字符串
*
* @return int
*/
function str_len($str)
{
$length = strlen(preg_replace('/[x00-x7F]/', '', $str));
if ($length)
{
return strlen($str) - $length + intval($length / 3) * 2;
}
else
{
return strlen($str);
}
}
第一步:输入网站访问帐号(为空则使用默认帐号[IUSR_****]),脚本会自动获取IUSR帐号,如IUSR帐号被改名则无法获取,[]中将显示空。另外如需要用其它帐号作为IIS访问帐号,则在这里填入,如不需要更改则直接回车。
第二步:为获取文件列表及初始化变量,这里花费时间也比较长。
第三步:设置C盘权限,因文件比较多,另外为防止有个别文件未继承权限,每一个文件都是重设置了,权限所以运行时间会比较长。
第三步:设置其它盘符时,如不需要,则输入N退出。
第四步:依次输入你的网站所在目录,如不在这里输入,则网站目录将没有权限访问。
@echo off
cls
echo ##########################################################
echo # #
echo # 设置磁盘权限 #
echo # Tony www.023.com.cn VPS,服务器租用 #
echo # #
echo # 注意事项: #
echo # #
echo # 1 如需使用PHP请先使用“服务器自主管理工具箱”安 #
echo # 装再使用此程序设置权限,若手动安装PHP则需手动 #
echo # 给PHP目录加上USERS的读权限再使用此脚本。 #
echo # #
echo # 2 此脚本只给了网站目录IIS访问帐户的修改权限, #
echo # 如需要使用.net需手动加上IIS_WPG组的权限。 #
echo # #
echo # 3 此脚本只适用于网站服务。 #
echo # #
echo # 4 添加修改权限方法:右键目录叵文件--属性--安全 #
echo # 选择用户,在下方法勾上需要的权限。点击添加-- #
echo # 高级--立即查找,选择用户名确定即可添加用户。 #
echo # #
echo ##########################################################
echo.
rem ====================================得到IUSER帐户
net user|find /v "命令成功完成"> %windir%tempisUser1.txt 2>nul
echo.> %windir%tempisUser.txt 2>nul
set webUser=
for /f "skip=4 tokens=1" %%i in (%windir%tempisUser1.txt) do echo %%i>> %windir%tempisUser.txt 2>nul
for /f "skip=4 tokens=2" %%i in (%windir%tempisUser1.txt) do echo %%i>> %windir%tempisUser.txt 2>nul
for /f "skip=4 tokens=3" %%i in (%windir%tempisUser1.txt) do echo %%i>> %windir%tempisUser.txt 2>nul
for /f "skip=1" %%i in (%windir%tempisUser.txt) do call:GetIusr %%i
set /p webUser=输入网站访问帐号(为空则使用默认帐号[%webUser%]):
del /f /q %windir%tempisUser1.txt
del /f /q %windir%tempisUser.txt
goto endGetIusr
:GetIusr
set webUser1=%1
if /i %webUser1:~0,5%==IUSR_ set webUser=%1
goto :eof
:endGetIusr
REM ===============================获取C盘文件列表
set /a No=0
set /a No1=0
set /p=初始化程序... <nul
set 退格=
echo y|cacls c: /g administrators:f > nul 2>nul
cacls c: /g system:f /e > nul 2>nul
dir /s /b c: > %windir%tempcacls.txt 2>nul
dir /s /b %windir% > %windir%tempcacls1.txt 2>nul
for /f "tokens=1,2 delims=:" %%a in ('findstr /n ".*" "%windir%tempcacls.txt"') do set /a totalNo=%%a
for /f "tokens=1,2 delims=:" %%a in ('findstr /n ".*" "%windir%tempcacls1.txt"') do set /a totalNo1=%%a+13
set /p=ok < nul
echo.
REM ===============================开始设置C盘权限
set isGoOn=Y
set /p isGoOn=是否设置C盘权限(Y/N)[Y]:
if /i "%isGoOn%"=="N" goto endSetC
set /p=初始化C盘权限... 0/%totalNo%<nul
for /f "tokens=* delims=" %%i in (%windir%tempcacls.txt) do call:setAcl "%%i"
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=初始化C盘权限... OK <nul
echo.
set /p=设置C盘权限细节... 0/%totalNo1%<nul
for /f "tokens=* delims=" %%i in (%windir%tempcacls1.txt) do call:addUsers "%%i"
cacls "%windir%" /t /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "C:Program FilesCommon FilesODBC" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "C:Program FilesCommon FilesServices" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "C:Program FilesCommon FilesSystem" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "C:Program Files (x86)Common FilesODBC" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "C:Program Files (x86)Common FilesServices" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "C:Program Files (x86)Common FilesSystem" /g Users:r /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "%windir%temp" /g Users:c /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "%windir%System32cmd.exe" /r Users /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "%windir%System32cacls.exe" /r Users /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "%windir%System32net.exe" /r Users /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "%windir%System32regsvr32.exe" /r Users /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls "c:php5" /r Users /e /c > nul 2> nul
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... OK <nul
echo.
goto endSetC
:setAcl
set /a No+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=初始化C盘权限... %No%/%totalNo%<nul
set tmpPath=%1
echo y|cacls %1 /g administrators:f > nul 2>nul
cacls %1 /g system:f /e > nul 2>nul
goto :eof
:addUsers
set /a No1+=1
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置C盘权限细节... %No1%/%totalNo1%<nul
cacls %1 /g Users:r /e > nul 2>nul
goto :eof
:endSetC
REM ========================设置其它盘权限
set DiskStr=DEFGHIJKLMNOPQRSTUVWXYZ
set /a DiskNo=23
:GoOnSetDisk
set thisDisk=%DiskStr:~0,1%
set DiskStr=%DiskStr:~1%
set /a DiskNo-=1
set isGoOn=Y
set /p isGoOn=是否设置%thisDisk%盘权限(Y/N)[Y]:
if /i "%isGoOn%"=="N" goto SetOtherDisk
set /p=设置%thisDisk%盘权限... <nul
dir /s /b %thisDisk%: > %windir%tempcacls.txt 2> nul
set /a totalNo=0
set /a No=0
for /f "tokens=1,2 delims=:" %%a in ('findstr /n ".*" "%windir%tempcacls.txt"') do set /a totalNo=%%a+1
for /f "tokens=* delims=" %%i in (%windir%tempcacls.txt) do call:setDisk "%%i"
echo y|cacls %thisDisk%: /g administrators:f > nul 2>nul
cacls %thisDisk%: /g system:f /e > nul 2>nul
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置%thisDisk%盘权限... OK <nul
echo.
if %DiskNo% GTR 0 goto GoOnSetDisk
goto endSetDisk
:SetOtherDisk
set isSetOther=Y
set /p isSetOther=是否设置其它盘权限(Y/N)[Y]:
if /i "%isSetOther%"=="N" goto endSetDisk
goto :GoOnSetDisk
:setDisk
set /a No+=1
echo y|cacls %1 /g administrators:f > nul 2>nul
cacls %1 /g system:f /e > nul 2>nul
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置%thisDisk%盘权限... %No%/%totalNo%<nul
goto :eof
:endSetDisk
REM =======================设置网站目录权限
tony.rings> %windir%tempwebDir.txt 2>nul
: addWebDir
set WebDir=
set /p WebDir=添加网站目录(为空则添加结束):
if "%WebDir%"=="" goto endAddWebDir
echo %WebDir%>> %windir%tempwebDir.txt 2>nul
goto addWebDir
:endAddWebDir
for /f "tokens=* delims=" %%i in (%windir%tempwebDir.txt) do call:setWebDir "%%i"
goto endSetWebDir
:setWebDir
set /a No=1
set /a totalNo=1
set /p=设置%1权限... <nul
dir /s /b %1> %windir%tempwebSubDir.txt 2>nul
for /f "tokens=1,2 delims=:" %%a in ('findstr /n ".*" "%windir%tempwebSubDir.txt"') do set /a totalNo=%%a+1
cacls %1 /t /g %webUser%:c /e /c > nul 2> nul
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置%1权限... 1/%totalNo% <nul
for /f "tokens=* delims=" %%i in (%windir%tempwebSubDir.txt) do call:setWebSubDir "%%i" %1
goto :eof
:setWebSubDir
set /a No+=1
cacls %1 /t /g %webUser%:c /e /c > nul 2> nul
set /p=%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%%退格%<nul
set /p=设置%2权限... %No%/%totalNo% <nul
goto :eof
:endSetWebDir
del /f /q %windir%tempcacls1.txt
del /f /q %windir%tempcacls.txt
del /f /q %windir%tempwebDir.txt
del /f /q %windir%tempwebSubDir.txt
echo.
echo 恭喜您,设置完成,请按任意键退出程序!
pause > nul
/**
* 文本转HTML
*
* @param string $txt;
* return string;
*/
function Text2Html($txt){
$txt = str_replace(" "," ",$txt);
$txt = str_replace("<","<",$txt);
$txt = str_replace(">",">",$txt);
$txt = preg_replace("/[rn]{1,}/isU","<br/>rn",$txt);
return $txt;
}
/**
* 获得IP
* return string;
*/
function GetIP(){
if(!empty($_SERVER["HTTP_CLIENT_IP"])) { $cip = $_SERVER["HTTP_CLIENT_IP"]; }
else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) { $cip = $_SERVER["HTTP_X_FORWARDED_FOR"]; }
else if(!empty($_SERVER["REMOTE_ADDR"])) { $cip = $_SERVER["REMOTE_ADDR"]; }
else $cip = "";
preg_match("/[d.]{7,15}/", $cip, $cips);
$cip = $cips[0] ? $cips[0] : 'unknown';
unset($cips);
return $cip;
}
<?php
function ubb($string) {
$searcharray['bbcode_regexp'] = array(
"/s*[quote][nr]*(.+?)[nr]*[/quote]s*/is",
"/([box=(#[0-9A-F]{6}|[a-z]+)])[nr]*(.+?)[nr]*([/box])/is",
"/[url]s*(www.|https?://|ftp://|gopher://|news://|telnet://|rtsp://|mms://){1}([^["']+?)s*[/url]/ie",
"/[url=www.([^["']+?)](.+?)[/url]/is",
"/[url=(https?|ftp|gopher|news|telnet|rtsp|mms){1}://([^["']+?)](.+?)[/url]/is",
"/[email]s*([A-Za-z0-9-_.]+)@([A-Za-z0-9-_]+[.][A-Za-z0-9-_.]+)s*[/email]/i",
"/[email=([A-Za-z0-9-_.]+)@([A-Za-z0-9-_]+[.][A-Za-z0-9-_.]+)](.+?)[/email]/is",
"/[color=([^[]+?)]/i",
"/[size=([^[]+?)]/i",
"/[font=([^[]+?)]/i",
"/[align=([^[]+?)]/i",
"/[center]/i",
"/[swf]s*([^[]+?)s*[/swf]/ies",
"/[img]s*([^[]+?)s*[/img]/ies",
"/[img=(d{1,3})[x|,](d{1,3})]s*([^[]+?)s*[/img]/ies"
);
$replacearray['bbcode_regexp'] = array(
"<br><br><center><table border="0" width="90%" cellspacing="0" cellpadding="0"><tr><td> Quote:</td></tr><tr><td><table border="0" width="100%" cellspacing="1" cellpadding="10" bgcolor="".BORDERCOLOR.""><tr><td width="100%" bgcolor="".ALTBG2."" style="word-break:break-all">\1</td></tr></table></td></tr></table></center><br>",
"<blockquote style="background-color: \2 ;"><span class="bold">$title</span>\3</blockquote>",
"cuturl('\1\2')",
"<a href="http://www.\1" target="_blank">\2</a>",
"<a href="\1://\2" target="_blank">\3</a>",
"<a href="mailto:\1@\2">\1@\2</a>",
"<a href="mailto:\1@\2">\3</a>",
"<font color="\1">",
"<font size="\1">",
"<font face="\1">",
"<p align="\1">",
"<p align="center">",
"bbcodeurl('\1', ' <img src="images/flash.gif" align="absmiddle"> <a href="%s" target="_blank">Flash: %s</a> ')",
"bbcodeurl('\1', '<img src="%s" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window';}" onmouseover="if(this.resized) this.style.cursor='hand';" onclick="if(this.resized) {window.open('%s');}">')",
"bbcodeurl('\3', '<img width="\1" height="\2" src="%s" border="0">')"
);
$searcharray['bbcode_str'] = array(
'[/color]', '[/size]', '[/font]', '[/align]', '[b]', '[/b]',
'[i]', '[/i]', '[u]', '[/u]', '[list]', '[list=1]', '[list=a]',
'[list=A]', '[*]', '[/list]','[/center]'
);
$replacearray['bbcode_str'] = array(
'</font>', '</font>', '</font>', '</p>', '<b>', '</b>', '<i>',
'</i>', '<u>', '</u>', '<ul>', '<ol type=1>', '<ol type=a>',
'<ol type=A>', '<li>', '</ul></ol>','</p>'
);
$string = str_replace($searcharray['bbcode_str'], $replacearray['bbcode_str'], preg_replace($searcharray['bbcode_regexp'], $replacearray['bbcode_regexp'], $string));
return $string;
}
function bbcodeurl($url, $tags) {
if(!preg_match("/<.+?>/s",$url)) {
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'ftp://', 'rtsp:/', 'mms://'))) {
$url = 'http://'.$url;
}
return str_replace('submit', '', sprintf($tags, $url, $url));
} else {
return ' '.$url;
}
}
function cuturl($url) {
$length = 65;
$urllink = "<a href="".(substr(strtolower($url), 0, 4) == 'www.' ? "http://$url" : $url).'" target="_blank">';
if(strlen($url) > $length) {
$url = substr($url, 0, intval($length * 0.5)).' ... '.substr($url, - intval($length * 0.3));
}
$urllink .= $url.'</a>';
return $urllink;
}
?>
session_start();
$enablegd = 1;
$funcs = array('imagecreatetruecolor','imagecolorallocate','imagefill','imagestring','imageline','imagerotate','imagedestroy','imagecolorallocatealpha','imageellipse','imagepng');
foreach($funcs as $func)
{
if(!function_exists($func))
{
$enablegd = 0;
break;
}
}
ob_clean();
if($enablegd)
{
//create captcha
$consts = 'cdfgkmnpqrstwxyz23456';
$vowels = 'aek23456789';
for ($x = 0; $x < 6; $x++)
{
$const[$x] = substr($consts, mt_rand(0,strlen($consts)-1),1);
$vow[$x] = substr($vowels, mt_rand(0,strlen($vowels)-1),1);
}
$radomstring = $const[0] . $vow[0] .$const[2] . $const[1] . $vow[1] . $const[3] . $vow[3] . $const[4];
$_SESSION['checkcode'] = $string = substr($radomstring,0,4); //only display 4 str
//set up image, the first number is the width and the second is the height
$imageX = strlen($radomstring)*8; //the image width
$imageY = 20; //the image height
$im = imagecreatetruecolor($imageX,$imageY);
//creates two variables to store color
$background = imagecolorallocate($im, rand(180, 250), rand(180, 250), rand(180, 250));
$foregroundArr = array(imagecolorallocate($im, rand(0, 20), rand(0, 20), rand(0, 20)),
imagecolorallocate($im, rand(0, 20), rand(0, 10), rand(245, 255)),
imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(0, 10)),
imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(245, 255)));
$foreground2 = imagecolorallocatealpha($im, rand(20, 100), rand(20, 100), rand(20, 100),80);
$middleground = imagecolorallocate($im, rand(200, 160), rand(200, 160), rand(200, 160));
$middleground2 = imagecolorallocatealpha($im, rand(180, 140), rand(180, 140), rand(180, 140),80);
//fill image with bgcolor
imagefill($im, 0, 0, imagecolorallocate($im, 250, 253, 254));
//writes string
imagettftext($im, 12, rand(30, -30), 5, rand(14, 16), $foregroundArr[rand(0,3)], PHPCMS_ROOT.'include/fonts/ALGER.TTF', $string[0]);
imagettftext($im, 12, rand(50, -50), 20, rand(14, 16), $foregroundArr[rand(0,3)], PHPCMS_ROOT.'include/fonts/ARIALNI.TTF', $string[1]);
imagettftext($im, 12, rand(50, -50), 35, rand(14, 16), $foregroundArr[rand(0,3)], PHPCMS_ROOT.'include/fonts/ALGER.TTF', $string[2]);
imagettftext($im, 12, rand(30, -30), 50, rand(14, 16), $foregroundArr[rand(0,3)], PHPCMS_ROOT.'include/fonts/arial.ttf', $string[3]);
//strikethrough
$border = imagecolorallocate($im, 133, 153, 193);
//imagefilledrectangle($aimg, 0, 0, $x_size - 1, $y_size - 1, $back);
imagerectangle($im, 0, 0, $imageX - 1, $imageY - 1, $border);
$pointcol = imagecolorallocate($im, rand(0,255), rand(0,255), rand(0,255));
for ($i=0;$i<80;$i++)
{
imagesetpixel($im,rand(2,$imageX-2),rand(2,$imageX-2),$pointcol);
}
//random shapes
for ($x=0; $x<9;$x++)
{
if(mt_rand(0,$x)%2==0)
{
imageline($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 999999));
imageellipse($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), $middleground2);
}
else
{
imageline($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 999999));
imageellipse($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), $middleground);
}
}
//output to browser
header("content-type:image/pngrn");
imagepng($im);
imagedestroy($im);
}
else
{
$files = glob(PHPCMS_ROOT.'images/checkcode/*.jpg');
if(!is_array($files)) exit($LANG['please_check_dir_images_checkcode']);
$checkcodefile = $files[rand(0, count($files)-1)];
$_SESSION['checkcode'] = substr(basename($checkcodefile), 0, 4);
header("content-type:image/jpegrn");
include $checkcodefile;
}
相关文章
- 这篇文章主要介绍了C#中截取字符串的的基本方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-11-03
- 这篇文章介绍了C#判断字符串是否数字或字母的实例,有需要的朋友可以参考一下...2020-06-25
- 这篇文章主要介绍了PostgreSQL判断字符串是否包含目标字符串的多种方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2021-02-23
- 这篇文章主要介绍了C++ string常用截取字符串方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-04-25
- 本文实例讲述了php字符串按照单词进行反转的方法。分享给大家供大家参考。具体分析如下:下面的php代码可以将字符串按照单词进行反转输出,实际上是现将字符串按照空格分隔到数组,然后对数组进行反转输出。...2015-03-15
- 今天在写一个vbs的时候,发现中文乱码,后来写好代码正常运行的代码压缩一下给了同事,发现报无效字符,经过验证后发现原来是编码的问题导致,这里就为大家分享一下...2020-06-30
- 这篇文章主要介绍了MySQL 字符串拆分操作(含分隔符的字符串截取),具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-02-22
- 这篇文章主要介绍了C#实现字符串转换成字节数组的简单实现方法,仅一行代码即可搞定,非常简单实用,需要的朋友可以参考下...2020-06-25
- 这篇文章主要介绍了使用list stream:任意对象List拼接字符串操作,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教...2021-09-09
- 这篇文章主要介绍了C# 16 进制字符串转 int的方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下...2020-06-25
- JS中默认中文字符长度和其它字符长度计算方法是一样的,但某些情况下我们需要获取中文字符串的实际长度,代码如下: 复制代码 代码如下: function strLength(str) { var realLength = 0, len = str.length, charCode = -1;...2014-06-07
- 这篇文章主要介绍了PostgreSQL 字符串处理与日期处理操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-02-01
- 这篇文章主要介绍了C#实现对字符串进行大小写切换的方法,涉及C#操作字符串的技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
- 文章介绍一个实用的函数,我们如果用php substr来截取字符在中文上处理的很有问题,今天自己写了一个比较好的中文与英文字符截取的函数,有需要的朋友可以参考下。 ...2016-11-25
- 这篇文章主要介绍了c#将字节数组转成易读的字符串的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-25
- 这篇文章主要介绍了C#获取字符串后几位数的方法,实例分析了C#操作字符串的技巧,具有一定参考借鉴价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要介绍了解决vue字符串换行问题(绝对管用),具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-08-06
- 这篇文章主要介绍了C#判断一个字符串是否是数字或者含有某个数字的方法,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下...2020-06-25
- 这篇文章主要介绍了Substring截取字符串方法小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-06-25
- 在网站开发中,我们经常使用php similar text 计算两个字符串相似度;1,similar_text的用法 如果我想计算"ly89cn"和"ly89"的相似程度,有两种表示方法复制代码 代码如下: echo similar_text('ly89cn', 'ly89'); ...2015-11-08