public function delete_by_icoid($icoid, $force = false) { //删除图标 global $_G; $icoid = intval($icoid); $data = self::fetch_by_icoid($icoid); if (!$force && !perm_check::checkperm('delete', $data)) { return array('error' => lang('message', 'no_privilege')); } //删除sourcedata self::deletesourcedata($data, $force); //空间计算 if ($data['size']) { SpaceSize(-$data['size'], $data['gid'], 1); } if (self::delete($icoid)) { delete_icoid_from_container($icoid, $data['pfid']); return $data; } else { return false; } }
public function FileCopy($icoid, $pfid, $first = true) { global $_G, $_GET; if (!($tfolder = DB::fetch_first("select * from " . DB::table('folder') . " where fid='{$pfid}'"))) { return array('error' => ' 目标位置不存在'); } if ($icoarr = C::t('icos')->fetch($icoid)) { //判断当前文件有没有拷贝权限; if (!perm_check::checkperm('copy', $icoarr)) { return array('error' => ' 没有权限'); } //判断目录目录有无当前类型的添加权限 if (in_array($icoarr['type'], array('folder', 'link', 'video', 'dzzdoc', 'shortcut'))) { if (!perm_check::checkperm_Container($pfid, $icoarr['type'])) { return array('error' => ' 没有权限'); } } elseif (!perm_check::checkperm_Container($pfid, 'newtype')) { return array('error' => ' 没有权限'); } $success = 0; if ($gid = DB::result_first("select gid from " . DB::table('folder') . " where fid='{$pfid}'")) { //判断空间大小 if (!SpaceSize($icoarr['size'], $gid)) { return array('error' => lang('message', 'inadequate_capacity_space')); } } //判断重复 if ($ricoid = self::getRepeatIDByName($icoarr['name'], $pfid, $icoarr['type'] == 'folder' ? true : false)) { //如果目录下有同名文件 if ($icoarr['type'] == 'folder') { $icoarr['name'] = self::getFolderName($icoarr['name'], $pfid); } else { $icoarr['name'] = self::getFileName($icoarr['name'], $pfid); } } switch ($icoarr['type']) { case 'folder': if ($folder = C::t('folder')->fetch($icoarr['oid'])) { $oldfid = $folder['fid']; $oldfolder = $folder; unset($folder['fid']); $folder['uid'] = $_G['uid']; $folder['username'] = $_G['username']; $folder['pfid'] = $pfid; $folder['fname'] = $icoarr['name']; $folder['gid'] = $gid; //$folder['perm']=0; if ($folder['fid'] = C::t("folder")->insert($folder, 1)) { foreach (C::t('icos')->fetch_all_by_pfid($oldfid) as $value) { try { self::FileCopy($value['icoid'], $folder['fid'], false); } catch (Exception $e) { } } $return['folderarr'] = $folder; $icoarr['oid'] = $folder['fid']; $success = 1; } } else { return array('error', lang('message', 'folder_not_exist')); } break; case 'user': $success = 1; break; case 'shortcut': $shortcut = C::t('source_shortcut')->fetch($icoarr['oid']); unset($shortcut['cutid']); if ($cutid = C::t('source_shortcut')->insert($shortcut, 1)) { $icoarr['oid'] = $cutid; $success = 1; } break; case 'app': $success = 1; break; case 'image': if ($image = C::t('source_image')->fetch($icoarr['oid'])) { $opicid = $image['picid']; unset($image['picid']); $image['title'] = $icoarr['name']; $image['uid'] = $_G['uid']; $image['gid'] = $gid; $image['username'] = $_G['username']; if ($image['picid'] = DB::insert('source_image', $image, 1)) { $image['aid'] && C::t('attachment')->addcopy_by_aid($image['aid']); $icoarr['oid'] = $image['picid']; $success = 1; } } else { return array('error', lang('message', 'image_not_exist')); } break; case 'video': if ($video = C::t('source_video')->fetch($icoarr['oid'])) { $video['uid'] = $_G['uid']; $video['gid'] = $gid; unset($video['vid']); $video['title'] = $icoarr['name']; $video['username'] = $_G['username']; if ($video['vid'] = DB::insert('source_video', $video, 1)) { if ($video['cid']) { DB::query("update " . DB::table('cai_video') . " set copys=copys+1 where cid='{$video[cid]}'"); } $icoarr['oid'] = $video['vid']; $success = 1; } } else { return array('error', lang('message', 'video_not_exist')); } break; case 'music': if ($music = C::t('source_music')->fetch($icoarr['oid'])) { unset($music['mid']); $music['uid'] = $_G['uid']; $music['gid'] = $gid; $music['title'] = $icoarr['name']; $music['username'] = $_G['username']; if ($music['mid'] = DB::insert('source_music', $music, 1)) { if ($music['cid']) { DB::query("update " . DB::table('cai_music') . " set copys=copys+1 where cid='{$music[cid]}'"); } $icoarr['oid'] = $music['mid']; $success = 1; } } else { return array('error', lang('message', 'video_not_exist')); } break; case 'link': if ($link = C::t('source_link')->fetch($icoarr['oid'])) { $olink = $link['lid']; unset($link['lid']); $link['uid'] = $_G['uid']; $link['username'] = $_G['username']; $link['title'] = $icoarr['name']; $link['gid'] = $gid; if ($link['lid'] = DB::insert('source_link', $link, 1)) { if ($link['cid']) { DB::query("update " . DB::table('cai_link') . " set copys=copys+1 where cid='{$link[cid]}'"); } if ($link['did']) { C::t('icon')->update_copys_by_did($link['did']); } $icoarr['oid'] = $link['lid']; $success = 1; } } else { return array('error', lang('message', 'link_not_exist')); } break; case 'attach': if ($attach1 = C::t('source_attach')->fetch($icoarr['oid'])) { $oqid = $attach1['qid']; unset($attach1['qid']); $attach1['uid'] = $_G['uid']; $attach['title'] = $icoarr['name']; $attach1['username'] = $_G['username']; $attach1['gid'] = $gid; if ($attach1['qid'] = DB::insert('source_attach', $attach1, 1)) { $attach1['aid'] && C::t('attachment')->addcopy_by_aid($attach1['aid']); $icoarr['oid'] = $attach1['qid']; $success = 1; } } else { return array('error', lang('message', 'attach_not_exist')); } break; case 'document': if ($document = C::t('source_document')->fetch($icoarr['oid'])) { $odid = $document['did']; unset($document['did']); $document['uid'] = $_G['uid']; $document['title'] = $icoarr['name']; $document['username'] = $_G['username']; $document['gid'] = $gid; if ($document['did'] = DB::insert('source_document', $document, 1)) { $document['aid'] && C::t('attachment')->addcopy_by_aid($document['aid']); $icoarr['oid'] = $document['did']; $success = 1; } } else { return array('error', lang('message', 'document_not_exist')); } break; case 'dzzdoc': if ($did = C::t('document')->copy_by_did($icoarr['oid'])) { $icoarr['oid'] = $did; $success = 1; } else { return array('error', '创建Dzz文档失败'); } break; default: $success = 1; } if ($success) { unset($icoarr['icoid']); $icoarr['gid'] = $gid; $icoarr['uid'] = $_G['uid']; $icoarr['username'] = $_G['username']; $icoarr['pfid'] = $pfid; if ($icoarr['icoid'] = DB::insert('icos', $icoarr, 1)) { if ($icoarr['size'] > 0) { SpaceSize($icoarr['size'], $gid, 1); } if (!$first) { addtoconfig($icoarr); } else { $return['icoarr'] = C::t('icos')->fetch_by_icoid($icoarr['icoid']); return $return; } } else { return array('error' => '此类文件不允许复制'); } } } return array('error' => 'copy error'); }