如果我用我的cms发布脚本,人们无法读取它,它会以文本形式进入数据库
像这样:
<script>
// Source: http://www.backalleycoder.com/2011/03/20/link-tag-css-stylesheet-load-event/
var loadCSS = function(url, callback){
var link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = url;
link.id = 'theme-style';
document.getElementsByTagName('head')[0].appendChild(link);
var img = document.createElement('img');
img.onerror = function(){
if(callback) callback(link);
}
img.src = url;
}
$(document).ready(function() {
var initEditor = function() {
$("textarea").sceditor({
plugins: 'bbcode',
style: "./minified/jquery.sceditor.default.min.css"
});
};
$("#theme").change(function() {
var theme = "./minified/themes/" + $(this).val() + ".min.css";
$("textarea").sceditor("instance").destroy();
$("link:first").remove();
$("#theme-style").remove();
loadCSS(theme, initEditor);
});
initEditor();
});
</script>
但我怎么能知道它可以在网站上阅读?
我使用这个mysql查询:
INSERT INTO categorie (title, longstory, shortstory, date, author, categorie, type,img) VALUES('{$title}','" . htmlspecialchars_decode($longstory) . "','{$shortstory}','" . time() . "','". $_SESSION['user']['username'] ."','{$categorie}','{$type}','{$img}')";
我用来发布一个脚本:" . htmlspecialchars_decode($longstory) . "
答案 0 :(得分:2)
要使用mysql(i)_real_escape_string
转义数据库(字符串/文本)输入。
htmlspecialchars
会在输出中使用。