#! /Usr/local/bin/PHP
<? PHP
Error_reporting (0 );
If (count ($ argv) <= 1 | $ argv [1] = "-h "){
Die ("no file or directory to sync./nusage: Synchronize file1 [directory1] file2 [directory2].../n ");
}
// $ Hosts = unserialize (file_get_contents ("/bin/hosts "));
$ Hosts = file ("/bin/hosts. Line ");
// $ Path = get_pwd ();
$ Path = getcwd ();
For ($ I = 1; $ I <count ($ argv); $ I ++ ){
If (strstr ($ argv [$ I], "/")! = $ Argv [$ I]) $ src = $ path. "/". $ argv [$ I];
Else $ src = $ argv [$ I];
If ($ _ server ["LOGNAME"]! = 'Root' | substr ($ SRC, 0, 30 )! = "/Usr/local/apache2/htdocs /")
{
Echo $ SRC. "Not allowed./N ";
Continue;
}
$ Tar = dirname ($ SRC )."/";
If (is_dir ($ SRC )){
Foreach ($ hosts as $ h ){
$ H = trim ($ H );
$ Cmd = "sudo/usr/bin/SCP-R". $ SRC. "test @". $ H. ":". $ tar;
Ex ($ cmd );
}
} Elseif (is_file ($ SRC )){
Foreach ($ hosts as $ h ){
$ H = trim ($ H );
$ Cmd = "sudo/usr/bin/SCP". $ SRC. "test @". $ H. ":". $ tar;
Ex ($ cmd );
}
} Else {
Echo "Ignore". $ SRC. "(does not exists ?) /N ";
}
}
Function get_pwd (){
Return $ _ server ['pwd'];
}
Function ex ($ cmd ){
Echo substr ($ cmd, 14). "-> executing, please wait ...";
System ($ cmd );
Echo "OK! /N ";
}
?>