Roxen.git / server / modules / scripting / piketag.pike

version» Context lines:

Roxen.git/server/modules/scripting/piketag.pike:1:   // This is a roxen module. Copyright © 1996 - 2000, Roxen IS.   //   // Adds support for inline pike in documents.   //   // Example:   // <pike>   // return "Hello world!\n";   // </pike>    - constant cvs_version = "$Id: piketag.pike,v 2.5 2000/03/16 18:34:42 nilsson Exp $"; + constant cvs_version = "$Id: piketag.pike,v 2.6 2000/07/03 06:43:20 nilsson Exp $";   constant thread_safe=1;    - inherit "roxenlib"; +    inherit "module"; - #include <module.h>; +       constant module_type = MODULE_PARSER;   constant module_name = "Pike tag";   constant module_doc =   #"This module adds a new tag, &lt;pike&gt;&lt;/pike&gt;. It makes it   possible to insert some pike code directly in the document. <br>   <img src=\"internal-roxen-err_2\" align=\"left\" alt=\"Warning\"> <br>NOTE: Enabling this   module is the same thing as letting your users run programs with the   same right as the server! Example:<p><pre> &lt;pike&gt; return   \"Hello world!\\n\"; &lt;/pike&gt;\n</pre> <p>Arguments: Any, all
Roxen.git/server/modules/scripting/piketag.pike:31:   hello world script is <tt>&lt;pike&gt;output(\"Hello %s\n\",   \"World\");&lt/pike&gt</tt><p> The request id is available as id.";      void create()   {    defvar (    "debugmode", "Log", "Error messages", TYPE_STRING_LIST | VAR_MORE,    "How to report errors (e.g. backtraces generated by the Pike code):\n"    "\n"    "<p><ul>\n" -  "<li><i>Off</i> - Silent.\n" -  "<li><i>Log</i> - System debug log.\n" -  "<li><i>HTML comment</i> - Include in the generated page as an HTML comment.\n" -  "<li><i>HTML text</i> - Include in the generated page as normal text.\n" +  "<li><i>Off</i> - Silent.</li>\n" +  "<li><i>Log</i> - System debug log.</li>\n" +  "<li><i>HTML comment</i> - Include in the generated page as an HTML comment.</li>\n" +  "<li><i>HTML text</i> - Include in the generated page as normal text.</li>\n"    "</ul>\n",    ({"Off", "Log", "HTML comment", "HTML text"}));       defvar("program_cache_limit", 256, "Program cache limit", TYPE_INT|VAR_MORE,    "Maximum size of the cache for compiled programs.");   }      string reporterr (string header, string dump)   { -  if (QUERY (debugmode) == "Off") return ""; +  if (query("debugmode") == "Off") return "";       report_error( header + dump + "\n" ); -  switch (QUERY (debugmode)) +  switch (query("debugmode"))    {    case "HTML comment": -  return "\n<!-- " + html_encode_string(header + dump) + "\n-->\n"; +  return "\n<!-- " + Roxen.html_encode_string(header + dump) + "\n-->\n";    case "HTML text": -  return "\n<br><font color=red><b><pre>" + html_encode_string (header) + -  "</b></pre></font><pre>\n"+html_encode_string (dump) + "</pre><br>\n"; +  return "\n<br><font color=\"red\"><b><pre>" + Roxen.html_encode_string (header) + +  "</b></pre></font><pre>\n"+Roxen.html_encode_string (dump) + "</pre><br />\n";    default:    return "";    }   }      // Helper functions, to be used in the pike script.   class Helpers   {    inherit "roxenlib";    string data = "";
Roxen.git/server/modules/scripting/piketag.pike:148:    if(err=catch    {    s = pre(s,request_id)+s+post(s);    p = program_cache[s];       if (!p)    {    // Not in the program cache.    p = compile_string(s, "Pike-tag("+request_id->not_query+":"+    request_id->misc->line+")"); -  if (sizeof(program_cache) > QUERY(program_cache_limit)) +  if (sizeof(program_cache) > query("program_cache_limit"))    {    array a = indices(program_cache);    int i;       // Zap somewhere between 25 & 50% of the cache. -  for(i = QUERY(program_cache_limit)/2; i > 0; i--) +  for(i = query("program_cache_limit")/2; i > 0; i--)    m_delete(program_cache, a[random(sizeof(a))]);    }    program_cache[s] = p;    }    })    {    master()->set_inhibit_compile_errors(0);    return reporterr(sprintf("Error compiling <pike> tag in %s:\n"    "%s\n\n", request_id->not_query, s),    e->get());