This file is indexed.

/usr/share/phamm/lib/phamm.php is in phamm 0.5.18-3.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?php
/*
* Phamm functions
*
* @package Phamm
*/

/*
* Phamm - http://www.phamm.org - <team@phamm.org>
* Copyright (C) 2004,2008 Alessandro De Zorzi and Mirko Grava
*
* This file is part of Phamm.
*  
* This program 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 of the License, or
* (at your option) any later version.
*
* This program 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/*
* @author Alessandro De Zorzi <adezorzi@rhx.it>
*
* @param string $date_format
* @return string
**/

function phamm_date($date_format)
{
    switch ($date_format)
    {
    case "test" :
            // YYYY-MM-DD
            return date(Ymd);
        break;

    default :
        // YYYY-MM-DD
        return date(Ymd);
        break;
    }
}

/**
* Set the PHP ERROR_LEVEL
* 
* @package Phamm
* @author Alessandro De Zorzi <adezorzi@rhx.it>
* 
* @constant int ERROR_LEVEL
* @return mixed
**/

function phamm_php_error_level ()
{
    // Set PHP error level one of 0,1,2,10
    if (ERROR_LEVEL == 0)
    {
        error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
    }

    elseif (ERROR_LEVEL == 1)
    {
        error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
    }

    elseif (ERROR_LEVEL == 2)
    {
        error_reporting(E_ALL & ~E_NOTICE);
    }

    if (ERROR_LEVEL == 10)
    {
        error_reporting(E_ALL);
    }
}

/**
* Write a log in to file
*
* TODO see:
* Log the operations in to file
* http://www.w3.org/Daemon/User/Config/Logging.html#common-logfile-format
*
* @package Phamm
* @author Alessandro De Zorzi <adezorzi@rhx.it>
*
* @param string $pn
* @param string $user
* @param string $operation
* @param bool $result
**/

function phamm_log ($pn,$user,$operation,$result)
{
    if (PHAMM_LOG == 1)
    {
	if (!$pn)
	    $pn = 'phamm';

	if ($result)
	    $resultLabel = 'OK';
	else
	    $resultLabel = 'FAILED';

	// Set the file in Append mode
	$logFile = fopen (LOG_FILE,'a');

	// Get time and date
	$day = date('Y'.'-'.'m'.'-'.'d');
	$hour = date ('H'.':'.'i'.':'.'s');
	$IP = $_SERVER["REMOTE_ADDR"];

	// Prepare the log string
	$log= "$IP - $user [$day $hour] \"$pn : $operation\" $resultLabel\n";

	// Write the log in to file
	fwrite ($logFile,"$log");

	// Close the file
	fclose ($logFile);
    }

    return true;
}

/**
* Set Phamm var
*
* @param string $name The variable name
* @param array $values Possible values
* @param string $methods @todo
* @param int $level
* @return mixed
**/

function phamm_set_var($name, $values=null, $methods=null, $level=0)
{
    if (isset($_GET[$name]))
    {
        if ($_GET[$name] == 'NONE')
            $_SESSION["phamm"][$name] = null;
        else
            $_SESSION["phamm"][$name] = $_GET[$name];
    }
    elseif (isset($_POST[$name]))
	$_SESSION["phamm"][$name] = $_POST[$name];

    // Prevent non wanted values
    if (is_array($values) && !in_array($_SESSION["phamm"]["$name"],$values))
        return null;

    if (isset($_SESSION["phamm"][$name]))
        return $_SESSION["phamm"][$name];

    return null;
}

function phamm_print_message ($class,$message,$newline=false)
{
    switch ($class) :
	
	case "error" :
	    $msg = _('Error: ').$message;
	break;
	
	case "warning" :
	    $msg = _('Warning: ').$message;
	break;
	
	default :
	    $msg = $message;
	break;

    endswitch;

    echo '<div class="'.$class.'">'.$msg.'</div>';

    if ($newline)
        echo '<br/>';
}

function phamm_print_xhtml ($tag)
{
    echo $tag;
}

/*
* Execute a command to multiple accounts/domains
*
* @param string $command The command
* @param array $values Lists of accounts/domains
*/

function group_actions ($command,$values)
{
    // Set initial return value
    $r = false;

    $ga = explode(';',$command);

    $mode = $ga[0];

    switch ($mode) :

    case "account" :

	foreach ($values as $key => $value)
        {
            // key contains mail
            $key1 = explode ('@',$key);

            // Create right DN
            $dn = 'mail='.$key.',vd='.$key1[1].','.LDAP_BASE;
	    
	    // Pre-load values
	    $self_values = self_values ($dn, $filter="(objectClass=*)");

            // (string) needed for TRUE and FALSE not real boolean...
            $entry[$ga[1]] = (string)$ga[2];
	    
	    $is_alias = (in_array('VirtualMailAlias',($self_values[0]["objectclass"])) ? true : false);
    
	    // Delete immediate if VirtualMailAlias
	    if (isset($entry["delete"]) && $is_alias)
		$r = phamm_ldap_delete($dn,$recursive=false);
	    // Change single value
	    else
		$r = phamm_modify ($dn,$entry);
        }

    break;

case "domain" :

    foreach ($values as $key => $value)
    {
        // Create right DN
        // $dn = 'cn=postmaster,vd='.$key.','.LDAP_BASE;
        $dn = 'vd='.$key.','.LDAP_BASE;

        // (string) needed for TRUE and FALSE not real boolean...
        $entry[$ga[1]]		= (string)$ga[2];

        // Change single value
        $r = phamm_modify ($dn,$entry);
    }

    break;

case "postmaster" :

    foreach ($values as $key => $value)
    {
        // Create right DN
        // $dn = 'cn=postmaster,vd='.$key.','.LDAP_BASE;
        $dn = 'cn=postmaster,vd='.$key.','.LDAP_BASE;

        // (string) needed for TRUE and FALSE not real boolean...
        $entry[$ga[1]]		= (string)$ga[2];

        // Change single value
        $r = phamm_modify ($dn,$entry);
    }

    break;

    endswitch;

    return $r;
}


?>