summaryrefslogtreecommitdiffstats
path: root/pages/Privileges/Update.c.xml
blob: a8a8c545340c137fad5dea20fff3a04f5f9dd28d (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
<?xml version="1.0" encoding="UTF-8" ?>
<page>
  <info>
    <name>Privileges:Update</name>
    <template>phpexec</template>
    <access>0</access>
    <type>c</type>
  </info>
  <data>
    <code>
      <![CDATA[
<?PHP
  require_once('code/db.inc.php');
  require_once('code/links.inc.php');
  require_once('code/pages.inc.php');
  
  if($_POST['type'] != 'c' && $_POST['type'] != 'n' && $_POST['type'] != 'e')
    exit();
  
  $groupres = $GLOBALS['db']->Execute('SELECT id FROM groups ORDER by id');
  $pages = $GLOBALS['pages']->GetList();
  
  $groups = $groupres->GetArray();
  array_unshift($groups, array(0));
  
  $group_max = $groups[count($groups)-1][0];
  
  foreach($pages as $page) {
    if($page[strlen($page)-1] != $_POST['type']) continue;
    
    $page = substr($page, 0, -2);
    
    $access = join('', array_fill(0, $group_max/4 + 1, '0'));
    
    foreach($groups as $group)
      if(isset($_POST[$page . ':' . $group[0]]))
        $access[$group[0]/4] = dechex(hexdec($access[$group[0]/4]) | (1 << ($group[0]%4)));
    
    $GLOBALS['pages']->SetAccess($page, $_POST['type'], $access);
  }
  
  header('Location: ' . $GLOBALS['links']->GetNeonLink('Privileges', 'type=' . $_POST['type'], false));
  exit();
?>
      ]]>
    </code>
  </data>
</page>