Esempio n. 1
0
 function generateConf()
 {
     global $amp_conf;
     global $version;
     //asterisk version
     $path_to_moh_dir = $amp_conf['ASTVARLIBDIR'] . '/' . $amp_conf['MOHDIR'];
     $output = "";
     $File_Write = "";
     $tresults = music_list();
     if (isset($tresults)) {
         if (version_compare($version, "1.6.0", "ge")) {
             $random = "sort=random\n";
             $alpha = "sort=alpha\n";
         } else {
             $random = "random=yes\n";
             $alpha = "";
         }
         foreach ($tresults as $tresult) {
             // hack - but his is all a hack until redone, in functions, etc.
             // this puts a none category to allow no music to be chosen
             //
             if ($tresult == "none") {
                 $dir = $path_to_moh_dir . "/.nomusic_reserved";
                 if (!is_dir($dir)) {
                     music_makemusiccategory($dir);
                 }
                 touch($dir . "/silence.wav");
             } elseif ($tresult != "default") {
                 $dir = $path_to_moh_dir . "/{$tresult}/";
             } else {
                 $dir = $path_to_moh_dir . '/';
             }
             if (file_exists("{$dir}.custom")) {
                 $application = file_get_contents("{$dir}.custom");
                 $File_Write .= "[{$tresult}]\nmode=custom\napplication={$application}\n";
             } else {
                 if (file_exists("{$dir}.random")) {
                     $File_Write .= "[{$tresult}]\nmode=files\ndirectory={$dir}\n{$random}";
                 } else {
                     $File_Write .= "[{$tresult}]\nmode=files\ndirectory={$dir}\n{$alpha}";
                 }
             }
         }
     }
     return $File_Write;
 }
Esempio n. 2
0
function makestreamcatergory($path_to_dir, $stream)
{
    if (!is_dir($path_to_dir)) {
        music_makemusiccategory($path_to_dir);
    }
    $fh = fopen("{$path_to_dir}/.custom", "w");
    fwrite($fh, $stream);
    fclose($fh);
}