Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated Url module to use SERVER_NAME instead of HTTP_HOST and added …

…more permission checks to Log module before writing files.
  • Loading branch information...
commit 638508d15d02f4937a7e678ac0df0eab504c1971 1 parent 9639882
@geekforbrains authored
View
8 README.md
@@ -1,4 +1,4 @@
-Caffeine 1.0.1
+Caffeine 1.0.2
==============
A simple PHP framework that combines modules through the use of routes and events to form an application.
@@ -122,5 +122,11 @@ Gavin Vickery
Change Log
----------
+1.0.2
+
+- Updated Url module to use SERVER_NAME instead of HTTP_HOST to determine current host.
+- Updated Log module to ensure the files and log directory is writable before creating file.
+
1.0.1
+
- Updated getBaseHref method in View module to return full url.
View
16 core/log/log.php
@@ -98,12 +98,26 @@ private static function _log($type, $module, $message)
private static function _writeLog($type, $module, $message)
{
$logFile = ROOT . Media::getFilesPath() . Config::get(sprintf('log.%s_file', $type));
+ $logDir = implode('/', explode('/', $logFile, -1));
+
+ if(!file_exists($logDir))
+ {
+ $filesPath = ROOT . Media::getFilesPath();
+
+ if(is_writable($filesPath))
+ mkdir($logDir);
+ else
+ die('Unable to create log directory because your files directory isn\'t writable.');
+ }
+
+ if(!is_writable($logDir))
+ die('Unable to write log file because your log directory isn\'t writable.');
if(!file_exists($logFile))
{
$header = "<?php if(!defined('ROOT')) exit; ?>\n";
- if(!$handle = fopen($logFile, 'w'))
+ if(!$handle = fopen($logFile, 'a'))
die('Cant create log file: ' . $logFile);
if(fwrite($handle, $header) === false)
View
4 core/log/setup.php
@@ -5,14 +5,14 @@
* When enabled (true) all messages logged with the Log::debug() method will
* either be displayed in the browser or written to file (see log.debug_to_file config).
*/
- 'log.debug_enabled' => false,
+ 'log.debug_enabled' => true,
/**
* When enabled, messages logged with the Log::debug() method will be saved to a
* file instead of being output to the browser. Note that log.debug_enabled must
* be set to "true" as well.
*/
- 'log.debug_to_file' => false,
+ 'log.debug_to_file' => true,
/**
* The debug log file, relative to the current sites "files/" directory, that debug
View
2  core/url/url.php
@@ -49,7 +49,7 @@ public static function scheme()
public static function host()
{
if(is_null(self::$_host))
- self::$_host = $_SERVER['HTTP_HOST'];
+ self::$_host = $_SERVER['SERVER_NAME'];
return self::$_host;
}
View
6 index.php
@@ -6,8 +6,8 @@
* A simple PHP framework that combines modules through the use of routes and
* events to form an application.
*
- * @version 1.0.1
- * @date 2012-03-22
+ * @version 1.0.2
+ * @date 2012-03-24
* @author Gavin Vickery <gavin@geekforbrains.com>
* @license http://www.opensource.org/licenses/mit-license.php
*/
@@ -178,7 +178,7 @@ private static function _isErrorResponse($response)
*/
define('ROOT', __DIR__ . '/');
define('EXT', '.php');
-define('VERSION', '1.0.1');
+define('VERSION', '1.0.2');
define('IS_CLI', defined('CLI'));
/**
View
1  sites/default/views/includes/header.php
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
+ <base href="<?= View::getBaseHref(); ?>" />
<title><?= View::getTitle('Caffeine', null, ' - Caffeine'); ?></title>
</head>
<body>
View
2  sites/default/views/index.php
@@ -4,6 +4,6 @@
<p>Caffeine is a simple PHP framework that combines modules through the use of routes and events to form an application.</p>
-<p><a href="http://github.com/geekforbrains/caffeine" target="_blank">Caffeine on GitHub</a></p>
+<p><?= Html::a('Caffeine on Github', 'http://github.com/geekforbrains/caffeine', array('target' => '_blank')); ?></p>
<? View::insert('includes/footer'); ?>
Please sign in to comment.
Something went wrong with that request. Please try again.