44 ); |
44 ); |
45 |
45 |
46 // ACL types |
46 // ACL types |
47 // These can also be added from within plugins |
47 // These can also be added from within plugins |
48 |
48 |
49 $session->register_acl_type('read', AUTH_ALLOW, 'Read page(s)'); |
49 $session->register_acl_type('read', AUTH_ALLOW, 'perm_read'); |
50 $session->register_acl_type('post_comments', AUTH_ALLOW, 'Post comments', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
50 $session->register_acl_type('post_comments', AUTH_ALLOW, 'perm_post_comments', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
51 $session->register_acl_type('edit_comments', AUTH_ALLOW, 'Edit own comments', Array('post_comments'), 'Article|User|Project|Template|File|Help|System|Category'); |
51 $session->register_acl_type('edit_comments', AUTH_ALLOW, 'perm_edit_comments', Array('post_comments'), 'Article|User|Project|Template|File|Help|System|Category'); |
52 $session->register_acl_type('edit_page', AUTH_WIKIMODE, 'Edit page', Array('view_source'), 'Article|User|Project|Template|File|Help|System|Category'); |
52 $session->register_acl_type('edit_page', AUTH_WIKIMODE, 'perm_edit_page', Array('view_source'), 'Article|User|Project|Template|File|Help|System|Category'); |
53 $session->register_acl_type('view_source', AUTH_WIKIMODE, 'View source', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); // Only used if the page is protected |
53 $session->register_acl_type('view_source', AUTH_WIKIMODE, 'perm_view_source', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); // Only used if the page is protected |
54 $session->register_acl_type('mod_comments', AUTH_DISALLOW, 'Moderate comments', Array('edit_comments'), 'Article|User|Project|Template|File|Help|System|Category'); |
54 $session->register_acl_type('mod_comments', AUTH_DISALLOW, 'perm_mod_comments', Array('edit_comments'), 'Article|User|Project|Template|File|Help|System|Category'); |
55 $session->register_acl_type('history_view', AUTH_WIKIMODE, 'View history/diffs', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
55 $session->register_acl_type('history_view', AUTH_WIKIMODE, 'perm_history_view', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
56 $session->register_acl_type('history_rollback', AUTH_DISALLOW, 'Rollback history', Array('history_view'), 'Article|User|Project|Template|File|Help|System|Category'); |
56 $session->register_acl_type('history_rollback', AUTH_DISALLOW, 'perm_history_rollback', Array('history_view'), 'Article|User|Project|Template|File|Help|System|Category'); |
57 $session->register_acl_type('history_rollback_extra', AUTH_DISALLOW, 'Undelete page(s)', Array('history_rollback'), 'Article|User|Project|Template|File|Help|System|Category'); |
57 $session->register_acl_type('history_rollback_extra', AUTH_DISALLOW, 'perm_history_rollback_extra', Array('history_rollback'), 'Article|User|Project|Template|File|Help|System|Category'); |
58 $session->register_acl_type('protect', AUTH_DISALLOW, 'Protect page(s)', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
58 $session->register_acl_type('protect', AUTH_DISALLOW, 'perm_protect', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
59 $session->register_acl_type('rename', AUTH_WIKIMODE, 'Rename page(s)', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
59 $session->register_acl_type('rename', AUTH_WIKIMODE, 'perm_rename', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
60 $session->register_acl_type('clear_logs', AUTH_DISALLOW, 'Clear page logs (dangerous)', Array('read', 'protect', 'even_when_protected'), 'Article|User|Project|Template|File|Help|System|Category'); |
60 $session->register_acl_type('clear_logs', AUTH_DISALLOW, 'perm_clear_logs', Array('read', 'protect', 'even_when_protected'), 'Article|User|Project|Template|File|Help|System|Category'); |
61 $session->register_acl_type('vote_delete', AUTH_ALLOW, 'Vote to delete', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
61 $session->register_acl_type('vote_delete', AUTH_ALLOW, 'perm_vote_delete', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
62 $session->register_acl_type('vote_reset', AUTH_DISALLOW, 'Reset delete votes', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
62 $session->register_acl_type('vote_reset', AUTH_DISALLOW, 'perm_vote_reset', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
63 $session->register_acl_type('delete_page', AUTH_DISALLOW, 'Delete page(s)', Array(), 'Article|User|Project|Template|File|Help|System|Category'); |
63 $session->register_acl_type('delete_page', AUTH_DISALLOW, 'perm_delete_page', Array(), 'Article|User|Project|Template|File|Help|System|Category'); |
64 $session->register_acl_type('tag_create', AUTH_ALLOW, 'Tag page(s)', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
64 $session->register_acl_type('tag_create', AUTH_ALLOW, 'perm_tag_create', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
65 $session->register_acl_type('tag_delete_own', AUTH_ALLOW, 'Remove own page tags', Array('read', 'tag_create'), 'Article|User|Project|Template|File|Help|System|Category'); |
65 $session->register_acl_type('tag_delete_own', AUTH_ALLOW, 'perm_tag_delete_own', Array('read', 'tag_create'), 'Article|User|Project|Template|File|Help|System|Category'); |
66 $session->register_acl_type('tag_delete_other', AUTH_DISALLOW, 'Remove others\' page tags', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
66 $session->register_acl_type('tag_delete_other', AUTH_DISALLOW, 'perm_tag_delete_other', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
67 $session->register_acl_type('set_wiki_mode', AUTH_DISALLOW, 'Set per-page wiki mode', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
67 $session->register_acl_type('set_wiki_mode', AUTH_DISALLOW, 'perm_set_wiki_mode', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
68 $session->register_acl_type('password_set', AUTH_DISALLOW, 'Set password', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
68 $session->register_acl_type('password_set', AUTH_DISALLOW, 'perm_password_set', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
69 $session->register_acl_type('password_reset', AUTH_DISALLOW, 'Disable/reset password', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
69 $session->register_acl_type('password_reset', AUTH_DISALLOW, 'perm_password_reset', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
70 $session->register_acl_type('mod_misc', AUTH_DISALLOW, 'Super moderator (generate SQL backtraces, view IP addresses, and send large numbers of private messages)', Array(), 'All'); |
70 $session->register_acl_type('mod_misc', AUTH_DISALLOW, 'perm_mod_misc', Array(), 'All'); |
71 $session->register_acl_type('edit_cat', AUTH_WIKIMODE, 'Edit categorization', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
71 $session->register_acl_type('edit_cat', AUTH_WIKIMODE, 'perm_edit_cat', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); |
72 $session->register_acl_type('even_when_protected', AUTH_DISALLOW, 'Allow editing, renaming, and categorization even when protected', Array('edit_page', 'rename', 'mod_comments', 'edit_cat'), 'Article|User|Project|Template|File|Help|System|Category'); |
72 $session->register_acl_type('even_when_protected', AUTH_DISALLOW, 'perm_even_when_protected', Array('edit_page', 'rename', 'mod_comments', 'edit_cat'), 'Article|User|Project|Template|File|Help|System|Category'); |
73 $session->register_acl_type('upload_files', AUTH_DISALLOW, 'Upload files', Array('create_page'), 'Article|User|Project|Template|File|Help|System|Category|Special'); |
73 $session->register_acl_type('upload_files', AUTH_DISALLOW, 'perm_upload_files', Array('create_page'), 'Article|User|Project|Template|File|Help|System|Category|Special'); |
74 $session->register_acl_type('upload_new_version', AUTH_WIKIMODE, 'Upload new versions of files', Array('upload_files'), 'Article|User|Project|Template|File|Help|System|Category|Special'); |
74 $session->register_acl_type('upload_new_version', AUTH_WIKIMODE, 'perm_upload_new_version', Array('upload_files'), 'Article|User|Project|Template|File|Help|System|Category|Special'); |
75 $session->register_acl_type('create_page', AUTH_WIKIMODE, 'Create pages', Array(), 'Article|User|Project|Template|File|Help|System|Category|Special'); |
75 $session->register_acl_type('create_page', AUTH_WIKIMODE, 'perm_create_page', Array(), 'Article|User|Project|Template|File|Help|System|Category|Special'); |
76 $session->register_acl_type('php_in_pages', AUTH_DISALLOW, 'Embed PHP code in pages', Array('edit_page'), 'Article|User|Project|Template|File|Help|System|Category|Admin'); |
76 $session->register_acl_type('php_in_pages', AUTH_DISALLOW, 'perm_php_in_pages', Array('edit_page'), 'Article|User|Project|Template|File|Help|System|Category|Admin'); |
77 $session->register_acl_type('edit_acl', AUTH_DISALLOW, 'Edit access control lists', Array('read', 'post_comments', 'edit_comments', 'edit_page', 'view_source', 'mod_comments', 'history_view', 'history_rollback', 'history_rollback_extra', 'protect', 'rename', 'clear_logs', 'vote_delete', 'vote_reset', 'delete_page', 'set_wiki_mode', 'password_set', 'password_reset', 'mod_misc', 'edit_cat', 'even_when_protected', 'upload_files', 'upload_new_version', 'create_page', 'php_in_pages')); |
77 $session->register_acl_type('edit_acl', AUTH_DISALLOW, 'perm_edit_acl', Array('read', 'post_comments', 'edit_comments', 'edit_page', 'view_source', 'mod_comments', 'history_view', 'history_rollback', 'history_rollback_extra', 'protect', 'rename', 'clear_logs', 'vote_delete', 'vote_reset', 'delete_page', 'set_wiki_mode', 'password_set', 'password_reset', 'mod_misc', 'edit_cat', 'even_when_protected', 'upload_files', 'upload_new_version', 'create_page', 'php_in_pages')); |
78 |
78 |
79 // DO NOT add new admin pages here! Use a plugin to call $paths->addAdminNode(); |
79 // DO NOT add new admin pages here! Use a plugin to call $paths->addAdminNode(); |
80 $this->addAdminNode('General', 'General Configuration', 'GeneralConfig'); |
80 $this->addAdminNode('adm_cat_general', 'adm_page_general_config', 'GeneralConfig'); |
81 $this->addAdminNode('General', 'File uploads', 'UploadConfig'); |
81 $this->addAdminNode('adm_cat_general', 'adm_page_file_uploads', 'UploadConfig'); |
82 $this->addAdminNode('General', 'Allowed file types', 'UploadAllowedMimeTypes'); |
82 $this->addAdminNode('adm_cat_general', 'adm_page_file_types', 'UploadAllowedMimeTypes'); |
83 $this->addAdminNode('General', 'Manage Plugins', 'PluginManager'); |
83 $this->addAdminNode('adm_cat_general', 'adm_page_plugins', 'PluginManager'); |
84 $this->addAdminNode('General', 'Backup database', 'DBBackup'); |
84 $this->addAdminNode('adm_cat_general', 'adm_page_db_backup', 'DBBackup'); |
85 $this->addAdminNode('Content', 'Manage Pages', 'PageManager'); |
85 $this->addAdminNode('adm_cat_content', 'adm_page_manager', 'PageManager'); |
86 $this->addAdminNode('Content', 'Edit page content', 'PageEditor'); |
86 $this->addAdminNode('adm_cat_content', 'adm_page_editor', 'PageEditor'); |
87 $this->addAdminNode('Content', 'Manage page groups', 'PageGroups'); |
87 $this->addAdminNode('adm_cat_content', 'adm_page_pg_groups', 'PageGroups'); |
88 $this->addAdminNode('Appearance', 'Manage themes', 'ThemeManager'); |
88 $this->addAdminNode('adm_cat_appearance', 'adm_page_themes', 'ThemeManager'); |
89 $this->addAdminNode('Users', 'Manage users', 'UserManager'); |
89 $this->addAdminNode('adm_cat_users', 'adm_page_users', 'UserManager'); |
90 $this->addAdminNode('Users', 'Edit groups', 'GroupManager'); |
90 $this->addAdminNode('adm_cat_users', 'adm_page_user_groups', 'GroupManager'); |
91 $this->addAdminNode('Users', 'COPPA support', 'COPPA'); |
91 $this->addAdminNode('adm_cat_users', 'adm_page_coppa', 'COPPA'); |
92 $this->addAdminNode('Users', 'Mass e-mail', 'MassEmail'); |
92 $this->addAdminNode('adm_cat_users', 'adm_page_mass_email', 'MassEmail'); |
93 $this->addAdminNode('Security', 'Security log', 'SecurityLog'); |
93 $this->addAdminNode('adm_cat_security', 'adm_page_security_log', 'SecurityLog'); |
94 $this->addAdminNode('Security', 'Ban control', 'BanControl'); |
94 $this->addAdminNode('adm_cat_security', 'adm_page_ban_control', 'BanControl'); |
95 |
95 |
96 $code = $plugins->setHook('acl_rule_init'); |
96 $code = $plugins->setHook('acl_rule_init'); |
97 foreach ( $code as $cmd ) |
97 foreach ( $code as $cmd ) |
98 { |
98 { |
99 eval($cmd); |
99 eval($cmd); |
853 |
858 |
854 function get_page_groups($page_id, $namespace) |
859 function get_page_groups($page_id, $namespace) |
855 { |
860 { |
856 global $db, $session, $paths, $template, $plugins; // Common objects |
861 global $db, $session, $paths, $template, $plugins; // Common objects |
857 |
862 |
|
863 static $cache = array(); |
|
864 |
|
865 if ( count($cache) == 0 ) |
|
866 { |
|
867 foreach ( $this->nslist as $key => $_ ) |
|
868 { |
|
869 $cache[$key] = array(); |
|
870 } |
|
871 } |
|
872 |
|
873 if ( !isset($this->nslist[$namespace]) ) |
|
874 die('$paths->get_page_groups(): HACKING ATTEMPT: namespace "'. htmlspecialchars($namespace) .'" doesn\'t exist'); |
|
875 |
|
876 $page_id_unescaped = $paths->nslist[$namespace] . |
|
877 dirtify_page_id($page_id); |
|
878 $page_id_str = $paths->nslist[$namespace] . |
|
879 sanitize_page_id($page_id); |
|
880 |
858 $page_id = $db->escape(sanitize_page_id($page_id)); |
881 $page_id = $db->escape(sanitize_page_id($page_id)); |
859 if ( !isset($this->nslist[$namespace]) ) |
882 |
860 die('$paths->get_page_groups(): HACKING ATTEMPT'); |
883 if ( isset($cache[$namespace][$page_id]) ) |
|
884 { |
|
885 return $cache[$namespace][$page_id]; |
|
886 } |
861 |
887 |
862 $group_list = array(); |
888 $group_list = array(); |
863 |
889 |
864 // What linked categories have this page? |
890 // What linked categories have this page? |
865 $q = $db->sql_query('SELECT g.pg_id FROM '.table_prefix.'page_groups AS g |
891 $q = $db->sql_unbuffered_query('SELECT g.pg_id, g.pg_type, g.pg_target FROM '.table_prefix.'page_groups AS g |
866 LEFT JOIN '.table_prefix.'categories AS c |
892 LEFT JOIN '.table_prefix.'categories AS c |
867 ON ( ( c.category_id = g.pg_target AND g.pg_type = ' . PAGE_GRP_CATLINK . ' ) OR c.category_id IS NULL ) |
893 ON ( ( c.category_id = g.pg_target AND g.pg_type = ' . PAGE_GRP_CATLINK . ' ) OR c.category_id IS NULL ) |
868 LEFT JOIN '.table_prefix.'page_group_members AS m |
894 LEFT JOIN '.table_prefix.'page_group_members AS m |
869 ON ( ( g.pg_id = m.pg_id AND g.pg_type = ' . PAGE_GRP_NORMAL . ' ) OR ( m.pg_id IS NULL ) ) |
895 ON ( ( g.pg_id = m.pg_id AND g.pg_type = ' . PAGE_GRP_NORMAL . ' ) OR ( m.pg_id IS NULL ) ) |
870 LEFT JOIN '.table_prefix.'tags AS t |
896 LEFT JOIN '.table_prefix.'tags AS t |
871 ON ( ( t.tag_name = g.pg_target AND pg_type = ' . PAGE_GRP_TAGGED . ' ) OR t.tag_name IS NULL ) |
897 ON ( ( t.tag_name = g.pg_target AND pg_type = ' . PAGE_GRP_TAGGED . ' ) OR t.tag_name IS NULL ) |
872 WHERE |
898 WHERE |
873 ( c.page_id=\'' . $page_id . '\' AND c.namespace=\'' . $namespace . '\' ) OR |
899 ( c.page_id=\'' . $page_id . '\' AND c.namespace=\'' . $namespace . '\' ) OR |
874 ( t.page_id=\'' . $page_id . '\' AND t.namespace=\'' . $namespace . '\' ) OR |
900 ( t.page_id=\'' . $page_id . '\' AND t.namespace=\'' . $namespace . '\' ) OR |
875 ( m.page_id=\'' . $page_id . '\' AND m.namespace=\'' . $namespace . '\' );'); |
901 ( m.page_id=\'' . $page_id . '\' AND m.namespace=\'' . $namespace . '\' ) OR |
|
902 ( g.pg_type = ' . PAGE_GRP_REGEX . ' );'); |
876 if ( !$q ) |
903 if ( !$q ) |
877 $db->_die(); |
904 $db->_die(); |
878 |
905 |
879 while ( $row = $db->fetchrow() ) |
906 while ( $row = $db->fetchrow() ) |
880 { |
907 { |
881 $group_list[] = $row['pg_id']; |
908 if ( $row['pg_type'] == PAGE_GRP_REGEX ) |
|
909 { |
|
910 //echo "<debug> matching page " . htmlspecialchars($page_id_unescaped) . " against regex <tt>" . htmlspecialchars($row['pg_target']) . "</tt>."; |
|
911 if ( @preg_match($row['pg_target'], $page_id_unescaped) || @preg_match($row['pg_target'], $page_id_str) ) |
|
912 { |
|
913 //echo "..matched"; |
|
914 $group_list[] = $row['pg_id']; |
|
915 } |
|
916 //echo "<br />"; |
|
917 } |
|
918 else |
|
919 { |
|
920 $group_list[] = $row['pg_id']; |
|
921 } |
882 } |
922 } |
883 |
923 |
884 $db->free_result(); |
924 $db->free_result(); |
885 |
925 |
886 /* |
926 $cache[$namespace][$page_id] = $group_list; |
887 // Static-page groups |
|
888 $q = $db->sql_query('SELECT g.pg_id FROM '.table_prefix.'page_groups AS g |
|
889 LEFT JOIN '.table_prefix.'page_group_members AS m |
|
890 ON ( g.pg_id = m.pg_id ) |
|
891 WHERE m.page_id=\'' . $page_id . '\' AND m.namespace=\'' . $namespace . '\' |
|
892 GROUP BY g.pg_id;'); |
|
893 |
|
894 if ( !$q ) |
|
895 $db->_die(); |
|
896 |
|
897 while ( $row = $db->fetchrow() ) |
|
898 { |
|
899 $group_list[] = $row['pg_id']; |
|
900 } |
|
901 |
|
902 // Tag groups |
|
903 |
|
904 $q = $db->sql_query('SELECT g.pg_id FROM '.table_prefix.'page_groups AS g |
|
905 LEFT JOIN '.table_prefix.'tags AS t |
|
906 ON ( t.tag_name = g.pg_target AND pg_type = ' . PAGE_GRP_TAGGED . ' ) |
|
907 WHERE t.page_id = \'' . $page_id . '\' AND t.namespace = \'' . $namespace . '\';'); |
|
908 if ( !$q ) |
|
909 $db->_die(); |
|
910 |
|
911 while ( $row = $db->fetchrow() ) |
|
912 { |
|
913 $group_list[] = $row['pg_id']; |
|
914 } |
|
915 */ |
|
916 |
927 |
917 return $group_list; |
928 return $group_list; |
918 |
929 |
919 } |
930 } |
920 |
931 |