Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F442602
DarkConsoleDataController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DarkConsoleDataController.php
View Options
<?php
final
class
DarkConsoleDataController
extends
PhabricatorController
{
private
$key
;
public
function
shouldRequireLogin
()
{
return
!
PhabricatorEnv
::
getEnvConfig
(
'darkconsole.always-on'
);
}
public
function
shouldRequireEnabledUser
()
{
return
!
PhabricatorEnv
::
getEnvConfig
(
'darkconsole.always-on'
);
}
public
function
shouldAllowPartialSessions
()
{
return
true
;
}
public
function
willProcessRequest
(
array
$data
)
{
$this
->
key
=
$data
[
'key'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$cache
=
new
PhabricatorKeyValueDatabaseCache
();
$cache
=
new
PhutilKeyValueCacheProfiler
(
$cache
);
$cache
->
setProfiler
(
PhutilServiceProfiler
::
getInstance
());
$result
=
$cache
->
getKey
(
'darkconsole:'
.
$this
->
key
);
if
(!
$result
)
{
return
new
Aphront400Response
();
}
$result
=
json_decode
(
$result
,
true
);
if
(!
is_array
(
$result
))
{
return
new
Aphront400Response
();
}
if
(
$result
[
'vers'
]
!=
DarkConsoleCore
::
STORAGE_VERSION
)
{
return
new
Aphront400Response
();
}
if
(
$result
[
'user'
]
!=
$user
->
getPHID
())
{
return
new
Aphront400Response
();
}
$output
=
array
();
$output
[
'tabs'
]
=
$result
[
'tabs'
];
$output
[
'panel'
]
=
array
();
foreach
(
$result
[
'data'
]
as
$class
=>
$data
)
{
try
{
$obj
=
newv
(
$class
,
array
());
$obj
->
setData
(
$data
);
$obj
->
setRequest
(
$request
);
$panel
=
$obj
->
renderPanel
();
// Because cookie names can now be prefixed, wipe out any cookie value
// with the session cookie name anywhere in its name.
$pattern
=
'('
.
preg_quote
(
PhabricatorCookies
::
COOKIE_SESSION
).
')'
;
foreach
(
$_COOKIE
as
$cookie_name
=>
$cookie_value
)
{
if
(
preg_match
(
$pattern
,
$cookie_name
))
{
$panel
=
PhutilSafeHTML
::
applyFunction
(
'str_replace'
,
$cookie_value
,
'(session-key)'
,
$panel
);
}
}
$output
[
'panel'
][
$class
]
=
$panel
;
}
catch
(
Exception
$ex
)
{
$output
[
'panel'
][
$class
]
=
'error'
;
}
}
return
id
(
new
AphrontAjaxResponse
())->
setContent
(
$output
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 9:13 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
60537
Default Alt Text
DarkConsoleDataController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment