娱乐新地带论坛  

返回   娱乐新地带论坛 > 电脑技术 > 『程序设计』

『程序设计』 不太懂编程,主要用来搜集例子,源码等...

 
 
主题工具 显示模式
旧 2006-02-15, 01:49 PM   #2
No1
Tony
坛主
级别:199 | 在线时长:40419小时 | 升级还需:381小时级别:199 | 在线时长:40419小时 | 升级还需:381小时级别:199 | 在线时长:40419小时 | 升级还需:381小时级别:199 | 在线时长:40419小时 | 升级还需:381小时
 
Tony 的头像
 
注册日期: 2003-10-22
帖子: 11,050
积分:6
精华:24
现金:14340金币
资产:29325297金币
声望: 395
Tony 是一位成功的新星Tony 是一位成功的新星Tony 是一位成功的新星Tony 是一位成功的新星
补充一个原作者现在发布的ups.class.php
PHP 代码:
<?php
/**
// 程序作者:张建
// 网站:http://www.phpsir.com
// 联系方法:52linux@gmail.com
// 联系方法:QQ 733905
//

示例:
include ("ugs.php"); // 你可以下载本ugs.phps 然后重命名为ugs.php
$ugs = new ugs();
$url = "http://domainname.com/path_to_your_target?param";
$ugs->set($url);
$ugs->gus();
以满足您的要求
$content=$ugs->get();
print($content);

======================================================
使用方法

include ("ugs.php");

$ugs = new ugs();
$url = "http://domainname.com/path_to_your_target?param";
$ugs->set($url);
$ugs->gus();
$content=$ugs->get();
print($content);


*/
class    ugs
{
var 
$value_  ;  //'目标内容
var $src_    ;  //'目标URL地址

function    set($url)
{
    
$this->src_=$url;
}

function    
get()
{
    return 
$this->value_;
}


function    
gus()
{
    
$this->value_=file_get_contents($this->src_); //(PHP 4 >= 4.3.0, PHP 5)
}

function    
gaa()
{
    
$this->value_=file($this->src_);
}

function    
nor()     // 删除回车换行
{
    
$this->value_=str_replace("\n","",$this->value_);
    
$this->value_=str_replace("\r","",$this->value_);
}

function    
chg($oldstr,$newstr//'对收集到的内容中的个别字符串用新值更换的方法,参数分别是旧字符串,新字符串
{
    
$this->value_=str_replace($oldstr,$newstr,$this->value_ );
}

function    
cut($StartFlag,$EndFlag,$no='1',$comprise='')
/*
按指定首尾字符串对收集的内容进行裁减的的方法
$no 必须是 1,2 3 ... 不允许 0
$comprise 可以选择 start 或者 end 或者 all 或者 什么都不填
*/
{
    
$string=explode($StartFlag,$this->value_);
    
//print_r($string);
    
$string=explode($EndFlag,$string[$no]);
    
//print_r($string);
    
switch ($comprise){
            case 
'start':
                    
$string=$StartFlag.$string[0];
            break;
            case 
'end':
                    
$string=$string[0].$EndFlag;
            break;
            case 
'all':
                    
$string=$StartFlag.$string[0].$EndFlag;
            break;
            default:
                    
$string=$string[0];
    }
    return 
$this->value_=$string;

}


function    
flt($start,$end,$newstr,$no='1',$comprise='')
/*
按指定首尾字符串对收集的内容用新值进行替换(不包括首尾字符串)方法
参数分别是首字符串,尾字符串,新值,新值位空则为过滤
*/
{
    
$tmp_ori=$this->value_;
    if(
$comprise==''){
        
$tmp=$this->cut($start,$end,$no);
    }else{
        
$tmp=$this->cut($start,$end,$no,$comprise);
    }

    
$this->value_=str_replace($tmp,$newstr,$tmp_ori);
}

function 
dbg() //调试显示
{
    
$tempstr="<SCRIPT>function runEx(){var winEx2 = window.open(\"\", \"winEx2\", \"width=500,height=300,status=yes,menubar=no,scrollbars=yes,resizable=yes\"); winEx2.document.open(\"text/html\", \"replace\"); winEx2.document.write(unescape(event.srcElement.parentElement.children[0].value)); winEx2.document.close(); }function saveFile(){var win=window.open('','','top=10000,left=10000');win.document.write(document.all.asdf.innerText);win.document.execCommand('SaveAs','','javascript.htm');win.close();}</SCRIPT><center><TEXTAREA id=asdf name=textfield rows=32  wrap=VIRTUAL cols=\"120\">".$this->value_."</TEXTAREA><BR><BR><INPUT name=Button onclick=runEx() type=button value=\"查看效果\">&nbsp;&nbsp;<INPUT name=Button onclick=asdf.select() type=button value=\"全选\">&nbsp;&nbsp;<INPUT name=Button onclick=\"asdf.value=''\" type=button value=\"清空\">&nbsp;&nbsp;<INPUT onclick=saveFile(); type=button value=\"保存代码\"></center>";
    echo 
$tempstr;
}


}
?>
Tony 当前离线  
回复时引用此帖
 

书签


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码

论坛跳转


所有时间均为北京时间。现在的时间是 04:57 AM


©2003-2024 1819.net All rights reserved.