blob: 360f994fcb105bf5d41a92818a5b223c2056d7ce (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?php /** @file */
// import page design element
function impel_init(&$a) {
$ret = array('success' => false);
if(! $local_user())
json_return_and_die($ret);
$elm = $_REQUEST['element'];
$x = base64_urldecode($elm);
if(! $x)
json_return_and_die($ret);
$j = json_decode($x,true);
if(! $j)
json_return_and_die($ret);
$channel = get_channel();
$arr = array();
switch($j['type']) {
case 'webpage':
$arr['item_restrict'] = ITEM_WEBPAGE;
break;
case 'block':
$arr['item_restrict'] = ITEM_BUILDBLOCK;
break;
case 'layout':
$arr['item_restrict'] = ITEM_PDL;
break;
default:
logger('mod_impel: unrecognised element type' . print_r($j,true));
break;
}
$arr['uid'] = local_user();
$arr['aid'] = $channel['channel_account_id'];
$arr['title'] = $j['title'];
$arr['body'] = $j['body'];
$arr['term'] = $j['term'];
$arr['owner_xchan'] = get_observer_hash();
$arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : $get_observer_hash());
$arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode');
$channel = get_channel();
// Verify ability to use html or php!!!
$execflag = false;
if($arr['mimetype'] === 'application/x-php') {
$z = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
intval(local_user())
);
if($z && ($z[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) {
$execflag = true;
}
}
$x = item_store($arr,$execflag);
$ret['success'] = true;
json_return_and_die(true);
}
|