"Fossies" - the Fresh Open Source Software Archive 
Member "ide.php-1.5.3/Conf.phpclass" (28 Sep 2009, 5290 Bytes) of package /linux/www/old/ide.php-1.5.3.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
1 <?php
2 /*******************************************************************************\
3 * IDE.PHP, a web based editor for quick PHP development *
4 * Copyright (C) 2000 Johan Ekenberg *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 * *
20 * To contact the author regarding this program, *
21 * please use this email address: <ide.php@ekenberg.se> *
22 \*******************************************************************************/
23
24 class Conf {
25 /* Public vars begin with Uppercase letter,
26 private vars all lowercase. */
27 var $Success_message_color = "#119900";
28 var $Alert_message_color = "#DD0000";
29 var $Fancy_line_number_color = "#222222";
30 var $Conf_file = "./ide.php.conf";
31 var $Code_file = "./code_ide"; // Keeps the current code.
32 var $tmp_file_basename = "./tmp_ide"; // $this->$Eval_suffix get added here, forms $this->Tmp_file
33 var $Data_dir = "./data";
34
35 /* Option defaults go here */
36 var $Code_rows = 25;
37 var $Code_cols = 80;
38 var $Code_template = "<HTML>\n<BODY BGCOLOR=\"#FFFFFF\">\n<?php\n\n?>\n</BODY>\n</HTML>";
39 var $Fancy_view_line_numbers = 1;
40 var $Protect_entities = 0;
41 var $Eval_suffix = ".php";
42 var $Eval_suffix_list = array(".php", ".html", ".shtml", ".cgi", ".jsp");
43 var $Eval_executable = 0; // Needed for .cgi etc.
44 var $Unix_newlines = 0; // For cgi on UNIX
45
46 /* Names of config options go in this array */
47 var $conf_var_names = array('Code_rows', 'Code_cols',
48 'Code_template', 'Fancy_view_line_numbers',
49 'Protect_entities', 'Eval_suffix', 'Eval_suffix_list',
50 'Eval_executable', 'Unix_newlines', 'Http_auth_username',
51 'Http_auth_password');
52 /* Other vars */
53 var $Tmp_file, $Current_file, $Default_suffix, $saved_conf_array;
54
55 function Conf() {
56 $this->init_vars();
57 $this->Tmp_file = $this->tmp_file_basename . $this->Eval_suffix;
58 sort($this->Eval_suffix_list);
59 }
60
61 function init_vars() {
62 global $_POST;
63 $this->saved_conf_array = $this->get_saved_conf_array();
64 while (list(,$var_name) = each($this->conf_var_names)) {
65 if (isset($_POST[$var_name])) {
66 $this->$var_name = $_POST[$var_name];
67 }
68 elseif(isset($this->saved_conf_array[$var_name])) {
69 $this->$var_name = $this->saved_conf_array[$var_name];
70 }
71 }
72 }
73
74 function save_to_file($var_names = array()) {
75 if (! sizeof($var_names)) { // No arg =
76 $var_names = $this->conf_var_names; // save everything
77 }
78 $save_to_file_array = $this->saved_conf_array;
79 while (list(,$name) = each($var_names)) {
80 if (isset($this->$name)) {
81 $save_to_file_array[$name] = $this->$name;
82 }
83 }
84 $CONF_FILE = fopen($this->Conf_file, "w");
85 fputs ($CONF_FILE, serialize($save_to_file_array));
86 fclose ($CONF_FILE);
87 }
88
89 function get_saved_conf_array() {
90 if (! file_exists($this->Conf_file)) {
91 return FALSE;
92 }
93 $CF = fopen($this->Conf_file, "r");
94 $saved_conf_array = unserialize(fread($CF, filesize($this->Conf_file)));
95 fclose ($CF);
96 return ($saved_conf_array);
97 }
98
99 function get_saved_value($var) {
100 return($this->saved_conf_array[$var]);
101 }
102
103 function is_bad_environment() {
104 $error = "";
105 if (! (file_exists($this->Data_dir) || mkdir($this->Data_dir, 0705)) ) {
106 $error = "Directory {$this->Data_dir} doesn't exist and can not be created!<BR>
107 Possibly wrong permissions for the Ide.php directory?? (chmod 777)";
108 }
109 elseif (! (is_writeable($this->Data_dir) && is_readable($this->Data_dir))) {
110 $error = "Directory {$this->Data_dir} has incorrect permissions!<BR>
111 PHP needs both read and write access to this directory! (chmod 777)";
112 }
113 elseif (! is_writeable(".")) {
114 $error = "The Ide.php directory (current directory) has incorrect permissions!<BR>
115 PHP needs both read and write access to this directory! (chmod 777)";
116 }
117 return $error;
118 }
119
120 }?>