Roxen.git / server / config_interface / sites / site_content.pike

version» Context lines:

Roxen.git/server/config_interface/sites/site_content.pike:1: - // $Id: site_content.pike,v 1.164 2010/05/19 07:36:28 noring Exp $ + // $Id$      inherit "../inheritinfo.pike";   inherit "../logutil.pike";   inherit "../statusinfo.pike";   #include <module.h>   #include <module_constants.h>   #include <config_interface.h>   #include <config.h>   #include <roxen.h>   
Roxen.git/server/config_interface/sites/site_content.pike:219:    return buttons;    if( sizeof( mod->error_log ) )    buttons+="<submit-gbutton>"+LOCALE(247, "Clear Log")+"</submit-gbutton>";       // Nor is it a good idea to drop configuration interface modules.    // It tends to make things rather unstable.   #ifndef YES_I_KNOW_WHAT_I_AM_DOING    if( c != id->conf )   #endif    buttons += "<link-gbutton href='../../../../drop_module.pike?config="+ -  path[0]+"&drop="+mn+"'>"+ +  path[0]+"&amp;drop="+mn+"&amp;&usr.set-wiz-id;'>"+    LOCALE(252, "Drop Module")+"</link-gbutton></a>";       // Add action buttons produced by the module itself    if (mod->query_action_buttons) {    mapping(string:function|array(function|string)) mod_buttons =    mod->query_action_buttons(id);    array(string) titles = indices(mod_buttons);    if (sizeof(titles)) {    buttons +=    " <img src='/internal-roxen-pixel-888888' "
Roxen.git/server/config_interface/sites/site_content.pike:260:    array report = indices(log), r2;       last_time=0;    sort(map(values(log),lambda(array a){    return id->variables->reversed?-a[-1]:a[0];    }),report);    for(int i=0;i<min(sizeof(report),1000);i++)    report[i] = describe_error(report[i], log[report[i]],    id->misc->cf_locale, no_links);    -  if( sizeof( report ) >= 1000 ) +  if( sizeof( report ) > 1000 )    report[1000] =    sprintf(LOCALE(472,"%d entries skipped. Present in log on disk."), -  sizeof( report )-999 ); +  sizeof( report )-1000 );       return "<h3>"+LOCALE(216, "Events")+"</h3>" + (report[..1000]*"");   }      string get_module_snmp(RoxenModule o, ModuleInfo moduleinfo, RequestID id)   {    if (!o->query_snmp_mib) return "";       Configuration conf = o->my_configuration();   
Roxen.git/server/config_interface/sites/site_content.pike:345:   string get_snmp_values(ADT.Trie mib,    array(int) oid_start,    void|array(int) oid_ignore)   {    array(string) res = ({    "<th align='left'>Name</th>"    "<th align='left'>Value</th>"    });       for (array(int) oid = oid_start; oid; oid = mib->next(oid)) { +  if (!has_prefix((string)oid, (string)oid_start)) { +  // Reached end of the oid subtree. +  break; +  }    if (oid_ignore && has_prefix((string)oid, (string)oid_ignore)) continue;    string oid_string = ((array(string)) oid) * ".";    string name = "";    string doc = "";    mixed val = "";    mixed err = catch {    val = mib->lookup(oid);    if (zero_type(val)) continue;    if (objectp(val)) {    if (val->update_value) {
Roxen.git/server/config_interface/sites/site_content.pike:494:    "<table border=0 cellpadding=0 cellspacing=0>"    "<tr nowrap=''><td><b>Identifier:</b></td>"    "<td><img src='/internal-roxen-unit' width=10 height=1 /></td>"    "<td>" + mi->sname + "</td></tr>\n"    "<td nowrap=''><b>Thread safe:</b></td>"    "<td><img src='/internal-roxen-unit' width=10 height=1 /></td>"    "<td>" + (m->thread_safe ?    LOCALE("yes", "Yes") : LOCALE("no", "No")) +   #ifdef THREADS    " <small>(<a href='../../../../../actions/?action" -  "=locks.pike&class=status'>more info</a>)</small></td></tr>\n" +  "=locks.pike&amp;class=status&amp;&usr.set-wiz-id;'>" +  "more info</a>)</small></td></tr>\n"    "<tr><td nowrap=''><b>Number of accesses:</b></td>"    "<td><img src='/internal-roxen-unit' width=10 height=1 /></td>"    "<td>" + my_accesses +   #endif    "</td></tr>\n"    "<tr><td valign='top' nowrap=''><b>Type:</b></td>"    "<td><img src='/internal-roxen-unit' width=10 height=1 /></td>"    "<td valign='top'>" + describe_type( m, mi->type, id ) +    "</td></tr>\n"    + fnas +
Roxen.git/server/config_interface/sites/site_content.pike:660:    +(settings?   #"<cfg-variables nosave='' source='port-variables' port='&port.port;'/>    </td></tr>    ":"")+#"    </if>    </emit>";    return res+(settings?"</table>":"");   }       - string parse( RequestID id ) + string|mapping parse( RequestID id )   {    array(string) path = ((id->misc->path_info||"")/"/")-({""});       // roxen_perror(sprintf("site_content:parse(): path: %{%O,%}\n", path));       string section;    array(string) _sec = id->real_variables->section;       if( _sec )    {    if( sizeof( _sec ) > 0 )    RXML.set_var( "section", _sec[0], "form" );    section = _sec[0];    }    -  if( !sizeof( path ) ) -  return "Hm?"; +  if( !sizeof( path ) || equal(path, ({ "" })) ) +  return Roxen.http_redirect("/sites/", id);       Configuration conf = roxen->find_configuration( path[0] );       if( !conf->inited )    conf->enable_all_modules();       if( !config_perm( "Site:"+conf->name ) )    return "Permission denied";       id->misc->current_configuration = conf;
Roxen.git/server/config_interface/sites/site_content.pike:700:    {    /* Global information for the configuration */    switch( section )    {    default: /* Not status info */    do id->misc->do_not_goto = 1; while( id = id->misc->orig );    return "<cfg-variables source='config-variables' "    "configuration='"+path[0]+"' section='&form.section;'/>";       case "ModulePriorities": +  if (conf == id->conf) { +  // Configuration interface. +  return 0; +  }    return module_priorities_page(id, conf);          case "Ports":    string res =    "<input type=hidden name='section' value='Ports' />"    "<cfg-variables source='config-variables' "    " configuration='"+path[0]+"' section='Ports'/><br clear='all'/>";       array(string) urls = conf->query("URLs");
Roxen.git/server/config_interface/sites/site_content.pike:770:    res += "<p>"+Roxen.html_encode_string(conf->variables->comment->query())+"</p>";       res += "<br /><table><tr><td valign=\"top\">"    "<h2>"+LOCALE(260, "Request status")+"</h2>";    res += status(conf);    res += "</td>"    "<td><img src='/internal-roxen-unit' width='10' height='1' /></td>"    "<td valign=top>"    "<h2>"+LOCALE(292, "Cache status")+"</h2><table cellpading='0' cellspacing='0' width='100%'>\n";    -  int total = conf->datacache->hits+conf->datacache->misses; -  -  if( !total ) -  total = 1; -  +  mapping stats = conf->datacache->get_cache_stats(); +  int total = stats->hits + stats->misses;    res +=    sprintf("<tr><td><b>" + LOCALE(293, "Hits") + ": </b></td>" -  "<td align='right'>%d</td><td align='right'>%d</td>" -  "<td align='left'>%%</td></tr>\n", -  conf->datacache->hits, -  conf->datacache->hits*100 / total ); +  "<td align='right'>%d</td><td align='right'>(%d</td>" +  "<td align='left'>%%)</td></tr>\n", +  stats->hits, +  total ? (stats->hits * 100 / total) : 0);    res +=    sprintf("<tr><td><b>" + LOCALE(294, "Misses") + ": </b></td>" -  "<td align='right'>%d</td><td align='right'>%d</td>" -  "<td align='left'>%%</td></tr>\n", -  conf->datacache->misses, -  conf->datacache->misses*100 / total ); +  "<td align='right'>%d</td><td align='right'>(%d</td>" +  "<td align='left'>%%)</td></tr>\n", +  stats->misses, +  total ? (stats->misses * 100 / total) : 0);       res +=    sprintf("<tr><td><b>" + LOCALE(295, "Entries") + ": </b></td>" -  "<td align='right'>%d</td><td align='right'>%d</td>" -  "<td align='left'>Kb</td></tr>\n", -  sizeof( conf->datacache->cache ), -  (conf->datacache->current_size / 1024 ) ); +  "<td align='right'>%d</td><td align='right'>(%d</td>" +  "<td align='left'>kB)</td></tr>\n", +  stats->entries, +  stats->current_size / 1024);       res += "</table>\n";       res += "</td></tr></table><br />";          if( id->variables[ LOCALE(247, "Clear Log")+".x" ] )    {    foreach( values(conf->modules), ModuleCopies m )    foreach( values( m ), RoxenModule md )
Roxen.git/server/config_interface/sites/site_content.pike:842:    }    } else    return module_page( id, path[0], path[2] );    return "";   }            string module_priorities_page( RequestID id, Configuration c)   { +  Variable.Variable maxpri_var = c->getvar("max_priority");    -  +  int max_priority = maxpri_var->query(); +     array modids = map( indices( c->otomod )-({0}),    lambda(mixed q){ return c->otomod[q]; });       array mod_types = ({ -  ([ "title" : "First Try Modules", "type" : MODULE_FIRST ]), -  ([ "title" : "Filter Modules", "type" : MODULE_FILTER ]), -  ([ "title" : "Last Try Modules", "type" : MODULE_LAST ]), -  +  ([ "title" : "First Try Modules", "type" : MODULE_FIRST ]), +  ([ "title" : "Filter Modules", "type" : MODULE_FILTER ]), +  ([ "title" : "Location Modules", "type" : MODULE_LOCATION ]), +  ([ "title" : "Last Try Modules", "type" : MODULE_LAST ]),    });       array mods = map( modids,    lambda(string q) {    object mod = roxen.find_module( (q/"#")[0] );    object modi = c->find_module(q);    int c = (int)((q/"#")[-1]);    return ([    "id":q,    "name":mod->get_name(),    "name2":mod->get_name()+(c?" #"+(c+1):""),    "modi":modi,    "instance":c,    "pri":modi->query("_priority"),    "type":modi->module_type,    ]);    } );    -  -  string res = "<input type=hidden name='section' value='ModulePriorities' />"; -  -  res += "<cf-save/>"; -  -  res += "<h1>Module priorities for site "+Roxen.roxen_encode(c->name,"html")+"</h1>"; -  res += "9 is highest and 0 is lowest.<br /><br />"; -  -  res += "<table border='0' cellpadding='0' cellspacing='2'>"; -  -  mapping modules_seen = ([ ]); -  -  foreach(mod_types, mapping mt) { -  res += "<tr><td colspan='3'><h2>"+mt->title+"</h2></td></tr>\n"; -  -  array _mods = Array.filter(mods, lambda(mapping m) { return m->type & mt->type; }); -  -  foreach( _mods, mapping m ) { +  // Update any module priorities before the range change. +  // Otherwise the priority scaling won't work properly. +  foreach( mods, mapping m ) { +  if (!(m->type & (MODULE_FIRST|MODULE_FILTER|MODULE_LAST|MODULE_LOCATION))) { +  continue; +  }    int modpri = m->pri;    string varname = "prichange_"+replace(m->id,"#","!");    if(id->variables[varname]) { -  modpri = (int)(id->variables[varname]); +  modpri = (int)m_delete(id->variables, varname);    if(modpri < 0)    modpri = 0; -  if(modpri > 9) -  modpri = 9; +  if(modpri > max_priority) +  modpri = max_priority;       if(m->pri != modpri) {    m->oldpri = m->pri;    m->pri = modpri;    m->modi->getvar("_priority")->set(m->pri);    if( m->modi->save_me )    m->modi->save_me();    else    m->modi->save();    }    }    }    -  +  if (id->variables["maxprichange"]) { +  int new_max = (int)m_delete(id->variables, "maxprichange"); +  if (new_max != max_priority) { +  maxpri_var->set(new_max); +  c->save_me(); +  // Recurse so that we get updated priorities in our variables. +  return module_priorities_page(id, c); +  } +  } +  +  string res = "<input type=hidden name='section' value='ModulePriorities' />"; +  +  res += "<cf-save/>"; +  +  res += "<h1>Module priorities for site "+Roxen.roxen_encode(c->name,"html")+"</h1>"; +  +  res += "<select name='maxprichange'>\n"; +  foreach(c->getvar("max_priority")->get_choice_list(), int pri) { +  if (pri == max_priority) { +  res += sprintf("<option selected='selected' value='%d'>%d</option>\n", pri, pri); +  } else { +  res += sprintf("<option value='%d'>%d</option>\n", pri, pri); +  } +  } +  res += "</select>\n"; +  res += "is highest and 0 is lowest.<br /><br />"; +  +  res += "<table border='0' cellpadding='0' cellspacing='2'>"; +  +  mapping modules_seen = ([ ]); +  +  foreach(mod_types, mapping mt) { +  res += "<tr><td colspan='4'><h2>"+mt->title+"</h2></td></tr>\n"; +  +  array _mods = Array.filter(mods, lambda(mapping m) { return m->type & mt->type; }); +     _mods = Array.sort_array(_mods, lambda(mapping m1, mapping m2) {    if(m2->pri==m1->pri)    return m2->name2 > m1->name2;    return m2->pri > m1->pri;    }    );       mapping seen_pri = ([ ]); -  int pri_warn = 0; +  string pri_warn;       foreach( _mods, mapping m ) {       res += "<tr><td>" + m->name2 + "</td>"; -  +  string location = ""; +  if ((mt->type & MODULE_LOCATION) && m->modi->query_location) { +  location = m->modi->query_location(); +  } +  res += "<td><i>" + Roxen.roxen_encode(location, "html") + "</i></td>";    res+= "<td><img src='/internal-roxen-unit' width='20' height='1'/></td>";       res += "<td> Priority: ";    -  if(seen_pri[m->pri]) -  pri_warn = 1; +  if (!seen_pri[location]) +  seen_pri[location] = ([ m->pri : 1 ]); +  else if(seen_pri[location][m->pri]) +  pri_warn = location;    else -  seen_pri[m->pri] = 1; +  seen_pri[location][m->pri] = 1;       if(!modules_seen[m->name2]) { -  +  if (max_priority == 9) {    res += "<select name='prichange_"+replace(m->id,"#","!")+"'>";    foreach( ({ 0,1,2,3,4,5,6,7,8,9 }), int pri) {    if(m->pri == pri)    res+="<option selected='selected' value='"+pri+"'>"+pri+"</option>";    else    res+="<option value='"+pri+"'>"+pri+"</option>";    }    res+="</select>"; -  +  } else { +  res += sprintf("<input type='text' name='prichange_%s' size='%d' value='%d' />", +  replace(m->id, "#", "!"), +  sizeof(sprintf("%d", max_priority) + 2), +  m->pri); +  }    modules_seen[m->name2] = 1;    } else {    res += (string)m->pri + " (change above)";    }          res+="</td></tr>\n";    -  res += "<tr><td colspan='3'>"; +  res += "<tr><td colspan='4'>";       if(m->oldpri)    res += "<imgs src='&usr.err-1;'/> Priority changed from " + m->oldpri + " to " + m->pri +".";       res += "</td></tr>";    }       if(pri_warn) { -  res += "<tr><td colspan='3'>"; -  res+= "<br /><imgs src='&usr.err-2;'/> Some modules have the same priority and will be called in random order."; +  res += "<tr><td colspan='4'>"; +  res += "<br /><imgs src='&usr.err-2;'/> Some modules have the same priority and will be called in random order.";    res += "</td></tr>";    }    -  res += "<tr><td colspan='3'>"; +  res += "<tr><td colspan='4'>";    res+= "<img src='/internal-roxen-unit' width='1' height='20'/>";    res += "</td></tr>";       }       res += "</table>";       res += "<cf-save/>";       return res;   }