虽然相隔千里,虽然擦肩也无缘相见,但是闭上眼睛还是可以见到你~
Day Dream这种东西是会上瘾的。
[singlepic=15460]
虽然相隔千里,虽然擦肩也无缘相见,但是闭上眼睛还是可以见到你~
Day Dream这种东西是会上瘾的。
[singlepic=15460]
最近的上海一直晴天,除了温度稍微高了一点(38度左右,睡觉有点困难),天色还是很不错的。蓝天白云,往窗外望望看上去真的很舒服,景物的对比度也超高,感觉置身国外了。
台风要来了,起风了。
[singlepic=15195,700,525]
[singlepic=15168,700,525]
家-院里的鹅掌楸
[singlepic=15169,700,525]
济南-山大路
[singlepic=15170,700,525]
济南-山大路
[singlepic=15171,700,525]
济南-山大路
[singlepic=15172,700,525]
济南-明湖东路
[singlepic=15173,700,525]
济南-银座北园店
[singlepic=15174,700,525]
实验室-炎热的上海
[singlepic=15175,700,525]
实验室-炎热的上海
防止你的网站被注入式攻击的第一步是理解什么是注入式攻击。一个注入式攻击是网站的某个访客在你的网站输入表单中输入了某种内容,试图改变你的MySQL查询本意。例如,某些人可能会在登陆窗口使用这种方法绕开登陆。如果你的查询用户名和密码的形式类似这样子:
[code=’sql’]
SELECT * FROM users WHERE username = {username} AND
password = {password }
[/code]
那么用户可以使用任意的用户名,使用这个密码:
[code=’sql’]’ OR ”=”[/code]
从而使得你的验证用户名密码的MySQL查询变成:
[code=’sql’]
SELECT * FROM users WHERE username = ‘anyuser’ AND
password = ” OR ”=”
[/code]
由于空串总是等于空串,所以查询条件永真。因此可以看到,MySQL注入的风险还是很大的,因为攻击者可以看到那些本来应该通过登陆才能访问的数据。防止你的网站受到注入式攻击是非常重要的。幸运的是,PHP可以帮助我们防止注入式攻击。
MySQL将会返回表中的所有行,根据你的程序逻辑,可能会导致全部用户都登陆了,因为他们都被匹配到了。现在,大部分情况下,人们会打开magic_quotes_gpc选项(也是PHP的默认情况),这样的配置将会自动添加反斜线,转义全部'(单引号),”(双引号),\(反斜线)和空字符。但事情并不是这么简单就能解决,因为并不是所有的会导致风险的字符都被转义了。PHP有一个函数可以转义全部可能带来多余SQL子句的MySQL字符。这个函数就是mysql_real_escape_string()。
使用这个函数的时候要小心,因为你可能已经打开了magic_quotes_gpc选项,这时候使用mysql_real_escape_string()会导致第二次转义。下面这个函数避免了这个问题,首先判断
magic_quotes_gpc选项是否打开,然后再决定是否执行mysql_real_escape_string()。
[code=’php’]
[/code]
需要注意的是,quote_smart()函数会自动给字符串加引号,因此你不需要自己加。
另外需要注意,因为不同的MySQL版本对于过滤的要求不一样,mysql_real_escape_string()需要一个MySQL连接才能工作,因此必须第二个参数传入一个MySQL连接。在本机安装MySQL的情况,可以省略,但是如果本机没有装MySQL,或者远程连接到MySQL,则这个参数必不可少,否则mysql_real_escape_string()将返回一个空字符串。
如果你有任何疑问,可以在下面评论,我们一起讨论。
0. 更新日志
1. 功能介绍
Nocoo IP 即查即看工具是Nocoo编写的一款旨在帮助站长了解其访客来源的小工具。以往,站长如果想确定某个IP的地理位置,需要将IP复制下来,使用第三方网站进行查询,非常麻烦,而且不能一次查询多个IP。
运行效果
有了这款工具,站长只需要把文字区域选中,复制,就会在任务栏弹出气球,自动分析剪贴板内所有IP,并将其地址查询结果返回,大大提高站长的管理效率。
2. 系统需求
3. 疑难解答
4. 下载地址
为项目组写了几个Howto的Case。
本文描述了一个用C#实现了在Windows Form或者Windows Console下调用Web Service的例子。
这是一个较复杂的例子。解决方案由三个项目组成:
1. ClassLibrary
Dorm.cs
[code=’c#’]
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
namespace ClassLibrary
{
[Serializable, XmlRoot(Namespace = “http://its.hpcc.tongji.edu.cn”)]
public class Dorm
{
[XmlAttribute]
public string Name;
[XmlElement]
public string Number;
}
}
[/code]
Student.cs
[code=’c#’]
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
namespace ClassLibrary
{
[Serializable, XmlRoot(Namespace = “http://its.hpcc.tongji.edu.cn”)]
public class Student
{
[XmlElement]
public long Number;
[XmlElement]
public string Name;
[XmlElement]
public bool enabled;
[XmlElement]
public Dorm dorm;
}
}
[/code]
2. WebServiceHowto
ITSTestService.asmx.cs
[code=’c#’]
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using ClassLibrary;
namespace WebServiceHowto
{
///
[WebService(Namespace = “http://hpcc.tongji.edu.cn/”)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class ITSTestService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return “Hello World”;
}
[WebMethod]
public Student GetStudent(Dorm d)
{
Student student = new Student();
student.dorm = d;
student.enabled = true;
student.Number = 222222;
student.Name = “maojun”;
return student;
}
}
}
[/code]
3. UseWebServiceHowto
Program.cs
[code=’c#’]
using System;
using System.Collections.Generic;
using System.Text;
using ClassLibrary;
namespace UseWebServiceHowto
{
class Program
{
static void Main(string[] args)
{
WebServiceProxy proxy = new WebServiceProxy();
Dorm dorm = new Dorm();
dorm.Name = “geng der drom”;
dorm.Number = “16-501-5”;
Student s = proxy.GetStudent(dorm);
Console.WriteLine(“Student Name={0}, Dorm={1}”, s.Name, s.dorm.Name);
}
}
}
[/code]
WebServiceProxy.cs
[code=’c#’]
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;
using System.Web.Services;
using System.Diagnostics;
using System.ComponentModel;
using ClassLibrary;
namespace UseWebServiceHowto
{
[WebServiceBinding(Name = “TestWebServiceSoap”, Namespace = “http://hpcc.tongji.edu.cn/”), DebuggerStepThrough, DesignerCategory(“code”)]
class WebServiceProxy : SoapHttpClientProtocol
{
public WebServiceProxy()
{
base.Url = “http://localhost:3489/ITSTestService.asmx”;
}
[SoapDocumentMethod(“http://hpcc.tongji.edu.cn/GetStudent”, RequestNamespace = “http://hpcc.tongji.edu.cn/”, ResponseNamespace = “http://hpcc.tongji.edu.cn/”, Use = System.Web.Services.Description.SoapBindingUse.Default, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Default)]
public Student GetStudent(Dorm d)
{
return (Student)base.Invoke(“GetStudent”, new object[] { d })[0];
}
}
}
[/code]
下载:用Visual Studio 2008打开
http://download.nocoo.us/Download/Archive/CSharpHowto/SQLServer.rar