Location: PHPKode > projects > Philosopher'Stone Personal > pssp/walencr.php
<?php

// Copyright (c) 2010 by Paul M. Foster <hide@address.com>
// Licensed under PostgreSQL License (see LICENSE file)

include('setup.php');

allowed(127, 5);

if (!$session->bfpasswd) {
	emsg('You must supply a password first.');
	redirect('walndx.php');
}

/* ***** FIELDS TO BE VALIDATED ***** */

$fields = array(
	'filename' => array('label' => 'Filename', 'default' => $_POST['filename'], 'rules' => 'required|maxlength[255]')
);

/* ***** CLASS REGISTRATION ***** */

$sc->register('pwfile', array('class' => 'pwfile', 'shared' => true));
$sc->register('validation', array('class' => 'validation', 'arguments' => '%fields%'));


/* ***** INSTANTIATE CLASSES HERE ***** */

$app_navs = $sc->appnavs;
$pwf = $sc->pwfile;
$v = $sc->validation;

/* ***** VALIDATE USER DATA ***** */

if (isset($_POST['encrypt']) && $_POST['encrypt'] == 'Encrypt') {
	if (0 == $v->validate()) {
		$pwf->encrypt_to_file($_POST['filename']);
		smsg('Your cleartext file has been encrypted.');
		redirect('walsel.php');
	}
}
elseif (isset($_POST['skip']) && $_POST['skip'] == 'Never mind') {
	redirect('walsel.php');
}


/* ***** PAGE SETUP ***** */

$meta['app_navs'] = $app_navs->get();
$meta['mod_navs'] = array(
	array('url' => 'waladd.php', 'txt' => 'Add Entry'),
	array('url' => 'waldump.php', 'txt' => 'Dump Cleartext'),
	array('url' => 'walndx.php', 'txt' => 'Master Password')
);
$meta['file_mtime'] = date("d F Y H:i:s", filemtime($_SERVER['SCRIPT_FILENAME']));
$meta['focus_field'] = 'filename';
$meta['return_url'] = 'walencr.php';
$meta['app_title'] = 'Wallet';
$meta['page_title'] = 'Encrypt Cleartext Wallet File';
$meta['view_file'] = fullpath('view', 'walencr');

include('generic.php');
Return current item: Philosopher'Stone Personal