Exemplo n.º 1
0
 /**
  * Singleton to instantiate the class
  *
  * @return mixed Object of the class
  */
 public static function getInstance()
 {
     if (self::$instance === NULL) {
         $klasse = __CLASS__;
         self::$instance = new $klasse();
     }
     return self::$instance;
 }
Exemplo n.º 2
0
/**
 * 连接ftp
 * 
 * $ftp = 'ftp://*****:*****@192.168.99.1:21'
 * @param string $ftp ftp连接url
 * @return boolean
 */
function ftp_connect_v2($ftp)
{
    if (!preg_match('/^ftp:\\/\\/[^:]+:[^@]+@[\\d\\.]+(:\\d+)?$/i', $ftp) || !($ftp = parse_url($ftp))) {
        return false;
    } elseif (@$ftp['scheme'] != 'ftp') {
        return false;
    } elseif (empty($ftp['host'])) {
        return false;
    } else {
        $ftp += array('port' => 21, 'user' => '', 'pass' => '');
    }
    $fp = FTP::instance($ftp['host'], $ftp['port'], $ftp['user'], $ftp['pass']);
    if (!$fp->connect()) {
        return $fp->error();
    }
    return $fp;
}