国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? PHP ???? PHP Python FTP ?? ???

PHP Python FTP ?? ???

Jul 25, 2016 am 08:51 AM

PHP Python FTP ?? ???
  1. class Ftp {
  2. //FTP ?? ???
  3. private $link;
  4. //FTP ?? ??
  5. public $link_time;
  6. //?? ??
  7. private $err_code = 0;
  8. //?? ?? {??? ??: FTP_ASCII, ???? ??: FTP_BINARY}
  9. ?? $mode = FTP_BINARY;
  10. /**
  11. ??? ???
  12. **/
  13. ?? ?? start($data)
  14. {
  15. if(empty($data['port']) ) $data['port'] ='21';
  16. if(empty($data['pasv'])) $data['pasv'] =false;
  17. if(empty($data[' ssl'])) $data['ssl'] = false;
  18. if(empty($data['timeout'])) $data['timeout'] = 30;
  19. return $this-> connect($data['??'],$data['??? ??'],$data['????'],$data['??'],$data['pasv'],$data['ssl'], $data['timeout']);
  20. }
  21. /**
  22. * FTP ??? ??
  23. * @param string $host ?? ??
  24. * @param string $username ??? ??
  25. * @param string $password ????
  26. * @param ?? $port ?? ?? , ???? 21
  27. * @param boolean $pasv Passive ?? ??? ??
  28. * @param boolean $ssl    SSL ?? ?? ??
  29. * @param ?? $timeout ?? ?? ??
  30. */
  31. ?? ?? connect($host, $username = '', $password = '', $ port = '21', $pasv = false, $ssl = false, $timeout = 30) {
  32. $start = time();
  33. if ($ssl) {
  34. if (!$this- >link = @ftp_ssl_connect($host, $port, $timeout)) {
  35. $this->err_code = 1;
  36. return false;
  37. }
  38. } else {
  39. if (!$this->link = @ftp_connect($host, $port, $timeout)) {
  40. $this->err_code = 1;
  41. return false;
  42. }
  43. }
  44. if (@ftp_login($this->link, $username, $password)) {
  45. if ($pasv)
  46. ftp_pasv($this->link, true);
  47. $this->link_time = time() - $start;
  48. return true;
  49. } else {
  50. $this->err_code = 1;
  51. return false;
  52. }
  53. register_shutdown_function(array(&$this, 'close'));
  54. }
  55. /**
  56. * ?? ??
  57. * @param string $dirname ???? ??,
  58. */
  59. ?? ?? mkdir($dirname) {
  60. if ( !$this->link) {
  61. $this->err_code = 2;
  62. return false;
  63. }
  64. $dirname = $this->ck_dirname($dirname);
  65. $nowdir = '/';
  66. foreach ($dirname as $v) {
  67. if ($v && !$this->chdir($nowdir . $v)) {
  68. if ($ nowdir)
  69. $this->chdir($nowdir);
  70. @ftp_mkdir($this->link, $v);
  71. }
  72. if ($v)
  73. $nowdir .= $v . '/';
  74. }
  75. return true;
  76. }
  77. /**
  78. * ?? ???
  79. * @param string $remote ?? ??? ??
  80. * @param string $local ?? ??? ??
  81. */
  82. ?? ?? put($remote, $local) {
  83. if (!$this->link) {
  84. $this->err_code = 2;
  85. return false;
  86. }
  87. $dirname = pathinfo($remote, PATHINFO_DIRNAME) ;
  88. if (!$this->chdir($dirname)) {
  89. $this->mkdir($dirname);
  90. }
  91. if (@ftp_put($this-> link, $remote, $local, $this->mode)) {
  92. return true;
  93. } else {
  94. $this->err_code = 7;
  95. return false;
  96. }
  97. }
  98. /**
  99. * ?? ??
  100. * @param string $dirname ???? ??
  101. * @param boolean $enforce ?? ??
  102. */
  103. ?? ?? rmdir($dirname, $enforce = false) {
  104. if (!$this->link) {
  105. $this->err_code = 2;
  106. return false;
  107. }
  108. $list = $this->nlist($dirname);
  109. if ($list && $enforce) {
  110. $this->chdir($dirname);
  111. foreach ($list as $v) {
  112. $this->f_delete($v);
  113. }
  114. } elseif ( $list && !$enforce) {
  115. $this->err_code = 3;
  116. return false;
  117. }
  118. @ftp_rmdir($this->link, $dirname);
  119. true? ?????.
  120. }
  121. /**
  122. * 刪除指定檔案
  123. * @param string $filename 檔案名稱
  124. */
  125. public function delete($filename) {
  126. if (!$this->link) {
  127. $this->err_code = 2 ;
  128. return false;
  129. }
  130. if (@ftp_delete($this->link, $filename)) {
  131. return true;
  132. } else {
  133. $this-> ;err_code = 4;
  134. return false;
  135. }
  136. }
  137. /**
  138. * 傳回給定目錄的檔案清單
  139. * @param string $dirname 目錄位址
  140. * @return array 檔案清單資料
  141. */
  142. public function nlist($dirname) {
  143. if (! $ $this-this >link) {
  144. $this->err_code = 2;
  145. return false;
  146. }
  147. if ($list = @ftp_nlist($this->link, $dirname )) {
  148. return $list;
  149. } else {
  150. $this->err_code = 5;
  151. return false;
  152. }
  153. }
  154. /* *
  155. * 在 FTP 伺服器上改變目前目錄
  156. * @param string $dirname 修改伺服器上目前目錄
  157. */
  158. public function chdir($dirname) {
  159. if (!$this->link) {
  160. $this->err_code = 2;
  161. return false;
  162. }
  163. if (if (@ ftp_chdir($this->link, $dirname)) {
  164. return true;
  165. } else {
  166. $this->err_code = 6;
  167. return false;
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }
  175. }
  176. }
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. /**
  200. * 取得錯誤訊息
  201. */
  202. public function get_error() {
  203. if (!$this->err_code)
  204. 回傳false;
  205. $err_msg = array(
  206. '1' =>; '伺服器無法連線',
  207. '2' =>; '未連線到伺服器',
'3' =>; '無法刪除非空資料夾',
'4' =>; '無法刪除檔案', '5' =>; '無法取得檔案清單', '6' =>; '無法變更伺服器上的目前目錄',
'7' =>; ' 無法上傳檔案' ); return $err_msg[$this->err_code]; } /** * 偵測目錄名稱 * @param string $url 目錄 * @return 由 / 分開的回傳陣列*/ 介面函數(shù) ck_dirname ($ url) { $url = str_replace('', '/', $url); $urls =explode('/', $url); return $urls; } /** * 關閉FTP連線*/ public function close() { return @ftp_close($this->link); } 複製程式碼
  1. #!/usr/bin/python
  2. #coding=gbk
  3. '''
  4. ftp ?? ????, ?? ??? ????, ??? ???? ?? ??
  5. '''
  6. from ftplib import FTP
  7. import os,sys,string,datetime,time
  8. import ??
  9. class MYFTP:
  10. def __init__(self,hostaddr , ??? ??, ????, ?? ????, ??=21):
  11. self.hostaddr = ??? ??
  12. self.username = ??? ??
  13. self.password = ????
  14. self.remotedir = ?? ????
  15. self.port = port
  16. self.ftp = FTP()
  17. self.file_list = []
  18. # self.ftp.set_debuglevel(2)
  19. def __del__(self):
  20. self.ftp.close ()
  21. # self.ftp.set_debuglevel(0)
  22. def login(self):
  23. ftp = self.ftp
  24. try:
  25. timeout = 60
  26. ??.setdefaulttimeout(timeout )
  27. ftp.set_pasv(True)
  28. print '%s? ?? ??' %(self.hostaddr)
  29. ftp.connect(self.hostaddr, self.port)
  30. print '%s? ????? ???????. %s' %(self.hostaddr)
  31. print '%s? ???? ?????' %(self.hostaddr)
  32. ftp.login(self.username, self.password)
  33. print '????? ????????. % s' %(self.hostaddr)
  34. debug_print(ftp.getwelcome())
  35. ?? ??:
  36. deal_error("?? ?? ??? ??")
  37. ??:
  38. ftp.cwd (self .remotedir)
  39. ??(??):
  40. deal_error('???? ?? ??')
  41. def is_same_size(self, localfile, remotefile):
  42. try:
  43. remotefile_size = self.ftp.size(remotefile)
  44. ??:
  45. Remotefile_size = -1
  46. ??:
  47. localfile_size = os.path.getsize(localfile)
  48. ??:
  49. localfile_size = - 1
  50. debug_print('lo:%d re:%d' %(localfile_size, remotefile_size),)
  51. if remotefile_size == localfile_size:
  52. return 1
  53. else:
  54. return 0
  55. def download_file (self, localfile, remotefile):
  56. if self.is_same_size(localfile, remotefile):
  57. debug_print('%s ??? ??? ????? ????? ??? ????.' %localfile)
  58. return
  59. else:
  60. debug_print('>>>>>>>>>>>>%s ?? ???? ... ...' %localfile)
  61. #return
  62. file_handler = open(localfile, 'wb')
  63. self.ftp.retrbinary('RETR %s'%(remotefile), file_handler.write)
  64. file_handler.close()
  65. def download_files( self, localdir='./', remotedir='./'):
  66. ??:
  67. self.ftp.cwd(remotedir)
  68. ??:
  69. debug_print( '???? %s?(?) ???? ????. ?????...' %remotedir)
  70. return
  71. ??? ?? ?? os.path.isdir(localdir):
  72. os.makedirs(localdir)
  73. debug_print('Switch %s' %self.ftp.pwd())
  74. self.file_list = []
  75. self.ftp.dir(self.get_file_list)
  76. remotenames = self.file_list
  77. #print( ?? ??)
  78. #return
  79. ?? ??? ??:
  80. filetype = item[0]
  81. filename = item[1]
  82. local = os.path.join(localdir, filename)
  83. if filetype == 'd' :
  84. self.download_files(local, ?? ??)
  85. elif filetype == '-':
  86. self.download_file(local, ?? ??)
  87. self.ftp.cwd ('..')
  88. debug_print('?? ???? %s? ?????' %self.ftp.pwd())
  89. def upload_file(self, localfile, remotefile):
  90. os.path? ?? ?? .isfile(localfile):
  91. return
  92. if self.is_same_size(localfile, remotefile):
  93. debug_print('Skip [equal]: %s' %localfile)
  94. return
  95. file_handler = open (localfile, 'rb')
  96. self.ftp.storbinary('STOR %s' %remotefile, file_handler)
  97. file_handler.close()
  98. debug_print('???: %s' %localfile)
  99. def upload_files(self, localdir= './', remotedir = './'):
  100. ??? ?? ?? os.path.isdir(localdir):
  101. return
  102. localnames = os.listdir(localdir)
  103. self.ftp.cwd (remotedir)
  104. for item in localnames:
  105. src = os.path.join(localdir, item)
  106. if os.path.isdir(src):
  107. ??:
  108. self.ftp .mkd(item)
  109. ??:
  110. debug_print('????? ?? %s' %item)
  111. self.upload_files(src, item)
  112. else:
  113. self.upload_file(src, item)
  114. self.ftp.cwd('..')
  115. def get_file_list(self, line):
  116. ret_arr = []
  117. file_arr = self.get_filename(line)
  118. if file_arr[1]? ['.', '..']? ??:
  119. self.file_list.append(file_arr)
  120. def get_filename(self, line ):
  121. pos = line .rfind(':')
  122. while(line[pos] != ' '):
  123. pos = 1
  124. while(line[pos] == ' ') :
  125. pos = 1
  126. file_arr = [line[0], line[pos:]]
  127. return file_arr
  128. def debug_print(s):
  129. print(s)
  130. def deal_error (e):
  131. timenow = time.localtime()
  132. datenow = time.strftime('%Y-%m-%d', timenow)
  133. logstr = '%s ??? ??????: %s ' %(datenow, e)
  134. debug_print(logstr)
  135. file.write(logstr)
  136. sys.exit()
  137. if __name__ == '__main__':
  138. file = open("log.txt", " a")
  139. timenow = time.localtime()
  140. datenow = time.strftime('%Y-%m-%d', timenow)
  141. logstr = datenow
  142. # ?? ??? ?????
  143. hostaddr = 'localhost' # ftp ??
  144. username = 'test' # Username
  145. password = 'test' # ????
  146. port = 21 # ?? ??
  147. rootdir_local = '.' os.sep 'bak/' # ?? ????
  148. rootdir_remote = './' # ?? ????
  149. f = MYFTP(hostaddr, ??? ??, ????, rootdir_remote, ??)
  150. f.login()
  151. f.download_files(rootdir_local, rootdir_remote)
  152. timenow = time.localtime()
  153. datenow = time.strftime('%Y-%m-%d', timenow )
  154. logstr = " - %s? ?? n? ????? ??????." ?tenow
  155. debug_print(logstr)
  156. file.write(logstr)
  157. file.close()
?? ??


? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
PHP ?? ??? ??????? PHP ?? ??? ??????? Jul 17, 2025 am 04:16 AM

PHP ?? ??? ?? ???? ?? ? ????? ??? ?????. 1. ?? ??? ??? ??? ??? ? ? ??? ??? ??? ?? ?? ??? ???? ???????. 2. ?? ??? ???? ???? ? ?? ????? ?? ?? ?? ??? ?????. 3. $ _get ? $ _post? ?? Hyperglobal ??? ?? ???? ?? ??? ? ??? ??? ??????? ???????. 4. ?? ?? ?? ???? ?? ?? ?? ??? ?????? ?? ??? ??? ?? ??? ???????. ??? ??? ????? ??? ??? ?? ???? ????? ? ??? ? ? ????.

PHP?? ?? ???? ???? ???? ??? ?????? PHP?? ?? ???? ???? ???? ??? ?????? Jul 08, 2025 am 02:37 AM

PHP ?? ???? ???? ????? ?? ? ??? ???? ?? ?? ? ??? ???? ?? ??? ?????? ??? ??? ? ? ???????. 1. ??? ?? CSRF? ???? ?? ??? ??? ???? ?????? ??? ???? FINFO_FILE? ?? ?? MIME ??? ?????. 2. ??? ??? ??? ???? ??? ?? ??? ?? ? WEB ????? ??? ???? ??????. 3. PHP ?? ??? ?? ? ?? ???? NGINX/APACHE? ??? ????? ?? ???? ?????. 4. GD ?????? ??? ? ?? ???? ??? ?? ??? ?? ????.

PHP?? ?? ?? PHP?? ?? ?? Jul 18, 2025 am 04:57 AM

PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

PHP?? ???? ??? ?????? PHP?? ???? ??? ?????? Jul 11, 2025 am 03:12 AM

Ageneratorinphpisamemory- ???? Way-Erate-Overgedatasetsetsbaluesoneatimeatimeatimeatimallatonce.1.generatorsuseTheyieldKeywordTocroadtOpvaluesondemand, RetingMemoryUsage.2

PHP ?? ?? ? PHP ?? ?? ? Jul 18, 2025 am 04:51 AM

PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

?? PHP : ??? ??? ?? PHP : ??? ??? Jul 18, 2025 am 04:54 AM

tolearnpheffectical, startBysetTupaloCalserErverEnmentUsingToolslikexamppandacodeeditor -likevscode.1) installxamppforapache, mysql, andphp.2) useacodeeditorforsyntaxsupport.3)) 3) testimplephpfile.next, withpluclucincludechlucincluclucludechluclucled

PHP?? ??? ? ???? ??? ????? ?? PHP?? ??? ? ???? ??? ????? ?? Jul 12, 2025 am 03:15 AM

PHP??? ???? ??? ?? ?? ????? ???? ??? ?? ??? ??? ?? ? ??? ??? ???? ?????. ???? 0?? ???? ?? ??? ???? ? ?? ???? ?? ?? ? ? ????. MB_SUBSTR? ?? ??? ??? ???????. ? : $ str = "hello"; echo $ str [0]; ?? H; ??? MB_SUBSTR ($ str, 1,1)? ?? ??? ??? ??? ??????. ?? ???????? ???? ??? ???? ?? ???? ?? ?? ???? ?????? ??? ????? ?? ??? ?? ??? ???? ???? ?? ????.

?? PHP ?? ??? ?? PHP ?? ??? Jul 18, 2025 am 04:52 AM

toinstallphpquickly, usexampponwindowsorhomebrewonmacos.1. ??, downloadandinstallxAmpp, selectComponents, startApache ? placefilesinhtdocs.2

See all articles