source: extensions/UserCollections/include/functions.inc.php @ 24421

Last change on this file since 24421 was 24421, checked in by mistic100, 11 years ago

new system for shares : password protection, link timeout, management popup + for mails
handle lightbox conflicts
menublock is visible by AMM

File size: 2.5 KB
Line 
1<?php
2defined('USER_COLLEC_PATH') or die('Hacking attempt!');
3
4function uc_check_email_validity($mail_address)
5{
6  if (function_exists('email_check_format'))
7  {
8    return email_check_format($mail_address); // Piwigo 2.5
9  }
10  else if (version_compare(PHP_VERSION, '5.2.0') >= 0)
11  {
12    return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;
13  }
14  else
15  {
16    $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
17    $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
18    $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
19
20    return (bool)preg_match($regex, $mail_address);
21  }
22}
23
24function get_random_key($length=32)
25{
26  $chars = '0123456789abcdefabcdef';
27  for ($s=''; strlen($s)<$length; )
28  {
29    $s.= $chars[rand(0, strlen($chars) - 1)];
30  }
31  return $s;
32}
33
34function get_collection_preferred_image_orders()
35{
36  global $conf;
37   
38  return trigger_event('get_category_preferred_image_orders', array(
39    array(l10n('Date added to collection, new &rarr; old'), 'add_date DESC', true),
40    array(l10n('Date added to collection, old &rarr; new'), 'add_date ASC',  true),
41    array(l10n('Photo title, A &rarr; Z'),        'name ASC',             true),
42    array(l10n('Photo title, Z &rarr; A'),        'name DESC',            true),
43    array(l10n('Date created, new &rarr; old'),   'date_creation DESC',   true),
44    array(l10n('Date created, old &rarr; new'),   'date_creation ASC',    true), 
45    array(l10n('Date posted, new &rarr; old'),    'date_available DESC',  true),
46    array(l10n('Date posted, old &rarr; new'),    'date_available ASC',   true),
47    array(l10n('Rating score, high &rarr; low'),  'rating_score DESC',    $conf['rate']),
48    array(l10n('Rating score, low &rarr; high'),  'rating_score ASC',     $conf['rate']),
49    array(l10n('Visits, high &rarr; low'),        'hit DESC',             true),
50    array(l10n('Visits, low &rarr; high'),        'hit ASC',              true),
51    ));
52}
53
54function get_collections_preferred_orders()
55{
56  return array(
57    array(l10n('Name, A &rarr; Z'),               'name ASC',           true),
58    array(l10n('Name, Z &rarr; A'),               'name DESC',          true),
59    array(l10n('Date created, new &rarr; old'),   'date_creation DESC', true),
60    array(l10n('Date created, old &rarr; new'),   'date_creation ASC',  true), 
61    array(l10n('Photos number, high &rarr; low'), 'nb_images DESC',     true),
62    array(l10n('Photos number, low &rarr; high'), 'nb_images ASC',      true),
63    );
64}
65
66?>
Note: See TracBrowser for help on using the repository browser.