function showgraph($date, $xsize = "640", $ysize = "480Â", $type, $interval) { include "cfg/nmcgraph_cfg.php"; $minscale = null; $maxscale = null; $imagefilename = dirname(__FILE__) . "/../cache/daily/daily_{$date}.png"; $imagepath = "/cache/daily/daily_{$date}.png"; $altimage = $type . " namecoin graph for date {$date}"; $permalink = $siteurl . "/daily/nmc_daily.php?day=" . $date; $title = $type . " namecoin historic data graph for date {$date}"; $graphgendate = ""; $cached = null; $message = "daily graph is cached one hour"; //echo $imagefilename; exit; if ($graphgendate = checkcache($imagefilename)) { $cached = true; } else { $cached = false; /* Create and populate the pData object */ $MyData = new pData(); load_nmc_data($MyData, $date, $type, $minscale, $maxscale); //var_dump($MyData); //printf("minscale: $minscale maxscale: $maxscale <br />\n"); $graphgendate = buildgraph($MyData, $xsize, $ysize, $title, $minscale, $maxscale, $date, $type, $imagefilename); } $html_code = "<img alt=\"" . $altimage . "\" src=\"" . $imagepath . "\" />"; return $html_code; }
/** * Get the template for the input, that, and topic * * Get the template for a paticular pattern and dialogue situation. If the pattern, including topic and that, was found in the cache, the mathcing routine is circumvented and that template used. This saves time. * * @todo The name gettemplate() and {@link findtemplate()} are too similar. * * @uses debugger() * @uses checkcache() * @uses graphwalker() * @uses findtemplate() * @uses fillcache() * * @global integer the Bot's ID. * * @param string $input The user's input * @param string $that The bot's previous output * @param string $topic The contents of the AIML tag <topic> * @param array &$inputstarvals contains the contents of the *'s when they are part of the matching pattern input string * @param array &$thatstarvals contains the contents of the *'s when they are part of the matching pattern that string * @param array &$topicstarvals contains the contents of the *'s when they are part of the matching pattern topic string * @param array &$patternmatched contains all patterns that were found. An input can have more than one sentence which are processed seperately. * @param array &$inputmatched contains all the individual sentences of a user's input. * * @return string The template belonging to the matching pattern. */ function gettemplate($input, $that, $topic, &$inputstarvals, &$thatstarvals, &$topicstarvals, &$patternmatched, &$inputmatched) { global $selectbot; // Put the input, that, and topic together into a single sentence to find a match for $combined = "<input> " . trim($input) . " <that> " . trim($that) . " <topic> " . trim($topic); debugger("Combined: {$combined}", 2); if (CACHE_CONTROL == 1 && checkcache($combined, $template, $inputstarvals, $thatstarvals, $topicstarvals, $patternmatched, $inputmatched)) { debugger("<BR><b>HIT CACHE!</b><br>", 2); return $template; } else { $inputmatched = array(trim($input), " : ", trim($that), " : ", trim($topic)); // These arrays will hold the words that matched the wildcards in the pattern $inputstarvals = array(); $thatstarvals = array(); $topicstarvals = array(); $patternmatched = array(); // Get the template with graphwalker function. $mytemplateid = graphwalker($combined, -$selectbot, 1, 0, "", $inputstarvals, $thatstarvals, $topicstarvals, $patternmatched); $mytemplate = findtemplate($mytemplateid); $s_patternmatched = ""; $s_inputmatched = ""; foreach ($patternmatched as $value) { $s_patternmatched .= " " . $value; } foreach ($inputmatched as $value) { $s_inputmatched .= $value; } $patternmatched = $s_patternmatched; $inputmatched = $s_inputmatched; if (CACHE_CONTROL == 1) { fillcache($combined, $mytemplateid, $inputstarvals, $thatstarvals, $topicstarvals, $patternmatched, $inputmatched); } return $mytemplate; } }
} else { $ysize = 600; } } $minscale = null; $maxscale = null; $type = "daily"; $interval = "1-hour"; $imagefilename = "../cache/daily/daily_{$date}.png"; $imagepath = "/cache/daily/daily_{$date}.png"; $altimage = $type . " namecoin graph for date {$date}"; $permalink = $siteurl . "/daily/nmc_daily.php?day=" . $date; $link_daybefore = $siteurl . "/daily/nmc_daily.php?day=" . $date_daybefore; $link_nextday = $siteurl . "/daily/nmc_daily.php?day=" . $date_nextday; $navigation = "<a href=" . $link_daybefore . ">Day before</a> - <a href=" . $link_nextday . ">Next day</a>"; $title = $type . " namecoin historic data graph for date {$date}"; $graphgendate = ""; $cached = null; $message = "daily graph is cached one hour"; if ($graphgendate = checkcache($imagefilename)) { $cached = true; } else { $cached = false; /* Create and populate the pData object */ $MyData = new pData(); load_nmc_data($MyData, $date, $type, $minscale, $maxscale); //var_dump($MyData); //printf("minscale: $minscale maxscale: $maxscale <br />\n"); $graphgendate = buildgraph($MyData, $xsize, $ysize, $title, $minscale, $maxscale, $date, $type, $imagefilename); } renderpage($title, $permalink, $altimage, $imagepath, $graphgendate, $message, $cached, $navigation);
function bog_check_($url) { function checkcache($url) { $w3c_url = 'http://validator.w3.org/check?uri=' . $url . '&charset=%28detect+automatically%29&doctype=Inline'; $result = array(); $timeout = 60; // cache timeout $cache_dir = WP_PLUGIN_DIR . '/debogger/cache/'; $cache_file = $cache_dir . md5($url) . '.cache'; if (!file_exists($cache_file) or filemtime($cache_file) < time() - $timeout) { if (!class_exists('WP_Http')) { include_once ABSPATH . WPINC . '/class-http.php'; } $result_1 = wp_remote_retrieve_body(wp_remote_get($w3c_url)); $result[0] = $result_1; $result[1] = '(not cached)'; file_put_contents($cache_file, $result_1, LOCK_EX); } else { $result[0] = file_get_contents($cache_file); $result[1] = '(cached)'; } return $result; } $html = array(); $html = checkcache($url); if (empty($html)) { return 'error'; } $doc = new DOMDocument(); $doc->loadHTML($html[0]); $res = $doc->getElementById('congrats'); if (isset($res)) { $res = $doc->getElementById('congrats')->nodeValue; } if ($res == 'Congratulations') { return 'W3C Valid!' . $html[1]; } else { return 'Not W3C valid (<a href="http://validator.w3.org/check?uri=' . $url . '&charset=%28detect+automatically%29&doctype=Inline">errors</a>)' . $html[1]; } }
$row = $result->fetch_assoc(); $date = $row['date']; $size = $row['size']; $type = $row['type']; $parent_id = $row['parent'] > 0 ? $row['parent'] : $id; $ar = getallheaders(); if (isset($ar['If-Modified-Since']) && $ar['If-Modified-Since'] != '' && strtotime($ar['If-Modified-Since']) >= $date) { header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT', true, 304); debug_hook('image processed in ' . (microtime(true) - $ts) . ' seconds'); exit; } else { header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT', true, 200); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 86400) . ' GMT', true, 200); } $cacheid = sha1($id . $mode); if (checkcache($cacheid)) { if ($mode == 'thumb') { $type = 'jpg'; } header("content-type: " . imgtypetomime($type)); echo file_get_contents(DB_PATH . '/cache/' . $cacheid); } else { if ($mode == 'thumb') { $sql = 'SELECT data,size FROM thumbs WHERE entry=' . $id . ' && custom=' . ($_GET['args'] && substr($_GET['args'], 0, 6) == 'custom' ? 1 : 0); if ($result = $db->query($sql)) { $row = $result->fetch_assoc(); header('Content-Length: ' . $row['size']); header("content-type: image/jpeg"); echo $row['data']; file_put_contents(DB_PATH . '/cache/' . $cacheid, $row['data']); }