Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
2aca132f
Commit
2aca132f
authored
16 years ago
by
Michael Klier
Browse files
Options
Downloads
Patches
Plain Diff
XML-RPC: added putAttachment()
darcs-hash:20080713165645-23886-2caca899a42016be8df0797b21d1adef70544cc4.gz
parent
26bec61e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/exe/xmlrpc.php
+109
-13
109 additions, 13 deletions
lib/exe/xmlrpc.php
with
109 additions
and
13 deletions
lib/exe/xmlrpc.php
+
109
−
13
View file @
2aca132f
...
...
@@ -123,12 +123,18 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
array
(
'struct'
,
'int'
),
'Returns a strukt about all recent changes since given timestamp.'
);
$this
->
addCallback
(
'wiki.aclCheck'
,
'this:aclCheck'
,
array
(
'struct'
,
'string'
),
'Returns the permissions of a given wiki page.'
);
$this
->
addCallback
(
'wiki.aclCheck'
,
'this:aclCheck'
,
array
(
'struct'
,
'string'
),
'Returns the permissions of a given wiki page.'
);
$this
->
addCallback
(
'wiki.putAttachment'
,
'this:putAttachment'
,
array
(
'struct'
,
'string'
,
'base64'
,
'struct'
),
'Upload a file to the wiki.'
);
$this
->
serve
();
}
...
...
@@ -289,12 +295,102 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
return
0
;
}
/**
* Returns the permissions of a given wiki page
*/
function
aclCheck
(
$id
)
{
return
auth_quickaclcheck
(
$id
);
}
/**
* Uploads a file to the wiki.
*
* Michael Klier <chi@chimeric.de>
*/
function
putAttachment
(
$ns
,
$file
,
$params
)
{
global
$conf
;
global
$lang
;
$auth
=
auth_quickaclcheck
(
$ns
.
':*'
);
if
(
$auth
>=
AUTH_UPLOAD
)
{
if
(
!
isset
(
$params
[
'name'
]))
{
return
new
IXR_ERROR
(
1
,
'Filename not given.'
);
}
$ftmp
=
$conf
[
'tmpdir'
]
.
'/'
.
$params
[
'name'
];
$name
=
$params
[
'name'
];
// save temporary file
@
unlink
(
$ftmp
);
$buff
=
base64_decode
(
$file
);
io_saveFile
(
$ftmp
,
$buff
);
// get filename
list
(
$iext
,
$imime
)
=
mimetype
(
$name
);
$id
=
cleanID
(
$ns
.
':'
.
$name
);
$fn
=
mediaFN
(
$id
);
// get filetype regexp
$types
=
array_keys
(
getMimeTypes
());
$types
=
array_map
(
create_function
(
'$q'
,
'return preg_quote($q,"/");'
),
$types
);
$regex
=
join
(
'|'
,
$types
);
// because a temp file was created already
if
(
preg_match
(
'/\.('
.
$regex
.
')$/i'
,
$fn
))
{
//check for overwrite
if
(
@
file_exists
(
$fn
)
&&
(
!
$params
[
'ow'
]
||
$auth
<
AUTH_DELETE
))
{
return
new
IXR_ERROR
(
1
,
$lang
[
'uploadexist'
]);
}
// check for valid content
@
require_once
(
DOKU_INC
.
'inc/media.php'
);
$ok
=
media_contentcheck
(
$ftmp
,
$imime
);
if
(
$ok
==
-
1
)
{
return
new
IXR_ERROR
(
1
,
sprintf
(
$lang
[
'uploadexist'
],
".
$iext
"
));
}
elseif
(
$ok
==
-
2
)
{
return
new
IXR_ERROR
(
1
,
$lang
[
'uploadspam'
]);
}
elseif
(
$ok
==
-
3
)
{
return
new
IXR_ERROR
(
1
,
$lang
[
'uploadxss'
]);
}
// prepare event data
$data
[
0
]
=
$ftmp
;
$data
[
1
]
=
$fn
;
$data
[
2
]
=
$id
;
$data
[
3
]
=
$imime
;
// trigger event
require_once
(
DOKU_INC
.
'inc/events.php'
);
return
trigger_event
(
'MEDIA_UPLOAD_FINISH'
,
$data
,
array
(
$this
,
'_media_upload_action'
),
true
);
}
else
{
return
new
IXR_ERROR
(
1
,
$lang
[
'uploadwrong'
]);
}
}
else
{
return
new
IXR_ERROR
(
1
,
"You don't have permissions to upload files."
);
}
}
/**
* Moves the temporary file to its final destination.
*
* Michael Klier <chi@chimeric.de>
*/
function
_media_upload_action
(
$data
)
{
global
$conf
;
if
(
is_array
(
$data
)
&&
count
(
$data
)
===
4
)
{
io_createNamespace
(
$data
[
2
],
'media'
);
if
(
rename
(
$data
[
0
],
$data
[
1
]))
{
chmod
(
$data
[
1
],
$conf
[
'fmode'
]);
media_notify
(
$data
[
2
],
$data
[
1
],
$data
[
3
]);
return
$data
[
2
];
}
else
{
return
new
IXR_ERROR
(
1
,
'Upload failed.'
);
}
}
else
{
return
new
IXR_ERROR
(
1
,
'Upload failed.'
);
}
}
/**
* Returns the permissions of a given wiki page
*/
function
aclCheck
(
$id
)
{
return
auth_quickaclcheck
(
$id
);
}
/**
* Lists all links contained in a wiki page
...
...
@@ -483,4 +579,4 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
$server
=
new
dokuwiki_xmlrpc_server
();
// vim:ts=4:sw=4:enc=utf-8:
// vim:ts=4:sw=4:
et:
enc=utf-8:
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