我有一个PHP脚本,其中包含以下行:
$query = "SELECT * FROM products WHERE product_id='" . filter_var($_GET[id], FILTER_SANITIZE_NUMBER_INT) . "'";
Run Code Online (Sandbox Code Playgroud)
这样安全吗?你会如何改进这段代码?
我有一个使用spring web flow ang spring security的j2ee web应用程序.如果用户的角色在被访问的页面上没有访问权限,我想将用户重定向到页面(可能是错误页面),因为目前我收到错误
错误404 - 从RFC 2068超文本传输协议找不到 - HTTP/1.1:10.4.5 404未找到服务器未找到与Request-URI匹配的任何内容.没有说明该病症是暂时的还是永久性的.
如果服务器不希望将此信息提供给客户端,则可以使用状态代码403(禁止).如果服务器通过一些内部可配置的机制知道旧资源永久不可用且没有转发地址,则应该使用410(Gone)状态代码.
我如何进行此重定向.我尝试了安全性的access-denied-page属性:http但我仍然得到错误.这是我对security-http的配置.
顺便说一句.我正在使用Spring Faces和Facelets.这可能是问题的原因吗?
<!-- Configure Spring Security -->
<security:http auto-config="true" access-denied-page="/deniedpage.xhtml"
session-fixation-protection="newSession">
<security:intercept-url pattern="/main.do"
access="ROLE_SUPERVISOR, ROLE_USER" />
<security:intercept-url pattern="/logoutSuccess.do"
access="ROLE_SUPERVISOR, ROLE_USER" />
<security:intercept-url pattern="/edit.do"
access="ROLE_SUPERVISOR" />
<security:intercept-url pattern="/register.do"
access="ROLE_SUPERVISOR" />
<security:intercept-url pattern="/admin_main.do"
access="ROLE_SUPERVISOR" />
<security:intercept-url pattern="/*"
access="IS_AUTHENTICATED_ANONYMOUSLY" />
<security:form-login login-page="/loginForm.do"
default-target-url="/main.do" authentication-failure-url="/loginForm.do?login_error=1" />
<security:logout logout-url="/logout.do"
invalidate-session="true" logout-success-url="/logoutSuccess.do" />
<security:concurrent-session-control
max-sessions="-1" exception-if-maximum-exceeded="true" expired-url="/loginform.do" />
</security:http>
Run Code Online (Sandbox Code Playgroud) 我有一个字符串" This is a test ".我想用空格字符分割字符串.我是这样做的:
puts " This is a test ".strip.each(' ') {|s| puts s.strip}
Run Code Online (Sandbox Code Playgroud)
结果是:
这个
是
一个
测试
这是一个测试
为什么会有最后一行"This is a test"?我需要的是,如果两个单词之间有两个或更多空格字符,那么这不应该返回"行".
我只想得到在给定字符串中分割的单词.
有没有人有想法?
我注意到在Django模型中,有一个class Meta对模型做出了一些额外的定义.
我的问题是,为什么这是一个旧式的课程呢?(即不进行子类化object?)是否有这样的原因或这只是一个习惯?我可以在项目中作为新式课程吗?
我有以下型号:
class A(models.Model):
name = models.CharField(max_length=50)
content_type = models.ForeignKey(ContentType)
Run Code Online (Sandbox Code Playgroud)
该模型应该是某些继承树中的根模型,而content_type属性是一种关于实际存储类型的提示.显然,我应该content_type在创建实例时透明地计算.我想,在__init__.但是存在一个问题 - 创建A实例有两个主要的上下文:
a = A(name='asdfdf') # here we must fill in content_typeQuerySet机械与*args元组.在这种情况下,我不应该填写content_type所以,我想写:
def __init__(self, *args, **kwargs):
super(A, self).__init__(*args, **kwargs)
if self.content_type is None: # << here is the problem
self.content_type = ContentType.objects.get_for_model(self)
Run Code Online (Sandbox Code Playgroud)
事情是self.content_type为ReverseSingleRelatedObjectDescriptor实例与__get__被覆盖的,以便它在案值抛出未设置.是的,我可以这样做:
def __init__(self, *args, **kwargs):
super(A, self).__init__(*args, **kwargs)
try:
self.content_type
except Exception, v:
self.content_type = ContentType.objects.get_for_model(self)
Run Code Online (Sandbox Code Playgroud)
但我不喜欢它.是否有更"礼貌"的方式来检查ForeignKey属性是否已设置?
我想知道在使用和处理消息队列时你的最佳做法是什么.如果特别是在处理部分中有代码以便可视化您的概念,我也将不胜感激.语言是C#或任何.NET语言都可以.正在使用的队列是Microsoft消息队列.
目前我遇到的错误是我们的系统资源不足但我们的硬件规格内存和磁盘空间很高.
我遇到的具体错误消息是:资源不足,无法执行操作.
非常感谢任何有关此事的重要或相关帮助.在此先感谢您的时间.
我尝试执行以下命令:
mysql AMORE -u username -ppassword -h localhost -e "SELECT host FROM amoreconfig"
Run Code Online (Sandbox Code Playgroud)
我把它存储在一个字符串中:
cmd="mysql AMORE -u username -ppassword -h localhost -e\"SELECT host FROM amoreconfig\""
Run Code Online (Sandbox Code Playgroud)
测试一下:
echo $cmd
mysql AMORE -u username -ppassword -h localhost -e"SELECT host FROM amoreconfig"
Run Code Online (Sandbox Code Playgroud)
尝试执行:
$cmd
Run Code Online (Sandbox Code Playgroud)
我得到了mysql的帮助页面:
mysql Ver 14.14 Distrib 5.1.31, for pc-linux-gnu (i686) using readline 5.1
Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute …Run Code Online (Sandbox Code Playgroud) 我试图使用以下查询在表中插入数据并出错
insert into filmo_person_song (person_id, song_id, role_id)
select person_id
from filmo_person_song fps, filmo_song fs, filmo_role fr
where fps.song_id = fs.song_id
and fps.role_id = fr.role_id
and fps.person_id = 43629;
Run Code Online (Sandbox Code Playgroud)
ERROR 1136(21S01):列数与第1行的值计数不匹配
我已准确指定了字段..