function delete($ids)
 {
     $p = array('ids' => $ids);
     $rets = $this->get($p);
     if (!$rets) {
         return 0;
     }
     $ret = 1;
     foreach ($rets['list'] as $r) {
         $id = $r['id'];
         if ($r['site_url']) {
             $ftpkey = getftpkey($r['site_url']);
             ftpcmd('delete', $r['url'], '', $ftp_key);
         } else {
             jio()->DeleteFile(topic_attach($id));
         }
         $ret = $ret && DB::query("delete from " . DB::table($this->table) . " where `id`='{$id}'");
         if ($r['tid'] > 0) {
             $this->set_topic_attachid($r['tid']);
         }
     }
     return $ret;
 }
Exemple #2
0
 function DeleteAttach()
 {
     $tid = (int) $this->Get['tid'];
     $ids = $this->Post['ids'] ? $this->Post['ids'] : $this->Get['ids'];
     $uid = DB::result_first("select uid from " . TABLE_PREFIX . "topic_attach where id = '{$ids}'");
     if (!$uid) {
         $this->Messager("您要删除的附件不存在!");
     }
     $sql = "delete from `" . TABLE_PREFIX . "topic_attach` where `id`='{$ids}'";
     $this->DatabaseHandler->Query($sql);
     update_credits_by_action('attach_del', $uid);
     jio()->DeleteFile(topic_attach($ids, 'file'));
     $verify = $this->Get['verify'];
     if ($verify) {
         $table = TABLE_PREFIX . "topic_verify";
     } else {
         $table = TABLE_PREFIX . "topic";
     }
     $attachid = DB::result_first("select attachid from {$table} where tid = '{$tid}'");
     if ($attachid) {
         $attach_id_arr = explode(",", $attachid);
         foreach ($attach_id_arr as $key => $value) {
             if ($value == $ids) {
                 unset($attach_id_arr[$key]);
             }
         }
         $new_attachid = implode(",", $attach_id_arr);
         $updata = "update {$table} set `attachid`='{$new_attachid}' where `tid`= '{$tid}'";
         $result = $this->DatabaseHandler->Query($updata);
     }
     $this->Messager("操作成功");
 }