record_path.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2018
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //settings
  22. $domain_name = '*';
  23. $year = '2018';
  24. $type = 'wav'; //wav or mp3
  25. $execute_sql = true;
  26. $document_root = '/var/www/fusionpbx';
  27. //web server or command line
  28. if(defined('STDIN')) {
  29. set_include_path($document_root);
  30. $_SERVER["DOCUMENT_ROOT"] = $document_root;
  31. $project_path = $_SERVER["DOCUMENT_ROOT"];
  32. define('PROJECT_PATH', $project_path);
  33. $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
  34. set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
  35. require_once "resources/require.php";
  36. $display_type = 'text'; //html, text
  37. }
  38. else {
  39. include "root.php";
  40. require_once "resources/require.php";
  41. require_once "resources/pdo.php";
  42. }
  43. //get the uuid recordings and update the information in the database
  44. $recordings = glob($_SESSION['switch']['recordings']['dir'].'/'.$domain_name.'/archive/'.$year.'/*/*/*.'.$type);
  45. foreach($recordings as $path) {
  46. //get the details from the path
  47. $parts = pathinfo($path);
  48. $record_path = $parts['dirname'];
  49. $record_name = $parts['basename'];
  50. $uuid = $parts['filename'];
  51. $extension = $parts['extension'];
  52. //update the database
  53. if (is_uuid($uuid)) {
  54. $sql = "update v_xml_cdr set ";
  55. $sql .= "record_path = '".$record_path."', ";
  56. $sql .= "record_name = '".$record_name."' ";
  57. $sql .= "where uuid = '".$uuid."';\n";
  58. if ($execute_sql) {
  59. $db->exec($sql);
  60. }
  61. echo $sql."\n";
  62. }
  63. }
  64. //send a message
  65. if ($execute_sql) {
  66. echo "\n";
  67. echo "-- The following SQL command have been executed.\n";
  68. }
  69. else {
  70. echo "\n";
  71. echo "-- Run the SQL commands on the database server.\n";
  72. }
  73. //include the footer
  74. if(!defined('STDIN')) {
  75. require_once "resources/footer.php";
  76. }
  77. ?>