改变旧脚本 - 注册全局 - 如何转换? [英] changing old script - register globals - how to convert?

查看:54
本文介绍了改变旧脚本 - 注册全局 - 如何转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个旧脚本是在


注册全局变量''''时编写的。


现在我需要将其转换为运行在一台带有php 4.3.6的服务器上 - 我只是

将相关变量从


$ posted_variable转换为$ _POST [''posted_variable'']


i意识到许多变量都是scrit内部的,所以不会改变



i我有点担心,因为一些脚本引用的变量是

用作流并用于上传图像文件。


感谢任何指针,


kev


这里的脚本是来自
http://www.onlamp.com/pub/a/onlamp/ 2 ... b2.html?page = 1


<!DOCTYPE HTML PUBLIC

" - // W3C // DTD HTML 4.0 Transitional // EN"

" http://www.w 3.org/TR/html4/loose.dtd">

< html>

< head>

< title>浏览上传文件< / title>

< / head>

< body bgcolor =" white">


<?php

包含''db.inc'';


$ query =" SELECT id,shortName,mimeName FROM files" ;;


if(!($ connection = @ mysql_pconnect($ hostName,

$ username,

$ password))) />
showerror();


if(!mysql_select_db(" files",$ connection))

showerror();


if(!($ result = @ mysql_query($ query,$ connection)))

showerror();

?> ;

< h1>图片数据库< / h1>


< h3>点击< a href =" insert.php"> here< ; / A>

上传图片。< / h3>

<?php

需要''免责声明'';


if($ row = @ mysql_fetch_array($ result))

{

?>


< table>

< col span =" 1" align =" right">

< tr>

< th>简短描述< / th>

< th>文件类型< / th>

< th>图片< / th>


< / tr>

< ?php

do

{

?>

< tr>

< td><?php echo" {$ row [" shortName"]}" ;;?>< / td>

< td><?php echo " {$ row [" mimeName"]}" ;;?>< / td>

< td><?php echo"< img src = \" ; view.php?file = {$ row [" id"]} \">";?>< / td>

< / tr>

<?php

} while($ row = @ mysql_fetch_array($ result));

?>

< / table>

<?php

} //如果mysql_fetch_array()

else

echo "< h3>没有要显示的图片< / h3> \ n" ;;

?>

< / body>

< / html>

解决方案

published_variable to


_POST [''posted_variable'']


i意识到许多变量都是scrit的内部因此不会被改变。


我有点担心,因为有些脚本指的是将
用作流并用于上传图像文件的变量。


感谢任何指针,


kev



这里的脚本来自
http://www.onlamp.com/pub/a/onlamp/2...b2.html?page= 1


<!DOCTYPE HTML PUBLIC

" - // W3C // DTD HTML 4.0 Transitional // EN"

" http://www.w3.org/TR/html4/loose.dtd">

< html>

< head> ;

< title>浏览上传文件< / title>

< / head>

< body bgcolor =" white">


<?php

包含''db.inc' ';


query =" SELECT id,shortName,mimeName FROM files" ;;


if(! (

this old script was written when

register globals was ''on''.

now i need to convert it to run on a server with a php 4.3.6 - do i just
convert the relevant variables from

$posted_variable to $_POST[''posted_variable'']

i realise that many of the variables are internal to the scrit so will not
be altered.

i''m slightly concerned because some of the script refers to variables which
are used as streams and used to upload image files.

thanks for any pointers,

kev


here are the scripts from
http://www.onlamp.com/pub/a/onlamp/2...b2.html?page=1

<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Browse Upload Files</title>
</head>
<body bgcolor="white">

<?php
include ''db.inc'';

$query = "SELECT id, shortName, mimeName FROM files";

if (!($connection = @ mysql_pconnect($hostName,
$username,
$password)))
showerror();

if (!mysql_select_db("files", $connection))
showerror();

if (!($result = @ mysql_query ($query, $connection)))
showerror();
?>
<h1>Image database</h1>

<h3>Click <a href="insert.php">here</a> to
upload an image.</h3>
<?php
require ''disclaimer'';

if ($row = @ mysql_fetch_array($result))
{
?>

<table>
<col span="1" align="right">
<tr>
<th>Short description</th>
<th>File type</th>
<th>Image</th>

</tr>
<?php
do
{
?>
<tr>
<td><?php echo "{$row["shortName"]}";?></td>
<td><?php echo "{$row["mimeName"]}";?></td>
<td><?php echo "<img src=\"view.php?file={$row["id"]}\">";?></td>
</tr>
<?php
} while ($row = @ mysql_fetch_array($result));
?>
</table>
<?php
} // if mysql_fetch_array()
else
echo "<h3>There are no images to display</h3>\n";
?>
</body>
</html>

解决方案

posted_variable to


_POST[''posted_variable'']

i realise that many of the variables are internal to the scrit so will not
be altered.

i''m slightly concerned because some of the script refers to variables which
are used as streams and used to upload image files.

thanks for any pointers,

kev


here are the scripts from
http://www.onlamp.com/pub/a/onlamp/2...b2.html?page=1

<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Browse Upload Files</title>
</head>
<body bgcolor="white">

<?php
include ''db.inc'';


query = "SELECT id, shortName, mimeName FROM files";

if (!(


这篇关于改变旧脚本 - 注册全局 - 如何转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆