Ignore:
Timestamp:
Jul 12, 2012, 8:28:27 PM (12 years ago)
Author:
plg
Message:

(by mistic100, but svn commit crashes for him)

-use random public_id, preventing to access other public collections
-use colorbox to browse inside a collection
-small css fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/UserCollection.class.php

    r16625 r16658  
    2424      'active' => false,
    2525      'public' => false,
     26      'public_id' => null,
    2627      );
    2728    $this->images = array();
     29   
     30    // access from public id
     31    if ( strlen($col_id) == 10 and strpos($col_id, 'uc') === 0 )
     32    {
     33      $query = '
     34SELECT id
     35  FROM '.COLLECTIONS_TABLE.'
     36  WHERE public_id = "'.$col_id.'"
     37;';
     38      $result = pwg_query($query);
     39     
     40      if (!pwg_db_num_rows($result))
     41      {
     42        $col_id = 0;
     43      }
     44      else
     45      {
     46        list($col_id) = pwg_db_fetch_row($result);
     47      }
     48    }
    2849   
    2950    // load specific collection
     
    3758    nb_images,
    3859    active,
    39     public
     60    public,
     61    public_id
    4062  FROM '.COLLECTIONS_TABLE.'
    4163  WHERE
     
    4870      {
    4971        $this->data['col_id'] = $col_id;
    50         list(
    51           $this->data['user_id'],
    52           $this->data['name'],
    53           $this->data['date_creation'],
    54           $this->data['nb_images'],
    55           $this->data['active'],
    56           $this->data['public']
    57           ) = pwg_db_fetch_row($result);
     72        $this->data = array_merge(
     73          $this->data,
     74          pwg_db_fetch_assoc($result)
     75          );
    5876       
    5977        // make sur all pictures of the collection exist
     
    89107      $this->data['active'] = $active;
    90108      $this->data['public'] = $public;
     109      $this->data['public_id'] = 'uc'.hash('crc32', uniqid(serialize($this->data, true)));
    91110     
    92111      $query = '
     
    96115    date_creation,
    97116    active,
    98     public
     117    public,
     118    public_id
    99119  )
    100120  VALUES(
     
    103123    NOW(),
    104124    '.(int)$this->data['active'].',
    105     '.(int)$this->data['public'].'
     125    '.(int)$this->data['public'].',
     126    "'.$this->data['public_id'].'"
    106127  )
    107128;';
     
    271292      'PUBLIC' => (bool)$this->data['public'],
    272293      'DATE_CREATION' => format_date($this->data['date_creation'], true),
    273       'U_PUBLIC' => get_absolute_root_url().USER_COLLEC_PUBLIC . 'view/'.$this->data['col_id'],
     294      'U_PUBLIC' => get_absolute_root_url().USER_COLLEC_PUBLIC . 'view/'.$this->data['public_id'],
    274295      'IS_TEMP' =>  $this->data['name'] == 'temp',
    275296      );
Note: See TracChangeset for help on using the changeset viewer.