Skip to content

Commit 94720e7

Browse files
committed
update fat free php framework version 3.0.8
1 parent 8411e6f commit 94720e7

File tree

19 files changed

+354
-133
lines changed

19 files changed

+354
-133
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Version 2.8-SNAPSHOT
5555
* improved Expires section and Compression in .htaccess (thanks a lot to S Anand)
5656
* make api item listing, tags and sources stats accessible for non loggedin users in public mode
5757
* replace file_get_content for icon fetching with curl based version for prevent allow_url_fopen problems
58+
* update fat free php framework version 3.0.8
5859

5960
Version 2.7
6061
* new spout for instapaper (thanks a lot to janeczku)

libs/f3/audit.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
//! Data validator
1717
class Audit extends Prefab {
1818

19+
//@{ User agents
20+
const
21+
UA_Mobile='android|blackberry|iphone|ipod|palm|windows\s+ce',
22+
UA_Desktop='bsd|linux|os\s+[x9]|solaris|windows',
23+
UA_Bot='bot|crawl|slurp|spider';
24+
//@}
25+
1926
/**
2027
* Return TRUE if string is a valid URL
2128
* @return bool
@@ -87,6 +94,26 @@ function ispublic($addr) {
8794
FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE);
8895
}
8996

97+
/**
98+
* Return TRUE if user agent is a desktop browser
99+
* @return bool
100+
**/
101+
function isdesktop() {
102+
$agent=Base::instance()->get('AGENT');
103+
return empty($agent) ||
104+
(!preg_match('/('.self::UA_Mobile.')/i',$agent) &&
105+
preg_match('/('.self::UA_Desktop.')/i',$agent) ||
106+
preg_match('/('.self::UA_Bot.')/i',$agent));
107+
}
108+
109+
/**
110+
* Return TRUE if user agent is a mobile device
111+
* @return bool
112+
**/
113+
function ismobile() {
114+
return !$this->isdesktop();
115+
}
116+
90117
/**
91118
* Return TRUE if specified ID has a valid (Luhn) Mod-10 check digit
92119
* @return bool
@@ -126,4 +153,17 @@ function card($id) {
126153
return FALSE;
127154
}
128155

156+
/**
157+
* Return entropy estimate of a password (NIST 800-63)
158+
* @return int
159+
* @param $str string
160+
**/
161+
function entropy($str) {
162+
$len=strlen($str);
163+
return 4*min($len,1)+($len>1?(2*(min($len,8)-1)):0)+
164+
($len>8?(1.5*(min($len,20)-8)):0)+($len>20?($len-20):0)+
165+
6*(bool)(preg_match(
166+
'/[A-Z].*?[0-9[:punct:]]|[0-9[:punct:]].*?[A-Z]/',$str));
167+
}
168+
129169
}

libs/f3/auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
//! Authorization/authentication plug-in
17-
class Auth extends Prefab {
17+
class Auth {
1818

1919
//@{ Error messages
2020
const

0 commit comments

Comments
 (0)