source: install/cfg-dist.php @ 19b5ce

Revision 19b5ce, 6.9 KB checked in by pierre-alain <pierre-alain@…>, 6 years ago (diff)

add support for memcache

  • 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
42// init UTF8 support
43if(!function_exists('mb_internal_encoding') || !mb_internal_encoding('UTF-8'))
44    die("Can not set internal encoding to utf8");
45
46ob_start();
47set_time_limit(0);
48gc_enabled() || gc_enable();
49$cfg = array();
50$cfg['begintime'] = microtime(true);
51
52/**************************************** START EDITING HERE ****************************************/
53/**
54 * Please have a look at http://trac.openwebreader.org/wiki/Configuration
55 */
56/* db config */
57$cfg['dbname']                  = 'openwebreader';
58$cfg['dbhost']                  = 'localhost';
59$cfg['dbport']                  = '3306';
60$cfg['dbdriver']                = 'mysql';
61$cfg['dbuser']                  = 'openwebreader';
62$cfg['dbpasswd']                = 'openwebreader';
63// generally /var/run/mysqld.sock or /tmp/mysql.sock
64$cfg['dbsocket']                = '/var/run/mysqld/mysqld.sock';
65$cfg['dsn']                     = $cfg['dbdriver'].':dbname='.$cfg['dbname'] .
66                                    ';host='.$cfg['dbhost'].';port='.$cfg['dbport'] .
67                                    ';unix_socket='.$cfg['dbsocket'];
68$cfg['dbCacheTime']             = 86400 * 7; // 24h * 7
69
70/* host config */
71$cfg['url']                     = 'openwebreader.mydomain.tld';
72$cfg['path']                    = '/'; // MUST ends with '/'
73$cfg['httpsecure']              = false; // set to true if owr will be used over SSL (HTTPS)
74$cfg['surl']                    = 'http'.($cfg['httpsecure'] ? 's' : '').'://'.$cfg['url'].$cfg['path'];
75
76/* templates cache time, default to 24h * 7 */
77$cfg['cacheTime']               = 86400 * 7;
78/* use file or memcache as cache */
79$cfg['cacheType']               = 'file';
80/* memcache hosts, for multiples server add comma-separated values */
81$cfg['memcache']                = '127.0.0.1:11211';
82/* session life time, default to 24h */
83$cfg['sessionLifeTime']         = 86400;
84
85/* server config */
86// default temporary directory
87// please keep this OUT of public web server access
88$cfg['defaultTmpDir']           = sys_get_temp_dir().DIRECTORY_SEPARATOR;
89// max upload file size, in octets, default to 5mo
90$cfg['maxUploadFileSize']       = 5120000;
91// path to php executable
92// please let empty open_basedir
93$cfg['phpbin']                  = '/usr/bin/php -d open_basedir= ';
94// default ttl, in minutes, used if no ttl is found while parsing a stream
95$cfg['defaultStreamRefreshTime'] = 60;
96// default minimum ttl, in minutes, used for checking ttl found while parsing a stream
97$cfg['defaultMinStreamRefreshTime'] = 30;
98// set to "index" for uri like /index.php?do=action, "action" for uri like /action?
99// look at file HOME/.htaccess for url-rewriting
100$cfg['uriStyle']                = 'index';
101// max log file size, in octets, default to 5mo
102$cfg['maxLogFileSize']          = 5120000;
103// maximum number of PHP threads that OWR can launch simultaneously
104// if you have an old server, maybe set this to 2, else 5 is not bad
105$cfg['maxThreads']              = 5;
106// nice command used to lower process priority, default "nice -n 10 "
107// (MUST ends with a space if you use it)
108$cfg['nicecmd']                 = 'nice -n 10 ';
109// command used to get the number of process used by OWR, default 'ps aux | grep "%s" | grep -v grep'
110$currentUser                    = @posix_getpwuid(posix_getuid());
111if(!empty($currentUser['name']))
112    $cfg['grepcmd']                 = 'pgrep -u '.$currentUser['name'].' -f "%s"';
113else
114    $cfg['grepcmd']                 = 'ps aux | grep "%s" | grep -v grep';
115unset($currentUser);
116
117/* default intl config */
118$cfg['date_default_timezone']   = 'Europe/Paris';
119$cfg['default_language']        = 'fr_FR';
120
121// activate debug mode here
122define('DEBUG', true);
123/**************************************** STOP EDITING HERE ****************************************/
124
125// OpenID
126$cfg['openIDUrl']               = 'http'.($cfg['httpsecure'] ? 's' : '').'://'.$cfg['url'];
127$cfg['openIDReturn']            = $cfg['surl'].'?do=verifyOpenID&try=1';
128
129// version
130$cfg['version']                 = '0.2.1';
131
132// CLI call ?
133define('CLI', 'cli' === PHP_SAPI);
134
135// REST call ?
136define('REST', isset($_SERVER['SCRIPT_FILENAME']) && basename($_SERVER['SCRIPT_FILENAME']) === 'rest.php');
137
138// AJAX call ?
139define('AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
140
141/**
142 * Defines classes autoloading
143 *
144 * @author Pierre-Alain Mignot <contact@openwebreader.org>
145 * @param string $c The classname to load
146 */
147spl_autoload_register(function($c)
148{
149    if(class_exists($c, false)) return true;
150
151    $ext = false;
152    $internal = false;
153
154    if(false === ($ns = strpos($c, '\\')) && false === ($ext = strpos($c, '_'))) return false;
155
156    $f = false;
157
158    if(false !== $ext)
159    { // external libraries
160        $f = HOME_PATH."libs".DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $c).'.php';
161        $fOpenID = HOME_PATH."libs".DIRECTORY_SEPARATOR."openID".DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $c).'.php';
162        if(!file_exists($f))
163        {
164            if(!file_exists($fOpenID))
165            {
166                return false;
167            }
168            $f = $fOpenID;
169        }
170    }
171    elseif(false !== $ns)
172    {
173        $f = PATH.str_replace('\\', DIRECTORY_SEPARATOR, str_replace('_', DIRECTORY_SEPARATOR, $c)).".php";
174    }
175    else
176    {
177        $f = HOME_PATH."libs".DIRECTORY_SEPARATOR.strtolower($c).".class.php";
178    }
179
180    if(!file_exists($f))
181    {
182        return false;
183    }
184
185    if(!include($f))
186    {
187        return false;
188    }
189
190    return class_exists($c, false);
191});
192
193Config::iGet($cfg); // init the config object
194// reset values from memory
195$cfg = null;
196unset($cfg);
197
198// we are set !
199define('INC_CONFIG', true);
Note: See TracBrowser for help on using the repository browser.