Changeset 940
- Timestamp:
- 11/05/08 18:16:54 (4 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
common/string.php (modified) (1 diff)
-
www/config.php (modified) (1 diff)
-
www/index.php (modified) (3 diffs)
-
www/wiki/MyTextile.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/string.php
r922 r940 1 1 <?php 2 2 3 // Various string processing functions.3 // Various string processing functions. 4 4 5 5 function starts_with($s, $substr) { 6 log_assert(is_string($s) && is_string($substr)); 6 7 return substr($s, 0, strlen($substr)) == $substr; 7 8 } 8 9 9 10 function ends_with($s, $substr) { 11 log_assert(is_string($s) && is_string($substr)); 10 12 return substr($s, -strlen($substr)) == $substr; 11 13 } -
trunk/www/config.php
r933 r940 69 69 define("IA_LATEX_ENABLE", false); 70 70 71 // List of infoarena controllers72 // Direct controllers73 $IA_DIRECT_CONTROLLERS = array('register', 'news_feed', 'changes',74 'login', 'logout', 'json', 'job_detail',75 'monitor', 'projector', 'submit',76 'plot', 'search',77 'unsubscribe', 'resetpass', 'reeval');78 79 // List of controllers which do not point to a textblock80 $IA_NONTEXTBLOCK_CONTROLLERS = array_merge(array('account', 'admin', 'forum', 'confirm',81 'inregistrare-runda', 'lista-inregistrare'),82 $IA_DIRECT_CONTROLLERS);83 84 // List of all controllers85 $IA_CONTROLLERS = array_merge(array('blog'),86 $IA_NONTEXTBLOCK_CONTROLLERS);87 88 71 // List of safe MIME types 89 72 // FIXME: add more? -
trunk/www/index.php
r938 r940 37 37 // Filter empty path elements. Strips extra '/'s 38 38 $page = normalize_page_name($page); 39 $page _path = explode('/', $page);40 41 $url _root = getattr($page_path, 0, '');42 $page_id = implode('/', array_slice($page _path, 1));39 $pagepath = explode('/', $page); 40 41 $urlstart = getattr($pagepath, 0, ''); 42 $page_id = implode('/', array_slice($pagepath, 1)); 43 43 $action = request('action', 'view'); 44 44 45 // Check if page gets passed to a controller or is a simple textblock 46 if (in_array($url_root, $IA_CONTROLLERS)) { 47 // Trivial direct mappings 48 if (in_array($url_root, $IA_DIRECT_CONTROLLERS)) { 49 require_once(IA_ROOT_DIR."www/controllers/{$url_root}.php"); 50 $fname = "controller_{$url_root}"; 51 $fname($page_id); 52 } 53 54 // Account edit page 55 if ($url_root == 'account') { 56 require_once(IA_ROOT_DIR.'www/controllers/account.php'); 57 controller_account(getattr($page_path, 1)); 58 } 59 60 // Admin controller 61 if ($url_root == 'admin') { 62 $subcontroller = getattr($page_path, 1); 63 64 // Blog admin 65 if ($subcontroller == 'blog') { 66 $obj_id = implode("/", array_slice($page_path, 1)); 67 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 68 controller_blog_admin($obj_id); 69 } 70 71 // Task creator 72 if ($subcontroller == 'problema-noua') { 73 require_once(IA_ROOT_DIR.'www/controllers/task.php'); 74 controller_task_create(); 75 } 76 77 // Task detail editor 78 if ($subcontroller == 'problema') { 79 $obj_id = implode("/", array_slice($page_path, 2)); 80 require_once(IA_ROOT_DIR.'www/controllers/task.php'); 81 controller_task_details($obj_id); 82 } 83 84 // Round creator 85 if ($subcontroller == 'runda-noua') { 86 require_once(IA_ROOT_DIR.'www/controllers/round.php'); 87 controller_round_create(); 88 } 89 90 // Round detail editor 91 if ($subcontroller == 'runda') { 92 $obj_id = implode("/", array_slice($page_path, 2)); 93 require_once(IA_ROOT_DIR.'www/controllers/round.php'); 94 controller_round_details($obj_id); 95 } 96 97 // Invalid subcontroller 98 flash_error('URL invalid'); 99 redirect(url_home()); 100 } 101 102 if ($url_root == 'inregistrare-runda') { 103 $obj_id = implode("/", array_slice($page_path, 1)); 104 require_once(IA_ROOT_DIR.'www/controllers/round_register.php'); 105 controller_round_register($obj_id); 106 } 107 108 // Round registered users 109 if ($url_root == 'lista-inregistrare') { 110 $obj_id = implode("/", array_slice($page_path, 1)); 111 require_once(IA_ROOT_DIR.'www/controllers/round_register.php'); 112 controller_round_register_view($obj_id); 113 } 114 115 // Password reset confirmation 116 if ($url_root == 'confirm') { 117 require_once(IA_ROOT_DIR.'www/controllers/resetpass.php'); 118 controller_resetpass_confirm($page_id); 119 } 120 121 // Special textblock controllers 122 // Blog controller 123 if ($url_root == 'blog') 124 { 125 // Blog index 126 if ($page == 'blog') { 127 // Blog RSS feed 128 if ($action == 'rss') { 129 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 130 controller_blog_feed(); 131 } else { 132 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 133 controller_blog_index(); 134 } 135 } 136 137 // Blog edit 138 if ($action == 'edit') { 139 require_once(IA_ROOT_DIR.'www/controllers/textblock_edit.php'); 140 controller_textblock_edit($page, 'private'); 141 } 142 143 // Blog view 144 if ($action == 'view') { 145 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 146 controller_blog_view($page, request('revision')); 147 } 148 } 45 // Direct mapping list 46 // Note: array_flip() flips keys with values in a dictionary. 47 // FIXME: change this to Romanian! 48 $directmaps = array_flip(array('register', 'news_feed', 'changes', 49 'login', 'logout', 'json', 'job_detail', 50 'monitor', 'projector', 'submit', 'userinfo', 51 'plot', 'search', 52 'unsubscribe', 'resetpass', 'reeval' 53 )); 54 // 55 // Here comes the big url mapper. 56 // We include in the if statement to avoid an extra parsing load. 57 // 58 59 // Trivial direct mappings 60 if (isset($directmaps[$urlstart])) { 61 require_once(IA_ROOT_DIR."www/controllers/{$urlstart}.php"); 62 $fname = "controller_{$urlstart}"; 63 $fname($page_id); 64 } 65 66 // Account edit page 67 else if ($urlstart == 'account') { 68 require_once(IA_ROOT_DIR.'www/controllers/account.php'); 69 controller_account(getattr($pagepath, 1)); 70 } 71 72 // Blog admin 73 else if ($urlstart == 'admin' && getattr($pagepath, 1) == 'blog') { 74 $obj_id = implode("/", array_slice($pagepath, 1)); 75 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 76 controller_blog_admin($obj_id); 77 } 78 79 // Task creator 80 else if ($page == 'admin/problema-noua') { 81 require_once(IA_ROOT_DIR.'www/controllers/task.php'); 82 controller_task_create(); 83 } 84 85 // Task detail editor 86 else if ($urlstart == 'admin' && getattr($pagepath, 1) == 'problema') { 87 $obj_id = implode("/", array_slice($pagepath, 2)); 88 require_once(IA_ROOT_DIR.'www/controllers/task.php'); 89 controller_task_details($obj_id); 90 } 91 92 // Round creator 93 else if ($page == 'admin/runda-noua') { 94 require_once(IA_ROOT_DIR.'www/controllers/round.php'); 95 controller_round_create(); 96 } 97 98 // Round detail editor 99 else if ($urlstart == 'admin' && getattr($pagepath, 1) == 'runda') { 100 $obj_id = implode("/", array_slice($pagepath, 2)); 101 require_once(IA_ROOT_DIR.'www/controllers/round.php'); 102 controller_round_details($obj_id); 103 } 104 105 // Round registration 106 else if ($urlstart == 'inregistrare-runda') { 107 $obj_id = implode("/", array_slice($pagepath, 1)); 108 require_once(IA_ROOT_DIR.'www/controllers/round_register.php'); 109 controller_round_register($obj_id); 110 } 111 112 // Round registered users 113 else if ($urlstart == 'lista-inregistrare') { 114 $obj_id = implode("/", array_slice($pagepath, 1)); 115 require_once(IA_ROOT_DIR.'www/controllers/round_register.php'); 116 controller_round_register_view($obj_id); 117 } 118 119 // Blog RSS feed 120 else if ($page == 'blog' && $action == 'rss') { 121 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 122 controller_blog_feed(); 123 } 124 125 // Blog index 126 else if ($page == 'blog') { 127 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 128 controller_blog_index(); 129 } 130 131 // Blog edit 132 else if ($urlstart == 'blog' && $action == 'edit') { 133 require_once(IA_ROOT_DIR.'www/controllers/textblock_edit.php'); 134 controller_textblock_edit($page, 'private'); 135 } 136 137 // Blog view 138 else if ($urlstart == 'blog' && $action == 'view') { 139 require_once(IA_ROOT_DIR.'www/controllers/blog.php'); 140 controller_blog_view($page, request('revision')); 149 141 } 150 142 … … 152 144 // FIXME: quick array of sorts? 153 145 // - edit textblock 154 if ($action == 'edit') {146 else if ($action == 'edit') { 155 147 require_once(IA_ROOT_DIR.'www/controllers/textblock_edit.php'); 156 148 controller_textblock_edit($page); … … 216 208 } 217 209 210 // reset password 211 else if ('confirm' == $urlstart) { 212 // confirm reset password 213 require_once(IA_ROOT_DIR.'www/controllers/resetpass.php'); 214 controller_resetpass_confirm($page_id); 215 } 216 218 217 // user profile, view personal page / statistics / rating evolution 219 else if (IA_USER_TEXTBLOCK_PREFIX == $url _root.'/' &&218 else if (IA_USER_TEXTBLOCK_PREFIX == $urlstart.'/' && 220 219 ('view' == $action || 'rating' == $action || 'stats' == $action )) { 221 220 require_once(IA_ROOT_DIR.'www/controllers/user.php'); -
trunk/www/wiki/MyTextile.php
r934 r940 131 131 $args['extra'] = $alt; 132 132 133 // Catch internal images134 133 // To avoid CSRF exploits we restrict all images to textblock attachments 135 134 $allowed = false; 136 135 // $allowed_urls are exceptions to this rule 137 $allowed_urls = array("static/images/", "plot/ rating", "plot/distribution");136 $allowed_urls = array("static/images/", "plot/"); 138 137 139 138 foreach ($allowed_urls as $url) { … … 144 143 } 145 144 } 146 147 if (!$allowed && !preg_match('/^'.IA_RE_EXTERNAL_URL.'$/xi', $srcpath)) { 145 146 // Catch internal images 147 if (!preg_match('/^'.IA_RE_EXTERNAL_URL.'$/xi', $srcpath)) { 148 148 if (preg_match('/^ ('.IA_RE_PAGE_NAME.') \? '. 149 149 '('.IA_RE_ATTACHMENT_NAME.')'. … … 158 158 $args['src'] = html_escape(url_absolute(url_image_resize($matches[1], $matches[2], $extra))); 159 159 $allowed = true; 160 161 // Test if $srcpath references an internal url that is NOT a textblock162 // in case someone tries to trick the regexp with something like !logout?something!163 164 $tmp = explode("?", $srcpath);165 $srcpath_root = $tmp[0]; // Strips everything after "?"166 $tmp = explode("/", $srcpath_root);167 $srcpath_controller = $tmp[0]; // Strips everything after first "/"168 global $IA_NONTEXTBLOCK_CONTROLLERS;169 if (in_array(strtolower($srcpath_controller), $IA_NONTEXTBLOCK_CONTROLLERS)) {170 $allowed = false;171 }172 160 } 173 161 } 174 162 175 163 if (!$allowed) { 176 return macro_error("Imaginile trebuie neaparat sa fie atasamente ale unei pagini ");164 return macro_error("Imaginile trebuie neaparat sa fie atasamente ale unei pagini."); 177 165 } 178 166 //log_print("passing to parent::format image");
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)