Replace mkringlist.sh with mkringlist.php
Move from tftpboot/ringtones to Tools Use PHP instead of Bash to simplify output Eliminate executables in tftpboot
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
outfile=ringlist.xml
|
||||
echo -e "<CiscoIPPhoneRingList>" >$outfile
|
||||
if [ ! -z "`ls *.pcm 2>/dev/null`" ]; then
|
||||
for filename in *.pcm;do
|
||||
basename=`basename ${filename} .pcm`
|
||||
echo -e "\t<Ring>" >>$outfile
|
||||
echo -e "\t\t<DisplayName>${basename}</DisplayName>" >>$outfile
|
||||
echo -e "\t\t<FileName>ringtones/${filename}</FileName>" >>$outfile
|
||||
echo -e "\t</Ring>" >>$outfile
|
||||
done
|
||||
fi
|
||||
if [ ! -z "`ls *.raw 2>/dev/null`" ]; then
|
||||
for filename in *.raw;do
|
||||
basename=`basename ${filename} .raw`
|
||||
echo -e "\t<Ring>" >>$outfile
|
||||
echo -e "\t\t<DisplayName>${basename}</DisplayName>" >>$outfile
|
||||
echo -e "\t\t<FileName>ringtones/${filename}</FileName>" >>$outfile
|
||||
echo -e "\t</Ring>" >>$outfile
|
||||
done
|
||||
fi
|
||||
echo -e "</CiscoIPPhoneRingList>" >>$outfile
|
||||
|
@@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<CiscoIPPhoneRingList>
|
||||
<Ring>
|
||||
<DisplayName>drums1</DisplayName>
|
||||
|
34
tools/mkringlist.php
Normal file
34
tools/mkringlist.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
//Usage: php mkringlist.php;
|
||||
|
||||
function createCats($currDirPos){
|
||||
|
||||
$xml = '';
|
||||
|
||||
if(is_dir($currDirPos)){
|
||||
// Remove unix ./..
|
||||
foreach (array_diff(scandir($currDirPos),array('.','..')) as $subDir) {
|
||||
//remove link information
|
||||
$subDir = explode(' ', $subDir);
|
||||
$displayName = explode('.',$subDir[0]);
|
||||
$fileName = str_replace('../tftpboot/','',$currDirPos) .'/'. $subDir[0];
|
||||
if (in_array($displayName[1], array('pcm','raw'))) {
|
||||
$xml .= "<Ring><DisplayName>{$displayName[0]}</DisplayName><FileName>{$fileName}</FileName></Ring>";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function saveXml($xml, $filename) {
|
||||
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'.'<CiscoIPPhoneRingList>' . $xml . '</CiscoIPPhoneRingList>';
|
||||
$dom = new \DOMDocument("1.0");
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
$dom->loadXML($xml);
|
||||
$dom->save($filename);
|
||||
}
|
||||
|
||||
saveXml(createCats('../tftpboot/ringtones'),'../tftpboot/ringtones/ringlist.xml');
|
||||
?>
|
Reference in New Issue
Block a user