&1",'r');
$line = '';
while (! feof($handle)) {
$chr = fread($handle, 1);
$line .= $chr;
if ($chr == "\n") {
print str_replace("\n", "
\n", $line);
$line = '';
flush();
}
elseif (strlen($line) > $line_length) {
print $line."
\n";
$line = '';
flush();
}
}
print $line."
\n";
flush;
return;
}
$version = PHPKI_VERSION;
# Who does the webserver run as (apache,www-data,etc)?
$uid = posix_getuid();
$pwdinfo = posix_getpwuid($uid);
$uname = $pwdinfo['name'];
# Permissions on the file store.
$store_perms=0770;
# Where are we?
$here = dirname($_SERVER['SCRIPT_FILENAME']);
$submit = gpvar('submit');
$stage = gpvar('stage');
$organization = gpvar('organization');
$unit = gpvar('unit');
$contact = gpvar('contact');
$locality = gpvar('locality');
$province = gpvar('province');
$country = gpvar('country');
$common_name = gpvar('common_name');
$passwd = gpvar('passwd');
$passwdv = gpvar('passwdv');
$expiry = gpvar('expiry');
$keysize = gpvar('keysize');
$base_url = gpvar('base_url');
$openssl_bin = gpvar('openssl_bin');
$passwd_file = gpvar('passwd_file');
$getting_help = gpvar('getting_help');
$ca_prefix = gpvar('ca_prefix');
$header_title = gpvar('header_title');
$store_dir = gpvar('store_dir');
if ($base_url && substr($base_url,-1) != '/') $base_url .= '/';
$hidden_fields = '
';
switch ($stage) {
case 'validate':
$er = '';
if (! $country) $er .= 'Missing Country
';
if (! $province) $er .= 'Missing State/Province
';
if (! $locality) $er .= 'Missing Locality
';
if (! $organization) $er .= 'Missing Organization
';
if (! $unit) $er .= 'Missing Unit/Department
';
if (! $contact) $er .= 'Missing Contact E-mail Address
';
if (! $common_name) $er .= 'Missing Common Name
';
if (! $passwd) $er .= 'Missing Certificate Password
';
if (! $passwdv) $er .= 'Missing Certificate Password Verification "Again"
';
if (! $header_title) $er .= 'Missing Header Title
';
if (! $passwd_file) $er .= 'Missing User Password File Location';
if (! $store_dir) $er .= 'Missing Storage Directory
';
if ( $passwd && strlen($passwd) < 8 )
$er .= 'Certificate password is too short.
';
if ( $passwd and $passwd != $passwdv )
$er .= 'Password and password verification do not match.
';
if ( $contact && ! is_email($contact) )
$er .= 'E-mail address ('. htvar($contact) . ') may be invalid.
';
if (strpos($store_dir,$_SERVER['DOCUMENT_ROOT']) === 0)
$er .= 'Store directory must exist somewhere outside of DOCUMENT_ROOT ('.$_SERVER['DOCUMENT_ROOT'].').
';
if (strpos($store_dir,dirname($_SERVER['SCRIPT_FILENAME'])) === 0)
$er .= 'Store directory cannot exist within the PHPki installation directory ('.dirname($_SERVER['SCRIPT_FILENAME']).').
';
if (! $er) {
if (! file_exists($store_dir) ) {
if ( ! mkdir("$store_dir",$store_perms)) $er .= "Could not create the store directory \"$store_dir\"
";
}
if (file_exists($store_dir)) {
if (! chmod($store_dir, $store_perms)) $er .= "Could not change permissions on the store directory \"$store_dir\"
";
if (! is_readable($store_dir)) $er .= "The store directory \"$store_dir\" is not readable by the web server user \"$uname\"
";
if (! is_writeable($store_dir)) $er .= "The store directory \"$store_dir\: is not writeable by the web server user \"$uname\"
";
}
else {
$er .= "Store directory \"$store_dir\" does not exist. You will have to manually create it as desribed in the setup form.
";
}
}
if ( $er )
$er = '
' . $er . '