Location: PHPKode > projects > phlyMail Lite > phlymail/handlers/contacts/preview.php
<?php
/**
 * preview.php - Used in the preview window
 * @package phlyMail Nahariya 4.0+ Default branch
 * @subpackage Handler Contacts
 * @copyright 2005-2010 phlyLabs, Berlin (http://phlylabs.de)
 * @version 4.1.3 2010-08-07
 */
// Only valid within phlyMail
if (!defined('_IN_PHM_')) die();
$error = false;
require_once(dirname(__FILE__).'/driver.mysql.php');
$cDB = new contacts_driver($_SESSION['phM_uid']);
$passthru = give_passthrough(1);
$bday = '';
$contact = array();
$id = '';
// That's it with the session
session_write_close();

if (isset($_REQUEST['id']) && $_REQUEST['id']) {
    if (isset($_REQUEST['getimage']) && $_REQUEST['getimage']) {
        $thumb = $DB->thumb_get('contacts', $_REQUEST['id'], $_REQUEST['getimage'] == 2 ? 'large' : 'small');
        if (false !== $thumb) {
            header('Content-Type: '.$thumb['mime']);
            header('Content-Transfer-Encoding: binary');
            header('Content-Length: '.$thumb['size']);
            echo $thumb['stream'];
            exit;
        }
        $contact = $cDB->get_contactimage($_REQUEST['id'], CONTACTS_VISIBILITY_MODE);
        if ($contact['image'] && $contact['imagemeta']) {
            $contact['imagemeta'] = unserialize($contact['imagemeta']);
            switch ($contact['imagemeta'][2]) {
                case 1: header('Content-Type: image/gif');  break;
                case 2: header('Content-Type: image/jpeg'); break;
                case 3: header('Content-Type: image/png');  break;
                default: exit;
            }
            echo phm_stripslashes($contact['image']);
        }
        exit;
    }
    $contact = $cDB->get_contact($_REQUEST['id'], CONTACTS_VISIBILITY_MODE);
    $id = intval($_REQUEST['id']);
    // Handle Birthday
    if ($contact['birthday'] && $contact['birthday'] != '0000-00-00') {
        list ($byear, $bmonth, $bday) = explode('-', $contact['birthday']);
        if ($byear == '0000') $byear = '';
        $bday = str_replace(array('%y', '%m' , '%d'), array($byear, $bmonth, $bday), $WP_msg['date_formatstring']);
    }
}
if (isset($_REQUEST['print'])) {
    $tpl = new fxl_cached_template($_PM_['path']['frontend'].'/templates/contacts.print.tpl', $_PM_['path']['tplcache'].'contacts.print.tpl');
    $tpl->assign_block('printhead');
    $tpl->assign_block('printfoot');
} else {
    $tpl = new fxl_cached_template($_PM_['path']['frontend'].'/templates/contacts.preview.tpl', $_PM_['path']['tplcache'].'contacts.preview.tpl');
    $tpl->assign_block('may_edit');
}
if (isset($contact['group'])) {
    if (sizeof($contact['group']) > 5) {
        $contact['group'] = array_merge(array_slice($contact['group'], 0, 5), array('&hellipse;'));
    }
    $contact['group'] = implode(', ', $contact['group']); // Stringify
}

$tpl->assign(array
        ('msg_nick' => $WP_msg['nick']
        ,'msg_fname' => $WP_msg['fnam']
        ,'msg_lname' => $WP_msg['snam']
        ,'msg_email1' => $WP_msg['emai1']
        ,'msg_email2' => $WP_msg['emai2']
        ,'msg_www' => $WP_msg['www']
        ,'msg_address' => $WP_msg['address']
        ,'msg_fonprivate' => $WP_msg['fon']
        ,'msg_fonbusiness' => $WP_msg['fon2']
        ,'msg_mobile' => $WP_msg['cell']
        ,'msg_fax' => $WP_msg['fax']
        ,'msg_bday' => $WP_msg['bday']
        ,'msg_bday_format' => $WP_msg['bday_format']
        ,'msg_comment' => $WP_msg['cmnt']
        ,'leg_general' => $WP_msg['General']
        ,'leg_personal' => $WP_msg['Personal']
        ,'leg_business' => $WP_msg['Business']
        ,'msg_company' => $WP_msg['company']
        ,'msg_comp_dep' => $WP_msg['comp_dep']
        ,'msg_addr' => $WP_msg['address']
        ,'msg_street' => $WP_msg['street']
        ,'msg_zip' => $WP_msg['zip']
        ,'msg_location' => $WP_msg['location']
        ,'msg_region' => $WP_msg['state']
        ,'msg_country' => $WP_msg['country']
        ,'displayname' => $contact['displayname']
        ,'nick' => isset($contact['nick']) ? $contact['nick'] : ''
        ,'group' => isset($contact['group']) ? $contact['group'] : ''
        ,'fname' => isset($contact['firstname']) ? $contact['firstname'] : ''
        ,'lname' => isset($contact['lastname']) ? $contact['lastname'] : ''
        ,'email1' => isset($contact['email1']) ? $contact['email1'] : ''
        ,'email2' => isset($contact['email2']) ? $contact['email2'] : ''
        ,'www' => isset($contact['www']) ? $contact['www'] : ''
        ,'address' => isset($contact['address']) ? $contact['address'] : ''
        ,'fon_private' => isset($contact['tel_private']) ? $contact['tel_private'] : ''
        ,'fon_business' => isset($contact['tel_business']) ? $contact['tel_business'] : ''
        ,'cellular' => isset($contact['cellular']) ? $contact['cellular'] : ''
        ,'fax' => isset($contact['fax']) ? $contact['fax'] : ''
        ,'comment' => isset($contact['comments']) ? $contact['comments'] : ''
        ,'company' => isset($contact['company']) ? $contact['company'] : ''
        ,'department' => isset($contact['comp_dep']) ? $contact['comp_dep'] : ''
        ,'addr' => (isset($contact['address']) ? $contact['address'] : '')
                .(isset($contact['address']) && $contact['address'] && isset($contact['address2']) && $contact['address2'] ? '<br />' : '')
                .(isset($contact['address2']) ? $contact['address2'] : '')
        ,'street' => isset($contact['street']) ? $contact['street'] : ''
        ,'zip_location' => ((isset($contact['zip']) ? $contact['zip'] : ''))
                .((isset($contact['zip']) && $contact['zip'] && isset($contact['location']) && $contact['location']) ? ' / ' : '')
                .(isset($contact['location']) ? $contact['location'] : '')
        ,'region_country' => (isset($contact['region']) ? $contact['region'] : '')
                .((isset($contact['region']) && $contact['region'] && isset($contact['country']) && $contact['country']) ? ' / ' : '')
                .(isset($contact['country']) ? $contact['country'] : '')
        ,'comp_addr' => (isset($contact['comp_address']) ? $contact['comp_address'] : '')
                .(isset($contact['comp_address2']) ? $contact['comp_address2'] : '')
        ,'comp_street' => isset($contact['comp_street']) ? $contact['comp_street'] : ''
        ,'comp_zip_location' => ((isset($contact['comp_zip']) ? $contact['comp_zip'] : ''))
                .((isset($contact['comp_zip']) && $contact['comp_zip']
                        && isset($contact['comp_location']) && $contact['comp_location']) ? ' / ' : '')
                .(isset($contact['comp_location']) ? $contact['comp_location'] : '')
        ,'comp_region_country' => (isset($contact['comp_region']) ? $contact['comp_region'] : '')
                .((isset($contact['comp_region']) && $contact['comp_region']
                        && isset($contact['comp_country']) && $contact['comp_country']) ? ' / ' : '')
                .(isset($contact['comp_country']) ? $contact['comp_country'] : '')
        ,'comp_www' => isset($contact['comp_www']) ? $contact['comp_www'] : ''
        ,'comp_cellular' => isset($contact['comp_cellular']) ? $contact['comp_cellular'] : ''
        ,'comp_fax' => isset($contact['comp_fax']) ? $contact['comp_fax'] : ''
        ,'passthrough' => give_passthrough(2)
        ,'action' => $action
        ,'id' => $id
        ,'bday' => $bday
        ,'leg_details' => $WP_msg['LegDetails']
        ,'theme_path' => $_PM_['path']['theme']
        ,'msg_edit' => $WP_msg['Edit']
        ,'msg_print' => $WP_msg['prnt']
        ,'edit_url' => PHP_SELF.'?load=edit_contact&handler=contacts&id='.$id.'&'.$passthru
        ,'print_url' => PHP_SELF.'?load=preview&handler=contacts&id='.$id.'&print=1&'.$passthru
        ,'composemail_url' => PHP_SELF.'?handler=core&load=compose_email&'.$passthru.'&to='
        ));

$thumb = $DB->thumb_get('contacts', $id, 'small');
if (false !== $thumb) {
    $tpl->fill_block('ifimage', array
            ('imgurl' => htmlspecialchars(PHP_SELF.'?load=preview&handler=contacts&id='.$id.'&getimage=1&'.$passthru)
            ,'imgw' => $thumb['width']
            ,'imgh' => $thumb['height']
            ));
} elseif ($contact['imagemeta']) {
    $contact['imagemeta'] = unserialize($contact['imagemeta']);
    $tpl->fill_block('ifimage', array
            ('imgurl' => htmlspecialchars(PHP_SELF.'?load=preview&handler=contacts&id='.$id.'&getimage=1&'.$passthru)
            ,'imgw' => $contact['imagemeta'][0]
            ,'imgh' => $contact['imagemeta'][1]
            ));
}
?>
Return current item: phlyMail Lite