Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7312227
log.phtml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
log.phtml
View Options
<?php
require
'/etc/cdrtool/global.inc'
;
page_open
(
array
(
"sess"
=>
"CDRTool_Session"
,
"auth"
=>
"CDRTool_Auth"
,
"perm"
=>
"CDRTool_Perm"
)
);
$loginname
=
$auth
->
auth
[
"uname"
];
$title
=
"Logs"
;
$search_text
=
isset
(
$_REQUEST
[
'search_text'
])
?
$_REQUEST
[
'search_text'
]
:
''
;
$task
=
isset
(
$_REQUEST
[
'task'
])
?
$_REQUEST
[
'task'
]
:
''
;
$current_log
=
isset
(
$_REQUEST
[
'current_log'
])
?
$_REQUEST
[
'current_log'
]
:
''
;
$log_description
=
isset
(
$_REQUEST
[
'log_description'
])
?
$_REQUEST
[
'log_description'
]
:
''
;
$next
=
isset
(
$_REQUEST
[
'next'
])
?
intval
(
$_REQUEST
[
'next'
])
:
0
;
$maxrowsperpage
=
20
;
$PHP_SELF
=
htmlentities
(
$_SERVER
[
'PHP_SELF'
]);
$thisMonth
=
isset
(
$_REQUEST
[
'thisMonth'
])
?
$_REQUEST
[
'thisMonth'
]
:
''
;
$recipient
=
isset
(
$_REQUEST
[
'recipient'
])
?
$_REQUEST
[
'recipient'
]
:
''
;
$db
=
new
DB_CDRTool
;
if
(
is_readable
(
"/etc/cdrtool/local/header.phtml"
))
{
include
'/etc/cdrtool/local/header.phtml'
;
}
else
{
include
'header.phtml'
;
}
if
(
$search_text
)
{
$search_text
=
preg_replace
(
"/[^\d|\w| -\.@_]/s"
,
""
,
$search_text
);
}
$layout
=
new
pageLayoutLocal
();
$layout
->
showTopMenu
(
$title
);
if
(
$thisMonth
)
{
$checked_thisMonth
=
'checked'
;
}
else
{
$checked_thisMonth
=
''
;
}
$where
=
" (1=1) "
;
if
(
$CDRTool
[
'filter'
][
'reseller'
])
{
$where
.=
sprintf
(
' and reseller_id = %s'
,
addslashes
(
$CDRTool
[
'filter'
][
'reseller'
]));
}
else
if
(
!
$perm
->
have_perm
(
"admin"
))
{
$where
.=
sprintf
(
" and login = '%s'"
,
addslashes
(
$auth
->
auth
[
"uname"
]));
}
if
(
$perm
->
have_perm
(
'admin'
))
{
$query
=
"select * from auth_user where perms like '%admin%'"
;
$db
->
query
(
$query
);
while
(
$db
->
next_record
())
{
$Collegues
[
$db
->
f
(
'email'
)]
=
$db
->
f
(
'name'
);
if
(
$loginname
==
$db
->
f
(
'username'
))
{
$myEmailAddress
=
$db
->
f
(
'email'
);
$myName
=
$db
->
f
(
'name'
);
}
}
}
else
{
$Collegues
[
$CDRTool
[
'provider'
][
'toEmail'
]]
=
$CDRTool
[
'provider'
][
'name'
];
$myName
=
$CDRTool
[
"loginName"
];
$myEmailAddress
=
$CDRTool
[
"loginEmail"
];
}
if
(
$current_log
)
{
if
(
$task
==
"edit"
)
{
$query
=
sprintf
(
"update log set description = '%s' where %s and id = %d"
,
addslashes
(
$log_description
),
$where
,
intval
(
$current_log
)
);
$db
->
query
(
$query
);
}
else
if
(
$task
==
"mailLog"
&&
$recipient
)
{
$query
=
sprintf
(
"select * from log where %s and id = %d"
,
$where
,
intval
(
$current_log
)
);
$db
->
query
(
$query
);
$db
->
next_record
();
$rerun
=
$db
->
f
(
'rerun'
);
$description
=
$db
->
f
(
'description'
);
if
(
$_SERVER
[
'HTTPS'
]
==
"on"
)
{
$protocolURL
=
"https://"
;
}
else
{
$protocolURL
=
"http://"
;
}
$subject
=
"CDRTool"
;
$fullURL
=
$protocolURL
.
$_SERVER
[
'HTTP_HOST'
]
.
$CDRTool
[
'tld'
]
.
"/"
.
$rerun
;
$body
=
"CDRTool query to analyse:
\n\n
$fullURL\n\n
"
;
if
(
$description
)
{
$body
=
$body
.
"The query id
$current_log
is saved with name
\"
$description\
"
\n\n
";
$subject
=
$subject
."
:
".
$description
;
}
$body
=
$body
."
This
notification
has
been
sent
to
you
from
CDRTool
log
interface
by
$myName
";
mail(
$recipient
,
$subject
,
$body
, "
From
:
$myEmailAddress
");
print "
<
p
>
Notified
$recipient
.
";
}
}
$url_log
= array();
if (
$search_text
) {
$where
.= sprintf(
"
and
(
description
like
'%s%s%s'
or
url
like
'%s'
or
id
=
'%s'
)
",
"
%
",
addslashes(
$search_text
),
"
%
",
addslashes(
$search_text
),
addslashes(
$search_text
)
);
$url_log["search_text"]
=
$search_text
;
}
if (
$thisMonth
) {
$where
.= sprintf("
and
date
like
'%s'
", date('Y-m').'%');
$url_log["thisMonth"]
= 1;
}
$query
= sprintf("
select
count
(
*
)
as
records
from
log
where
%
s
",
$where
);
if (
$db->query
(
$query
)) {
$db->next_record
();
$rows
=
$db->f
('records');
} else {
$rows
= 0;
}
if (!
$next
) {
$i
= 0;
$next
= 0;
} else {
$i
= intval(
$next
);
}
$j
= 0;
$z
= 0;
print "
<
form
method
=
post
action
=
$PHP_SELF
>
<
table
border
=
0
align
=
center
>
<
tr
>
<
td
>
Found
$rows
records
.
</
td
>
<
td
>
<
div
class
=
'input-append'
>
<
input
class
=
span2
type
=
text
size
=
30
name
=
search_text
value
=
\
"
$search_text\
"
><
button
class
=
'btn btn-primary'
type
=
submit
value
=
Search
>
Search
</
button
></
div
>
</
td
>
<
td
>
<
input
type
=
checkbox
name
=
thisMonth
value
=
1
$checked_thisMonth
>
Only
this
month
?
</
td
>
</
tr
>
</
table
>
</
form
>
";
if (
$rows
> 0) {
if (
$rows
>
$maxrowsperpage
) {
$maxrows
=
$maxrowsperpage
+
$next
;
if (
$maxrows
>
$rows
) {
$maxrows
=
$rows
;
$prev_rows
=
$maxrows
;
}
} else {
$maxrows
=
$rows
;
}
$_max_rows
= intval(
$maxrowsperpage
);
if (!
$_max_rows
) {
$_max_rows
= 10;
}
$query
= sprintf("
select
*
from
log
where
%
s
order
by
id
desc
limit
%
d
,
%
d
",
$where
, intval(
$i
),
$_max_rows
);
$db->query
(
$query
);
print "
<
br
/>
<
table
id
=
'log'
class
=
'table table-striped table-condensed'
width
=
100
%
align
=
center
>
<
thead
>
<
tr
>
<
th
>
</
th
>
<
th
>
<
b
>
Log
id
</
th
>
<
th
>
<
b
>
Reseller
</
th
>
<
th
>
<
b
>
Date
and
time
</
th
>
<
th
>
<
b
>
Account
</
th
>
<
th
>
<
b
>
IP
address
</
th
>
<
th
>
<
b
>
Data
source
</
th
>
<
th
>
<
b
>
Rows
</
th
>
<
th
>
<
b
>
Description
</
th
>
<
th
>
<
b
>
Actions
</
th
>
</
tr
>
</
thead
>
";
while (
$i
<
$maxrows
) {
$found
=
$i
+1;
$db->next_record
();
$current_log
=
$db->f
('id');
$reseller_id
=
$db->f
('reseller_id');
$log_date
=
$db->f
('date');
$login
=
$db->f
('login');
$ip
=
$db->f
('ip');
$url
=
$db->f
('url');
$reedit
=
$db->f
('reedit');
$rerun
=
$db->f
('rerun');
$results
=
$db->f
('results');
$description
=
$db->f
('description');
$datasource
=
$db->f
('datasource');
if (
$rerun
&&
$DATASOURCES[$datasource]
['name']) {
$datasource_print
=
$DATASOURCES[$datasource]
['name'];
} else {
$datasource_print
=
$datasource
;
}
if (!
$reedit
|| !
$rerun
) {
if (preg_match("
/
do_search
/
",
$url
)) {
$url_run
= "
<
a
href
=
\
"../search_call/
$url
"
.
"&history_id=
$current_log
"
.
"
\"
>Run</a>"
;
$url_edit
=
preg_replace
(
"/do_/"
,
""
,
$url
);
$url_edit
=
"<a href=
\"
../search_call/
$url_edit\
"
>
Edit
</
a
>
";
$display_form
= 1;
} elseif (preg_match("
/
do_statistics
/
",
$url
)) {
$url_run
= "
<
a
href
=
\
"../statistics/
$url
"
.
"&history_id=
$current_log
"
.
"
\"
>Run</a>"
;
$url_edit
=
preg_replace
(
"/do_/"
,
""
,
$url
);
$url_edit
=
"<a href=
\"
../statistics/
$url_edit\
"
>
Edit
stat
</
a
>
";
$display_form
= 1;
} else {
$url_edit
= "";
$url_run
= "";
$display_form
= 0;
}
} else {
$display_form
=1;
$url_run
="
<
a
class
=
'btn'
href
=
\
"
$rerun\
"
>
Run
</
a
>
";
$url_edit
="
<
a
class
=
'btn btn-info'
href
=
\
"
$reedit\
"
>
Edit
</
a
>
";
}
$rr
= floor(
$found
/ 2);
$mod
=
$found
-
$rr
* 2;
if (
$mod
== 0) {
//
$bgcolor
="
lightgrey
";
} else {
//
$bgcolor
="
white
";
}
print "
<
tr
>
<
td
class
=
cdr
><
b
>
$found
.</
b
></
td
>
<
td
class
=
cdr
>
$current_log
</
td
>
<
td
class
=
cdr
>
$reseller_id
</
td
>
<
td
class
=
cdr
>
$log_date
</
td
>
<
td
class
=
cdr
>
$login
</
td
>
<
td
class
=
cdr
>
$ip
</
td
>
<
td
class
=
cdr
>
$datasource_print
</
td
>
<
td
class
=
cdr
>
$results
</
td
>
<
td
class
=
cdr
><
form
class
=
'cform form-inline'
method
=
post
>
";
if (
$display_form
== 1) {
print "
<
input
type
=
hidden
name
=
current_log
value
=
\
"
$current_log\
"
>
<
input
type
=
hidden
name
=
task
value
=
edit
>
<
input
type
=
hidden
name
=
next
value
=
$next
>
<
input
type
=
hidden
name
=
search_text
value
=
\
"
$search_text\
"
>
<
div
class
=
'input-append'
>
<
input
type
=
text
class
=
span2
size
=
25
name
=
log_description
value
=
\
"
$description\
"
><
button
class
=
btn
type
=
submit
value
=
Save
>
Save
</
button
>
</
div
>
";
} else {
print "
$description
";
}
print "
</
form
>
</
td
>
<
td
class
=
cdr
>
<
form
class
=
'cform form-inline'
method
=
post
>
<
div
class
=
'btn-group'
>
$url_run
$url_edit
";
if (strlen(
$description
) &&
$rerun
) {
print "
<
button
class
=
'btn'
type
=
submit
value
=
Notify
>
Notify
</
button
>
<
select
class
=
span3
name
=
recipient
>
";
foreach (array_keys(
$Collegues
) as
$col
) {
print "
<
option
value
=
\
"
$col\
"
>
$Collegues
[
$col
]
";
}
print "
</
select
>
<
input
type
=
hidden
name
=
current_log
value
=
\
"
$current_log\
"
>
<
input
type
=
hidden
name
=
task
value
=
mailLog
>
<
input
type
=
hidden
name
=
next
value
=
$next
>
<
input
type
=
hidden
name
=
search_text
value
=
\
"
$search_text\
"
>
";
}
print "
</
div
></
form
>
</
td
>
</
tr
>
";
$i
++;
}
print "
</
table
>
";
}
print "
<
ul
class
=
\
"pager
\"
>"
;
if
(
$next
!=
0
)
{
$show_next
=
$maxrowsperpage
-
$next
;
$url_log
[
'action'
]
=
"search"
;
if
(
$show_next
<
0
)
{
$url_log
[
'next'
]
=
$show_next
-
2
*
$show_next
;
}
$url_prev
=
sprintf
(
"%s?%s"
,
$PHP_SELF
,
http_build_query
(
$url_log
)
);
print
"<li><a href=
\"
$url_prev\
"
>&
larr
;
Previous
</
a
></
li
>
";
}
if (
$rows
>
$maxrowsperpage
&&
$rows
!=
$maxrows
) {
$url_log['action']
= "
search
";
$url_log['next']
=
$maxrowsperpage
+
$next
;
$url_next
= sprintf(
"
%
s
?%
s
",
$PHP_SELF
,
http_build_query(
$url_log
)
);
print "
<
li
><
a
href
=
\
"
$url_next\
"
>
Next
&
rarr
;
</
a
></
li
>
";
}
print "
</
div
>
";
$layout->showFooter
();
print "
</
body
>
</
html
>
";
page_close();
?>
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Feb 1, 5:29 AM (22 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3488519
Default Alt Text
log.phtml (9 KB)
Attached To
Mode
rCDRT CDRTool
Attached
Detach File
Event Timeline
Log In to Comment