Changeset 573

Show
Ignore:
Timestamp:
05/12/07 02:14:55 (2 years ago)
Author:
raphael
Message:

Adding patches from #262 and #263

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gui/admin/ahp.php

    r474 r573  
    249249  } 
    250250 
    251   return TRUE; 
    252  
    253251}// End of check_data_correction() 
    254252 
  • trunk/gui/admin/circular.php

    r474 r573  
    2020 
    2121 
    22 include '../include/ispcp-lib.php'; 
     22require '../include/ispcp-lib.php'; 
    2323 
    2424check_login(); 
     
    301301    ); 
    302302 
    303 send_circular(&$tpl, &$sql); 
     303send_circular($tpl, $sql); 
    304304 
    305305gen_page_data ($tpl, $sql); 
  • trunk/gui/admin/delete_ip.php

    r474 r573  
    7777    $reseller_ips = $data['reseller_ips']; 
    7878 
    79     while ($data = $res -> FetchRow()) { 
     79    while (($data = $res -> FetchRow())) { 
    8080      if (preg_match("/$delete_id;/", $reseller_ips) == 1) { 
    8181        set_page_message(tr('Error we have reseller that use this IP!')); 
  • trunk/gui/admin/ehp.php

    r474 r573  
    249249  global $hpid; 
    250250 
    251   $ahp_error    = "_off_"
     251  $ahp_error    = '_off_'
    252252  $hp_name              = clean_input($_POST['hp_name']); 
    253253  $hp_sub               = clean_input($_POST['hp_sub']); 
     
    312312    return false; 
    313313  } 
    314  
    315   return TRUE; 
    316314 
    317315} // End of check_data_iscorrect() 
  • trunk/gui/admin/hp.php

    r518 r573  
    8484function gen_hp_message (&$tpl) { 
    8585        //global $externel_event, $hp_added, $hp_deleted, $hp_updated; 
    86       global $external_event; 
     86//    global $external_event; 
    8787 
    8888        if (isset($_SESSION["hp_added"]) && $_SESSION["hp_added"] == '_yes_') { 
    89               $external_event = '_on_'; 
     89//            $external_event = '_on_'; 
    9090                set_page_message(tr('Hosting plan added!')); 
    9191                unset($_SESSION["hp_added"]); 
     
    9494        } 
    9595        else if (isset($_SESSION["hp_deleted"]) && $_SESSION["hp_deleted"] == '_yes_') { 
    96               $external_event = '_on_'; 
     96//            $external_event = '_on_'; 
    9797                set_page_message(tr('Hosting plan deleted!')); 
    9898                unset($_SESSION["hp_deleted"]); 
     
    100100                        unset($GLOBALS['hp_deleted']); 
    101101        } else if (isset($_SESSION["hp_updated"]) && $_SESSION["hp_updated"] == '_yes_') { 
    102               $external_event = '_on_'; 
     102//            $external_event = '_on_'; 
    103103                set_page_message(tr('Hosting plan updated!')); 
    104104                unset($_SESSION["hp_updated"]); 
     
    138138                $tpl -> assign('HP_TABLE', ''); 
    139139        } else { // There are data for hosting plants :-) 
    140                 if ($externel_event == '_off_') { 
     140                /*if ($GLOBALS['external_event'] == '_off_') { 
    141141                        $tpl -> assign('HP_MESSAGE', ''); 
    142                 } 
     142                }*/ 
    143143 
    144144                $tpl -> assign(array('TR_HOSTING_PLANS' => tr('Hosting plans'), 
  • trunk/gui/admin/index.php

    r474 r573  
    8383} 
    8484 
     85 
    8586function get_update_infos(&$tpl) { 
    8687        global $cfg; 
    8788 
    88         $last_update = "http://isp-control.net/latest.txt"; 
     89        $last_update = "http://www.isp-control.net/latest.txt"; 
    8990 
    9091    // Fake the browser type 
    9192    ini_set('user_agent','Mozilla/5.0'); 
    9293 
    93         $dh2 = @fopen("$last_update",'r'); 
    94         (int) $last_update_result = @fread($dh2, 8); 
    95  
    96         (int) $current_version = $cfg['BuildDate']; 
     94        $dh2 = @fopen($last_update,'r'); 
     95        $last_update_result = (int)@fread($dh2, 8); 
     96        fclose($dh2); 
     97 
     98        $current_version = (int)$cfg['BuildDate']; 
    9799        if ($current_version < $last_update_result) { 
    98100                $tpl -> assign(array('UPDATE' =>  tr('New ISPCP update is now available'))); 
  • trunk/gui/admin/ispcp_updates.php

    r474 r573  
    3232    ini_set('user_agent','Mozilla/5.0'); 
    3333 
    34         $dh2 = @fopen("$last_update",'r'); 
    35         (int) $last_update_result = @fread($dh2, 8); 
     34        $dh2 = @fopen($last_update,'r'); 
     35        $last_update_result = (int)@fread($dh2, 8); 
     36        fclose($dh2); 
    3637 
    37         (int) $current_version = $cfg['BuildDate']; 
     38        $current_version = (int)$cfg['BuildDate']; 
    3839        if ($current_version < $last_update_result) { 
    3940 
  • trunk/gui/admin/layout.php

    r474 r573  
    226226$theme_color = $cfg['USER_INITIAL_THEME']; 
    227227 
    228 gen_def_layout($tpl, $sql, $user_def_layout); 
     228gen_def_layout($tpl, $sql, $_SESSION['user_theme']); 
    229229 
    230230$tpl -> assign( 
  • trunk/gui/admin/manage_reseller_users.php

    r474 r573  
    439439    } 
    440440 
     441    return true; 
     442 
    441443} 
    442444function calculate_reseller_dvals (&$dest, $dest_max, &$src, $src_max, $umax, &$err, $obj, $uname) { 
  • trunk/gui/admin/server_traffic_settings.php

    r474 r573  
    4747 
    4848    if (!isset($_POST['uaction']) && !isset($_POST['uaction'])) { 
     49        return; 
     50    } 
     51    /*global $data; 
     52    $match = array(); 
     53    preg_match("/^(-1|0|[1-9][0-9]*)$/D", $data, $match);*/ 
     54 
     55    $max_traffic = clean_input($_POST['max_traffic']); 
     56 
     57    $traffic_warning = $_POST['traffic_warning']; 
     58 
     59    if (!is_numeric($max_traffic) || !is_numeric($traffic_warning) ) { 
     60        set_page_message(tr('Wrong data input!')); 
     61    } 
     62 
     63    if ($traffic_warning > $max_traffic){ 
     64 
     65        set_page_message(tr('Warning traffic is bigger then max traffic!')); 
    4966 
    5067        return; 
    5168    } 
    5269 
     70    if ($max_traffic < 0) { 
     71        $max_traffic = 0; 
     72    } 
     73    if ($traffic_warning < 0) { 
     74        $traffic_warning = 0; 
     75    } 
    5376 
    54         else 
    55         { 
    56                         global $data; 
    57                         preg_match("/^(-1|0|[1-9][0-9]*)$/", $data, $match); 
    58  
    59             $max_traffic = clean_input($_POST['max_traffic']); 
    60  
    61             $traffic_warning = $_POST['traffic_warning']; 
    62  
    63                         if (!is_numeric($max_traffic) || !is_numeric($traffic_warning) ) { 
    64                                 set_page_message(tr('Wrong data input!')); 
    65                         } 
    66  
    67  
    68  
    69                         if ($traffic_warning > $max_traffic){ 
    70  
    71                                 set_page_message(tr('Warning traffic is bigger then max traffic!')); 
    72  
    73                                 return; 
    74                         } 
    75  
    76                         if ($max_traffic < 0){ 
    77                                  $max_traffic = 0; 
    78                         } 
    79                         if ($traffic_warning < 0){ 
    80                                  $traffic_warning = 0; 
    81                         } 
    82  
    83             $query = <<<SQL_QUERY 
     77    $query = <<<SQL_QUERY 
    8478                update 
    8579                    straff_settings 
     
    8882                    straff_warn  = ? 
    8983SQL_QUERY; 
    90             $rs = exec_query($sql, $query, array($max_traffic, $traffic_warning)); 
     84    $rs = exec_query($sql, $query, array($max_traffic, $traffic_warning)); 
    9185 
    92             set_page_message(tr('Server traffic settings updated successfully!')); 
    93  
    94  
    95         } 
     86    set_page_message(tr('Server traffic settings updated successfully!')); 
    9687} 
    9788 
  • trunk/gui/include/i18n.php

    r553 r573  
    3333        global $sql, $default_lang; 
    3434 
    35         $default_lang = session_id() ? $_SESSION['user_def_lang'] : $cfg['USER_INITIAL_LANG']; 
     35        $default_lang = (session_id() && isset($_SESSION['user_def_lang'])) ? $_SESSION['user_def_lang'] : $cfg['USER_INITIAL_LANG']; 
    3636 
    3737        if (!$sql) { 
  • trunk/gui/include/login.php

    r519 r573  
    154154  } 
    155155 
    156   if (isset($_SESSION['user_logged'])) { 
     156  if (!isset($_SESSION['user_logged'])) { 
     157 
     158//              write_log(htmlspecialchars($user_logged, ENT_QUOTES, "UTF-8") . " bad session data."); 
     159 
     160                return false; 
     161        } 
    157162 
    158163                // verify sessiondata with database 
     
    185190        if ($cfg['SERVICEMODE'] == 1 AND $user_type != 'admin') { 
    186191 
     192            unset_user_login_data(); 
     193 
    187194                        write_log("<b><i>".htmlspecialchars($user_logged, ENT_QUOTES, "UTF-8")."</i></b> system currently in servicemode. User logged out..."); 
    188195 
     
    209216 
    210217      return true; 
    211  
    212         } else { 
    213  
    214                 write_log(htmlspecialchars($user_logged, ENT_QUOTES, "UTF-8") . " bad session data."); 
    215  
    216                 return false; 
    217         } 
    218218 
    219219} 
     
    251251function check_login () { 
    252252 
    253         if (isset($_SESSION['user_logged'])) { 
    254  
    255                 if (!check_user_login()) { 
    256                 header("Location: ../index.php"); 
    257                         die(); 
    258             } 
    259         } 
    260         else { 
    261                 header("Location: ../index.php"); 
    262                 die(); 
    263         } 
     253    if (!check_user_login()) { //check_user_login already performs all the check 
     254        header("Location: ../index.php"); 
     255        die(); 
     256    } 
    264257} 
    265258 
     
    443436        } 
    444437 
     438        $lang = $_SESSION['user_def_lang']; 
     439 
    445440        $_SESSION = array(); 
    446441 
    447 //      session_unset(); 
    448  
    449 //      session_destroy(); 
    450  
    451         $_SESSION['user_def_lang'] = $cfg['USER_INITIAL_LANG']; 
    452  
     442        $_SESSION['user_def_lang'] = $lang; 
     443 
     444
     445 
     446function redirect_to_level_page() 
     447
     448    if (!isset($_SESSION['user_type'])) 
     449    return false; 
     450 
     451    $user_type = $_SESSION['user_type']; 
     452 
     453    switch ($user_type) { 
     454        case 'user': 
     455            $user_type = 'client'; 
     456        case 'admin': 
     457        case 'reseller': 
     458            header('Location: ' . $user_type . '/index.php'); 
     459            break; 
     460        default: 
     461            die("FIX ME! " . __FILE__ . ":" . __LINE__); 
     462            break; 
     463    } 
     464    exit; 
    453465} 
    454466 
  • trunk/gui/index.php

    r474 r573  
    1818 **/ 
    1919 
    20 include 'include/ispcp-lib.php'; 
     20require 'include/ispcp-lib.php'; 
    2121 
    22 unset_user_login_data(); 
     22//unset_user_login_data(); 
     23do_session_timeout(); 
    2324 
    2425init_login(); 
     
    3334 
    3435        if (register_user($uname, $_POST['upass'])) { 
     36            redirect_to_level_page(); 
     37        } 
    3538 
    36         if ($_SESSION['user_type'] == 'admin') { 
    37  
    38                         header("Location: admin/index.php"); 
    39  
    40                 } else if ($_SESSION['user_type'] == 'reseller') { 
    41  
    42                         header("Location: reseller/index.php"); 
    43  
    44                 } else if ($_SESSION['user_type'] == 'user') { 
    45  
    46                         header("Location: client/index.php"); 
    47  
    48     } 
    49  
    50         } else { 
    51  
    52                 header('Location: index.php'); 
    53  
    54         } 
     39        header('Location: index.php'); 
     40        exit; 
    5541 
    5642} 
    5743 
    58  
     44if (check_user_login()) { 
     45    if (!redirect_to_level_page()) { 
     46        unset_user_login_data(); 
     47    } 
     48
    5949 
    6050