<?
include ("xqfunc.php");
include ("admin_log.php");;
/////////////////////上传数组图片/////////////////////////////////////////////
if ($model=="upfile" and $act=="add")   {
if($phpfile != "none") {
       $phpfile_count=count($phpfile);
       for ($i=0;$i<=$phpfile_count-1;$i++){
         if( $phpfile_size[$i]!=0 )
         $phpfile_s[]=$phpfile[$i];
                                           }
       $phpfile_count_s=count($phpfile_s);
       if ($phpfile_count_s==0){
        $msg="您还没有选择要上传的图片";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
                              }

       for ($i=0;$i<=$phpfile_count_s-1;$i++)   {
        if( !$phpfile_size[$i] ) {
        $msg="您上传的图片 $phpfile_name[$i] 不存在或大小为零";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
        }

        if(file_exists("../images/upimage/$phpfile_name[$i]")) {
        $msg="您上传的图片 $phpfile_name[$i] 已经存在，请改名";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
        }
        $full_filename[$i] = split("\.", $phpfile_name[$i]);
        $file_extention[$i] = $full_filename[sizeof($phpfile_name[$i])];

        if(!copy($phpfile[$i], "../images/upimage/$phpfile_name[$i]")) {
            $msg="您上传的图片 $phpfile_name[$i] 失败，未知原因";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
        }

        if(!unlink("$phpfile[$i]")) {
            $msg="您上传的图片 $phpfile_name[$i] 没有从临时文件中删除，请手动删除";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
        }
}

       $msg="您成功上传了 $phpfile_count_s 张图片";
        $turn_page="managepic.php";
        error_1($msg,$turn_page);
        exit;
}
}
//////////////////删除图片/////////////////////////////////////////////////////
if ($model=="upfile" and $act=="del")   {
if (!file_exists("../images/upimage/$file")) {
    $msg="您所要删除的图片不存在";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
}

if (is_file("../images/upimage/$file")) {
        unlink("../images/upimage/$file");

    $msg="您成功删除图片";
        $turn_page="managepic.php";
        error_1($msg,$turn_page);
        exit;
   }
   }
//////////////////重命名图片/////////////////////////////////////////////
if ($model=="upfile" and $act=="rename")   {
        echo "<html><head><STYLE><!--A:link {text-decoration:none}A:visited {text-decoration:none}A:hover {  text-decoration:underline;  color:brown;}p,br,body,td {color:black; font-size:9pt; line-height:140%;}--></STYLE></head><body BGCOLOR='EFEFEF'><br><br><br><br><br><br><br><br><br><br>";
echo "<table width=\"60%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" bgcolor=\"BBBBBB\" align=\"center\"><tr><td>";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr bgcolor=\"#a6a7d9\"><td width=\"100%\" valign=\"middle\"><font color=\"#FFFFFF\">修改图片<font color=red>$file</font>名字</font></td></tr>";
echo "<form action=\"managepic1.php\" method=\"post\">";
echo "<tr bgcolor=\"#FFFFFF\">";
echo "<td align=\"middle\"> &nbsp;";
echo "<input type=\"text\"  name=\"newfile\" maxlength=\"10\" value=\"\" size=\"10\" style=\"background-color:#ffffff; color:#8888AA; border: 1 double #B4B4B4\" onMouseOver = \"this.style.backgroundColor = '#E5F0FF'\" onMouseOut = \"this.style.backgroundColor = ''\">";
echo " <input type=\"submit\" value=\"提 交\" style=\"color: #000000; background-color: #EEEEF8; border-style: solid; border-width: 0\" onMouseOver =\"this.style.backgroundColor='#a6a7d9'\" onMouseOut =\"this.style.backgroundColor='EEEEF8'\" name=\"submit\">";
echo "<input type=\"hidden\" name=\"act\" value=\"rename_act\">";
echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
echo "<input type=\"hidden\" name=\"p\" value=\"$p\">";
echo "<input type=\"hidden\" name=\"model\" value=\"upfile\">";
echo "</td></tr></form></table></td> </tr></table>";
exit;
}
////////////////////////////////////////////////////////////////////////////
if ($model=="upfile" and $act=="rename_act")   {
if (!file_exists("../images/upimage/$file")) {
    $msg="您所要修改的图片不存在";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
}

if (is_file("../images/upimage/$file")) {
        rename("../images/upimage/$file","../images/upimage/$newfile");

    $msg="您成功修改图片名字";
        $turn_page="managepic.php";
        error_1($msg,$turn_page);
        exit;
   }
   }
///////////////图片属性修改/////////////////////////////////////////////////
if ($model=="upfile" and $act=="reatt")   {
        echo "<html><head><STYLE><!--A:link {text-decoration:none}A:visited {text-decoration:none}A:hover {  text-decoration:underline;  color:brown;}p,br,body,td {color:black; font-size:9pt; line-height:140%;}--></STYLE></head><body BGCOLOR='EFEFEF'><br><br><br><br><br><br><br><br><br><br>";
echo "<table width=\"60%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" bgcolor=\"BBBBBB\" align=\"center\"><tr><td>";
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr bgcolor=\"#a6a7d9\"><td width=\"100%\" valign=\"middle\"><font color=\"#FFFFFF\">修改图片<font color=red>$file</font>属性</font></td></tr>";
echo "<form action=\"managepic1.php\" method=\"post\">";
echo "<tr bgcolor=\"#FFFFFF\">";
echo "<td align=\"middle\"> &nbsp;";
echo "<input type=\"text\"  name=\"newatt\" maxlength=\"10\" value=\"\" size=\"10\" style=\"background-color:#ffffff; color:#8888AA; border: 1 double #B4B4B4\" onMouseOver = \"this.style.backgroundColor = '#E5F0FF'\" onMouseOut = \"this.style.backgroundColor = ''\">";
echo " <input type=\"submit\" value=\"提 交\" style=\"color: #000000; background-color: #EEEEF8; border-style: solid; border-width: 0\" onMouseOver =\"this.style.backgroundColor='#a6a7d9'\" onMouseOut =\"this.style.backgroundColor='EEEEF8'\" name=\"submit\">";
echo "<input type=\"hidden\" name=\"act\" value=\"reatt_act\">";
echo "<input type=\"hidden\" name=\"file\" value=\"$file\">";
echo "<input type=\"hidden\" name=\"p\" value=\"$p\">";
echo "<input type=\"hidden\" name=\"model\" value=\"upfile\">";
echo "</td></tr></form></table></td> </tr></table>";
exit;
}
/////////////////////////////////////////////////////////////////////////////
if ($model=="upfile" and $act=="reatt_act")   {
if (!file_exists("../images/upimage/$file")) {
    $msg="您所修改的图片不存在";
        $turn_page="managepic.php";
        error_0($msg,$turn_page);
        exit;
}
$newatt="0".$newatt;
if (is_file("../images/upimage/$file")) {
        chmod("../images/upimage/$file",$newatt);

    $msg="您成功修改图片属性";
        $turn_page="managepic.php";
        error_1($msg,$turn_page);
        exit;
   }
   }
?>
