/usr/share/yate/scripts/libvoicemail.php is in yate-scripts 5.4.0-1-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | <?php
/* libvoicemail.php
* This file is part of the YATE Project http://YATE.null.ro
*
* Voicemail access functions
*
* Yet Another Telephony Engine - a fully featured software PBX and IVR
* Copyright (C) 2004-2014 Null Team
*
* This software is distributed under multiple licenses;
* see the COPYING file in the main directory for licensing
* information for this specific distribution.
*
* This use of this software may be subject to additional restrictions.
* See the LEGAL file in the main directory for details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
require_once("libyate.php");
$vm_base = "/var/spool/voicemail";
$vm_func_for_dir = "vmDefaultGetDir";
function vmGetMessageStats($mailbox,&$total,&$unread,$type = "voicemail")
{
$o = 0;
$n = 0;
$dir = vmGetVoicemailDir($mailbox);
if (is_dir($dir) && ($d = @opendir($dir))) {
while (($f = readdir($d)) !== false) {
if (substr($f,0,4) == "nvm-") {
Yate::Debug("found new file '$f'");
$n++;
}
else if (substr($f,0,3) == "vm-") {
Yate::Debug("found old file '$f'");
$o++;
}
}
closedir($d);
}
$total = $n + $o;
$unread = $n;
}
function vmGetMessageFiles($mailbox,&$files)
{
$dir = vmGetVoicemailDir($mailbox);
if (is_dir($dir) && ($d = @opendir($dir))) {
$nf = array();
$of = array();
while (($f = readdir($d)) !== false) {
if (substr($f,0,4) == "nvm-") {
Yate::Debug("found new file '$f'");
$nf[] = $f;
}
else if (substr($f,0,3) == "vm-") {
Yate::Debug("found old file '$f'");
$of[] = $f;
}
}
closedir($d);
$files = array_merge($nf,$of);
return true;
}
return false;
}
function vmSetMessageRead($mailbox,&$file)
{
$dir = vmGetVoicemailDir($mailbox);
if (is_dir($dir) && is_file("$dir/$file")) {
if (substr($file,0,4) != "nvm-")
return false;
$newname = substr($file,1);
if (rename("$dir/$file","$dir/$newname")) {
$file = $newname;
return true;
}
}
return false;
}
function vmInitMessageDir($mailbox)
{
$dir = vmGetVoicemailDir($mailbox);
if (!is_dir($dir))
mkdir($dir,0750);
}
function vmHasMessageDir($mailbox)
{
return is_dir(vmGetVoicemailDir($mailbox));
}
function vmBuildNewFilename($caller)
{
$tmp = strftime("%Y.%m.%d-%H.%M.%S");
$tmp = "nvm-$tmp-$caller.slin";
return $tmp;
}
function vmGetVoicemailDir($called)
{
global $vm_func_for_dir;
return call_user_func($vm_func_for_dir,$called);
}
function vmDefaultGetDir($called)
{
global $vm_base;
return "$vm_base/$called";
}
/* vi: set ts=8 sw=4 sts=4 noet: */
|