Line # Revision Author
1 191 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_key} = '@FACEBOOK_APP_KEY@';
46 $self->{facebook_app_secret} = '@FACEBOOK_APP_SECRET@';
47 $self->{facebook_authorize_url} = '@FACEBOOK_AUTHORIZE_URL@';
48 $self->{facebook_access_token_url} = '@FACEBOOK_ACCESS_TOKEN_URL@';
49 $self->{facebook_user_info_url} = '@FACEBOOK_USER_INFO_URL@';
50 $self->{facebook_redirect_uri} = '@FACEBOOK_REDIRECT_URL@';
51 $self->{facebook_user_post_url} = '@FACEBOOK_USER_POST_URL@';
52
53 $self->{vk_app_id} = '@VK_APP_ID@';
54 $self->{vk_app_secret} = '@VK_APP_SECRET@';
55
56 $self->{vk_authorize_url} = '@VK_AUTHORIZE_URL@' || 'http://api.vkontakte.ru/oauth/authorize';
57 $self->{vk_access_token_url} = '@VK_ACCESS_TOKEN_URL@' || 'https://api.vkontakte.ru/oauth/access_token';
58 $self->{vk_user_info_url} = '@VK_USER_INFO_URL@' || 'https://api.vkontakte.ru/method/getProfiles';
59
60 $self->{vk_redirect_uri} = '@VK_REDIRECT_URL@';
61 $self->{vk_user_post_url} = '@VK_USER_POST_URL@';
62
63 $self->{connection_timeout} = '@CONNECTION_TIMEOUT@';
64
65 $self->_init_();
66 $self;
67 }
68
69 sub info {
70 my $self = shift;
71 return unless ref $self;
72
73 for (sort keys %{$self->{attributes}}) {
74 my $la = length $_;
75 warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n";
76 }
77 }
78
79 sub _init_ {
80 my $self = shift;
81
82 # ������� ������������ �������
83 $self->{attributes}->{$_} = 'SCALAR' for qw(
84 db_type
85 session_dir
86 session_directory
87 domain
88 cookie
89 expires
90 storage
91 lifetime
92 checkout
93 db_keepalive
94 db_host
95 db_port
96 db_name
97 db_user
98 db_password
99 data_directory images_directory binary_directory preview debug store_method cascade memcached_enable
100 );
101 }
102
103 sub AUTOLOAD {
104 my $self = shift;
105 my $attribute = $AUTOLOAD;
106
107 $attribute =~ s/.*:://;
108 return unless $attribute =~ /[^A-Z]/; # ��������� ������ ���� DESTROY
109
110 if (!exists $self->{attributes}->{$attribute}) {
111 warn "Contenido Error (session::State): ����� ������, ��� �������� �� ���������� ��������������� ��������: ->$attribute()\n";
112 return;
113 }
114
115 $self->{$attribute} = shift @_ if $#_>=0;
116 $self->{$attribute};
117 }
118
119 1;