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

version» Context lines:

Roxen.git/server/modules/tags/sqltag.pike:1:   /* -  * $Id: sqltag.pike,v 1.13 1997/10/15 18:59:32 grubba Exp $ +  * $Id: sqltag.pike,v 1.14 1997/10/15 19:05:08 grubba Exp $    *    * A module for Roxen Challenger, which gives the tags    * <SQLQUERY> and <SQLOUTPUT>.    *    * Henrik Grubbström 1997-01-12    */    - constant cvs_version="$Id: sqltag.pike,v 1.13 1997/10/15 18:59:32 grubba Exp $"; + constant cvs_version="$Id: sqltag.pike,v 1.14 1997/10/15 19:05:08 grubba Exp $";   constant thread_safe=1;   #include <module.h>      /* Compatibility with old versions of the sqltag module. */   // #define SQL_TAG_COMPAT      inherit "module";   inherit "roxenlib";      import Array;
Roxen.git/server/modules/tags/sqltag.pike:106:    database = args->database;    user = "";    password = "";    }    if (args->user) {    user = args->user;    }    if (args->password) {    password = args->password;    } -  host = (lowercase(host) == "localhost")?"":host; +  host = (lower_case(host) == "localhost")?"":host;       if (error = catch(con = sql(host, database, user, password))) {    contents = "<h1>Couldn't connect to SQL-server</h1><br>\n" +    ((master()->describe_backtrace(error)/"\n")*"<br>\n");    } else if (error = catch(result = con->query(args->query))) {    contents = "<h1>Query \"" + args->query + "\" failed: " +    con->error() + "</h1>\n" +    ((master()->describe_backtrace(error)/"\n")*"<br>\n");    } else if (result && sizeof(result)) {    string nullvalue="";
Roxen.git/server/modules/tags/sqltag.pike:186:    database = args->database;    user = "";    password = "";    }    if (args->user) {    user = args->user;    }    if (args->password) {    password = args->password;    } -  host = (lowercase(host) == "localhost")?"":host; +  host = (lower_case(host) == "localhost")?"":host;       if (error = catch(con = sql(host, database, user, password))) {    return("<h1>Couldn't connect to SQL-server</h1><br>\n" +    ((master()->describe_backtrace(error)/"\n")*"<br>\n"));    } else if (error = catch(res = con->query(args->query))) {    return("<h1>Query \"" + args->query + "\" failed: " +    con->error() + "</h1>\n" +    ((master()->describe_backtrace(error)/"\n")*"<br>\n"));    }    return(res?"<true>":"<false>");    } else {    return("<!-- No query! --><false>");    }   }      string sqltable_tag(string tag_name, mapping args,    object request_id, mapping defines)   { -  +  int ascii; +  +  if (args->ascii) { +  // ASCII-mode +  ascii = 1; +  } +     if (args->query) {    string host = query("hostname");   #ifdef SQL_TAG_COMPAT    string database = query("database");    string user = query("user");    string password = query("password");   #else /* SQL_TAG_COMPAT */    string database, user, password;   #endif /* SQL_TAG_COMPAT */    object(sql) con;    mixed error;    object(sql_result) result;    string res; -  int ascii; +     -  if (args->ascii) { -  // ASCII-mode -  ascii = 1; -  } -  +     if (args->host) {    host = args->host;    user = "";    password = "";    }    if (args->database) {    database = args->database;    user = "";    password = "";    }    if (args->user) {    user = args->user;    }    if (args->password) {    password = args->password;    } -  host = (lowercase(host) == "localhost")?"":host; +  host = (lower_case(host) == "localhost")?"":host;       if (error = catch(con = sql(host, database, user, password))) {    return("<h1>Couldn't connect to SQL-server</h1><br>\n" +    ((master()->describe_backtrace(error)/"\n")*"<br>\n"));    } else if (error = catch(result = con->big_query(args->query))) {    return("<h1>Query \"" + args->query + "\" failed: " +    con->error() + "</h1>\n" +    ((master()->describe_backtrace(error)/"\n")*"<br>\n"));    }   
Roxen.git/server/modules/tags/sqltag.pike:360:    defvar("hostname", "localhost", "Default SQL-database host",    TYPE_STRING, "Specifies the default host to use for SQL-queries.\n"    "This argument can also be used to specify which SQL-server to "    "use by specifying an \"SQL-URL\":<ul>\n"    "<pre>[<i>sqlserver</i>://][[<i>user</i>][:<i>password</i>]@]"    "[<i>host</i>[:<i>port</i>]]/<i>database</i></pre></ul><br>\n"    "Valid values for \"sqlserver\" depend on which "    "sql-servers your pike has support for, but the following "    "might exist: msql, mysql, odbc, oracle, postgres.\n");   #ifdef SQL_TAG_COMPAT -  defvar("database", "", "Default SQL-database", -  TYPE_STRING, "Specifies the name of the default SQL-database.\n"); -  defvar("user", "", "Default username", -  TYPE_STRING, "Specifies the default username to use for access.\n"); -  defvar("password", "", "Default password", -  TYPE_STRING, "Specifies the default password to use for access.\n"); +  defvar("database", "", "Default SQL-database (deprecated)", +  TYPE_STRING|VAR_MORE, +  "Specifies the name of the default SQL-database.\n"); +  defvar("user", "", "Default username (deprecated)", +  TYPE_STRING|VAR_MORE, +  "Specifies the default username to use for access.\n"); +  defvar("password", "", "Default password (deprecated)", +  TYPE_STRING|VAR_MORE, +  "Specifies the default password to use for access.\n");   #endif /* SQL_TAG_COMPAT */   }      /*    * More interface functions    */      void start()   {   }      void stop()   {   }      string status()   {    if (catch { -  object o = Sql.sql(QUERY(hostname), QUERY(database), -  QUERY(user), QUERY(password)); +  object o = Sql.sql(QUERY(hostname) + #ifdef SQL_TAG_COMPAT +  , QUERY(database), QUERY(user), QUERY(password) + #endif /* SQL_TAG_COMPAT */ +  );    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");    }   }