function SplitRMM($str=""){
if($str!="") $this->SetSource(trim($str));
if($this->SourceString=="") return "";
//对文本进行粗分
$this->SourceString = $this->ReviseString($this->SourceString);
//对特定文本进行分离
$spwords = explode(" ",$this->SourceString);
$spLen = count($spwords);
$spc = $this->SplitChar;
for($i=($spLen-1);$i>=0;$i--){
if(trim($spwords[$i])=="") continue;
if($this->NotGBK($spwords[$i])){
if(ereg("[^0-9.+-]",$spwords[$i]))
{ $this->ResultString = $spwords[$i].$spc.$this->ResultString; }
else
{
$nextword = "";
@$nextword = substr($this->ResultString,0,strpos($this->ResultString," "));
if(ereg("^".$this->CommonUnit,$nextword)){
$this->ResultString = $spwords[$i].$this->ResultString;
}else{
$this->ResultString = $spwords[$i].$spc.$this->ResultString;
}
}
}
else
{
$c = $spwords[$i][0].$spwords[$i][1];
$n = hexdec(bin2hex($c));
if($c=="《") //书名
{ $this->ResultString = $spwords[$i].$spc.$this->ResultString; }
else if($n>0xA13F && $n < 0xAA40) //标点符号
{ $this->ResultString = $spwords[$i].$spc.$this->ResultString; }
else //正常短句
{
if(strlen($spwords[$i]) <= $this->SplitLen)
{
//如果结束符为特殊分割词,分离处理
if(ereg($this->EspecialChar."$",$spwords[$i],$regs)){
$spwords[$i] = ereg_replace($regs[0]."$","",$spwords[$i]).$spc.$regs[0];
}
//是否为常用单位
if(!ereg("^".$this->CommonUnit,$spwords[$i]) || $i==0){
$this->ResultString = $spwords[$i].$spc.$this->ResultString;
}else{
$this->ResultString = $spwords[$i-1].$spwords[$i].$spc.$this->ResultString;
$i--;
}
}
else
{
$this->ResultString = $this->RunRMM($spwords[$i]).$spc.$this->ResultString;
}
}
}
}
return $this->ResultString;
}
//
function GetAlabNum($fnum)
{
$nums = array("0","1","2","3","4","5","6","7","8","9","+","-","%",".");
$fnums = "0123456789+-%.";
for($i=0;$i<count($nums);$i++){
if($nums[$i]==$fnum) return $fnums[$i];
}
return $fnum;
}
这是一个文件目录移动类,只要在listDir写你的要转移文件的目录名移就可以了,这个文件夹与文件移动类,比较适合采集下载的多文件操作,如要在打包文件里面加说明,等哦。
<?php教程
die();
class s{
//var $path ='flash';
var $htm ='/index.htm';
var $html='/index.html';
var $ladir='/111cn.net教程';
public function full_copy( $source, $target )
{
if ( is_dir( $source ) && $source != $source.$this->ladir )
{
@mkdir( $target );
$d = dir( $source );
while ( FALSE !== ( $entry = $d->read() ) )
{
if ( $entry == '.' || $entry == '..' )
{
continue;
}
$Entry = $source . '/' . $entry;
if ( is_dir( $Entry ) )
{
$this->full_copy( $Entry, $target . '/' . $entry );
continue;
}
copy( $Entry, $target . '/' . $entry );
}
$d->close();
}
else
{
copy( $source, $target );
}
}
//
public function listDir($dir_path)
{
if(is_dir($dir_path)){
if($dir_file=opendir($dir_path)){
while(($dir_list=readdir($dir_file))!==false)
{
if($dir_list!="." && $dir_list!="..")
{
$this->listSunDir($dir_path."/".$dir_list);
//$this->mkdir_r($dir_path."/".$dir_list.$this->ladir);
}
}
}else{
echo($dir_path);
}
}else{
echo($dir_path);
}
}
//
public function listSunDir($dir_path)
{
if(is_dir($dir_path)){
if($dir_file=opendir($dir_path)){
while(($dir_list=readdir($dir_file))!==false)
{
if($dir_list!="." && $dir_list!="..")
{
//$this->mkdir_r($dir_path."/".$dir_list.$this->ladir);
if( '/'.$dir_list == $this->ladir )
{
continue;
}
else
{
echo $dir_path."/".$dir_list,'<br />';
$this->full_copy($dir_path."/".$dir_list,$dir_path."/".$this->ladir);
$this->deldir($dir_path."/".$dir_list);
}
//$this->full_copy($dir_path."/".$dir_list,$dir_path."/".$dir_list.$this->ladir);
}
}
}else{
echo($dir_path);
}
}else{
echo($dir_path);
}
}
//
public function checkFile($dir)
{
if( is_dir( $dir ) )
{
if(is_file( $dir.$htm ) || is_file($dir . $html) )
{
continue;
}
else
{
$this->full_copy( $dir, $target );
}
}
}
// mkdir
function mkdir_r($dirName, $rights=0777)
{
$dirs = explode('/', $dirName);
$dir='';
foreach ($dirs as $part) {
$dir.=$part.'/';
if (!is_dir($dir) && strlen($dir)>0 && !is_file($dirName))
{
mkdir($dir, $rights);
echo "$dirName<br/>";
}
}
}
// delall
function deldir($dir)
{
if(is_dir($dir))
{
$rdir = $dir;
if($dirlist = scandir($rdir))
{
array_shift($dirlist);
array_shift($dirlist);
foreach($dirlist as $d){
$rd = $rdir.'/'.$d;
if(isset($d) && is_file($rd)){
unlink($rd);
}else{
$this->deldir($rd);
}
}
rmdir($rdir);
}else{
return false;
}
}
return true;
}
}
$s = new s();
$s->listDir('flash');//要移动目录
?>
<?
//php教程获取ip的算法
$user_IP = ($_SERVER["HTTP_VIA"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
$user_IP = ($user_IP) ? $user_IP : $_SERVER["REMOTE_ADDR"];
//echo $user_IP;
//===================================
//
// 功能:IP地址获取真实地址函数
// 参数:$ip - IP地址
// 作者:[Discuz!] (C) Comsenz Inc.
//
//===================================
function convertip($ip) {
//IP数据文件路径,请根据情况自行修改
$dat_path = 'QQWry.dat';
//检查IP地址
if(!ereg("^([0-9]{1,3}.){3}[0-9]{1,3}$", $ip)){
return 'IP Address Error';
}
//打开IP数据文件
if(!$fd = @fopen($dat_path, 'rb')){
return 'IP date file not exists or access denied';
}
//分解IP进行运算,得出整形数
$ip = explode('.', $ip);
$ipNum = $ip[0] * 16777216 + $ip[1] * 65536 + $ip[2] * 256 + $ip[3];
//获取IP数据索引开始和结束位置
$DataBegin = fread($fd, 4);
$DataEnd = fread($fd, 4);
$ipbegin = implode('', unpack('L', $DataBegin));
if($ipbegin < 0) $ipbegin += pow(2, 32);
$ipend = implode('', unpack('L', $DataEnd));
if($ipend < 0) $ipend += pow(2, 32);
$ipAllNum = ($ipend - $ipbegin) / 7 + 1;
$BeginNum = 0;
$EndNum = $ipAllNum;
//使用二分查找法从索引记录中搜索匹配的IP记录
while($ip1num>$ipNum || $ip2num<$ipNum) {
$Middle= intval(($EndNum + $BeginNum) / 2);
//偏移指针到索引位置读取4个字节
fseek($fd, $ipbegin + 7 * $Middle);
$ipData1 = fread($fd, 4);
if(strlen($ipData1) < 4) {
fclose($fd);
return 'System Error';
}
//提取出来的数据转换成长整形,如果数据是负数则加上2的32次幂
$ip1num = implode('', unpack('L', $ipData1));
if($ip1num < 0) $ip1num += pow(2, 32);
//提取的长整型数大于我们IP地址则修改结束位置进行下一次循环
if($ip1num > $ipNum) {
$EndNum = $Middle;
continue;
}
//取完上一个索引后取下一个索引
$DataSeek = fread($fd, 3);
if(strlen($DataSeek) < 3) {
fclose($fd);
return 'System Error';
}
$DataSeek = implode('', unpack('L', $DataSeek.chr(0)));
fseek($fd, $DataSeek);
$ipData2 = fread($fd, 4);
if(strlen($ipData2) < 4) {
fclose($fd);
return 'System Error';
}
$ip2num = implode('', unpack('L', $ipData2));
if($ip2num < 0) $ip2num += pow(2, 32);
//没找到提示未知
if($ip2num < $ipNum) {
if($Middle == $BeginNum) {
fclose($fd);
return 'Unknown';
}
$BeginNum = $Middle;
}
}
//下面的代码读晕了,没读明白,有兴趣的慢慢读
$ipFlag = fread($fd, 1);
if($ipFlag == chr(1)) {
$ipSeek = fread($fd, 3);
if(strlen($ipSeek) < 3) {
fclose($fd);
return 'System Error';
}
$ipSeek = implode('', unpack('L', $ipSeek.chr(0)));
fseek($fd, $ipSeek);
$ipFlag = fread($fd, 1);
}
if($ipFlag == chr(2)) {
$AddrSeek = fread($fd, 3);
if(strlen($AddrSeek) < 3) {
fclose($fd);
return 'System Error';
}
$ipFlag = fread($fd, 1);
if($ipFlag == chr(2)) {
$AddrSeek2 = fread($fd, 3);
if(strlen($AddrSeek2) < 3) {
fclose($fd);
return 'System Error';
}
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
fseek($fd, $AddrSeek2);
} else {
fseek($fd, -1, SEEK_CUR);
}
while(($char = fread($fd, 1)) != chr(0))
$ipAddr2 .= $char;
$AddrSeek = implode('', unpack('L', $AddrSeek.chr(0)));
fseek($fd, $AddrSeek);
while(($char = fread($fd, 1)) != chr(0))
$ipAddr1 .= $char;
} else {
fseek($fd, -1, SEEK_CUR);
while(($char = fread($fd, 1)) != chr(0))
$ipAddr1 .= $char;
$ipFlag = fread($fd, 1);
if($ipFlag == chr(2)) {
$AddrSeek2 = fread($fd, 3);
if(strlen($AddrSeek2) < 3) {
fclose($fd);
return 'System Error';
}
$AddrSeek2 = implode('', unpack('L', $AddrSeek2.chr(0)));
fseek($fd, $AddrSeek2);
} else {
fseek($fd, -1, SEEK_CUR);
}
while(($char = fread($fd, 1)) != chr(0)){
$ipAddr2 .= $char;
}
}
fclose($fd);
//最后做相应的替换操作后返回结果
if(preg_match('/http/i', $ipAddr2)) {
$ipAddr2 = '';
}
$ipaddr = "$ipAddr1 $ipAddr2";
$ipaddr = preg_replace('/CZ88.Net/is', '', $ipaddr);
$ipaddr = preg_replace('/^s*/is', '', $ipaddr);
$ipaddr = preg_replace('/s*$/is', '', $ipaddr);
if(preg_match('/http/i', $ipaddr) || $ipaddr == '') {
$ipaddr = 'Unknown';
}
return $ipaddr;
}
?>
<script language="javascript教程">
var sf='<?echo convertip($user_IP);?>';
if(sf.indexOf("香港")>=0){
window.location.href="http://xianggang.111cn.net";
}
else if(sf.indexOf("广东省")>=0){
window.location.href="http://guangdong.111cn.net";
}
else if(sf.indexOf("北京")>=0){
window.location.href="http://beijing.111cn.net";
}
else{
window.location.href="http://www.111cn.net";
}
</script>
<?php
require ('resize_img.php');
//how to use the class:
//makes a simple thumbnail of an image of 100x100 and saves the image then outputs it.
$imgresize = new resize_img();
$imgresize->sizelimit_x = 100;
$imgresize->sizelimit_y = 100;
$imgresize->keep_proportions = true;
$imgresize->output = 'PNG';
if( $imgresize->resize_image( 'C:/xampp/htdocs/wannabe/image_bin/public/treeshadows_001.gif' ) === false )
{
echo 'ERROR!';
}
else
{
$imgresize->save_resizedimage( 'C:/xampp/htdocs/wannabe/image_bin/public/thumbnails/', 'treeshadows_001' );
$imgresize->output_resizedimage();
}
$imgresize->destroy_resizedimage();
?>
// resize_img.php文件
<?php
/**
* by Daniel M. Story <admin@danstory.com>
*/
class resize_img
{
var $image_path = '';
//holds the image path
var $sizelimit_x = 250;
//the limit of the image width
var $sizelimit_y = 250;
//the limit of the image height
var $image_resource = '';
//holds the image resource
var $keep_proportions = true;
//if true it keeps教程 the image proportions when resized
var $resized_resource = '';
//holds the resized image resource
var $hasGD = false;
var $output = 'SAME';
//can be JPG, GIF, PNG, or SAME (same will save as old type)
function resize_img()
{
if( function_exists('gd_info') ){ $this->hasGD = true; }
}
function resize_image( $image_path )
{
if( $this->hasGD === false ){ return false; }
//no GD installed on the server!
list($img_width, $img_height, $img_type, $img_attr) = @getimagesize( $image_path );
//this is going to get the image width, height, and format
if( ( $img_width != 0 ) || ( $img_width != 0 ) )
//make sure it was loaded correctly
{
switch( $img_type )
{
case 1:
//GIF
$this->image_resource = @imagecreatefromgif( $image_path );
if( $this->output == 'SAME' ){ $this->output = 'GIF'; }
break;
case 2:
//JPG
$this->image_resource = @imagecreatefromjpeg( $image_path );
if( $this->output == 'SAME' ){ $this->output = 'JPG'; }
break;
case 3:
//PNG
$this->image_resource = @imagecreatefrompng( $image_path );
if( $this->output == 'SAME' ){ $this->output = 'PNG'; }
}
if( $this->image_resource === '' ){ return false; }
//it wasn't able to load the image
}
else{ return false; }
//something happened!
if( $this->keep_proportions === true )
{
if( ($img_width-$this->sizelimit_x) > ($img_height-$this->sizelimit_y) )
{
//if the width of the img is greater than the size limit we scale by width
$scalex = ( $this->sizelimit_x / $img_width );
$scaley = $scalex;
}
else
//if the height of the img is greater than the size limit we scale by height
{
$scalex = ( $this->sizelimit_y / $img_height );
$scaley = $scalex;
}
}
else
{
$scalex = ( $this->sizelimit_x / $img_width );
$scaley = ( $this->sizelimit_y / $img_height );
//just make the image fit the image size limit
if( $scalex > 1 ){ $scalex = 1; }
if( $scaley > 1 ){ $scaley = 1; }
//don't make it so it streches the image
}
$new_width = $img_width * $scalex;
$new_height = $img_height * $scaley;
$this->resized_resource = @imagecreatetruecolor( $new_width, $new_height );
//creates an image resource, with the width and height of the size limits (or new resized proportion )
if( function_exists( 'imageantialias' )){ @imageantialias( $this->resized_resource, true ); }
//helps in the quality of the image being resized
@imagecopyresampled( $this->resized_resource, $this->image_resource, 0, 0, 0, 0, $new_width, $new_height, $img_width, $img_height );
//resize the iamge onto the resized resource
@imagedestroy( $this->image_resource );
//destory old image resource
return true;
}
function save_resizedimage( $path, $name )
{
switch( strtoupper($this->output) )
{
case 'GIF':
//GIF
@imagegif( $this->resized_resource, $path . $name . '.gif' );
break;
case 'JPG':
//JPG
@imagejpeg( $this->resized_resource, $path . $name . '.jpg' );
break;
case 'PNG':
//PNG
@imagepng( $this->resized_resource, $path . $name . '.png' );
}
}
function output_resizedimage()
{
$the_time = time();
header('Last-Modified: ' . date( 'D, d M Y H:i:s', $the_time ) . ' GMT');
header('Cache-Control: public');
switch( strtoupper($this->output) )
{
case 'GIF':
//GIF
header('Content-type: image/gif');
@imagegif( $this->resized_resource );
break;
case 'JPG':
//JPG
header('Content-type: image/jpg');
@imagejpeg( $this->resized_resource );
break;
case 'PNG':
//PNG
header('Content-type: image/png');
@imagepng( $this->resized_resource );
}
}
function destroy_resizedimage()
{
@imagedestroy( $this->resized_resource );
@imagedestroy( $this->image_resource );
}
}
?>