function ewiki_input_truncate() { global $ewiki_input_limits, $ewiki_plugins; //get and trim current page id $id = substr(ewiki_id(), 0, $ewiki_input_limits['_AllPages']['id']); if ($delim = strpos($id, EWIKI_ACTION_SEP_CHAR)) { $action = substr($id, 0, $delim); $id = substr($id, $delim + 1); } foreach ($_REQUEST as $key => $value) { //loop through the $_REQUEST variable $input_value = trim($value); //trim value $ewiki_input_key = $key; $ewiki_input_id = ewiki_check_input($id, $ewiki_input_key, $action); if (!strlen($ewiki_input_id)) { $ewiki_input_key = ewiki_reset_key($id, $key); $ewiki_input_id = ewiki_check_input($id, $ewiki_input_key, $action); } if (!strlen($ewiki_input_id)) { ewiki_log('Unhandled submit: Page: "' . $id . '" Key: "' . $key . '" Value: "' . $value . '" \\n', 1); ewiki_set_globals($key); } if (is_array($input_value)) { //loop through the input array foreach ($input_value as $array_input_key => $array_input_value) { $input_value = trim($array_input_value); //redefine input_value with the array value //check to see if its longer than allowed if (strlen($input_value) > $ewiki_input_limits[$ewiki_input_id][$ewiki_input_key]) { //its too long truncate it... ewiki_set_globals($key, substr($input_value, 0, $ewiki_input_limits[$ewiki_input_id][$ewiki_input_key]), $array_input_key); } } } elseif (strlen($input_value) > $ewiki_input_limits[$ewiki_input_id][$ewiki_input_key] && isset($ewiki_input_limits[$ewiki_input_id][$ewiki_input_key])) { ewiki_log("Trimming: Key: {$ewiki_input_key} Id: {$ewiki_input_id} to length: " . $ewiki_input_limits[$ewiki_input_id][$ewiki_input_key]); ewiki_set_globals($key, substr($input_value, 0, $ewiki_input_limits[$ewiki_input_id][$ewiki_input_key])); } } }
function ewiki_page($id = false) { global $ewiki_links, $ewiki_plugins, $ewiki_ring, $ewiki_t, $ewiki_errmsg; #-- output var $o = ""; #-- selected page $action = optional_param('action', EWIKI_DEFAULT_ACTION); $content = optional_param('content', false); $version = optional_param('version', false); if (!strlen($id)) { $id = ewiki_id(); } $id = format_string($id, true); #-- page action if ($delim = strpos($id, EWIKI_ACTION_SEP_CHAR)) { $action = substr($id, 0, $delim); $id = substr($id, $delim + 1); } elseif (!EWIKI_USE_ACTION_PARAM) { $action = EWIKI_DEFAULT_ACTION; } $GLOBALS["ewiki_id"] = $id; $GLOBALS["ewiki_title"] = ewiki_split_title($id); $GLOBALS["ewiki_action"] = $action; #-- fetch from db $dquery = array("id" => $id); if (!$content && ($dquery["version"] = $version)) { $dquery["forced_version"] = $dquery["version"]; } $data = @array_merge($dquery, ewiki_database("GET", $dquery)); #-- stop here if page is not marked as _TEXT, # perform authentication then, and let only administrators proceed if (!empty($data["flags"]) && ($data["flags"] & EWIKI_DB_F_TYPE) != EWIKI_DB_F_TEXT) { if ($data["flags"] & EWIKI_DB_F_BINARY && ($pf = $ewiki_plugins["handler_binary"][0])) { return $pf($id, $data, $action); //_BINARY entries handled separately } elseif (!EWIKI_PROTECTED_MODE || !ewiki_auth($id, $data, $action, 0, 1) && $ewiki_ring != 0) { return ewiki_t("DISABLEDPAGE"); } } #-- pre-check if actions exist $pf_page = ewiki_array($ewiki_plugins["page"], $id); #-- edit <form> for non-existent pages if ($action == EWIKI_DEFAULT_ACTION && empty($data["content"]) && empty($pf_page)) { if (EWIKI_AUTO_EDIT) { $action = "edit"; } else { $data["content"] = ewiki_t("DOESNOTEXIST"); } } #-- more initialization if ($pf_a = @$ewiki_plugins["page_init"]) { ksort($pf_a); foreach ($pf_a as $pf) { $o .= $pf($id, $data, $action); } unset($ewiki_plugins["page_init"]); } $pf_page = ewiki_array($ewiki_plugins["page"], $id); #-- require auth if (EWIKI_PROTECTED_MODE) { if (!ewiki_auth($id, $data, $action, $ring = false, $force = EWIKI_AUTO_LOGIN)) { return $o .= $ewiki_errmsg; } } #-- handlers $handler_o = ""; if ($pf_a = @$ewiki_plugins["handler"]) { ksort($pf_a); foreach ($pf_a as $pf) { if ($handler_o = $pf($id, $data, $action)) { break; } } } #-- finished by handler if ($handler_o) { $o .= $handler_o; } elseif (($pf = @$ewiki_plugins["action_always"][$action]) && function_exists($pf)) { $o .= $pf($id, $data, $action); } elseif ($pf_page && function_exists($pf_page)) { $o .= $pf_page($id, $data, $action); } else { $pf = @$ewiki_plugins["action"][$action]; #-- fallback to "view" action if (empty($pf) || !function_exists($pf)) { $pf = "ewiki_page_view"; $action = "view"; // we could also allow different (this is a // catch-all) view variants, but this would lead to some problems } $o .= $pf($id, $data, $action); } #-- error instead of page? if (empty($o) && $ewiki_errmsg) { $o = $ewiki_errmsg; } #-- html post processing if ($pf_a = $ewiki_plugins["page_final"]) { ksort($pf_a); foreach ($pf_a as $pf) { if ($action == 'edit' and $pf == 'ewiki_html_tag_balancer') { continue; // balancer breaks htmlarea buttons } $pf($o, $id, $data, $action); } } EWIKI_ESCAPE_AT && ($o = str_replace("@", "@", $o)); return $o; }
<style type="text/css"><!-- <?php /* Just include() this fragment in the <head> part of yoursite.php, it will include the appropriate stylesheet snippets for the current page. You may want to remove the surrounding <style> tags here, if you already have them in yoursite. */ #-- base dir $_css_dir = dirname(__FILE__) . "/css/"; #-- page id if (!$ewiki_id) { $ewiki_action = EWIKI_DEFAULT_ACTION; $ewiki_id = ewiki_id(); if (strpos($ewiki_id, "/")) { list($ewiki_action, $ewiki_id) = explode("/", $ewiki_id, 2); } } #-- PageName.css if (file_exists($_css = $_css_dir . $ewiki_id . ".css") || file_exists($_css = $_css_dir . strtolower($ewiki_id) . ".css")) { include $_css; } #-- action.css if (file_exists($_css = $_css_dir . $ewiki_action . ".css")) { include $_css; } ?> //--></style>