", $output); list($skip, $end) = explode("", $tmpstr); $output = "$begin$end"; } if ( isset($_REQUEST["nodate"]) ) { list($begin, $tmpstr) = explode("", $output); list($skip, $end) = explode("", $tmpstr); $output = "$begin$end"; } if ( isset($_REQUEST["height"]) ) { $totalheight = $_REQUEST["height"] - 1; $contentheight = $_REQUEST["height"] - 70; $locstyle = "\n"; $output = preg_replace("!!", "$locstyle", $output); } print $output; function getoriginal($file, $what, $mode) { lockfile($file); include "config.inc.php"; $time_start = microtime(true); $handledetail = true; $usedserver = $urlserver["default"]; if ( isset($urlserver[$what]) ) { $usedserver = $urlserver[$what]; if ( $what != "now" && $what != "next" ) { $handledetail = false; } } $c = curl_init(); // URL curl_setopt($c, CURLOPT_URL, $usedserver); // accept server URL rewriting curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); // transmit return value curl_setopt($c, CURLOPT_RETURNTRANSFER, true); // no header in return value curl_setopt($c, CURLOPT_HEADER, false); // methodPOST curl_setopt($c, CURLOPT_POST,true); // parameters $options = $parameters[$what]; if ( $what == "now" ) { $timereference = date("Y-m-d H:i", time()); foreach ( $options as $key => $val ) { $options[$key] = preg_replace("/NOW/", $timereference, $val); } } else if ( $what == "next" ) { $timereference = date("Y-m-d H:i", time() + 5400); foreach ( $options as $key => $val ) { $options[$key] = preg_replace("/NEXT/", $timereference, $val); } } if ( $mode == "short" ) $options[$hideowners_label] = $hideowners_value; curl_setopt($c, CURLOPT_POSTFIELDS , $options); // execute request $string = curl_exec($c); if($string !== false) { if ( $REMOVEMENU && ! isset($keepmenu[$what]) ) { $RETURN = "$NAVIN$BACKTEXT"; if ( $handledetail ) { if ( $mode == "short" ) { $RETURN .= "$NAVMID$SHOWTEXT"; } else { $RETURN .= "$NAVMID$HIDETEXT"; } } $RETURN .= $NAVOUT; list($begin, $tmpstr) = explode("", $tmpstr); $string = "$begin$RETURN$end"; list($begin, $tmpstr) = explode("", $tmpstr); $string = "$begin$end"; } $usedtitle = ""; if ( isset($pagetitle[$what]) ) $usedtitle = " (" .$pagetitle[$what] . ")"; $string = preg_replace("/.*<\/title>/", "<title>$TITLE$usedtitle", $string); $string = preg_replace("/href=\"\//", "href=\"$PROGSERVER/", $string); $string = preg_replace("/action=\"\//", "action=\"$PROGSERVER/", $string); if ( $ADDTIME ) { $time_end = microtime(true); $time = $time_end - $time_start; $when = gmdate("M d, Y h:i a T"); $timetext = sprintf("
Page " . "generated on $when using %.2f seconds" . "
", $time); $string = preg_replace("/<\/body>/", "$timetext", $string); } if ( ! isset($nocache[$what]) ) { $fd = fopen($file, "w"); if ( $fd ) { fwrite($fd, $string); fclose($fd); } chmod($file, 0640); } } curl_close($c); unlockfile($file); return $string; } function getfromcache($file) { $string = false; waitonlock($file); if ( is_readable($file) ) { $fd = fopen($file, "r"); if ( $fd ) { $string = ""; while(!feof($fd)){ $string .= fread($fd, 8192); } fclose($fd); } } return $string; } function lockfile($file) { $lock = "$file.lock"; clearlock($lock); $cnt = 0; $fd = fopen($lock, "x"); while ( ! $fd ) { if ( $cnt++ > 20 ) break; sleep(1); $fd = fopen($lock, "x"); } if ( $fd ) fclose($fd); } function unlockfile($file) { $lock = "$file.lock"; unlink($lock); } function islocked($file) { $lock = "$file.lock"; clearlock($lock); return file_exists($lock); } function waitonlock($file) { $lock = "$file.lock"; clearlock($lock); $cnt = 0; while ( file_exists($lock) ) { if ( $cnt++ > 20 ) break; sleep(1); } } function clearlock($lock) { if ( file_exists($lock) ) { $locktime = time() - filectime($lock); if ( $locktime > 30 ) unlink($lock); } }