[16591] | 1 | <?php |
---|
| 2 | defined('USER_COLLEC_PATH') or die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | function get_current_collection_id($create=true) |
---|
| 5 | { |
---|
| 6 | global $user; |
---|
| 7 | |
---|
| 8 | // active in db |
---|
| 9 | $query = ' |
---|
| 10 | SELECT id |
---|
| 11 | FROM '.COLLECTIONS_TABLE.' |
---|
| 12 | WHERE |
---|
| 13 | active = 1 |
---|
| 14 | AND user_id = '.$user['id'].' |
---|
| 15 | ;'; |
---|
| 16 | $result = pwg_query($query); |
---|
| 17 | |
---|
| 18 | if (pwg_db_num_rows($result)) |
---|
| 19 | { |
---|
| 20 | list($col_id) = pwg_db_fetch_row($result); |
---|
| 21 | return $col_id; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | // new one |
---|
| 25 | if ($create) |
---|
| 26 | { |
---|
| 27 | $UserCollection = new UserCollection('new', array(), 'temp', 1); |
---|
[16688] | 28 | return $UserCollection->getParam('id'); |
---|
[16591] | 29 | } |
---|
| 30 | |
---|
| 31 | return false; |
---|
| 32 | } |
---|
| 33 | |
---|
[20090] | 34 | function uc_check_email_validity($mail_address) |
---|
| 35 | { |
---|
| 36 | if (function_exists('email_check_format')) |
---|
| 37 | { |
---|
| 38 | return email_check_format($mail_address); // Piwigo 2.5 |
---|
| 39 | } |
---|
| 40 | else if (version_compare(PHP_VERSION, '5.2.0') >= 0) |
---|
| 41 | { |
---|
| 42 | return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false; |
---|
| 43 | } |
---|
| 44 | else |
---|
| 45 | { |
---|
| 46 | $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase |
---|
| 47 | $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name |
---|
| 48 | $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; |
---|
| 49 | |
---|
| 50 | return (bool)preg_match($regex, $mail_address); |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
[20093] | 54 | function get_collection_preferred_image_orders() |
---|
| 55 | { |
---|
| 56 | global $conf, $page; |
---|
| 57 | |
---|
| 58 | return trigger_event('get_category_preferred_image_orders', array( |
---|
| 59 | array(l10n('Date added to collection, new → old'), 'add_date DESC', true), |
---|
| 60 | array(l10n('Date added to collection, old → new'), 'add_date ASC', true), |
---|
| 61 | array(l10n('Photo title, A → Z'), 'name ASC', true), |
---|
| 62 | array(l10n('Photo title, Z → A'), 'name DESC', true), |
---|
| 63 | array(l10n('Date created, new → old'), 'date_creation DESC', true), |
---|
| 64 | array(l10n('Date created, old → new'), 'date_creation ASC', true), |
---|
| 65 | array(l10n('Date posted, new → old'), 'date_available DESC', true), |
---|
| 66 | array(l10n('Date posted, old → new'), 'date_available ASC', true), |
---|
| 67 | array(l10n('Rating score, high → low'), 'rating_score DESC', $conf['rate']), |
---|
| 68 | array(l10n('Rating score, low → high'), 'rating_score ASC', $conf['rate']), |
---|
| 69 | array(l10n('Visits, high → low'), 'hit DESC', true), |
---|
| 70 | array(l10n('Visits, low → high'), 'hit ASC', true), |
---|
| 71 | )); |
---|
| 72 | } |
---|
| 73 | |
---|
[16591] | 74 | ?> |
---|