function checkRCSdir($dir, $usleep = 0) { $dir = rtrim($dir, '/'); $handle = opendir($dir); if (!is_resource($handle)) { return false; } set_time_limit(0); $count = 0; while (($file = readdir($handle)) !== false) { if ((($p = strpos($file, '.')) !== false or $file == 'RCS' or $file == 'CVS') and is_dir($dir . '/' . $file)) { continue; } if (substr($file, -2) != ',v') { continue; } // ignore non rcs files $fp = fopen($dir . '/' . $file, 'r'); if (!is_resource($fp)) { continue; } // just ignore fseek($fp, -4, SEEK_END); $end = fread($fp, 4); fclose($fp); if (!preg_match("/@\n\\s*\$/", $end)) { echo "RCS file for page " . pagename($file) . ": {$dir}/{$file} is broken.\n"; } if ($usleep > 0) { usleep($usleep); } } closedir($handle); }
if ($plugin['enabled_groups'] == '') { # Add to the plugins array if not already present which is what we are working with # later on. if (!in_array($plugin['name'], $plugins)) { $plugins[] = $plugin['name']; } include_plugin_config($plugin['name'], $plugin['config'], $plugin['config_json']); } } } else { for ($n = 0; $n < count($plugins); $n++) { include_plugin_config($plugins[$n]); } } # Include the appropriate language file $pagename = str_replace(".php", "", pagename()); if (isset($defaultlanguage)) { $language = $defaultlanguage; } else { $language = http_get_preferred_language(); } if (isset($_COOKIE["language"])) { $language = $_COOKIE["language"]; } if (isset($_GET["language_set"])) { $language = $_GET["language_set"]; # Cannot use the general.php: rs_setcookie() here since general may not have been included. if ($global_cookies) { # Remove previously set cookies to avoid clashes setcookie("language", "", time() - 3600, $baseurl_short . "pages/"); setcookie("language", "", time() - 3600, $baseurl_short);
function fixrcs($rcsfile, $force = true) { chmod($rcsfile, 0666); $fp = fopen($rcsfile, 'rw'); if (!is_resource($fp)) { return -1; } $mtime = filemtime($rcsfile); $filesize = filesize($rcsfile); fseek($fp, -20, SEEK_END); $end = fread($fp, 20); $looks_ok = false; if (preg_match("!@\n\\s*\$!", $end)) { $looks_ok = true; } if (!$force and $looks_ok) { fclose($fp); echo "Looks OK\n"; return 0; // no need to fix RCS file } $pagename = preg_replace("/,v\$/", '', basename($rcsfile)); $pagename = pagename($pagename); $bs = 512; $pos = 0; $state = 'unknown'; $buf = ''; while (true) { echo '.'; if ($filesize < $bs) { echo "No version info!!\n"; return -1; } //if ($filesize + $pos - $bs < 0) // $bs = $filesize + $pos; //echo "\n".$filesize,' - ',$pos,' - ',$bs."\n"; fseek($fp, $pos - $bs, SEEK_END); $buf = fread($fp, $bs); if (!isset($buf[0])) { fclose($fp); echo "Empty!!\n"; return -1; } //echo $buf."\n"; if ($buf[0] == '@') { $bs += 512; $state = 'unknown'; continue; } if (($p = strrpos($buf, '@')) !== false) { if ($buf[$p - 1] == '@') { if ($p >= 6 && substr($buf, $p - 6, 4) == 'text') { // empty text case. \ntext\n@@ $state = 'text'; $buf = substr($buf, 0, $p - 2); } else { if ($p >= 5 && substr($buf, $p - 5, 3) == 'log') { // invalid case $state = 'unknown'; break; } else { if ($p >= 6 && substr($buf, $p - 6, 4) == 'desc') { return -3; break; } else { $buf = substr($buf, 0, $p - 2); $state = 'text'; } } } } else { if ($buf[$p - 1] != '@') { $buf = substr($buf, 0, $p - 1); $state = $state != 'text' ? 'text' : 'log'; } } //echo "===".$state."\n"; } if ($p === false or $state == 'unknown' or strlen($buf) < strlen($state)) { $bs += 512; //echo "inc block size\n"; $state = 'unknown'; continue; } while ($state == 'text' || $state == 'log') { if (strlen($buf) > strlen($state) and substr($buf, -strlen($state)) == $state) { if ($state == 'log') { break; } // broken delta cases, state == 'text' or 'log' if (($p = strrpos($buf, '@')) !== false) { $buf = substr($buf, 0, $p - 1); if ($state == 'text') { $state = 'log'; } else { break; } if ($state == 'log' and strlen($buf) < strlen($state)) { break; } } //echo "******".$buf."*******\n"; } while (($p = strrpos($buf, '@')) !== false) { if ($buf[$p - 1] == '@') { $buf = substr($buf, 0, $p - 2); } else { $buf = substr($buf, 0, $p - 1); if ($state != 'text') { break 2; } else { break; } } //echo "^^^***".$buf."*******\n"; } if ($p === false) { break; } } if ($state != 'text' and $state != 'log' or strlen($buf) < strlen($state)) { $bs += 512; $state = 'unknown'; continue; } if (strlen($buf) > 3 and substr($buf, -3) == 'log') { if (($p = strrpos($buf, '@')) !== false) { $last = substr($buf, $p + 1); $buf = substr($buf, 0, $p + 1); $buf .= "\n"; // OK $state = 'OK'; } } if ($state != 'OK' or $p == false) { $bs += 512; $state = 'unknown'; continue; } break; } echo "Done\n"; preg_match('/^(\\d.\\d+)$/m', $last, $match); $last = $match[1]; if (!$looks_ok) { echo "Broken revision is {$last}\n"; } else { echo "Last revision is {$last}\n"; } //echo "\tsearched position $pos, block size = $bs\n"; $tmpname = tempnam('.', 'RCS'); if (!$looks_ok) { fseek($fp, $pos - $bs, SEEK_END); $sz = ftell($fp); fseek($fp, 0, SEEK_SET); $fixed = fread($fp, $sz + strlen($buf)); file_put_contents($tmpname, $fixed); } else { fseek($fp, 0, SEEK_SET); $all = fread($fp, $filesize); file_put_contents($tmpname, $all); } fclose($fp); // fix revision info $fp = fopen($tmpname, 'r'); if (!is_resource($fp)) { echo "Can't open {$tmpname}\n"; return false; } $fixed = ''; $state = ''; // search empty string while (($line = fgets($fp, 1024)) !== false) { $fixed .= $line; $l = trim($line); if (preg_match('/^\\s*$/', $l)) { $state = 'found'; // empty string found break; } } if ($state != 'found') { // empty string not found! echo "empty string not found\n"; fclose($fp); return -2; } // search version string while (!feof($fp)) { $line = fgets($fp, 1024); // version string while (!preg_match('/^(\\d\\.\\d+)$/', $line, $match)) { if (preg_match('/^desc\\s$/', $line)) { break; } $fixed .= $line; $line = fgets($fp, 1024); } $tmp = explode('.', $match[1]); $next = $tmp[0] . '.' . ($tmp[1] - 1); $fixed .= $line; $line = fgets($fp, 1024); if (preg_match('@^date\\s+([^;]+);(.*)$@', $line, $m)) { $t = explode('.', $m[1]); $str = $t[0] . '/' . $t[1] . '/' . $t[2] . ' ' . $t[3] . ':' . $t[4] . ':' . $t[5]; $atime = strtotime($str); $remain = $m[2]; } $fixed .= $line; $fixed .= fgets($fp, 1024); $line = fgets($fp, 1024); if (preg_match('/^next\\s+(\\d\\.\\d+)?;/', $line, $match)) { // is it the last version string ? if (!empty($match[1]) && $match[1] === $last) { // include last revision info. if ($looks_ok) { //echo 'last ver',"\n"; $fixed .= $line; $fixed .= fgets($fp, 1024); // empty line while (($line = fgets($fp, 1024)) !== false) { if (preg_match('/^(\\d\\.\\d+)$/', $line, $match)) { $fixed .= $line; break; } $fixed .= $line; } $fixed .= fgets($fp, 1024); $fixed .= fgets($fp, 1024); $line = fgets($fp, 1024); } $line = "next\t;\n"; $fixed .= $line; $fixed .= fgets($fp, 1024); $state = 'fixed'; break; } else { if (!empty($match[1])) { $tmp = explode('.', $match[1]); $next = $tmp[0] . '.' . ($tmp[1] - 1); } else { echo "Broken RCS header. try to fill up\n"; if (empty($next)) { break; } while ($next !== $last) { $fixed .= "next\t{$next};\n\n{$next}\n"; $tmp = explode('.', $next); if ($tmp[1] == 1) { break; } $next = $tmp[0] . '.' . ($tmp[1] - 1); $atime -= 60 * 60 * 2; $fixed .= "date\t" . date("Y.m.d.H.i.s", $atime) . ';' . $remain . "\n"; $fixed .= "branches;\n"; } if ($next === $last) { $fixed .= "next\t{$next};\n\n{$next}\n"; $atime -= 60 * 60 * 2; $fixed .= "date\t" . date("Y.m.d.H.i.s", $atime) . ';' . $remain . "\n"; $fixed .= "branches;\n"; $fixed .= "next\t;\n"; $state = "fixed"; } break; } } } else { break; } $fixed .= $line; $fixed .= fgets($fp, 1024); } if ($state != 'fixed') { // the last version string not found echo "The last version not found\n"; fclose($fp); return -2; } // trash the last remaing version info while (!feof($fp)) { $line = fgets($fp, 1024); if (!preg_match('/^\\d\\.\\d+$/', $line)) { // broken case. simply ignore $fixed .= $line; break; } fgets($fp, 1024); fgets($fp, 1024); $line = fgets($fp, 1024); if (preg_match('/^next\\s;/', $line, $match)) { fgets($fp, 1024); break; } fgets($fp, 1024); } while (!feof($fp)) { $line = fgets($fp, 1024); if (preg_match("/^desc\n\$/", $line)) { $fixed .= $line; $line = fgets($fp, 8192); if ($line[0] == '@') { $fixed .= '@' . str_replace('@', '@@', $pagename) . "\n@\n"; if ($line[1] == '@' && $line[2] == "\n") { break; } // trash remaining desc info. while (!feof($fp)) { $line = fgets($fp, 8192); if ($line == "@\n") { break; } } } break; } $fixed .= $line; } // read the remaining version while (!feof($fp)) { $fixed .= fread($fp, 4096); } fclose($fp); echo "Fixed!!\n"; //file_put_contents('tmp,v', $fixed); file_put_contents($rcsfile, $fixed); touch($rcsfile, $mtime); unlink($tmpname); return 0; }
public function csvAction() { $this->load(); $this->render("none", null, true); header("Content-type: text/csv; charset=UTF-8"); header("Content-Disposition: attachment; filename=\"" . pagename() . ".csv\""); //output bom for utf-8 (so that excel will open this as UTF-8 file! UTF-8 should not need BOM but Excel doesn't know that.. echo chr(239) . chr(187) . chr(191); $xmlpath = $this->view->getScriptPath("") . pagename() . "/xml.phtml"; if (file_exists($xmlpath)) { $xml_content = $this->view->render(pagename() . "/xml.phtml"); require_once "app/xml2csv.php"; xml2csv($xml_content); } else { echo "No CSV content is available for this page."; } }
<a data-toggle="menu" href="#menu"> <img src="http://xcdn.cf/img/menu.svg"> </a> </li> </ul> <a class="header-logo" href="/"><?php sitename(); ?> </a> </div> </header> <div class="content"> <div class="content-heading"> <div class="container container-full"> <h1 class="heading"><?php pagename(); ?> </h1> </div> </div> <div class="content-inner"> <div class="container container-full"> <?php pagecontent(); ?> </div> </div> </div> <footer class="footer"> <div class="container container-full"> <p>© 2015 <?php
<!DOCTYPE html> <html> <head> <title> <?php if (!(include 'class/config.php')) { include '../class/config.php'; } echo $config['sitename']; echo pagename(); ?> </title> <meta charset="utf8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <link rel="icon" type="image/png" href="images/favico.png"> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="css/style.css"/> <script type="text/javascript" src="js/jquery-1.11.2.js"></script> <script type="text/javascript" src="js/tabs.js"></script> <script type="text/javascript" src="js/product.js"></script> </head> <body> <?php function pagename() { $full_name = $_SERVER['PHP_SELF']; $full_name = explode('/', $full_name); $full_name = $full_name[count($full_name) - 1]; $page_name = explode('.', $full_name); $page_name = $page_name[0];
$plugins[] = $plugin['name']; } } for ($n = count($active_plugins) - 1; $n >= 0; $n--) { $plugin = $active_plugins[$n]; if ($plugin['enabled_groups'] == '' && !isset($active_yaml[$n]["userpreferencegroup"])) { include_plugin_config($plugin['name'], $plugin['config'], $plugin['config_json']); } } } else { for ($n = count($plugins) - 1; $n >= 0; $n--) { include_plugin_config($plugins[$n]); } } # Include the appropriate language file $pagename = safe_file_name(str_replace(".php", "", pagename())); $language = setLanguage(); # Fix due to rename of US English language file if (isset($language) && $language == "us") { $language = "en-US"; } # Always include the english pack (in case items have not yet been translated) include dirname(__FILE__) . "/../languages/en.php"; if ($language != "en") { if (substr($language, 2, 1) == '-' && substr($language, 0, 2) != 'en') { @(include dirname(__FILE__) . "/../languages/" . safe_file_name(substr($language, 0, 2)) . ".php"); } @(include dirname(__FILE__) . "/../languages/" . safe_file_name($language) . ".php"); } # Register all plugins for ($n = 0; $n < count($plugins); $n++) {
public function kmlAction() { $this->load(); $filename = "osg_site_map.kml"; header("Content-type: application/vnd.google-earth.kml+xml; charset=utf8"); header("Content-Disposition: attachment; filename={$filename}"); //recreate the original non-xml url ?> <!-- This KML was generated with a query in following MyOSG page <?php echo fullbase() . "/" . pagename() . "/?" . $_SERVER["QUERY_STRING"]; ?> --><?php }