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 |
253 |
ahitrov |
$self->{project} = '@PROJECT@'; |
16 |
|
|
|
17 |
194 |
ahitrov |
$self->{db_type} = 'none'; |
18 |
|
|
$self->{storage} = '@SESSION_STORAGE@' || 'FILE'; ## ��������: FILE POSTGRES MEMCACHED |
19 |
|
|
$self->{session_dir} = '@SESSIONS@'; |
20 |
|
|
$self->{session_directory} = '@SESSIONS@'; |
21 |
|
|
|
22 |
|
|
$self->{domain} = '@SESSION_DOMAIN@'; |
23 |
|
|
$self->{cookie} = 'lsid'; |
24 |
|
|
$self->{expires} = '@SESSION_EXPIRES@' || ''; |
25 |
|
|
|
26 |
|
|
$self->{lifetime} = '@SESSION_LIFETIME@'; |
27 |
|
|
$self->{lifetime} *= 3600; |
28 |
|
|
$self->{checkout} = $self->{lifetime} - int ($self->{lifetime} / 2); |
29 |
|
|
|
30 |
|
|
$self->{db_keepalive} = 0; |
31 |
|
|
$self->{db_host} = ''; |
32 |
|
|
$self->{db_name} = ''; |
33 |
|
|
$self->{db_user} = ''; |
34 |
|
|
$self->{db_password} = ''; |
35 |
|
|
$self->{db_port} = ''; |
36 |
|
|
|
37 |
|
|
$self->{data_directory} = ''; |
38 |
|
|
$self->{images_directory} = ''; |
39 |
|
|
$self->{binary_directory} = ''; |
40 |
|
|
$self->{preview} = ''; |
41 |
|
|
$self->{debug} = ''; |
42 |
|
|
$self->{store_method} = ''; |
43 |
|
|
$self->{cascade} = ''; |
44 |
|
|
|
45 |
253 |
ahitrov |
$self->{memcached_enable} = lc( '@MEMCACHED_ENABLE@' ) eq 'yes' ? 1 : 0; |
46 |
|
|
$self->{memcached_backend} = '@MEMCACHED_BACKEND@'; |
47 |
|
|
$self->{memcached_select_timeout} = '@MEMCACHED_SELECT_TIMEOUT@' || 0.2; |
48 |
|
|
$self->{memcached_servers} = [qw(@MEMCACHED_SERVERS@)]; |
49 |
|
|
$self->{memcached_enable_compress} = lc( '@MEMCACHED_ENABLE_COMPRESS@' ) eq 'yes' ? 1 : 0; |
50 |
|
|
$self->{memcached_delayed} = lc('@MEMCACHED_DELAYED@') eq 'yes' ? 1 : 0; |
51 |
|
|
$self->{memcached_set_mode} = lc('@MEMCACHED_SET_MODE@') eq 'add' ? 'add' : 'set'; |
52 |
|
|
$self->{memcached_busy_lock} = 60; |
53 |
|
|
$self->{memcached_namespace} = lc( $self->{'project'} ).'|plugin_session|'; |
54 |
|
|
|
55 |
|
|
$self->{memcached_object_expire} = undef; |
56 |
|
|
|
57 |
|
|
$self->{storage} = 'FILE' if $self->{storage} eq 'MEMCACHED' && !$self->{memcached_enable}; |
58 |
|
|
|
59 |
194 |
ahitrov |
$self->{facebook_app_id} = '@FACEBOOK_APP_ID@'; |
60 |
|
|
$self->{facebook_app_secret} = '@FACEBOOK_APP_SECRET@'; |
61 |
|
|
$self->{facebook_redirect_uri} = '@FACEBOOK_REDIRECT_URL@'; |
62 |
|
|
$self->{facebook_user_post_url} = '@FACEBOOK_USER_POST_URL@'; |
63 |
|
|
|
64 |
|
|
$self->{vk_app_id} = '@VK_APP_ID@'; |
65 |
|
|
$self->{vk_app_secret} = '@VK_APP_SECRET@'; |
66 |
|
|
$self->{vk_redirect_uri} = '@VK_REDIRECT_URL@'; |
67 |
|
|
$self->{vk_user_post_url} = '@VK_USER_POST_URL@'; |
68 |
|
|
|
69 |
243 |
ahitrov |
$self->{mailru_app_id} = '@MAILRU_APP_ID@'; |
70 |
|
|
$self->{mailru_app_secret} = '@MAILRU_APP_SECRET@'; |
71 |
|
|
$self->{mailru_redirect_uri} = '@MAILRU_REDIRECT_URL@'; |
72 |
|
|
$self->{mailru_user_post_url} = '@MAILRU_USER_POST_URL@'; |
73 |
|
|
|
74 |
194 |
ahitrov |
$self->{connection_timeout} = '@CONNECTION_TIMEOUT@'; |
75 |
|
|
|
76 |
|
|
$self->_init_(); |
77 |
|
|
$self; |
78 |
|
|
} |
79 |
|
|
|
80 |
|
|
sub info { |
81 |
|
|
my $self = shift; |
82 |
|
|
return unless ref $self; |
83 |
|
|
|
84 |
|
|
for (sort keys %{$self->{attributes}}) { |
85 |
|
|
my $la = length $_; |
86 |
|
|
warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n"; |
87 |
|
|
} |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
sub _init_ { |
91 |
|
|
my $self = shift; |
92 |
|
|
|
93 |
|
|
# ������� ������������ ������� |
94 |
|
|
$self->{attributes}->{$_} = 'SCALAR' for qw( |
95 |
|
|
db_type |
96 |
|
|
session_dir |
97 |
|
|
session_directory |
98 |
|
|
domain |
99 |
|
|
cookie |
100 |
|
|
expires |
101 |
|
|
storage |
102 |
|
|
lifetime |
103 |
|
|
checkout |
104 |
|
|
db_keepalive |
105 |
|
|
db_host |
106 |
|
|
db_port |
107 |
|
|
db_name |
108 |
|
|
db_user |
109 |
|
|
db_password |
110 |
253 |
ahitrov |
|
111 |
|
|
memcached_enable |
112 |
|
|
memcached_servers |
113 |
|
|
memcached_select_timeout |
114 |
|
|
memcached_backend |
115 |
|
|
memcached_enable_compress |
116 |
|
|
memcached_set_mode |
117 |
|
|
memcached_object_expire |
118 |
|
|
memcached_busy_lock |
119 |
|
|
memcached_delayed |
120 |
|
|
memcached_namespace |
121 |
|
|
|
122 |
|
|
data_directory |
123 |
|
|
images_directory |
124 |
|
|
binary_directory |
125 |
|
|
preview |
126 |
|
|
debug |
127 |
|
|
store_method |
128 |
|
|
cascade |
129 |
194 |
ahitrov |
); |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
sub AUTOLOAD { |
133 |
|
|
my $self = shift; |
134 |
|
|
my $attribute = $AUTOLOAD; |
135 |
|
|
|
136 |
|
|
$attribute =~ s/.*:://; |
137 |
|
|
return unless $attribute =~ /[^A-Z]/; # ��������� ������ ���� DESTROY |
138 |
|
|
|
139 |
|
|
if (!exists $self->{attributes}->{$attribute}) { |
140 |
|
|
warn "Contenido Error (session::State): ����� ������, ��� �������� �� ���������� ��������������� ��������: ->$attribute()\n"; |
141 |
|
|
return; |
142 |
|
|
} |
143 |
|
|
|
144 |
|
|
$self->{$attribute} = shift @_ if $#_>=0; |
145 |
|
|
$self->{$attribute}; |
146 |
|
|
} |
147 |
|
|
|
148 |
|
|
1; |