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

Annotation of /trunk/www/printable.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 133 - (hide annotations)
Wed Sep 22 14:44:59 2010 UTC (13 years, 6 months ago) by sng
File size: 9694 byte(s)
fixing news presentation in printable.php
fixing news.php

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    
31    
32 sng 132
33 sng 28
34 sng 133 // // Read the file into $file
35     // $file = file_get_contents ($thePage);
36 sng 130
37 sng 133
38    
39     if($pageUrlName == "news.php" ){
40     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n
41     <html>\n
42     <head>\n
43     <link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"http://clonezilla-sysresccd.hellug.gr/clonezilla-sysresccd.rss\">\n
44     <link rel=\"shortcut icon\" href=\"favicon.ico\">\n
45     <title>Clonezilla-SysRescCD - What's New</title>\n
46     <style type=\"text/css\">\n";
47    
48     $thePage = dirname($thePage) . "/clonezilla-sysresccd.rss";
49    
50     // Read the file into $file
51     $file = file_get_contents ($thePage);
52    
53     } else {
54    
55     // Read the file into $file
56     $file = file_get_contents ($thePage);
57    
58     // Get top navigation div
59     $eReg = "#<div id=\"docline-top\">.*#";
60     $numMatch = preg_match($eReg,$file,$matches);
61     if($numMatch > 0)
62     $topNav = $matches[0];
63     // echo $topNav;
64    
65     // Get bottom navigation div
66     $eReg = "#<div id=\"docline-bottom\">.*#";
67     $numMatch = preg_match($eReg,$file,$matches);
68     if($numMatch > 0)
69     $bottomNav = $matches[0];
70     // echo $bottomNav;
71    
72     // Remove text starting from line 1 to
73     // line containing <body> tag
74     $eReg="#<html.*</head>#is";
75     $file = preg_replace($eReg,"",$file);
76     $eReg = "#<!DOCTYPE HTML PUBLIC.*#i";
77     $file = preg_replace($eReg,"",$file);
78     $eReg = "#<body.*#i";
79     $file = preg_replace($eReg,"",$file);
80     }
81    
82 sng 28 ?>
83 sng 130 <style type="text/css">
84 sng 127 body { background : fixed no-repeat; background-color: White; }
85 sng 28 H1,H2,H3{color: #990000; text-align: left;}
86     H1{margin-top: 4em; margin-bottom: 2em;}
87     H2{margin-top: 2em;}
88     H3{margin-top: 1.5em}
89     li{margin-top: 1em;}
90     :link { color: #0000C0; text-decoration: none; }
91     :visited { color: #0000C0; text-decoration: none; }
92     a:hover { color: #0000C0; text-decoration: underline; }
93 sng 130 img { display: block; margin:0 auto; }
94 sng 28 /*p,td,table,tr,li{margin-left: 15pt;}*/
95     .nav{margin-left: 0pt;}
96     .newcode{font-family : "Courier New", Courier, monospace, sans-serif, serif; font-weight: bold; background-color: #F2F2F2; border: solid 1px #DEDEDE;padding: 20pt;}
97     .note{margin-top: 30pt; margin-bottom: 30pt; text-align: center; background-color: #FFEFEF; border: solid 1px; border-color: #FFD5D5;}
98     hr{color: Black; background-color: Black; height: 1px; border: none;}
99     #header {color: #990000; }
100 sng 130 .newcode{font-family : "Courier New", Courier, monospace; font-weight: bold; background-color: #F2F2F2; border: solid 1px #DEDEDE;padding: 20pt;}
101     .note{margin-top: 30pt; margin-bottom: 30pt; text-align: left; background-color: #FFEFEF; border: double 3px; border-color: #FFD5D5;}
102     .otherpage{border: solid 1px darkgoldenrod; padding: 20pt; background-color: lemonchiffon;}
103 sng 132 .docline-top {color: #990000 ; font-weight: bold; display:block;}
104     .docline-top a{color: #990000; font-weight: bold;}
105     .docline-bottom {color: #990000 ; font-weight: bold; display:block;}
106     .docline-bottom a{color: #990000; font-weight: bold;}
107    
108     @media print {
109     .docline-top {display: none;}
110     .docline-bottom {display: none;}
111     }
112 sng 28 </style>
113     <META NAME="Keywords" CONTENT="multiboot Multi Boot bootable cd rescue clonezilla sysresccd">
114     </head>
115 sng 130 <body style="margin: 40pt;">
116 sng 28 <?php
117    
118 sng 133 if($pageUrlName == "news.php" ){
119 sng 28
120 sng 133 $eReg = "#<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>.*</image>#is";
121     $file = preg_replace($eReg,"",$file);
122 sng 28
123    
124 sng 133 $eReg = "#<title>[^<]*<#";
125     $tReg = '<a name=\0"></a>\0';
126     $file = preg_replace($eReg,$tReg,$file);
127    
128     $file = str_replace('<">','">',$file);
129     $file = str_replace("<a name=<H2>","<a name=\"",$file);
130    
131     $file = str_replace("=<title>","=\"",$file);
132     $file = str_replace("<title>","<H2>",$file);
133     $file = str_replace("</title>"," <span class=\"hideprint\">[<a href=\"#news-top\" title=\"go to top of the page\">^</a>]</span></H2>",$file);
134    
135     $file = str_replace("<pubDate>","<p><b>Date: </b>",$file);
136     $file = str_replace("</pubDate>","<br><br>",$file);
137     $file = str_replace("<description><![CDATA[","",$file);
138     $file = str_replace("]]></description>","</p>",$file);
139     $file = str_replace("<item>","",$file);
140     $file = str_replace("</item>","",$file);
141     //$file = str_replace("<rss>","",$file);
142     $file = str_replace("</rss>","",$file);
143     //$file = str_replace("<channel>","",$file);
144     $file = str_replace("</channel>","",$file);
145    
146     $eReg = "#^" . ".*" . "<" . "/image" . ">#";
147     $file = preg_replace($eReg,"",$file);
148    
149    
150     $eReg = "#<" . "guid" . "[^<]*" . "<" . "/guid" . ">#";
151     $file = preg_replace($eReg,"",$file);
152    
153    
154     $eReg = "#<" . "link" . "[^<]*" . "<" . "/link" . ">#";
155 sng 28
156    
157 sng 133 // $file = preg_replace($eReg,"",$file);
158     // $indexFile = file_get_contents ("./index.html");
159     // $headerTokken = preg_match("#<div id=\"header\".*<div id=\"contarea\">#is", $indexFile , $matches);
160     // if( $headerTokken == 0 )
161     // echo "<big>Error: Cannot find header in <b>index.html</b>!!!</big>";
162     // else{
163     // $headerTokken = $matches[0];
164     // $headerTokken = preg_replace( "#<div id=\"lphp\".*#" , "" , $headerTokken );
165     // $headerTokken = preg_replace( "#<div id=\"linkline\">.*<div id=\"contarea\">#is" , "" , $headerTokken );
166     // $headerTokken = str_replace("position: absolute; left: 0px;","position: absolute; left: 40pt;",$headerTokken);
167     // $headerTokken = str_replace("position: absolute; right: 0px;","position: absolute; right: 40pt;",$headerTokken);
168     // $headerTokken = preg_replace( "#Well*come#" , "What's New" , $headerTokken );
169     // $headerTokken = preg_replace( "#</H2>.*<H3>#is" , "<br>" , $headerTokken );
170     // // $headerTokken = preg_replace( "#(.*)</div>$#is" , "$1<div></div style=\"margin-bottom: 300px;\"></div>" , $headerTokken );
171     // // $headerTokken = str_replace( " style=\"margin:0; padding: 3px; width: 980; position relative;\">" , ">" , $headerTokken );
172     // echo $headerTokken;
173     // }
174     // // $file = preg_replace( "#<body style=\"margin: 40pt;\">#" , "<body style=\"margin: 40pt;\">\n".$headerTokken , $file );
175     //
176 sng 28
177 sng 133 echo "<H2>Clonezilla-SysRescCD<br>What's New</H2>";
178 sng 28
179 sng 133 } else {
180    
181    
182     // Remove RSS
183     $eReg="#<div id=\"lphp\" style=.*</div>#";
184     $file=preg_replace($eReg,"",$file);
185    
186     // Remove link line
187     $eReg="#<div id=\"linkline\">.*<div id=\"contarea\">#is";
188     $file=preg_replace($eReg,"<!-- docline-top-->\n<div id=\"contarea\">",$file);
189    
190    
191     // Remove footer
192     $eReg = "#<div id=\"menu\">.*</div>#is";
193     $file = preg_replace($eReg,"",$file);
194     $eReg = "#<div id=\"footer\">.*</div>#is";
195     $file = preg_replace($eReg,"",$file);
196    
197     $eReg = "#</H2>[^<]*<H3>#";
198     $file = preg_replace($eReg,"<br>",$file);
199    
200     $eReg = "#<H2 style=\"margin-top: 0;\">#";
201     $file = preg_replace($eReg,"<H2 style=\"margin-top: 4em;\">",$file);
202    
203    
204     $file = str_replace("position: absolute; left: 0px;","position: absolute; left: 40pt;",$file);
205     $file = str_replace("position: absolute; right: 0px;","position: absolute; right: 40pt;",$file);
206    
207     $eReg = "#<H2>Clonezilla-SysRescCD<br>(.*)</H3>#i";
208     $file = preg_replace($eReg,"<H1>Clonezilla-SysRescCD<br>$1</H1>",$file);
209    
210    
211     // Place top navigation
212     if(! empty($topNav)){
213     $eReg = "#<div id=\"contarea\">#";
214     $file = preg_replace($eReg, $topNav."\n<div id=\"contarea\">", $file);
215     }
216     $file = preg_replace( "#id=\"docline-top\"#" , "align=\"center\" class=\"docline-top\"" , $file );
217    
218     // Place bottom navigation
219     if(! empty($bottomNav)){
220     $eReg = "#</body>#i";
221     $file = preg_replace($eReg, $bottomNav."\n</body>", $file);
222     }
223     $file = preg_replace( "#id=\"docline-bottom\"#" , "align=\"center\" class=\"docline-bottom\"" , $file );
224    
225     // Remove extra tags
226     $file = preg_replace( "#<div id=\"contarea\">#" , "" , $file );
227     $file = preg_replace( "#<div id=\"content\">#" , "" , $file );
228    
229     }
230 sng 28
231 sng 133
232     // Remove [^] links
233     $eReg="#\[<a href=[^>]*>\^</a>\]#i";
234 sng 130 $file = preg_replace($eReg,"",$file);
235 sng 132
236 sng 133 $eReg = "#<div id=.rss.>.*<!-- docline-top-->#i";
237     $file = preg_replace($eReg,"<!-- docline-top-->",$file);
238 sng 132
239 sng 133 $eReg = "{<div id=.lphp.*<H2>Clonezilla-SysRescCD</H2>}";
240     preg_replace($eReg,"<H2>Clonezilla-SysRescCD</H2>",$file);
241 sng 132
242    
243 sng 28
244 sng 132 $file = preg_replace( "#href=\"\"#i" , "href=\"printable.php?index.html\"" , $file );
245    
246     // Convert href="XXX.html#YYY" to href="printable.php?XXX.html#YYY"
247     $eReg = "@href=\"([^hf][^t][^t]?[^p][^s]?[^\"]*)\"@i";
248     //$eReg = "@href=\"([:alpha:]]\.html#?[^\"]*\")@i";
249     $file = preg_replace( $eReg, "href=\"printable.php?$1\"" , $file );
250    
251     // Convert href="#YYY" to href="printable.php?XXX.html#YYY"
252     // Because of previous conversion, the link is now:
253     // href="printable.php?#YYY"
254     $eReg = "@href=\"printable.php\?(#[^\"]*)\"@i";
255     $file = preg_replace( $eReg, "href=\"printable.php?".$pageUrlName."$1\"" , $file );
256 sng 28 echo $file;
257 sng 132
258 sng 130 // echo "</div>
259     // ";
260 sng 28
261 sng 133
262 sng 28 ?>
263     </body>
264     </html>

Properties

Name Value
svn:executable *

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26