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
2393a628
Commit
2393a628
authored
4 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Plain Diff
Merge branch '1098-add-interface-to-test-adgoal-responses' into 'development'
Resolve "Add interface to test adgoal responses" Closes
#1098
See merge request
!1812
parents
4042fb10
be7348c8
No related branches found
No related tags found
3 merge requests
!1895
Development
,
!1813
Development
,
!1812
Resolve "Add interface to test adgoal responses"
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/Http/Controllers/AdgoalTestController.php
+93
-0
93 additions, 0 deletions
app/Http/Controllers/AdgoalTestController.php
resources/views/admin/adgoal.blade.php
+30
-0
30 additions, 0 deletions
resources/views/admin/adgoal.blade.php
routes/web.php
+3
-0
3 additions, 0 deletions
routes/web.php
with
126 additions
and
0 deletions
app/Http/Controllers/AdgoalTestController.php
0 → 100644
+
93
−
0
View file @
2393a628
<?php
namespace
App\Http\Controllers
;
use
Illuminate\Http\Request
;
use
stdClass
;
use
Cache
;
use
Illuminate\Support\Facades\Redis
;
class
AdgoalTestController
extends
Controller
{
public
function
index
(
Request
$request
){
return
view
(
'admin.adgoal'
)
->
with
(
'title'
,
"Admin Adgoal - MetaGer"
);
}
public
function
post
(
Request
$request
){
$urls
=
explode
(
"
\r\n
"
,
$request
->
input
(
"urls"
));
// Bring it in a form that's similar to metager results
$mgUrls
=
array
();
foreach
(
$urls
as
$url
){
$result
=
new
stdClass
();
$result
->
link
=
$url
;
$result
->
new
=
true
;
$mgUrls
[]
=
$result
;
}
$resultHash
=
\App\Models\Adgoal
::
startAdgoal
(
$mgUrls
);
Cache
::
forget
(
$resultHash
);
$startTime
=
microtime
(
true
);
$answer
=
null
;
while
(
microtime
(
true
)
-
$startTime
<
5
)
{
$answer
=
Cache
::
get
(
$resultHash
);
if
(
$answer
===
null
)
{
usleep
(
50
*
1000
);
}
else
{
break
;
}
}
if
(
!
empty
(
$answer
)){
$answer
=
json_decode
(
$answer
,
true
);
$answer
=
json_encode
(
$answer
,
JSON_PRETTY_PRINT
);
}
return
view
(
"admin.adgoal"
)
->
with
(
'title'
,
'Admin Adgoal - MetaGer'
)
->
with
(
'urls'
,
$request
->
input
(
"urls"
))
->
with
(
'answer'
,
$answer
);
}
public
function
generateUrls
(
Request
$request
){
$eingabe
=
$request
->
input
(
'eingabe'
);
if
(
empty
(
$eingabe
)){
return
redirect
(
'admin/adgoal'
);
}
$url
=
route
(
'resultpage'
,
[
"eingabe"
=>
$eingabe
,
"out"
=>
"api"
,
"key"
=>
env
(
"mainz_key"
)]);
$hash
=
md5
(
$url
);
$mission
=
[
"resulthash"
=>
$hash
,
"url"
=>
$url
,
"useragent"
=>
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0"
,
"username"
=>
null
,
"password"
=>
null
,
"cacheDuration"
=>
60
,
"name"
=>
"AdgoalGen"
,
];
$mission
=
json_encode
(
$mission
);
Redis
::
rpush
(
\App\MetaGer
::
FETCHQUEUE_KEY
,
$mission
);
$results
=
Redis
::
brpop
(
$hash
,
10
);
$linklist
=
array
();
if
(
!
empty
(
$results
)
&&
is_array
(
$results
)
&&
sizeof
(
$results
)
===
2
){
$results
=
$results
[
1
];
$results
=
\simplexml_load_string
(
$results
);
foreach
(
$results
->
entry
as
$entry
){
$linklist
[]
=
$entry
->
link
[
"href"
]
->
__toString
();
}
}
return
view
(
"admin.adgoal"
)
->
with
(
'title'
,
'Admin Adgoal - MetaGer'
)
->
with
(
'urls'
,
implode
(
"
\r\n
"
,
$linklist
));
}
}
This diff is collapsed.
Click to expand it.
resources/views/admin/adgoal.blade.php
0 → 100644
+
30
−
0
View file @
2393a628
@
extends
(
'layouts.subPages'
)
@
section
(
'title'
,
$title
)
@
section
(
'content'
)
<
div
id
=
"adgoal"
,
class
=
"card-heavy"
>
<
h1
>
Adgoal
Test
Interface
</
h1
>
<
p
>
Auf
dieser
Seite
kannst
du
URLs
eingeben
,
welche
bei
Adgoal
auf
Affliate
Links
überprüft
werden
sollen
.
</
p
>
<
p
>
Eine
URL
pro
Zeile
</
p
>
<
form
action
=
"
{
{route("adgoal-generate")}
}
"
method
=
"post"
>
<
textarea
name
=
"urls"
id
=
"urls"
style
=
"width: 100%;"
rows
=
"10"
>@
if
(
!
empty
(
$urls
)){{
$urls
}}
@
endif
</
textarea
>
<
p
style
=
"padding-top: 16px;"
><
input
type
=
"submit"
value
=
"Generieren"
></
p
>
</
form
>
</
div
>
@
if
(
!
empty
(
$answer
))
<
div
class
=
"card-heavy"
>
<
h1
>
Antwort
</
h1
>
<
pre
style
=
"background-color: black; padding: 8px; color: white; border: 1px solid grey;"
>
{{
$answer
}}
</
pre
>
</
div
>
@
endif
<
div
class
=
"card-heavy"
>
<
h1
>
Generate
URLs
from
search
query
</
h1
>
<
form
action
=
"
{
{route("adgoal-urls")}
}
"
method
=
"post"
>
<
input
type
=
"text"
name
=
"eingabe"
placeholder
=
"Sucheingabe"
>
<
input
type
=
"submit"
value
=
"OK"
>
</
form
>
</
div
>
@
endsection
This diff is collapsed.
Click to expand it.
routes/web.php
+
3
−
0
View file @
2393a628
...
...
@@ -212,6 +212,9 @@ Route::group(
Route
::
post
(
'service-desk'
,
'ServiceDesk@webhook'
);
Route
::
get
(
'stress'
,
'Stresstest@index'
);
Route
::
get
(
'stress/verify'
,
'Stresstest@index'
)
->
middleware
(
'browserverification'
,
'humanverification'
);
Route
::
get
(
'adgoal'
,
'AdgoalTestController@index'
)
->
name
(
"adgoal-index"
);
Route
::
post
(
'adgoal'
,
'AdgoalTestController@post'
)
->
name
(
"adgoal-generate"
);
Route
::
post
(
'adgoal/generate-urls'
,
'AdgoalTestController@generateUrls'
)
->
name
(
"adgoal-urls"
);
});
Route
::
get
(
'settings'
,
function
()
{
...
...
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