File: preview.php

package info (click to toggle)
achims-guestbook 2.52-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 956 kB
  • ctags: 714
  • sloc: php: 4,821; sh: 56; makefile: 38
file content (111 lines) | stat: -rw-r--r-- 4,362 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/*
 preview.php - preview modul

 Copyright (C) 2001 Achim Winkler <achim@lkcc.org>

 This is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 This software is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this package; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  
*/

class CPreview extends CTools {

	function CPreview($emotion = "no") {
		$this->CTools($emotion);
	}
	
	
	function Show_Preview(&$newname, &$newmail, &$newicq, &$newaim, &$newyim, &$newmsn, &$newloc, &$newurl, &$newtext) {
		header ("Expires: Mon, 08 Jan 1990 01:00:00 GMT");
		header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
    header ("Cache-Control: no-cache, must-revalidate");
    header ("Pragma: no-cache");
		
		if ($this->dateformat > 0) {
			$newdate = strftime("%m.%d.%Y %H:%M", time() + ($this->fixedtime * 3600));
		} else {
			$newdate = strftime("%d.%m.%Y %H:%M", time() + ($this->fixedtime * 3600));
		}
		
		#delete old temp files
		$handle = opendir("temp"); 
		while ($file = readdir ($handle)) { 
	    	if (preg_match("/temp(\d+).dat/", $file, $number)) {
	    		$time = filemtime("temp/".$file);
	    		if (($time + 3600) < time())
	    			unlink("temp/".$file); 
	       	}	    		  		
	    }
		closedir($handle);
				
		#tempfile for the preview data
		mt_srand((double)microtime() * 1000000);
		$random = mt_rand(0, 1000);
		while (file_exists("temp/temp".$random.".dat")) {
			$random = mt_rand(0, 1000);		
		}
		
		$output = fopen("temp/temp".$random.".dat", "w") or die ("Can't create temp".$random.".dat!");
		
		$newtext = str_replace("\r\n", "[BR]", $newtext);
		fputs($output, $newname."\r\n");
		fputs($output, $newmail."\r\n");
		fputs($output, $newicq."\r\n");
		fputs($output, $newaim."\r\n");
		fputs($output, $newyim."\r\n");
		fputs($output, $newmsn."\r\n");
		fputs($output, $newloc."\r\n");
		fputs($output, $newurl."\r\n");
		fputs($output, $newtext."\r\n");
		
		fclose($output);
		
		$this->newname = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newname)));
		$this->newmail = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newmail)));
		$this->newicq = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newicq)));
		$this->newaim = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newaim)));
		$this->newyim = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newyim)));
		$this->newmsn = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newmsn)));
		$this->newloc = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newloc)));
		$this->newurl = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newurl)));
		$this->newtext = str_replace("&", "&amp;amp;", str_replace("\"", "&#34;", stripslashes($newtext)));
		$this->newtext = eregi_replace("\[BR\]", "\r\n", $this->newtext);
		$this->Check_Empty();
		
		$this->Format_String($newname, "name");
		$this->Format_String($newmail, "mail");
		$this->Format_String($newicq, "icq");
		$this->Format_String($newaim, "aim");
		$this->Format_String($newyim, "yim");
		$this->Format_String($newmsn, "msn");
		$this->Format_String($newloc, "loc");
		$this->Format_String($newurl, "url");
		$this->Format_String($newtext, "text");
		$newname = stripslashes($newname);
		$newmail = stripslashes($newmail);
		$newicq = stripslashes($newicq);
		$newaim = stripslashes($newaim);
		$newyim = stripslashes($newyim);
		$newmsn = stripslashes($newmsn);
		$newloc = stripslashes($newloc);
		$newurl = stripslashes($newurl);
		$newtext = stripslashes($newtext);
		
		#show preview
		if (!file_exists("preview.html.inc")) die ("Can't open preview.html.inc!");
		include("preview.html.inc");
	}

}