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

version» Context lines:

Roxen.git/server/modules/tags/sqltag.pike:1:   /* -  * $Id: sqltag.pike,v 1.26 1998/07/22 16:11:33 noring Exp $ +  * $Id: sqltag.pike,v 1.27 1998/07/23 18:41:58 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.26 1998/07/22 16:11:33 noring Exp $"; + constant cvs_version="$Id: sqltag.pike,v 1.27 1998/07/23 18:41:58 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:133:    sql_connect = 0;    }    if (sql_connect) {    error = catch(con = sql_connect(host));    } else {    host = (lower_case(host) == "localhost")?"":host;    error = catch(con = sql(host, database, user, password));    }    if (error) {    if (!args->quiet) { +  if (args->log_error && QUERY(log_error)) { +  report_error(sprintf("SQLTAG: Couldn't connect to SQL-server:\n" +  "%s\n", describe_backtrace(error))); +  }    contents = ("<h3>Couldn't connect to SQL-server</h1><br>\n" +    html_encode_string(error[0]) + "<false>");    } else {    contents = "<false>";    }    } else if (error = catch(result = con->query(args->query))) {    if (!args->quiet) { -  +  if (args->log_error && QUERY(log_error)) { +  report_error(sprintf("SQLTAG: Query %O failed:\n" +  "%s\n", +  args->query, describe_backtrace(error))); +  }    contents = ("<h3>Query \"" + html_encode_string(args->query)    + "\" failed: " + html_encode_string(con->error())    + "</h1>\n<false>");    } else {    contents = "<false>";    }    } else if (result && sizeof(result))    {    contents = do_output_tag( args, result, contents, request_id )    + "<true>";
Roxen.git/server/modules/tags/sqltag.pike:210:    sql_connect = 0;    }    if (sql_connect) {    error = catch(con = sql_connect(host));    } else {    host = (lower_case(host) == "localhost")?"":host;    error = catch(con = sql(host, database, user, password));    }    if (error) {    if (!args->quiet) { +  if (args->log_error && QUERY(log_error)) { +  report_error(sprintf("SQLTAG: Couldn't connect to SQL-server:\n" +  "%s\n", describe_backtrace(error))); +  }    return("<h3>Couldn't connect to SQL-server</h1><br>\n" +    html_encode_string(error[0])+"<false>");    } else {    return("<false>");    }    } else if (error = catch(res = con->query(args->query))) {    if (!args->quiet) { -  +  if (args->log_error && QUERY(log_error)) { +  report_error(sprintf("SQLTAG: Query %O failed:\n" +  "%s\n", +  args->query, describe_backtrace(error))); +  }    return("<h3>Query \"" + html_encode_string(args->query)+"\" failed: "    + html_encode_string(con->error()) + "</h1>\n<false>");    } else {    return("<false>");    }    }    if(args["mysql-insert-id"])    if(con->master_sql)    request_id->variables[args["mysql-insert-id"]] =    con->master_sql->insert_id();
Roxen.git/server/modules/tags/sqltag.pike:294:    sql_connect = 0;    }    if (sql_connect) {    error = catch(con = sql_connect(host));    } else {    host = (lower_case(host) == "localhost")?"":host;    error = catch(con = sql(host, database, user, password));    }    if (error) {    if (!args->quiet) { +  if (args->log_error && QUERY(log_error)) { +  report_error(sprintf("SQLTAG: Couldn't connect to SQL-server:\n" +  "%s\n", describe_backtrace(error))); +  }    return("<h3>Couldn't connect to SQL-server</h1><br>\n" +    html_encode_string(error[0])+"<false>");    } else {    return("<false>");    }    } else if (error = catch(result = con->big_query(args->query))) {    if (!args->quiet) { -  +  if (args->log_error && QUERY(log_error)) { +  report_error(sprintf("SQLTAG: Query %O failed:\n" +  "%s\n", +  args->query, describe_backtrace(error))); +  }    return ("<h3>Query \"" + html_encode_string(args->query) +    "\" failed: " + html_encode_string(con->error()) + "</h1>\n" +    "<false>");    } else {    return("<false>");    }    }       if (result) {    string nullvalue="";
Roxen.git/server/modules/tags/sqltag.pike:449:   {    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"); +  +  defvar("log_error", 0, "Enable the \"log_error\" attribute", +  TYPE_FLAG|VAR_MORE, "Enables the attribute \"log_error\" " +  "which causes errors to be logged to the event-log.\n"); +    #ifdef SQL_TAG_COMPAT    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");