6 |
kaklik |
1 |
<?php
|
|
|
2 |
/*************************
|
|
|
3 |
Coppermine Photo Gallery
|
|
|
4 |
************************
|
|
|
5 |
Copyright (c) 2003-2005 Coppermine Dev Team
|
|
|
6 |
v1.1 originaly written by Gregory DEMAR
|
|
|
7 |
|
|
|
8 |
This program is free software; you can redistribute it and/or modify
|
|
|
9 |
it under the terms of the GNU General Public License as published by
|
|
|
10 |
the Free Software Foundation; either version 2 of the License, or
|
|
|
11 |
(at your option) any later version.
|
|
|
12 |
********************************************
|
|
|
13 |
Coppermine version: 1.3.3
|
|
|
14 |
$Source: /cvsroot/coppermine/stable/ecard.php,v $
|
|
|
15 |
$Revision: 1.12 $
|
|
|
16 |
$Author: gaugau $
|
|
|
17 |
$Date: 2005/04/19 03:17:10 $
|
|
|
18 |
**********************************************/
|
|
|
19 |
|
|
|
20 |
define('IN_COPPERMINE', true);
|
|
|
21 |
define('ECARDS_PHP', true);
|
|
|
22 |
|
|
|
23 |
require('include/init.inc.php');
|
|
|
24 |
require('include/smilies.inc.php');
|
|
|
25 |
require('include/mailer.inc.php');
|
|
|
26 |
|
|
|
27 |
if (!USER_CAN_SEND_ECARDS) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
|
|
|
28 |
|
|
|
29 |
//print_r(get_defined_constants());
|
|
|
30 |
|
|
|
31 |
function get_post_var($name, $default = '')
|
|
|
32 |
{
|
|
|
33 |
global $HTTP_POST_VARS;
|
|
|
34 |
|
|
|
35 |
return isset($HTTP_POST_VARS[$name]) ? $HTTP_POST_VARS[$name] : $default;
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
$pid = (int)$HTTP_GET_VARS['pid'];
|
|
|
39 |
$album = $HTTP_GET_VARS['album'];
|
|
|
40 |
$pos = (int)$HTTP_GET_VARS['pos'];
|
|
|
41 |
|
|
|
42 |
$sender_name = get_post_var('sender_name', USER_NAME ? USER_NAME : (isset($USER['name']) ? $USER['name'] : ''));
|
|
|
43 |
if (defined('UDB_INTEGRATION')AND USER_ID) $USER_DATA = array_merge($USER_DATA,udb_get_user_infos(USER_ID));
|
|
|
44 |
if ($USER_DATA['user_email']){
|
|
|
45 |
$sender_email = $USER_DATA['user_email'];
|
|
|
46 |
$sender_box = $sender_email;
|
|
|
47 |
} else {
|
|
|
48 |
$sender_email = get_post_var('sender_email',$USER['email'] ? $USER['email'] : '');
|
|
|
49 |
$sender_box = "<input type=\"text\" class=\"textinput\" value=\"$sender_email\" name=\"sender_email\" style=\"WIDTH: 100%;\">";
|
|
|
50 |
}
|
|
|
51 |
$recipient_name = get_post_var('recipient_name');
|
|
|
52 |
$recipient_email = get_post_var('recipient_email');
|
|
|
53 |
$greetings = get_post_var('greetings');
|
|
|
54 |
$message = get_post_var('message');
|
|
|
55 |
$sender_email_warning = '';
|
|
|
56 |
$recipient_email_warning = '';
|
|
|
57 |
// Get picture thumbnail url
|
|
|
58 |
$result = db_query("SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid' $ALBUM_SET");
|
|
|
59 |
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
|
|
|
60 |
$row = mysql_fetch_array($result);
|
|
|
61 |
$thumb_pic_url = get_pic_url($row, 'thumb');
|
|
|
62 |
|
|
|
63 |
if (!is_image($row['filename'])) cpg_die(ERROR, $lang_ecard_php['error_not_image'], __FILE__, __LINE__);
|
|
|
64 |
|
|
|
65 |
// Check supplied email address
|
|
|
66 |
$valid_email_pattern = "^[_\.0-9a-z\-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$";
|
|
|
67 |
$valid_sender_email = eregi($valid_email_pattern, $sender_email);
|
|
|
68 |
$valid_recipient_email = eregi($valid_email_pattern, $recipient_email);
|
|
|
69 |
$invalid_email = '<font size="1">' . $lang_ecard_php['invalid_email'] . '</font>';
|
|
|
70 |
if (!$valid_sender_email && count($HTTP_POST_VARS) > 0) $sender_email_warning = $invalid_email;
|
|
|
71 |
if (!$valid_recipient_email && count($HTTP_POST_VARS) > 0) $recipient_email_warning = $invalid_email;
|
|
|
72 |
// Create and send the e-card
|
|
|
73 |
if (count($HTTP_POST_VARS) > 0 && $valid_sender_email && $valid_recipient_email) {
|
|
|
74 |
$gallery_url_prefix = $CONFIG['ecards_more_pic_target']. (substr($CONFIG['ecards_more_pic_target'], -1) == '/' ? '' : '/');
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
if($CONFIG['thumb_use']=='ht' && $row['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
|
|
|
78 |
$condition = true;
|
|
|
79 |
}elseif($CONFIG['thumb_use']=='wd' && $row['pwidth'] > $CONFIG['picture_width']){
|
|
|
80 |
$condition = true;
|
|
|
81 |
}elseif($CONFIG['thumb_use']=='any' && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']){
|
|
|
82 |
$condition = true;
|
|
|
83 |
}else{
|
|
|
84 |
$condition = false;
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
if ($CONFIG['make_intermediate'] && $condition ) {
|
|
|
88 |
$n_picname = get_pic_url($row, 'normal');
|
|
|
89 |
} else {
|
|
|
90 |
$n_picname = get_pic_url($row, 'fullsize');
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
if (!stristr($n_picname, 'http:')) $n_picname = $gallery_url_prefix . $n_picname;
|
|
|
94 |
|
|
|
95 |
$msg_content = nl2br(process_smilies($message, $gallery_url_prefix));
|
|
|
96 |
|
|
|
97 |
$data = array('rn' => $HTTP_POST_VARS['recipient_name'],
|
|
|
98 |
'sn' => $HTTP_POST_VARS['sender_name'],
|
|
|
99 |
'se' => $sender_email,
|
|
|
100 |
'p' => $n_picname,
|
|
|
101 |
'g' => $greetings,
|
|
|
102 |
'm' => $message,
|
|
|
103 |
);
|
|
|
104 |
|
|
|
105 |
$encoded_data = urlencode(base64_encode(serialize($data)));
|
|
|
106 |
|
|
|
107 |
$params = array('{LANG_DIR}' => $lang_text_dir,
|
|
|
108 |
'{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $sender_name),
|
|
|
109 |
'{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
|
|
|
110 |
'{VIEW_ECARD_TGT}' => "{$gallery_url_prefix}displayecard.php?data=$encoded_data",
|
|
|
111 |
'{VIEW_ECARD_LNK}' => $lang_ecard_php['view_ecard'],
|
|
|
112 |
'{PIC_URL}' => $n_picname,
|
|
|
113 |
'{URL_PREFIX}' => $gallery_url_prefix,
|
|
|
114 |
'{GREETINGS}' => $greetings,
|
|
|
115 |
'{MESSAGE}' => $msg_content,
|
|
|
116 |
'{SENDER_EMAIL}' => $sender_email,
|
|
|
117 |
'{SENDER_NAME}' => $sender_name,
|
|
|
118 |
'{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'],
|
|
|
119 |
'{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'],
|
|
|
120 |
);
|
|
|
121 |
|
|
|
122 |
$message = template_eval($template_ecard, $params);
|
|
|
123 |
$tempTime = time();
|
|
|
124 |
$message .= "Sent by $sender_name from IP {$_SERVER['REMOTE_ADDR']} at ".gmstrftime("%A, %B,%d,%Y %I:%M %p ", time())." [GMT]";
|
|
|
125 |
$subject = sprintf($lang_ecard_php['ecard_title'], $sender_name);
|
|
|
126 |
|
|
|
127 |
$result = cpg_mail($recipient_email, $subject, $message, 'text/html', $sender_name, $sender_email);
|
|
|
128 |
|
|
|
129 |
//write ecard log
|
|
|
130 |
if ($CONFIG['log_ecards'] == 1) {
|
|
|
131 |
$result_log = 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"]}')");
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
if (!USER_ID) {
|
|
|
135 |
$USER['name'] = $sender_name;
|
|
|
136 |
$USER['email'] = $sender_email;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
if ($result) {
|
|
|
140 |
pageheader($lang_ecard_php['title'], "<META http-equiv=\"refresh\" content=\"3;url=displayimage.php?album=$album&pos=$pos\">");
|
|
|
141 |
msg_box($lang_cpg_die[INFORMATION], $lang_ecard_php['send_success'], $lang_continue, "displayimage.php?album=$album&pos=$pos");
|
|
|
142 |
pagefooter();
|
|
|
143 |
ob_end_flush();
|
|
|
144 |
exit;
|
|
|
145 |
} else {
|
|
|
146 |
cpg_die(ERROR, $lang_ecard_php['send_failed'], __FILE__, __LINE__);
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
pageheader($lang_ecard_php['title']);
|
|
|
151 |
starttable("100%", $lang_ecard_php['title'], 3);
|
|
|
152 |
|
|
|
153 |
echo <<<EOT
|
|
|
154 |
<tr>
|
|
|
155 |
<td class="tableh2" colspan="2"><b>{$lang_ecard_php['from']}</b></td>
|
|
|
156 |
<td rowspan="6" align="center" valign="top" class="tableb">
|
|
|
157 |
<img src="$thumb_pic_url" alt="" vspace="8" border="0" class="image"><br />
|
|
|
158 |
</td>
|
|
|
159 |
</tr>
|
|
|
160 |
<tr>
|
|
|
161 |
<td class="tableb" valign="top" width="40%">
|
|
|
162 |
<form method="post" name="post" action="$PHP_SELF?album=$album&pid=$pid&pos=$pos">
|
|
|
163 |
{$lang_ecard_php['your_name']}<br />
|
|
|
164 |
</td>
|
|
|
165 |
<td valign="top" class="tableb" width="60%">
|
|
|
166 |
<input type="text" class="textinput" name="sender_name" value="$sender_name" style="WIDTH: 100%;"><br />
|
|
|
167 |
</td>
|
|
|
168 |
</tr>
|
|
|
169 |
<tr>
|
|
|
170 |
<td class="tableb" valign="top" width="40%">
|
|
|
171 |
{$lang_ecard_php['your_email']}<br />
|
|
|
172 |
</td>
|
|
|
173 |
<td valign="top" class="tableb" width="60%">
|
|
|
174 |
{$sender_box}
|
|
|
175 |
{$sender_email_warning}
|
|
|
176 |
</td>
|
|
|
177 |
</tr>
|
|
|
178 |
<tr>
|
|
|
179 |
<td class="tableh2" colspan="2"><b>{$lang_ecard_php['to']}</b></td>
|
|
|
180 |
</tr>
|
|
|
181 |
<tr>
|
|
|
182 |
<td class="tableb" valign="top" width="40%">
|
|
|
183 |
{$lang_ecard_php['rcpt_name']}<br />
|
|
|
184 |
</td>
|
|
|
185 |
<td valign="top" class="tableb" width="60%">
|
|
|
186 |
<input type="text" class="textinput" name="recipient_name" value="$recipient_name" style="WIDTH: 100%;"><br />
|
|
|
187 |
</td>
|
|
|
188 |
</tr>
|
|
|
189 |
<tr>
|
|
|
190 |
<td class="tableb" valign="top" width="40%">
|
|
|
191 |
{$lang_ecard_php['rcpt_email']}<br />
|
|
|
192 |
</td>
|
|
|
193 |
<td valign="top" class="tableb" width="60%">
|
|
|
194 |
<input type="text" class="textinput" name="recipient_email" value="$recipient_email" style="WIDTH: 100%;"><br />
|
|
|
195 |
$recipient_email_warning
|
|
|
196 |
</td>
|
|
|
197 |
</tr>
|
|
|
198 |
<tr>
|
|
|
199 |
<td class="tableh2" colspan="3"><b>{$lang_ecard_php['greetings']}</b></td>
|
|
|
200 |
</tr>
|
|
|
201 |
<tr>
|
|
|
202 |
<td class="tableb" colspan="3">
|
|
|
203 |
<input type="text" class="textinput" name="greetings" value="$greetings" style="WIDTH: 100%;"><br />
|
|
|
204 |
</td>
|
|
|
205 |
</tr>
|
|
|
206 |
<tr>
|
|
|
207 |
<td class="tableh2" colspan="3"><b>{$lang_ecard_php['message']}</b></td>
|
|
|
208 |
</tr>
|
|
|
209 |
<tr>
|
|
|
210 |
<td class="tableb" colspan="3" valign="top"><br />
|
|
|
211 |
<textarea name="message" class="textinput" ROWS="8" COLS="40" WRAP="virtual" onselect="storeCaret_post(this);" onclick="storeCaret_post(this);" onkeyup="storeCaret_post(this);" STYLE="WIDTH: 100%;">$message</textarea><br /><br />
|
|
|
212 |
</td>
|
|
|
213 |
</tr>
|
|
|
214 |
<tr>
|
|
|
215 |
<td class="tableb" colspan="3" valign="top">
|
|
|
216 |
|
|
|
217 |
EOT;
|
|
|
218 |
echo generate_smilies();
|
|
|
219 |
echo <<<EOT
|
|
|
220 |
</td>
|
|
|
221 |
</tr>
|
|
|
222 |
<tr>
|
|
|
223 |
<td colspan="3" align="center" class="tablef">
|
|
|
224 |
<input type="submit" class="button" value="{$lang_ecard_php['title']}">
|
|
|
225 |
</form>
|
|
|
226 |
</td>
|
|
|
227 |
</tr>
|
|
|
228 |
EOT;
|
|
|
229 |
|
|
|
230 |
endtable();
|
|
|
231 |
pagefooter();
|
|
|
232 |
ob_end_flush();
|
|
|
233 |
|
|
|
234 |
?>
|