6def8c716adc9e32dab5cf4de8fd99db2e7e1a4e
2 require_once dirname(__FILE__
) . '/widget.blog.owner.php';
4 class XorgWebservice
extends dcUrlHandlers
{
5 static private function canRunServices() {
6 $addrs = explode(',', XORG_SERV_ADDRS
);
7 foreach ($addrs as $addr) {
8 if ($addr == $_SERVER['REMOTE_ADDR']) {
15 static public function handle($args) {
16 if (!self
::canRunServices()) {
17 header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
18 echo "You're not allowed to run the webservices";
24 $service = array('XorgWebservice', $args);
27 if ($service == null
) {
28 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
29 echo 'Webservice does not handle "' . $args . '"';
33 $result = $core->auth
->sudo($service);
34 if ($result['status']) {
35 header($_SERVER['SERVER_PROTOCOL'] . ' 200 Success');
37 header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
39 echo $result['message'];
43 static public function createBlog() {
45 if (!isset($_GET['owner']) ||
!isset($_GET['url']) ||
!isset($_GET['type'])) {
46 return array('status' => false
,
47 'message' => 'Missing parameters');
49 $owner = $_GET['owner'];
50 $url = rtrim($_GET['url'], '/') . '/';
51 $type = $_GET['type'];
52 if ($type != 'user' && $type != 'group-member' && $type != 'group-admin') {
53 return array('status' => false
,
54 'message' => 'Invalid blog type required');
56 if (isset($_GET['ownername'])) {
57 $ownername = $_GET['ownername'];
62 $cur = new cursor($core->con
, 'dc_blog');
63 $cur->blog_id
= $owner;
64 $cur->blog_uid
= $owner;
65 $cur->blog_url
= $url;
66 $cur->blog_name
= 'Blog de ' . $ownername;
67 $cur->blog_status
= 1;
70 $settings = new dcSettings($core, $owner);
71 $settings->system
->put('public_path', 'public/' . $owner);
72 $settings->system
->put('public_url', '/public/' . $owner);
73 $xorgauth = $settings->addNamespace('xorgauth');
74 $xorgauth->put('xorg_blog_type', $type, 'string', 'Type de blog X.org');
75 $xorgauth->put('xorg_blog_owner', $owner, 'string', 'PropriƩtaire X.org du blog');
77 return array('status' => true
,
78 'message' => 'blog created');