English 中文(简体)
品格和工地安全
原标题:character encoding and site security
function intfix($i)
{
   $i = preg_replace( /[^d]/ ,   , $i);
   if (!strlen($i))
      $i = 0;
   return $i;
}


function textfix($text = ""){
if(!is_array($text)){ $text = htmlentities($text,ENT_QUOTES,"UTF-8");
}
return $text;
}

这两个功能过滤了所有用户提交的变量。 你们是否认为这足够安全?

我略为混淆了大自然。 我想允许我的使用者围绕ACII艺术玩.,使用他们想要的任何象征,但现在似乎不可能。 应当做些什么? 这可能与表格编码和我的职能有关。

EDIT:

这些数字实际上很大。 有时在数万人中。

这是我如何过滤用户投入的一个例子:

if($_GET[ number ]){ $number = intfix($_GET[ number ]);  }
if($_GET[ text ]){ $text = textfix($_GET[ text ]);  } 

你们的错误是否在谈论?

这也是我如何在带至(b)之前过滤:

function filter($input,$s=1){

    $input = strip_tags($input, "");
    $input = str_replace("
", "<br />", $input);
    if($s == 1){$input = bbcode($input); } // smileys and bbcode
    $input = textWrap($input); // wordwrap without breaking html
    return $input;
}

function unfilter($input){ // to unfilter in case I need to show the text in a textbox

    $input = html_entity_decode($input,ENT_QUOTES,"UTF-8");
    $input = str_replace("<br />", "
", $input);

    return $input;

}
最佳回答

用<代码>intval()或floatval(>)取代斜体,除非你预计会有很多人,否则你将重新发明轮机。

我希望你们不会使用<条码>关于投入的内容()? 这将是一大错误。 你们必须把有关产出而不是投入的实体编码。

也许需要:

ini_set( default_charset ,  UTF-8 );
问题回答

<代码>intfix()功能并非必要,因此,你可以简单地通过$num = (int)$num;进行播种。

关于扼杀盐碱化问题,如果你不能使用“细化”的查询,通过<条码>米qsl_real_e爱因_string()通过你的扼杀。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签