summaryrefslogtreecommitdiffstats
path: root/pages/content/Pages:Privs.xml
blob: fd8658e7f797a6b8a138920faa91189f4309cdd2 (plain)
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
<?xml version="1.0" encoding="UTF-8" ?>
<page>
  <info>
    <name>Pages:Privs</name>
    <template>phpexec</template>
    <access>0:0</access>
    <type>c</type>
  </info>
  <data>
    <code>
      <![CDATA[
<?PHP
  Uses('pages', 'links', 'util');
  
  
  if($_POST['type'] != 'c' && $_POST['type'] != 'n' && $_POST['type'] != 'e')
    exit();
  
  if($_POST['back']) {
    header('Location: ' . $GLOBALS['links']->GetNeonLink('Pages', 'type=' . $_POST['type'], false));
    exit();
  }
  
  if(!$_POST['name']) exit();
  
  $groups = $GLOBALS['user']->ListGroups();
  array_unshift($groups, array(0));
  
  $group_max = $groups[count($groups)-1][0];
  
  $readaccess = implode('', array_fill(0, $group_max/4 + 1, '0'));
  $writeaccess = $readaccess;
    
  foreach($groups as $group) {
    if(!isset($_POST['group_' . $group[0]])) exit();
    
    switch($_POST['group_' . $group[0]]) {
      case 0:
        break;
      case 1:
        $readaccess[$group[0]/4] = dechex(hexdec($readaccess[$group[0]/4]) | (1 << ($group[0]%4)));
        break;
      case 2:
        $readaccess[$group[0]/4] = dechex(hexdec($readaccess[$group[0]/4]) | (1 << ($group[0]%4)));
        $writeaccess[$group[0]/4] = dechex(hexdec($writeaccess[$group[0]/4]) | (1 << ($group[0]%4)));
        break;
      default:
        exit();
    }
  }
  
  $GLOBALS['pages']->SetAccess(Unquote($_POST['name']), $_POST['type'], array($readaccess, $writeaccess));
  
  header('Location: ' . $GLOBALS['links']->GetNeonLink('Pages', 'type=' . $_POST['type'], false));
  exit();
?>
      ]]>
    </code>
  </data>
</page>