Changeset 6555
- Timestamp:
- 09/04/08 00:00:26 (3 months ago)
- Files:
-
- modules/branches/2.5/music/functions.inc.php (modified) (2 diffs)
- modules/branches/2.5/music/page.music.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.5/music/functions.inc.php
r4914 r6555 2 2 3 3 function music_list($path) { 4 global $amp_conf;5 4 $i = 1; 6 5 $arraycount = 0; … … 33 32 function music_rmdirr($dirname) 34 33 { 35 // Sanity check36 if (!file_exists($dirname)) {37 print "$dirname Doesn't exist\n";38 return false;39 }34 // Sanity check 35 if (!file_exists($dirname)) { 36 print "$dirname Doesn't exist\n"; 37 return false; 38 } 40 39 41 // Simple delete for a file42 if (is_file($dirname)) {43 return unlink($dirname);44 }40 // Simple delete for a file 41 if (is_file($dirname)) { 42 return unlink($dirname); 43 } 45 44 46 // Loop through the folder47 $dir = dir($dirname);48 while (false !== $entry = $dir->read()) {49 // Skip pointers50 if ($entry == '.' || $entry == '..') {51 continue;52 }45 // Loop through the folder 46 $dir = dir($dirname); 47 while (false !== $entry = $dir->read()) { 48 // Skip pointers 49 if ($entry == '.' || $entry == '..') { 50 continue; 51 } 53 52 54 // Recurse55 music_rmdirr("$dirname/$entry");56 }53 // Recurse 54 music_rmdirr("$dirname/$entry"); 55 } 57 56 58 // Clean up59 $dir->close();60 return rmdir($dirname);57 // Clean up 58 $dir->close(); 59 return rmdir($dirname); 61 60 } 62 61 modules/branches/2.5/music/page.music.php
r6303 r6555 21 21 $display='music'; 22 22 23 global $a sterisk_conf;23 global $amp_conf; 24 24 25 25 if ($category == "default") { 26 $path_to_dir = $a sterisk_conf['astvarlibdir']."/mohmp3"; //path to directory u want to read.26 $path_to_dir = $amp_conf['ASTVARLIBDIR']."/mohmp3"; //path to directory u want to read. 27 27 } else { 28 $path_to_dir = $a sterisk_conf['astvarlibdir']."/mohmp3/$category"; //path to directory u want to read.28 $path_to_dir = $amp_conf['ASTVARLIBDIR']."/mohmp3/$category"; //path to directory u want to read. 29 29 } 30 30 … … 33 33 touch($path_to_dir."/.random"); 34 34 createmusicconf(); 35 needreload(); 35 36 } 36 37 if (strlen($randoff)) { 37 38 unlink($path_to_dir."/.random"); 38 39 createmusicconf(); 40 needreload(); 39 41 } 40 42 switch ($action) { 43 case "addednewstream": 44 case "editednewstream": 45 $stream = isset($_REQUEST['stream'])?$_REQUEST['stream']:''; 46 makestreamcatergory($path_to_dir,$stream); 47 createmusicconf(); 48 needreload(); 49 redirect_standard(); 41 50 case "addednew": 42 makemusiccategory($path_to_dir ,$category);51 makemusiccategory($path_to_dir); 43 52 createmusicconf(); 44 53 needreload(); … … 51 60 break; 52 61 case "delete": 62 //$fh = fopen("/tmp/music.log","a"); 63 //fwrite($fh,print_r($_REQUEST,true)); 53 64 music_rmdirr("$path_to_dir"); 54 $path_to_dir = $a sterisk_conf['astvarlibdir']."/mohmp3"; //path to directory u want to read.65 $path_to_dir = $amp_conf['ASTVARLIBDIR']."/mohmp3"; //path to directory u want to read. 55 66 $category='default'; 56 67 createmusicconf(); … … 65 76 <div class="rnav"><ul> 66 77 <li><a href="config.php?display=<?php echo urlencode($display)?>&action=add"><?php echo _("Add Music Category")?></a></li> 78 <li><a href="config.php?display=<?php echo urlencode($display)?>&action=addstream"><?php echo _("Add Streaming Category")?></a></li> 67 79 68 80 <?php 69 81 //get existing trunk info 70 $tresults = music_list($a sterisk_conf['astvarlibdir']."/mohmp3");82 $tresults = music_list($amp_conf['ASTVARLIBDIR']."/mohmp3"); 71 83 if (isset($tresults)) { 72 84 foreach ($tresults as $tresult) { … … 82 94 <?php 83 95 function createmusicconf() { 84 global $asterisk_conf;85 96 global $amp_conf; 86 97 87 98 $File_Write=""; 88 $tresults = music_list($a sterisk_conf['astvarlibdir']."/mohmp3");99 $tresults = music_list($amp_conf['ASTVARLIBDIR']."/mohmp3"); 89 100 if (isset($tresults)) { 90 101 foreach ($tresults as $tresult) { … … 98 109 } 99 110 if ($tresult != "default" ) { 100 $dir = $a sterisk_conf['astvarlibdir']."/mohmp3/{$tresult}/";111 $dir = $amp_conf['ASTVARLIBDIR']."/mohmp3/{$tresult}/"; 101 112 } else { 102 $dir = $asterisk_conf['astvarlibdir']."/mohmp3/"; 103 } 104 if (file_exists("{$dir}.random")) { 113 $dir = $amp_conf['ASTVARLIBDIR']."/mohmp3/"; 114 } 115 if (file_exists("{$dir}.custom")) { 116 $application = file_get_contents("{$dir}.custom"); 117 $File_Write.="[{$tresult}]\nmode=custom\napplication=$application\n"; 118 } else if (file_exists("{$dir}.random")) { 105 119 $File_Write.="[{$tresult}]\nmode=files\ndirectory={$dir}\nrandom=yes\n"; 106 120 } else { … … 119 133 120 134 fclose($handle); 121 122 needreload(); 123 } 124 125 function makemusiccategory($category) { 126 mkdir("$path_to_dir/$category", 0755); 135 } 136 137 function makestreamcatergory($path_to_dir,$stream) { 138 if (!is_dir($path_to_dir)) { 139 makemusiccategory($path_to_dir); 140 } 141 $fh=fopen("$path_to_dir/.custom","w"); 142 fwrite($fh,$stream); 143 fclose($fh); 144 } 145 146 function makemusiccategory($path_to_dir) { 147 mkdir("$path_to_dir", 0755); 127 148 } 128 149 … … 289 310 290 311 <?php 312 } else if ($action == 'addstream') { 313 ?> 314 <form name="addstream" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return addstream_onsubmit();"> 315 <input type="hidden" name="display" value="<?php echo $display?>"> 316 <input type="hidden" name="action" value="addednewstream"> 317 <table> 318 <tr><td colspan="2"><h5><?php echo _("Add Streaming Category")?><hr></h5></td></tr> 319 <tr> 320 <td><a href="#" class="info"><?php echo _("Category Name:")?><span><?php echo _("Allows you to Set up Different Categories for music on hold. This is useful if you would like to specify different Hold Music or Commercials for various ACD Queues.")?> </span></a></td> 321 <td><input type="text" name="category" value=""></td> 322 </tr> 323 <tr> 324 <td><a href="#" class="info"><?php echo _("Application:")?><span><?php echo _("This is the \"application=\" line used to provide the streaming details to Asterisk. See information on musiconhold.conf configuration for different audio and internet streaming source options.")?> </span></a></td> 325 <td><input type="text" name="stream" size="80" value=""></td> 326 </tr> 327 <tr> 328 <td colspan="2"><br><h6><input name="Submit" type="submit" value='<?php echo _("Submit Changes")?>' ></h6></td> 329 </tr> 330 </table> 331 <script language="javascript"> 332 <!-- 333 334 var theForm = document.addstream; 335 theForm.category.focus(); 336 337 function addstream_onsubmit() { 338 var msgInvalidCategoryName = "<?php echo _('Please enter a valid Category Name'); ?>"; 339 var msgInvalidStreamName = "<?php echo _('Please enter a streaming application command and arguments'); ?>"; 340 var msgReservedCategoryName = "<?php echo _('Categories: \"none\" and \"default\" are reserved names. Please enter a different name'); ?>"; 341 342 defaultEmptyOK = false; 343 if (!isAlphanumeric(theForm.category.value)) 344 return warnInvalid(theForm.category, msgInvalidCategoryName); 345 if (theForm.category.value == "default" || theForm.category.value == "none") 346 return warnInvalid(theForm.category, msgReservedCategoryName); 347 if (isEmpty(theForm.stream.value)) 348 return warnInvalid(theForm.stream, msgInvalidStreamName); 349 350 return true; 351 } 352 353 //--> 354 </script> 355 356 </form> 357 <br><br><br><br><br> 358 359 <?php 291 360 } else { 292 361 ?> … … 294 363 <h5><?php echo _("Category:")?> <?php echo $category=="default"?_("default"):$category;?></h5> 295 364 <?php 365 if (file_exists("{$path_to_dir}/.custom")) { 366 $application = file_get_contents("{$path_to_dir}/.custom"); 367 } else { 368 $application = false; 369 } 296 370 if ($category!="default") { 297 $delURL = $_SERVER['PHP_SELF'].'?d splay='.urlencode($display).'&action=delete&category='.urlencode($category);298 $tlabel = sprintf( _("Delete Music Category %s"),$category);371 $delURL = $_SERVER['PHP_SELF'].'?display='.urlencode($display).'&action=delete&category='.urlencode($category); 372 $tlabel = sprintf(($application === false)?_("Delete Music Category %s"):_("Delete Streaming Category"),$category); 299 373 $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/core_delete.png"/> '.$tlabel.'</span>'; 300 374 ?> … … 302 376 <?php 303 377 } 378 if ($application !== false) { 379 ?> 380 <form name="editstream" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return editstream_onsubmit();"> 381 <input type="hidden" name="display" value="<?php echo $display?>"> 382 <input type="hidden" name="action" value="editednewstream"> 383 <table> 384 <tr><td colspan="2"><h5><?php echo _("Edit Streaming Category").": $category"?><hr></h5></td></tr> 385 <tr> 386 <td><a href="#" class="info"><?php echo _("Application:")?><span><?php echo _("This is the \"application=\" line used to provide the streaming details to Asterisk. See information on musiconhold.conf configuration for different audio and internet streaming source options.")?> </span></a></td> 387 <td><input type="text" name="stream" size="80" value="<?php echo $application?>"></td> 388 </tr> 389 <tr> 390 <td colspan="2"><br><h6><input name="Submit" type="submit" value='<?php echo _("Submit Changes")?>' ></h6></td> 391 </tr> 392 </table> 393 <script language="javascript"> 394 <!-- 395 396 var theForm = document.editstream; 397 theForm.stream.focus(); 398 399 function editstream_onsubmit() { 400 var msgInvalidStreamName = "<?php echo _('Please enter a streaming application command and arguments'); ?>"; 401 402 defaultEmptyOK = false; 403 if (isEmpty(theForm.stream.value)) 404 return warnInvalid(theForm.stream, msgInvalidStreamName); 405 406 return true; 407 } 408 //--> 409 </script> 410 411 </form> 412 <br><br><br><br><br> 413 414 <?php 415 } else { // normal moh dir 304 416 ?> 305 417 … … 376 488 $file_array = build_list(); 377 489 $numf = count($file_array); 490 } // normal moh dir 378 491 379 492 … … 396 509 } 397 510 } 398 $file_array = build_list(); 399 draw_list($file_array, $path_to_dir, $category); 511 if ($application === false) { 512 $file_array = build_list(); 513 draw_list($file_array, $path_to_dir, $category); 514 } 400 515 ?> 401 516 <br><br><br><br><br><br>
