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
|
<?php
/*
* This file is part of Zoph.
*
* Zoph 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.
*
* Zoph 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 Zoph; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once("include.inc.php");
require_once("htmlMimeMail.php");
$title = translate("E-Mail Photo");
$photo_id = getvar("photo_id");
$html = getvar("html");
$to_name = getvar("to_name");
$to_email = getvar("to_email");
$from_name = getvar("from_name");
$from_email = getvar("from_email");
$subject = getvar("subject");
$message = getvar("message");
$includeurl = getvar("includeurl");
$annotate = getvar("annotate");
if (!ANNOTATE_PHOTOS) {
$annotate = 0;
}
// image will have been deleted if sent
if ($annotate) {
$skipcrumb = true;
}
$photo = new photo($photo_id);
$found = $photo->lookup($user);
if (!$found) {
$msg = sprintf(translate("Could not find photo id %s."), $photo_id);
}
else {
if ($_action == "mail") {
$mail = new Mail_mime();
$hdrs = array (
"X-Mailer" => "Html Mime Mail Class",
"X-Zoph-Version" => VERSION
);
$size = getvar("_size");
if ($annotate) {
$file = $photo->get_annotated_file_name($user);
$dir = ANNOTATE_TEMP_DIR . "/";
}
else if ($size == "full") {
$file = $photo->get("name");
$dir = IMAGE_DIR . $photo->get("path") . "/";
}
else {
$file = MID_PREFIX . "_" . $photo->get("name");
$dir = IMAGE_DIR . $photo->get("path") . "/" .
MID_PREFIX . "/";
}
if($includeurl) {
$link = "\n" . sprintf(translate("See this photo in %s"), ZOPH_TITLE) . ": " . ZOPH_URL . "/photo.php?photo_id=" . $photo_id;
}
if ($html) {
$html = "<center>\n";
$html .= "<img src=\"" . $file . "\"><br>\n";
$html .= str_replace("\n", "<br>\n", $message);
if($includeurl) {
$html .= "<a href=\"" . ZOPH_URL . "/photo.php?photo_id=" . $photo_id . "\">" . sprintf(translate("See this photo in %s"), ZOPH_TITLE) . "</a>";
}
$html .= "</center>\n";
$mail->addHTMLImage($dir . "/" . $file, get_image_type($file), $file);
$mail->setHTMLBody($html);
$mail->setTXTBody($message . $link);
} else {
$mail->setTXTBody($message . $link);
$mail->addAttachment($dir . "/" . $file, get_image_type($file));
}
$mail->setFrom("$from_name <$from_email>");
if (strlen(BCC_ADDRESS) > 0) {
$mail->setBCC(BCC_ADDRESS);
}
$body = $mail->get();
$hdrs = $mail->headers($hdrs);
foreach($hdrs as $header => $content) {
$headers .= $header . ": " . $content . "\n";
}
if (mail($to_email,$subject, $body,$headers)) {
$msg = translate("Your mail has been sent.");
if ($annotate) {
unlink(ANNOTATE_TEMP_DIR . "/" . $photo->get_annotated_file_name($user));
}
}
else {
$msg = translate("Could not send mail.");
}
}
}
$from_name = $user->person->get_name();
$from_email = $user->person->get_email();
require_once("header.inc.php");
?>
<h1>
<?php if (ANNOTATE_PHOTOS) {
?>
<span class="actionlink">
<a href="define_annotated_photo.php?photo_id=<?php echo $photo->get("photo_id") ?>"><?php echo translate("create annotated photo", 0) ?></a>
</span>
<?php
}
?>
<?php echo translate("email photo") ?>
</h1>
<form action="<?php echo $PHP_SELF ?>" method="post">
<div class="main">
<?php
if ($msg) {
?>
<?php echo $msg ?>
<?php
}
if ($found && $_action == "compose") {
$subject = sprintf(translate("A Photo from %s"), ZOPH_TITLE) . ": " . $photo->get("name");
$ea = $photo->get_email_array();
if ($ea) {
while (list($name, $value) = each($ea)) {
if ($name && $value) {
$body .= "$name: $value\r\n";
}
}
}
if ($annotate) {
$photo->annotate($request_vars, $user);
}
?>
<input type="hidden" name="_action" value="mail">
<input type="hidden" name="photo_id" value="<?php echo $photo_id ?>">
<input type="hidden" name="annotate" value="<?php echo $annotate ?>">
<label for="html"><?php echo translate("send as html") ?></label>
<?php echo create_pulldown("html", "1", array("1" => translate("Yes",0), "0" => translate("No",0))) ?><br>
<label for="toname"><?php echo translate("to (name)") ?></label>
<?php echo create_text_input("to_name", $to_name, 24, 32) ?><br>
<label for="toemail"><?php echo translate("to (email)") ?></label>
<?php echo create_text_input("to_email", $to_email, 24, 32) ?><br>
<label for="fromname"><?php echo translate("from (your name)") ?></label>
<?php echo create_text_input("from_name", $from_name, 24, 32) ?><br>
<label for="fromemail"><?php echo translate("from (your email)") ?></label>
<?php echo create_text_input("from_email", $from_email, 24, 64) ?><br>
<label for="subject"><?php echo translate("subject") ?></label>
<?php echo create_text_input("subject", $subject, 48, 64) ?><br>
<?php
if (!$annotate) {
?>
<label for="size"><?php echo translate("send fullsize") ?></label>
<?php echo create_pulldown("_size", "mid", array("full" => translate("Yes",0), "mid" => translate("No",0)) ) ?><br>
<label for="includeurl"><?php echo translate("include URL") ?></label>
<?php echo create_pulldown("includeurl", "1", array("1" => translate("Yes",0), "0" => translate("No",0)) ) ?><br>
<?php
}
?>
<label for="message"><?php echo translate("message:") ?></label><br>
<textarea name="message" class="email" cols="70" rows="5"><?php echo $body ?></textarea>
<?php
if ($annotate) {
?>
<img src="image_service.php?photo_id=<?php echo $photo_id ?>&annotated=1" alt="<?= $photo->get("title") ? $photo->get("title") : $photo->get("name") ?>">
<?php
}
else {
?>
<?php echo $photo->get_midsize_img() ?>
<?php
}
?>
<input type="submit" name="_button" value="<?php echo translate("email", 0); ?>">
<?php
}
?>
</div>
</form>
<?php
require_once("footer.inc.php");
?>
|