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

version» Context lines:

Roxen.git/server/modules/tags/sqltag.pike:1:   /* -  * $Id: sqltag.pike,v 1.15 1997/10/15 19:40:13 grubba Exp $ +  * $Id: sqltag.pike,v 1.16 1997/11/26 22:12:27 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.15 1997/10/15 19:40:13 grubba Exp $"; + constant cvs_version="$Id: sqltag.pike,v 1.16 1997/11/26 22:12:27 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:88: Inside #if defined(SQL_TAG_COMPAT)
   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;    array(mapping(string:mixed)) result; +  function sql_connect = request_id->conf->sql_connect;    mixed error;       if (args->host) {    host = args->host;    user = "";    password = "";    }    if (args->database) {    database = args->database;    user = "";    password = ""; -  +  sql_connect = 0;    }    if (args->user) {    user = args->user; -  +  sql_connect = 0;    }    if (args->password) {    password = args->password; -  +  sql_connect = 0;    } -  +  if (sql_connect) { +  error = catch(con = sql_connect(host)); +  } else {    host = (lower_case(host) == "localhost")?"":host; -  -  if (error = catch(con = sql(host, database, user, password))) { +  error = catch(con = sql(host, database, user, password)); +  } +  if (error) {    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="";    array(string) content_array = contents/"#";    array(string) res_array=allocate(sizeof(content_array)*sizeof(result));
Roxen.git/server/modules/tags/sqltag.pike:168: Inside #if defined(SQL_TAG_COMPAT)
   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; +  function sql_connect = request_id->conf->sql_connect;    array(mapping(string:mixed)) res;       if (args->host) {    host = args->host;    user = "";    password = "";    }    if (args->database) {    database = args->database;    user = "";    password = ""; -  +  sql_connect = 0;    }    if (args->user) {    user = args->user; -  +  sql_connect = 0;    }    if (args->password) {    password = args->password; -  +  sql_connect = 0;    } -  +  if (sql_connect) { +  error = catch(con = sql_connect(host)); +  } else {    host = (lower_case(host) == "localhost")?"":host; -  -  if (error = catch(con = sql(host, database, user, password))) { +  error = catch(con = sql(host, database, user, password)); +  } +  if (error) {    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>");
Roxen.git/server/modules/tags/sqltag.pike:223: Inside #if defined(SQL_TAG_COMPAT)
   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; +  function sql_connect = request_id->conf->sql_connect;    object(sql_result) result;    string res;       if (args->host) {    host = args->host;    user = "";    password = "";    }    if (args->database) {    database = args->database;    user = "";    password = ""; -  +  sql_connect = 0;    }    if (args->user) {    user = args->user; -  +  sql_connect = 0;    }    if (args->password) {    password = args->password; -  +  sql_connect = 0;    } -  +  if (sql_connect) { +  error = catch(con = sql_connect(host)); +  } else {    host = (lower_case(host) == "localhost")?"":host; -  -  if (error = catch(con = sql(host, database, user, password))) { +  error = catch(con = sql(host, database, user, password)); +  } +  if (error) {    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"));    }       if (result) {    string nullvalue="";
Roxen.git/server/modules/tags/sqltag.pike:379: Inside #if defined(SQL_TAG_COMPAT)
   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() + object conf; +  + void start(int level, object _conf)   { -  +  if (_conf) { +  conf = _conf;    } -  + }      void stop()   {   }      string status()   {    if (catch { -  object o = Sql.sql(QUERY(hostname) +  object o; +  if (conf->sql_connect) { +  o = conf->sql_connect(QUERY(hostname)); +  } else { +  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");    }   }