Copy CodeThe code is as follows:
/*
* Generate Ubuntu Auto Switch wallpaper XML file
*/
Picture Catalogue
$dir = '/home/yuxing/background ';
$HD = Opendir ($dir) or Die (' Can not open dir ');
$files = Array ();
while ($file = Readdir ($HD)) {
$tem = "$dir/$file";
if (Is_file ($tem) && In_array (Strtolower (substr (STRRCHR ($file, '. '), 1)), array (' jpg ', ' gif '))
$files [] = $tem;
}
Closedir ($HD);
Unset ($file);
$xw = new XmlWriter ();
$xw->openmemory ();
$xw->setindent (TRUE);
$xw->setindentstring (");
$xw->startdocument (' 1.0 ', ' utf-8 ');
$xw->startelement (' background ');
$xw->startelement (' StartTime ');
$xw->writeelement (' Year ', ' 2000 ');
$xw->writeelement (' month ', ' 01 ');
$xw->writeelement (' Day ', ' 01 ');
$xw->writeelement (' hour ', ' 00 ');
$xw->writeelement (' minute ', ' 00 ');
$xw->writeelement (' second ', ' 00 ');
$xw->endelement ();
$count = count ($files);
for ($i =0; $i < $count; $i + +) {
$xw->startelement (' static ');
$xw->writeelement (' duration ', ' 1795.0 ');
$xw->writeelement (' duration ', ' 30.0 ');
$xw->writeelement (' file ', $files [$i]);
$xw->endelement ();
$xw->startelement (' transition ');
$xw->writeelement (' Duration ', ' 5 ');
$xw->writeelement (' from ', $files [$i]);
$xw->writeelement (' to ', Isset ($files [$i +1])? $files [$i +1]: $files [0]);
$xw->endelement ();
}
$xw->endelement ();
$xml = $xw->outputmemory (true);
Generating files
$HD = fopen ($dir. "/yuxing.xml", ' WB ');
Fwrite ($HD, $xml);
Fclose ($HD);
echo ' OK ';
?>
http://www.bkjia.com/PHPjc/322262.html www.bkjia.com true http://www.bkjia.com/PHPjc/322262.html techarticle Copy the code as follows: PHP/* * Generate Ubuntu Auto Switch wallpaper XML file *///Picture Directory $dir = '/home/yuxing/background '; $hd = Opendir ($dir) or Die (' can n OT open dir '); $fi ...