This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
functions.php
131 lines (116 loc) · 3.35 KB
/
functions.php
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
122
123
124
125
126
127
128
129
130
131
<?php
session_start();
require "config.inc.php";
putenv('LC_ALL=' + HYLAFAX_LANG);
if (setlocale(LC_ALL, HYLAFAX_LANG) === FALSE) {
die("Locale " + HYLAFAX_LANG + " not available on this system");
}
bindtextdomain("hylafax", "./locale");
bind_textdomain_codeset("hylafax", "UTF-8");
textdomain("hylafax");
function errMsg($errmsg, $to) {
$_SESSION["errmsg"] = $errmsg;
header("Location: $to");
die();
}
function infoMsg($msg, $to) {
$_SESSION["infomsg"] = $msg;
header("Location: $to");
die();
}
function getAllNumbers() {
$numbers = array();
$d = dir(HYLAFAX_ROOT . "etc/");
while (false !== ($entry = $d->read())) {
if(preg_match("/^config\\.tty(x[0-9]+)/", $entry, $matches)) {
$output = "";
$modem = "tty" . $matches[1];
$faxnumber = exec("cat ".HYLAFAX_ROOT."etc/config.$modem | grep FAXNumber | awk -F' ' '{ print $2 }'", $output);
$localidentifier = exec("cat ".HYLAFAX_ROOT."etc/config.$modem | grep LocalIdentifier | awk -F' ' '{ print $2 }'", $output);
$numbers[$modem] = $localidentifier;
}
}
return $numbers;
}
function getDoneq($inqueue=false) {
$ret = array();
$folder = $inqueue ? "sendq/" : "doneq/";
$d = dir(HYLAFAX_ROOT . $folder);
while (false !== ($entry = $d->read())) {
if(preg_match("/^q[0-9]+$/", $entry)) {
$rows = explode("\n", file_get_contents(HYLAFAX_ROOT . $folder . $entry));
$infos = array();
foreach($rows as $r) {
if(trim($r) == "") continue;
list($k, $v) = explode(":", $r, 2);
if(HYLAFAX_REPLACEZERO && ($k == "number" || $k == "external")) {
$v = preg_replace("/^0/", "", $v);
}
$infos[$k] = $v;
if($k == "state") {
switch(intval($v)) {
case 1:
$infos["state_string"] = _("sospeso");
break;
case 2:
$infos["state_string"] = _("in coda per l'invio");
break;
case 3:
$infos["state_string"] = _("in attesa");
break;
case 4:
$infos["state_string"] = _("bloccato");
break;
case 5:
$infos["state_string"] = _("pronto per l'invio");
break;
case 6:
$infos["state_string"] = _("invio in corso");
break;
case 7:
$infos["state_string"] = _("invio completato");
break;
case 8:
$infos["state_string"] = _("invio fallito");
break;
}
}
}
$ret[$infos["jobid"]] = $infos;
}
}
krsort($ret);
return $ret;
}
function getRecvq() {
$ret = array();
$d = dir(HYLAFAX_ROOT . "recvq/");
while (false !== ($entry = $d->read())) {
if($entry == "seqf") continue;
$fname = HYLAFAX_ROOT . "recvq/$entry";
$infos = `/usr/sbin/faxinfo -c "," $fname`;
if(preg_match("/corrupted/", $infos)) continue;
list($fname, $sender, $pages, $quality, $pagetype, $received, $ttr, $sr, $df, $ec) = explode(",", $infos);
$id = intval(preg_replace("/^fax([0-9]+)\\.tif$/", "\\1", basename($fname)));
if($sender == "" || $sender == "<UNSPECIFIED>") {
$sender = _("Anonimo");
}
if(HYLAFAX_REPLACEZERO) {
$sender = preg_replace("/^0/", "", $sender);
}
$ret[$id] = array(
"id" => $id,
"sender" => $sender,
"pages" => $pages,
"quality" => $quality,
"pagetype" => $pagetype,
"received" => $received,
"ttr" => $ttr,
"sr" => $sr,
"df " => $df,
"ec" => $ec
);
}
krsort($ret);
return $ret;
}