archives_do.php 36.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
<?php
/**
 * 文档处理
 *
 * @version        $Id: archives_do.php 1 8:26 2010年7月12日Z tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
require_once(dirname(__FILE__).'/config.php');
require_once(DEDEADMIN.'/inc/inc_batchup.php');
require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
require_once(DEDEINC.'/typelink.class.php');
require_once(DEDEINC.'/arc.archives.class.php');
$ENV_GOBACK_URL = (empty($_COOKIE['ENV_GOBACK_URL']) ? 'content_list.php' : $_COOKIE['ENV_GOBACK_URL']);

if(empty($dopost))
{
    ShowMsg('对不起,你没指定运行参数!','-1');
    exit();
}
$aid = isset($aid) ? preg_replace("#[^0-9]#", '', $aid) : '';

/*--------------------------
//编辑文档
function editArchives(){ }
---------------------------*/
if($dopost=='editArchives')
{
    $query = "SELECT arc.id,arc.typeid,ch.maintable,ch.editcon
           FROM `#@__arctiny` arc
           LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
           LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
          WHERE arc.id='$aid' ";
    $row = $dsql->GetOne($query);
    $gurl = $row['editcon'];
    if($gurl=='') $gurl='article_edit.php';
    header("location:{$gurl}?aid=$aid");
    exit();
}
/*--------------------------
//浏览文档
function viewArchives(){ }
---------------------------*/
else if($dopost=="viewArchives")
{
    $aid = preg_replace("#[^0-9]#", '', $aid);

    //获取主表信息
    $query = "SELECT arc.*,ch.maintable,ch.addtable,ch.issystem,ch.editcon,
              tp.typedir,tp.typename,tp.corank,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.sitepath,tp.siteurl
           FROM `#@__arctiny` arc
           LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
           LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
           WHERE arc.id='$aid' ";
    $trow = $dsql->GetOne($query);
    $trow['maintable'] = ( trim($trow['maintable'])=='' ? '#@__archives' : trim($trow['maintable']) );
    if($trow['issystem'] != -1)
    {
        $arcQuery = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.sitepath,tp.siteurl
                   FROM `{$trow['maintable']}` arc LEFT JOIN `#@__arctype` tp on arc.typeid=tp.id
                   LEFT JOIN `#@__channeltype` ch on ch.id=arc.channel WHERE arc.id='$aid' ";
        $arcRow = $dsql->GetOne($arcQuery);
		PutCookie('DedeUserID',$arcRow['mid'],1800);
		PutCookie('DedeLoginTime',time(),1800);
        if($arcRow['ismake']==-1 || $arcRow['corank']!=0 || $arcRow['arcrank']!=0 || ($arcRow['typeid']==0 && $arcRow['channel']!=-1) || $arcRow['money']>0)
        {
            echo "<script language='javascript'>location.href='{$cfg_phpurl}/view.php?aid={$aid}';</script>";
            exit();
        }
    }
    else
    {
        $arcRow['id'] = $aid;
        $arcRow['typeid'] = $trow['typeid'];
        $arcRow['senddate'] = $trow['senddate'];
        $arcRow['title'] = '';
        $arcRow['ismake'] = 1;
        $arcRow['arcrank'] = $trow['corank'];
        $arcRow['namerule'] = $trow['namerule'];
        $arcRow['typedir'] = $trow['typedir'];
        $arcRow['money'] = 0;
        $arcRow['filename'] = '';
        $arcRow['moresite'] = $trow['moresite'];
        $arcRow['siteurl'] = $trow['siteurl'];
        $arcRow['sitepath'] = $trow['sitepath'];
    }
    $arcurl  = GetFileUrl($arcRow['id'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],$arcRow['ismake'],$arcRow['arcrank'],
    $arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename'],$arcRow['moresite'],$arcRow['siteurl'],$arcRow['sitepath']);
    $arcfile = GetFileUrl($arcRow['id'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],
    $arcRow['ismake'],$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename']);
    if(preg_match("#^http:#", $arcfile))
    {
        $arcfile = preg_replace("#^http:\/\/([^\/]*)\/#i", '/', $arcfile);
    }
    $truefile = GetTruePath().$arcfile;
    if(!file_exists($truefile))
    {
        MakeArt($aid,TRUE);
    }
    echo "<script language='javascript'>location.href='$arcurl"."?".time()."';</script>";
    exit();
}
/*--------------------------
//异步上传缩略图
function uploadLitpic(){ }
---------------------------*/
else if($dopost=="uploadLitpic")
{
    $upfile = AdminUpload('litpic', 'imagelit', 0, false );
    if($upfile=='-1')
    {
        $msg = "<script language='javascript'>
                parent.document.getElementById('uploadwait').style.display = 'none';
                alert('你没指定要上传的文件或文件大小超过限制!');
            </script>";
    }
    else if($upfile=='-2')
    {
        $msg = "<script language='javascript'>
                parent.document.getElementById('uploadwait').style.display = 'none';
                alert('上传文件失败,请检查原因!');
            </script>";
    }
    else if($upfile=='0')
    {
        $msg = "<script language='javascript'>
                parent.document.getElementById('uploadwait').style.display = 'none';
                alert('文件类型不正确!');
            </script>";
    }
    else
    {
         if(!empty($cfg_uplitpic_cut) && $cfg_uplitpic_cut=='N')
         {
                 $msg = "<script language='javascript'>
                    parent.document.getElementById('uploadwait').style.display = 'none';
                    parent.document.getElementById('picname').value = '{$upfile}';
                    if(parent.document.getElementById('divpicview'))
                    {
                        parent.document.getElementById('divpicview').style.width = '150px';
                        parent.document.getElementById('divpicview').innerHTML = \"<img src='{$upfile}?n' width='150' />\";
                    }
                </script>";
         }
         else
         {
               $msg = "<script language='javascript'>
                    parent.document.getElementById('uploadwait').style.display = 'none';
                    window.open('imagecut.php?f=picname&isupload=yes&file={$upfile}', 'popUpImagesWin', 'scrollbars=yes,resizable=yes,statebar=no,width=800,height=600,left=150, top=50');
                </script>";
         }
    }
    echo $msg;
    exit();
}
/*--------------------------
//推荐文档
function commendArchives(){ }
---------------------------*/
else if($dopost=="commendArchives")
{
    CheckPurview('a_Commend,sys_ArcBatch');
    if( !empty($aid) && empty($qstr) )
    {
        $qstr = $aid;
    }
    if($qstr=='')
    {
        ShowMsg("参数无效!",$ENV_GOBACK_URL);
        exit();
    }
    $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
    $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
           LEFT JOIN `#@__arctype` tp on tp.id=arc.typeid
           LEFT JOIN `#@__channeltype` ch on ch.id=tp.channeltype
          WHERE arc.id in($arcids) ";
    $dsql->SetQuery($query);
    $dsql->Execute();
    while($row = $dsql->GetArray())
    {
        $aid = $row['id'];
        if($row['issystem']!=-1)
        {
            $maintable = ( trim($row['maintable'])=='' ? '#@__archives' : trim($row['maintable']) );
            $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
            $flag = ($arr['flag']=='' ? 'c' : $arr['flag'].',c');
            $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
        }
        else
        {
            $maintable = trim($row['addtable']);
            $arr = $dsql->GetOne("SELECT flag From `{$maintable}` where aid='$aid' ");
            $flag = ($arr['flag']=='' ? 'c' : $arr['flag'].',c');
            $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
        }
    }
    ShowMsg("成功把所选的文档设为推荐!",$ENV_GOBACK_URL);
    exit();
}

/*--------------------------
//生成HTML
function makeArchives();
---------------------------*/
else if($dopost=="makeArchives")
{
    CheckPurview('sys_MakeHtml,sys_ArcBatch');
    if( !empty($aid) && empty($qstr) ) $qstr = $aid;
    
    if($qstr=='')
    {
        ShowMsg('参数无效!',$ENV_GOBACK_URL);
        exit();
    }
    require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
    $qstrs = explode('`',$qstr);
    $i = 0;
    foreach($qstrs as $aid)
    {
        $i++;
        $pageurl = MakeArt($aid,false);
    }
    ShowMsg("成功更新指定 $i 个文件...",$ENV_GOBACK_URL);
    exit();
}
/*--------------------------
//审核文档
function checkArchives() {   }
---------------------------*/
else if($dopost=="checkArchives")
{
    CheckPurview('a_Check,a_AccCheck,sys_ArcBatch');
    require_once(DEDEADMIN."/inc/inc_archives_functions.php");
    if( !empty($aid) && empty($qstr) ) $qstr = $aid;
    if($qstr=='')
    {
        ShowMsg("参数无效!",$ENV_GOBACK_URL);
        exit();
    }
    $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
    $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
               LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
            LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
            WHERE arc.id in($arcids) ";
    $dsql->SetQuery($query);
    $dsql->Execute('ckall');
    while($row = $dsql->GetArray('ckall'))
    {
        $aid = $row['id'];
        $maintable = ( trim($row['maintable'])=='' ? '#@__archives' : trim($row['maintable']) );
        $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET arcrank='0' WHERE id='$aid' ");
        if($row['issystem']==-1)
        {
            $dsql->ExecuteNoneQuery("UPDATE `".trim($row['addtable'])."` SET arcrank='0' WHERE aid='$aid' ");
        }
        else
        {
            $dsql->ExecuteNoneQuery("UPDATE `$maintable` SET arcrank='0', dutyadmin='".$cuserLogin->getUserID()."' WHERE id='$aid' ");
        }
        $dsql->ExecuteNoneQuery("UPDATE `#@__taglist` SET arcrank='0' WHERE aid='$aid' "); 
        $pageurl = MakeArt($aid,false);
    }
    ShowMsg("成功审核指定的文档!",$ENV_GOBACK_URL);
    exit();
}
/*--------------------------
//删除文档
function delArchives(){ }
---------------------------*/
else if($dopost=="delArchives")
{
    CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
    require_once(DEDEINC."/oxwindow.class.php");
    if(empty($fmdo)) $fmdo = '';

    if($fmdo=='yes')
    {
        if( !empty($aid) && empty($qstr) )
        {
            $qstr = $aid;
        }
        if($qstr=='')
        {
            ShowMsg("参数无效!",$ENV_GOBACK_URL);
            exit();
        }
        $qstrs = explode("`",$qstr);
        $okaids = Array();

        foreach($qstrs as $aid)
        {
            if(!isset($okaids[$aid]))
            {
                DelArc($aid);
            }
            else
            {
                $okaids[$aid] = 1;
            }
        }
        ShowMsg("成功删除指定的文档!",$ENV_GOBACK_URL);
        exit();
    }

    else
    {
        $wintitle = "文档管理-删除文档";
        $wecome_info = "<a href='".$ENV_GOBACK_URL."'>文档管理</a>::删除文档";
        $win = new OxWindow();
        $win->Init("archives_do.php","js/blank.js","POST");
        $win->AddHidden("fmdo","yes");
        $win->AddHidden("dopost",$dopost);
        $win->AddHidden("qstr",$qstr);
        $win->AddHidden("aid",$aid);
        $win->AddTitle("你确实要删除“ $qstr$aid ”这些文档?");
        $winform = $win->GetWindow("ok");
        $win->Display();
    }
}
/*-----------------------------
function moveArchives(){ }
------------------------------*/
else if($dopost=='moveArchives')
{
    CheckPurview('sys_ArcBatch');
    if(empty($totype))
    {
        require_once(DEDEINC.'/typelink.class.php');
        if( !empty($aid) && empty($qstr) ) $qstr = $aid;
 
        AjaxHead();
        $channelid = empty($channelid) ? 0 : $channelid;
        $tl = new TypeLink($aid);
        $typeOptions = $tl->GetOptionArray(0, $admin_catalogs, $channelid);
        $typeOptions = "<select name='totype' style='width:90%'>
        <option value='0'>请选择移动到的位置...</option>\r\n
        $typeOptions
        </select>";
        
        //输出AJAX可移动窗体
        $divname = 'moveArchives';
        echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">\r\n";
        echo "    <div class='titLeft'>移动文档</div>\r\n";
        echo "    <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
        echo "</div>\r\n";
        echo "<form name='quickeditform' action='archives_do.php' method='post'>\r\n";
        echo "<input type='hidden' name='dopost' value='{$dopost}' />\r\n";
        echo "<input type='hidden' name='qstr' value='{$qstr}' />\r\n";
        echo "<table width='100%' style='margin-top:6px;z-index:9000;'>\r\n";
?>
<tr height='28'>
    <td width="80" class='bline'>&nbsp;目标栏目:</td>
    <td class='bline'>
    <?php echo $typeOptions; ?>
    </td>
</tr>
<tr height='32'>
    <td width="80" class='bline'>&nbsp;文档ID:</td>
    <td class='bline'>
        <input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:310px;overflow:hidden;' />
        <br />
        移动到的目标栏目必须和选定的文档频道类型一致,否则程序会自动勿略不符合的文档。
    </td>
</tr>
<tr height='32'>
    <td colspan='2' align='center' style='padding-top:12px'>
        <input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" class="np" border="0" style="cursor:pointer" />
        &nbsp;&nbsp;
        <img src="images/button_back.gif" width="60" height="22" border="0" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' style="cursor:pointer" />
    </td>
</td>
</tr>
</table>
</form>
<?php
    //AJAX窗体结束
    }
    else
    {
        $totype = preg_replace("#[^0-9]#", '', $totype);
        $typeInfos = $dsql->GetOne("SELECT tp.channeltype,tp.ispart,tp.channeltype,ch.maintable,ch.addtable,ch.issystem FROM `#@__arctype` tp LEFT JOIN `#@__channeltype` ch on ch.id=tp.channeltype WHERE tp.id='$totype' ");
        $idtype = "id";
        if(!is_array($typeInfos))
        {
            ShowMsg('参数错误!','-1');
            exit();
        }
        if($typeInfos['ispart']!=0)
        {
            ShowMsg('文档保存的栏目必须为最终列表栏目!','-1');
            exit();
        }
        if(empty($typeInfos['addtable']))
        {
            $typeInfos['maintable'] = '#@__archives';
        }
        //增加单表模型判断
        if($typeInfos['issystem'] == -1)
        {
            $typeInfos['maintable'] = $typeInfos['addtable'];
            $idtype = "aid";
        }
        $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
        $arc = '';
        $j = 0;
        $okids = array();
        $dsql->SetQuery("SELECT {$idtype},typeid FROM `{$typeInfos['maintable']}` WHERE {$idtype} in($arcids) AND channel='{$typeInfos['channeltype']}' ");
        $dsql->Execute();
        while($row = $dsql->GetArray())
        {
            if($row['typeid']!=$totype)
            {
                $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny`  SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
                $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['maintable']}` SET typeid='$totype' WHERE id='{$row[$idtype]}' ");
                $dsql->ExecuteNoneQuery("UPDATE `{$typeInfos['addtable']}` SET typeid='$totype' WHERE aid='{$row[$idtype]}' ");
                $okids[] = $row[$idtype];
                $j++;
            }
        }
        //更新HTML
        foreach($okids as $aid)
        {
            $arc = new Archives($aid);
            $arc->MakeHtml();
        }
        ShowMsg("成功移动 $j 个文档!", $ENV_GOBACK_URL);
        exit();
    }
}
/*-----------------------------
//还原文档
function RbReturnArchives(){ }
------------------------------*/
else if($dopost=='return')
{
    CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
    require_once(DEDEINC."/oxwindow.class.php");

    if( !empty($aid) && empty($qstr) ) $qstr = $aid;

    if($qstr=='')
    {
        ShowMsg("参数无效!","recycling.php");
        exit();
    }
    $qstrs = explode("`", $qstr);
    foreach($qstrs as $aid)
    {
        $dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET arcrank='-1',ismake='0' WHERE id='$aid'");
        $dsql->ExecuteNoneQuery("UPDATE `#@__arctiny` SET `arcrank` = '-1' WHERE id = '$aid'; ");
    }
    ShowMsg("成功还原指定的文档!","recycling.php");
    exit();
}
/*-----------------------------
//清空文档
function RbClearArchives(){ }
------------------------------*/
else if($dopost=='clear')
{
    CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
    require_once(DEDEINC."/oxwindow.class.php");
    if(empty($fmdo)) $fmdo = '';
    $recycle = empty($recycle)? "" : $recycle;

    if($fmdo=='yes')
    {
        if( !empty($aid) && empty($qstr) ) $qstr = $aid;
        if($qstr=='')
        {
            ShowMsg("参数无效!","recycling.php");
            exit();
        }
        $qstrs = explode(",", $qstr);
        $okaids = Array();
        foreach($qstrs as $qstr)
        {
            if(!isset($okaids[$qstr]))
            {
                DelArc($qstr, "OK", FALSE, $recycle);
                $okaids[$qstr] = $qstr;
            }
            else
            {
                $okaids[$qstr] = 1;
            }
        }
        ShowMsg("成功删除指定的文档!","recycling.php");
        exit();
    }
    else
    {
        $dsql->SetQuery("SELECT id FROM `#@__archives` WHERE `arcrank` = '-2'");
        $dsql->Execute();
        $qstr = '';
        while($row = $dsql->GetArray())
        {
            $qstr .= $row['id'].",";
            $aid = $row['id'];
        }
        $num = $dsql->GetTotalRow();
        if(empty($num))
        {
            ShowMsg("对不起,未发现相关文档!","recycling.php");
            exit();
        }
        $wintitle = "文档管理-清空所有文档";
        $wecome_info = "<a href='recycling.php'>文档回收站</a>::清空所有文档";
        $win = new OxWindow();
        $win->Init("archives_do.php","js/blank.js","POST");
        $win->AddHidden("fmdo","yes");
        $win->AddHidden("dopost",$dopost);
        $win->AddHidden("qstr",$qstr);
        $win->AddHidden("aid",$aid);
        $win->AddHidden("recycle",$recycle);
        $win->AddTitle("本次操作将清空回收站<font color='#FF0000'>所有共 $num 篇文档</font><br>你确实要永久删除“ $qstr ”这些文档?");
        $winform = $win->GetWindow("ok");
        $win->Display();
    }
}
/*-----------------------------
//清除文档
function RbDelArchives(){ }
------------------------------*/
else if($dopost=='del')
{
    CheckPurview('a_Del,a_AccDel,a_MyDel,sys_ArcBatch');
    require_once(DEDEINC."/oxwindow.class.php");
    if(empty($fmdo)) $fmdo = '';
    $recycle = empty($recycle)? "" : $recycle;

    if($fmdo=='yes')
    {
        if( !empty($aid) && empty($qstr) ) $qstr = $aid;
        if($qstr=='')
        {
            ShowMsg("参数无效!","recycling.php");
            exit();
        }
        $qstrs = explode("`", $qstr);
        $okaids = Array();

        foreach($qstrs as $aid)
        {
            if(!isset($okaids[$aid]))
            {
                DelArc($aid,"OK","",$recycle);
            }
            else
            {
                $okaids[$aid] = 1;
            }
        }
        ShowMsg("成功删除指定的文档!","recycling.php");
        exit();
    }

    else
    {
        $wintitle = "文档管理-删除文档";
        $wecome_info = "<a href='recycling.php'>文档管理</a>::删除文档";
        $win = new OxWindow();
        $win->Init("archives_do.php","js/blank.js","POST");
        $win->AddHidden("fmdo","yes");
        $win->AddHidden("dopost",$dopost);
        $win->AddHidden("qstr",$qstr);
        $win->AddHidden("aid",$aid);
        $win->AddHidden("recycle",$recycle);
        $win->AddTitle("你确实要永久删除“ $qstr 和 $aid ”这些文档?");
        $winform = $win->GetWindow("ok");
        $win->Display();
    }
}
/*-----------------------------
//快速编辑
function quickEdit(){ }
------------------------------*/
else if($dopost=='quickEdit')
{
    require_once(DEDEADMIN."/inc/inc_catalog_options.php");
    AjaxHead();
    $query = "SELECT ch.typename as channelname,ch.addtable,ar.membername as rankname,arc.*
    FROM `#@__archives` arc
    LEFT JOIN `#@__channeltype` ch ON ch.id=arc.channel
    LEFT JOIN `#@__arcrank` ar ON ar.rank=arc.arcrank WHERE arc.id='$aid' ";
    $arcRow = $dsql->GetOne($query);
    $divname = 'quickEdit';
    echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">\r\n";
    echo "    <div class='titLeft'>快速属性编辑</div>\r\n";
    echo "    <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
    echo "</div>\r\n";
    echo "<form name='quickeditform' action='archives_do.php?dopost=quickEditSave&aid={$aid}' method='post'>\r\n";
    echo "<input type='hidden' name='addtable' value='{$arcRow['addtable']}' />\r\n";
    echo "<input type='hidden' name='oldtypeid' value='{$arcRow['typeid']}' />\r\n";
    echo "<table width='100%' style='margin-top:6px;z-index:9000;'>\r\n";
?>
<tr height='32'>
    <td width="80" class='bline'>&nbsp;所属栏目:</td>
    <td class='bline'>
        <?php
            $typeOptions = GetOptionList($arcRow['typeid'],$cuserLogin->getUserChannel(), $arcRow['channel']);
            echo "<select name='typeid' style='width:70%'>\r\n";
            if($arcRow["typeid"]=="0") echo "<option value='0' selected>请选择栏目...</option>\r\n";
            echo $typeOptions;
            echo "</select>";
        ?>
    </td>
</tr>
<tr height='28'>
    <td width="80" class='bline'>&nbsp;属 性:</td>
    <td class='bline'>
    <input type='hidden' name='oldflag' value='<?php echo $arcRow['flag']; ?>' />
    <?php
    $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
    $dsql->Execute();
    while($trow = $dsql->GetObject())
    {
        if($trow->att=='j' || $trow->att=='p') continue;
                  if(preg_match("#".$trow->att."#", $arcRow['flag']))
                  echo "<input class='np' type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' checked='checked' />{$trow->attname}.{$trow->att}";
        else
                  echo "<input class='np' type='checkbox' name='flags[]' id='flags{$trow->att}' value='{$trow->att}' />{$trow->attname}.{$trow->att}";
    }
    ?>
    </td>
</tr>
<tr height='32'>
    <td width="80" class='bline'>&nbsp;标 题:</td>
    <td class='bline'>
        <input name="title" type="text" id="title" value="<?php echo $arcRow['title']; ?>" style="width:90%" />
    </td>
</tr>
<tr height='32'>
    <td width="80" class='bline'>&nbsp;简略标题:</td>
    <td class='bline'>
        <input name="shorttitle" type="text" id="shorttitle" value="<?php echo $arcRow['shorttitle']; ?>" style="width:60%" />
    </td>
</tr>
<tr height='32'>
    <td width="80" class='bline'>&nbsp;阅读权限:</td>
    <td class='bline'>
        <select name="arcrank" id="arcrank" style="width:120px">
    <option value='<?php echo $arcRow["arcrank"]?>'>
    <?php echo $arcRow["rankname"]?>                </option>
    <?php
    $urank = $cuserLogin->getUserRank();

    $dsql->SetQuery("SELECT * FROM `#@__arcrank` WHERE adminrank<='$urank'");
    $dsql->Execute();
    while($row = $dsql->GetObject()){
        echo "     <option value='".$row->rank."'>".$row->membername."</option>\r\n";
    }
    ?>
    </select>
    需要金币:<input name="money" type="text" id="money" value="<?php echo $arcRow["money"]; ?>" style="width:80px" />
    </td>
</tr>
<tr height='32'>
    <td width="80" class='bline'>&nbsp;关键字:</td>
    <td class='bline'>
        <input name="keywords" type="text" id="keywords" value="<?php echo $arcRow['keywords']; ?>" style="width:70%" />
    </td>
</tr>
<tr height='32'>
    <td colspan='2' align='center' style='padding-top:12px'>
        <input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" class="np" border="0" style="cursor:pointer" />
        &nbsp;&nbsp;
        <img src="images/button_back.gif" width="60" height="22" border="0" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' style="cursor:pointer" />
    </td>
</td>
</tr>
</table>
</form>
<?php
//AJAX窗体结束
}
/*-----------------------------
//保存快速编辑的内容
function quickEditSave(){ }
------------------------------*/
else if($dopost=='quickEditSave')
{
    require_once(DEDEADMIN.'/inc/inc_archives_functions.php');
    //权限检测
    if(!TestPurview('a_Edit'))
    {
        if(TestPurview('a_AccEdit'))
        {
            CheckCatalog($typeid, "对不起,你没有操作栏目 {$typeid} 的文档权限!");
        }
        else
        {
            CheckArcAdmin($aid, $cuserLogin->getUserID());
        }
    }
    $title = htmlspecialchars(cn_substrR($title, $cfg_title_maxlen));
    $shorttitle = cn_substrR($shorttitle, 36);
    $keywords = trim(cn_substrR($keywords, 60));
    if(!TestPurview('a_Check,a_AccCheck,a_MyCheck')) $arcrank = -1;

    $adminid = $cuserLogin->getUserID();
    
    //属性处理
    $flag = isset($flags) ? join(',', $flags) : '';
    if(!empty($flag))
    {
        if(preg_match("#p#", $oldflag)) $flag .= ',p';
        if(preg_match("#j#", $oldflag)) $flag .= ',j';
    }
	/*
    else
    {
        $flag = $oldflag;
    }
	*/
    
    $query = "UPDATE `#@__archives` SET
    typeid = '$typeid',
    flag = '$flag',
    arcrank = '$arcrank',
    money = '$money',
    title = '$title', 
    shorttitle = '$shorttitle',
    keywords = '$keywords',
    dutyadmin = '$adminid'
    WHERE id = '$aid'; ";
    //更新主表
    $dsql->ExecuteNoneQuery($query);
    //更新微表
    $dsql->ExecuteNoneQuery(" UPDATE `#@__arctiny` SET typeid='$typeid',arcrank='$arcrank' WHERE id='$aid' ");
    //更新附加表
    if($typeid != $oldtypeid)
    {
        $addtable = trim($addtable);
        if(empty($addtable)) $addtable = '#@__addonarticle';
        else $addtable = preg_replace("#[^a-z0-9__#@-]#i", "", $addtable);
            $dsql->ExecuteNoneQuery(" UPDATE `$addtable` SET typeid='$typeid' WHERE aid='$aid' ");
      }
    //更新HTML
    $artUrl = MakeArt($aid, TRUE, TRUE);

        $backurl = !empty($_COOKIE['ENV_GOBACK_URL']) ? $_COOKIE['ENV_GOBACK_URL'] : '-1';
        ShowMsg('成功更新一篇文档的基本信息!', $backurl);
        exit();
}
/*--------------------------
分析并自动获取文档关键词
function makekw(){ }
--------------------------*/
else if($dopost=="makekw")
{
    include_once(DEDEINC.'/splitword.class.php');
    CheckPurview('a_Commend,sys_ArcBatch');
    if( !empty($aid) && empty($qstr) ) $qstr = $aid;

    if($qstr=='')
    {
        ShowMsg("参数无效!", $ENV_GOBACK_URL);
        exit();
    }
    $sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
    $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
    $query = "SELECT arc.*, addt.* From `#@__archives` arc LEFT JOIN `#@__addonarticle` addt ON addt.aid=arc.id  WHERE arc.id in($arcids) AND arc.channel=1 ";
    $dsql->SetQuery($query);
    $dsql->Execute();
    while($row = $dsql->GetArray())
    {
        //跳过已经有关键字的内容
        if(trim($row['keywords']) !='' ) continue;
        
        $aid = $row['id'];
        $keywords = '';
        $title = $row['title'];
        $description = $row['description'];
        $body = cn_substr($row['body'], 5000);
        $sp->SetSource($title, $cfg_soft_lang, $cfg_soft_lang);
        $sp->StartAnalysis();
        $titleindexs = preg_replace("/#p#|#e#/",'',$sp->GetFinallyIndex());
        $sp->SetSource(Html2Text($body), $cfg_soft_lang, $cfg_soft_lang);
        $sp->StartAnalysis();
        $allindexs = preg_replace("/#p#|#e#/",'',$sp->GetFinallyIndex());
        
        if(is_array($allindexs) && is_array($titleindexs))
        {
            foreach($titleindexs as $k => $v)
            {
                if(strlen($keywords.$k)>=60)
                {
                    break;
                }
                else
                {
                    if(strlen($k) <= 2) continue;
                    $keywords .= $k.',';
                }
            }
            foreach($allindexs as $k => $v)
            {
                if(strlen($keywords.$k)>=60)
                {
                    break;
                }
                else if(!in_array($k,$titleindexs))
                {
                    if(strlen($k) <= 2) continue;
                    $keywords .= $k.',';
                }
            }
        }

        $description = str_replace(' ', ' ', trim($description));
        $description = str_replace('[', ' ', $description);
        $description = str_replace(']', ' ', $description);
        $description = preg_replace("#[ \r\n\t]{1,}#is", ' ', $description);
        $description = str_replace('关键字', '', $description);
        $description = str_replace('关键词', '', $description);
        $description = addslashes($description);
        $dsql->ExecuteNoneQuery(" UPDATE `#@__archives` SET `keywords`='$keywords',`description`='$description'  WHERE id='{$aid}' ");
    }
    $sp = null;
    ShowMsg("成功分析指定文档的关键词!", $ENV_GOBACK_URL);
    exit();
}
/*--------------------------
//批量增加属性
function attsAdd(){ }
---------------------------*/
else if($dopost=='attsAdd')
{
    CheckPurview('a_Commend,sys_ArcBatch');
    if( !empty($aid) && empty($qstr) ) $qstr = $aid;

    if($qstr=='')
    {
        ShowMsg("参数无效!",$ENV_GOBACK_URL);
        exit();
    }
    if(empty($flagname))
    {
        ShowMsg("必须指定要添加的属性!",$ENV_GOBACK_URL);
        exit();
    }
    $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
    $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
           LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
           LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
          WHERE arc.id in($arcids) ";
    $dsql->SetQuery($query);
    $dsql->Execute();
    while($row = $dsql->GetArray())
    {
        $aid = $row['id'];
        if($row['issystem'] != -1)
        {
            $maintable = ( trim($row['maintable'])=='' ? '#@__archives' : trim($row['maintable']) );
            $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
            $flag = ($arr['flag']=='' ? $flagname : $arr['flag'].','.$flagname);
            $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE id='{$aid}' ");
        }
        else
        {
            $maintable = trim($row['addtable']);
            $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
            $flag = ($arr['flag']=='' ? $flagname : $arr['flag'].','.$flagname);
            $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE aid='{$aid}' ");
        }
    }
    ShowMsg("成功对选中文档增加指定的属性!",$ENV_GOBACK_URL);
    exit();
}
/*--------------------------
//批量删除属性
function attsDel(){ }
---------------------------*/
else if($dopost=='attsDel')
{
    CheckPurview('a_Commend,sys_ArcBatch');
    if( !empty($aid) && empty($qstr) ) $qstr = $aid;
    if($qstr=='')
    {
        ShowMsg("参数无效!", $ENV_GOBACK_URL);
        exit();
    }
    if(empty($flagname))
    {
        ShowMsg("必须指定要删除的属性!", $ENV_GOBACK_URL);
        exit();
    }
    $arcids = preg_replace("#[^0-9,]#", '', preg_replace("#`#", ',', $qstr));
    $query = "SELECT arc.id,arc.typeid,ch.issystem,ch.maintable,ch.addtable FROM `#@__arctiny` arc
           LEFT JOIN `#@__arctype` tp ON tp.id=arc.typeid
           LEFT JOIN `#@__channeltype` ch ON ch.id=tp.channeltype
          WHERE arc.id in($arcids) ";
    $dsql->SetQuery($query);
    $dsql->Execute();
    while($row = $dsql->GetArray())
    {
        $aid = $row['id'];
        if($row['issystem'] != -1)
        {
            $idname = 'id';
            $maintable = ( trim($row['maintable'])=='' ? '#@__archives' : trim($row['maintable']) );
            $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE id='$aid' ");
        }
        else
        {
            $idname = 'aid';
            $maintable = trim($row['addtable']);
            $arr = $dsql->GetOne("SELECT flag FROM `{$maintable}` WHERE aid='$aid' ");
        }
        $flag = $arr['flag'];
        if(trim($flag)=='' || !preg_match("#".$flagname."#", $flag) )
        {
            continue;
        }
        else
        {
            $flags  = explode(',', $flag);
            $okflags = array();
            foreach($flags as $f)
            {
                if($f != $flagname) $okflags[] = $f;
            }
        }
        $flag = trim(join(',', $okflags));
        $dsql->ExecuteNoneQuery(" UPDATE `{$maintable}` SET `flag`='$flag' WHERE {$idname}='{$aid}' ");
    }
    ShowMsg("成功对选中文档删除指定的属性!", $ENV_GOBACK_URL);
    exit();
}
/*--------------------------
//获得批量属性处理的AJAX窗体
function attsDlg(){ }
---------------------------*/
else if($dopost=='attsDlg')
{
    if( !empty($aid) && empty($qstr) ) $qstr = $aid;

    $dojobname = ($dojob=='attsDel' ? '批量删除属性' : '批量增加属性');
    AjaxHead();
    //输出AJAX可移动窗体
    $divname = 'attsDlg';
    echo "<div class='title' onmousemove=\"DropMoveHand('{$divname}', 225);\" onmousedown=\"DropStartHand();\" onmouseup=\"DropStopHand();\">\r\n";
    echo "    <div class='titLeft'>{$dojobname}</div>\r\n";
    echo "    <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
    echo "</div>\r\n";
    echo "<form name='quickeditform' action='archives_do.php' method='post'>\r\n";
    echo "<input type='hidden' name='dopost' value='{$dojob}' />\r\n";
    echo "<input type='hidden' name='qstr' value='{$qstr}' />\r\n";
    echo "<table width='100%' style='margin-top:6px;z-index:9000;'>\r\n";
?>
<tr height='28'>
    <td width="80" class='bline'>&nbsp;属 性:</td>
    <td class='bline'>
    <input type='hidden' name='oldflag' value='<?php echo $arcRow['flag']; ?>' />
    <?php
    $dsql->SetQuery("SELECT * FROM `#@__arcatt` ORDER BY sortid ASC");
    $dsql->Execute();
    while($trow = $dsql->GetObject())
    {
        if($trow->att=='j' || $trow->att=='p') continue;
        echo "<input class='np' type='radio' name='flagname' id='flags{$trow->att}' value='{$trow->att}' />{$trow->attname}.{$trow->att}";
    }
    ?>
    </td>
</tr>
<tr height='32'>
    <td width="80" class='bline'>&nbsp;文档ID:</td>
    <td class='bline'>
        <input type='text' name='tmpids' value="<?php echo $qstr; ?>" style='width:310px;overflow:hidden;' />
    </td>
</tr>
<tr height='32'>
    <td colspan='2' align='center' style='padding-top:12px'>
        <input name="imageField" type="image" src="images/button_ok.gif" width="60" height="22" class="np" border="0" style="cursor:pointer" />
        &nbsp;&nbsp;
        <img src="images/button_back.gif" width="60" height="22" border="0" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' style="cursor:pointer" />
    </td>
</td>
</tr>
</table>
</form>
<?php
//AJAX窗体结束
}
/*------------------------
function getCatMap() {  }
-------------------------*/
else if($dopost=='getCatMap')
{
    require_once(DEDEINC.'/typeunit.class.selector.php');
    AjaxHead();
    //输出AJAX可移动窗体
    $divname = 'getCatMap';
    echo "<div class='title' style='cursor:default;'>\r\n";
    echo "    <div class='titLeft'>栏目快速选择器</div>\r\n";
    echo "    <div class='titRight'><img src='images/ico-close.gif' style='cursor:pointer;' onclick='HideObj(\"{$divname}\");ChangeFullDiv(\"hide\");' alt='关闭' title='关闭' /></div>\r\n";
    echo "</div>\r\n";
    $tus = new TypeUnitSelector();
?>
<form name='quicksel' action='javascript:;' method='get'>
<div class='quicksel'>
    <?php $tus->ListAllType($channelid); ?>
</div>
<div align='center' class='quickselfoot'>
    <img src="images/button_ok.gif" onclick="getSelCat('<?php echo $targetid; ?>');" width="60" height="22" class="np" border="0" style="cursor:pointer" />
        &nbsp;&nbsp;
    <img src="images/button_back.gif" onclick='HideObj("<?php echo $divname; ?>");ChangeFullDiv("hide");' width="60" height="22" border="0"  style="cursor:pointer" />
</div>
</form>
<?php
//AJAX窗体结束
}
?>