From d4c07930d51244c8ae5014344c9502d010954448 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Fri, 10 May 2013 06:13:24 -0400 Subject: add $db_port to .htconfig.php and $a->config['syste]['smarty3_folder'] for compiled templates --- boot.php | 2 +- include/dba/dba_driver.php | 16 +++++++++------- include/dba/dba_mysql.php | 4 ++-- include/dba/dba_mysqli.php | 4 ++-- include/friendica_smarty.php | 19 ++++++++++++++----- index.php | 4 ++-- install/htconfig.sample.php | 4 ++++ 7 files changed, 34 insertions(+), 19 deletions(-) mode change 100644 => 100755 include/dba/dba_driver.php mode change 100644 => 100755 include/dba/dba_mysql.php mode change 100644 => 100755 include/dba/dba_mysqli.php mode change 100644 => 100755 index.php mode change 100644 => 100755 install/htconfig.sample.php diff --git a/boot.php b/boot.php index cf45fed16..26dd8396f 100755 --- a/boot.php +++ b/boot.php @@ -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(); diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php old mode 100644 new mode 100755 index 1091b9632..abc759adc --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -1,15 +1,17 @@ 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); } diff --git a/include/dba/dba_mysql.php b/include/dba/dba_mysql.php old mode 100644 new mode 100755 index 05e19903d..f5a2a47ba --- a/include/dba/dba_mysql.php +++ b/include/dba/dba_mysql.php @@ -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; } diff --git a/include/dba/dba_mysqli.php b/include/dba/dba_mysqli.php old mode 100644 new mode 100755 index af9a2434e..9cb60cb8c --- a/include/dba/dba_mysqli.php +++ b/include/dba/dba_mysqli.php @@ -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; } diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php index a4675acd4..ec0748600 100755 --- a/include/friendica_smarty.php +++ b/include/friendica_smarty.php @@ -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 "ERROR: folder view/tpl/smarty3/ 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 "ERROR: folder $basecompiledirdoes not exixst."; killme(); + } + if(!is_writable($basecompiledir)){ + echo "ERROR: folder $basecompiledir must be writable by webserver."; killme(); } + $a->config['system']['smarty3_folder'] = $basecompiledir; } // ITemplateEngine interface diff --git a/index.php b/index.php old mode 100644 new mode 100755 index d8be14888..7e3fd0ef1 --- a/index.php +++ b/index.php @@ -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 diff --git a/install/htconfig.sample.php b/install/htconfig.sample.php old mode 100644 new mode 100755 index ebfc84543..77a0aa8a5 --- a/install/htconfig.sample.php +++ b/install/htconfig.sample.php @@ -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. -- cgit v1.2.3