| 2 | | /* settings Class for the Jlog setup.php and change settings in /admin/settings.php |
|---|
| 3 | | It needs the $l(anguage) array |
|---|
| 4 | | */ |
|---|
| 5 | | |
|---|
| | 2 | |
|---|
| | 3 | /** |
|---|
| | 4 | * Jlog |
|---|
| | 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 | * $HeadURL$ |
|---|
| | 21 | * $Rev$ |
|---|
| | 22 | * $Author$ |
|---|
| | 23 | * $Date$ |
|---|
| | 24 | */ |
|---|
| | 25 | |
|---|
| | 26 | /** |
|---|
| | 27 | * Settings class |
|---|
| | 28 | * |
|---|
| | 29 | * This class represents the current settings for Jlog and |
|---|
| | 30 | * offers the possibility to modify these settings based on |
|---|
| | 31 | * user's input. The configuration can be saved to disk, |
|---|
| | 32 | * if wanted. |
|---|
| | 33 | * |
|---|
| | 34 | * @category Jlog |
|---|
| | 35 | * @package Jlog_Settings |
|---|
| | 36 | * @license GNU General Public License |
|---|
| | 37 | * |
|---|
| | 38 | */ |
|---|
| 7 | | |
|---|
| 8 | | var $d = array(); |
|---|
| 9 | | |
|---|
| 10 | | function Settings($l) { |
|---|
| 11 | | # no return |
|---|
| 12 | | |
|---|
| 13 | | // get the language array $l and put it into the class |
|---|
| 14 | | $this->l = $l; |
|---|
| 15 | | } |
|---|
| 16 | | |
|---|
| 17 | | function put_data($what = false) { |
|---|
| 18 | | if($what === false) return $this->d; |
|---|
| 19 | | else return $this->d[$what]; |
|---|
| 20 | | } |
|---|
| 21 | | |
|---|
| 22 | | function get_data() { |
|---|
| 23 | | # no return |
|---|
| 24 | | // this is a blacklist of constats which are not to be written in settings.inc.php |
|---|
| 25 | | $search = array( 'JLOG_ADMIN', |
|---|
| 26 | | 'JLOG_DB_CONTENT', |
|---|
| 27 | | 'JLOG_DB_COMMENTS', |
|---|
| 28 | | 'JLOG_DB_CATASSIGN', |
|---|
| 29 | | 'JLOG_DB_CATEGORIES', |
|---|
| 30 | | 'JLOG_DB_ATTRIBUTES', |
|---|
| 31 | | 'JLOG_UPDATE', |
|---|
| 32 | | 'JLOG_VERSION', |
|---|
| 33 | | 'JLOG_LOGIN', |
|---|
| 34 | | 'JLOG_SOFTWARE_VERSION', |
|---|
| 35 | | 'JLOG_SOFTWARE_URL', |
|---|
| 36 | | 'JLOG_SOFTWARE_PHPV', |
|---|
| 37 | | 'JLOG_SOFTWARE_MYSQLV', |
|---|
| 38 | | 'JLOG_ADMIN_PASSWORD_AGAIN' |
|---|
| 39 | | ); |
|---|
| 40 | | |
|---|
| 41 | | // get all needed constants and put it into the class |
|---|
| 42 | | $constants = get_defined_constants(); |
|---|
| 43 | | foreach($constants as $key => $value) { |
|---|
| | 40 | |
|---|
| | 41 | /** |
|---|
| | 42 | * Assoziative array holding configuration options |
|---|
| | 43 | * |
|---|
| | 44 | * @access private |
|---|
| | 45 | * @var array |
|---|
| | 46 | */ |
|---|
| | 47 | var $d = array(); |
|---|
| | 48 | |
|---|
| | 49 | /** |
|---|
| | 50 | * Assoziative array holding translations according |
|---|
| | 51 | * to the current language. |
|---|
| | 52 | * |
|---|
| | 53 | * @access private |
|---|
| | 54 | * @var array |
|---|
| | 55 | */ |
|---|
| | 56 | var $l = array(); |
|---|
| | 57 | |
|---|
| | 58 | /** |
|---|
| | 59 | * Settings() - class constructor |
|---|
| | 60 | * |
|---|
| | 61 | * @access public |
|---|
| | 62 | * @param array $l |
|---|
| | 63 | * @return void |
|---|
| | 64 | */ |
|---|
| | 65 | function Settings($l) { |
|---|
| | 66 | // get the language array $l and put it into the class |
|---|
| | 67 | $this->l = $l; |
|---|
| | 68 | } |
|---|
| | 69 | |
|---|
| | 70 | /** |
|---|
| | 71 | * put_data() - reads configuration data |
|---|
| | 72 | * |
|---|
| | 73 | * This procedure returns the value for then configuration option |
|---|
| | 74 | * specified by $key or an array of all options if $key is not |
|---|
| | 75 | * specified or false |
|---|
| | 76 | * |
|---|
| | 77 | * @access public |
|---|
| | 78 | * @param string|boolean $key |
|---|
| | 79 | * @return mixed |
|---|
| | 80 | */ |
|---|
| | 81 | function put_data($key = false) { |
|---|
| | 82 | if($key === false) return $this->d; |
|---|
| | 83 | else return $this->d[$key]; |
|---|
| | 84 | } |
|---|
| | 85 | |
|---|
| | 86 | /** |
|---|
| | 87 | * Enter description here... |
|---|
| | 88 | * |
|---|
| | 89 | * @access public |
|---|
| | 90 | * @return void |
|---|
| | 91 | */ |
|---|
| | 92 | function get_data() { |
|---|
| | 93 | # no return |
|---|
| | 94 | // this is a blacklist of constats which are not to be written in settings.inc.php |
|---|
| | 95 | $search = array( |
|---|
| | 96 | 'JLOG_ADMIN', |
|---|
| | 97 | 'JLOG_DB_CONTENT', |
|---|
| | 98 | 'JLOG_DB_COMMENTS', |
|---|
| | 99 | 'JLOG_DB_CATASSIGN', |
|---|
| | 100 | 'JLOG_DB_CATEGORIES', |
|---|
| | 101 | 'JLOG_DB_ATTRIBUTES', |
|---|
| | 102 | 'JLOG_UPDATE', |
|---|
| | 103 | 'JLOG_VERSION', |
|---|
| | 104 | 'JLOG_LOGIN', |
|---|
| | 105 | 'JLOG_SOFTWARE_VERSION', |
|---|
| | 106 | 'JLOG_SOFTWARE_URL', |
|---|
| | 107 | 'JLOG_SOFTWARE_PHPV', |
|---|
| | 108 | 'JLOG_SOFTWARE_MYSQLV', |
|---|
| | 109 | 'JLOG_ADMIN_PASSWORD_AGAIN' |
|---|
| | 110 | ); |
|---|
| | 111 | |
|---|
| | 112 | // get all needed constants and put it into the class |
|---|
| | 113 | $constants = get_defined_constants(); |
|---|
| | 114 | foreach($constants as $key => $value) { |
|---|
| 48 | | } |
|---|
| 49 | | } |
|---|
| 50 | | |
|---|
| 51 | | function get_userdata($d = false, $exclusiv = false) { |
|---|
| 52 | | # no return |
|---|
| 53 | | |
|---|
| 54 | | // get the data from users $d array and put it into the class |
|---|
| 55 | | if($d !== false) { |
|---|
| 56 | | if($exclusiv) $this->d = $d; |
|---|
| 57 | | else $this->d = array_merge($this->d, $d); |
|---|
| 58 | | } |
|---|
| 59 | | |
|---|
| 60 | | if(JLOG_ADMIN === true) { |
|---|
| 61 | | $this->d['jlog_db'] = JLOG_DB; |
|---|
| 62 | | $this->d['jlog_db_url'] = JLOG_DB_URL; |
|---|
| 63 | | $this->d['jlog_db_user'] = JLOG_DB_USER; |
|---|
| 64 | | $this->d['jlog_db_pwd'] = JLOG_DB_PWD; |
|---|
| 65 | | $this->d['jlog_db_prefix'] = JLOG_DB_PREFIX; |
|---|
| 66 | | $this->d['jlog_start_year'] = JLOG_START_YEAR; |
|---|
| 67 | | $this->d['jlog_path'] = JLOG_PATH; |
|---|
| 68 | | $this->d['jlog_basepath'] = JLOG_BASEPATH; |
|---|
| 69 | | if($this->d['jlog_admin_password'] == '') $this->jlog_admin_password = JLOG_ADMIN_PASSWORD; |
|---|
| 70 | | else { |
|---|
| 71 | | $this->d['jlog_admin_password'] = md5($this->d['jlog_admin_password']); |
|---|
| 72 | | $this->d['jlog_admin_password_again'] = md5($this->d['jlog_admin_password_again']); |
|---|
| 73 | | } |
|---|
| 74 | | $this->d['jlog_installed_version'] = JLOG_INSTALLED_VERSION; |
|---|
| 75 | | $this->d['jlog_installed_url'] = JLOG_INSTALLED_URL; |
|---|
| 76 | | $this->d['jlog_installed_phpv'] = JLOG_INSTALLED_PHPV; |
|---|
| 77 | | $this->d['jlog_installed_mysqlv'] = JLOG_INSTALLED_MYSQLV; |
|---|
| | 119 | } |
|---|
| | 120 | } |
|---|
| | 121 | |
|---|
| | 122 | /** |
|---|
| | 123 | * get_userdata() - sets configuration data |
|---|
| | 124 | * |
|---|
| | 125 | * Sets configuration data according to $d. If working in |
|---|
| | 126 | * non-exclusive mode (the default), $d is merged into the current |
|---|
| | 127 | * configuration, otherwise the current configuration is discared |
|---|
| | 128 | * and $d is set as the new configuration. |
|---|
| | 129 | * |
|---|
| | 130 | * @access public |
|---|
| | 131 | * @param array $d |
|---|
| | 132 | * @param boolean $exclusiv |
|---|
| | 133 | * @return void |
|---|
| | 134 | */ |
|---|
| | 135 | function get_userdata($d = false, $exclusiv = false) { |
|---|
| | 136 | |
|---|
| | 137 | // get the data from users $d array and put it into the class |
|---|
| | 138 | if($d !== false) { |
|---|
| | 139 | if($exclusiv) $this->d = $d; |
|---|
| | 140 | else $this->d = array_merge($this->d, $d); |
|---|
| | 141 | } |
|---|
| | 142 | |
|---|
| | 143 | if(JLOG_ADMIN === true) { |
|---|
| | 144 | $this->d['jlog_db'] = JLOG_DB; |
|---|
| | 145 | $this->d['jlog_db_url'] = JLOG_DB_URL; |
|---|
| | 146 | $this->d['jlog_db_user'] = JLOG_DB_USER; |
|---|
| | 147 | $this->d['jlog_db_pwd'] = JLOG_DB_PWD; |
|---|
| | 148 | $this->d['jlog_db_prefix'] = JLOG_DB_PREFIX; |
|---|
| | 149 | $this->d['jlog_start_year'] = JLOG_START_YEAR; |
|---|
| | 150 | $this->d['jlog_path'] = JLOG_PATH; |
|---|
| | 151 | $this->d['jlog_basepath'] = JLOG_BASEPATH; |
|---|
| | 152 | if($this->d['jlog_admin_password'] == '') { |
|---|
| | 153 | $this->jlog_admin_password = JLOG_ADMIN_PASSWORD; |
|---|
| 83 | | |
|---|
| 84 | | if((defined('JLOG_SETUP') AND JLOG_SETUP === true) OR (defined('JLOG_UPDATE') AND JLOG_UPDATE === true)) { |
|---|
| 85 | | $this->d['jlog_installed_version'] = JLOG_SOFTWARE_VERSION; |
|---|
| 86 | | $this->d['jlog_installed_url'] = JLOG_SOFTWARE_URL; |
|---|
| 87 | | $this->d['jlog_installed_phpv'] = JLOG_SOFTWARE_PHPV; |
|---|
| 88 | | $this->d['jlog_installed_mysqlv'] = JLOG_SOFTWARE_MYSQLV; |
|---|
| 89 | | } |
|---|
| 90 | | } |
|---|
| 91 | | |
|---|
| 92 | | function get_sugestiondata() { |
|---|
| 93 | | # no return |
|---|
| 94 | | |
|---|
| 95 | | // suggest some data for setup |
|---|
| 96 | | $this->d['jlog_path'] = dirname("http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]); |
|---|
| 97 | | $this->d['jlog_basepath'] = dirname(dirname( __FILE__ )).DIRECTORY_SEPARATOR; |
|---|
| 98 | | $date = getdate(); |
|---|
| 99 | | $this->d['jlog_start_year'] = $date['year']; |
|---|
| 100 | | $this->d['jlog_max_blog_orginal'] = 1; |
|---|
| 101 | | $this->d['jlog_max_blog_big'] = 4; |
|---|
| 102 | | $this->d['jlog_max_blog_small'] = 15; |
|---|
| 103 | | $this->d['jlog_sub_current'] = 6; |
|---|
| 104 | | $this->d['jlog_date'] = $this->l['date_format']; |
|---|
| 105 | | $this->d['jlog_date_comment'] = $this->l['date_format_comment']; |
|---|
| 106 | | $this->d['jlog_date_subcurrent'] = $this->l['date_format_subcurrent']; |
|---|
| 107 | | $this->d['jlog_info_by_comment'] = '1'; |
|---|
| 108 | | $this->d['jlog_db_url'] = "localhost"; |
|---|
| 109 | | $this->d['jlog_db_prefix'] = "jlog_"; |
|---|
| 110 | | $this->d['jlog_blogservices'] = "http://rpc.pingomatic.com/"; |
|---|
| 111 | | $this->d['jlog_language'] = JLOG_LANGUAGE; |
|---|
| 112 | | } |
|---|
| 113 | | |
|---|
| 114 | | function get_value($array, $key, $default = "") { |
|---|
| 115 | | # Return value of entry $key in $array if exists |
|---|
| 116 | | # or return $default otherwise |
|---|
| 117 | | if(isset($array[$key])) { |
|---|
| 118 | | return $array[$key]; |
|---|
| 119 | | } |
|---|
| 120 | | else { |
|---|
| 121 | | return $default; |
|---|
| 122 | | } |
|---|
| 123 | | } |
|---|
| 124 | | |
|---|
| 125 | | function form_output() { |
|---|
| | 159 | $this->d['jlog_installed_version'] = JLOG_INSTALLED_VERSION; |
|---|
| | 160 | $this->d['jlog_installed_url'] = JLOG_INSTALLED_URL; |
|---|
| | 161 | $this->d['jlog_installed_phpv'] = JLOG_INSTALLED_PHPV; |
|---|
| | 162 | $this->d['jlog_installed_mysqlv'] = JLOG_INSTALLED_MYSQLV; |
|---|
| | 163 | } |
|---|
| | 164 | else { |
|---|
| | 165 | $this->d['jlog_admin_password'] = md5($this->d['jlog_admin_password']); |
|---|
| | 166 | $this->d['jlog_admin_password_again'] = md5($this->d['jlog_admin_password_again']); |
|---|
| | 167 | } |
|---|
| | 168 | |
|---|
| | 169 | if((defined('JLOG_SETUP') AND JLOG_SETUP === true) |
|---|
| | 170 | OR (defined('JLOG_UPDATE') AND JLOG_UPDATE === true)) |
|---|
| | 171 | { |
|---|
| | 172 | $this->d['jlog_installed_version'] = JLOG_SOFTWARE_VERSION; |
|---|
| | 173 | $this->d['jlog_installed_url'] = JLOG_SOFTWARE_URL; |
|---|
| | 174 | $this->d['jlog_installed_phpv'] = JLOG_SOFTWARE_PHPV; |
|---|
| | 175 | $this->d['jlog_installed_mysqlv'] = JLOG_SOFTWARE_MYSQLV; |
|---|
| | 176 | } |
|---|
| | 177 | } |
|---|
| | 178 | |
|---|
| | 179 | /** |
|---|
| | 180 | * get_suggestiondata() - preallocates configuration data |
|---|
| | 181 | * |
|---|
| | 182 | * Initialises the configuration with useful settings during |
|---|
| | 183 | * the installation process. |
|---|
| | 184 | * |
|---|
| | 185 | * @access public |
|---|
| | 186 | * @return void |
|---|
| | 187 | */ |
|---|
| | 188 | function get_sugestiondata() { |
|---|
| | 189 | |
|---|
| | 190 | // suggest some data for setup |
|---|
| | 191 | $this->d['jlog_path'] = $this->get_suggest_path(); |
|---|
| | 192 | $this->d['jlog_basepath'] = dirname(dirname( __FILE__ )).DIRECTORY_SEPARATOR; |
|---|
| | 193 | $date = getdate(); |
|---|
| | 194 | $this->d['jlog_start_year'] = $date['year']; |
|---|
| | 195 | $this->d['jlog_max_blog_orginal'] = 1; |
|---|
| | 196 | $this->d['jlog_max_blog_big'] = 4; |
|---|
| | 197 | $this->d['jlog_max_blog_small'] = 15; |
|---|
| | 198 | $this->d['jlog_sub_current'] = 6; |
|---|
| | 199 | $this->d['jlog_date'] = $this->l['date_format']; |
|---|
| | 200 | $this->d['jlog_date_comment'] = $this->l['date_format_comment']; |
|---|
| | 201 | $this->d['jlog_date_subcurrent'] = $this->l['date_format_subcurrent']; |
|---|
| | 202 | $this->d['jlog_info_by_comment'] = '1'; |
|---|
| | 203 | $this->d['jlog_db_url'] = 'localhost'; |
|---|
| | 204 | $this->d['jlog_db_prefix'] = 'jlog_'; |
|---|
| | 205 | $this->d['jlog_blogservices'] = 'http://rpc.pingomatic.com/'; |
|---|
| | 206 | $this->d['jlog_language'] = JLOG_LANGUAGE; |
|---|
| | 207 | } |
|---|
| | 208 | |
|---|
| | 209 | |
|---|
| | 210 | /** |
|---|
| | 211 | * get_suggest_path() - generate a suggestion for JLOG_PATH |
|---|
| | 212 | * |
|---|
| | 213 | * @access private |
|---|
| | 214 | * @return string |
|---|
| | 215 | */ |
|---|
| | 216 | function get_suggest_path() { |
|---|
| | 217 | $host = empty($_SERVER['HTTP_HOST']) |
|---|
| | 218 | ? (empty($_SERVER['SERVER_NAME']) |
|---|
| | 219 | ? $_SERVER['SERVER_ADDR'] |
|---|
| | 220 | : $_SERVER['SERVER_NAME']) |
|---|
| | 221 | : $_SERVER['HTTP_HOST']; |
|---|
| | 222 | $proto = (empty($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] == 'off') |
|---|
| | 223 | ? 'http' |
|---|
| | 224 | : 'https'; |
|---|
| | 225 | $port = $_SERVER['SERVER_PORT']; |
|---|
| | 226 | |
|---|
| | 227 | $uri = $proto . '://' . $host; |
|---|
| | 228 | if ((('http' == $proto) and (80 != $port)) |
|---|
| | 229 | or (('https' == $proto) and (443 != $port))) |
|---|
| | 230 | { |
|---|
| | 231 | $uri .= ':' . $port; |
|---|
| | 232 | } |
|---|
| | 233 | $uri .= dirname(dirname($_SERVER['PHP_SELF'])); |
|---|
| | 234 | |
|---|
| | 235 | return $uri; |
|---|
| | 236 | } |
|---|
| | 237 | |
|---|
| | 238 | /** |
|---|
| | 239 | * get_value() - gets a value of an array |
|---|
| | 240 | * |
|---|
| | 241 | * Look for index $key in the array $array and return |
|---|
| | 242 | * the corresponding value if it exists or the default |
|---|
| | 243 | * value $default if it doesn't. |
|---|
| | 244 | * |
|---|
| | 245 | * @access public |
|---|
| | 246 | * @param array $array |
|---|
| | 247 | * @param mixed $key |
|---|
| | 248 | * @param mixed $default |
|---|
| | 249 | * @return mixed |
|---|
| | 250 | */ |
|---|
| | 251 | function get_value($array, $key, $default = '') { |
|---|
| | 252 | |
|---|
| | 253 | if(isset($array[$key])) { |
|---|
| | 254 | return $array[$key]; |
|---|
| | 255 | } |
|---|
| | 256 | else { |
|---|
| | 257 | return $default; |
|---|
| | 258 | } |
|---|
| | 259 | } |
|---|
| | 260 | |
|---|
| | 261 | /** |
|---|
| | 262 | * form_output() - generates HTML output for formular |
|---|
| | 263 | * |
|---|
| | 264 | * @access public |
|---|
| | 265 | * @return string |
|---|
| | 266 | */ |
|---|
| | 267 | function form_output() { |
|---|
| 127 | | |
|---|
| 128 | | $data = array_htmlspecialchars($this->d); |
|---|
| 129 | | |
|---|
| 130 | | if(isset($data['jlog_clean_url']) AND ($data['jlog_clean_url'] === 'true' OR $data['jlog_clean_url'] === '1')) |
|---|
| 131 | | $d['clean_url_yes'] = " checked='checked'"; |
|---|
| 132 | | else $d['clean_url_no'] = " checked='checked'"; |
|---|
| 133 | | |
|---|
| 134 | | if(isset($data['jlog_info_by_comment'])) $d['info_by_comment'] = " checked='checked'"; |
|---|
| 135 | | else $d['info_by_comment'] = ""; |
|---|
| 136 | | |
|---|
| 137 | | if(isset($data['jlog_bs_weblogs_com']) AND ($data['jlog_bs_weblogs_com'] === 'true' OR $data['jlog_bs_weblogs_com'] === '1')) |
|---|
| 138 | | $d['bs_weblogs_com'] = " checked='checked' "; |
|---|
| 139 | | |
|---|
| 140 | | if(defined("JLOG_ADMIN") AND JLOG_ADMIN === true) $admincenter_password = " ".$this->l['admin']['m_admin_password_admin']; |
|---|
| 141 | | else $admincenter_password = ''; |
|---|
| 142 | | |
|---|
| 143 | | // get available languages |
|---|
| 144 | | $dir = opendir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'); |
|---|
| 145 | | $languages = array(); |
|---|
| 146 | | while(($file = readdir($dir)) !== false) { |
|---|
| | 269 | |
|---|
| | 270 | $data = array_htmlspecialchars($this->d); |
|---|
| | 271 | |
|---|
| | 272 | if(isset($data['jlog_clean_url']) AND ($data['jlog_clean_url'] === 'true' OR $data['jlog_clean_url'] === '1')) |
|---|
| | 273 | $d['clean_url_yes'] = " checked='checked'"; |
|---|
| | 274 | else $d['clean_url_no'] = " checked='checked'"; |
|---|
| | 275 | |
|---|
| | 276 | if(isset($data['jlog_info_by_comment'])) $d['info_by_comment'] = " checked='checked'"; |
|---|
| | 277 | else $d['info_by_comment'] = ""; |
|---|
| | 278 | |
|---|
| | 279 | if(isset($data['jlog_bs_weblogs_com']) AND ($data['jlog_bs_weblogs_com'] === 'true' OR $data['jlog_bs_weblogs_com'] === '1')) |
|---|
| | 280 | $d['bs_weblogs_com'] = " checked='checked' "; |
|---|
| | 281 | |
|---|
| | 282 | if(defined("JLOG_ADMIN") AND JLOG_ADMIN === true) $admincenter_password = " ".$this->l['admin']['m_admin_password_admin']; |
|---|
| | 283 | else $admincenter_password = ''; |
|---|
| | 284 | |
|---|
| | 285 | // get available languages |
|---|
| | 286 | $dir = opendir(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'lang'); |
|---|
| | 287 | $languages = array(); |
|---|
| | 288 | while(($file = readdir($dir)) !== false) { |
|---|
| 230 | | return $form; |
|---|
| 231 | | } |
|---|
| 232 | | |
|---|
| 233 | | function validate() { |
|---|
| 234 | | # if everything validate then return true |
|---|
| 235 | | # otherwise return the $errors array |
|---|
| 236 | | |
|---|
| 237 | | $errors = array(); |
|---|
| 238 | | |
|---|
| 239 | | // paths |
|---|
| 240 | | if(empty($this->d['jlog_path']) OR (check_url($this->d['jlog_path'], array ('http')) === false)) $errors[] = $this->l['admin']['e_path']; |
|---|
| 241 | | if(empty($this->d['jlog_basepath']) OR !is_dir($this->d['jlog_basepath'])) $errors[] = $this->l['admin']['e_basepath']; |
|---|
| 242 | | if($this->d['jlog_clean_url'] != 'true') $this->d['jlog_clean_url'] = 'false'; |
|---|
| 243 | | // metadata |
|---|
| 244 | | if(empty($this->d['jlog_website'])) $errors[] = $this->l['admin']['e_website']; |
|---|
| 245 | | if(empty($this->d['jlog_publisher'])) $errors[] = $this->l['admin']['e_publisher']; |
|---|
| 246 | | if(defined('JLOG_SETUP') AND JLOG_SETUP) { |
|---|
| 247 | | if($this->d['jlog_admin_password'] == md5("")) |
|---|
| 248 | | $errors[] = $this->l['admin']['e_admin_password']; |
|---|
| 249 | | elseif($this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) |
|---|
| 250 | | $errors[] = $this->l['admin']['e_admin_password_again']; |
|---|
| 251 | | } |
|---|
| 252 | | elseif(!empty($this->d['jlog_admin_password']) AND $this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) { |
|---|
| 253 | | $errors[] = $this->l['admin']['e_admin_password_again']; |
|---|
| 254 | | } |
|---|
| 255 | | // Fix of bug #148 |
|---|
| 256 | | if(isset($this->d['jlog_admin_password_again'])) |
|---|
| 257 | | unset($this->d['jlog_admin_password_again']); |
|---|
| 258 | | |
|---|
| 259 | | if(empty($this->d['jlog_email']) OR !strpos($this->d['jlog_email'], '@')) $errors[] = $this->l['admin']['e_email']; |
|---|
| 260 | | if(empty($this->d['jlog_description'])) $errors[] = $this->l['admin']['e_description']; |
|---|
| 261 | | // behavour |
|---|
| 262 | | if(!is_numeric($this->d['jlog_max_blog_orginal']) OR intval($this->d['jlog_max_blog_orginal']) < 0) $errors[] = $this->l['admin']['e_max_blog_orginal']; |
|---|
| 263 | | if(!is_numeric($this->d['jlog_max_blog_big']) OR intval($this->d['jlog_max_blog_big']) < 0) $errors[] = $this->l['admin']['e_max_blog_big']; |
|---|
| 264 | | if(!is_numeric($this->d['jlog_max_blog_small']) OR intval($this->d['jlog_max_blog_small']) < 0) $errors[] = $this->l['admin']['e_max_blog_small']; |
|---|
| 265 | | if(!is_numeric($this->d['jlog_sub_current']) OR intval($this->d['jlog_sub_current']) < 0) $errors[] = $this->l['admin']['e_sub_current']; |
|---|
| 266 | | if(!is_numeric($this->d['jlog_start_year'])) $errors[] = $this->l['admin']['e_start_year']; |
|---|
| 267 | | if($this->d['jlog_info_by_comment'] != 'true') $this->d['jlog_info_by_comment'] = 'false'; |
|---|
| 268 | | // database |
|---|
| 269 | | if(empty($this->d['jlog_db'])) $errors[] = $this->l['admin']['e_db']; |
|---|
| 270 | | if(empty($this->d['jlog_db_url'])) $errors[] = $this->l['admin']['e_db_url']; |
|---|
| 271 | | |
|---|
| 272 | | return $errors; |
|---|
| 273 | | } |
|---|
| 274 | | |
|---|
| 275 | | function do_settings() { |
|---|
| 276 | | # if it's all done return true |
|---|
| | 372 | return $form; |
|---|
| | 373 | } |
|---|
| | 374 | |
|---|
| | 375 | /** |
|---|
| | 376 | * validate() - validates the current configuration |
|---|
| | 377 | * |
|---|
| | 378 | * If the current configuration is valid, an empty array is returned. |
|---|
| | 379 | * Otherwise the returned array containes all errors, described in the |
|---|
| | 380 | * current language. |
|---|
| | 381 | * |
|---|
| | 382 | * @access public |
|---|
| | 383 | * @return array |
|---|
| | 384 | */ |
|---|
| | 385 | function validate() { |
|---|
| | 386 | # if everything validate then return true |
|---|
| 279 | | $errors = array(); |
|---|
| 280 | | |
|---|
| 281 | | // if there is no new password set the old |
|---|
| 282 | | if(JLOG_ADMIN AND empty($this->d['jlog_admin_password'])) $this->d['jlog_admin_password'] = $this->jlog_admin_password; |
|---|
| 283 | | |
|---|
| 284 | | // erase last slashes |
|---|
| | 389 | $errors = array(); |
|---|
| | 390 | |
|---|
| | 391 | // paths |
|---|
| | 392 | if(empty($this->d['jlog_path']) OR (check_url($this->d['jlog_path'], array ('http')) === false)) $errors[] = $this->l['admin']['e_path']; |
|---|
| | 393 | if(empty($this->d['jlog_basepath']) OR !is_dir($this->d['jlog_basepath'])) $errors[] = $this->l['admin']['e_basepath']; |
|---|
| | 394 | if($this->d['jlog_clean_url'] != 'true') $this->d['jlog_clean_url'] = 'false'; |
|---|
| | 395 | // metadata |
|---|
| | 396 | if(empty($this->d['jlog_website'])) $errors[] = $this->l['admin']['e_website']; |
|---|
| | 397 | if(empty($this->d['jlog_publisher'])) $errors[] = $this->l['admin']['e_publisher']; |
|---|
| | 398 | if(defined('JLOG_SETUP') AND JLOG_SETUP) { |
|---|
| | 399 | if($this->d['jlog_admin_password'] == md5("")) |
|---|
| | 400 | $errors[] = $this->l['admin']['e_admin_password']; |
|---|
| | 401 | elseif($this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) |
|---|
| | 402 | $errors[] = $this->l['admin']['e_admin_password_again']; |
|---|
| | 403 | } |
|---|
| | 404 | elseif(!empty($this->d['jlog_admin_password']) AND $this->d['jlog_admin_password'] !== $this->d['jlog_admin_password_again']) { |
|---|
| | 405 | $errors[] = $this->l['admin']['e_admin_password_again']; |
|---|
| | 406 | } |
|---|
| | 407 | // Fix of bug #148 |
|---|
| | 408 | if(isset($this->d['jlog_admin_password_again'])) |
|---|
| | 409 | unset($this->d['jlog_admin_password_again']); |
|---|
| | 410 | |
|---|
| | 411 | if(empty($this->d['jlog_email']) OR !strpos($this->d['jlog_email'], '@')) $errors[] = $this->l['admin']['e_email']; |
|---|
| | 412 | if(empty($this->d['jlog_description'])) $errors[] = $this->l['admin']['e_description']; |
|---|
| | 413 | // behavour |
|---|
| | 414 | if(!is_numeric($this->d['jlog_max_blog_orginal']) OR intval($this->d['jlog_max_blog_orginal']) < 0) $errors[] = $this->l['admin']['e_max_blog_orginal']; |
|---|
| | 415 | if(!is_numeric($this->d['jlog_max_blog_big']) OR intval($this->d['jlog_max_blog_big']) < 0) $errors[] = $this->l['admin']['e_max_blog_big']; |
|---|
| | 416 | if(!is_numeric($this->d['jlog_max_blog_small']) OR intval($this->d['jlog_max_blog_small']) < 0) $errors[] = $this->l['admin']['e_max_blog_small']; |
|---|
| | 417 | if(!is_numeric($this->d['jlog_sub_current']) OR intval($this->d['jlog_sub_current']) < 0) $errors[] = $this->l['admin']['e_sub_current']; |
|---|
| | 418 | if(!is_numeric($this->d['jlog_start_year'])) $errors[] = $this->l['admin']['e_start_year']; |
|---|
| | 419 | if($this->d['jlog_info_by_comment'] != 'true') $this->d['jlog_info_by_comment'] = 'false'; |
|---|
| | 420 | // database |
|---|
| | 421 | if(empty($this->d['jlog_db'])) $errors[] = $this->l['admin']['e_db']; |
|---|
| | 422 | if(empty($this->d['jlog_db_url'])) $errors[] = $this->l['admin']['e_db_url']; |
|---|
| | 423 | |
|---|
| | 424 | return $errors; |
|---|
| | 425 | } |
|---|
| | 426 | |
|---|
| | 427 | /** |
|---|
| | 428 | * do_settings() - save configuration |
|---|
| | 429 | * |
|---|
| | 430 | * Saves the current configuration to the settings.inc.php file |
|---|
| | 431 | * in the personal folder. Return an empty array if configuration |
|---|
| | 432 | * was saved successfully, or an array containing descriptions of |
|---|
| | 433 | * the errors that occured otherwise. |
|---|
| | 434 | * |
|---|
| | 435 | * @access public |
|---|
| | 436 | * @return array |
|---|
| | 437 | */ |
|---|
| | 438 | function do_settings() { |
|---|
| | 439 | # if it's all done return true |
|---|
| | 440 | # otherwise return the $errors array |
|---|
| | 441 | |
|---|
| | 442 | $errors = array(); |
|---|
| | 443 | |
|---|
| | 444 | // if there is no new password set the old |
|---|
| | 445 | if(JLOG_ADMIN AND empty($this->d['jlog_admin_password'])) $this->d['jlog_admin_password'] = $this->jlog_admin_password; |
|---|
| | 446 | |
|---|
| | 447 | // erase last slashes |
|---|
| 288 | | // no quotes for bolean and numbers |
|---|
| 289 | | $no_quotes = array ( "jlog_clean_url", |
|---|
| 290 | | "jlog_max_blog_orginal", |
|---|
| 291 | | "jlog_max_blog_big", |
|---|
| 292 | | "jlog_max_blog_small", |
|---|
| 293 | | "jlog_sub_current", |
|---|
| 294 | | "jlog_start_year", |
|---|
| 295 | | "jlog_info_by_comment" ); |
|---|
| 296 | | |
|---|
| 297 | | // serialize data to file format |
|---|
| 298 | | $file_content = "<?php\n//generated at " . date('Y-m-d, h:i:s') . "\n"; |
|---|
| 299 | | |
|---|
| 300 | | foreach($this->d as $key => $value) { |
|---|
| 301 | | unset($q, $s, $s2); |
|---|
| 302 | | if(!in_array($key, $no_quotes)) $q = "'"; |
|---|
| 303 | | $key = strtoupper($key); |
|---|
| 304 | | |
|---|
| 305 | | // bolean |
|---|
| 306 | | if($key == 'JLOG_CLEAN_URL' OR $key == 'JLOG_INFO_BY_COMMENT') { |
|---|
| 307 | | if($value == 'true' OR $value === true) $value = "true"; |
|---|
| 308 | | else $value = "false"; |
|---|
| 309 | | } |
|---|
| 310 | | $file_content .= " define('".$key."', ".$q.addslashes($value).$q.");\n"; |
|---|
| 311 | | } |
|---|
| 312 | | |
|---|
| | 451 | // no quotes for bolean and numbers |
|---|
| | 452 | $no_quotes = array ( |
|---|
| | 453 | 'jlog_clean_url', |
|---|
| | 454 | 'jlog_max_blog_orginal', |
|---|
| | 455 | 'jlog_max_blog_big', |
|---|
| | 456 | 'jlog_max_blog_small', |
|---|
| | 457 | 'jlog_sub_current', |
|---|
| | 458 | 'jlog_start_year', |
|---|
| | 459 | 'jlog_info_by_comment' |
|---|
| | 460 | ); |
|---|
| | 461 | |
|---|
| | 462 | // serialize data to file format |
|---|
| | 463 | $file_content = "<?php\n//generated at " . date('Y-m-d, h:i:s') . "\n"; |
|---|
| | 464 | |
|---|
| | 465 | foreach($this->d as $key => $value) { |
|---|
| | 466 | unset($q, $s, $s2); |
|---|
| | 467 | if(!in_array($key, $no_quotes)) $q = "'"; |
|---|
| | 468 | $key = strtoupper($key); |
|---|
| | 469 | |
|---|
| | 470 | // bolean |
|---|
| | 471 | if($key == 'JLOG_CLEAN_URL' OR $key == 'JLOG_INFO_BY_COMMENT') { |
|---|
| | 472 | if($value == 'true' OR $value === true) $value = "true"; |
|---|
| | 473 | else $value = 'false'; |
|---|
| | 474 | } |
|---|
| | 475 | $file_content .= " define('".$key."', ".$q.addslashes($value).$q.");\n"; |
|---|
| | 476 | } |
|---|
| | 477 | |
|---|