Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezgpg.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezgpg.php,v 1.3 2001/04/09 14:37:39 chrism Exp $
5 //
6 // Definition of eZGPG class
7 //
8 // Chris Mason <chris@net.ai>
9 // Created on: <09-Apr-2001 16:36:08 bf>
10 // Updated 6/24/2001 to improve command and remove
11 // the need to write a file
12 //
13 // This source file is part of Exponential Basic, publishing software.
14 // Copyright (C) 1999-2001 eZ systems as
15 //
16 // This program is free software; you can redistribute it and/or
17 // modify it under the terms of the GNU General Public License
18 // as published by the Free Software Foundation; either version 2
19 // of the License, or (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program; if not, write to the Free Software
28 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
29 //
30
33
38 class eZGPG
39 {
44 function __construct( $plaintxt, $keyname, $wwwuser)
45 {
46
47 putenv($home);
48 $boundary = md5( uniqid( time() ) );
49
50 $this->keyname=$keyname;
51 if ( sizeof( $this->keyname ) == 0 )
52 echo "WARNING: No Keys Specified";
53
54 $this->pcmd = "echo '$plaintxt' | ";
55 $this->pcmd .= $this->pathtogpg.$this->encryptcommand;
56 $this->pcmd.= " -a -q --always-trust --no-tty -e --homedir '" . $this->gnuhome . "' -u $wwwuser -r $keyname";
57 $this->pcmd.= " -o/var/www/" . $boundary;
58
59 system( $this->pcmd );
60
61 print( $this->pcmd );
62 exit();
63 // $pp = popen( $this->pcmd, "w" );
64 // fwrite( $pp, $this->body );
65 // pclose( $pp );
66
67
68 $fp = eZPBFile::fopen( "/var/www/" . $boundary, r );
69 $this->body = fread( $fp, eZPBFile::filesize( "/var/www/" . $boundary ) );
70 fclose( $fp );
71
72 eZPBFile::unlink( "/var/www/" . $boundary );
73 }
74
79 function __constructStock( $plaintxt, $keyname, $wwwuser)
80 {
81 $this->keyname=$keyname;
82 if ( sizeof( $this->keyname ) == 0 )
83 $this->body = "WARNING: No Keys Specified";
84
85 $this->messagetext = escapeshellarg( $plaintxt );
86
87 $this->pcmd = "echo '" . $this->messagetext . "' | ";
88 $this->pcmd .= $this->pathtogpg.$this->encryptcommand;
89 $this->pcmd.= " -u ". $wwwuser . " --homedir '" . $this->home ."' -r '". $this->keyname . "' ";
90
91 //clear return array and execute encrypt command
92 unset( $ret );
93 exec($this->pcmd, $ret);
94
95 print( "<pre>" );
96 print_r( $ret);
97 print( "</pre><br />" );
98
99
100
101 //loop return array for encrypted text
102 foreach( $ret as $key=>$value )
103 {
104 $this->body .= $value;
105 $this->body .="\n";
106 }
107
108 }
109
110 function getbody()
111 {
112 return $this->body;
113 }
114
115 var $messagetext;
116 var $body;
117 var $keyname = array();
118 var $ret = array();
119 var $pathtogpg = "/usr/bin/";
120 var $pp;
121 var $fp;
122 var $pcmd;
123 var $encryptcommand = "gpg --encrypt --batch --no-secmem-warning -a -q --no-tty";
124 var $signcommand = "gpg --sign --batch";
125 //var $home = "/var/www/.gnupg";
126 var $home="HOME=/var/www/";
127 var $gnuhome="/var/www/.gnupg";
128 }
129
130 ?>
eZGPG
Definition: ezgpg.php:39
eZGPG\$pp
$pp
Definition: ezgpg.php:120
eZGPG\$home
$home
Definition: ezgpg.php:126
eZGPG\$pathtogpg
$pathtogpg
Definition: ezgpg.php:119
eZGPG\$messagetext
$messagetext
Definition: ezgpg.php:115
eZGPG\__construct
__construct( $plaintxt, $keyname, $wwwuser)
Definition: ezgpg.php:44
eZGPG\$fp
$fp
Definition: ezgpg.php:121
eZGPG\$gnuhome
$gnuhome
Definition: ezgpg.php:127
eZGPG\$encryptcommand
$encryptcommand
Definition: ezgpg.php:123
eZGPG\$pcmd
$pcmd
Definition: ezgpg.php:122
eZGPG\$body
$body
Definition: ezgpg.php:116
eZGPG\getbody
getbody()
Definition: ezgpg.php:110
eZGPG\$keyname
$keyname
Definition: ezgpg.php:117
eZGPG\__constructStock
__constructStock( $plaintxt, $keyname, $wwwuser)
Definition: ezgpg.php:79
eZGPG\$ret
$ret
Definition: ezgpg.php:118
eZGPG\$signcommand
$signcommand
Definition: ezgpg.php:124
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZPBFile\unlink
static unlink( $filename)
Definition: ezpbfile.php:352
eZPBFile\filesize
static filesize( $filename)
Definition: ezpbfile.php:339
exit
exit
Definition: folder.php:81
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.