PHP code generated by ubuntu Auto Switch wallpaper XML file PHP code

Source: Internet
Author: User
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 ';
?>

The above describes the PHP code generation ubuntu automatically switch wallpaper XML file PHP code, including the content of the PHP code, I hope to be interested in PHP tutorial friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.