projects
/
platal.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prepare db migration.
[platal.git]
/
modules
/
search
/
classes.inc.php
diff --git
a/modules/search/classes.inc.php
b/modules/search/classes.inc.php
index
62a3ad7
..
d232f11
100644
(file)
--- a/
modules/search/classes.inc.php
+++ b/
modules/search/classes.inc.php
@@
-1,6
+1,6
@@
<?php
/***************************************************************************
<?php
/***************************************************************************
- * Copyright (C) 2003-20
09
Polytechnique.org *
+ * Copyright (C) 2003-20
10
Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
@@
-267,9
+267,9
@@
class QuickSearch extends SField
$s = replace_accent(trim($this->value));
$r = $s = str_replace('*','%',$s);
$s = replace_accent(trim($this->value));
$r = $s = str_replace('*','%',$s);
- if (S::
has_perms
() && strpos($s, '@') !== false) {
+ if (S::
admin
() && strpos($s, '@') !== false) {
$this->email = $s;
$this->email = $s;
- } else if (S::
has_perms
() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) {
+ } else if (S::
admin
() && preg_match('/[0-9]+\.([0-9]+|%)\.([0-9]+|%)\.([0-9]+|%)/', $s)) {
$this->ip = $s;
}
if ($this->email || $this->ip) {
$this->ip = $s;
}
if ($this->email || $this->ip) {
@@
-342,7
+342,14
@@
class QuickSearch extends SField
}
if (!empty($this->ip)) {
$ip = ip_to_uint($this->ip);
}
if (!empty($this->ip)) {
$ip = ip_to_uint($this->ip);
- $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip ) AND ls.suid = 0";
+
+ // If the IP address requested for the search cannot be translated,
+ // the predicate should always be valued to false.
+ if ($ip != null) {
+ $where[] = "( ls.ip = $ip OR ls.forward_ip = $ip ) AND ls.suid = 0";
+ } else {
+ $where[] = "false";
+ }
}
if (!empty($this->phone)){
require_once("profil.func.inc.php");
}
if (!empty($this->phone)){
require_once("profil.func.inc.php");
@@
-372,7
+379,7
@@
class QuickSearch extends SField
$join .= "LEFT JOIN emails AS ems ON (ems.uid = u.user_id)";
}
if (!empty($this->ip)) {
$join .= "LEFT JOIN emails AS ems ON (ems.uid = u.user_id)";
}
if (!empty($this->ip)) {
- $join .= "INNER JOIN log
ger.
sessions AS ls ON (ls.uid = u.user_id)\n";
+ $join .= "INNER JOIN log
_
sessions AS ls ON (ls.uid = u.user_id)\n";
}
if (!empty($this->phone)) {
if (!S::logged()) {
}
if (!empty($this->phone)) {
if (!S::logged()) {
@@
-482,7
+489,7
@@
class RefSField extends SField
function too_large()
{
function too_large()
{
- return ($this->value
==
'');
+ return ($this->value
==
'');
}
// }}}
}
// }}}
@@
-643,7
+650,7
@@
class StringSField extends SField
* imposées par l'utilisateur) */
function length()
{
* imposées par l'utilisateur) */
function length()
{
- $cleaned =
replace_accent(strtolower
($this->value));
+ $cleaned =
strtolower(replace_accent
($this->value));
$length = strlen(ereg_replace('[a-z0-9]', '', $cleaned));
return strlen($this->value) - $length;
}
$length = strlen(ereg_replace('[a-z0-9]', '', $cleaned));
return strlen($this->value) - $length;
}
@@
-653,7
+660,7
@@
class StringSField extends SField
function too_large()
{
function too_large()
{
- return ($this->length()
<
2);
+ return ($this->length()
<
2);
}
// }}}
}
// }}}
@@
-839,11
+846,14
@@
class SFieldGroup
{
$this->fields = $_fields;
$this->and = $_and;
{
$this->fields = $_fields;
$this->and = $_and;
- foreach ($this->fields as $key=>&$field) {
- if (is_null($field)) {
- unset($this->fields[$key]);
+
+ $cleanFields = array();
+ foreach ($this->fields as $field) {
+ if (!is_null($field)) {
+ $cleanFields[] = $field;
}
}
}
}
+ $this->fields = $cleanFields;
}
// }}}
}
// }}}
@@
-852,7
+862,7
@@
class SFieldGroup
function too_large()
{
$b = true;
function too_large()
{
$b = true;
- for ($i
=0 ; $b && $i<count($this->fields) ; $i++
) {
+ for ($i
= 0; $b && $i < count($this->fields); ++$i
) {
if (!is_null($this->fields[$i])) {
$b = $b && $this->fields[$i]->too_large();
}
if (!is_null($this->fields[$i])) {
$b = $b && $this->fields[$i]->too_large();
}