Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vikm-rserve
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ViKM-Group
vikm-rserve
Commits
7fe93cb9
Commit
7fe93cb9
authored
Dec 22, 2016
by
Robin Liechti
Browse files
Options
Downloads
Patches
Plain Diff
modifications...
parent
553cfaf3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
FastRWeb/web.R/Rdemo.R
+5
-6
5 additions, 6 deletions
FastRWeb/web.R/Rdemo.R
FastRWebPHP/R.php
+40
-0
40 additions, 0 deletions
FastRWebPHP/R.php
FastRWeb_config.php
+6
-0
6 additions, 0 deletions
FastRWeb_config.php
Rdemo.RData
+0
-0
0 additions, 0 deletions
Rdemo.RData
rserve.js
+29
-25
29 additions, 25 deletions
rserve.js
with
80 additions
and
31 deletions
FastRWeb/web.R/Rdemo.R
+
5
−
6
View file @
7fe93cb9
run
<-
function
(
samples
,
...
)
{
run
<-
function
(
nb
=
5
,
...
)
{
oclear
();
row
<-
fromJSON
(
URLdecode
(
samples
),
simplifyMatrix
=
FALSE
)
col
<-
colnames
(
patient
);
dat
<-
patient
[
1
:
row
,]
l
<-
list
(
data
=
dat
,
cols
=
col
,
nbPages
=
3
)
nb
<-
as.numeric
(
nb
);
col
<-
colnames
(
expData
);
sub
<-
expData
[
1
:
nb
,]
l
<-
list
(
data
=
sub
,
headers
=
col
)
out
(
toJSON
(
l
))
done
()
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
FastRWebPHP/R.php
+
40
−
0
View file @
7fe93cb9
...
...
@@ -5,6 +5,26 @@ require_once $_SERVER["DOCUMENT_ROOT"].'/../conf/FastRWeb_config.php';
require_once
$_SERVER
[
"DOCUMENT_ROOT"
]
.
'/../tools/include.php'
;
require
RSERVE_PHPFW
.
'/Connection.php'
;
if
(
!
isset
(
$_SERVER
[
'PHP_AUTH_USER'
]))
{
header
(
'WWW-Authenticate: Basic realm="My Realm"'
);
header
(
'HTTP/1.0 401 Unauthorized'
);
exit
;
}
else
{
$login
=
$_SERVER
[
'PHP_AUTH_USER'
];
$code
=
$_SERVER
[
'PHP_AUTH_PW'
];
$user
=
$GLOBALS
[
'DB'
]
->
get
(
"users"
,
array
(
'user_id'
,
'is_active'
,
'is_admin'
),
array
(
'AND'
=>
array
(
'login'
=>
$login
,
'code'
=>
$code
)));
if
(
!
$user
)
throw
new
Exception
(
'Invalid username and / or password'
,
501
);
if
(
$user
[
'is_active'
]
==
'N'
&&
urldecode
(
$req
->
getPathInfo
())
!==
'/user/'
.
base64_encode
(
$login
.
":"
.
$code
)){
header
(
'WWW-Authenticate: Basic realm="My Realm"'
);
header
(
'HTTP/1.0 401 Unauthorized'
);
exit
;
}
}
$root
=
RSERVE_FASTRWEB
;
// set to the root of your FastRWeb installation - must be absolute
function
process_FastRWeb
()
{
...
...
@@ -19,6 +39,26 @@ function process_FastRWeb() {
if
(
count
(
$sp_path
)
==
2
)
$sp_path
[
2
]
=
""
;
$sID
=
$sp_path
[
1
];
$path
=
"/"
.
$sp_path
[
2
];
// Verify permissions for loading data
if
(
$path
==
'/load_data'
){
if
(
preg_match
(
"/project_(\d+)\/dataset_(\d+)\//"
,
$_GET
[
'file'
],
$matches
)){
$project_id
=
$matches
[
1
];
$dataset_id
=
$matches
[
2
];
require
__DIR__
.
"/../../htdocs/api/datasets.php"
;
if
(
!
check_dataset_permissions
(
$dataset_id
,
$user_id
,
1
)){
header
(
'WWW-Authenticate: Basic realm="My Realm"'
);
header
(
'HTTP/1.0 401 Unauthorized'
);
exit
;
}
}
else
{
error_log
(
'path unvalid'
);
header
(
'WWW-Authenticate: Basic realm="My Realm"'
);
header
(
'HTTP/1.0 401 Unauthorized'
);
exit
;
}
}
}
elseif
(
preg_match
(
'/newskt/'
,
$sp_path
[
1
]))
{
// Client kindly asks for a new socket
try
{
...
...
This diff is collapsed.
Click to expand it.
FastRWeb_config.php
0 → 100644
+
6
−
0
View file @
7fe93cb9
<?php
define
(
'RSERVE_HOST'
,
$_SERVER
[
"DOCUMENT_ROOT"
]
.
'/../tools/socketeer'
);
define
(
'RSERVE_PORT'
,
0
);
define
(
'RSERVE_PHPFW'
,
$_SERVER
[
"DOCUMENT_ROOT"
]
.
'/../tools/FastRWebPHP/'
);
define
(
'RSERVE_FASTRWEB'
,
$_SERVER
[
"DOCUMENT_ROOT"
]
.
'/../tools/FastRWeb/'
);
?>
This diff is collapsed.
Click to expand it.
Rdemo.RData
+
0
−
0
View file @
7fe93cb9
No preview for this file type
This diff is collapsed.
Click to expand it.
rserve.js
+
29
−
25
View file @
7fe93cb9
...
...
@@ -43,6 +43,8 @@
};
var
serverRoot
=
ENV
.
serverURL
.
split
(
'
api
'
)[
0
]
+
"
R/
"
;
// function to start a new connection to RServe. Register a new socket with socketeer and get it's ID. It will then keeps the socket alive with $interval call.
function
start
(){
return
$http
.
get
(
serverRoot
+
"
newskt
"
).
then
(
function
successCallback
(
data
)
{
...
...
@@ -59,26 +61,28 @@
}
// function to keep the socket alive. Otherwise, the socket dies after 120 seconds (default)
function
keepAlive
(){
if
(
!
service
.
socketeerID
)
start
();
return
$http
.
get
(
serverRoot
+
service
.
socketeerID
);
}
// function to load the data in the R session.
function
loadData
(
dataPath
){
if
(
!
service
.
socketeerID
)
toastr
.
error
(
"
No connection to RServe
"
);
else
{
return
$http
.
get
(
serverRoot
+
"
/
"
+
service
.
socketeerID
+
"
/load_data?file=
"
+
dataPath
).
then
(
function
(
data
){
});
return
$http
.
get
(
serverRoot
+
"
/
"
+
service
.
socketeerID
+
"
/load_data?file=
"
+
dataPath
);
}
}
function
Rdemo
(
samples
){
// example of an R function to query a dataset
function
Rdemo
(
nb
){
if
(
!
service
.
socketeerID
)
toastr
.
error
(
"
No connection to RServe
"
);
else
{
var
url
=
serverRoot
+
"
/
"
+
service
.
socketeerID
+
"
/Rdemo
"
;
// if(samples) url += "&samples="+samples
if
(
samples
&&
samples
!=
'
[]
'
)
url
+=
"
?samples=
"
+
samples
;
if
(
nb
)
url
+=
"
?nb=
"
+
nb
;
return
$http
.
get
(
url
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment