预览模式: 普通 | 列表

MSSQL备份移植到另一服务器还原时容易遇到的问题,尤其是从虚拟主机备份回来的数据库在本机还原的问题…

 --将下面的代码在查询分析器中执行,修改修改库名

use 你的库名
go

declare tb cursor local
for
select 'sp_changeobjectowner '
+quotename(
+quotename(user_name(uid))
+'.'+quotename(name),'''')
+',''dbo'''
from sysobjects
where objectproperty(id,N'isusertable')=1
and uid<>user_id('dbo')
declare @s nvarchar(4000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
执行完毕就可以删除改用户了

查看更多...

Tags: sqlserver

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2307

中文搜索引擎蜘蛛大全

搜索引擎 蜘蛛名称
百度 baiduspider
谷歌 googlebot
搜狗 Sogou+web+spider
Bing bingbot
搜搜 Sosospider
360 360Spider
Msn msnbot
即刻 JikeSpider
有道 YoudaoBot
雅虎中文 Yahoo!+Slurp+China

欢迎补充。

Tags: 搜索引擎研究

分类:随笔杂记 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2806

php中eregi_replace()和ereg_replace()函数的功能一致,只是前者忽略大小写。

代码示例:

PHP代码
  1. <?php     
  2. $lines = file('source.php'); //将文件读入数组中    
  3. for($i=0; $i<count($lines); $i++)    
  4. {    
  5. //将行末以“\”或“#”开头的注释去掉    
  6. $lines[$i] = eregi_replace("(//|#).*$"""$lines[$i]);     
  7. //将行末的空白消除    
  8. $lines[$i] = eregi_replace("[ nrtvf]*$""rn"$lines[$i]);     
  9. }    
  10. //整理后输出到页面    
  11. echo htmlspecialchars(join("",$lines));    
  12. ?>   

Tags: php 正则表达式

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2549

.htaccess配置PHP错误显示

关闭错误显示:

php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0

只显示PHP错误:

php_flag display_errors on
php_flag display_startup_errors on
php_value error_reporting 2047

查看更多...

Tags: php

分类:业界文摘 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2639

Php记录网站访问log日志

PHP代码
  1. function GetRootPath()  
  2. {  
  3. $sRealPath = realpath'./' ) ;  
  4. $sSelfPath = $_SERVER['PHP_SELF'] ;  
  5. $sSelfPath = substr$sSelfPath, 0, strrpos$sSelfPath'/' ) ) ;  
  6. return substr$sRealPath, 0, strlen$sRealPath ) - strlen$sSelfPath ) ) ;  
  7. }  
  8. //记录访问日志  
  9. $logtxt="IP: ".$_SERVER["REMOTE_ADDR"]."  时间: ".strftime("%Y-%m-%d %H:%M:%S")."  页面:".$_SERVER["PHP_SELF"]."  来路: ".$_SERVER['HTTP_REFERER']."  客户端: ".$_SERVER['HTTP_USER_AGENT']."\r\n";  
  10. $fp = @fopen(GetRootPath().'/log/'.date("Ymd").'.txt',"a+");  
  11. fwrite($fp,$logtxt);  
  12. fclose($fp);  

Tags: php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3936

 

1、将时间转换为时间戳
select unix_timestamp('2009-10-26 10-06-07')
如果参数为空,则处理为当前时间
2、将时间戳转换为时间
select from_unixtime(1256540102)
有些应用生成的时间戳是比这个多出三位,是毫秒表示,如果要转换,需要先将最后三位去掉(标准的10位数字,如果是13位的话可以以除以1000的方式),否则返回NULL

还有就是IP地址和数字之间的转换:

1.将IP地址转化为数字

select inet_aton('210.30.0.103');

2.将数字转化为IP地址

 

查看更多...

Tags: mysql

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2266

IP地址与数字地址相互转换

首先来看一下网上提供的IP查询工具是如何通过IP查找出具体物理位置的。



站长网IP查询地址:http://tool.chinaz.com/ip/
可以看到,IP查询工具是先将IP段地址转化成数字地址,再才得到IP的物理地址。
-------------------------------------------------------------------------------------------------------------------------------------
为什么要将IP段地址转化成数字地址?

根据TCP/IP协议规定,IP地址是由32位二进制数组成,而且在INTERNET范围内是唯一的。例如,某台联在因特网上的计算机的IP地址为: 
11010010 01001001 10001100 00000010 
很明显,这些数字对于人来说不太好记忆。人们为了方便记忆,就将组成计算机的IP地址的32位二进制分成四段,每段8位,中间用小数点隔开,然后将每八位二进制转换成十进制数,这样上述计算机的IP地址就变成了:118.123.15.102。
由于在同一个区域里,IP段都是很相近的,如果拿IP段(118.123.15.102)直接进行比较,在操作上很是麻烦,而且数据的存储也不易实现,所以才会把IP转换成数字地址,再来确定IP段的物理地址。

-------------------------------------------------------------------------------------------------------------------------------------
理解了IP的概念之后,诸如IP(118.123.15.102)怎样转换成数字地址呢?

IP本是32为二进制,为了方便记忆才转化成了四段十进制,所以只要把IP还原成二进制,再转换成十进制就可以得到IP的数字地址。

.NET C# IP与数字地址相互转化:

查看更多...

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 3359

记录网站访问日志按日期保存。

PHP代码
  1. $logtxt="IP: ".$_SERVER["REMOTE_ADDR"]."  时间: ".strftime("%Y-%m-%d %H:%M:%S")."  页面:".$_SERVER["PHP_SELF"]."  来路: ".$_SERVER['HTTP_REFERER']."  客户端: ".$_SERVER['HTTP_USER_AGENT']."\r\n";  
  2. $fp = @fopen('/log'.date("Ymd").'.txt',"a+");  
  3. fwrite($fp,$logtxt);  
  4. fclose($fp);  

附带PHP服务器变量$_SERVER详解
1、$_SESSION['PHP_SELF'] — 获取当前正在执行脚本的文件名。
将得到浏览器请求页面的文件名, 并剥掉问号 ? 后的内容, 注意:不包含路径, 比如在客户端里请求 http://localhost:8080/test.php?age=20&name=Tom,那么test.php 和 test_dir/test2.php 的 $_SERVER["PHP_SELF"] 都将得到 “test.php”。”age=20&name=Tom”被剥掉。
而如果客户端里请求 http://localhost:8080/test.php/age=20&name=Tom,那么test.php 和 test_dir/test2.php 的 $_SERVER["PHP_SELF"] 都将得到 “test.php/age=20&name=Tom”。
2、$_SERVER['SERVER_PROTOCOL'] — 请求页面时通信协议的名称和版本。例如,“HTTP/1.0”。
3、$_SERVER['REQUEST_TIME'] — 请求开始时的时间戳。从 PHP 5.1.0 起有效。和time函数效果一样。
4、$_SERVER['argv'] — 传递给该脚本的参数。我试了下,get方法可以得到$_SERVER['argv'][0];post方法无法给他赋值。
5、$_SERVER['SERVER_NAME'] — 返回当前主机名。
6、$_SERVER['SERVER_SOFTWARE'] — 服务器标识的字串,在响应请求时的头信息中给出。 如Microsoft-IIS/6.0
7、$_SERVER['REQUEST_METHOD'] — 访问页面时的请求方法。例如:“GET”、“HEAD”,“POST”,“PUT”。
8、$_SERVER['QUERY_STRING'] – 查询(query)的字符串(URL 中第一个问号 ? 之后的内容)。
9、$_SERVER['DOCUMENT_ROOT'] — 当前运行脚本所在的文档根目录。在服务器配置文件中定义。 如E:\server
10、$_SERVER['HTTP_ACCEPT'] — 当前请求的 Accept: 头信息的内容。
11、$_SERVER['HTTP_ACCEPT_CHARSET'] — 当前请求的 Accept-Charset: 头信息的内容。例如:“iso-8859-1,*,utf-8”。
12、$_SERVER['HTTP_ACCEPT_ENCODING'] — 当前请求的 Accept-Encoding: 头信息的内容。例如:“gzip”。
13、$_SERVER['HTTP_ACCEPT_LANGUAGE'] — 当前请求的 Accept-Language: 头信息的内容。例如:“en”。
14、$_SERVER['HTTP_CONNECTION'] — 当前请求的 Connection: 头信息的内容。例如:“Keep-Alive”。
15、$_SERVER['HTTP_HOST'] — 当前请求的 Host: 头信息的内容。
16、$_SERVER['HTTP_REFERER'] — 链接到当前页面的前一页面的 URL 地址。
17、$_SERVER['HTTP_USER_AGENT'] — 返回用户使用的浏览器信息。也可以使用 get_browser() 得到此信息。
18、$_SERVER['HTTPS'] — 如果通过https访问,则被设为一个非空的值,否则返回off.
19、$_SERVER['REMOTE_ADDR'] — 正在浏览当前页面用户的 IP 地址。
20、$_SERVER['REMOTE_HOST'] — 正在浏览当前页面用户的主机名。反向域名解析基于该用户的 REMOTE_ADDR。如本地测试返回127.0.0.1

21、$_SERVER['REMOTE_PORT'] — 用户连接到服务器时所使用的端口。我在本机测试没通过,不知道什么原因。
22、$_SERVER['SCRIPT_FILENAME'] — 当前执行脚本的绝对路径名。如返回E:\server\index.php
23、$_SERVER['SERVER_ADMIN'] — 该值指明了 Apache 服务器配置文件中的 SERVER_ADMIN 参数。如果脚本运行在一个虚拟主机上,则该值是那个虚拟主机的值
24、$_SERVER['SERVER_PORT'] — 服务器所使用的端口。默认为“80”。如果使用 SSL 安全连接,则这个值为用户设置的 HTTP 端口。
25、$_SERVER['SERVER_SIGNATURE'] — 包含服务器版本和虚拟主机名的字符串。
26、$_SERVER['PATH_TRANSLATED'] — 当前脚本所在文件系统(不是文档根目录)的基本路径。这是在服务器进行虚拟到真实路径的映像后的结果。 Apache 2 用 户可以使用 httpd.conf 中的 AcceptPathInfo On 来定义 PATH_INFO。
27、$_SERVER['SCRIPT_NAME'] — 包含当前脚本的路径。这在页面需要指向自己时非常有用。__FILE__ 包含当前文件的绝对路径和文件名(例如包含文件)。
将得到浏览器请求的页面文件的文件名,注意: 与 $_SERVER["SCRIPT_NAME"] 不同, 此变量只得到文件名而不包含路径,在test.php 与 test_dir/test2.php 用$_SERVER["SCRIPT_NAME"] 得到的都将是 test.php.
当然, 在test.php 与 test_dir/test2.php 执行 basename($_SERVER["SCRIPT_FILENAME"]) 与 $_SERVER["SCRIPT_NAME"] 相同.执行在test.php 与 test_dir/test2.php 执行 realpath(”test.php”) 得到的结果与 $_SERVER["SCRIPT_FILENAME"] 相同
28、$_SERVER['REQUEST_URI'] — 访问此页面所需的 URI。例如,“/index.html”。
29、$_SERVER['PHP_AUTH_DIGEST'] — 当作为 Apache 模块运行时,进行 HTTP Digest 认证的过程中,此变量被设置成客户端发送的“Authorization”HTTP 头内容(以便作进一步的认证操作)。
30、$_SERVER['PHP_AUTH_USER']– 当 PHP 运行在 Apache 或 IIS(PHP 5 是 ISAPI)模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的用户名。
31、$_SERVER['PHP_AUTH_PW'] — 当 PHP 运行在 Apache 或 IIS(PHP 5 是 ISAPI)模块方式下,并且正在使用 HTTP 认证功能,这个变量便是用户输入的密码。
32、$_SERVER['AUTH_TYPE']–当 PHP 运行在 Apache 模块方式下,并且正在使用 HTTP 认证功能,这个变量便是认证的类型。

Tags: php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2681

电脑由于安全原因时间无法同步

windows time服务失效。 修复: 1.开始---所有程序----附件----命令提示符,进入命令行,然后键入 :
w32tm /register
正确的响应为: W32Time 成功注册。
2.如果上一步正确,用
net start "windows time"启动服务。
可以粘贴

经本人测试此方法无效,重启电脑后时间又会出错!怀疑是主机纽扣电池没电了。

分类:业界文摘 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 6057

目前主流网站都是这样,google chrome浏览器不支持点击加入收藏夹,提示手工Ctrl+D添加收藏夹。

JavaScript代码
  1. function add_favourite()  
  2. {  
  3.     try{  
  4.         if ( window.sidebar && 'object' == typeof( window.sidebar ) && 'function' == typeof( window.sidebar.addPanel ) ){  
  5.             window.sidebar.addPanel("田志刚个人博客", window.location.href , '');  
  6.         }  
  7.         else if ( document.all && 'object' == typeof( window.external ) ){  
  8.             window.external.addFavorite(window.location.href , "t");  
  9.         }  
  10.         else {  
  11.             alert('您使用的浏览器不支持此功能,请按“Ctrl + D”键手工加入收藏');  
  12.         }  
  13.     }catch(e){  
  14.         alert('您使用的浏览器不支持此功能,请按“Ctrl + D”键手工加入收藏');  
  15.     }   
  16.     return false;  
  17. }  

代码来源:360网址导航

Tags: javascript

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 4121

常见http错误

400 Invalid syntax. 语法问题
401 Access denied. 访问拒绝
402 Payment required. 必须完整
403 Request forbidden. 请求被禁止
404 Object not found. 对象没有找到
405 Method is not allowed. 方法不允许
406 No response acceptable to client found. 客户端没有响应
407 Proxy authentication required. 代理需要验证
408 Server timed out waiting for request. 等等请求时服务器断开连接
409 User should resubmit with more info. 有冲突用户应该进行检查
410 Resource is no longer available. 资源不可用
411 Server refused to accept request without a length. 服务器拒绝接受没有长度的请求
412 Precondition given in request failed. 放弃请求失败的条件
413 Request entity was too large. 请求太大
414 Request Uniform Resource Identifier (URI) too long. 请求的URI 太长
415 Unsupported media type. 不支持MEDIA类型
449 Retry after doing the appropriate action. 在作了适当动作后重试
500 Internal server error. 服务器内部错误
501 Server does not support the functionality required to fulfill the request. 服务器不支持请求的功能
502 Error response received from gateway. 从网关收到错误应答
503 Temporarily overloaded. 过载
504 Timed out waiting for gateway. 等待网关时请求断开
505 HTTP version not supported. 不支持HTTP的版本


HTTP status codes returned by servers on the Internet.
从Internet返回的HTTP status代码(HTTP 状态字)
HTTP_STATUS_CONTINUE (100)
The request can be continued.
请求不能被继续
HTTP_STATUS_SWITCH_PROTOCOLS (101)
The server has switched protocols in an upgrade header.
通过新的header服务器的协议被转换了
HTTP_STATUS_OK (200)
The request completed successfully.
请求成功的完成
HTTP_STATUS_CreateD (201)
The request has been fulfilled and resulted in the creation of a new resource.
通过新的资源请求已经被完成
HTTP_STATUS_ACCEPTED (202)
The request has been accepted for processing, but the processing has not been completed.
请求已经被接受处理,但是处理还没有完成
HTTP_STATUS_PARTIAL (203)
The returned meta information in the entity-header is not the definitive set available from the origin server.
从服务器返回的在entity-header中的meta信息是无效的
HTTP_STATUS_NO_CONTENT (204)
The server has fulfilled the request, but there is no new information to send back.
服务器实现了请求,但是没有返回信息
HTTP_STATUS_RESET_CONTENT (205)
The request has been completed, and the client program should reset the document view that caused the request to be sent to allow the user to easily initiate another input action.
请求已经被完成,并且web程序(客户端程序浏览器程序)已经重置了文档视图目录(content),这个目录很容易允许使用者用另一个动作发送请求
HTTP_STATUS_PARTIAL_CONTENT (206)
The server has fulfilled the partial GET request for the resource.
服务器已经为资源完成了部分GET请求
HTTP_STATUS_AMBIGUOUS (300)
The server couldn't decide what to return.
服务器不能判定返回什么
HTTP_STATUS_MOVED (301)
The requested resource has been assigned to a new permanent URI (Uniform Resource Identifier), and any future references to this resource should be done using one of the returned URIs.
被请求的资源已经被分配给新的URI,并且以后引用时都使用这个URIs资源。
HTTP_STATUS_REDIRECT (302)
The requested resource resides temporarily under a different URI (Uniform Resource Identifier).
请求的资源临时在不同的uri下
HTTP_STATUS_REDIRECT_METHOD (303)
The response to the request can be found under a different URI (Uniform Resource Identifier) and should be retrieved using a GET HTTP verb on that resource.
请求的资源不能在不同的uri下找到,并且从新使用GET HTTP在服务器上从新检索
HTTP_STATUS_NOT_MODIFIED (304)
The requested resource has not been modified.
请求的资源没有被改变
HTTP_STATUS_USE_PROXY (305)
The requested resource must be accessed through the proxy given by the location field.
请求的资源必须通过特定的代理获得
HTTP_STATUS_REDIRECT_KEEP_VERB (307)
The redirected request keeps the same HTTP verb. HTTP/1.1 behavior.
从定位请求,
HTTP_STATUS_BAD_REQUEST (400)
The request could not be processed by the server due to invalid syntax.
因为语法不能被服务器处理
HTTP_STATUS_DENIED (401)
The requested resource requires user authentication.
请求资源命令必须被验证(拒绝访问)
HTTP_STATUS_PAYMENT_REQ (402)
Not currently implemented in the HTTP protocol.
没有完全实现HTTP协议
HTTP_STATUS_FORBIDDEN (403)
The server understood the request, but is refusing to fulfill it.
服务器理解了请求,但是拒绝完成他
HTTP_STATUS_NOT_FOUND (404)
The server has not found anything matching the requested URI (Uniform Resource Identifier).
没有找到任何被指定的URI

HTTP_STATUS_BAD_METHOD (405)
The HTTP verb used is not allowed.
Http动作不被允许
HTTP_STATUS_NONE_ACCEPTABLE (406)
No responses acceptable to the client were found.
应答没有被客户接受
HTTP_STATUS_PROXY_AUTH_REQ (407)
Proxy authentication required.
代理必须被验证
HTTP_STATUS_REQUEST_TIMEOUT (408)
The server timed out waiting for the request.
服务器在等待请求时中止了
HTTP_STATUS_CONFLICT (409)
The request could not be completed due to a conflict with the current state of the resource. The user should resubmit with more information.
请求不能被完成,问题是资源冲突。用户应该进行调整
HTTP_STATUS_GONE (410)
The requested resource is no longer available at the server, and no forwarding address is known.
请求的资源在服务器上不再可用,而且没有转发地址
HTTP_STATUS_LENGTH_REQUIRED (411)
The server refuses to accept the request without a defined content length.
服务器拒绝接受没有定义目录大小的请求
HTTP_STATUS_PRECOND_FAILED (412)
The precondition given in one or more of the request header fields evaluated to false when it was tested on the server.
当在服务器上测试请求头文件放弃一个或者多个请求的条件
HTTP_STATUS_REQUEST_TOO_LARGE (413)
The server is refusing to process a request because the request entity is larger than the server is willing or able to process.
服务器拒绝处理请求,原因是请求的大小超过服务器能够处理的大小
HTTP_STATUS_URI_TOO_LONG (414)
The server is refusing to service the request because the request URI (Uniform Resource Identifier) is longer than the server is willing to interpret.
服务器拒绝服务,原因是请求的URI超过了服务器能够揭示的长度
HTTP_STATUS_UNSUPPORTED_MEDIA (415)
The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
服务器拒绝服务,原因是请求格式不被支持
HTTP_STATUS_RETRY_WITH (449)
The request should be retried after doing the appropriate action.
在作了适当的动作后请求被重试
HTTP_STATUS_SERVER_ERROR (500)
The server encountered an unexpected condition that prevented it from fulfilling the request.
服务器遇到请求失败意外
HTTP_STATUS_NOT_SUPPORTED (501)
The server does not support the functionality required to fulfill the request.
服务器不支持必须完成请求的功能
HTTP_STATUS_BAD_GATEWAY (502)
The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.
服务器当作为网关或代理时,从上行服务器接受的响应请求失败
HTTP_STATUS_SERVICE_UNAVAIL (503)
The service is temporarily overloaded.
服务器负载
HTTP_STATUS_GATEWAY_TIMEOUT (504)
The request was timed out waiting for a gateway.
等待网关时请求断开,没有响应
HTTP_STATUS_VERSION_NOT_SUP (505)
The server does not support, or refuses to support, the HTTP protocol version that was used in the request message.
服务器不支持或者拒绝支持正在使用请求的HTTP协议的版本

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2585

百度观察期内的网站不要随便动!

 昨天刚恢复了几十页,晚上做了301重定向,今天site又成了0了,杯具。
去掉301重定向,又有一点收录了,变化真快。

Tags: 百度

分类:随笔杂记 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2208

 广告位

↑返回顶部↑