首頁仿360桌面 添加、刪除桌面圖標

首頁仿360桌面  添加、刪除桌面圖標
user.php
else if ($action == 'getusericon')
{
     $sql = "select b.id,b.title,b.linkurl,b.icon from {$tablepre}userdesktop a inner join {$tablepre}subsystem b on a.systemid=b.id where a.uid='".$SESSION['uid']."'";
     $result = $db->fetchAssocArrBySql($sql);
     $ret = array();
     $i = 0;
     foreach($result as $key => $value)
     {
          $ret[$i]['id'] = 'subsystem_'.$value['id'];
          $ret[$i]['title'] = $value['title'];
          $ret[$i]['img'] = $value['icon'];
          $ret[$i]['href'] = $value['linkurl'];
          $i++;
     }
     $ret[$i]['id'] = 'add_new';
     $ret[$i]['title'] = '添加';
     $ret[$i]['img'] = 'add.png';
     $ret[$i]['href'] = '';
     $ret[$i]['url'] = '/user.php?action=addsubsystem';
     echo json_encode($ret);
     exit;
}
else if($action == 'addsubsystem')
{    
     $sql = "select systemid from {$tablepre}userdesktop where uid='".$SESSION['uid']."'";
     $havesystemids = $db->fetchColBySql($sql);
    
     $sql = "select * from {$tablepre}subsystem order by id asc";
     $result = $db->fetchAssocArrBySql($sql);
     $subsystem = '';
     foreach($result as $key => $value)
     {    
          $id = $value['id'];
          $title = $value['title'];
          $icon = "/data/images/user/icon/".$value['icon'];
          $checked = "";         
          if(in_array($id,$havesystemids))
          {
               $checked = " checked";
          }
          eval ("\$subsystem .= \"".$tpl->get("subsystem_scripts", $templates, $language)."\";");
     }
     eval ("\$addsubsystem = \"".$tpl->get("user_subsystems", $templates, $language)."\";");
     echo $addsubsystem;
     exit;
}
else if($action == 'addicon')
{    
     $sql = "select systemid from {$tablepre}userdesktop where uid='".$SESSION['uid']."'";
     $haveids = $db->fetchColBySql($sql);
    
     $uid =  $SESSION['uid'];
         
     foreach($arr['subsystem'] as $k => $v)
     {    
          $id = $v;
          if(in_array($id,$haveids))
          {
               continue;
          }
          else
          {
               $sql = "INSERT into {$tablepre}userdesktop(uid,systemid) value('".$uid."','".$id."')";
               $result = $db->query($sql);
          }
              
     }
     $deleteids = array();
     foreach($haveids as $k => $v)
     {
          if (!in_array($v,$arr['subsystem']))
          {
               $deleteids[] = $v;
          }
     }    
     if ($deleteids)
     {
          $sql = "delete from {$tablepre}userdesktop where uid='".$uid."' and systemid in (".implode(",",$deleteids).")";
          $db->query($sql);
     }
     exit;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章