Hi all, :)
Is it possible to change the ecard content in the email with only a link to the ecard
Like:
You received an e-card!
Click here to see your e-card! ( Link to the online e-card )
( Just an example to tell you what i mean :D )
I have really no idea how i can do this ??? Because if i change the displayecard.php it will change in the e-mail but also for the online link :(
Hope someone can help me out!
Regards,
Penelope
Never mind, found it! :D
It would be better if you post what you've found for others with same question
Ok i will do my best to remember what i've done, it's been a few weeks ago :)
First make a file called displayimage.php and past the underneath code in this file.
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2006 Coppermine Dev Team
v1.1 originally written by Gregory DEMAR
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.4.9
$Source$
$Revision: 3125 $
$Author: gaugau $
$Date: 2006-06-16 08:48:03 +0200 (Fr, 16 Jun 2006) $
**********************************************/
define('IN_COPPERMINE', true);
define('DISPLAYIMAGE_PHP', true);
define('INDEX_PHP', true);
//define('SMILIES_PHP', true);
require('include/init.inc.php');
if (!USER_ID && $CONFIG['allow_unlogged_access'] == 0) {
$redirect = $redirect . "login.php";
header("Location: $redirect");
exit();
}
if ($CONFIG['enable_smilies']) include("include/smilies.inc.php");
$breadcrumb = '';
$breadcrumb_text = '';
$cat_data = array();
if($CONFIG['read_exif_data'] ){
include("include/exif_php.inc.php");
}
if($CONFIG['read_iptc_data'] ){
include("include/iptc.inc.php");
}
/**
* Local functions definition
*/
# Sanitize the data - to fix the XSS vulnerability - Aditya
function sanitize_data(&$value, $key)
{
if (is_array($value)) {
array_walk($value, 'sanitize_data');
} else {
# sanitize against sql/html injection; trim any nongraphical non-ASCII character:
$value = trim(htmlentities(strip_tags(trim($value,"\x7f..\xff\x0..\x1f")),ENT_QUOTES));
}
}
function html_picture_menu()
{
global $lang_display_image_php, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $CONFIG;
$mime_content = cpg_get_type($CURRENT_PIC_DATA['filename']);
$picmenu = '';
if (false) { //(!($mime_content['content']=='image')) {
$picmenu = <<<EOT
<a href="#" onclick="return MM_openBrWindow('setplayer.php?={$mime_content['extension']}','Set_Player','scrollbars=no,toolbar=no,status=no,resizable=no')" class="admin_menu" >{$lang_display_image_php['set_player']}</a>
EOT;
}
if ((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || ($CONFIG['users_can_edit_pics'] && $CURRENT_PIC_DATA['owner_id'] == USER_ID && USER_ID != 0) || GALLERY_ADMIN_MODE) {
$picmenu .= <<<EOT
<a href="javascript:;" onclick="return MM_openBrWindow('picEditor.php?id={$CURRENT_PIC_DATA['pid']}','Crop_Picture','scrollbars=yes,toolbar=no,status=yes,resizable=yes')" class="admin_menu" >{$lang_display_image_php['crop_pic']}</a> <a href="editOnePic.php?id={$CURRENT_PIC_DATA['pid']}&what=picture" class="admin_menu">{$lang_display_image_php['edit_pic']}</a> <a href="delete.php?id={$CURRENT_PIC_DATA['pid']}&what=picture" class="admin_menu" onclick="return confirm('{$lang_display_image_php['confirm_del']}'); return false; ">{$lang_display_image_php['del_pic']}</a>
EOT;
}
return $picmenu;
}
// Display picture information
function html_picinfo()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $FAVPICS, $REFERER;
global $album, $lang_picinfo, $lang_display_image_php, $lang_byte_units, $lastup_date_fmt;
if ($CURRENT_PIC_DATA['owner_id'] && $CURRENT_PIC_DATA['owner_name']) {
$owner_link = '<a href ="profile.php?uid=' . $CURRENT_PIC_DATA['owner_id'] . '">' . $CURRENT_PIC_DATA['owner_name'] . '</a> ';
} else {
$owner_link = '';
}
if (GALLERY_ADMIN_MODE && $CURRENT_PIC_DATA['pic_raw_ip']) {
if ($CURRENT_PIC_DATA['pic_hdr_ip']) {
$ipinfo = ' (' . $CURRENT_PIC_DATA['pic_hdr_ip'] . '[' . $CURRENT_PIC_DATA['pic_raw_ip'] . ']) / ';
} else {
$ipinfo = ' (' . $CURRENT_PIC_DATA['pic_raw_ip'] . ') / ';
}
} else {
if ($owner_link) {
$ipinfo = '/ ';
} else {
$ipinfo = '';
}
}
$info[$lang_picinfo['Filename']] = htmlspecialchars($CURRENT_PIC_DATA['filename']);
$info[$lang_picinfo['Album name']] = '<span class="alblink">' . $owner_link . $ipinfo . '<a href="thumbnails.php?album=' . $CURRENT_PIC_DATA['aid'] . '">' . $CURRENT_ALBUM_DATA['title'] . '</a></span>';
if ($CURRENT_PIC_DATA['votes'] > 0) {
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$prefix = $THEME_DIR;
} else {
$prefix = '';
}
if (GALLERY_ADMIN_MODE) {
$width = 800;
$height = 500;
} else {
$width = 400;
$height = 250;
}
$detailsLink = $CONFIG['vote_details'] ? ' (<a href="#" onclick="MM_openBrWindow(\'stat_details.php?type=vote&pid='.$CURRENT_PIC_DATA['pid'].'&sort=sdate&dir=&sdate=1&ip=1&rating=1&referer=1&browser=1&os=1\',\'\',\'resizable=yes,width='.$width.',height='.$height.',top=50,left=50,scrollbars=yes\'); return false;">'.$lang_picinfo['details'].'</a>)' : '';
$info[sprintf($lang_picinfo['Rating'], $CURRENT_PIC_DATA['votes'])] = '<img src="' . $prefix . 'images/rating' . round($CURRENT_PIC_DATA['pic_rating'] / 2000) . '.gif" align="middle" alt="" />'.$detailsLink;
}
if ($CURRENT_PIC_DATA['keywords'] != "") {
$info[$lang_picinfo['Keywords']] = '<span class="alblink">' . preg_replace("/(\S+)/", "<a href=\"thumbnails.php?album=search&search=\\1\">\\1</a>" , $CURRENT_PIC_DATA['keywords']) . '</span>';
}
for ($i = 1; $i <= 4; $i++) {
if ($CONFIG['user_field' . $i . '_name']) {
if ($CURRENT_PIC_DATA['user' . $i] != "") {
$info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
}
}
}
$info[$lang_picinfo['File Size']] = ($CURRENT_PIC_DATA['filesize'] > 10240 ? ($CURRENT_PIC_DATA['filesize'] >> 10) . ' ' . $lang_byte_units[1] : $CURRENT_PIC_DATA['filesize'] . ' ' . $lang_byte_units[0]);
$info[$lang_picinfo['File Size']] = '<span dir="ltr">' . $info[$lang_picinfo['File Size']] . '</span>';
$info[$lang_picinfo['Date Added']] = localised_date($CURRENT_PIC_DATA['ctime'],$lastup_date_fmt);
$info[$lang_picinfo['Dimensions']] = sprintf($lang_display_image_php['size'], $CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']);
$detailsLink = ($CURRENT_PIC_DATA['hits'] && $CONFIG['vote_details'] && GALLERY_ADMIN_MODE) ? ' (<a href="#" onclick="MM_openBrWindow(\'stat_details.php?type=hits&pid='.$CURRENT_PIC_DATA['pid'].'&sort=sdate&dir=&sdate=1&ip=1&search_phrase=1&referer=1&browser=1&os=1\',\'\',\'resizable=yes,width=800,height=500,top=50,left=50,scrollbars=yes\'); return false;">'.$lang_picinfo['details'].'</a>)' : '';
$info[$lang_picinfo['Displayed']] = sprintf($lang_display_image_php['views'], $CURRENT_PIC_DATA['hits']);
$info[$lang_picinfo['Displayed']] .= $detailsLink;
$path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
if ($CONFIG['read_exif_data']) $exif = exif_parse_file($path_to_pic);
if (isset($exif) && is_array($exif)) {
array_walk($exif, 'sanitize_data');
$info = array_merge($info,$exif);
}
if ($CONFIG['read_iptc_data']) $iptc = get_IPTC($path_to_pic);
if (isset($iptc) && is_array($iptc)) {
array_walk($iptc, 'sanitize_data');
if (isset($iptc['Title'])) $info[$lang_picinfo['iptcTitle']] = $iptc['Title'];
if (isset($iptc['Copyright'])) $info[$lang_picinfo['iptcCopyright']] = $iptc['Copyright'];
if (!empty($iptc['Keywords'])) $info[$lang_picinfo['iptcKeywords']] = implode(' ',$iptc['Keywords']);
if (isset($iptc['Category'])) $info[$lang_picinfo['iptcCategory']] = $iptc['Category'];
if (!empty($iptc['SubCategories'])) $info[$lang_picinfo['iptcSubCategories']] = implode(' ',$iptc['SubCategories']);
}
// Create the absolute URL for display in info
$info[$lang_picinfo['URL']] = '<a href="' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') .basename($_SERVER['PHP_SELF']) . "?pos=-$CURRENT_PIC_DATA[pid]" . '" >' . $CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') . basename($_SERVER['PHP_SELF']) . "?pos=-$CURRENT_PIC_DATA[pid]" . '</a>';
// with subdomains the variable is $_SERVER["SERVER_NAME"] does not return the right value instead of using a new config variable I reused $CONFIG["ecards_more_pic_target"] no trailing slash in the configure
// Create the add to fav link
$ref = $REFERER ? "&ref=$REFERER" : '';
if (!in_array($CURRENT_PIC_DATA['pid'], $FAVPICS)) {
$info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['addFav'] . '</a>';
} else {
$info[$lang_picinfo['addFavPhrase']] = "<a href=\"addfav.php?pid=" . $CURRENT_PIC_DATA['pid'] . $ref . "\" >" . $lang_picinfo['remFav'] . '</a>';
}
/**
* Filter file information
*/
$info = CPGPluginAPI::filter('file_info',$info);
return theme_html_picinfo($info);
}
function get_subcat_data($parent, $level)
{
global $CONFIG, $ALBUM_SET_ARRAY;
$result = cpg_db_query("SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$parent'");
if (mysql_num_rows($result) > 0) {
$rowset = cpg_db_fetch_rowset($result);
foreach ($rowset as $subcat) {
$result = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = {$subcat['cid']}");
$album_count = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$ALBUM_SET_ARRAY[] = $row['aid'];
} // while
}
if ($level > 1) get_subcat_data($subcat['cid'], $level -1);
}
}
/**
* Main code
*/
$pos = isset($_GET['pos']) ? (int)$_GET['pos'] : 0;
/**
* Hack added by tarique to prevent incorrect picture being seen on last view or last uploaded
*/
$pid = isset($_GET['pid']) ? (int)$_GET['pid'] : 0;
$cat = isset($_GET['cat']) ? (int)$_GET['cat'] : 0;
$album = isset($_GET['album']) ? $_GET['album'] : '';
// Build the album set if required
/*
//disabled by donnoman
if (!is_numeric($album) && $cat) { // Meta albums, we need to restrict the albums to the current category
if ($cat < 0) {
$ALBUM_SET .= 'AND aid IN (' . (- $cat) . ') ';
} else {
$ALBUM_SET_ARRAY = array();
if ($cat == USER_GAL_CAT)
$where = 'category > ' . FIRST_USER_CAT;
else
$where = "category = '$cat'";
$result = cpg_db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE $where");
while ($row = mysql_fetch_array($result)) {
$ALBUM_SET_ARRAY[] = $row['aid'];
} // while
get_subcat_data($cat, $CONFIG['subcat_level']);
// Treat the album set
if (count($ALBUM_SET_ARRAY)) {
$set = '';
foreach ($ALBUM_SET_ARRAY as $album_id) $set .= ($set == '') ? $album_id : ',' . $album_id;
$ALBUM_SET .= "AND aid IN ($set) ";
}
}
}
//disabled by donnoman
*/
//get_meta_album_set in functions.inc.php will populate the $ALBUM_SET instead; matches $META_ALBUM_SET.
get_meta_album_set($cat,$ALBUM_SET);
$META_ALBUM_SET = $ALBUM_SET; //displayimage uses $ALBUM_SET but get_pic_data in functions now uses $META_ALBUM_SET
//attempt to fix topn images for keyworded albums
if ($cat < 0) {
$result = cpg_db_query("SELECT category, title, aid, keyword, description, alb_password_hint FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='" . (- $cat) . "'");
if (mysql_num_rows($result) > 0) {
$CURRENT_ALBUM_DATA = mysql_fetch_array($result);
$CURRENT_ALBUM_KEYWORD = $CURRENT_ALBUM_DATA['keyword'];
}
}
// Retrieve data for the current picture
if ($pos < 0 || $pid > 0) {
$pid = ($pos < 0) ? -$pos : $pid;
$result = cpg_db_query("SELECT aid from {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid' $ALBUM_SET LIMIT 1");
if (mysql_num_rows($result) == 0) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
$row = mysql_fetch_array($result);
$album = $row['aid'];
$pic_data = get_pic_data($album, $pic_count, $album_name, -1, -1, false);
for($pos = 0; $pic_data[$pos]['pid'] != $pid && $pos < $pic_count; $pos++);
$pic_data = get_pic_data($album, $pic_count, $album_name, $pos, 1, false);
$CURRENT_PIC_DATA = $pic_data[0];
} elseif (isset($_GET['pos'])) {
$pic_data = get_pic_data($album, $pic_count, $album_name, $pos, 1, false);
if ($pic_count == 0) {
cpg_die(INFORMATION, $lang_errors['no_img_to_display'], __FILE__, __LINE__);
} elseif (count($pic_data) == 0 && $pos >= $pic_count) {
$pos = $pic_count - 1;
$human_pos = $pos + 1;
$pic_data = get_pic_data($album, $pic_count, $album_name, $pos, 1, false);
}
$CURRENT_PIC_DATA = $pic_data[0];
}
// Retrieve data for the current album
if (isset($CURRENT_PIC_DATA)) {
$result = cpg_db_query("SELECT title, comments, votes, category, aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='{$CURRENT_PIC_DATA['aid']}' LIMIT 1");
if (!mysql_num_rows($result)) cpg_die(CRITICAL_ERROR, sprintf($lang_errors['pic_in_invalid_album'], $CURRENT_PIC_DATA['aid']), __FILE__, __LINE__);
$CURRENT_ALBUM_DATA = mysql_fetch_array($result);
if (is_numeric($album)) {
$cat = - $album;
$actual_cat = $CURRENT_ALBUM_DATA['category'];
breadcrumb($actual_cat, $breadcrumb, $breadcrumb_text);
$cat = - $album;
} else {
$actual_cat = $CURRENT_ALBUM_DATA['category'];
breadcrumb($actual_cat, $breadcrumb, $breadcrumb_text);
}
}
if (isset($_GET['fullsize'])) {
theme_display_fullsize_pic();
ob_end_flush();
} elseif (isset($_GET['slideshow'])) {
theme_slideshow();
ob_end_flush();
} else {
if (!isset($_GET['pos'])) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
$picture_title = $CURRENT_PIC_DATA['title'] ? $CURRENT_PIC_DATA['title'] : strtr(preg_replace("/(.+)\..*?\Z/", "\\1", htmlspecialchars($CURRENT_PIC_DATA['filename'])), "_", " ");
$nav_menu = theme_html_img_nav_menu();
$picture = theme_html_picture();
$votes = theme_html_rating_box();
$pic_info = html_picinfo();
$comments = theme_html_comments($CURRENT_PIC_DATA['pid']);
if ($CURRENT_PIC_DATA['keywords']) { $meta_keywords = "<meta name=\"keywords\" content=\"".$CURRENT_PIC_DATA['keywords']."\"/>"; }
//$meta_nav .= "<link rel=\"alternate\" type=\"text/xml\" title=\"RSS feed\" href=\"rss.php\" />
// ";
$meta_keywords .= $meta_nav;
pageheader($album_name . '/' . $picture_title, $meta_keywords, false);
// Display Breadcrumbs
if ($breadcrumb && !(strpos($CONFIG['main_page_layout'],"breadcrumb")===false)) {
theme_display_breadcrumb($breadcrumb, $cat_data);
}
// Display Filmstrip if the album is not search
if ($album != 'search') {
$film_strip = display_film_strip($album, (isset($cat) ? $cat : 0), $pos, true);
}
CPGPluginAPI::filter('post_breadcrumb',null);
theme_display_image($nav_menu, $picture, $votes, $pic_info, $comments, $film_strip);
pagefooter();
ob_end_flush();
}
?>
2) Add this file displayimage.php to /gallery/
3) Open displayecard.php and select all!
4) Now copy and paste the underneath code into your displayecard.php
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2006 Coppermine Dev Team
v1.1 originally written by Gregory DEMAR
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.4.9
$Source$
$Revision: 3227 $
$Author: tranzndance $
$Date: 2006-08-15 07:54:45 +0200 (Di, 15 Aug 2006) $
**********************************************/
define('IN_COPPERMINE', true);
define('DISPLAYECARD_PHP', true);
require('include/init.inc.php');
require('include/smilies.inc.php');
if (!isset($_GET['data'])) cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'], __FILE__, __LINE__);
$data = array();
$data = @unserialize(@base64_decode($_GET['data']));
// attempt to obtain full link from db if ecard logging enabled and min 12 chars of data is provided and only 1 match
if ((!is_array($data)) && $CONFIG['log_ecards'] && (strlen($_GET['data']) > 12)) {
$result = cpg_db_query("SELECT link FROM {$CONFIG['TABLE_ECARDS']} WHERE link LIKE '{$_GET['data']}%'");
if (mysql_num_rows($result) === 1) {
$row = mysql_fetch_assoc($result);
$data = @unserialize(@base64_decode($row['link']));
}
}
if (is_array($data)) {
// Remove HTML tags as we can't trust what we receive
foreach($data as $key => $value) $data[$key] = html_entity_decode(strtr($value, $HTML_SUBST));
// Load template parameters
$params = array('{LANG_DIR}' => $lang_text_dir,
'{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $data['sn']),
'{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
'{VIEW_ECARD_TGT}' => '',
'{VIEW_ECARD_LNK}' => '',
'{PIC_URL}' => $data['p'],
'{URL_PREFIX}' => '',
'{GREETINGS}' => $data['g'],
'{MESSAGE}' => bb_decode(process_smilies($data['m'])),
'{SENDER_EMAIL}' => $data['se'],
'{SENDER_NAME}' => $data['sn'],
'{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'],
'{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'],
'{PID}' => $data['pid'],
'{PIC_TITLE}' => $data['pt'],
'{PIC_CAPTION}' => $data['pc'],
);
// Parse template
//dummy way to check if the file is flash anim!
if (strpos($data['p'], ".swf") > 1) {
$flash = '<object id="SWFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/
cabs/flash/swflash.cab#version=6,0,0,0"
type="application/x-shockwave-flash">
<param name="autostart" value="true">
<param name="src" value="{PIC_URL}">
<embed src="{PIC_URL}" autostart="true" type="application/x-shockwave-flash">
</object>
';
$template_ecard = str_replace('<img src="{PIC_URL}" border="1" alt="" />', $flash,
$template_ecard);
}
echo template_eval($template_ecard, $params);
} else {
cpg_die(CRITICAL_ERROR, $lang_displayecard_php['invalid_data'], __FILE__, __LINE__);
}
?>
4) Open ecard.php and select all!
5) Now copy and paste the underneath code into your ecard.php
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2006 Coppermine Dev Team
v1.1 originally written by Gregory DEMAR
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.4.9
$Source$
$Revision: 3125 $
$Author: gaugau $
$Date: 2006-06-16 08:48:03 +0200 (Fr, 16 Jun 2006) $
**********************************************/
define('IN_COPPERMINE', true);
define('ECARDS_PHP', true);
require('include/init.inc.php');
require('include/smilies.inc.php');
require('include/mailer.inc.php');
if (!USER_CAN_SEND_ECARDS) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
//print_r(get_defined_constants());
function get_post_var($name, $default = '')
{
return isset($_POST[$name]) ? $_POST[$name] : $default;
}
$pid = (int)$_GET['pid'];
$album = $_GET['album'];
$pos = (int)$_GET['pos'];
$sender_name = get_post_var('sender_name', USER_NAME ? USER_NAME : (isset($USER['name']) ? $USER['name'] : ''));
if (defined('UDB_INTEGRATION')AND USER_ID) $USER_DATA = array_merge($USER_DATA,$cpg_udb->get_user_infos(USER_ID));
if ($USER_DATA['user_email']){
$sender_email = $USER_DATA['user_email'];
$sender_box = $sender_email;
} else {
$sender_email = get_post_var('sender_email',$USER['email'] ? $USER['email'] : '');
$sender_box = "<input type=\"text\" class=\"textinput\" value=\"$sender_email\" name=\"sender_email\" style=\"width: 100%;\" />";
}
$recipient_name = get_post_var('recipient_name');
$recipient_email = get_post_var('recipient_email');
$greetings = get_post_var('greetings');
$message = get_post_var('message');
$sender_email_warning = '';
$recipient_email_warning = '';
// Get picture thumbnail url
$result = cpg_db_query("SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid' $ALBUM_SET");
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
$row = mysql_fetch_array($result);
$thumb_pic_url = get_pic_url($row, 'thumb');
$pic_title = $row['title'];
$pic_caption = bb_decode($row['caption']);
//dummy way to check if the file is flash anim!
if (!is_image($row['filename'])) {
if (strpos($row['filename'], ".swf") < 1 ) {
cpg_die(ERROR, $lang_ecard_php['error_not_image'], __FILE__, __LINE__);
}
}
// Check supplied email address
$valid_email_pattern = "^[_\.0-9a-z\-]+@([0-9a-z][0-9a-z-]*\.)+[a-z]{2,6}$";
$valid_sender_email = eregi($valid_email_pattern, $sender_email);
$valid_recipient_email = eregi($valid_email_pattern, $recipient_email);
$invalid_email = '<font size="1">' . $lang_ecard_php['invalid_email'] . ' (' . $recipient_email . ')</font>';
if (!$valid_sender_email && count($_POST) > 0) $sender_email_warning = $invalid_email;
if (!$valid_recipient_email && count($_POST) > 0) $recipient_email_warning = $invalid_email;
pageheader($lang_ecard_php['title']);
if (isset($_POST['submit'])) {
// Create and send the e-card
if (count($_POST) > 0 && $valid_sender_email && $valid_recipient_email) {
$gallery_url_prefix = $CONFIG['ecards_more_pic_target']. (substr($CONFIG['ecards_more_pic_target'], -1) == '/' ? '' : '/');
if ($CONFIG['make_intermediate'] && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']) {
$n_picname = get_pic_url($row, 'normal');
} else {
$n_picname = get_pic_url($row, 'fullsize');
}
if (!stristr($n_picname, 'http:')) $n_picname = $gallery_url_prefix . $n_picname;
$msg_content = process_smilies($message, $gallery_url_prefix);
$data = array('rn' => $_POST['recipient_name'],
'sn' => $_POST['sender_name'],
'se' => $sender_email,
'p' => $n_picname,
'g' => $greetings,
'm' => $message,
'pid' => $pid,
'pt' => $pic_title,
'pc' => $pic_caption,
);
$encoded_data = urlencode(base64_encode(serialize($data)));
$params = array('{LANG_DIR}' => $lang_text_dir,
'{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $sender_name),
'{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
'{VIEW_ECARD_TGT}' => "{$gallery_url_prefix}displayemail.php?data=$encoded_data",
'{VIEW_ECARD_LNK}' => $lang_ecard_php['view_ecard'],
'{VIEW_ECARD_LNK_PLAINTEXT}' => $lang_ecard_php['view_ecard_plaintext'],
'{PIC_URL}' => $n_picname,
'{URL_PREFIX}' => $gallery_url_prefix,
'{GREETINGS}' => $greetings,
'{MESSAGE}' => bb_decode($msg_content),
'{PLAINTEXT_MESSAGE}' => $message,
'{SENDER_EMAIL}' => $sender_email,
'{SENDER_NAME}' => $sender_name,
'{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'],
'{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'],
'{PID}' => $pid,
'{PIC_TITLE}' => $pic_title,
'{PIC_CAPTION}' => $pic_caption,
);
$message = template_eval($template_ecard, $params);
$plaintext_message = template_eval($template_ecard_plaintext, $params);
$tempTime = time();
$message .= sprintf($lang_ecard_php['ecards_footer'], $sender_name, localised_date(-1,$comment_date_fmt));
$subject = sprintf($lang_ecard_php['ecard_title'], $sender_name);
$result = cpg_mail($recipient_email, $subject, $message, 'text/html', $sender_name, $sender_email, $plaintext_message);
//write ecard log
if ($CONFIG['log_ecards'] == 1) {
$result_log = cpg_db_query("INSERT INTO {$CONFIG['TABLE_ECARDS']} (sender_name, sender_email, recipient_name, recipient_email, link, date, sender_ip) VALUES ('$sender_name', '$sender_email', '$recipient_name', '$recipient_email', '$encoded_data', '$tempTime', '{$_SERVER["REMOTE_ADDR"]}')");
}
if (!USER_ID) {
$USER['name'] = $sender_name;
$USER['email'] = $sender_email;
}
if ($result) {
//pageheader($lang_ecard_php['title']);
msg_box($lang_cpg_die[INFORMATION], $lang_ecard_php['send_success'], $lang_continue, "displayimage.php?album=$album&pos=$pos");
echo '<br />';
starttable('100%', $lang_ecard_php['preview']);
echo '<tr><td>';
//dummy way to check if the file is flash anim!
if (strpos($n_picname, ".swf") > 1) {
$flash = '<object id="SWFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/
cabs/flash/swflash.cab#version=6,0,0,0"
type="application/x-shockwave-flash">
<param name="autostart" value="true">
<param name="src" value="{PIC_URL}">
<embed src="{PIC_URL}" autostart="true" type="application/x-shockwave-flash">
</object>';
$template_ecard = str_replace('<img src="{PIC_URL}" border="1" alt="" />', $flash,
$template_ecard);
}
echo template_eval($template_ecard, $params);
echo '</td></tr>';
endtable();
pagefooter();
ob_end_flush();
exit;
} else {
cpg_die(ERROR, $lang_ecard_php['send_failed'], __FILE__, __LINE__);
}
}
}//submit
elseif (isset($_POST['preview'])) {
if ($CONFIG['make_intermediate'] && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']) {
$n_picname = get_pic_url($row, 'normal');
} else {
$n_picname = get_pic_url($row, 'fullsize');
}
if (!stristr($n_picname, 'http:')) $n_picname = $gallery_url_prefix . $n_picname;
$msg_content = process_smilies($message, $gallery_url_prefix);
$data = array(
'sn' => $_POST['sender_name'],
'se' => $sender_email,
'p' => $n_picname,
'g' => $greetings,
'm' => $message,
'pid' => $pid,
'pt' => $pic_title,
'pc' => $pic_caption,
);
$params = array('{LANG_DIR}' => $lang_text_dir,
'{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $sender_name),
'{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
'{VIEW_ECARD_TGT}' => "{$gallery_url_prefix}displayecard.php?data=$encoded_data",
'{VIEW_ECARD_LNK}' => $lang_ecard_php['preview_view_ecard'],
'{PIC_URL}' => $n_picname,
'{URL_PREFIX}' => $gallery_url_prefix,
'{GREETINGS}' => $greetings,
'{MESSAGE}' => bb_decode($msg_content),
'{SENDER_EMAIL}' => $sender_email,
'{SENDER_NAME}' => $sender_name,
'{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'],
'{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'],
'{PID}' => $pid,
'{PIC_TITLE}' => $pic_title,
'{PIC_CAPTION}' => $pic_caption,
);
starttable('100%', $lang_ecard_php['preview']);
echo '<tr><td>';
//dummy way to check if the file is flash anim!
if (strpos($data['p'], ".swf") > 1) {
$flash = '<object id="SWFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/
cabs/flash/swflash.cab#version=6,0,0,0"
type="application/x-shockwave-flash">
<param name="autostart" value="true">
<param name="src" value="{PIC_URL}">
<embed src="{PIC_URL}" width="100%" height="100%" autostart="true" type="application/x-shockwave-flash">
</object>
';
$template_ecard2 = str_replace('<img src="{PIC_URL}" border="1" alt="" />', $flash,
$template_ecard2);
}
echo template_eval($template_ecard2, $params);
echo '</td></tr>';
endtable();
echo '<br />';
}//preview
//pageheader($lang_ecard_php['title']);
//ecard form
if ($CONFIG['show_bbcode_help']) {$captionLabel = ' '. cpg_display_help('f=index.html&base=64&h='.urlencode(base64_encode(serialize($lang_bbcode_help_title))).'&t='.urlencode(base64_encode(serialize($lang_bbcode_help))),470,245);}
starttable("100%", $lang_ecard_php['title'], 3);
echo <<<EOT
<tr>
<td class="tableh2" colspan="2"><b>{$lang_ecard_php['from']}</b></td>
<td rowspan="6" align="center" valign="top" class="tableb">
<a href="displayimage.php?pos=-{$pid}">
<img src="$thumb_pic_url" alt="" vspace="8" border="0" class="image" /></a><br />
</td>
</tr>
<tr>
<td class="tableb" valign="top" width="40%">
<form method="post" name="post" action="{$_SERVER['PHP_SELF']}?album=$album&pid=$pid&pos=$pos">
{$lang_ecard_php['your_name']}<br />
</td>
<td valign="top" class="tableb" width="60%">
<input type="text" class="textinput" name="sender_name" value="$sender_name" style="width: 100%;" /><br />
</td>
</tr>
<tr>
<td class="tableb" valign="top" width="40%">
{$lang_ecard_php['your_email']}<br />
</td>
<td valign="top" class="tableb" width="60%">
{$sender_box}
{$sender_email_warning}
</td>
</tr>
<tr>
<td class="tableh2" colspan="2"><b>{$lang_ecard_php['to']}</b></td>
</tr>
<tr>
<td class="tableb" valign="top" width="40%">
{$lang_ecard_php['rcpt_name']}<br />
</td>
<td valign="top" class="tableb" width="60%">
<input type="text" class="textinput" name="recipient_name" value="$recipient_name" style="width: 100%;" /><br />
</td>
</tr>
<tr>
<td class="tableb" valign="top" width="40%">
{$lang_ecard_php['rcpt_email']}<br />
</td>
<td valign="top" class="tableb" width="60%">
<input type="text" class="textinput" name="recipient_email" value="$recipient_email" style="width: 100%;" /><br />
$recipient_email_warning
</td>
</tr>
<tr>
<td class="tableh2" colspan="3"><b>{$lang_ecard_php['greetings']}</b></td>
</tr>
<tr>
<td class="tableb" colspan="3">
<input type="text" class="textinput" name="greetings" value="$greetings" style="width: 100%;" /><br />
</td>
</tr>
<tr>
<td class="tableh2" colspan="3"><b>{$lang_ecard_php['message']}$captionLabel</b></td>
</tr>
<tr>
<td class="tableb" colspan="3" valign="top"><br />
<textarea name="message" class="textinput" rows="8" cols="40" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" style="width: 100%;">$message</textarea><br /><br />
</td>
</tr>
<tr>
<td class="tableb" colspan="3" valign="top">
EOT;
echo generate_smilies();
echo <<<EOT
</td>
</tr>
<tr>
<td colspan="3" align="center" class="tablef">
<input type="submit" class="button" name="preview" title="{$lang_ecard_php['preview_button']}" value="{$lang_ecard_php['preview_button']}" />
<input type="submit" class="button" name="submit" title="{$lang_ecard_php['submit_button']}" value="{$lang_ecard_php['submit_button']}" />
</form>
</td>
</tr>
EOT;
endtable();
pagefooter();
ob_end_flush();
?>
6) Open gallery/themes/Your template/theme.php
7) Find:
// HTML template for e-cards
$template_ecard = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="{LANG_DIR}">
<head>
<meta http-equiv="content-type" content="text/html; charset={CHARSET}" />
<title>{TITLE}</title>
</head>
<body bgcolor="#FFFFFF" text="#0F5475" link="#0F5475" vlink="#0F5475" alink="#0F5475">
<br />
<p align="center"><a href="{VIEW_ECARD_TGT}"><b>{VIEW_ECARD_LNK}</b></a></p>
<table border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td bgcolor="#000000">
<table border="0" cellspacing="0" cellpadding="10" bgcolor="#ffffff">
<tr>
<td valign="top">
<a href="{VIEW_MORE_TGT}displayimage.php?pos=-{PID}">
<img src="{PIC_URL}" border="1" alt="" /></a>
<br />
<div align="center">
<h2>{PIC_TITLE}</h2>
</div>
</td>
<td valign="top" width="300">
<div align="right"><img src="{URL_PREFIX}images/stamp.gif" border="0" alt="" /></div>
<br />
<b><font face="arial" color="#000000" size="4">{GREETINGS}</font></b>
<br />
<br />
<font face="arial" color="#000000" size="2">{MESSAGE}</font>
<br />
<br />
<font face="arial" color="#000000" size="2">{SENDER_NAME}</font>
(<a href="mailto:{SENDER_EMAIL}"><font face="arial" color="#000000" size="2">{SENDER_EMAIL}</font></a>)
</td>
</tr>
<tr>
<td colspan="2">
{PIC_CAPTION}
</td>
</tr>
</table>
</td>
</tr>
</table>
<p align="center"><a href="{VIEW_MORE_TGT}"><b>{VIEW_MORE_LNK}</b></a></p>
</body>
</html>
EOT;
// plain-text template for e-cards (as fallback for clients that can't display html-formatted mails)
$template_ecard_plaintext = <<<EOT
{TITLE}
=========================================
{VIEW_ECARD_LNK_PLAINTEXT}:
{VIEW_ECARD_TGT}
{GREETINGS}
{PLAINTEXT_MESSAGE}
{SENDER_NAME} ({SENDER_EMAIL})
-----------------------------------------
{VIEW_MORE_LNK}:
{VIEW_MORE_TGT}
EOT;
8 ) Replace with
// HTML template for e-cards
$template_ecard = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="{LANG_DIR}">
<head>
<meta http-equiv="content-type" content="text/html; charset={CHARSET}" />
<title>{TITLE}</title>
</head>
<body bgcolor="#ede3ec" text="#0F5475" link="#0F5475" vlink="#0F5475" alink="#0F5475">
<table border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td valign="top">
<font face="arial" color="#000000" size="2">You have received an e-card from {SENDER_NAME}!</font>
(<a href="mailto:{SENDER_EMAIL}"><font face="arial" color="#000000" size="2">{SENDER_EMAIL}</font></a>)
<br /><br/>
<p align="center"><a href="{VIEW_ECARD_TGT}"><b>{VIEW_ECARD_LNK}</b></a></p>
</td>
</tr>
<tr>
<td colspan="2"><br/><br/>
{PIC_CAPTION}
</td>
</tr>
</table>
</body>
</html>
EOT;
// plain-text template for e-cards (as fallback for clients that can't display html-formatted mails)
$template_ecard_plaintext = <<<EOT
{TITLE}
=========================================
{VIEW_ECARD_LNK_PLAINTEXT}:
{VIEW_ECARD_TGT}
{GREETINGS}
{PLAINTEXT_MESSAGE}
{SENDER_NAME} ({SENDER_EMAIL})
-----------------------------------------
{VIEW_MORE_LNK}:
{VIEW_MORE_TGT}
EOT;
// HTML template for e-cards2
$template_ecard2 = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="{LANG_DIR}">
<head>
<meta http-equiv="content-type" content="text/html; charset={CHARSET}" />
<title>{TITLE}</title>
</head>
<body bgcolor="#ede3ec" text="#603a5d" link="#603a5d" vlink="#603a5d" alink="#603a5d">
<br />
<p align="center"><a href="{VIEW_ECARD_TGT}"><b>{VIEW_ECARD_LNK}</b></a></p>
<table border="0" cellspacing="0" cellpadding="1" align="center">
<tr>
<td bgcolor="#000000">
<table border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff" height="100%" width="780">
<tr>
<td valign="middle" width="50%" height="240">
<a href="{VIEW_MORE_TGT}displayimage.php?pos=-{PID}">
<img src="{PIC_URL}" border="1" alt="" /></a>
<br />
</td>
<td valign="top" width="500">
<div align="right"><img src="{URL_PREFIX}images/stamp.gif" border="0" alt="" /></div>
<font face="arial" color="#000000" size="2"> {MESSAGE}</font>
<br />
<br />
<font face="arial" color="#000000" size="2"> {SENDER_NAME}</font>
(<a href="mailto:{SENDER_EMAIL}"><font face="arial" color="#000000" size="2"> {SENDER_EMAIL}</font></a>)
</td>
</tr>
<tr>
<td colspan="2">
{PIC_CAPTION}
</td>
</tr>
</table>
</td>
</tr>
</table>
<p align="center"><a href="http://pinklady.ath.cx/board/gallery.php"><b>{VIEW_MORE_LNK}</b></a></p>
</body>
</html>
EOT;
// plain-text template for e-cards (as fallback for clients that can't display html-formatted mails)
$template_ecard2_plaintext = <<<EOT
{TITLE}
=========================================
{VIEW_ECARD_LNK_PLAINTEXT}:
{VIEW_ECARD_TGT}
{GREETINGS}
{PLAINTEXT_MESSAGE}
{SENDER_NAME} ({SENDER_EMAIL})
-----------------------------------------
{VIEW_MORE_LNK}:
{VIEW_MORE_TGT}
EOT;
9) Open /gallery/lang/english.php
10) Find:
// ------------------------------------------------------------------------- //
// File ecard.php
// ------------------------------------------------------------------------- //
if (defined('ECARDS_PHP') || defined('DISPLAYECARD_PHP')) $lang_ecard_php =array(
'title' => 'Send an e-card',
'invalid_email' => '<font color="red"><b>Warning</b></font>: invalid email address:', //cpg1.4
'ecard_title' => 'An e-card from %s for you',
'error_not_image' => 'Only images can be sent as an ecard.',
'view_ecard' => 'Alternate link if the e-card does not display correctly', //cpg1.4
'view_ecard_plaintext' => 'To view the ecard, copy and paste this url into your browser\'s address bar:', //cpg1.4
'view_more_pics' => 'View more pictures !', //cpg1.4
'send_success' => 'Your ecard was sent',
'send_failed' => 'Sorry but the server can\'t send your e-card...',
'from' => 'From',
'your_name' => 'Your name',
'your_email' => 'Your email address',
'to' => 'To',
'rcpt_name' => 'Recipient name',
'rcpt_email' => 'Recipient email address',
'greetings' => 'Heading', //cpg1.4
'message' => 'Message', //cpg1.4
'ecards_footer' => 'Sent by %s from IP %s at %s (Gallery time)', //cpg1.4
'preview' => 'Preview of the ecard', //cpg1.4
'preview_button' => 'Preview', //cpg1.4
'submit_button' => 'Send ecard', //cpg1.4
'preview_view_ecard' => 'This will be the alternate link to the ecard once it gets generated. It won\'t work for previews.', //cpg1.4
);
11) Replace with:
// ------------------------------------------------------------------------- //
// File ecard.php
// ------------------------------------------------------------------------- //
if (defined('ECARDS_PHP') || defined('DISPLAYECARD_PHP')) $lang_ecard_php =array(
'title' => 'Send an e-card',
'invalid_email' => '<font color="red"><b>Warning</b></font>: invalid email address:', //cpg1.4
'ecard_title' => 'An e-card from %s for you',
'error_not_image' => 'Only images can be sent as an ecard.',
'view_ecard' => 'Click here to view your e-card!', //cpg1.4
'view_ecard_plaintext' => 'To view the ecard, copy and paste this url into your browser\'s address bar:', //cpg1.4
'view_more_pics' => 'View more e-cards and pictures !', //cpg1.4
'send_success' => 'Your ecard was sent',
'send_failed' => 'Sorry but the server can\'t send your e-card...',
'from' => 'From',
'your_name' => 'Your name',
'your_email' => 'Your email address',
'to' => 'To',
'rcpt_name' => 'Recipient name',
'rcpt_email' => 'Recipient email address',
'greetings' => 'Heading', //cpg1.4
'message' => 'Message', //cpg1.4
'ecards_footer' => 'Sent by %s from IP %s at %s (Gallery time)', //cpg1.4
'preview' => 'Preview of the ecard', //cpg1.4
'preview_button' => 'Preview', //cpg1.4
'submit_button' => 'Send ecard', //cpg1.4
'preview_view_ecard' => 'This will be the alternate link to the ecard once it gets generated. It won\'t work for previews.', //cpg1.4
);
I think i put all the code above to make it work! :)
If it doesn't work please let me know! Maybe i've forgot something, it was a few weeks ago i made this hack. ;)
A working sample can you find here! (http://pinklady.ath.cx/board/gallery.php)
To send and view an e-card you have to register on the forum.
Hope you enjoy this hack!
Greets,
Penelope
p.s: Always make backup of the files you are going to edit! ;)
( All the code didn't fit into one post, so that's why the several posts :) )
This doesnt work for me, from what i can tell it is the link in the email >>>
gallery/displayemail.php?data=
I dont have a displayemail.php
QuoteAlternate link if the e-card does not display correctly
I dont see ecard on my mail, only text in ecard, and show me text about not correctly link
what I must do????
(sorry for my gramma, and Im admin, and I use 1.4)
I wont see picture in mail...it is possible???