Changeset 1162 for trunk


Ignore:
Timestamp:
12/15/11 16:00:09 (5 months ago)
Author:
bogdan2412
Message:

More fixes from live.

  • Fix 500 errors appearing when attachment name contained ilegal characters.

(was not security issue, only failing assert)

  • Fix 500 errors appearing when textblock revision was not an integer

(was not security issue, got converted into integer -1 and caused mysql
syntax error)

  • Fix coding style, variable name mismatch and memory leak in userwidget view.
  • Fix bug in account controller when trying to change user's security level.
  • Do not allow tests to be run if not in development mode.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/utilities.php

    r1091 r1162  
    66require_once(IA_ROOT_DIR."common/db/db.php"); 
    77require_once(IA_ROOT_DIR."common/db/user.php"); 
     8 
     9if (!IA_DEVELOPMENT_MODE) { 
     10    // These tests alter the database and can remove user created content 
     11    // by mistake (it has happened in the past). 
     12    log_error("You should never run these tests in a production environment"); 
     13} 
    814 
    915// Test with curl. $args format: 
  • trunk/www/controllers/account_validator.php

    r1149 r1162  
    121121 
    122122    // Security 
    123     log_print($user['security_level']); 
    124123    if (!$register && array_key_exists('security_level', $data)) { 
    125         if ($user['security_level'] != 'normal' && 
    126                $user['security_level'] != 'helper' && 
    127                $user['security_level'] != 'admin' && 
    128                $user['security_level'] != 'intern') { 
     124        if ($data['security_level'] != 'normal' && 
     125            $data['security_level'] != 'helper' && 
     126            $data['security_level'] != 'admin' && 
     127            $data['security_level'] != 'intern') { 
    129128            $errors['security_level'] = "Nivel de securitate invalid"; 
    130129        } 
  • trunk/www/controllers/attachment.php

    r1159 r1162  
    414414// Returns attachment model 
    415415function try_attachment_get($page_name, $file_name) { 
    416     if (!$file_name) { 
     416    if (!$file_name || !is_attachment_name($file_name)) { 
    417417        die_http_error(); 
    418418    } 
  • trunk/www/controllers/textblock.php

    r1086 r1162  
    2222        $rev_count = textblock_get_revision_count($page_name); 
    2323        if ($rev_num && $rev_num != $rev_count) { 
     24            if (!is_numeric($rev_num) || (int)$rev_num < 1) { 
     25                flash_error('Revizia "' . $rev_num . '" este invalida.'); 
     26                redirect(url_textblock($page_name)); 
     27            } else { 
     28                $rev_num = (int)$rev_num; 
     29            } 
    2430            identity_require("textblock-history", $crpage); 
    2531            $page = textblock_get_revision($page_name, $rev_num); 
    2632 
    2733            if (!$page) { 
    28                 flash_error("Revizia \"{$rev_num}\" nu exista."); 
     34                flash_error('Revizia "' . $rev_num . '" nu exista.'); 
    2935                redirect(url_textblock($page_name)); 
    3036            } 
  • trunk/www/views/userwidget.php

    r1157 r1162  
    55    $my_img = imagecreatefromjpeg (IA_ROOT_DIR . "www/static/images/widget.jpg"); 
    66    $background = imagecolorallocate($my_img, 154, 205, 50); 
    7     $text_colour = imagecolorallocate($my_img, 255, 255, 255); 
     7    $text_color = imagecolorallocate($my_img, 255, 255, 255); 
    88    $rating_value = (int) $view['rating']; 
    99    if($rating_value >= 600) { 
    10         $line_colour = imagecolorallocate($my_img, 178, 34, 34); 
     10        $line_color = imagecolorallocate($my_img, 178, 34, 34); 
     11    } else if ($rating_value >= 520) { 
     12        $line_color = imagecolorallocate($my_img, 255, 255, 0); 
     13    } else { 
     14        $line_color = imagecolorallocate($my_img, 50, 205, 50); 
    1115    } 
    12     else if($rating_value >= 520) { 
    13         $line_colour = imagecolorallocate($my_img, 255, 255, 0); 
    14     } 
    15     else { 
    16         $line_colour = imagecolorallocate($my_img, 50, 205, 50); 
    17     } 
    18     imagestring($my_img, 3, 15, 42, $view['name'], $text_colour); 
    19     imagestring($my_img, 3, 115, 5, $print_rating, $text_colour); 
    20     imagestring($my_img, 3, 95, 19, "Succes: " . $view['succes'], $text_colour); 
    21     imagestring($my_img, 3, 15, 54, "Probleme rezolvate: " . $view['task_data_succes'], $text_colour); 
    22     imagestring($my_img, 3, 15, 65, "Probleme incercate: " . $view['task_data_failed'], $text_colour); 
     16    imagestring($my_img, 3, 15, 42, $view['name'], $text_color); 
     17    imagestring($my_img, 3, 115, 5, $print_rating, $text_color); 
     18    imagestring($my_img, 3, 95, 19, "Succes: " . $view['succes'], $text_color); 
     19    imagestring($my_img, 3, 15, 54, "Probleme rezolvate: " . $view['task_data_succes'], $text_color); 
     20    imagestring($my_img, 3, 15, 65, "Probleme incercate: " . $view['task_data_failed'], $text_color); 
    2321    imagesetthickness($my_img, 5); 
    24     imageline($my_img, 0, 38, 200, 38, $line_colour); 
     22    imageline($my_img, 0, 38, 200, 38, $line_color); 
    2523    header("Content-type: image/png"); 
    2624    imagepng($my_img); 
    27     imagecolordeallocate($line_color); 
    28     imagecolordeallocate($text_color); 
    29     imagecolordeallocate($background); 
     25    imagecolordeallocate($my_img, $line_color); 
     26    imagecolordeallocate($my_img, $text_color); 
     27    imagecolordeallocate($my_img, $background); 
    3028    imagedestroy($my_img); 
    31  ?> 
     29?> 
Note: See TracChangeset for help on using the changeset viewer.