Merge pull request #2123 from MPOS/move-internals

[CLEANUP] Move internals
This commit is contained in:
Sebastian Grewe 2014-05-03 12:19:03 +02:00
commit 1c36de9729
572 changed files with 103 additions and 67 deletions

16
.gitignore vendored
View File

@ -1,12 +1,12 @@
# Local Config
/public/include/config/global.inc.php
/public/include/config/security.inc.php
/include/config/global.inc.php
/include/config/security.inc.php
# Templates
/public/templates/compile/*.php
/public/templates/compile/**
/public/templates/cache/*.php
/public/templates/cache/**
/templates/compile/*.php
/templates/compile/**
/templates/cache/*.php
/templates/cache/**
# Logs
/cronjobs/logs
@ -14,8 +14,8 @@
/logs/*
# Test configs
public/include/config/global.inc.scrypt.php
public/include/config/global.inc.sha.php
/include/config/global.inc.scrypt.php
/include/config/global.inc.sha.php
# IDE Settings
/.idea/*

View File

@ -1,3 +1,10 @@
ErrorDocument 404 /public/index.php?page=error&action=404
RedirectMatch 404 /logs(/|$)
Options -Indexes
RedirectMatch 404 /templtes(/|$)
RedirectMatch 404 /include(/|$)
RedirectMatch 404 /scripts(/|$)
RedirectMatch 404 /sql(/|$)
RedirectMatch 404 /upgrade(/|$)
RedirectMatch 404 /cronjobs(/|$)
RedirectMatch 404 /tests(/|$)
Options -Indexes

View File

@ -1 +0,0 @@
Logging directory for cronjobs.

View File

@ -35,7 +35,7 @@ if (SECHASH_CHECK) {
// MODIFY THIS
// We need to find our include files so set this properly
define("BASEPATH", "../public/");
define("BASEPATH", dirname(__FILE__) . "/");
/*****************************************************
* No need to change beyond this point *
@ -48,14 +48,8 @@ $dStartTime = microtime(true);
$cron_name = basename($_SERVER['PHP_SELF'], '.php');
// Include our configuration (holding defines for the requires)
require_once(BASEPATH . 'include/config/global.inc.dist.php');
require_once(BASEPATH . 'include/config/global.inc.php');
require_once(BASEPATH . 'include/config/security.inc.dist.php');
@include_once(BASEPATH . 'include/config/security.inc.php');
require_once(BASEPATH . 'include/bootstrap.php');
require_once(BASEPATH . 'include/version.inc.php');
require_once(BASEPATH . '../include/bootstrap.php');
require_once(BASEPATH . '../include/version.inc.php');
// Command line switches
array_shift($argv);
@ -69,7 +63,7 @@ foreach ($argv as $option) {
}
// Load 3rd party logging library for running crons
$log = KLogger::instance( 'logs/' . $cron_name, KLogger::INFO );
$log = KLogger::instance( BASEPATH . '../logs/' . $cron_name, KLogger::INFO );
$log->LogDebug('Starting ' . $cron_name);
// Load the start time for later runtime calculations for monitoring

View File

@ -53,10 +53,10 @@ if (@$_SESSION['USERDATA']['is_admin'] && $user->isAdmin(@$_SESSION['USERDATA'][
}
// check if we can write templates/cache and templates/compile -> error
if (!is_writable(THEME_DIR.'/cache')) {
if (!is_writable(TEMPLATE_DIR . '/cache')) {
$error[] = "templates/cache folder is not writable for uid {$apache_user['name']}";
}
if (!is_writable(THEME_DIR.'/compile')) {
if (!is_writable(TEMPLATE_DIR . '/compile')) {
$error[] = "templates/compile folder is not writable for uid {$apache_user['name']}";
}

View File

@ -3,20 +3,20 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
// Used for performance calculations
$dStartTime = microtime(true);
define('INCLUDE_DIR', BASEPATH . 'include');
define('INCLUDE_DIR', BASEPATH . '../include');
define('CLASS_DIR', INCLUDE_DIR . '/classes');
define('PAGES_DIR', INCLUDE_DIR . '/pages');
define('THEME_DIR', BASEPATH . 'templates');
define('TEMPLATE_DIR', BASEPATH . '../templates');
$quickstartlink = "<a href='https://github.com/MPOS/php-mpos/wiki/Quick-Start-Guide' title='MPOS Quick Start Guide'>Quick Start Guide</a>";
// Include our configuration (holding defines for the requires)
if (!include_once(BASEPATH . 'include/config/global.inc.dist.php')) die('Unable to load base global config from ['.BASEPATH . 'include/config/global.inc.dist.php' . '] - '.$quickstartlink);
if (!@include_once(BASEPATH . 'include/config/global.inc.php')) die('Unable to load your global config from ['.BASEPATH . 'include/config/global.inc.php' . '] - '.$quickstartlink);
if (!include_once(INCLUDE_DIR . '/config/global.inc.dist.php')) die('Unable to load base global config from ['.INCLUDE_DIR. '/config/global.inc.dist.php' . '] - '.$quickstartlink);
if (!@include_once(INCLUDE_DIR . '/config/global.inc.php')) die('Unable to load your global config from ['.INCLUDE_DIR. '/config/global.inc.php' . '] - '.$quickstartlink);
// load our security configs
if (!include_once(BASEPATH . 'include/config/security.inc.dist.php')) die('Unable to load base security config from ['.BASEPATH . 'include/config/security.inc.dist.php' . '] - '.$quickstartlink);
if (@file_exists(BASEPATH . 'include/config/security.inc.php')) include_once(BASEPATH . 'include/config/security.inc.php');
if (!include_once(INCLUDE_DIR . '/config/security.inc.dist.php')) die('Unable to load base security config from ['.INCLUDE_DIR. '/config/security.inc.dist.php' . '] - '.$quickstartlink);
if (@file_exists(INCLUDE_DIR . '/config/security.inc.php')) include_once(INCLUDE_DIR . '/config/security.inc.php');
// start our session, we need it for smarty caching
session_set_cookie_params(time()+$config['cookie']['duration'], $config['cookie']['path'], $config['cookie']['domain'], $config['cookie']['secure'], $config['cookie']['httponly']);

View File

@ -5,7 +5,7 @@ class Logger {
private $logging = false;
public function __construct($config) {
if ($config['logging']['enabled'] && $config['logging']['level'] > 0) {
$this->KLogger = KLogger::instance($config['logging']['path'], $config['logging']['level']);
$this->KLogger = KLogger::instance($config['logging']['path'] . '/website', $config['logging']['level']);
$this->logging = true;
$this->floatStartTime = microtime(true);
}

View File

@ -74,8 +74,8 @@ class Mail extends Base {
}
// Prepare the smarty templates used
$this->smarty->clearCache(BASEPATH . 'templates/mail/' . $template . '.tpl');
$this->smarty->clearCache(BASEPATH . 'templates/mail/subject.tpl');
$this->smarty->clearCache(TEMPLATE_DIR . '/mail/' . $template . '.tpl');
$this->smarty->clearCache(TEMPLATE_DIR . '/mail/subject.tpl');
$this->smarty->assign('WEBSITENAME', $this->setting->getValue('website_name'));
$this->smarty->assign('SUBJECT', $aData['subject']);
$this->smarty->assign('DATA', $aData);
@ -84,12 +84,12 @@ class Mail extends Base {
$senderEmail = $this->setting->getValue('website_email', 'test@example.com');
$senderName = $this->setting->getValue('website_name', 'test@example.com');
$message = Swift_Message::newInstance()
->setSubject($this->smarty->fetch(BASEPATH . 'templates/mail/subject.tpl'))
->setSubject($this->smarty->fetch(TEMPLATE_DIR . '/mail/subject.tpl'))
->setFrom(array( $senderEmail => $senderName))
->setTo($aData['email'])
->setSender($senderEmail)
->setReturnPath($senderEmail)
->setBody($this->smarty->fetch(BASEPATH . 'templates/mail/' . $template . '.tpl'), 'text/html');
->setBody($this->smarty->fetch(TEMPLATE_DIR . '/mail/' . $template . '.tpl'), 'text/html');
if (isset($aData['senderName']) &&
isset($aData['senderEmail']) &&
strlen($aData['senderName']) > 0 &&

View File

@ -17,13 +17,13 @@ class Template extends Base {
/**
* Get all available themes
* Read theme folders from THEME_DIR
* Read theme folders from TEMPLATE_DIR
*
* @return array - list of available themes
*/
public function getThemes() {
$this->debug->append("STA " . __METHOD__, 4);
$aTmpThemes = glob(THEME_DIR . '/*');
$aTmpThemes = glob(TEMPLATE_DIR . '/*');
$aThemes = array();
foreach ($aTmpThemes as $dir) {
if (basename($dir) != 'cache' && basename($dir) != 'compile' && basename($dir) != 'mail') $aThemes[basename($dir)] = basename($dir);
@ -86,12 +86,12 @@ class Template extends Base {
/**
* Return the content of specific template file
*
* @param $file - file of template related to THEME_DIR
* @param $file - file of template related to TEMPLATE_DIR
* @return string - content of the template file
*/
public function getTemplateContent($file) {
$this->debug->append("STA " . __METHOD__, 4);
$filepath = THEME_DIR . '/' . $file;
$filepath = TEMPLATE_DIR . '/' . $file;
return file_get_contents($filepath);
}
@ -103,7 +103,7 @@ class Template extends Base {
*/
public function getTemplateFiles($theme) {
$this->debug->append("STA " . __METHOD__, 4);
$folder = THEME_DIR . '/' . $theme;
$folder = TEMPLATE_DIR . '/' . $theme;
$dir = new RecursiveDirectoryIterator($folder);
$ite = new RecursiveIteratorIterator($dir);
@ -130,7 +130,7 @@ class Template extends Base {
$templates = array();
foreach($themes as $theme) {
$templates[$theme] = $this->_getTemplatesTreeRecursive(THEME_DIR . '/' . $theme);
$templates[$theme] = $this->_getTemplatesTreeRecursive(TEMPLATE_DIR . '/' . $theme);
}
return $templates;

Some files were not shown because too many files have changed in this diff Show More