Changeset 1068


Ignore:
Timestamp:
Mar 7, 2006, 2:20:02 AM (18 years ago)
Author:
rvelices
Message:

bug fix: call to undefined session_create in register.php (added function
log_user called from identification and register)

bug fix: empty line at the beginning of functions.php disallowed cookies
(and hence logging in)

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r1064 r1068  
    1 
    21<?php
    32// +-----------------------------------------------------------------------+
     
    188187;';
    189188  pwg_query($query);
    190  
     189
    191190  $query = '
    192191DELETE FROM '.GROUP_ACCESS_TABLE.'
     
    206205
    207206  $sources_of = array();
    208  
     207
    209208  while ($row = mysql_fetch_array($result))
    210209  {
     
    446445  {
    447446    array_push($query_ids, $row['category_id']);
    448    
     447
    449448    array_push(
    450449      $datas,
     
    13501349{
    13511350  $images_of = array();
    1352  
     1351
    13531352  $query = '
    13541353SELECT category_id, image_id
     
    13691368      );
    13701369  }
    1371  
     1370
    13721371  $fulldirs = get_fulldirs(
    13731372    array_keys($images_of)
     
    16191618
    16201619  $destinations_of = array();
    1621  
     1620
    16221621  while ($row = mysql_fetch_array($result))
    16231622  {
     
    16391638    // let's suppose we only need a single turn
    16401639    $need_new_turn = false;
    1641    
     1640
    16421641    foreach ($destinations_of as $source => $destinations)
    16431642    {
     
    16561655            array($source) // no cyclic link
    16571656            );
    1658          
     1657
    16591658          if (count($missing_destinations) > 0)
    16601659          {
     
    16851684      $filtered_destinations_of[$category] = array();
    16861685    }
    1687    
     1686
    16881687    foreach ($destinations_of as $source => $destinations)
    16891688    {
     
    17131712
    17141713  $sources_of = array();
    1715  
     1714
    17161715  foreach ($destinations_of as $source => $destinations)
    17171716  {
     
    17261725    }
    17271726  }
    1728  
     1727
    17291728  // eventually, filter
    17301729  if (is_array($categories))
     
    17381737      $filtered_sources_of[$category] = array();
    17391738    }
    1740    
     1739
    17411740    foreach ($sources_of as $destination => $sources)
    17421741    {
     
    17841783    }
    17851784  }
    1786  
     1785
    17871786  $query = '
    17881787SELECT image_id, category_id
     
    18031802
    18041803  $inserts = array();
    1805  
     1804
    18061805  foreach ($sources_of as $destination => $sources)
    18071806  {
    18081807    // merge all images from the sources of this destination
    18091808    $sources_images = array();
    1810    
     1809
    18111810    foreach ($sources as $source)
    18121811    {
     
    18751874 *
    18761875 * Warning: only virtual links can be removed, physical links are protected.
    1877  * 
     1876 *
    18781877 * @param int destination
    18791878 * @param array sources
     
    18941893;';
    18951894  pwg_query($query);
    1896  
     1895
    18971896  // The strategy is the following:
    18981897  //
     
    19281927    $destinations_of[$destination]
    19291928    );
    1930  
     1929
    19311930  // unlink sources images from destinations
    19321931  $query = '
     
    19491948
    19501949  $request_random = array();
    1951  
     1950
    19521951  while ($row = mysql_fetch_array($result))
    19531952  {
     
    19791978{
    19801979  global $conf;
    1981  
     1980
    19821981  // is the given category name only containing blank spaces ?
    19831982  if (preg_match('/^\s*$/', $category_name))
     
    19851984    return array('error' => l10n('cat_error_name'));
    19861985  }
    1987        
     1986
    19881987  $parent_id = !empty($parent_id) ? $parent_id : 'NULL';
    19891988
     
    19941993;';
    19951994  list($current_rank) = mysql_fetch_array(pwg_query($query));
    1996  
     1995
    19971996  $insert = array(
    19981997    'name' => $category_name,
     
    20012000    'uploadable' => 'false',
    20022001    );
    2003    
     2002
    20042003  if ($parent_id != 'NULL')
    20052004  {
     
    20132012    $insert{'id_uppercat'} = $parent{'id'};
    20142013    $insert{'global_rank'} = $parent{'global_rank'}.'.'.$insert{'rank'};
    2015    
     2014
    20162015    // at creation, must a category be visible or not ? Warning : if the
    20172016    // parent category is invisible, the category is automatically create
     
    20252024      $insert{'visible'} = $conf['newcat_default_visible'];
    20262025    }
    2027    
     2026
    20282027    // at creation, must a category be public or private ? Warning : if the
    20292028    // parent category is private, the category is automatically create
     
    20672066;';
    20682067  pwg_query($query);
    2069  
     2068
    20702069  return array(
    20712070    'info' => l10n('cat_virtual_added'),
  • trunk/identification.php

    r1061 r1068  
    5757  if ($row['password'] == $conf['pass_convert']($_POST['password']))
    5858  {
    59     $session_length = $conf['session_length'];
     59    $remember_me = false;
    6060    if ($conf['authorize_remembering']
    6161        and isset($_POST['remember_me'])
    6262        and $_POST['remember_me'] == 1)
    6363    {
    64       $session_length = $conf['remember_me_length'];
     64      $remember_me = true;
    6565    }
    66     session_set_cookie_params($session_length);
    67     session_start();
    68     $_SESSION['id'] = $row['id'];
     66    log_user( $row['id'], $remember_me);
    6967    redirect(empty($redirect_to) ? 'category.php' : $redirect_to);
    7068  }
  • trunk/include/functions_user.inc.php

    r1036 r1068  
    8383;';
    8484    list($next_id) = mysql_fetch_array(pwg_query($query));
    85    
     85
    8686    $insert =
    8787      array(
     
    9494    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    9595    mass_inserts(USERS_TABLE, array_keys($insert), array($insert));
    96    
     96
    9797    create_user_infos($next_id);
    9898  }
     
    118118
    119119  $userdata = array();
    120  
     120
    121121  $query = '
    122122SELECT ';
     
    139139  WHERE '.$conf['user_fields']['id'].' = \''.$user_id.'\'
    140140;';
    141  
     141
    142142  $row = mysql_fetch_array(pwg_query($query));
    143143
     
    160160    }
    161161  }
    162  
     162
    163163  $row = array_merge($row, mysql_fetch_array($result));
    164  
     164
    165165  foreach ($row as $key => $value)
    166166  {
     
    195195;';
    196196      pwg_query($query);
    197  
     197
    198198      $query = '
    199199INSERT INTO '.USER_CACHE_TABLE.'
     
    308308    $private_array = array_unique($private_array);
    309309  }
    310  
     310
    311311  // retrieve category ids directly authorized to the user
    312312  $query = '
     
    341341  // true.
    342342  array_push($forbidden_array, '-1');
    343  
     343
    344344  return implode(',', $forbidden_array);
    345345}
     
    354354{
    355355  global $conf;
    356  
     356
    357357  $query = '
    358358SELECT '.$conf['user_fields']['username'].'
     
    369369    return false;
    370370  }
    371  
     371
    372372  return $username;
    373373}
     
    434434{
    435435  global $conf;
    436  
     436
    437437  list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
    438438
     
    480480    return false;
    481481  }
    482  
     482
    483483  return $groupname;
    484484}
     
    497497{
    498498  global $user, $conf;
    499  
     499
    500500  $directories =
    501501    array(
     
    508508  {
    509509    $filepath = $directory.'/'.$filename;
    510    
     510
    511511    if (file_exists($filepath))
    512512    {
     
    514514    }
    515515  }
    516  
     516
    517517  return false;
    518518}
     519
     520/*
     521 * Performs all required actions for user login
     522 * @param int user_id
     523 * @param bool remember_me
     524 * @return void
     525*/
     526function log_user($user_id, $remember_me)
     527{
     528  global $conf;
     529  $session_length = $conf['session_length'];
     530  if ($remember_me)
     531  {
     532    $session_length = $conf['remember_me_length'];
     533  }
     534  session_set_cookie_params($session_length);
     535  session_start();
     536  $_SESSION['id'] = $user_id;
     537}
     538
    519539?>
  • trunk/register.php

    r1004 r1068  
    3737    array_push($errors, $lang['reg_err_pass']);
    3838  }
    39  
     39
    4040  $errors =
    4141    array_merge(
     
    4545                    $_POST['mail_address'])
    4646      );
    47  
     47
    4848  if (count($errors) == 0)
    4949  {
    5050    $user_id = get_userid($_POST['login']);
    51     $session_id = session_create($user_id, $conf['session_length']);
    52     $url = 'category.php?id='.$session_id;
    53     redirect($url);
     51    log_user( $user_id, false);
     52    redirect('category.php');
    5453  }
    5554}
     
    7776
    7877  'U_HOME' => PHPWG_ROOT_PATH.'category.php',
    79  
     78
    8079  'F_ACTION' => 'register.php',
    8180  'F_LOGIN' => $login,
Note: See TracChangeset for help on using the changeset viewer.