Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Patch for Online PHP-IDE (online-php.com): added FTP SSL connection
diff --git a/www/php-ide/application/model/ftp.class.php b/www/php-ide/application/model/ftp.class.php
--- a/www/php-ide/application/model/ftp.class.php
+++ b/www/php-ide/application/model/ftp.class.php
@@ -5,12 +5,12 @@
//e-mail:rsr_cn@yahoo.com.cn
//website:www.yawill.com
//create:2004-6-23 09:22
-//modify:
+//modify: 2011-12-30 - Martin Mevald, www.mevald.cz - added SSL connection
//////////////////////////////////////////////////
class ClsFTP{
- var $host = "localhost";//FTP HOST
+ var $host = "localhost"; //FTP HOST, prefix "!" - use SSL
var $port = "21"; //FTP port
var $user = "Anonymous";//FTP user
var $pass = "Email"; //FTP password
@@ -36,9 +36,9 @@ class ClsFTP{
echo "FTP Error message:$msg<br/>\n";
exit();
}
- function login(){
+ function connLogin($conn){ // $conn - resource from ftp_connect / ftp_ssl_connect
if(!$this->link_id){
- if (!($this->link_id = ftp_connect($this->host,$this->port, 30))) {
+ if (!($this->link_id = $conn)) {
return false; //$this->halt("can not connect to host:$this->host:$this->port",__LINE__);
}
}
@@ -47,7 +47,25 @@ class ClsFTP{
return false;//or $this->halt("ftp login faild.invaid user or password",__LINE__);
}
}
+ return true;
}
+
+ function login() { // host: prefix "!" - use SSL
+
+ if (substr($this->host,0,1)=='!') {
+ if (!function_exists('ftp_ssl_connect')) {
+ return false;
+ }
+ $host=substr($this->host,1,strlen($this->host));
+
+ $conn = ftp_ssl_connect($host,$this->port,30);
+ return ($this->connLogin($conn));
+ } else {
+ return $this->connLogin(ftp_connect($this->host,$this->port, 30));
+ }
+ }
+
+
function systype(){
return ftp_systype($this->link_id);
}
diff --git a/www/php-ide/application/view/login_screen.phtml b/www/php-ide/application/view/login_screen.phtml
--- a/www/php-ide/application/view/login_screen.phtml
+++ b/www/php-ide/application/view/login_screen.phtml
@@ -7,7 +7,7 @@
<? } ?>
<form action="<?=_HTTP_ROOT?>/" method="POST">
<dl>
- <dt>Host name</dt>
+ <dt>Host name</dt> (prefix "<b>!</b>" &ndash; use SSL)
<dd><input type="text" class="input_text" name="ftp_hostname" size="40" maxlength="250" /></dd>
<dt>Login</dt>
<dd><input type="text" class="input_text" name="ftp_username" size="40" maxlength="250" /></dd>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment