Changeset 1091
- Timestamp:
- 12/23/09 00:26:25 (2 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
common/db/user.php (modified) (2 diffs)
-
common/security.php (modified) (5 diffs)
-
tests/round.php (modified) (2 diffs)
-
tests/task.php (modified) (2 diffs)
-
tests/utilities.php (modified) (2 diffs)
-
www/controllers/account_validator.php (modified) (1 diff)
-
www/controllers/register.php (modified) (2 diffs)
-
www/controllers/round.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/common/db/user.php
r1070 r1091 131 131 // $user must be a valid user struct, user_id ignored 132 132 // Returns created $user or throws up on error. 133 function user_create($user )133 function user_create($user, $remote_ip_info=null) 134 134 { 135 135 log_assert_valid(user_validate($user)); … … 150 150 $replace = array("user_id" => $user['username']); 151 151 textblock_copy_replace("template/newuser", IA_USER_TEXTBLOCK_PREFIX.$user['username'], 152 $replace, "public", $new_user['id'], remote_ip_info());152 $replace, "public", $new_user['id'], $remote_ip_info); 153 153 154 154 // Create SMF user -
trunk/common/security.php
r1087 r1091 129 129 case 'task-create': 130 130 case 'task-delete': 131 case 'task-tag': 131 132 case 'round-delete': 132 133 case 'textblock-delete': … … 143 144 case 'textblock-change-security': 144 145 case 'task-edit-owner': 145 case 'task-tag':146 146 case 'round-tag': 147 147 case 'textblock-tag': … … 280 280 // FIXME: attach-grader? 281 281 function security_attach($user, $action, $attach) { 282 283 282 $att_name = $attach['name']; 284 283 $att_page = normalize_page_name($attach['page']); … … 296 295 } 297 296 298 // HACK: magic prefix. 299 if (preg_match('/^grader\_/', $att_name)) { 297 // Speed hack: avatars are always visible. This is good. 298 if ($action == 'attach-download' && $att_name == 'avatar' && 299 starts_with($att_page, IA_USER_TEXTBLOCK_PREFIX)) { 300 return true; 301 } 302 303 // Forward to textblock. 304 $tb = textblock_get_revision($attach['page']); 305 if (!$tb) { 306 log_print_r($attach); 307 } 308 log_assert($tb, "Orphan attachment"); 309 310 // Convert action into a grader action if the textblock is a task 311 // textblock and the attachment has the grader_ prefix. 312 if (preg_match("/^ \s* task: \s* (".IA_RE_TASK_ID.") \s* $/xi", $tb["security"]) && 313 preg_match('/^grader\_/', $att_name)) { 300 314 $newaction = preg_replace('/^attach/', 'grader', $action); 301 315 if (IA_LOG_SECURITY) { … … 304 318 $action = $newaction; 305 319 } 306 307 // Speed hack: avatars are always visible. This is good.308 if ($action == 'attach-download' && $att_name = 'avatar' &&309 strstr($att_page, IA_USER_TEXTBLOCK_PREFIX) === $att_page) {310 return true;311 }312 313 // Forward to textblock.314 $tb = textblock_get_revision($attach['page']);315 if (!$tb) {316 log_print_r($attach);317 }318 log_assert($tb, "Orphan attachment");319 320 320 321 return security_textblock($user, $action, $tb); -
trunk/tests/round.php
r1026 r1091 74 74 'type' => 'classic', 75 75 'rating_update' => true, 76 ))); 77 log_assert_equal($res['url'], url_absolute(url_round_edit('test_round'))); 78 log_assert(strstr($res['content'], 'Concurs clasic')); 76 'start_time' => db_date_format(time() + 3600), 77 ))); 78 log_assert(!strstr($res['content'], '<span class="fieldError"')); 79 log_assert(strstr($res['content'], '<option value="classic" selected="selected">Concurs clasic')); 80 log_assert_equal($res['url'], url_absolute(url_round_edit('test_round'))); 79 81 80 82 log_print("Admin adds tasks adunare and cmmdc to round."); … … 197 199 log_assert_equal($res['url'], url_absolute(url_textblock('runda/tEst_Round'))); 198 200 log_assert(strstr($res['content'], 'xzx-round-title-xzx')); 199 log_assert(!strstr($res['content'], 'Nu esti inscris la'), 201 log_assert(!strstr($res['content'], 'Nu esti inscris la'), 200 202 "Round still waiting, is the evaluator ON?"); 201 203 log_assert(strstr($res['content'], 'Nu se mai pot face inscrieri')); -
trunk/tests/task.php
r852 r1091 39 39 'post' => array( 40 40 'title' => 'xzx-task1-title-xzx', 41 ' author' => 'xzx-task1-author-xzx',41 'tag_author' => 'xzx-task1-author-xzx', 42 42 'source' => 'xzx-task1-source-xzx', 43 43 ))); … … 223 223 log_assert(strstr($res['content'], 'xzx-task1-author-xzx')); 224 224 log_assert(strstr($res['content'], 'xzx-task1-source-xzx')); 225 log_assert(strstr($res['content'], 'name=" author"'));225 log_assert(strstr($res['content'], 'name="tag_author"')); 226 226 log_assert(!strstr($res['content'], 'name="hidden"')); 227 227 -
trunk/tests/utilities.php
r1051 r1091 66 66 $res['content'] = $content; 67 67 curl_close($ch); 68 68 69 69 if (getattr($args, 'validate_html', false)) { 70 70 validate_html($content); … … 132 132 function test_cleanup() 133 133 { 134 db_query("DELETE FROM ia_user WHERE `username` LIKE 'test_%'"); 135 db_query("DELETE FROM ia_task WHERE `id` LIKE 'test_%'"); 136 db_query("DELETE FROM ia_round WHERE `id` LIKE 'test_%'"); 134 $test_accounts = "('test_dudE1', 'teSt_dude2', 'teSt_helper1', 'test_hElper2', 'tEst_adMin')"; 135 db_query("DELETE FROM ia_user WHERE `username` IN $test_accounts"); 136 db_query("DELETE FROM ia_smf_members WHERE `memberName` IN $test_accounts"); 137 db_query("DELETE FROM ia_task WHERE `id` LIKE 'test\_%'"); 138 db_query("DELETE FROM ia_round WHERE `id` LIKE 'test\_%'"); 137 139 // Remove various stuff from the wiki. 138 140 $prefixes = array('sandbox', 'utilizator', 'runda', 'problema'); 139 141 foreach ($prefixes as $prefix) { 140 142 db_query("DELETE FROM `ia_textblock` ". 141 "WHERE `name` LIKE '$prefix/test _%'");143 "WHERE `name` LIKE '$prefix/test\_%'"); 142 144 db_query("DELETE FROM `ia_textblock_revision` ". 143 "WHERE `name` LIKE '$prefix/test _%'");145 "WHERE `name` LIKE '$prefix/test\_%'"); 144 146 db_query("DELETE FROM `ia_file` ". 145 "WHERE `page` LIKE '$prefix/test _%'");147 "WHERE `page` LIKE '$prefix/test\_%'"); 146 148 } 147 149 } -
trunk/www/controllers/account_validator.php
r997 r1091 46 46 .'invalide.'; 47 47 } 48 elseif (user_get_by_username($data['username'])) { 48 elseif (user_get_by_username($data['username']) || 49 smf_get_member_by_name($data['username'])) { 49 50 $errors['username'] = 'Nume utilizator rezervat de altcineva. Va ' 50 51 .'rugam alegeti altul.'; -
trunk/www/controllers/register.php
r986 r1091 47 47 48 48 // There are no acceptable errors in user_create. 49 user_create($user );49 user_create($user, remote_ip_info()); 50 50 flash("Felicitari! Contul a fost creat. Acum te poti " 51 51 ."autentifica."); … … 59 59 $data['tnc'] = 1; 60 60 } 61 61 62 62 if(!IA_DEVELOPMENT_MODE) { 63 63 $view['captcha'] = recaptcha_get_html(IA_CAPTCHA_PUBLIC_KEY); -
trunk/www/controllers/round.php
r1090 r1091 134 134 } 135 135 136 if (request_is_post() && count($values['tasks']) == 0) {137 $errors['tasks'] = "Trebuie sa alegi cel putin o problema";138 }139 140 136 // Additional validation for user defined tasks 141 137 if (!array_key_exists('tasks', $errors)
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)