当前位置:  编程技术>php
本页文章导读:
    ▪php中随机显示图片的函数代码       例如博客的展示窗 代码如下: <?php /********************************************** * Filename : img.php * Author : freemouse * web : www.cnphp.info * email :freemouse1981@gmail.com * Date : 2010/12/27 * Usage: * <img src=/blog_article/img.php>........._/font/index.html>
    ▪使用php shell命令合并图片的代码       代码如下: #!/usr/local/bin/php -q author:freemouse <?php // 下面是说明. print ("本程序用于合并2张 640x480大小的.\n"); print ("图片,并将其转化为一张 400x300 大小的图片\n"); print ("需要指定存放合成前.........
    ▪php whois查询API制作方法       这里我们从万网或新网的数据接口取得数据,透过php的简单文本处理再输出。 代码如下: <php? $domain = $_GET['q']; preg_match("| <div lyTableInfoWrap\"">(.+?)</div> |is", @file_get_contents('http://www.x.........

[1]php中随机显示图片的函数代码
    来源: 互联网  发布时间: 2013-11-30
例如博客的展示窗
代码如下:

<?php
/**********************************************
* Filename : img.php
* Author : freemouse
* web : www.cnphp.info
* email :freemouse1981@gmail.com
* Date : 2010/12/27
* Usage:
* <img src=/blog_article/img.html
* <img src=/blog_article/img/folder/images2/gt;.html
***********************************************/
if($_GET['folder']){
$folder=$_GET['folder'];
}else{
$folder='/images/';
}
//存放图片文件的位置
$path = $_SERVER['DOCUMENT_ROOT']."/".$folder;
$files=array();
if ($handle=opendir("$path")) {
while(false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if(substr($file,-3)=='gif' || substr($file,-3)=='jpg') $files[count($files)] = $file;
}
}
}
closedir($handle);

$random=rand(0,count($files)-1);
if(substr($files[$random],-3)=='gif') header("Content-type: image/gif");
elseif(substr($files[$random],-3)=='jpg') header("Content-type: image/jpeg");
readfile("$path/$files[$random]");
?>

    
[2]使用php shell命令合并图片的代码
    来源: 互联网  发布时间: 2013-11-30
代码如下:

#!/usr/local/bin/php -q
author:freemouse
<?php
// 下面是说明.
print ("本程序用于合并2张 640x480大小的.\n");
print ("图片,并将其转化为一张 400x300 大小的图片\n");
print ("需要指定存放合成前图片(a.jpg,b.jpg)的默认目录\n");
print ("生成的图片将会保存为c.jpg\n");

//默认目录,自己编辑吧^_^
$d="/home/freemouse/Desktop";
print ("当前目录为: $d\n");

print (" 图片 a.jpg 偏移, 0-100: ");
$fp = fopen("php://stdin", "r");
$a = fgets($fp,255);
print (" 图片 b.jpg 偏移, 0-100: ");
$b = fgets($fp,255);
fclose($fp);
$a=$a*3.2;
$a=floor($a);
$b=$b*3.2;
$b=floor($b);

// 将两张图片缩放至 640x480 尺寸
exec("缩放至 640x480 -质量 95 " . $d . "/a.jpg");
exec("缩放至 640x480 -质量 95 " . $d . "/b.jpg");

$aa = "转换 -质量 90 -尺寸 320x480+";
$ab = " " . $d . "/a.jpg";
$bb = " " . $d . "/b.jpg";
$ac = " " . $d . "/aa.jpg";
$cc = " " . $d . "/bb.jpg";

// 缩放后的 a.jpg 另存为 aa.jpg
$yy = $aa . $a . $ab . $ac;
print ("$yy\n");
exec($yy);

// 缩放后的 b.jpg 另存为 bb.jpg
$zz = $aa . $b . $bb . $cc;
print ("$zz\n");
exec($zz);

// 合并两张图片为 c.jpg.
$adjoin = "合成 -质量 80 ";
$adjoin .= $d . "/aa.jpg ";
$adjoin .= $d . "/bb.jpg ";
$adjoin .= $d . "/c.jpg";
print ("$adjoin\n");
exec($adjoin);

// 调整 c.jpg 至 400x300 尺寸 并添加边框.
$edge="缩放至 400x300 -质量 75 -raise 4x4 -sharpen 1x1 " . $d . "/c.jpg";
print ("$edge\n");
exec($edge);

?>

    
[3]php whois查询API制作方法
    来源: 互联网  发布时间: 2013-11-30
这里我们从万网或新网的数据接口取得数据,透过php的简单文本处理再输出。
代码如下:

<php?
$domain = $_GET['q'];
preg_match("|
<div lyTableInfoWrap\"">(.+?)</div>
|is", @file_get_contents('http://www.xinnet.cn/Modules/agent/serv/pages/domain_whois.jsp?domainNameWhois='.$domain.'&noCode=noCode'), $whois);
echo $whois[1];
?>

做到这里,可能有的朋友要问了,这不就是简单的php脚本么?!哪是api接口阿;接着我们来加工一下,让查询方式更专业一些:
我们需要的查询格式如下:
http://api/whois/baidu.com
其中baidu.com是需要查询的域名
可以修改nginx的配置来实现这一点:
代码如下:

location ~* /whois/(.+)$ {
proxy_pass http://127.0.0.1:8080/whois/index.php?q=baidu.com
#将查询传递给内网的apache处理
}

ok,至此一个使用的whois api接口完成了,你可以自己的程序中调用,也可以共享给大家使用^_^!。
查询baidu.com的结果:
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: BAIDU.COM
Registrar: REGISTER.COM, INC.
Whois Server: whois.register.com
Referral URL: http://www.register.com
Name Server: DNS.BAIDU.COM
Name Server: NS2.BAIDU.COM
Name Server: NS3.BAIDU.COM
Name Server: NS4.BAIDU.COM
Status: clientTransferProhibited
Status: serverDeleteProhibited
Status: serverTransferProhibited
Status: serverUpdateProhibited
Updated Date: 15-mar-2010
Creation Date: 11-oct-1999
Expiration Date: 11-oct-2014
>>> Last update of whois database: Fri, 20 Aug 2010 05:42:12 UTC <<<
NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.
TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' (“VeriSign”) Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.
The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
The data in Register.com's WHOIS database is provided to you by
Register.com for information purposes only, that is, to assist you in
obtaining information about or related to a domain name registration
record. Register.com makes this information available “as is,” and
does not guarantee its accuracy. By submitting a WHOIS query, you
agree that you will use this data only for lawful purposes and that,
under no circumstances will you use this data to: (1) allow, enable,
or otherwise support the transmission of mass unsolicited, commercial
advertising or solicitations via direct mail, electronic mail, or by
telephone; or (2) enable high volume, automated, electronic processes
that apply to Register.com (or its systems). The compilation,
repackaging, dissemination or other use of this data is expressly
prohibited without the prior written consent of Register.com.
Register.com reserves the right to modify these terms at any time.
By submitting this query, you agree to abide by these terms.
Registrant:
Beijing Baidu Netcom Science and Technology Co.Ltd.
Baidu Netcom Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing, 100085
CN
Phone: +86.1059926680
Email: domainmaster@baidu.com
Registrar Name….: Register.com
Registrar Whois…: whois.register.com
Registrar Homepage: www.register.com
Domain Name: baidu.com
Created on…………..: 1999-10-11
Expires on…………..: 2014-10-11
Administrative Contact:
Beijing Baidu Netcom Science and Technology Co.Ltd.
Baidu Netcom Baidu Netcom
No. 10, Shangdi 10th Street, Haidian District,
Beijing, 100085
CN
Phone: +86.1059927440
Email: wumengyi@baidu.com
Technical Contact:
Registercom
Domain Registrar
575 8th Avenue
New York, NY 10018
US
Phone: +1.9027492701
Email: domainregistrar@register.com
DNS Servers:
ns3.baidu.com
ns2.baidu.com
ns4.baidu.com
dns.baidu.com
Visit AboutUs.org for more information about baidu.com
AboutUs: baidu.com
Register your domain name at http://www.register.com

    
最新技术文章:
▪PHP函数microtime()时间戳的定义与用法
▪PHP单一入口之apache配置内容
▪PHP数组排序方法总结(收藏)
▪php数组排序方法大全(脚本学堂整理奉献)
▪php数组排序的几个函数(附实例)
▪php二维数组排序(实例)
▪php根据键值对二维数组排序的小例子
▪php验证码(附截图)
▪php数组长度的获取方法(三个实例)
▪php获取数组长度的方法举例
▪判断php数组维度(php数组长度)的方法
▪php获取图片的exif信息的示例代码
▪PHP 数组key长度对性能的影响实例分析
▪php函数指定默认值的方法示例
▪php提交表单到当前页面、提交表单后页面重定...
▪php四舍五入的三种实现方法
▪php获得数组长度(元素个数)的方法
▪php日期函数的简单示例代码
▪php数学函数的简单示例代码
▪php字符串函数的简单示例代码
▪php文件下载代码(多浏览器兼容、支持中文文...
▪php实现文件下载、支持中文文件名的示例代码...
▪php文件下载(防止中文文件名乱码)的示例代码
▪解决PHP文件下载时中文文件名乱码的问题
▪php数组去重(一维、二维数组去重)的简单示例
▪php小数点后取两位的三种实现方法
▪php Redis 队列服务的简单示例
▪PHP导出excel时数字变为科学计数的解决方法
▪PHP数组根据值获取Key的简单示例
▪php数组去重的函数代码示例
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3