4 This plugin provides a below-every-page image uploading function
5 similar to the one of the edit page. The advantage is faster access
6 and that it is working without JavaScript.
10 $ewiki_plugins["view_append"][] = "ewiki_aview_image_append";
11 $ewiki_plugins["action"]["imageappend"] = "ewiki_action_image_append";
14 $ewiki_t["en"]["IMAGEAPPEND_FORM0"] = '<img src="imageappend.jpeg" width="80" height="60" alt="imageappend" align="left" /> <b>Append an Image</b><br />';
15 $ewiki_t["en"]["NO_IMAGEAPPEND"] = "The image uploading succeeded, but the page couldn't get updated. Please try the image upload function on EditThisPage.";
20 function ewiki_aview_image_append($id, $data, $action) {
22 $URL = ewiki_script("imageappend", $id);
23 $TXT = ewiki_t("IMAGEAPPEND_FORM0");
24 $BTN1 = ewiki_t("UPLOAD_PICTURE_BUTTON");
26 $accept = (defined("EWIKI_IMAGE_ACCEPT") ? ' accept="'.EWIKI_IMAGE_ACCEPT.'">' : "");
28 <div class="imageappend">
29 <form action="$URL" method="POST" enctype="multipart/form-data">
31 <input type="file" name="imagefile" $accept><br />
32 <input type="submit" value="$BTN1">
41 function ewiki_action_image_append($id, $data, $action) {
46 (EWIKI_DB_F_TEXT != ($data["flags"] & EWIKI_DB_F_TYPE)))
48 $o = ewiki_t("CANNOTCHANGEPAGE");
51 #-- temporary upload-file found
52 elseif ($fa = $_FILES["imagefile"]) {
54 #-- guess HTTP meta data
56 "X-Content-Type" => $fa["type"],
57 #"X-Content-Length" => $fa["size"],
59 if ($s = $fa["name"]) {
60 $meta["Content-Location"] = $s;
62 ($p = strrpos($s, "/")) and ($p++) or
63 ($p = strrpos($s, '\\')) and ($p++);
64 $meta["Content-Disposition"] = 'inline; filename="'.urlencode(substr($s, $p)).'"';
67 #-- proceed an image (reject binary, resize if too large)
68 $result = ewiki_binary_save_image(
69 $fa["tmp_name"], // uploaded file location
70 "", // no predefined $id
71 "RETURN", // do not die() on error
72 $meta, // =Content-Location
73 0, // =do not accept plain binary
77 #-- database rejected file
79 $o = ewiki_t("BIN_NOIMG");
82 #-- if picture stored in db
88 $data = ewiki_db::GET($id);
91 $data["content"] = rtrim($data["content"], "\n") . "\n\n" .
92 "[\"AppendedPicture\"$result]\n\n\n";
94 $result = ewiki_db::WRITE($data);
103 $o = ewiki_page("view/$id");
104 ewiki_log("image appended to '$id'");
107 $o .= ewiki_t("NO_IMAGEAPPEND");
116 $o .= ewiki_t("BIN_NOIMG");
117 #"You did not select an image, or something went really wrong during tansmission. Plase go back to the previous page.";