⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ftp.php

📁 这是一个joomla系统的插件, 这是一个joomla系统的插件
💻 PHP
字号:
<?php/*** @package EasyGallery* @copyright (C) 2006 Joomla-addons.org* @author  Adam van Dongen* @version $Id: ftp.php 6 2007-06-21 19:05:30Z websmurf $* * --------------------------------------------------------------------------------* All rights reserved. Easy Gallery Component for Joomla!** This program is free software; you can redistribute it and/or* modify it under the terms of the Joomla-addons Free Software License * See LICENSE.php for more information.** This program is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  * --------------------------------------------------------------------------------**/defined( '_VALID_MOS' ) or die( 'Restricted access' );class egftp {    var $fp = null;    function ftp(){    global $mainframe, $option;        require(PATH_EASYGALLERY . '/configuration.php');        if(!function_exists('ftp_connect') && $eg_ftp_disabled == 0){      echo "<script> alert('Function ftp_connect not available, please disable ftp mode'); window.history.go(-1); </script>\n";      exit;    }        if($eg_ftp_disabled == 0){      $this->fp = ftp_connect($eg_ftp_host, $eg_ftp_port);            if(substr($eg_ftp_path, 0, 1) != '/'){        mosRedirect('index2.php?option=' . $option . '&act=configuration', 'FTP path MUST start with a leading slash');      }            if(empty($eg_ftp_user)){        mosRedirect('index2.php?option=' . $option . '&act=configuration', 'Please configure a FTP username');      }            if(!ftp_login($this->fp, $eg_ftp_user, $eg_ftp_password)){        echo "<script> alert('Login to FTP server failed'); window.history.go(-1); </script>\n";        exit;      }            if(!$this->cd($eg_ftp_path . $eg_image_path)){        echo "<script> alert('Failed to change ftp path: ". $eg_ftp_path . $eg_image_path . "'); window.history.go(-1); </script>\n";        exit;      }    }  }    /**   * Change directory   *   * @param string $dirname   */  function cd($dir){    return ftp_chdir($this->fp, $dir);  }    /**   * Move one directory up   *   */  function up(){    return @ftp_cdup($this->fp);  }    /**   * Returns an array with the content of the directory   *   * @param string $dir   */  function getDirContent($dir){    return ftp_nlist($this->fp, $dir);  }    /**   * Creates a dir in the target directory if it doesn't exist allready   *   * @param string $dir   * @param string new dir name   */  function mkDir($tgt_dir, $dirname){    global $mainframe, $eg_ftp_path;    $files = $this->getDirContent($tgt_dir);        if(!file_exists($mainframe->getCfg('absolute_path') . $tgt_dir . '/' . $dirname)){//    if(!in_array($tgt_dir . '/' . $dirname, $files)){      return ftp_mkdir($this->fp, $eg_ftp_path . $tgt_dir . '/' . $dirname);    } else {      return true;    }  }    /**   * Copies a file from the local server through ftp   *   * @param string original file path   * @param string file name   */  function copy($path, $name){    return ftp_put($this->fp, $name, $path, FTP_BINARY);  }    /**   * Rename a file through ftp   *   * @param string $old_name   * @param string $new_name   */  function rename($old_name, $new_name){    return ftp_rename($this->fp, $old_name, $new_name);  }    /**   * Create a new file based on the passed content   *   * @param string $name   * @param gd $fp   */  function createFile($name, $fp){    return ftp_fput($this->fp, $name, $fp, FTP_BINARY);  }    function del($file){    return ftp_delete($this->fp, $file);  }}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -