\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++ )
{
// ensures that the photo is written to the specified jpeg_temp_dir
$jpeg_temp_dir = realpath($jpeg_temp_dir.'/');
$jpeg_filename = tempnam($jpeg_temp_dir.'/', 'pla');
$outjpeg = fopen($jpeg_filename, "wb");
fwrite($outjpeg, $jpeg_data[$i]);
fclose ($outjpeg);
$jpeg_data_size = filesize( $jpeg_filename );
if( $jpeg_data_size < 6 ) {
echo $lang['jpeg_contains_errors'];
echo ''. $lang['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 = "pla.*";
$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, md5crypt, sha, smd5, ssha, or clear.
*/
function password_hash( $password_clear, $enc_type )
{
global $lang;
$enc_type = strtolower( $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':
if( ! defined( 'CRYPT_MD5' ) || 0 == CRYPT_MD5 )
pla_error( $lang['install_not_support_blowfish'] );
$new_value = '{crypt}' . crypt( $password_clear , '$1$' . random_salt(9) );
break;
case 'blowfish':
if( ! defined( 'CRYPT_BLOWFISH' ) || 0 == CRYPT_BLOWFISH )
pla_error( $lang['install_not_support_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( $lang['install_no_mash'] );
}
break;
case 'ssha':
if( function_exists( 'mhash' ) && function_exists( 'mhash_keygen_s2k' ) ) {
mt_srand( (double) microtime() * 1000000 );
$salt = mhash_keygen_s2k( MHASH_SHA1, $password_clear, substr( pack( "h*", md5( mt_rand() ) ), 0, 8 ), 4 );
$new_value = "{ssha}".base64_encode( mhash( MHASH_SHA1, $password_clear.$salt ).$salt );
} else {
pla_error( $lang['install_no_mash'] );
}
break;
case 'smd5':
if( function_exists( 'mhash' ) && function_exists( 'mhash_keygen_s2k' ) ) {
mt_srand( (double) microtime() * 1000000 );
$salt = mhash_keygen_s2k( MHASH_MD5, $password_clear, substr( pack( "h*", md5( mt_rand() ) ), 0, 8 ), 4 );
$new_value = "{smd5}".base64_encode( mhash( MHASH_SHA1, $password_clear.$salt ).$salt );
} else {
pla_error( $lang['install_no_mash'] );
}
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( realpath( 'VERSION' ) ) )
return 'unknown version';
$f = fopen( realpath( 'VERSION' ), 'r' );
$version = fread( $f, filesize( realpath( 'VERSION' ) ) );
fclose( $f );
return $version;
}
function draw_chooser_link( $form_element )
{
global $lang;
$href = "javascript:dnChooserPopup('$form_element');";
$title = $lang['chooser_link_tooltip'];
echo "