WebDAV alternative in a PHP server - php

I'm currently exposing a WebDAV server using SabrePHP which allows me to expose a virtual filesystem based on a MongoDB database and a GridFS implementation to store files.
Now, it works quite well with Cyberduck, but here's the problem, only with Cyberduck. I smashed my head against the walls more than once to make the authentication work with the Windows built-in DAV client implementation just to see that it required special headers and authentication strategy to work.
So I'd like to know if there is any kind of alternative to WebDAV. My first thought was FTP, but I don't know if it is possible to expose an FTP "server" in PHP (cheating with the protocol in some dark apache configuration), and if it will work with my whole filesystem stored in database.

Related

File sending from browser to a server which is not a web server

I want to send a file from my browser to a server which is not the server on which the site is hosted.The problem is the another server is not a web server.
Is it programmatically possible to send a file to different server without the involvement of host server? I do not want copy of the file I am uploading on my hosting server.
Sorry for not being clear on the first go. I hope this makes sense.
Note: I have the IP address of server. Implementation has to be done in a secure way.
Create a signed application to handle the upload.
One of the fundamental rules of browser sandboxing is that you don't let the browser communicate to a server other than the one which provided the website. This has been a rule for quite some time, and is done for security reasons.
The only way I know of to bypass this restriction is to use a signed application. This is possible in several languages including at least Flash and Java. Once you've signed your application with an authoritative source, then you can specify that your application is known to communicate with a third-party server and should be trusted to do so. The process of doing this will be different depending on the technology you choose.
The server to which you are sending the file needs to allow some sort of protocol in order to accept the file. You do not specify what that is, but these languages should be more than sufficient to implement whatever you need.
given that you have the necessary authentication of the secondary server you can
i'll explain using ftp, but there can be other socket related ways
1) upload the file to your server as usual, using $_FILE
2) use the ftp class in php to transfer the file to the remote host
Thanks all for valuable suggestions. I am opting for bit weird way but it seems the only feasible solution considering the current requirements of the project.
I am planning to install lite version of web server and php on the external server which can accept uploaded files through browser.
Our team has worked out this is the best solution we can consider as of now.
Thanks again to all for their suggestions.
This is done all the time with Firefox plugins, (youtube etc.). Does it have to be driven from your page source ? How stealthily do you want to do this ?
The other server should use a common protocol, SSH or ftp or NFS or CIFS.
In any case the user is going to have to agree with the plugin or the applet or a third party service (think punkbuster) running in the background.
BF4 runs in a browser window via a plugin and routinely sends data to servers other than the game server.

How do I handle file uploading on distributed application?

I have photo uploading functionality in web application using PHP. Which is going to host as distributed application on many servers.
Now, problem is how should I handle that photo uploading functionality so, that photo can be available on all server? My application is in php.
You could use an already existing platform to perform syncing. Most modern OSes support syncing, and you could also use external tools.
At the OS level:
You can use rsync for *nix servers (plus, this has been ported to Windows too)
Here's a way to do it between Windows servers
Using external tools:
Goodsync enterprise
Syncbreeze
Under *nix, you could use rsync
Here's a collection of programs (free and paid) to do this
You could use a cloud-based service like Dropbox in all your servers
Using PHP:
You could use librsync
You could add an FTP/SSH server to each one of your distributed servers. Once a file is uploaded to one server, it can be uploaded via FTP to the others. PHP includes functionality for FTP - check the FTP section in the PHP handbook.
Use FXP to transfer files between servers. The KioobFTP class can be used for this, as it implements FXP transfers

Basic knowledge for Node.JS?

I'm trying to learn about node.js and there are tons of examples out there, but one question that I can't find an answer to or example is how does this work with web hosts (i'm using inmotionhosting.com)?
say I have a basic website www.url.com/index.php (note: I'm using PHP also). For this website to work, all I have to do is upload a file into my file manager in my web hosting site.
How does node.js work? do I just upload a node.js file into the web hosting also?
In all the examples, they are using localhost with port 8000 or something. Can someone shine some light?
Thanks!
you will need at least VPS hosting to install node.js, shared hosting won't allow you to install any application on your own, unless you they give you the option to do it.
then it all depends on how you have configured and what application is node.js serving, you can't really say where to upload files by default unless a path is set either from you or from webhosting..
from nodejs.org
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
it doesn't say it specific for web use, instead you should use a web framework such as
ExpressJS where you can build you web application or any other stuff.. your host should provide further information on how to manage packages in your nodejs instance, configuration, etc..
some usefull links
Domain API
ExpressJS
ExpressJS examples
Here is something i came cross.
Hosting your node app?
Hosting Node Apps
nodeFu
Supported hosting providers?
Node Hosting
just read the descriptions for each section.

To use cURL FTP does both servers need the PHP cURL library installed?

I'm trying to wrap my brain about how to do this. We need to provide some files within a directory from our servers to our clients' servers via a PHP/Web interface using FTP. I've looked at the FTP capabilities built in to PHP and some custom classes, but someone suggested cURL might be a better option. We will have the FTP login credentials in our database for the application to access. With that information can we use cURL FTP capabilities to do the transfers, knowing our server has libcurl installed, but the clients servers may not? Do both servers have to have it for the FTP function to work?
Or am I completely going about this the wrong way, and have misunderstood how to use cURL and should be looking into an FTP PHP class?
libCURL is a library; it acts as the client.
Your clients need to be running a FTP server but do not need libCURL.
Just to make it super clear, there are 2 computers involved:
Your server, the one that's supposed to provide files to the client using the FTP protocol. That server does not need to have a web server (or PHP) running. The only thing it needs is an FTP server. It also needs to have permissions configured in such a way that there is an account that can access the files through FTP.
Your client's server, the one that's supposed to retrieve files from your server using the FTP protocol. That server needs to have PHP installed, with libCurl. The software on that server needs to access your server using the FTP protocol, providing the user credentials that you configured on your box.
Hope that helps.
It sounds like what you want to do is have the client connect to your PHP script & then push a button to start an FTP transfer that sends a file from your FTP server to their FTP server. If this is the case, then all you need is cURL on your server.

how to add ftp users to an apache from PHP?

how do i go about adding ftp users to an apache web server? i need the user to register from normal web/script and then have an FTP account set up for them automatically.
I have seen the cPanel API, and it is pretty decent, but since cPanel costs money, i don't wish to use it for this project. I'm also reluctant to use any other lisenced piece of software.
i want to be able to do it using shell/batch (or pure PHP, though that hardly seem plausible)
Well as you said Apache is a Web and not an FTP Server. But most FTP servers like e.g. PureFtpd offer MySQL authentication. So you just have to modify the authentication table with PHP to add new users.

Categories