package session::State; use strict; use warnings 'all'; use vars qw($AUTOLOAD); sub new { my ($proto) = @_; my $class = ref($proto) || $proto; my $self = {}; bless $self, $class; # зашитая конфигурация плагина $self->{db_type} = 'none'; $self->{storage} = '@SESSION_STORAGE@' || 'FILE'; ## Значения: FILE POSTGRES MEMCACHED $self->{session_dir} = '@SESSIONS@'; $self->{session_directory} = '@SESSIONS@'; $self->{domain} = '@SESSION_DOMAIN@'; $self->{cookie} = 'lsid'; $self->{expires} = '@SESSION_EXPIRES@' || ''; $self->{lifetime} = '@SESSION_LIFETIME@'; $self->{lifetime} *= 3600; $self->{checkout} = $self->{lifetime} - int ($self->{lifetime} / 2); $self->{db_keepalive} = 0; $self->{db_host} = ''; $self->{db_name} = ''; $self->{db_user} = ''; $self->{db_password} = ''; $self->{db_port} = ''; $self->{data_directory} = ''; $self->{images_directory} = ''; $self->{binary_directory} = ''; $self->{preview} = ''; $self->{debug} = ''; $self->{store_method} = ''; $self->{cascade} = ''; $self->{memcached_enable} = ''; $self->{facebook_app_id} = '@FACEBOOK_APP_ID@'; $self->{facebook_app_key} = '@FACEBOOK_APP_KEY@'; $self->{facebook_app_secret} = '@FACEBOOK_APP_SECRET@'; $self->{facebook_authorize_url} = '@FACEBOOK_AUTHORIZE_URL@'; $self->{facebook_access_token_url} = '@FACEBOOK_ACCESS_TOKEN_URL@'; $self->{facebook_user_info_url} = '@FACEBOOK_USER_INFO_URL@'; $self->{facebook_redirect_uri} = '@FACEBOOK_REDIRECT_URL@'; $self->{facebook_user_post_url} = '@FACEBOOK_USER_POST_URL@'; $self->{vk_app_id} = '@VK_APP_ID@'; $self->{vk_app_secret} = '@VK_APP_SECRET@'; $self->{vk_authorize_url} = '@VK_AUTHORIZE_URL@' || 'http://api.vkontakte.ru/oauth/authorize'; $self->{vk_access_token_url} = '@VK_ACCESS_TOKEN_URL@' || 'https://api.vkontakte.ru/oauth/access_token'; $self->{vk_user_info_url} = '@VK_USER_INFO_URL@' || 'https://api.vkontakte.ru/method/getProfiles'; $self->{vk_redirect_uri} = '@VK_REDIRECT_URL@'; $self->{vk_user_post_url} = '@VK_USER_POST_URL@'; $self->{connection_timeout} = '@CONNECTION_TIMEOUT@'; $self->_init_(); $self; } sub info { my $self = shift; return unless ref $self; for (sort keys %{$self->{attributes}}) { my $la = length $_; warn "\t$_".("\t" x (2-int($la/8))).": $self->{$_}\n"; } } sub _init_ { my $self = shift; # зашитая конфигурация плагина $self->{attributes}->{$_} = 'SCALAR' for qw( db_type session_dir session_directory domain cookie expires storage lifetime checkout db_keepalive db_host db_port db_name db_user db_password data_directory images_directory binary_directory preview debug store_method cascade memcached_enable ); } sub AUTOLOAD { my $self = shift; my $attribute = $AUTOLOAD; $attribute =~ s/.*:://; return unless $attribute =~ /[^A-Z]/; # Отключаем методы типа DESTROY if (!exists $self->{attributes}->{$attribute}) { warn "Contenido Error (session::State): Вызов метода, для которого не существует обрабатываемого свойства: ->$attribute()\n"; return; } $self->{$attribute} = shift @_ if $#_>=0; $self->{$attribute}; } 1;