/[clonezilla-sysresccd]/trunk/www/working/printable.php
ViewVC logotype

Annotation of /trunk/www/working/printable.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 132 - (hide annotations)
Tue Sep 21 13:14:15 2010 UTC (11 years ago) by sng
File size: 6077 byte(s)
updating printable.php
  - added navigation links for documentation pages
  - made the navigation links invissible when printing

1 sng 28 <?php
2     error_reporting(E_ALL);
3 sng 130 // error_reporting(E_ERROR);
4 sng 28 ini_set('display_errors', '1');
5    
6 sng 131 $curPage = basename( $_SERVER["REQUEST_URI"] );
7     // echo "pageURL = $curPage<br><br><br>";
8     if (substr($curPage,0,14) == "printable.php?" ) {
9     //
10     // This means we have a printable.php?xxx.html URL
11     // let's get the xxx.html part
12     //
13     $pageUrlName = substr( $curPage,14,strlen($curPage) );
14     // echo "pageUrlName = $pageUrlName<br><br><br>";
15     } else {
16     //
17     // trunk or demo are the local folders used to develop
18     // this file at my own private apache server
19     //
20     $pageUrlName=basename ($_SERVER['HTTP_REFERER']);
21     if ( $pageUrlName == 'clonezilla-sysresccd.hellug.gr' OR $pageUrlName == "localhost" OR $pageUrlName == "demo" OR $pageUrlName == "trunk" ) $pageUrlName='index.html';
22     $eReg="{#.*}";
23     $onlyURL=preg_replace($eReg,"",$pageUrlName);
24     // echo "pageUrlName = $pageUrlName<br><br><br>";
25     $thePage = getcwd() . '/' . basename ($_SERVER['HTTP_REFERER']);
26     }
27 sng 130 $thePage = getcwd() . '/' . $pageUrlName;
28     // echo "thePage = $thePage<br><br><br>";
29 sng 28
30 sng 130 // Read the file into $file
31 sng 28 $file = file_get_contents ($thePage);
32    
33 sng 132 // Get top navigation div
34     $eReg = "#<div id=\"docline-top\">.*#";
35     $numMatch = preg_match($eReg,$file,$matches);
36     if($numMatch > 0)
37     $topNav = $matches[0];
38     // echo $topNav;
39 sng 28
40 sng 132 // Get bottom navigation div
41     $eReg = "#<div id=\"docline-bottom\">.*#";
42     $numMatch = preg_match($eReg,$file,$matches);
43     if($numMatch > 0)
44     $bottomNav = $matches[0];
45     // echo $bottomNav;
46    
47 sng 130 // Remove text starting from line 1 to
48     // line containing <body> tag
49     $eReg="#<html.*</head>#is";
50     $file = preg_replace($eReg,"",$file);
51     $eReg = "#<!DOCTYPE HTML PUBLIC.*#i";
52     $file = preg_replace($eReg,"",$file);
53     $eReg = "#<body.*#i";
54     $file = preg_replace($eReg,"",$file);
55 sng 28
56 sng 130
57 sng 28 ?>
58 sng 130 <style type="text/css">
59 sng 126 body { background : fixed no-repeat; background-color: White; }
60 sng 28 H1,H2,H3{color: #990000; text-align: left;}
61     H1{margin-top: 4em; margin-bottom: 2em;}
62     H2{margin-top: 2em;}
63     H3{margin-top: 1.5em}
64     li{margin-top: 1em;}
65     :link { color: #0000C0; text-decoration: none; }
66     :visited { color: #0000C0; text-decoration: none; }
67     a:hover { color: #0000C0; text-decoration: underline; }
68 sng 130 img { display: block; margin:0 auto; }
69 sng 28 /*p,td,table,tr,li{margin-left: 15pt;}*/
70     .nav{margin-left: 0pt;}
71     .newcode{font-family : "Courier New", Courier, monospace, sans-serif, serif; font-weight: bold; background-color: #F2F2F2; border: solid 1px #DEDEDE;padding: 20pt;}
72     .note{margin-top: 30pt; margin-bottom: 30pt; text-align: center; background-color: #FFEFEF; border: solid 1px; border-color: #FFD5D5;}
73     hr{color: Black; background-color: Black; height: 1px; border: none;}
74     #header {color: #990000; }
75 sng 130 .newcode{font-family : "Courier New", Courier, monospace; font-weight: bold; background-color: #F2F2F2; border: solid 1px #DEDEDE;padding: 20pt;}
76     .note{margin-top: 30pt; margin-bottom: 30pt; text-align: left; background-color: #FFEFEF; border: double 3px; border-color: #FFD5D5;}
77     .otherpage{border: solid 1px darkgoldenrod; padding: 20pt; background-color: lemonchiffon;}
78 sng 132 .docline-top {color: #990000 ; font-weight: bold; display:block;}
79     .docline-top a{color: #990000; font-weight: bold;}
80     .docline-bottom {color: #990000 ; font-weight: bold; display:block;}
81     .docline-bottom a{color: #990000; font-weight: bold;}
82    
83     @media print {
84     .docline-top {display: none;}
85     .docline-bottom {display: none;}
86     }
87 sng 28 </style>
88     <META NAME="Keywords" CONTENT="multiboot Multi Boot bootable cd rescue clonezilla sysresccd">
89     </head>
90 sng 130 <body style="margin: 40pt;">
91 sng 28 <?php
92    
93    
94 sng 132 // Remove [^] links
95 sng 130 $eReg="#\[<a href=[^>]*>\^</a>\]#i";
96     $file = preg_replace($eReg,"",$file);
97 sng 28
98 sng 130 $eReg = "#<div id=.rss.>.*<!-- docline-top-->#i";
99     $file = preg_replace($eReg,"<!-- docline-top-->",$file);
100 sng 28
101 sng 130 $eReg = "{<div id=.lphp.*<H2>Clonezilla-SysRescCD</H2>}";
102     preg_replace($eReg,"<H2>Clonezilla-SysRescCD</H2>",$file);
103 sng 28
104    
105 sng 130 // Remove RSS
106     $eReg="#<div id=\"lphp\" style=.*</div>#";
107     $file=preg_replace($eReg,"",$file);
108 sng 28
109 sng 130 // Remove link line
110     $eReg="#<div id=\"linkline\">.*<div id=\"contarea\">#is";
111     $file=preg_replace($eReg,"<!-- docline-top-->\n<div id=\"contarea\">",$file);
112 sng 28
113    
114 sng 130 // Remove footer
115     $eReg = "#<div id=\"menu\">.*</div>#is";
116     $file = preg_replace($eReg,"",$file);
117     $eReg = "#<div id=\"footer\">.*</div>#is";
118     $file = preg_replace($eReg,"",$file);
119 sng 132
120 sng 130 $eReg = "#</H2>[^<]*<H3>#";
121     $file = preg_replace($eReg,"<br>",$file);
122 sng 132
123 sng 130 $eReg = "#<H2 style=\"margin-top: 0;\">#";
124     $file = preg_replace($eReg,"<H2 style=\"margin-top: 4em;\">",$file);
125 sng 132
126    
127 sng 28 $file = str_replace("position: absolute; left: 0px;","position: absolute; left: 40pt;",$file);
128     $file = str_replace("position: absolute; right: 0px;","position: absolute; right: 40pt;",$file);
129    
130 sng 130 $eReg = "#<H2>Clonezilla-SysRescCD<br>(.*)</H3>#i";
131     $file = preg_replace($eReg,"<H1>Clonezilla-SysRescCD<br>$1</H1>",$file);
132 sng 28
133 sng 132
134     // Place top navigation
135     if(! empty($topNav)){
136     $eReg = "#<div id=\"contarea\">#";
137     $file = preg_replace($eReg, $topNav."\n<div id=\"contarea\">", $file);
138     }
139     $file = preg_replace( "#id=\"docline-top\"#" , "align=\"center\" class=\"docline-top\"" , $file );
140    
141     // Place bottom navigation
142     if(! empty($bottomNav)){
143     $eReg = "#</body>#i";
144     $file = preg_replace($eReg, $bottomNav."\n</body>", $file);
145     }
146     $file = preg_replace( "#id=\"docline-bottom\"#" , "align=\"center\" class=\"docline-bottom\"" , $file );
147    
148     // Remove extra tags
149     $file = preg_replace( "#<div id=\"contarea\">#" , "" , $file );
150     $file = preg_replace( "#<div id=\"content\">#" , "" , $file );
151    
152    
153     $file = preg_replace( "#href=\"\"#i" , "href=\"printable.php?index.html\"" , $file );
154    
155     // Convert href="XXX.html#YYY" to href="printable.php?XXX.html#YYY"
156     $eReg = "@href=\"([^hf][^t][^t]?[^p][^s]?[^\"]*)\"@i";
157     //$eReg = "@href=\"([:alpha:]]\.html#?[^\"]*\")@i";
158     $file = preg_replace( $eReg, "href=\"printable.php?$1\"" , $file );
159    
160     // Convert href="#YYY" to href="printable.php?XXX.html#YYY"
161     // Because of previous conversion, the link is now:
162     // href="printable.php?#YYY"
163     $eReg = "@href=\"printable.php\?(#[^\"]*)\"@i";
164     $file = preg_replace( $eReg, "href=\"printable.php?".$pageUrlName."$1\"" , $file );
165    
166 sng 28 echo $file;
167 sng 132
168 sng 130 // echo "</div>
169     // ";
170 sng 28
171     ?>
172     </body>
173     </html>

Properties

Name Value
svn:executable *

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26