1 |
194 |
ahitrov |
package session::State; |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use warnings 'all'; |
5 |
|
|
use vars qw($AUTOLOAD); |
6 |
|
|
|
7 |
|
|
|
8 |
|
|
sub new { |
9 |
|
|
my ($proto) = @_; |
10 |
|
|
my $class = ref($proto) || $proto; |
11 |
|
|
my $self = {}; |
12 |
|
|
bless $self, $class; |
13 |
|
|
|
14 |
|
|
# ������� ������������ ������� |
15 |
|
|
$self->{db_type} = 'none'; |
16 |
|
|
$self->{storage} = '@SESSION_STORAGE@' || 'FILE'; ## ��������: FILE POSTGRES MEMCACHED |
17 |
|
|
$self->{session_dir} = '@SESSIONS@'; |
18 |
|
|
$self->{session_directory} = '@SESSIONS@'; |
19 |
|
|
|
20 |
|
|
$self->{domain} = '@SESSION_DOMAIN@'; |
21 |
|
|
$self->{cookie} = 'lsid'; |
22 |
|
|
$self->{expires} = '@SESSION_EXPIRES@' || ''; |
23 |
|
|
|
24 |
|
|
$self->{lifetime} = '@SESSION_LIFETIME@'; |
25 |
|
|
$self->{lifetime} *= 3600; |
26 |
|
|
$self->{checkout} = $self->{lifetime} - int ($self->{lifetime} / 2); |
27 |
|
|
|
28 |
|
|
$self->{db_keepalive} = 0; |
29 |
|
|
$self->{db_host} = ''; |
30 |
|
|
$self->{db_name} = ''; |
31 |
|
|
$self->{db_user} = ''; |
32 |
|
|
$self->{db_password} = ''; |
33 |
|
|
$self->{db_port} = ''; |
34 |
|
|
|
35 |
|
|
$self->{data_directory} = ''; |
36 |
|
|
$self->{images_directory} = ''; |
37 |
|
|
$self->{binary_directory} = ''; |
38 |
|
|
$self->{preview} = ''; |
39 |
|
|
$self->{debug} = ''; |
40 |
|
|
$self->{store_method} = ''; |
41 |
|
|
$self->{cascade} = ''; |
42 |
|
|
$self->{memcached_enable} = ''; |
43 |
|
|
|
44 |
|
|
$self->{facebook_app_id} = '@FACEBOOK_APP_ID@'; |
45 |
|
|
$self->{facebook_app_secret} = '@FACEBOOK_APP_SECRET@'; |
46 |
|
|
$self->{facebook_redirect_uri} = '@FACEBOOK_REDIRECT_URL@'; |
47 |
|
|
$self->{facebook_user_post_url} = '@FACEBOOK_USER_POST_URL@'; |
48 |
|
|
|
49 |
|
|
$self->{vk_app_id} = '@VK_APP_ID@'; |
50 |
|
|
$self->{vk_app_secret} = '@VK_APP_SECRET@'; |
51 |
|
|
$self->{vk_redirect_uri} = '@VK_REDIRECT_URL@'; |
52 |
|
|
$self->{vk_user_post_url} = '@VK_USER_POST_URL@'; |
53 |
|
|
|
54 |
243 |
ahitrov |
$self->{mailru_app_id} = '@MAILRU_APP_ID@'; |
55 |
|
|
$self->{mailru_app_secret} = '@MAILRU_APP_SECRET@'; |
56 |
|
|
$self->{mailru_redirect_uri} = '@MAILRU_REDIRECT_URL@'; |
57 |
|
|
$self->{mailru_user_post_url} = '@MAILRU_USER_POST_URL@'; |
58 |
|
|
|
59 |
194 |
ahitrov |
$self->{connection_timeout} = '@CONNECTION_TIMEOUT@'; |
60 |
|
|
|
61 |
|
|
$self->_init_(); |
62 |
|
|
$self; |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
sub info { |
66 |
|
|
my $self = shift; |
67 |
|
|
return unless ref $self; |
68 |
|
|
|
69 |
|
|
for (sort keys %{$self->{attributes}}) { |
70 |
|
|
my $la = length $_; |
71 |
|
|
warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n"; |
72 |
|
|
} |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
sub _init_ { |
76 |
|
|
my $self = shift; |
77 |
|
|
|
78 |
|
|
# ������� ������������ ������� |
79 |
|
|
$self->{attributes}->{$_} = 'SCALAR' for qw( |
80 |
|
|
db_type |
81 |
|
|
session_dir |
82 |
|
|
session_directory |
83 |
|
|
domain |
84 |
|
|
cookie |
85 |
|
|
expires |
86 |
|
|
storage |
87 |
|
|
lifetime |
88 |
|
|
checkout |
89 |
|
|
db_keepalive |
90 |
|
|
db_host |
91 |
|
|
db_port |
92 |
|
|
db_name |
93 |
|
|
db_user |
94 |
|
|
db_password |
95 |
|
|
data_directory images_directory binary_directory preview debug store_method cascade memcached_enable |
96 |
|
|
); |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
sub AUTOLOAD { |
100 |
|
|
my $self = shift; |
101 |
|
|
my $attribute = $AUTOLOAD; |
102 |
|
|
|
103 |
|
|
$attribute =~ s/.*:://; |
104 |
|
|
return unless $attribute =~ /[^A-Z]/; # ��������� ������ ���� DESTROY |
105 |
|
|
|
106 |
|
|
if (!exists $self->{attributes}->{$attribute}) { |
107 |
|
|
warn "Contenido Error (session::State): ����� ������, ��� �������� �� ���������� ��������������� ��������: ->$attribute()\n"; |
108 |
|
|
return; |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
$self->{$attribute} = shift @_ if $#_>=0; |
112 |
|
|
$self->{$attribute}; |
113 |
|
|
} |
114 |
|
|
|
115 |
|
|
1; |