Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
7b482a79
Commit
7b482a79
authored
4 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
changed counter to count all entries
parent
5b829e84
No related branches found
Branches containing commit
No related tags found
5 merge requests
!1730
Development
,
!1724
Development
,
!1723
Development
,
!1712
Development
,
!1701
Resolve "settings for blacklisting pages"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/MetaGer.php
+27
-38
27 additions, 38 deletions
app/MetaGer.php
with
27 additions
and
38 deletions
app/MetaGer.php
+
27
−
38
View file @
7b482a79
...
...
@@ -73,7 +73,10 @@ class MetaGer
protected
$verificationId
;
protected
$verificationCount
;
protected
$searchUid
;
protected
$redisResultWaitingKey
,
$redisResultEngineList
,
$redisEngineResult
,
$redisCurrentResultList
;
protected
$redisResultWaitingKey
;
protected
$redisResultEngineList
;
protected
$redisEngineResult
;
protected
$redisCurrentResultList
;
public
$starttime
;
public
function
__construct
(
$hash
=
""
)
...
...
@@ -258,7 +261,7 @@ class MetaGer
$engines
=
$this
->
engines
;
// combine
$this
->
combineResults
(
$engines
);
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"combined results"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
// misc (WiP)
...
...
@@ -280,7 +283,7 @@ class MetaGer
return
(
$a
->
getRank
()
<
$b
->
getRank
())
?
1
:
-
1
;
});
}
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"sorted results"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
# Validate Results
...
...
@@ -291,7 +294,7 @@ class MetaGer
}
}
$this
->
results
=
$newResults
;
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"validated results"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
# Validate Advertisements
...
...
@@ -306,7 +309,7 @@ class MetaGer
$newResults
[]
=
$ad
;
}
$this
->
ads
=
$newResults
;
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"validated ads"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
#Adgoal Implementation
...
...
@@ -322,19 +325,19 @@ class MetaGer
}
}
$this
->
adgoalHash
=
$this
->
startAdgoal
(
$this
->
results
);
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"started adgoal"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
if
(
!
$this
->
javascript
)
{
$this
->
adgoalLoaded
=
$this
->
parseAdgoal
(
$this
->
results
,
$this
->
adgoalHash
,
true
);
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"parsed adgoal"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
else
{
$this
->
adgoalLoaded
=
$this
->
parseAdgoal
(
$this
->
results
,
$this
->
adgoalHash
,
false
);
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"parsed adgoal"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
...
...
@@ -345,7 +348,7 @@ class MetaGer
# Human Verification
$this
->
humanVerification
(
$this
->
results
);
$this
->
humanVerification
(
$this
->
ads
);
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"human verification"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
...
...
@@ -368,7 +371,7 @@ class MetaGer
'engines'
=>
$this
->
next
,
];
Cache
::
put
(
$this
->
getSearchUid
(),
serialize
(
$this
->
next
),
60
*
60
);
if
(
!
empty
(
$timings
)){
if
(
!
empty
(
$timings
))
{
$timings
[
"prepareResults"
][
"filled cache"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
else
{
...
...
@@ -449,7 +452,7 @@ class MetaGer
$answer
=
null
;
# Hash is true if Adgoal request wasn't started in the first place
if
(
$hash
===
true
){
if
(
$hash
===
true
)
{
return
true
;
}
...
...
@@ -513,7 +516,6 @@ class MetaGer
\App\PrometheusExporter
::
Duration
(
$requestTime
,
"adgoal"
);
}
return
true
;
}
public
function
humanVerification
(
&
$results
)
...
...
@@ -685,7 +687,6 @@ class MetaGer
if
(
!
empty
(
$timings
))
{
$timings
[
"createSearchEngines"
][
"saved engines"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
private
function
removeAdsFromListIfAdfree
(
&
$sumas
)
...
...
@@ -744,7 +745,6 @@ class MetaGer
if
(
!
empty
(
$timings
))
{
$timings
[
"startSearch"
][
"searches started"
]
=
microtime
(
true
)
-
$timings
[
"starttime"
];
}
}
public
function
checkCache
()
...
...
@@ -762,7 +762,6 @@ class MetaGer
}
}
}
}
# Spezielle Suchen und Sumas
...
...
@@ -786,7 +785,6 @@ class MetaGer
{
$engines
=
[];
foreach
(
$enabledSearchengines
as
$engineName
=>
$engine
)
{
if
(
!
isset
(
$engine
->
{
"parser-class"
}))
{
die
(
var_dump
(
$engine
));
}
...
...
@@ -874,7 +872,7 @@ class MetaGer
foreach
(
$availableFilter
as
$filterName
=>
$filter
)
{
if
(
\Request
::
filled
(
$filter
->
{
"get-parameter"
}))
{
$filter
->
value
=
\Request
::
input
(
$filter
->
{
"get-parameter"
});
}
else
if
(
\Cookie
::
get
(
$this
->
getFokus
()
.
"_setting_"
.
$filter
->
{
"get-parameter"
})
!==
null
)
{
}
elseif
(
\Cookie
::
get
(
$this
->
getFokus
()
.
"_setting_"
.
$filter
->
{
"get-parameter"
})
!==
null
)
{
$filter
->
value
=
\Cookie
::
get
(
$this
->
getFokus
()
.
"_setting_"
.
$filter
->
{
"get-parameter"
});
}
}
...
...
@@ -1018,7 +1016,7 @@ class MetaGer
# Javascript option will be set by an asynchronious script we will check for it when we are fetching adgoal
# Until then javascript parameter will be false
$this
->
javascript
=
false
;
if
(
$request
->
filled
(
"javascript"
)
&&
is_bool
(
$request
->
input
(
"javascript"
))){
if
(
$request
->
filled
(
"javascript"
)
&&
is_bool
(
$request
->
input
(
"javascript"
)))
{
$this
->
javascript
=
boolval
(
$request
->
input
(
"javascript"
));
$request
->
request
->
remove
(
"javascript"
);
}
...
...
@@ -1086,7 +1084,7 @@ class MetaGer
$this
->
newtab
=
$request
->
input
(
'newtab'
,
'on'
);
if
(
$this
->
newtab
===
"on"
)
{
$this
->
newtab
=
"_blank"
;
}
else
if
(
$this
->
framed
)
{
}
elseif
(
$this
->
framed
)
{
$this
->
newtab
=
"_top"
;
}
else
{
$this
->
newtab
=
"_self"
;
...
...
@@ -1187,7 +1185,7 @@ class MetaGer
}
}
}
}
else
if
(
$this
->
request
->
filled
(
"ff"
)
||
$this
->
request
->
filled
(
"ft"
))
{
}
elseif
(
$this
->
request
->
filled
(
"ff"
)
||
$this
->
request
->
filled
(
"ft"
))
{
$this
->
request
=
$this
->
request
->
replace
(
$this
->
request
->
except
([
"fc"
,
"ff"
,
"ft"
]));
}
...
...
@@ -1268,7 +1266,7 @@ class MetaGer
foreach
(
$this
->
sumaFile
->
filter
->
{
"query-filter"
}
as
$filterName
=>
$filter
)
{
if
(
!
empty
(
$filter
->
{
"optional-parameter"
})
&&
$request
->
filled
(
$filter
->
{
"optional-parameter"
}))
{
$this
->
queryFilter
[
$filterName
]
=
$request
->
input
(
$filter
->
{
"optional-parameter"
});
}
else
if
(
preg_match_all
(
"/"
.
$filter
->
regex
.
"/si"
,
$this
->
q
,
$matches
)
>
0
)
{
}
elseif
(
preg_match_all
(
"/"
.
$filter
->
regex
.
"/si"
,
$this
->
q
,
$matches
)
>
0
)
{
switch
(
$filter
->
match
)
{
case
"last"
:
$this
->
queryFilter
[
$filterName
]
=
$matches
[
$filter
->
save
][
sizeof
(
$matches
[
$filter
->
save
])
-
1
];
...
...
@@ -1295,7 +1293,7 @@ class MetaGer
if
((
$request
->
filled
(
$filter
->
{
"get-parameter"
})
&&
$request
->
input
(
$filter
->
{
"get-parameter"
})
!==
"off"
)
||
\Cookie
::
get
(
$this
->
getFokus
()
.
"_setting_"
.
$filter
->
{
"get-parameter"
})
!==
null
)
{
# If the filter is set via Cookie
$this
->
parameterFilter
[
$filterName
]
=
$filter
;
$this
->
parameterFilter
[
$filterName
]
=
$filter
;
$this
->
parameterFilter
[
$filterName
]
->
value
=
$request
->
input
(
$filter
->
{
"get-parameter"
},
''
);
if
(
empty
(
$this
->
parameterFilter
[
$filterName
]
->
value
))
{
$this
->
parameterFilter
[
$filterName
]
->
value
=
\Cookie
::
get
(
$this
->
getFokus
()
.
"_setting_"
.
$filter
->
{
"get-parameter"
});
...
...
@@ -1348,12 +1346,12 @@ class MetaGer
$this
->
hostBlacklist
[]
=
$blacklistElement
;
}
}
}
else
if
(
strpos
(
$blacklistString
,
"*"
)
!==
0
)
{
}
elseif
(
strpos
(
$blacklistString
,
"*"
)
!==
0
)
{
$this
->
hostBlacklist
[]
=
$blacklistString
;
}
}
foreach
(
Cookie
::
get
()
as
$key
=>
$value
){
if
((
stripos
(
$key
,
$this
->
fokus
.
'_blpage'
)
===
0
)
&&
(
stripos
(
$value
,
'*.'
)
===
false
)){
foreach
(
Cookie
::
get
()
as
$key
=>
$value
)
{
if
((
stripos
(
$key
,
$this
->
fokus
.
'_blpage'
)
===
0
)
&&
(
stripos
(
$value
,
'*.'
)
===
false
))
{
$this
->
hostBlacklist
[]
=
$value
;
}
}
...
...
@@ -1390,12 +1388,12 @@ class MetaGer
$this
->
domainBlacklist
[]
=
substr
(
$blacklistElement
,
strpos
(
$blacklistElement
,
"*."
)
+
2
);
}
}
}
else
if
(
strpos
(
$blacklistString
,
"*."
)
===
0
)
{
}
elseif
(
strpos
(
$blacklistString
,
"*."
)
===
0
)
{
$this
->
domainBlacklist
[]
=
substr
(
$blacklistString
,
strpos
(
$blacklistString
,
"*."
)
+
2
);
}
}
foreach
(
Cookie
::
get
()
as
$key
=>
$value
){
if
(
stripos
(
$key
,
$this
->
fokus
.
'_blpage'
)
===
0
&&
stripos
(
$value
,
'*.'
)
===
0
){
foreach
(
Cookie
::
get
()
as
$key
=>
$value
)
{
if
(
stripos
(
$key
,
$this
->
fokus
.
'_blpage'
)
===
0
&&
stripos
(
$value
,
'*.'
)
===
0
)
{
$this
->
domainBlacklist
[]
=
str_replace
(
"*."
,
""
,
$value
);
}
}
...
...
@@ -1744,25 +1742,16 @@ class MetaGer
{
$cookies
=
\Cookie
::
get
();
$count
=
0
;
$checkBlacklist
=
true
;
$sumaFile
=
MetaGer
::
getLanguageFile
();
$sumaFile
=
json_decode
(
file_get_contents
(
$sumaFile
),
true
);
$foki
=
array_keys
(
$sumaFile
[
'foki'
]);
foreach
(
$cookies
as
$key
=>
$value
)
{
if
(
starts_with
(
$key
,
[
$this
->
getFokus
()
.
"_setting_"
,
$this
->
getFokus
()
.
"_engine_"
]))
{
if
(
starts_with
(
$key
,
[
$this
->
getFokus
()
.
"_setting_"
,
$this
->
getFokus
()
.
"_engine_"
,
$this
->
getFokus
()
.
"_blpage_"
]))
{
$count
++
;
continue
;
}
if
(
$checkBlacklist
){
foreach
(
$foki
as
$fokus
){
if
(
strpos
(
$key
,
$fokus
.
'_blpage'
)
===
0
){
$count
++
;
$checkBlacklist
=
false
;
}
}
}
}
return
$count
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment