\n\n";
// for each jpegPhoto in the entry, draw it (there may be only one, and that's okay)
$jpeg_data = ldap_get_values_len( $conn, $entry, "jpegphoto");
for( $i=0; $i<$jpeg_data['count']; $i++ )
{
$jpeg_filename = $jpeg_temp_dir . '/' . basename( tempnam ('.', 'djp') );
$outjpeg = fopen($jpeg_filename, "wb");
fwrite($outjpeg, $jpeg_data[$i]);
fclose ($outjpeg);
$jpeg_data_size = filesize( $jpeg_filename );
if( $jpeg_data_size < 6 ) {
echo "jpegPhoto contains errors ";
echo 'Delete Photo';
continue;
}
$jpeg_dimensions = getimagesize ($jpeg_filename);
$width = $jpeg_dimensions[0];
$height = $jpeg_dimensions[1];
if( $width > 300 ) {
$scale_factor = 300 / $width;
$img_width = 300;
$img_height = $height * $scale_factor;
} else {
$img_width = $width;
$img_height = $height;
}
echo " \n";
echo "" . number_format($jpeg_data_size) . " bytes. ";
echo "$width x $height pixels. \n\n";
if( $draw_delete_buttons )
{ ?>
Delete Photo
|
\n\n";
// If they have misconfigured their config.php, use default values
if( ! isset( $jpeg_tmp_keep_time ) )
$jpeg_tmp_keep_time = 120;
if( $jpeg_tmp_keep_time == 0 )
$jpeg_tmp_keep_time = 10;
// delete old jpeg files.
$jpegtmp_wildcard = "djp.*";
$handle = opendir($jpeg_temp_dir);
while (($file = readdir($handle)) != false)
if (eregi($jpegtmp_wildcard, $file))
{
$file = "$jpeg_temp_dir/$file";
if ((time() - filemtime($file)) > $jpeg_tmp_keep_time)
unlink ( $file );
}
closedir($handle);
}
/*
* Returns the root DN of the specified server_id, or false if it
* can't find it (ie, the server won't give it to us).
* Tested with OpenLDAP 2.0, Netscape iPlanet, and Novell eDirectory 8.7 (nldap.com)
* Please report any and all bugs!!
*/
function try_to_get_root_dn( $server_id )
{
if( ! have_auth_info( $server_id ) )
return false;
$ds = pla_ldap_connect( $server_id );
if( ! $ds )
return false;
$r = @ldap_read( $ds, '', 'objectClass=*', array( 'namingContexts' ) );
if( ! $r )
return false;
$r = @ldap_get_entries( $ds, $r );
if( isset( $r[0]['namingcontexts'][0] ) ) {
$root_dn = $r[0]['namingcontexts'][0];
return $root_dn;
} else {
return false;
}
}
/*
* Hashes a password and returns the hash based on the enc_type, which can be one of
* crypt, md5, sha, or clear.
*/
function password_hash( $password_clear, $enc_type )
{
switch( $enc_type )
{
case 'crypt':
$new_value = '{crypt}' . crypt( $password_clear, random_salt(2) );
break;
case 'md5':
$new_value = '{md5}' . base64_encode( pack( 'H*' , md5( $password_clear) ) );
break;
case 'md5crypt':
$new_value = '{crypt}' . crypt( $password_clear , '$1$' . random_salt(9) );
break;
case 'blowfish':
$new_value = '{crypt}' . crypt( $password_clear , '$2$' . random_salt(13) );
break;
case 'sha':
if( function_exists( 'mhash' ) ) {
$new_value = '{sha}' . base64_encode( mhash( MHASH_SHA1, $password_clear) );
} else {
pla_error( "Your PHP install does not have the mhash() function." .
" Cannot do SHA hashes." );
}
break;
case 'clear':
default:
$new_value = $password_clear;
}
return $new_value;
}
/*
* Returns the version as a string as stored in the VERSION file.
*/
function pla_version()
{
if( ! file_exists( 'VERSION' ) )
return 'unknown version';
$f = fopen( 'VERSION', 'r' );
$version = fread( $f, filesize( 'VERSION' ) );
fclose( $f );
return $version;
}
function draw_chooser_link( $form_element )
{
$href = "javascript:dnChooserPopup('$form_element');";
echo "