/usr/share/gosa/plugins/admin/fai/class_debconfTemplate.inc is in gosa-plugin-fai 2.7.4+reloaded1-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 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | <?php
class debconf
{
var $package= "";
var $language= "";
var $loaded_template= FALSE;
var $template= array();
function debconf($language= "")
{
$this->set_language($language);
}
function set_language($language)
{
$this->language= $language;
}
function load_from_string($str)
{
$lines = explode("\n",$str);
$this->template = array();
$post_name = 0;
$langcode = $this->language.".UTF-8";
$in_description = FALSE;
$got_local_description = FALSE;
foreach($lines as $line){
/* Reset description flag */
if ($in_description && !preg_match("/^ /", $line)){
$in_description= FALSE;
}
/* Template header */
if (preg_match("/^Template: /", $line)){
$post_name ++;
$name= trim(preg_replace("/^Template: (.*)$/", "\\1", $line));
$this->template[$post_name]['Name'] = $name;
$this->template[$post_name]['Default'] ="";
$got_local_description= FALSE;
continue;
}
/* Get type */
if (preg_match("/^Type: /", $line)){
$type= trim(preg_replace("/^Type: (.*)$/", "\\1", $line));
$this->template[$post_name]['Type']= $type;
continue;
}
/* Get default */
if (preg_match("/^Default: /", $line)){
$this->template[$post_name]['Default']= "";
$default= trim(preg_replace("/^Default: (.*)$/", "\\1", $line));
$this->template[$post_name]['Default']= $default;
continue;
}
/* Get description */
if (!$got_local_description && preg_match("/^Description: /i", $line)){
$description= trim(preg_replace("/^Description: (.*)$/i", "\\1", $line));
$this->template[$post_name]['Topic']= $description;
$this->template[$post_name]['Description']= "";
$in_description= TRUE;
continue;
}
/* Fill description */
if (!$got_local_description && $in_description){
$description= preg_replace("/^ (.*)$/", "\\1", $line);
$this->template[$post_name]['Description'].= $description;
continue;
}
/* Get local description */
if (preg_match("/^Description-$langcode: /i", $line)){
$description= trim(preg_replace("/^Description-$langcode: (.*)$/i", "\\1", $line));
$this->template[$post_name]['Topic']= $description;
$in_description= TRUE;
$got_local_description= TRUE;
$this->template[$post_name]['Description']= "";
continue;
}
/* Fill local description */
if ($got_local_description && $in_description){
$description= preg_replace("/^ (.*)$/", "\\1", $line);
$this->template[$post_name]['Description'].= $description;
continue;
}
/* Get native choices */
if (preg_match("/^Choices: /", $line)){
$type= trim(preg_replace("/^Choices: (.*)$/", "\\1", $line));
$this->template[$post_name]['Choices']= $type;
}
/* Get local choices */
if (preg_match("/^Choices-$langcode: /", $line)){
$type= trim(preg_replace("/^Choices-$langcode: (.*)$/", "\\1", $line));
$this->template[$post_name]['Choices-local']= $type;
}
}
$this->loaded_template= TRUE;
$tmp= array();
foreach($this->template as $post_name => $template){
$template['post_name'] = "post_".$post_name;
$tmp[] = $template;
}
$this->template = $tmp;
return (TRUE);
}
function has_template()
{
return(count($this->template) != FALSE);
}
/* Check if some fields are posted */
function PostCheck()
{
/* Walk through all template variables */
foreach($this->template as $post_name => $entry){
/* Check if this var is set*/
if(isset($_POST[$entry['post_name']])){
/* special handling for arrays */
if(is_array($_POST[$entry['post_name']])){
$str = "";
foreach($_POST[$entry['post_name']] as $val){
$str.= $val.", ";
}
$str = preg_replace("/\,\ $/","",$str);
$this->template[$post_name]['Default'] = $str;
}else{
$this->template[$post_name]['Default'] = get_post($entry['post_name']);
}
}
}
foreach($this->template as $post_name => $entry){
if(isset($_POST["multi-".$entry['post_name']])){
$this->template[$post_name]['Default']= "";
foreach($_POST as $name => $value){
if(preg_match("/".$entry['post_name']."-multi-/",$name)){
$this->template[$post_name]['Default'] .= $value.", ";
}
}
$this->template[$post_name]['Default'] = preg_replace("/, $/","",$this->template[$post_name]['Default']);
}
}
}
/* This funtion sets the defualt value */
function SetDefault($var,$val)
{
if ($this->loaded_template) {
foreach($this->template as $key => $tmp){
if($tmp['Name'] == $var ){
$this->template[$key]['Default'] = $val;
}
}
}
}
/* Display all possible options in html*/
function get_dialog()
{
if ($this->loaded_template && count($this->template)) {
$result= "<table summary=''>";
foreach ($this->template as $post_name => $entry){
$types= array("boolean" => "", "multiselect" => "", "note" => "",
"password" => "", "select" => "", "string" => "", "text" => "", "title" => "");
/* Check if type is available */
if ((isset($entry['Type']))&&(isset($types[$entry['Type']]))){
/* Produce type specific output */
$fn= "render_".$entry['Type'];
$str = $this->$fn($entry);
if(!empty($str)){
$result.=$str."<tr><td colspan='2'><hr></td></tr>";
}
} else {
//php_error(E_WARNING, "An unknown type has been specified in the debconf template. Please fix.");
}
}
$result.="</table>";
$result .= "<input type='hidden' post_name='check_post' value='1'>";
return ($result);
} else {
return _("This package has no debconf options.");
}
}
function render_boolean($data)
{
$post_name= $data['post_name'];
$result="
<tr>
<td valign='top' style='width:100%'>
<h3>".$data['Topic']."</h3>".$data['Description']."
</td>
<td style=\"white-space:nowrap; vertical-align:top; border-left: 1px solid rgb(160, 160, 160);\">";
foreach(array("true","false") as $value){
if($data['Default'] == $value){
$result.="<input type='radio' name='".$data['post_name']."' value='".$value."' checked>"._($value);
}else{
$result.="<input type='radio' name='".$data['post_name']."' value='".$value."' >"._($value);
}
$result.="<br>";
}
$result.= "
</td>
</tr>
";
return ($result);
}
function render_multiselect($data)
{
$post_name= $data['post_name'];
if (preg_match('/\$\{/', $data['Choices'])){
$data['Description'].= '<br><br><b>'._('This debconf question is dynamically generated during package installation and requires choosing between specific options which cannot be presented here. The entered text needs to be one of the valid choices in order to take effect.').'</b>';
$result= $this->render_string($data);
} else {
$choices= "";
foreach (explode(", ", $data['Choices']) as $choice){
$choices[]= $choice;
}
$result="
<tr>
<td valign='top'>
<h3>".$data['Topic']."</h3>".$data['Description']."
</td>
<td valign='top' style=\"white-space:nowrap; border-left: 1px solid rgb(160, 160, 160);\">
<input type='hidden' name='multi-".$post_name."' value='1'>
";
$defs = explode(", ",$data['Default']);
foreach($choices as $value){
if(in_array_strict($value,$defs)){
$result.="\n<input name='".$post_name."-multi-".$value."' type='checkbox' value='".set_post($value)."' checked>".$value."<br>";
}else{
$result.="\n<input name='".$post_name."-multi-".$value."' type='checkbox' value='".set_post($value)."'>".$value."<br>";
}
}
$result .= "</td>
</tr>
";
}
return ($result);
}
function render_note($data)
{
/* Ignore notes, they do not makes sense, since we don't get any
chance to test entered values... */
return ("");
}
function render_password($data)
{
$result= "";
$result.= "<tr><td valign='top'>";
$result.= "<h3>".$data['Topic']."</h3>".$data['Description']."</td><td style=\"white-space:nowrap; border-left: 1px solid rgb(160, 160, 160);\"> <input type='text' name='".$data['post_name']."' value='".$data['Default']."'></b><br><br>";
$result.= $data['Description'];
$result.= "</td>";
return ($result);
}
function render_select($data)
{
$post_name= $data['post_name'];
if (preg_match('/\$\{/', $data['Choices'])){
$result = $this->render_multiselect($data);
} else {
$choices= "";
foreach (explode(", ", $data['Choices']) as $choice){
$choices[]= $choice;
}
$result="
<tr>
<td valign='top'>
<h3>".$data['Topic']."</h3>".$data['Description']."
</td>
<td valign='top' style=\"white-space:nowrap; border-left: 1px solid rgb(160, 160, 160);\">
";
foreach($choices as $value){
if($data['Default'] == $value){
$result.="\n<input type='radio' name='".$post_name."' value='".set_post($value)."' checked >".set_post($value)."<br>";
}else{
$result.="\n<input type='radio' name='".$post_name."' value='".set_post($value)."'>".set_post($value)."<br>";
}
}
$result.= "
</td>
</tr>
";
}
return ($result);
}
function render_string($data)
{
$result= "
<tr>
<td valign='top'>
<h3>".$data['Topic']."</h3>".$data['Description']."
</td>
<td style=\"white-space:nowrap; border-left: 1px solid rgb(160, 160, 160);\" valign='top'>
<input type='text' name='".$data['post_name']."' value='".$data['Default']."' style='width:300px;'>
</td>
</tr>
";
return ($result);
}
function render_text($data)
{
/* Ignore text messages, they are normally used for status hints. */
return ("");
}
function render_title($data)
{
/* Ignore text messages, they are normally used for status hints. */
return ("");
}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
|