Esempio n. 1
0
 /**
  *  删除
  *
  * @param     int    $id
  * @return    string
  */
 function del($id)
 {
     if ($id) {
         $row = $this->dsql->GetOne("SELECT askid FROM `#@__askanswer` WHERE id='{$id}'");
         $query = "DELETE FROM #@__askanswer WHERE id='{$id}'";
         if ($this->dsql->ExecuteNoneQuery($query)) {
             $query2 = "UPDATE `#@__ask` SET replies = replies - 1 WHERE id='{$row['askid']}'";
             $this->dsql->ExecuteNoneQuery($query2);
             global $cfg_basedir, $cfg_remote_site;
             //启用远程站点则创建FTP类
             if ($cfg_remote_site == 'Y') {
                 require_once DEDEINC . '/ftp.class.php';
                 if (file_exists(DEDEDATA . "/cache/inc_remote_config.php")) {
                     require_once DEDEDATA . "/cache/inc_remote_config.php";
                 }
                 if (empty($remoteuploads)) {
                     $remoteuploads = 0;
                 }
                 if (empty($remoteupUrl)) {
                     $remoteupUrl = '';
                 }
                 //初始化FTP配置
                 $ftpconfig = array('hostname' => $rmhost, 'port' => $rmport, 'username' => $rmname, 'password' => $rmpwd);
                 $ftp = new FTP();
                 $ftp->connect($ftpconfig);
             }
             $query = "SELECT url FROM `#@__uploads_ask` WHERE rid ='{$id}' AND type = 0";
             $this->dsql->SetQuery($query);
             $this->dsql->Execute();
             while ($row = $this->dsql->GetArray()) {
                 if ($cfg_remote_site == 'Y' && $remoteuploads == 1) {
                     $ftp->delete_file($row['url']);
                 } else {
                     @unlink($cfg_basedir . $row['url']);
                 }
             }
             $this->dsql->ExecuteNoneQuery("DELETE FROM `#@__uploads_ask` WHERE rid ='{$id}' AND type = 0");
             return TRUE;
         } else {
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }