[Solved]: Compare file date of Android and FTP
Posted: Fri Jan 06, 2017 2:34 pm
Edit notice: Title was changed from: "Help with Regex/ PHP, please!"
Hi,
due to LC's subterranean implementation for Android I need to go rough roads to accomplish my goals.
Here I need a detailed listing of a ftp-folders contents, which usually is easy:
or, with more meaningful results:
On Android, this simply isn't implemented yet :/
So I have to call PHP(!) to help, to get my detailed folder list. Found some basic code, but I'm running into a problem. Lemme show you:
The "ftp_raw" sets mode to passive, and provides an array, whose later used key value I have included.
If I understand it correctly, "127,0,0,1,196,66" should then be extracted, so that the following lines would resolve to:
But the "preg_match", that should test the regex:
"#^227.*\(([0-9]+,[0-9]+,[0-9]+,[0-9]+),([0-9]+),([0-9]+)\)$#"
against the string:
"227 Entering Passive Mode (127,0,0,1,196,66)."
fails with no hit.
I found a second version, with "/" instead of "#" at begin and end, but both versions never hit.
Now my knowledge of Regexp is even less than my knowledge of PHP, so you can understand I'm doomed.
Is any kind soul out there that can:
PS:
There's a solution, but it's not really satisfying:This works exactly as the first LC example above, but both give dateTime in a poor manner: "Jan 6 06:01". Not really useful without year.
Hi,
due to LC's subterranean implementation for Android I need to go rough roads to accomplish my goals.
Here I need a detailed listing of a ftp-folders contents, which usually is easy:
Code: Select all
put "ftp://" & myUSR & ":" & myPAS \
& "@" & myDir into myURL
put URL myURL into myVar
Code: Select all
put "ftp://" & myUSR & ":" & myPAS \
& "@" & myDir into myURL
libURLSetFTPListCommand "LIST"
put URL myURL into myVar
So I have to call PHP(!) to help, to get my detailed folder list. Found some basic code, but I'm running into a problem. Lemme show you:
Code: Select all
$ret = ftp_raw($ftp, 'PASV');
// $ret[0] => "227 Entering Passive Mode (127,0,0,1,196,66)." //
if (preg_match('#^227.*\(([0-9]+,[0-9]+,[0-9]+,[0-9]+),([0-9]+),([0-9]+)\)$#', $ret[0], $matches)) {
$controlIP = str_replace(',', '.', $matches[1]);
$controlPort = intval($matches[2])*256+intval($matches[3]);
$socket = fsockopen($controlIP, $controlPort);
ftp_raw($ftp, 'MLSD');
// $socket is needed in the following code //
If I understand it correctly, "127,0,0,1,196,66" should then be extracted, so that the following lines would resolve to:
Code: Select all
$controlIP = '127.0.0.1';
$controlPort = (196*256+66);
$socket = fsockopen('127.0.0.1',50242);
"#^227.*\(([0-9]+,[0-9]+,[0-9]+,[0-9]+),([0-9]+),([0-9]+)\)$#"
against the string:
"227 Entering Passive Mode (127,0,0,1,196,66)."
fails with no hit.
I found a second version, with "/" instead of "#" at begin and end, but both versions never hit.
Now my knowledge of Regexp is even less than my knowledge of PHP, so you can understand I'm doomed.
Is any kind soul out there that can:
- Find the mistake in the regexp & correct it, OR
- Give me a hint what PHP construction I should google for to solve the problem in another way?
PS:
There's a solution, but it's not really satisfying:
Code: Select all
ftp_rawlist($ftpConn, '/');