This script reads two type of files and updates a sales table. First it executes the shell script file. After that it reads the .out files and then i updates one of the table in a database.
<?php
$ftps = array( host => "localhost" , user => "ftp" , psswd => "" );
//Openning an ftp connection
$conn = ftp_connect ( $ftps [ "host" ] );
if( ! $conn ){
echo "FTP server connection error" . "<BR>" ;
exit;
}
else{
echo "Connected to FTP Server" . "<BR>" ;
//Login to the FTP server.
@ $result = ftp_login ( $conn , $ftps [ "user" ], $ftps [ "psswd" ] );
if( ! $result ){
echo "The page couldn't log in as : " . $ftps [ "user" ] . "<BR>" ;
ftp_quit ( $conn );
exit;
}
echo "You are user: " . $ftps [ "user" ] . "<BR>" ;
//Getting the file's time from the FTP_Server.
$time = ftp_mdtm ( $conn , "/alex/hola.txt" );
echo date ( "D d-M-Y -- H:i:s" , $time ) . "<BR>" ;
//Executing a shell script.
//my_script is a shell script which only has an echo statement.
$res = ftp_exec ( $conn , "/src/shell_scripts/my_script" );
echo "Script Shell result: " . $res ;
$readfile = file ( "var/www/html/rt.out" );
for ( $k = 0 ; $k <= count ( $readfile )- 1 ; $k ++) {
$fields = split ( "\t" , $readfile [ $k ]);
$rt = "UPDATE sales set date =' $fields [ 0 ] ', downloads=' $fields [ 2 ] ' where type = 'rt'" ;
}
$readfile1 = file ( "var/www/html/rbt.out" );
for ( $k = 0 ; $k <= count ( $readfile1 )- 1 ; $k ++) {
$fields = split ( "\t" , $readfile1 [ $k ]);
$rbt = "UPDATE sales set date =' $fields [ 0 ] ', downloads=' $fields [ 2 ] ' where type = 'rbt'" ;
}
ftp_quit ( $conn );
}
?>
Checks Date-Input from HTML-Forms and converts to YYYY-MM-DD Format for MySQL Date-Fields Categories : MySQL , Date Time , PHP , Databases How to Insert a Date Format Into MySQL from PHP Categories : PHP , Databases , MySQL , Date Time , Beginner Guides Save and restore files into postgresql database (PHP SCRIPT) PHP CLASS Categories : PHP , Databases , PostgreSQL , Filesystem Fetching product details from the commission junction website using php Categories : PHP , FTP , Filesystem , Compression Query Timer Categories : PHP , Databases , Date Time mysql date/time converters Categories : PHP , MySQL , Databases , Date Time Finding the day of the week for a specific date.
Categories : PHP , Databases , MySQL , Date Time Using PHP to Delete a directory with all sub directories and files using FTP Categories : PHP , FTP , Directories , Filesystem A wrapper function to format dates coming from a databases with the
same syntax as PHP's date() function. Categories : Date Time , Databases , PHP Monthly and Daily Upcoming Events calendar. Categories : Date Time , PostgreSQL , PHP , Calendar , Databases Simple function to return the number of days in a time span between 2 given dates. Categories : PHP , Date Time , MySQL , Databases Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support Categories : PHP , FTP , Filesystem , PHP Classes , Compression Simple conversion functions to change MySQL dates to arrays, arrays to MySQL dates.
Categories : PHP , Arrays , Date Time , Databases , MySQL Phorum, MySQL, Language, UK date format, MySQL UK Date format Categories : PHP , Date Time , Strings , MySQL , Databases Convert a File database into MySQL Categories : PHP , Filesystem , Databases , MySQL , Beginner Guides