Roxen.git / server / modules / tags / sqltag.pike

version» Context lines:

Roxen.git/server/modules/tags/sqltag.pike:1:   /* -  * $Id: sqltag.pike,v 1.2 1997/05/19 23:23:54 grubba Exp $ +  * $Id: sqltag.pike,v 1.3 1997/06/20 16:57:15 grubba Exp $    *    * A module for Roxen Challenger, which gives the tags    * <SQLQUERY> and <SQLOUTPUT>.    *    * Henrik Grubbström 1997-01-12    */      #include <module.h>      inherit "module";
Roxen.git/server/modules/tags/sqltag.pike:22:   array register_module()   {    return( ({ MODULE_PARSER,    "SQL-module",    "This module gives the three tags &lt;SQLQUERY&gt;, "    "&lt;SQLOUTPUT&gt; and &lt;SQLTABLE&gt;.",    0,    1 }) );   }    - string cvs_version = "$Id: sqltag.pike,v 1.2 1997/05/19 23:23:54 grubba Exp $"; + string cvs_version = "$Id: sqltag.pike,v 1.3 1997/06/20 16:57:15 grubba Exp $";      /*    * Tag handlers    */      string sqloutput_tag(string tag_name, mapping args, string contents,    object request_id, mapping defines)   {    if (args->query) {    string host = query("hostname");
Roxen.git/server/modules/tags/sqltag.pike:273:    defvar("hostname", "localhost", "Default SQL-database host",    TYPE_STRING, "Specifies the default host to use for SQL-queries");    defvar("database", "", "Default SQL-database",    TYPE_STRING, "Specifies the name of the default SQL-database");    defvar("user", "", "Default username",    TYPE_STRING, "Specifies the default username to use for access");    defvar("password", "", "Default password",    TYPE_STRING, "Specifies the default password to use for access");   }    - string|void check_variable(string var, mixed new_value) - { -  switch(var) { -  case "hostname": -  if (catch(sql(((lower_case(new_value)=="localhost")?"":new_value)))) { -  return("Couldn't connect to any SQL-server at "+new_value+"\n"); -  } -  break; -  case "database": -  if (catch(sql(((lower_case(query("hostname"))=="localhost")?"":query("hostname")), -  new_value))) { -  return("Couldn't select database "+new_value+"\n"); -  } -  break; -  case "user": -  break; -  case "password": -  if (catch(sql(((lower_case(query("hostname"))=="localhost")?"":query("hostname")), -  query("database"), query("user"), new_value))) { -  return("Couldn't connect to database. Wrong password?\n"); -  } -  break; -  default: -  return("Unknown variable "+var+"\n"); -  } - } -  +    /*    * More interface functions    */      void start()   {   }      void stop()   {   }      string status()   { -  return("OK"); +  if (catch { +  object o = Sql.sql(QUERY(hostname), QUERY(database), +  QUERY(user), QUERY(password)); +  return(sprintf("Connected to %s-server on %s<br>\n" +  o->server_info(), o->host_info())); +  }) { +  return("<font color=red>Not connected.</font><br>\n");    } -  + }