Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
druid-public
headwork
Commits
0ee4f6de
Commit
0ee4f6de
authored
May 13, 2021
by
GROSS-AMBLARD David
Browse files
Adds bots to users (add NBBOTS in config.php - see config.php.example).
Reset will populate these bots, named Allgaier<num>.
parent
5686f650
Changes
3
Hide whitespace changes
Inline
Side-by-side
actions.php
View file @
0ee4f6de
...
...
@@ -102,6 +102,40 @@ function executeSqlFile($file_name, $conn){
}
}
/**
* createBots
* create an armada of bots as users
* @param $conn: a valid PDO connection
* @param $nbbots: the number of bots to create
*/
function
createBots
(
$conn
,
$nbbots
){
$namePrefix
=
"Allgaier"
;
$conn
->
query
(
"delete from Skills where iduser in (select id from Users where name like '
$namePrefix
%')"
);
$conn
->
query
(
"delete from UserProfile where id in (select id from Users where name like '
$namePrefix
%')"
);
$conn
->
query
(
"delete from Users where name like '
$namePrefix
%'"
);
for
(
$i
=
1
;
$i
<=
NBBOTS
;
$i
++
){
$botname
=
"
$namePrefix$i
"
;
$pwd
=
"bot"
;
$stmt
=
$conn
->
prepare
(
"insert into Users(name,hashed_password) values(:name,:pwd)"
);
$stmt
->
bindParam
(
':name'
,
$botname
,
PDO
::
PARAM_STR
);
$stmt
->
bindParam
(
':pwd'
,
$pwd
,
PDO
::
PARAM_STR
);
$pwd
=
password_hash
(
$pwd
,
PASSWORD_DEFAULT
);
$stmt
->
execute
();
$stmt
=
$conn
->
prepare
(
"select * from Users where name=:username"
);
$stmt
->
bindParam
(
':username'
,
$botname
,
PDO
::
PARAM_STR
);
$stmt
->
execute
();
$result
=
$stmt
->
setFetchMode
(
PDO
::
FETCH_ASSOC
);
$line
=
$stmt
->
fetch
();
$id
=
$line
[
'id'
];
// Any user has the "common knowledge" skill
$conn
->
query
(
"insert into Skills values (
$id
,1,100)"
);
$conn
->
query
(
"insert into UserProfile values (
$id
,'I am a bot and proud of it.',365,0)"
);
}
}
/**
* nextTaskFromArtifact
*
...
...
@@ -282,7 +316,7 @@ function insertTaskFeedback($conn, $idtask, $feedbackText, $targetTable)
"idtask"
=>
$idtask
,
"text"
=>
$feedbackText
,
"iduser"
=>
$user
));
// or die(mysql_error());
));
}
/**
...
...
config.php.example
View file @
0ee4f6de
...
...
@@ -34,5 +34,7 @@ define("DEBUG",false);
define
(
"WIRKPROJECTENDPOINT"
,
"https://api.wirk.io/v1_0/AppProject"
);
define
(
"WIRKTASKLINEENDPOINT"
,
"https://api.wirk.io/v1_0/TaskLine"
);
// Bot parameters
define
(
"NBBOTS"
,
10
);
?>
index.php
View file @
0ee4f6de
...
...
@@ -132,6 +132,7 @@ switch ($mode) {
case
"restart"
:
restart
(
$conn
);
initialize
(
$conn
);
createBots
(
$conn
,
NBBOTS
);
showTasks
(
$conn
);
break
;
case
"showState"
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment