<?
/////////////////////////////////////////////////////
//  险情文章管理 1.0正式版本--php文本存储格式      //
//  作者：上海财经大学99国际工管    险情           //
//  email：indraw@sina.com                         //
//  qq：   30467826                                //
//  技术支持：http://shcj.51.net/wdb               //
//  最新演示：http://xqart.126.com                 //
//  2002/4/10                                      //
//  最新下载地址 http;//shcj.51.net/wdb            //
/////////////////////////////////////////////////////
include ("admin_log.php");
echo("<html><head><title>上传一张图片</title><LINK href=\"style.css\" type=text/css rel=stylesheet> </head><body>");
echo"<table width=100% cellpadding=3 cellspacing=0 border=0>";
echo"<tr>";
echo"<td bgcolor=#a6a7d9><font color=#FFFFFF> <b>欢迎来到险情文章管理程式 / 上传图片</b></font>";
echo"</td>";
echo"</tr>";
echo"</table><br>";
echo("
        <FORM ENCTYPE=\"multipart/form-data\" NAME=\"upload\" ACTION=\"$PHP_SELF\" METHOD=\"post\">
        &nbsp<INPUT NAME=\"userfile\" TYPE=\"file\" style=border-bottom:1px;border-left:1px;border-right:1px;border-top:1px;border-style:solid;font-size:9pt;background:#ffffff;>
        <INPUT TYPE=\"submit\" VALUE=\" 上 传 \" style=\"font-family: 新细明体, 宋体, Arial; font-size: 9pt; height:20px;background-color:#f3f3f3;border:1 solid black\" onMouseOver =\"this.style.backgroundColor='#a6a7d9'\" onMouseOut =\"this.style.backgroundColor='#f3f3f3'\"></FORM><center>");


$tmp_name = $HTTP_POST_FILES["userfile"]["tmp_name"];

if(!empty($tmp_name))
{
        $newfile_type = $HTTP_POST_FILES["userfile"]["type"];
         $newfile_size = $HTTP_POST_FILES["userfile"]["size"];
        $newfile_name = $HTTP_POST_FILES["userfile"]["name"];
        $MAX_FILE_SIZE = 100000;

        $newname = explode(".", $newfile_name);
        $welke = $newname[0];


        if (($newfile_type == "image/pjpeg")OR($newfile_type == "image/gif")OR($newfile_type == "image/bmp"))
        {
                if (($newfile_size) <= ($MAX_FILE_SIZE))
                {
                        if (file_exists($tmp_name))
                        {

                               if (!file_exists("../images/upimage/$newfile_name")){
                                $path = $HTTP_SERVER_VARS["DOCUMENT_ROOT"];
                                $new_tmp_name = tempnam("$path/temp/", "upload");

                                move_uploaded_file($tmp_name, $new_tmp_name);
                                $tmp_name = $new_tmp_name;
                                if ($newfile_type == "image/pjpeg")
                                        $ext = ".jpg";

                                if ($newfile_type == "image/gif")
                                        $ext = ".gif";

                                $newname=strtolower($welke.$ext);
                                copy($tmp_name, "../images/upimage/$newname");
                                chmod("../images/upimage/$newname", 0755);

                                list($x, $y)=GetImageSize ("../images/upimage/$newname");
                                echo "<p class='extrapadding'>你所上传的图片已经成功上传: <b>" . $newname. "</b></p>";
                                echo "<script>\n";
                                echo "if (window.opener) { window.opener.form1.f_image.value='xqart/upload/".$newname."'; \n";
                                echo "window.opener.form1.f_width.value='".$x."'; \n";
                                echo "window.opener.form1.f_height.value='".$y."'; }\n";
                                echo "</script>\n";


                                unlink ($tmp_name);
                                }
                                else $uploadstat = "- 错误: 上传图片已经存在";


                        }
                        else
                                $uploadstat = "- 错误: 上传图片已经存在";
                }
                else
                        $uploadstat = "- 错误: 上传图片太大";
        }
        else
                $uploadstat = "- 错误: 上传文件必须是图片存储格式..";
}
else
        $uploadstat = "- 请您选择要上传的图片.";

echo("<b>$uploadstat</b>");
echo"<br>";
echo"</center><table width=100% cellpadding=3 cellspacing=0 border=0>";
echo"<tr>";
echo"<td bgcolor=#a6a7d9><font color=#FFFFFF> </font><font color=#FFFFFF><b>程式制作：险情  版权所有：上海财经大学99国际工商管理</b></font> </td> ";
echo"</tr>";
echo"</table>";
echo"</body>";
echo"<script>";
echo"</script>";
echo"</html> ";
echo("</BODY></HTML>");
 ?>