1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2006 Bharat Mediratta
*
* This file Copyright (C) 2003-2004 Joan McGalliard
*
* 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.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Id: ecard_form.php 13579 2006-05-02 09:59:13Z jenst $
*/
?>
<?php
/*
####################################################################################
# IBPS E-C@ard for Gallery Version 1 #
# Copyright 2002 IBPS Friedrichs info@ibps-friedrichs.de #
# Ported (the first time) for Gallery By freenik webmaster@cittadipolicoro.com#
####################################################################################
*/
require_once(dirname(__FILE__) . '/init.php');
list($photoIndex, $ecard, $submit_action) = getRequestVar(array('photoIndex', 'ecard', 'submit_action'));
printPopupStart(gTranslate('core', "Send this photo as eCard"));
$ecard['photoIndex'] = empty($ecard['photoIndex']) ? $photoIndex : $ecard['photoIndex'];
if(!$photo = $gallery->album->getPhoto($ecard['photoIndex'])) {
echo gallery_error($errortext);
echo "\n<p></p>";
echo galleryLink(makeGalleryUrl(), "Back to Gallery");
exit;
}
/* Get the dimensions of the sized Photo */
list($width, $height) = $photo->getDimensions(0, false);
$max_length = 300; // Maximum length of the e-Card text
$msgTextError1 = _("Error processing e-card. Please try later.");
$msgTextError2 = _("Some input fields are not correctly filled out. Please fill out.");
$ecard_PLAIN_data = _("You have an e-card as attachment. Click to see.");
$error_msg = '';
$ecard_send = false;
if (! empty($submit_action)) {
if (check_email($ecard["email_recepient"]) &&
check_email($ecard["email_sender"]) &&
! empty($ecard["email_recepient"]) &&
! empty($ecard["name_sender"])) {
if (strlen($ecard["message"]) > $max_length) {
$ecard["message"] = substr($ecard["message"],0,$max_length-1);
}
list($error,$ecard_data_to_parse) = get_ecard_template($ecard["template_name"]);
if ($error) {
$error_msg = $msgTextError1;
} else {
$ecard_HTML_data = parse_ecard_template($ecard,$ecard_data_to_parse, false);
$result = send_ecard($ecard,$ecard_HTML_data,$ecard_PLAIN_data);
if ($result) {
$ecard_send = true;
} else {
$error_msg = $msgTextError1;
}
}
} else {
$error_msg = $msgTextError2;
}
} else {
if (!isset($ecard["image_name"])) {
$ecard["image_name"] = $photo->getPhotoPath($gallery->album->fields['name'], false);
}
}
?>
<script type="text/javascript">
<!--
function popup_win(theURL,winName,winOptions) {
win = window.open(theURL,winName,winOptions);
win.focus();
}
function make_preview() {
document.ecard_form.action = "<?php echo $gallery->app->photoAlbumURL ; ?>/ecard_preview.php";
popup_win('','ecard_preview','resizable=yes,scrollbars=yes,width=800,height=600');
document.ecard_form.target = "ecard_preview";
document.ecard_form.submit();
}
function send_ecard() {
document.ecard_form.action = "<?php echo $HTTP_SERVER_VARS["PHP_SELF"] ?>";
document.ecard_form.target = "_self";
document.ecard_form["submit_action"].value = "send";
if (check()) { document.ecard_form.submit(); }
}
function check() {
var error = false;
var error_message = "<?php echo _("Error: to send an eCard you need to fill out all fields."); ?>";
error_message +="\n <?php echo _("Please fill this fields:"); ?>\n\n";
if (document.ecard_form["ecard[name_sender]"].value == "") {
error = true;
error_message += "<?php echo _("- Your Name"); ?>\n";
}
if ((document.ecard_form["ecard[email_sender]"].value == "") &&
(document.ecard_form["ecard[email_sender]"].value.indexOf("@") == -1)) {
error = true;
error_message += "<?php echo _("- Your Email"); ?>\n";
}
if (document.ecard_form["ecard[name_recepient]"].value == "") {
error = true;
error_message += "<?php echo _("- Recipient's Name"); ?>\n";
}
if ((document.ecard_form["ecard[email_recepient]"].value == "") &&
(document.ecard_form["ecard[email_recepient]"].value.indexOf("@") == -1)) {
error = true;
error_message += "<?php echo _("- Recipient's Email"); ?>\n";
}
if (document.ecard_form["ecard[message]"].value == "") {
error = true;
error_message += "<?php echo _("- Your Message"); ?>\n";
}
if (error) {
error_message += "\n\n<?php echo _('Please fill all fields next click >Send<.'); ?>";
alert(error_message);
return false; // Form not sent
} else {
return true; // Form sent
}
} // Ende function check()
function CountMax() {
max = <?php echo $max_length ?>;
wert = max - document.ecard_form["ecard[message]"].value.length;
if (wert < 0) {
alert("<?php echo sprintf(_("You have entered more than %d characters"), $max_length); ?>");
document.ecard_form["ecard[message]"].value = document.ecard_form["ecard[message]"].value.substring(0,max);
wert = 0;
document.ecard_form.counter.value = wert;
} else {
document.ecard_form.counter.value = max - document.ecard_form["ecard[message]"].value.length;
}
} // Ende function CountMax()
//-->
</script>
<?php
if (! $ecard_send) {
echo $gallery->album->getThumbnailTag($photoIndex);
if (!empty($error_msg)) {
echo '<p>'. gallery_error($error_msg) .'</p>';
}
echo makeFormIntro("ecard_form.php",
array("name" => "ecard_form"),
array("type" => "popup"));
?>
<input name="ecard[image_name]" type="hidden" value="<?php echo $ecard["image_name"] ?>">
<input name="ecard[template_name]" type="hidden" value="ecard_1.tpl">
<input name="ecard[photoIndex]" type="hidden" value="<?php echo $photoIndex; ?>">
<input name="submit_action" type="hidden" value="">
<br>
<table border="0" cellpadding="0" cellspacing="4" align="center">
<tr>
<td class="columnheader" colspan="2"><?php echo _("Your info"); ?></td>
<td width="10"> </td>
<td class="columnheader" colspan="2"><?php echo _("Recipient's info"); ?></td>
</tr>
<tr>
<td><?php echo _("Name") ?></td>
<?php
$defaultSenderName = '';
$defaultSenderEmail = '';
if (! empty($gallery->user) && $gallery->user->isLoggedIn()) {
$defaultSenderName = $gallery->user->displayName();
$defaultSenderEmail = $gallery->user->getEmail();
}
?>
<td><input tabindex="1" maxlength="40" name="ecard[name_sender]" size="18" type="Text" value="<?php echo $defaultSenderName; ?>"></td>
<td></td>
<td><?php echo _("Name") ?></td>
<td><input tabindex="3" maxlength="40" name="ecard[name_recepient]" size="18" type="Text" value=""></td>
</tr>
<tr>
<td><?php echo _("E-Mail"); ?></td>
<td><input tabindex="2" maxlength="40" name="ecard[email_sender]" size="18" type="Text" value="<?php echo $defaultSenderEmail; ?>"></td>
<td></td>
<td><?php echo _("E-Mail"); ?></td>
<td><input tabindex="4" maxlength="40" name="ecard[email_recepient]" size="18" type="Text" value=""></td>
</tr>
<tr>
<td colspan="5" align="center">
<select id="ecardstamp" name="ecard[stamp]">
<option selected value="08"><?php echo _("Choose a Stamp"); ?></option>
<?php
for($i = 1; $i <= 27; $i++) {
$nr = sprintf("%02d", $i-1);
echo "\n\t" . '<option value="'. $nr .'">';
echo sprintf(_("Stamp #%d"), $i);
echo "</option>";
}
?>
</select>
<?php $stamp_previewURL = build_popup_url("stamp_preview.php"); ?>
<img alt="helpIcon" height="15" hspace="5" onclick="popup_win('<?php echo $stamp_previewURL; ?>', 'Stamp_Preview','scrollbars=yes, width=150, height=300')" src="<?php echo getImagePath('ecard_images/icon_help.gif') ?>" width="15">
</td>
</tr>
<tr>
<td><?php echo _("Subject:"); ?></td>
<?php $defaultSubject = (!empty($defaultSenderName)) ? sprintf(_("%s sent you an E-C@rd"), $defaultSenderName) : ''; ?>
<td colspan="4"><input type="Text" size="65" maxlength="75" name="ecard[subject]" value="<?php echo $defaultSubject; ?>"></td>
</tr>
<tr>
<td colspan="5"><?php echo _("Your Message:"); ?></td>
</tr>
<tr>
<td align="center" colspan="5">
<textarea cols="55" rows="7" name="ecard[message]" onKeyPress="CountMax();" onfocus="CountMax();"><?php if (! empty($ecard["message"])) echo $ecard["message"]; ?></textarea>
</td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td align="center" colspan="5">
<input maxlength="<?php echo $max_length ?>" name="counter" size="3" type="Text">
</td>
</tr>
<tr>
<td colspan="5" align="center">
<table>
<tr>
<td><input type="button" onClick="javascript:make_preview();" value="<?php echo _("Preview"); ?>"></td>
<td><input type="reset" value="<?php echo _("Reset"); ?>"></td>
<td width="100%"> </td>
<td align="left"><input type="button" onClick="javascript:window.close()" value="<?php echo _("Cancel"); ?>"></td>
<td><input type="button" onClick="javascript:send_ecard();" value="<?php echo _("Send eCard"); ?>"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php } else {
echo sprintf(_("Your E-C@rd with the picture below has been sent to %s <%s>."), $ecard["name_recepient"], $ecard["email_recepient"]);
?>
<p align="center"><?php echo $gallery->album->getThumbnailTag($ecard['photoIndex']); ?></p>
<br>
<a href="javascript:window.close()"><?php echo _("Close this window") ?></a>
<?php }
?>
</div>
<?php
global $GALLERY_EMBEDDED_INSIDE;
$validation_args = array('photoIndex' => $photoIndex);
$validation_file = basename(__FILE__);
if (! isset($GALLERY_EMBEDDED_INSIDE)) {
print gallery_validation_link($validation_file, true, $validation_args);
}
?>
</body>
</html>
|