source: install/cfg-dist.php @ f08393

Revision f08393, 6.7 KB checked in by pierre-alain <pierre-alain@…>, 4 years ago (diff)

adding two new constants for theme and plugins path

  • Property mode set to 100644
Line 
1<?php
2/**
3 * Config file for OpenWebReader installation
4 *
5 * PHP 5
6 *
7 * OWR - OpenWebReader
8 *
9 * Copyright (c) 2009, Pierre-Alain Mignot
10 *
11 * Home page: http://openwebreader.org
12 *
13 * E-Mail: contact@openwebreader.org
14 *
15 * All Rights Reserved
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 *
31 * @author Pierre-Alain Mignot <contact@openwebreader.org>
32 * @copyright Copyright (c) 2009, Pierre-Alain Mignot
33 * @licence http://www.gnu.org/copyleft/gpl.html
34 * @package OWR
35 */
36namespace OWR;
37if(defined('INC_CONFIG'))
38    die("can't include config file more than one time");
39if(!defined('PATH') || !defined('HOME_PATH'))
40    die('please define constants HOME and HOME_PATH before including the config file');
41
42define('OWR_THEMES_PATH', HOME_PATH . 'Includes' . DIRECTORY_SEPARATOR . 'Themes' . DIRECTORY_SEPARATOR);
43define('OWR_PLUGINS_PATH', HOME_PATH . 'Includes' . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR);
44
45// init UTF8 support
46if(!function_exists('mb_internal_encoding') || !mb_internal_encoding('UTF-8'))
47    die("Can not set internal encoding to utf8");
48
49ob_start();
50set_time_limit(0);
51gc_enabled() || gc_enable();
52$cfg = array();
53$cfg['begintime'] = microtime(true);
54
55/**************************************** START EDITING HERE ****************************************/
56/**
57 * Please have a look at http://trac.openwebreader.org/wiki/Configuration
58 */
59/* db config */
60$cfg['dbname']                  = 'openwebreader';
61$cfg['dbhost']                  = 'localhost';
62$cfg['dbport']                  = '3306';
63$cfg['dbdriver']                = 'mysql';
64$cfg['dbuser']                  = 'openwebreader';
65$cfg['dbpasswd']                = 'openwebreader';
66// generally /var/run/mysqld.sock or /tmp/mysql.sock
67$cfg['dbsocket']                = '/var/run/mysqld/mysqld.sock';
68$cfg['dsn']                     = $cfg['dbdriver'].':dbname='.$cfg['dbname'] .
69                                    ';host='.$cfg['dbhost'].';port='.$cfg['dbport'] .
70                                    ';unix_socket='.$cfg['dbsocket'];
71$cfg['dbCacheTime']             = 86400 * 7; // 24h * 7
72
73/* host config */
74$cfg['url']                     = 'openwebreader.mydomain.tld';
75$cfg['path']                    = '/'; // MUST ends with '/'
76$cfg['httpsecure']              = false; // set to true if owr will be used over SSL (HTTPS)
77$cfg['surl']                    = 'http'.($cfg['httpsecure'] ? 's' : '').'://'.$cfg['url'].$cfg['path'];
78
79/* templates cache time, default to 24h * 7 */
80$cfg['cacheTime']               = 86400 * 7;
81/* use file or memcache as cache */
82$cfg['cacheType']               = 'file';
83/* memcache hosts, for multiples server add comma-separated values */
84$cfg['memcache']                = '127.0.0.1:11211';
85/* session life time, default to 24h */
86$cfg['sessionLifeTime']         = 86400;
87
88/* server config */
89// default temporary directory
90// please keep this OUT of public web server access
91$cfg['defaultTmpDir']           = sys_get_temp_dir().DIRECTORY_SEPARATOR;
92// max upload file size, in octets, default to 5mo
93$cfg['maxUploadFileSize']       = 5120000;
94// path to php executable
95// please let empty open_basedir
96$cfg['phpbin']                  = '/usr/bin/php -d open_basedir= ';
97// default ttl, in minutes, used if no ttl is found while parsing a stream
98$cfg['defaultStreamRefreshTime'] = 60;
99// default minimum ttl, in minutes, used for checking ttl found while parsing a stream
100$cfg['defaultMinStreamRefreshTime'] = 30;
101// set to "index" for uri like /index.php?do=action, "action" for uri like /action?
102// look at file HOME/.htaccess for url-rewriting
103$cfg['uriStyle']                = 'index';
104// max log file size, in octets, default to 5mo
105$cfg['maxLogFileSize']          = 5120000;
106// maximum number of PHP threads that OWR can launch simultaneously
107// if you have an old server, maybe set this to 2, else 5 is not bad
108$cfg['maxThreads']              = 5;
109// nice command used to lower process priority, default "nice -n 10 "
110// (MUST ends with a space if you use it)
111$cfg['nicecmd']                 = 'nice -n 10 ';
112// command used to get the number of process used by OWR, default 'ps aux | grep "%s" | grep -v grep'
113$currentUser                    = @posix_getpwuid(posix_getuid());
114if(!empty($currentUser['name']))
115    $cfg['grepcmd']                 = 'pgrep -u '.$currentUser['name'].' -f "%s"';
116else
117    $cfg['grepcmd']                 = 'ps aux | grep "%s" | grep -v grep';
118unset($currentUser);
119
120/* default intl config */
121$cfg['date_default_timezone']   = 'Europe/Paris';
122$cfg['default_language']        = 'fr_FR';
123
124// activate debug mode here
125define('DEBUG', true);
126/**************************************** STOP EDITING HERE ****************************************/
127
128// version
129$cfg['version']                 = '0.2.1';
130
131// CLI call ?
132define('CLI', 'cli' === PHP_SAPI);
133
134// REST call ?
135define('REST', isset($_SERVER['SCRIPT_FILENAME']) && basename($_SERVER['SCRIPT_FILENAME']) === 'rest.php');
136
137// AJAX call ?
138define('AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
139
140/**
141 * Defines classes autoloading
142 *
143 * @author Pierre-Alain Mignot <contact@openwebreader.org>
144 * @param string $c The classname to load
145 */
146spl_autoload_register(function($c)
147{
148    if(class_exists($c, false)) return true;
149
150    $ext = false;
151    $internal = false;
152
153    if(false === ($ns = strpos($c, '\\')) && false === ($ext = strpos($c, '_'))) return false;
154
155    $f = false;
156
157    if(false !== $ext)
158    { // external libraries
159        $f = HOME_PATH."libs".DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $c).'.php';
160        if(!file_exists($f))
161            return false;
162    }
163    elseif(false !== $ns)
164    {
165        $f = PATH.str_replace('\\', DIRECTORY_SEPARATOR, str_replace('_', DIRECTORY_SEPARATOR, $c)).".php";
166    }
167    else
168    {
169        $f = HOME_PATH."libs".DIRECTORY_SEPARATOR.strtolower($c).".class.php";
170    }
171
172    if(!file_exists($f))
173    {
174        return false;
175    }
176
177    if(!include($f))
178    {
179        return false;
180    }
181
182    return class_exists($c, false);
183});
184
185Config::iGet($cfg); // init the config object
186// reset values from memory
187$cfg = null;
188unset($cfg);
189
190// we are set !
191define('INC_CONFIG', true);
Note: See TracBrowser for help on using the repository browser.