public function copy_file($srcfile, $desfile, $type) { global $_G; if (!is_file($srcfile)) { return false; } if ($type == 'file') { $this->mkdirs(dirname($desfile)); copy($srcfile, $desfile); } elseif ($type == 'ftp') { $siteftp = $_GET['siteftp']; $siteftp['on'] = 1; $siteftp['password'] = authcode($siteftp['password'], 'ENCODE', md5($_G['config']['security']['authkey'])); $ftp =& core_ftp::instance($siteftp); $ftp->connect(); $ftp->upload($srcfile, $desfile); if ($ftp->error()) { return false; } } return true; }
function ftpcmd($cmd, $arg1 = '') { static $ftp; $ftpon = getglobal('setting/ftp/on'); if (!$ftpon) { return $cmd == 'error' ? -101 : 0; } elseif ($ftp == null) { $ftp =& core_ftp::instance(); } if (!$ftp->enabled) { return $ftp->error(); } elseif ($ftp->enabled && !$ftp->connectid) { $ftp->connect(); } switch ($cmd) { case 'upload': return $ftp->upload(getglobal('setting/attachdir') . '/' . $arg1, $arg1); break; case 'delete': return $ftp->ftp_delete($arg1); break; case 'close': return $ftp->ftp_close(); break; case 'error': return $ftp->error(); break; case 'object': return $ftp; break; default: return false; } }