function ewiki_entry_downloads($row, $show_section = 0) { global $ewiki_binary_icons, $ewiki_upload_sections, $ewiki_config; $meta =& $row["meta"]; $id = $row["id"]; $p_title = basename($meta["Content-Location"]); $p_time = strftime("%c", $row["created"]); $p_hits = $uu = $row["hits"] ? $uu : "0"; $p_size = $meta["size"]; $p_size = isset($p_size) ? ", " . ($p_size >= 4096 ? round($p_size / 1024) . "K" : $p_size . " bytes") : ""; $p_ct1 = $meta["Content-Type"]; $p_ct2 = $meta["X-Content-Type"]; if ($p_ct1 == $p_ct2) { unset($p_ct2); } if ($p_ct1 && !$p_ct2) { $p_ct = "<tt>{$p_ct1}</tt>"; } elseif (!$p_ct1 && $p_ct2) { $p_ct = "<tt>{$p_ct2}</tt>"; } elseif ($p_ct1 && $p_ct2) { $p_ct = "<tt>{$p_ct1}</tt>, <tt>{$p_ct2}</tt>"; } else { $p_ct = "<tt>application/octet-stream</tt>"; } $p_section = $ewiki_upload_sections[$meta["section"]]; $p_section = $p_section ? $p_section : $meta["section"]; $p_comment = strlen($meta["comment"]) ? '<table border="1" cellpadding="2" cellspacing="0"><tr><td class="lighter">' . str_replace('</p>', '', str_replace('<p>', '', ewiki_format($meta["comment"]))) . '</td></tr></table>' : "<br />"; $p_icon = ""; foreach ($ewiki_binary_icons as $str => $i) { if (empty($str) || strstr($row["Content-Location"], $str) || strstr($p_ct, $str) || strstr($p_ct2, $str)) { $p_icon = $i; $p_icon_t = $str; } } $o .= ewiki_t("DWNL_ENTRY_FORMAT", array("id" => $id, "size" => $p_size, "icon" => $p_icon ? '<img src="' . $p_icon . '" alt="[' . $p_icon_t . ']" align="left" width="14" height="14" border="0" /> ' : '', "time" => $p_time, "hits" => $p_hits, "section" => $show_section ? ewiki_t('dwnl_section') . ": {$p_section}<br />" : '', "type" => $p_ct, "url" => ewiki_script_binary("", $row["id"]), "title" => $p_title, 'comment' => $p_comment, 'control_links' => ewiki_control_links_list($id, &$data, $ewiki_config["action_links"]["binary_get"], $data["version"]))); return $o; }
function ewiki_page_image_gallery($id, $data = 0, $action) { global $ewiki_config; $o = ewiki_make_title($id, $id, 2); $mwidth = 120; $mscale = 0.7; #-- fetch and asort images $sorted = array(); $pages = array(); $result = ewiki_db::GETALL(array("flags", "created", "meta", "refs")); while ($row = $result->get()) { if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_BINARY && strpos($row['meta']['Content-Type'], 'image/') === 0) { if (isset($ewiki_config['image-galleries'][$id])) { foreach ($ewiki_config['image-galleries'][$id] as $field => $value) { if ($row['meta'][$field] != $value) { continue 2; } } } if (!EWIKI_PROTECTED_MODE || EWIKI_PROTECTED_MODE_HIDING <= 0.5 || ewiki_auth($row["id"], $uu, "binary-get")) { $sorted[$row["id"]] = $row["created"]; $pages[$row["id"]] = $row; } } elseif (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_TEXT) { $page_refs[$row["id"]] = $row["refs"]; } } arsort($sorted); #-- start table $o .= '<table border="0" cellpadding="10" cellspacing="4">' . "\n"; $n = 0; $num_per_row = EWIKI_GALLERY_WIDTH; foreach ($sorted as $image => $uu) { $row = $pages[$image]; $meta = $row["meta"]; #-- height, width $x = $x0 = $meta["width"]; $y = $y0 = $meta["height"]; if (!($x && $y)) { $x = $mwidth; $y = (int) ($mwidth * $mscale); } $r = 1; if ($y > $mwidth * $mscale) { $r = $mwidth * $mscale / $y; } if ($r > $mwidth / $x) { $r = $mwidth / $x; } $x = (int) ($x * $r); $y = (int) ($y * $r); #-- get image references $ref = array(); foreach ($page_refs as $pageid => $pageref) { if (strstr($pageref, $image)) { if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($pageid, $str_null, "view")) { continue; } $ref[] = '<a href=?page=' . $pageid . '>' . $pageid . '</a>'; } if (count($ref) >= 5) { break; } } $ref = implode(", ", $ref); #-- table lines $n % $num_per_row == 0 && ($o .= "<tr>\n"); #-- print a/img tag $o .= '<td class="lighter" align="center">' . '<a href="' . ewiki_script_binary("", $image) . '">' . '<img src="' . ewiki_script_binary("", $image) . '" alt="' . $image . '" border="0"' . ($x && $y ? ' width="' . $x . '" height="' . $y . '"' : '') . ' />' . str_replace('/', '/ ', urldecode($meta["Content-Location"])) . '</a><br />' . ($x0 && $y0 ? "{$x0}x{$y0}<br />" : "") . $ref . '<div class="action-links">' . ewiki_control_links_list($image, $uuu, $ewiki_config["action_links"]["gallery"]) . "</div>\n" . "</td>\n"; #-- table lines $n++; $n % $num_per_row == 0 && ($o .= "</tr>\n"); } #-- empty table cells if ($n % $num_per_row) { while ($n % $num_per_row && $n++) { $o .= "<td class=\"lighter\"> </td>\n"; } $o .= "</tr>\n"; } $o .= "</table>\n"; return $o; }