Changeset 1406

Show
Ignore:
Timestamp:
04/09/06 00:06:32 (7 years ago)
Author:
qldrob
Message:

Added 'random' option, only works on non default ohm

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/htdocs/admin/modules/music/page.music.php

    r1201 r1406  
    1515<?php 
    1616$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; 
     17$randon = isset($_REQUEST['randon'])?$_REQUEST['randon']:''; 
     18$randoff = isset($_REQUEST['randoff'])?$_REQUEST['randoff']:''; 
    1719$category = strtr(isset($_REQUEST['category'])?$_REQUEST['category']:''," ", "-"); 
    1820if ($category == null) $category = 'Default'; 
     
    2426  $path_to_dir = "/var/lib/asterisk/mohmp3/$category"; //path to directory u want to read. 
    2527 
     28if (strlen($randon)) { 
     29  touch($path_to_dir."/.random"); 
     30  createmusicconf(); 
     31} 
     32if (strlen($randoff)) { 
     33  unlink($path_to_dir."/.random"); 
     34  createmusicconf(); 
     35} 
    2636switch ($action) { 
    2737  case "addednew": 
     
    6878  $tresults = music_list("/var/lib/asterisk/mohmp3"); 
    6979  if (isset($tresults)) { 
    70     foreach ($tresults as $tresult)  
    71       $File_Write.="[{$tresult}]\nmode=files\ndirectory=/var/lib/asterisk/mohmp3/{$tresult}\n"; 
    72   } 
    73  
    74 $handle = fopen("/etc/asterisk/musiconhold_additional.conf", "w"); 
    75  
    76 if (fwrite($handle, $File_Write) === FALSE) 
    77 
    78         echo _("Cannot write to file")." ($tmpfname)"; 
    79         exit; 
    80 
    81  
    82 fclose($handle); 
    83  
    84  
    85 
     80    foreach ($tresults as $tresult)  { 
     81      $dir = "/var/lib/asterisk/mohmp3/{$tresult}/"; 
     82      if (file_exists("{$dir}.random")) { 
     83        $File_Write.="[{$tresult}]\nmode=files\ndirectory={$dir}\nrandom=yes\n"; 
     84      } else { 
     85        $File_Write.="[{$tresult}]\nmode=files\ndirectory={$dir}{$tresult}\n"; 
     86      } 
     87    } 
     88  } 
     89 
     90  $handle = fopen("/etc/asterisk/musiconhold_additional.conf", "w"); 
     91 
     92  if (fwrite($handle, $File_Write) === FALSE) { 
     93    echo _("Cannot write to file")." ($tmpfname)"; 
     94    exit; 
     95  } 
     96 
     97  fclose($handle); 
     98 
     99  needreload(); 
     100
     101 
    86102function makemusiccategory($category) 
    87103{ 
     
    227243    <input type="button" value="<?php echo _("Upload")?>" onclick="document.upload.submit(upload);alert('<?php echo _("Please wait until the page loads. Your file is being processed.")?>');"/> 
    228244  </form> 
    229    
    230    
     245  <br /> 
     246  <form name="randomon" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> 
     247  <?php  
     248    if ($category != "Default") { 
     249      if (file_exists("{$path_to_dir}/.random")) { 
     250        ?> <input type="submit" name="randoff" value="Disable Random Play"> <?php 
     251      } else { 
     252        ?> <input type="submit" name="randon" value="Enable Random Play"> <?php 
     253      } 
     254    } 
     255  ?> 
     256  </form> 
     257  <br /> 
    231258  <?php 
    232259 
     
    265292} 
    266293?> 
     294