rtoss - Diff between revs 45 and 358

Subversion Repositories:
Rev:
Show entire file - Ignore whitespace
Rev 45 Rev 358
Line 12... Line 12...
12  * # modify it under the same terms as Perl itself. 12  * # modify it under the same terms as Perl itself.
13  */ 13  */
14 14
15 /* Config section */ 15 /* Config section */
16 16
17 $thisurl_absolute = 'http://'.$_SERVER['HTTP_HOST'].preg_replace('/'.preg_replace('/.*\/+/','',$_SERVER['PHP_SELF']).'$/','',$_SERVER['PHP_SELF']); //Auto Setting -  
-   17 $thisurl_absolute = ''; //'http://'.$_SERVER['HTTP_HOST'].preg_replace('/'.preg_replace('/.*\/+/','',$_SERVER['PHP_SELF']).'$/','',$_SERVER['PHP_SELF']); //Auto Setting
18 $site_name = 'Tropy'; 18 $site_name = 'Tropy';
19 $dir_html = 'html'; # Directory for Cached HTML files. 19 $dir_html = 'html'; # Directory for Cached HTML files.
20 $dir_files = 'files'; # Directory for user-written text files and the index file. 20 $dir_files = 'files'; # Directory for user-written text files and the index file.
21 $file_index = "$dir_files/index.txt"; 21 $file_index = "$dir_files/index.txt";
22 $tropy_self = 'tropy.php'; 22 $tropy_self = 'tropy.php';
Line 113... Line 113...
113         global $maxrows,$maxcols,$tropy_self; 113         global $maxrows,$maxcols,$tropy_self;
114         $mymsg = htmlspecialchars($msg); 114         $mymsg = htmlspecialchars($msg);
115         echo <<<EOD 115         echo <<<EOD
116   <form action="$tropy_self" method="post"> 116   <form action="$tropy_self" method="post">
117         <input type="hidden" name="w$id" value="1"> 117         <input type="hidden" name="w$id" value="1">
118         <textarea cols="$maxcols" rows="$maxrows" name="mymsg">$mymsg</textarea><br><input type="submit" value="Write"> -  
-   118         <textarea cols="$maxcols" rows="$maxrows" name="mymsg" id="msg">$mymsg</textarea><br><input type="submit" value="Write">&emsp;&emsp;<button onclick='document.getElementById("preview").innerHTML="<p>"+document.getElementById("msg").value.replace(/\\n\\n/g,"</p><p>").replace(/\\n/g,"<br>")+"</p>";return false;'>Preview</button>
119   </form> 119   </form>
-   120   <div id="preview"></div>
120 EOD; 121 EOD;
121 } 122 }
122 123
123 function do_write($id) { 124 function do_write($id) {
124         global $form,$maxlength,$maxlines,$maxpages,$allid; 125         global $form,$maxlength,$maxlines,$maxpages,$allid;
Line 165... Line 166...
165         unlink_html($id); 166         unlink_html($id);
166 } 167 }
167 168
168 function print_jumpto($id) { 169 function print_jumpto($id) {
169         global $content_type,$time_jumpto_sec,$thisurl_absolute,$dir_html,$site_name; 170         global $content_type,$time_jumpto_sec,$thisurl_absolute,$dir_html,$site_name;
170         $meta = "<meta http-equiv='refresh' content='$time_jumpto_sec; url=${thisurl_absolute}${dir_html}/${id}.html'>\n"; -  
-   171         $meta = "<meta http-equiv='refresh' content='$time_jumpto_sec; url=${thisurl_absolute}${dir_html}/${id}.html?t=".time()."'>\n";
171         $navi = '<div id="navi"></div>'; 172         $navi = '<div id="navi"></div>';
172         header($content_type); 173         header($content_type);
173         header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1 174         header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
174         echo get_header("$site_name...", "", 'black', 'white', $navi, $meta); 175         echo get_header("$site_name...", "", 'black', 'white', $navi, $meta);
175         echo get_footer(); 176         echo get_footer();
Line 237... Line 238...
237         global $dir_html; 238         global $dir_html;
238         @unlink("$dir_html/$id.html"); 239         @unlink("$dir_html/$id.html");
239 } 240 }
240 241
241 function build_html($id) { 242 function build_html($id) {
242         global $dir_html,$allow_html,$site_name,$allow_edit,$auto_link; -  
-   243         global $dir_html,$allow_html,$site_name,$allow_edit,$auto_link,$return_url;
243         list($color, $bgcolor) = get_style($id); 244         list($color, $bgcolor) = get_style($id);
244         $navi = get_navi($id, $allow_edit); 245         $navi = get_navi($id, $allow_edit);
245 246
246         # Check. 247         # Check.
247         if (file_exists("$dir_html/$id.html")) { 248         if (file_exists("$dir_html/$id.html")) {
Line 255... Line 256...
255         $content = implode('',$fil); 256         $content = implode('',$fil);
256         257        
257         if (!$allow_html) { 258         if (!$allow_html) {
258                 $content = htmlspecialchars($content); 259                 $content = htmlspecialchars($content);
259 260
260                 if (strpos(strtolower($content),'=nbsp\n') !== -1) { -  
-   261                 if (strpos(strtolower($content),'=nbsp\n') > -1) {
261                         $content = preg_replace('/=nbsp\n/i','',$content); 262                         $content = preg_replace('/=nbsp\n/i','',$content);
262                         $content = str_replace(' ','&nbsp;',$content); -  
-   263                         $content = str_replace(' ',chr(0xc2).chr(0xa0),$content); // C2 A0 = nbsp in UTF-8
263                 } 264                 }
264                 $content = preg_replace("/=pre\n?/i",'<pre>',$content); 265                 $content = preg_replace("/=pre\n?/i",'<pre>',$content);
265                 $content = preg_replace('/=\/pre\n?/i','</pre>',$content); 266                 $content = preg_replace('/=\/pre\n?/i','</pre>',$content);
266                 267                
267                 $content = preg_replace('/(\n\n+)/',"\n\n",$content); 268                 $content = preg_replace('/(\n\n+)/',"\n\n",$content);
Line 272... Line 273...
272 273
273         # Write. 274         # Write.
274         if (!$wfil=fopen("$dir_html/$id.html","wb")) { 275         if (!$wfil=fopen("$dir_html/$id.html","wb")) {
275                 print_error("build to $id"); 276                 print_error("build to $id");
276         } 277         }
277         fwrite($wfil,get_header("$caption - $site_name", $caption, $color, $bgcolor, $navi, "")); -  
-   278         fwrite($wfil,get_header("$caption - $site_name", $caption, $color, $bgcolor, $navi, "<base href=\"$return_url\">"));
278         fwrite($wfil,"<p>$content</p>"); 279         fwrite($wfil,"<p>$content</p>");
279         fwrite($wfil,get_footer()); 280         fwrite($wfil,get_footer());
280         fclose($wfil); 281         fclose($wfil);
281 } 282 }
282 283
Line 296... Line 297...
296         echo "<p>$content</p>"; 297         echo "<p>$content</p>";
297         echo get_footer(); 298         echo get_footer();
298 } 299 }
299 300
300 function get_header($title, $caption, $color, $bgcolor, $navi, $meta) { 301 function get_header($title, $caption, $color, $bgcolor, $navi, $meta) {
301         global $time_visible_msec,$thisurl_absolute; -  
-   302         global $time_visible_msec;
302         return <<<EOD 303         return <<<EOD
303 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 304 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
304    "http://www.w3.org/TR/html4/loose.dtd"> 305    "http://www.w3.org/TR/html4/loose.dtd">
305 <html lang="ja"> 306 <html lang="ja">
306 <head> 307 <head>
307 <meta http-equiv="content-type" content="text/html; charset=utf-8"> 308 <meta http-equiv="content-type" content="text/html; charset=utf-8">
308 <meta http-equiv="content-style-type" content="text/css"> 309 <meta http-equiv="content-style-type" content="text/css">
309 $meta<base href="$thisurl_absolute"> -  
-   310 $meta
310 <style type="text/css"><!-- 311 <style type="text/css"><!--
311 body{font-family:Verdana,sans-serif;margin:2% 20% 10% 20%;color:$color;background-color:$bgcolor;} 312 body{font-family:Verdana,sans-serif;margin:2% 20% 10% 20%;color:$color;background-color:$bgcolor;}
312 input{font-family:Verdana,sans-serif;} 313 input{font-family:Verdana,sans-serif;}
313 #navi{text-align:right;} 314 #navi{text-align:right;}
314 p{line-height:150%;} 315 p{line-height:150%;}
Line 479... Line 480...
479         } 480         }
480         fwrite($idx,implode("\n", $index)."\n"); 481         fwrite($idx,implode("\n", $index)."\n");
481         fclose($idx); 482         fclose($idx);
482 } 483 }
483 484
484 ?> -  
-   485 ?>