<?php
if(IN_IQQOL){
if($_COOKIE['iQQol_Administrator']!=IQQOL_SPPASS)
{
    $style->assign("state",'COOKIE失效');
    $style->display('admin/index.html');exit();
}
    $link_search=mysql_query("SELECT * FROM ".$table."friends_links",$con);
        if($_GET['act']=='delete'){
            $info=mysql_fetch_array($link_search);
            $i=mysql_query("DELETE FROM {$table}friends_links
WHERE name='{$_GET['name']}'",$con);echo mysql_error();
            if($i){
                $tem_url_return='admin.php?action=misc&operation=link';
                $state=$info[username].' 删除成功';
                $style->display('admin/status.html');
                }
            else{
                $tem_url_return='admin.php?action=misc&operation=link';
                $state=$info[username].' 删除失败';
                $style->display('admin/status.html');
            }
        }

        if($_GET['act']=='insert'){
            $info=mysql_fetch_array($link_search);
            if($_GET['edit']=='yes'){
                $i=mysql_query("INSERT INTO {$table}friends_links (`name`,`note`,`url`) VALUES ('{$_POST['name']}','{$_POST['note']}','{$_POST['url']}')",$con);echo mysql_error();
                if($i){
                    $tem_url_return='admin.php?action=misc&operation=link';
                    $state=$info[username].' 添加成功';
                    $style->display('admin/status.html');
                    }
                else{
                    $tem_url_return='admin.php?action=misc&operation=link';
                    $state=$info[username].' 修改失败,请检查链接是否已经存在！';
                    $style->display('admin/status.html');
                }
            }
            else{
                $style->display('admin/misc/linkinsert.html');
            }
        }

        if($_GET['act']=='edit'){
            $info=mysql_fetch_array($link_search);
            $i=mysql_query("SELECT * FROM {$table}friends_links
WHERE name='{$_GET['name']}'",$con);echo mysql_error();
            if($_GET['edit']=='yes'){
                $i=mysql_query("UPDATE ".IQQOL_SQLTABLE."friends_links
 SET `name`='{$_POST['name']}' 
 WHERE name='{$_GET['name']}'",$con);
                $i.=mysql_query("UPDATE ".IQQOL_SQLTABLE."friends_links
 SET `note`='{$_POST['note']}' 
 WHERE name='{$_GET['name']}'",$con);
                $i.=mysql_query("UPDATE ".IQQOL_SQLTABLE."friends_links
 SET `url`='{$_POST['url']}' 
 WHERE name='{$_GET['name']}'",$con);
                echo mysql_error();
                if($i){
                    $tem_url_return='admin.php?action=misc&operation=link';
                    $state=$info[username].' 修改成功';
                    $style->display('admin/status.html');
                    }
                else{
                    $tem_url_return='admin.php?action=misc&operation=link';
                    $state=$info[username].' 修改失败';
                    $style->display('admin/status.html');
                }
            }
            else{
                $style->display('admin/misc/linkedit.html');
            }
        }
        if(!isset($_GET['act'])){
                $style->display('admin/misc/linklist.html');
            }
}
?>