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

version» Context lines:

Roxen.git/server/modules/tags/insert_cached_href.pike:1:   // This is a roxen module. Copyright © 2000 - 2004, Roxen IS.   //      #include <module.h>   inherit "module";      //<locale-token project="mod_insert_cached_href">LOCALE</locale-token>   #define LOCALE(X,Y) _DEF_LOCALE("mod_insert_cached_href",X,Y)    - constant cvs_version = "$Id: insert_cached_href.pike,v 1.24 2009/04/16 09:49:24 liin Exp $"; + constant cvs_version = "$Id: insert_cached_href.pike,v 1.25 2009/11/11 15:42:25 stewa Exp $";      constant thread_safe = 1;   constant module_type = MODULE_TAG;   LocaleString module_name = LOCALE(1, "Tags: Insert cached href");   LocaleString module_doc = LOCALE(2, "This module contains the RXML tag \"insert "    "cached-href\". Useful when implementing e.g."    " RSS syndication.");      #if DEBUG_INSERT_CACHED_HREF   #define DWRITE(x) report_debug("INSERT_CACHED_HREF: " + x + "\n")
Roxen.git/server/modules/tags/insert_cached_href.pike:397:    if (next_fetch < time())    next_fetch += 24 * 3600;    }      #ifndef THREADS    /* When running unthreaded the database still needs to be kept up-to-date */    remove_old_entrys();   #endif       sql_query("UPDATE " + request_table + " SET latest_request=" + time() -  + " WHERE url='" + args["cached-href"] + "' AND fetch_interval=" +  + " WHERE url=%s AND fetch_interval="    + args["fetch-interval"] + " AND fresh_time=" + args["fresh-time"]    + " AND ttl=" + args["ttl"] + " AND timeout=" + args["timeout"] -  + " AND time_of_day=" + args["time-of-day"]); +  + " AND time_of_day=" + args["time-of-day"], args["cached-href"] );       sql_query("INSERT IGNORE INTO " + request_table    + " values (%s, %d, %d, %d, %d, %d, %d, %d)", args["cached-href"],    args["fetch-interval"], args["fresh-time"], args["ttl"],    args["timeout"], args["time-of-day"], next_fetch, time());       sql_query("INSERT IGNORE INTO " + data_table + " values (%s, '', 0)",    args["cached-href"]);    -  result = sql_query("SELECT data FROM " + data_table + " WHERE url='" + -  args["cached-href"] + "' AND (" + time() + " - latest_write < " -  + args["fresh-time"] + " OR " + args["fresh-time"] + " = 0)"); +  result = sql_query("SELECT data FROM " + data_table + " WHERE url=%s " +  " AND (" + time() + " - latest_write < " +  + args["fresh-time"] + " OR " + args["fresh-time"] + " = 0)", args["cached-href"]);       if (result && sizeof(result) && result[0]["data"] != "") {    DWRITE("get_data(): Returning cached data for " + args["cached-href"]);       return utf8_to_string(result[0]["data"]);    } else if (!args["pure-db"]) {    DWRITE("get_data(): No cached data existed for " + args["cached-href"] + " so performing a synchronous fetch");       string data = fetch_url((["url":args["cached-href"], "timeout":args["timeout"],    "sync":1]), header);