Skip to content

Commit

Permalink
Got refresh working
Browse files Browse the repository at this point in the history
  • Loading branch information
zz9pzza committed Apr 15, 2012
1 parent 4d13527 commit 4035019
Show file tree
Hide file tree
Showing 37 changed files with 80 additions and 36 deletions.
1 change: 1 addition & 0 deletions README
Expand Up @@ -9,3 +9,4 @@ Uses the following debian packages
libdbix-class-perl
libdbix-class-schema-loader-perl
libmime-lite-perl
libcgi-session-expiresessions-perl
14 changes: 0 additions & 14 deletions templates/cgi/file_view.html
@@ -1,17 +1,3 @@
<div class="ui-container">
<!--
<div class="content">
<div class="page-header">
<h1>Page name <small>Supporting text or tagline</small></h1>
</div>
-->
<div class="row">
<h2>Main content</h2>
</div>

<footer>
<p>[% footer_text %]</p>
</footer>

</div> <!-- /ui-container -->

16 changes: 12 additions & 4 deletions templates/lib/footer
@@ -1,11 +1,19 @@
<div id="footer"></div>
<script type="text/javascript" src="/vault/js/jquery-1.7.1.min.js"></script>
[% IF menu == 0 %]
</div>
[% ELSE %]
</div> <!-- content -->
<footer>
<p>[% footer_text %]</p>
</footer>

</div> <!-- /ui-container -->
[%END%]

<script type="text/javascript" src="/vault/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/vault/js/jquery-ui-1.8.18.custom.min.js"></script>
[% LOAD %]
<script type="text/javascript">
$(function(){
[% SCRIPT %]
});
</script>

</div>
43 changes: 34 additions & 9 deletions templates/lib/header
Expand Up @@ -10,30 +10,55 @@
<ul class="nav">
<li class="ui-state-active"><a href="#masthead">View Files</a></li>
<li><a href="#uploadfile">Upload File</a></li>
<li><a href="#preferences">Preferences</a></li>
<li><a href="#groupadmin">Group Admin</a></li>
<li><a href="#useradmin">User Admin</a></li>
<li><a href="#about">About</a></li>
<li><a href="#help">Help</a></li>
<li><a id='logout' href="javascript:void(0);">Logout</a></li>
<li><span class="ui-state-disabled">Logout in :</span></li>
<li><span class="ui-state-disabled"><div id="timetologout"></div></span></li>
<li><a id='refresh' href="javascript:void(0);">Logout in :</a></li>
<li><a id='refresh1' href="javascript:void(0);"><div id="timetologout"></div></a></li>
</ul>
</div>
</div>
</div>
<div class="ui-container">
<div class="content">
<div class="page-header">
<h1>Welcome [%username%]</h1>
</div>


[% LOAD= "$LOAD
<script type='text/javascript' src='/vault/js/jquery.countdown.js'></script>
<script type='text/javascript' src='/vault/js/jquery.cookie.js'></script>
" %]
[% SCRIPT="$SCRIPT
function delete_cookie(cookie_name) {
document.cookie = cookie_name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
\$('#timetologout').countdown({until: +${time_to_expire},format: 'MS',compact: true,expiryUrl: './index.cgi'});
\$('#logout').click(function() {
window.location = '${rooturl}${rootcgi}';
delete_cookie('VAULTID');
\$.post('./logout',{ },function(){},'json') ;
});

function refresh_cookie(data) {
var date = new Date();
value=\$.cookie('VAULTID')
\$('#timetologout').countdown('change', {until: +(data.timeout-2)});
date.setTime(date.getTime() + (data.timeout * 1000));
\$.cookie('VAULTID', value, { expires: date, path: '/',secure:1 });
}

function refresh_timer () {
\$.post('./refresh_cookie',{},function(data){refresh_cookie(data)},'json');
}

function logout () {
delete_cookie('VAULTID');
window.location = '${rooturl}logout';
}

<!-- If we logout at the right time we will have lost the session and will fail to delete from the database -->
\$('#timetologout').countdown({until: +(${time_to_expire}-2),format: 'MS',compact: true, onExpiry: logout});
\$('#refresh').click(function(){refresh_timer()});
\$('#refresh1').click(function(){refresh_timer()});
\$('#logout').click(function(){logout()});
" %]

[%END%]
Expand Down
2 changes: 2 additions & 0 deletions web/cgi/Vault/core.pm
Expand Up @@ -10,6 +10,7 @@ use Carp;
use Readonly;
use Error qw(:try);
use Data::Dumper ;
use CGI::Session::ExpireSessions;

Readonly our $LOG_FATAL => '1000';
Readonly our $LOG_APP_INFORM => '0800';
Expand Down Expand Up @@ -39,6 +40,7 @@ sub new {
);

$self->{'dbi'}=DBI->connect ($dsn,$self->{'settings'}->{database},$self->{'settings'}->{password}) ;
CGI::Session::ExpireSessions -> new(dbh => $self->{'dbi'},delta=>2*60*60) -> expire_db_sessions();

bless $self, $class;
return $self;
Expand Down
18 changes: 12 additions & 6 deletions web/cgi/index.cgi
Expand Up @@ -15,18 +15,19 @@ $| = 1;
#--------------------------------------------------

my $ROOTDIR = '/home/vault';
my $ROOTURL = 'https://stage.transformativeworks.org/';
my $ROOTCGI = '/vault_cgi/index.cgi';
my $ROOTURL = 'https://stage.transformativeworks.org/vault_cgi/';
my $ROOTCGI = 'index.cgi';

my $cgi = CGI->new( );
my ($param, $template,$cookie,$session,$vault,$menu,$time_to_expire);
my ($param, $template,$cookie,$session,$vault,$menu,$time_to_expire,$user_info,$username);

#--------------------------------------------------
# application
#--------------------------------------------------
my $script_add= '';
my $html_add= '';
$menu=1;
$username="";
$vault = Vault::core->new();
# Set the default action to be the login page.
my $action='display_login_page';
Expand All @@ -40,15 +41,19 @@ if ( $action eq 'display_login_page' ) {
} else {
$cookie=$cgi->cookie("VAULTID") || undef;
$session = new CGI::Session("driver:MySQL", $cookie, {Handle=>$vault->dbi()});
$user_info = $vault->{schema}->resultset('User')->search ( {
'username' =>$session->param("username") } )->single;
$vault->log_event('Looking for user '.$session->param("username"),$Vault::core::LOG_APP_INFORM);
$time_to_expire=$session->atime()+$session->expire()-time;
# Display an error if we do not have a valid session
if ( !defined ( $session->param("username") ) ) {
if ( !( defined ($user_info ) && defined ( $user_info->get_column('username')) ) ) {
$vault->log_event("Attempt to access $action with no session( $cookie )",$Vault::core::LOG_APP_INFORM);
print 'Location: '.$vault->get_default_value('cgi_path')."/index.cgi\n\n" ;
exit 0 ;
}

}
$username=$user_info->get_column('username') ;
}
$vault->log_event('Found user '.$username,$Vault::core::LOG_APP_INFORM);
if ( $action eq 'front_page' ) {
$template = 'file_view.html';
}
Expand All @@ -63,6 +68,7 @@ my $vars = {
footer_text => $vault->get_default_value('footer_text','NONE'),
menu => $menu,
time_to_expire => $time_to_expire,
username => $username ,
};


Expand Down
2 changes: 2 additions & 0 deletions web/cgi/logout
Expand Up @@ -18,5 +18,7 @@ my $cgi = CGI->new( );
my $vault = Vault::core->new();
my $cookie=$cgi->cookie("VAULTID") || undef;
my $session = new CGI::Session("driver:MySQL", $cookie, {Handle=>$vault->dbi()});
$vault->log_event('User: '.$session->param("username").' Session id ' .$cookie .' logged out',$Vault::core::LOG_INFO) ;
$session->delete();
print 'Location: '.$vault->get_default_value('cgi_path')."/index.cgi\n\n" ;
exit 0;
3 changes: 2 additions & 1 deletion web/cgi/register
Expand Up @@ -21,13 +21,14 @@ use JSON;
$| = 1;

my $vault = Vault::core->new();
my $cgi = new CGI ;
my $passphrase=param('passphrase');
my $ppr = Authen::Passphrase::BlowfishCrypt->new(
cost => $vault->get_default_value('passphrase_cost',11), salt_random => 1,
passphrase => $passphrase);
my $salt=$ppr->salt_base64;
my $hash=$ppr->hash_base64;
print header('application/json');
print $cgi->header('application/json');
my $json = new JSON;
$json = $json->pretty() ;
$json = $json->ascii() ;
Expand Down
5 changes: 3 additions & 2 deletions web/cgi/resend_email
Expand Up @@ -14,9 +14,10 @@ use Vault::core;

$| = 1;

print header('application/json');

my $vault = Vault::core->new();
my $cgi = new CGI ;
print $cgi->header('application/json');

my $username= param('username');
my $found_user=$vault->{schema}->resultset('User')->search ( {
'username' => $username
Expand Down
4 changes: 4 additions & 0 deletions web/img/_notes/bird.png.mno
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<info>
<infoitem key="fw_source" value="/CSS/CSS frameworks/bootstrap-boilerplate-31.08.11/assets/img/bird.png" />
</info>
4 changes: 4 additions & 0 deletions web/img/_notes/browsers.png.mno
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<info>
<infoitem key="fw_source" value="/CSS/CSS frameworks/bootstrap-boilerplate-31.08.11/assets/img/browsers.png" />
</info>
4 changes: 4 additions & 0 deletions web/img/_notes/sprite-icons.png.mno
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<info>
<infoitem key="fw_source" value="/CSS/CSS frameworks/bootstrap-boilerplate-31.08.11/assets/img/sprite-icons.png" />
</info>
Binary file added web/img/arrows.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/bg_fallback.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/bird.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/browsers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/example-diagram-01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/example-diagram-02.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/example-diagram-03.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/grid-18px.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/progress_bar.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/slider_handles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/sprite-icons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-bg_flat_0_aaaaaa_40x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-bg_glass_55_fbf9ee_1x400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-bg_glass_75_dadada_1x400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-bg_glass_75_e6e6e6_1x400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-bg_glass_75_ffffff_1x400.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-bg_highlight-soft_75_cccccc_1x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-bg_inset-soft_95_fef1ec_1x100.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-icons_2e83ff_256x240.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-icons_333333_256x240.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-icons_454545_256x240.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-icons_888888_256x240.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-icons_cd0a0a_256x240.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/img/ui-icons_dev_256x240.psd
Binary file not shown.
Binary file added web/img/ui-icons_f6cf3b_256x240.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4035019

Please sign in to comment.