Merge pull request #51 from fabrixxm/settings

add some settings:
This commit is contained in:
friendica 2013-05-10 03:32:42 -07:00
commit c6662e3574
7 changed files with 34 additions and 19 deletions

View file

@ -582,7 +582,7 @@ class App {
date_default_timezone_set($this->timezone);
$this->config = array();
$this->config = array('system'=>array());
$this->page = array();
$this->pager= array();

16
include/dba/dba_driver.php Normal file → Executable file
View file

@ -1,15 +1,17 @@
<?php /** @file */
function dba_factory($server,$user,$pass,$db,$install = false) {
function dba_factory($server, $port,$user,$pass,$db,$install = false) {
$dba = null;
if(class_exists('mysqli')) {
if (is_null($port)) $port = ini_get("mysqli.default_port");
require_once('include/dba/dba_mysqli.php');
$dba = new dba_mysqli($server,$user,$pass,$db,$install);
$dba = new dba_mysqli($server, $port,$user,$pass,$db,$install);
}
else {
if (is_null($port)) $port = "3306";
require_once('include/dba/dba_mysql.php');
$dba = new dba_mysql($server,$user,$pass,$db,$install);
$dba = new dba_mysql($server, $port,$user,$pass,$db,$install);
}
return $dba;
@ -23,16 +25,16 @@ abstract class dba_driver {
public $connected = false;
public $error = false;
abstract function connect($server,$user,$pass,$db);
abstract function connect($server, $port, $user,$pass,$db);
abstract function q($sql);
abstract function escape($str);
abstract function close();
function __construct($server,$user,$pass,$db,$install = false) {
if(($install) && (! $this->install($server,$user,$pass,$db))) {
function __construct($server, $port, $user,$pass,$db,$install = false) {
if(($install) && (! $this->install($server, $port, $user,$pass,$db))) {
return;
}
$this->connect($server,$user,$pass,$db);
$this->connect($server, $port, $user,$pass,$db);
}

4
include/dba/dba_mysql.php Normal file → Executable file
View file

@ -5,8 +5,8 @@ require_once('include/dba/dba_driver.php');
class dba_mysql extends dba_driver {
function connect($server,$user,$pass,$db) {
$this->db = mysql_connect($server,$user,$pass);
function connect($server, $port, $user,$pass,$db) {
$this->db = mysql_connect($server.":".$port,$user,$pass);
if($this->db && mysql_select_db($db,$this->db)) {
$this->connected = true;
}

4
include/dba/dba_mysqli.php Normal file → Executable file
View file

@ -4,8 +4,8 @@ require_once('include/dba/dba_driver.php');
class dba_mysqli extends dba_driver {
function connect($server,$user,$pass,$db) {
$this->db = new mysqli($server,$user,$pass,$db);
function connect($server, $port, $user,$pass,$db) {
$this->db = new mysqli($server,$user,$pass,$db, $port);
if(! mysqli_connect_errno()) {
$this->connected = true;
}

View file

@ -21,9 +21,11 @@ class FriendicaSmarty extends Smarty {
$template_dirs = $template_dirs + array('base' => 'view/tpl/');
$this->setTemplateDir($template_dirs);
$this->setCompileDir('view/tpl/smarty3/compiled/');
$this->setConfigDir('view/tpl/smarty3/config/');
$this->setCacheDir('view/tpl/smarty3/cache/');
$basecompiledir = $a->config['system']['smarty3_folder'];
$this->setCompileDir($basecompiledir.'/compiled/');
$this->setConfigDir($basecompiledir.'/config/');
$this->setCacheDir($basecompiledir.'/cache/');
$this->left_delimiter = $a->get_template_ldelim('smarty3');
$this->right_delimiter = $a->get_template_rdelim('smarty3');
@ -46,9 +48,16 @@ class FriendicaSmartyEngine implements ITemplateEngine {
static $name ="smarty3";
public function __construct(){
if(!is_writable('view/tpl/smarty3/')){
echo "<b>ERROR:</b> folder <tt>view/tpl/smarty3/</tt> must be writable by webserver."; killme();
$a = get_app();
$basecompiledir = $a->config['system']['smarty3_folder'];
if (!$basecompiledir) $basecompiledir = dirname(__dir__)."/view/tpl/smarty3";
if (!is_dir($basecompiledir)) {
echo "<b>ERROR:</b> folder <tt>$basecompiledir</tt>does not exixst."; killme();
}
if(!is_writable($basecompiledir)){
echo "<b>ERROR:</b> folder <tt>$basecompiledir</tt> must be writable by webserver."; killme();
}
$a->config['system']['smarty3_folder'] = $basecompiledir;
}
// ITemplateEngine interface

4
index.php Normal file → Executable file
View file

@ -39,8 +39,8 @@ $a->language = get_best_language();
require_once("include/dba/dba_driver.php");
if(! $install) {
$db = dba_factory($db_host, $db_user, $db_pass, $db_data, $install);
unset($db_host, $db_user, $db_pass, $db_data);
$db = dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $install);
unset($db_host, $db_port, $db_user, $db_pass, $db_data);
/**
* Load configs from db. Overwrite configs from .htconfig.php

4
install/htconfig.sample.php Normal file → Executable file
View file

@ -13,10 +13,14 @@
// Then set the following for your MySQL installation
$db_host = 'your.mysqlhost.com';
$db_port = null; #leave null for default or set your port
$db_user = 'mysqlusername';
$db_pass = 'mysqlpassword';
$db_data = 'mysqldatabasename';
// smarty3 compile dir. make sure is writable by webserver
$a->config['system']['smarty3_folder'] = "view/tpl/smart3";
// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
// It can be changed later and only applies to timestamps for anonymous viewers.