Skip to content

Commit

Permalink
3.6.2-Release
Browse files Browse the repository at this point in the history
  • Loading branch information
ikkez committed Jun 26, 2017
1 parent 835f536 commit e9aec87
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 90 deletions.
40 changes: 33 additions & 7 deletions lib/CHANGELOG → lib/CHANGELOG.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
CHANGELOG

3.6.2 (26 June 2017)
* Return a status code > 0 when dying on error [#220](https://github.com/bcosca/fatfree-core/issues/220)
* fix SMTP line width [#215](https://github.com/bcosca/fatfree-core/issues/215)
* Allow using a custom field for ldap user id checking [#217](https://github.com/bcosca/fatfree-core/issues/217)
* NEW: DB\SQL->exists: generic method to check if SQL table exists
* Pass handler to route handler and hooks [#1035](https://github.com/bcosca/fatfree/issues/1035)
* pass carriage return of multiline dictionary keys
* Better Web->slug customization
* fix incorrect header issue [#211](https://github.com/bcosca/fatfree-core/issues/211)
* fix schema issue on databases with case-sensitive collation, fixes [#209](https://github.com/bcosca/fatfree-core/issues/209)
* Add filter for deriving C-locale equivalent of a number
* Bug fix: @LANGUAGE remains unchanged after override
* abort: added Header pre-check
* Assemble URL after ONREROUTE
* Add reroute argument to skip script termination
* Invoke ONREROUTE after headers are sent
* SQLite switch to backtick as quote
* Bug fix: Incorrect timing in SQL query logs
* DB\SQL\Mapper: Cast return value of count to integer
* Patched $_SERVER['REQUEST_URI'] to ensure it contains a relative URI
* Tweak debug verbosity
* fix php carriage return issue in preview->build [#205](https://github.com/bcosca/fatfree-core/pull/205)
* fixed template string resolution [#205](https://github.com/bcosca/fatfree-core/pull/205)
* Fixed unexpected default seed on CACHE set [#1028](https://github.com/bcosca/fatfree/issues/1028)
* DB\SQL\Mapper: Optimized field escaping on options
* Optimize template conversion to PHP file

3.6.1 (2 April 2017)
* NEW: Recaptcha plugin (#194)
* NEW: Recaptcha plugin [#194](https://github.com/bcosca/fatfree-core/pull/194)
* NEW: MB variable for detecting multibyte support
* NEW: DB\SQL: Cache parsed schema for the TTL duration
* NEW: quick erase flag on Jig/Mongo/SQL mappers (#193)
* NEW: Allow OPTIONS method to return a response body (#171)
* NEW: quick erase flag on Jig/Mongo/SQL mappers [#193](https://github.com/bcosca/fatfree-core/pull/193)
* NEW: Allow OPTIONS method to return a response body [#171](https://github.com/bcosca/fatfree-core/pull/171)
* NEW: Add support for Memcached (bcosca/fatfree#997)
* NEW: Rudimentary preload resource (HTTP2 server) support via template push()
* NEW: Add support for new MongoDB driver (#177)
* NEW: Add support for new MongoDB driver [#177](https://github.com/bcosca/fatfree-core/pull/177)
* Changed: template filter are all lowercase now
* Changed: Fix template lookup inconsistency: removed base dir from UI on render
* Changed: count() method now has an options argument (#192)
* Changed: count() method now has an options argument [#192](https://github.com/bcosca/fatfree-core/pull/192)
* Changed: SMTP, Spit out error message if any
* \DB\SQL\Mapper: refactored row count strategy
* DB\SQL\Mapper: Allow non-scalar values to be assigned as mapper property
* DB\SQL::PARAM_FLOAT: remove cast to float (#106 and bcosca/fatfree#984) (#191)
* DB\SQL\mapper->erase: allow empty string
* DB\SQL\mapper->insert: fields reset after successful INSERT
* Add option to debounce Cursor->paginate subset (#195)
* Add option to debounce Cursor->paginate subset [#195](https://github.com/bcosca/fatfree-core/pull/195)
* View: Don't delete sandboxed variables (#198)
* Preview: Optimize compilation of template expressions
* Preview: Use shorthand tag for direct rendering
Expand Down Expand Up @@ -56,7 +83,6 @@ CHANGELOG
* Bug fix: locales order and charset hyphen
* Bug fix: base stripped twice in router (#176)


3.6.0 (19 November 2016)
* NEW: [cli] request type
* NEW: console-friendly CLI mode
Expand Down
4 changes: 2 additions & 2 deletions lib/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ protected function _ldap($id,$pw) {
ldap_set_option($dc,LDAP_OPT_REFERRALS,0) &&
ldap_bind($dc,$this->args['rdn'],$this->args['pw']) &&
($result=ldap_search($dc,$this->args['base_dn'],
'uid='.$id)) &&
$this->args['uid'].'='.$id)) &&
ldap_count_entries($dc,$result) &&
($info=ldap_get_entries($dc,$result)) &&
@ldap_bind($dc,$info[0]['dn'],$pw) &&
@ldap_close($dc)) {
return $info[0]['uid'][0]==$id;
return $info[0][$this->args['uid']][0]==$id;
}
user_error(self::E_LDAP,E_USER_ERROR);
}
Expand Down
117 changes: 73 additions & 44 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class Base extends Prefab implements ArrayAccess {
//@{ Framework details
const
PACKAGE='Fat-Free Framework',
VERSION='3.6.1-Release';
VERSION='3.6.2-Release';
//@}

//@{ HTTP status codes (RFC 2616)
Expand Down Expand Up @@ -351,7 +351,7 @@ function set($key,$val,$ttl=0) {
}
else switch ($key) {
case 'CACHE':
$val=Cache::instance()->load($val,TRUE);
$val=Cache::instance()->load($val);
break;
case 'ENCODING':
ini_set('default_charset',$val);
Expand Down Expand Up @@ -1000,7 +1000,7 @@ function language($code) {
$locales[]=$locale;
}
setlocale(LC_ALL,$locales);
return implode(',',$this->languages);
return $this->hive['LANGUAGE']=implode(',',$this->languages);
}

/**
Expand Down Expand Up @@ -1038,7 +1038,7 @@ function lexicon($path,$ttl=0) {
elseif (!array_key_exists(
$key=$prefix.$match['lval'],$lex))
$lex[$key]=trim(preg_replace(
'/\\\\\h*\r?\n/','',$match['rval']));
'/\\\\\h*\r?\n/',"\n",$match['rval']));
}
}
if ($ttl)
Expand Down Expand Up @@ -1171,8 +1171,8 @@ function trace(array $trace=NULL,$format=TRUE) {
$trace,
function($frame) use($debug) {
return isset($frame['file']) &&
($debug>2 ||
($frame['file']!=__FILE__ || $debug>1) &&
($debug>1 ||
($frame['file']!=__FILE__ || $debug) &&
(empty($frame['function']) ||
!preg_match('/^(?:(?:trigger|user)_error|'.
'__call|call_user_func)/',$frame['function'])));
Expand Down Expand Up @@ -1255,7 +1255,7 @@ function error($code,$text='',array $trace=NULL,$level=0) {
'</body>'.$eol.
'</html>');
if ($this->hive['HALT'])
die;
die(1);
}

/**
Expand Down Expand Up @@ -1365,8 +1365,9 @@ function route($pattern,$handler,$ttl=0,$kbps=0) {
* @return NULL
* @param $url array|string
* @param $permanent bool
* @param $die bool
**/
function reroute($url=NULL,$permanent=FALSE) {
function reroute($url=NULL,$permanent=FALSE,$die=TRUE) {
if (!$url)
$url=$this->hive['REALM'];
if (is_array($url))
Expand All @@ -1386,12 +1387,14 @@ function reroute($url=NULL,$permanent=FALSE) {
$url=$this->hive['SCHEME'].'://'.
$this->hive['HOST'].$port.$this->hive['BASE'].$url;
}
if (!$this->hive['CLI']) {
if ($this->hive['CLI'])
$this->mock('GET '.$url.' [cli]');
else {
header('Location: '.$url);
$this->status($permanent?301:302);
die;
if ($die)
die;
}
$this->mock('GET '.$url.' [cli]');
}

/**
Expand Down Expand Up @@ -1605,7 +1608,7 @@ function($id) use($args) {
$this->hive['BODY']=file_get_contents('php://input');
ob_start();
// Call route handler
$result=$this->call($handler,[$this,$args],
$result=$this->call($handler,[$this,$args,$handler],
'beforeroute,afterroute');
$body=ob_get_clean();
if (isset($cache) && !error_get_last()) {
Expand Down Expand Up @@ -1705,12 +1708,13 @@ function until($func,$args=NULL,$timeout=60) {
function abort() {
if (!headers_sent() && session_status()!=PHP_SESSION_ACTIVE)
session_start();
session_commit();
$out='';
while (ob_get_level())
$out=ob_get_clean().$out;
header('Content-Encoding: none');
header('Content-Length: '.strlen($out));
header('Connection: close');
session_commit();
echo $out;
flush();
if (function_exists('fastcgi_finish_request'))
Expand Down Expand Up @@ -2246,6 +2250,9 @@ function($level,$text,$file,$line) {
dirname($_SERVER['SCRIPT_NAME'])),'/');
$uri=parse_url((preg_match('/^\w+:\/\//',$_SERVER['REQUEST_URI'])?'':
'//'.$_SERVER['SERVER_NAME']).$_SERVER['REQUEST_URI']);
$_SERVER['REQUEST_URI']=$uri['path'].
(isset($uri['query'])?'?'.$uri['query']:'').
(isset($uri['fragment'])?'#'.$uri['fragment']:'');
$path=preg_replace('/^'.preg_quote($base,'/').'/','',$uri['path']);
session_cache_limiter('');
call_user_func_array('session_set_cookie_params',
Expand Down Expand Up @@ -2683,9 +2690,9 @@ protected function sandbox(array $hive=NULL,$mime=NULL) {
$hive=$fw->hive();
}
if ($this->level<1 || $implicit) {
if (!$fw->CLI && !headers_sent() &&
if (!$fw->CLI && $mime && !headers_sent() &&
!preg_grep ('/^Content-Type:/',headers_list()))
header('Content-Type: '.($mime?:'text/html').'; '.
header('Content-Type: '.$mime.'; '.
'charset='.$fw->ENCODING);
if ($fw->ESCAPE)
$hive=$this->esc($hive);
Expand All @@ -2711,7 +2718,7 @@ protected function sandbox(array $hive=NULL,$mime=NULL) {
* @param $hive array
* @param $ttl int
**/
function render($file,$mime=NULL,array $hive=NULL,$ttl=0) {
function render($file,$mime='text/html',array $hive=NULL,$ttl=0) {
$fw=Base::instance();
$cache=Cache::instance();
if ($cache->exists($hash=$fw->hash($file),$data))
Expand Down Expand Up @@ -2749,12 +2756,27 @@ class Preview extends View {
protected
//! token filter
$filter=[
'c'=>'$this->c',
'esc'=>'$this->esc',
'raw'=>'$this->raw',
'alias'=>'Base::instance()->alias',
'format'=>'Base::instance()->format'
];

/**
* Return C-locale equivalent of number
* @return string
* @param $val int|float
**/
function c($val) {
$fw=Base::instance();
$locale=setlocale(LC_NUMERIC,0);
setlocale(LC_NUMERIC,'C');
$out=(string)(float)$val;
$locale=setlocale(LC_NUMERIC,$locale);
return $out;
}

/**
* Convert token to variable
* @return string
Expand Down Expand Up @@ -2797,47 +2819,48 @@ function filter($key=NULL,$func=NULL) {
**/
protected function build($node) {
return preg_replace_callback(
'/\{\-(.+?)\-\}|\{\{(.+?)\}\}(\n*)/s',
'/\{~(.+?)~\}|\{\*(.+?)\*\}|\{\-(.+?)\-\}|'.
'\{\{(.+?)\}\}((?:\r?\n)*)/s',
function($expr) {
if ($expr[1])
return $expr[1];
$str='<?= '.trim($this->token($expr[2])).' ?>';
if (isset($expr[3]))
$str.=$expr[3];
$str='<?php '.$this->token($expr[1]).' ?>';
elseif ($expr[2])
return '';
elseif ($expr[3])
$str=$expr[3];
else {
$str='<?= '.trim($this->token($expr[4])).
(!empty($expr[5])?'.PHP_EOL':'').' ?>';
if (isset($expr[5]))
$str.=$expr[5];
}
return $str;
},
preg_replace_callback(
'/\{~(.+?)~\}/s',
function($expr) {
return '<?php '.$this->token($expr[1]).' ?>';
},
$node
)
$node
);
}
/**
* Render template string
* @return string
* @param $str string
* @param $node string|array
* @param $hive array
* @param $ttl int
* @param $persist bool
**/
function resolve($str,array $hive=NULL,$ttl=0,$persist=FALSE) {
function resolve($node,array $hive=NULL,$ttl=0,$persist=FALSE) {
$fw=Base::instance();
$cache=Cache::instance();
if ($ttl && $cache->exists($hash=$fw->hash($str),$data))
if ($ttl || $persist)
$hash=$fw->hash($fw->serialize($node));
if ($ttl && $cache->exists($hash,$data))
return $data;
// Remove PHP code and comments
$text=preg_replace(
'/\h*<\?(?!xml)(?:php|\s*=)?.+?\?>\h*|\{\*.+?\*\}/is','',$str);
if ($persist) {
if (!is_dir($tmp=$fw->TEMP))
mkdir($tmp,Base::MODE,TRUE);
if (!is_file($this->file=($tmp.
$fw->SEED.'.'.$hash.'.php')))
$fw->write($this->file,$this->build($text));
$fw->write($this->file,$this->build($node));
if (isset($_COOKIE[session_name()]) &&
!headers_sent() && session_status()!=PHP_SESSION_ACTIVE)
session_start();
Expand All @@ -2852,14 +2875,26 @@ function resolve($str,array $hive=NULL,$ttl=0,$persist=FALSE) {
extract($hive);
unset($hive);
ob_start();
eval(' ?>'.$this->build($text).'<?php ');
eval(' ?>'.$this->build($node).'<?php ');
$data=ob_get_clean();
}
if ($ttl)
$cache->set($hash,$data,$ttl);
return $data;
}

/**
* Parse template string
* @return string
* @param $text string
**/
function parse($text) {
// Remove PHP code and comments
return preg_replace(
'/\h*<\?(?!xml)(?:php|\s*=)?.+?\?>\h*|'.
'\{\*.+?\*\}/is','', $text);
}

/**
* Render template
* @return string
Expand All @@ -2868,7 +2903,7 @@ function resolve($str,array $hive=NULL,$ttl=0,$persist=FALSE) {
* @param $hive array
* @param $ttl int
**/
function render($file,$mime=NULL,array $hive=NULL,$ttl=0) {
function render($file,$mime='text/html',array $hive=NULL,$ttl=0) {
$fw=Base::instance();
$cache=Cache::instance();
if (!is_dir($tmp=$fw->TEMP))
Expand All @@ -2880,13 +2915,7 @@ function render($file,$mime=NULL,array $hive=NULL,$ttl=0) {
if (!is_file($this->file=($tmp.
$fw->SEED.'.'.$fw->hash($view).'.php')) ||
filemtime($this->file)<filemtime($view)) {
// Remove PHP code and comments
$text=preg_replace(
'/\h*<\?(?!xml)(?:php|\s*=)?.+?\?>\h*|'.
'\{\*.+?\*\}/is','',
$fw->read($view));
if (method_exists($this,'parse'))
$text=$this->parse($text);
$text=$this->parse($fw->read($view));
$fw->write($this->file,$this->build($text));
}
if (isset($_COOKIE[session_name()]) &&
Expand Down
Loading

0 comments on commit e9aec87

Please sign in to comment.