首页 \ 问答 \ 这段代码是否真的可以防止SQL注入?(Will this code actually work against SQL-injection? [duplicate])

这段代码是否真的可以防止SQL注入?(Will this code actually work against SQL-injection? [duplicate])

可能重复:
PHP:最终的清洁/安全功能

我在这里找到了这段代码: http//snipplr.com/view/12853/clean-variables-from-sql-injections/

作者声称:

这个小函数有助于解决SQL注入的常见安全问题,它可以清理任何全局变量,如$ POST,$ GET,$ _SERVER等,并转义不安全的字符。

在此处输入图像描述 这段代码安全吗?

function _clean($str){
  return is_array($str) ? array_map('_clean', $str) : str_replace("\\", "\\\\"
       , htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($str) : $str)
       , ENT_QUOTES));
}

//usage call it somewhere in beginning of your script
_clean($_POST);
_clean($_GET);
_clean($_REQUEST);// and so on..

请告诉我这是否安全,因为它看起来像陪审团操纵我。


Possible Duplicate:
PHP: the ultimate clean/secure function

I found this code snippet here: http://snipplr.com/view/12853/clean-variables-from-sql-injections/

The author claims:

This little function helps to fight common security issue with SQL injections, it can sanitize any global variable like $POST, $GET, $_SERVER etc and escape unsafe characters.

enter image description hereIs this code safe?

function _clean($str){
  return is_array($str) ? array_map('_clean', $str) : str_replace("\\", "\\\\"
       , htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($str) : $str)
       , ENT_QUOTES));
}

//usage call it somewhere in beginning of your script
_clean($_POST);
_clean($_GET);
_clean($_REQUEST);// and so on..

Please enlighten me whether this is safe, 'cause it looks jury-rigged to me.


原文:https://stackoverflow.com/questions/6164522
更新时间:2024-05-02 17:05

最满意答案

看起来您使用JRE而不是JDK运行Structr。 Structr需要JDK来动态编译类。

有关为Structr设置JDK的更多详细信息,请参阅文档


It looks like you are running Structr using JRE instead of JDK. Structr needs JDK to dynamically compile classes.

Please refer to the documentation for further details on setting up JDK for Structr.

相关问答

更多
  • 比如说社区网站,用户之间的关系有朋友关系,亲友关系,同事关系等,把每个人看作是一个结点,用户与用户之间的关系看作是一条边,这样整个社区就像一张大的图一样。 用图论的方法查找用户之间的关系网是很方便的,查询速度也极快,它可以查出通过朋友可能认识的人(二度人脉),甚至三度人脉及多度人脉,还可以查出两个用户间最短路径。 如果是这样的需求用neo4j作数据库效果非常好
  • 是,对的。 Structr启动它自己的嵌入式Neo4j数据库,所以如果你先启动Neo4j,Structr会尝试绑定到Neo4j所做的相同端口,并因为端口已经在使用而失败。 Structr没有Cypher shell的连接器,因此您将无法连接到内部Neo4j实例。 使用最新的Structr Snapshot(2.1)来自https://structr.org/repositories/snapshots/org/structr/structr-ui/2.1.0-SNAPSHOT/structr-ui-2.1. ...
  • Neo4j通常用作主数据库,有关node.js驱动程序,请参阅https://github.com/thingdom/node-neo4j 。 另外,根据您的使用情况,您可以在不同情况下将其与MySQL结合使用,以用于需要在MySQL中花费很长时间的复杂查询,如推荐和其他路径查询,请参阅http://docs.neo4j.org/chunked/snapshot/data -modeling-examples.html中的一些有趣的开始示例。 /彼得 Neo4j is often used as the p ...
  • 您的应用程序需要一个数据库才能与之通信。 您需要为他们托管一个,或者他们需要在本地拥有一个。 Neo4j不支持多租户,因此除非您可以在应用程序级别强制分离客户端数据,否则每个客户端都需要一个单独的数据库实例,如果您选择为它们托管它们。 Your application will need a database to communicate with. You'll either need to host one for them or they will need to have one locally. ...
  • 自SDN 4.2(编写本文时为4.2.RC1)以来,您可以使用只读事务。 从SDN 4.2开始,您还可以定义只读事务。 您可以通过使用@Transactional(readOnly = true)标记类或方法来启动只读事务。 http://docs.spring.io/spring-data/data-neo4j/docs/4.2.x/reference/html/#_read_only_transactions Since SDN 4.2 (4.2.RC1 at the time of writing) ...
  • 嗯,你是对的。 对于嵌入式Rails设置,这不是正确的地方。 如何为这种情况做亚马逊呢? 否则,请尝试https://github.com/maxdemarzi/neography ,它在Heroku上运行良好? Well, you are right. For embedded Rails setup, this is not the right place. How about doing Amazon instead for that scenario? Otherwise, try https:// ...
  • Neo4j通常不比SQL数据库快。 基于图的问题在很多情况下更快。 例如,如果你想找到两个实体之间的最短路径,Neo4j很可能会胜过MySQL等,因为数据的结构以及你可以使用的算法是因为这个结构。 Neo4j将其数据存储为这些节点之间的节点和关系。 它们直接相连。 简单的最短路径算法是宽度优先搜索。 你从一个节点开始,展开它的连接节点,然后为它的每个孩子做同样的事情,直到找到终端节点。 这样你只会触及少量的数据。 在SQL查询中,您无法轻松完成此操作,因此您必须在代码中构建某些内容,遍历结果集并为每个结果生 ...
  • 看起来您使用JRE而不是JDK运行Structr。 Structr需要JDK来动态编译类。 有关为Structr设置JDK的更多详细信息,请参阅文档 。 It looks like you are running Structr using JRE instead of JDK. Structr needs JDK to dynamically compile classes. Please refer to the documentation for further details on setting ...
  • 如果您有一个名为的存储库: public interface ProductRepository extends CrudRepository { List findByNameLike(String name); List findByDescriptionLike(String description); } 然后你可以做这样的事情(从4.2.0开始): List products = produc ...
  • 试试这个: $userLabel = $client->makeLabel('Users'); $user->save()->addLabels(array($userLabel)); User::addLabels需要一个Label对象数组。 https://github.com/jadell/neo4jphp/wiki/Labels#wiki-adding-labels-to-a-node 除此之外:如果添加一个裸字符串作为标签是您希望看到的功能,请提交功能请求: https : //github.c ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)