1 | <?php |
---|
2 | defined('USER_COLLEC_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | function 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 | |
---|
24 | function 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 | |
---|
34 | function 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 → old'), 'add_date DESC', true), |
---|
40 | array(l10n('Date added to collection, old → new'), 'add_date ASC', true), |
---|
41 | array(l10n('Photo title, A → Z'), 'name ASC', true), |
---|
42 | array(l10n('Photo title, Z → A'), 'name DESC', true), |
---|
43 | array(l10n('Date created, new → old'), 'date_creation DESC', true), |
---|
44 | array(l10n('Date created, old → new'), 'date_creation ASC', true), |
---|
45 | array(l10n('Date posted, new → old'), 'date_available DESC', true), |
---|
46 | array(l10n('Date posted, old → new'), 'date_available ASC', true), |
---|
47 | array(l10n('Rating score, high → low'), 'rating_score DESC', $conf['rate']), |
---|
48 | array(l10n('Rating score, low → high'), 'rating_score ASC', $conf['rate']), |
---|
49 | array(l10n('Visits, high → low'), 'hit DESC', true), |
---|
50 | array(l10n('Visits, low → high'), 'hit ASC', true), |
---|
51 | )); |
---|
52 | } |
---|
53 | |
---|
54 | function get_collections_preferred_orders() |
---|
55 | { |
---|
56 | return array( |
---|
57 | array(l10n('Name, A → Z'), 'name ASC', true), |
---|
58 | array(l10n('Name, Z → A'), 'name DESC', true), |
---|
59 | array(l10n('Date created, new → old'), 'date_creation DESC', true), |
---|
60 | array(l10n('Date created, old → new'), 'date_creation ASC', true), |
---|
61 | array(l10n('Photos number, high → low'), 'nb_images DESC', true), |
---|
62 | array(l10n('Photos number, low → high'), 'nb_images ASC', true), |
---|
63 | ); |
---|
64 | } |
---|
65 | |
---|
66 | ?> |
---|