MongoRandomElements __construct(
[string
$user = self::DEFAULT_USER], [string
$password = self::DEFAULT_PASSWORD], [string
$host = self::DEFAULT_HOST], [string
$database = self::DEFAULT_DB], [boolean
$safemode = self::DEFAULT_SAFEMODE]
)
|
|
Constructor. For creating an instance we need to pass all the parameters for the MongoDB database where the data will be stored (user, password, host & database name). The fifth parameter tells if the insertions will we made in safe mode or not (by default they are NOT safe)
- The default user and password will be mongodb
- The default host will be localhost
- The default database name will be InternetAccessLog
- Inertions will be NOT safe by default
Parameters:
string |
$user: |
|
string |
$password: |
|
string |
$host: |
|
string |
$database: |
|
boolean |
$safemode: |
|
Destructor. Close the open connection to MongoDB database
boolean addFakeUser(
string
$username, [string
$collectionname = self::RNDUSERSC_NAME]
)
|
|
This function add a fake user to the collection passed as second argument. If not collection done then the user will be added to Random_UsersList.
This function is coded for load tests, not for real user. The id is the id generated by Mongo Returns true if the user has been succesfull added, false if not
Parameters:
string |
$username: |
|
string |
$collectionname: |
|
API Tags:
void createDomains(
integer
$number, [boolean
$use_index = TRUE], [
$dont_repeat = TRUE], boolean
$dont_repeat_users
)
|
|
Save random domains in MongoDB The parameter are the number of domains to create and to booleans: if we want an unique index to be created for the domain (default is TRUE) and if we want that the domain is unique (default TRUE).
If the domain is going to be unique the existence of the name is verified with a query before inserting a new one The id will be autonumeric (1, 2, 3 ....)
Parameters:
integer |
$number: |
|
boolean |
$use_index: |
|
boolean |
$dont_repeat_users: |
|
|
$dont_repeat: |
|
void createIPs(
integer
$number, [boolean
$use_index = TRUE], [
$dont_repeat = TRUE], boolean
$dont_repeat_users
)
|
|
Save random IPs in MongoDB The parameters are the number of IPs to create and to booleans: if we want an unique index to be created for the ip (default is TRUE) and if we want that the ip is unique (default TRUE).
If the ip is going to be unique the existence of the name is verified with a query before inserting a new one The id will be autonumeric (1, 2, 3 ....)
Parameters:
integer |
$number: |
|
boolean |
$use_index: |
|
boolean |
$dont_repeat_users: |
|
|
$dont_repeat: |
|
void createUsers(
integer
$number, [boolean
$use_index = TRUE], [boolean
$dont_repeat = TRUE]
)
|
|
Save random users in MongoDB.
The parameters are the number of users to create and to booleans: if we want an unique index to be created for the user name (default is TRUE) and if we want that the user name is unique (default TRUE). If the user name is going to be unique the existence of the name is verified with a query before inserting a new one. The id will be autonumeric (1, 2, 3 ....)
Parameters:
integer |
$number: |
|
boolean |
$use_index: |
|
boolean |
$dont_repeat: |
|
boolean existUser(
string
$username, [
$collectionname = self::RNDUSERSC_NAME], string
$tablename
)
|
|
This function verifies if the user exists in the collection passed as second argument. If not collection done then the user will be added to Random_UsersList.
Parameters:
string |
$username: |
|
string |
$tablename: |
|
|
$collectionname: |
|
API Tags:
Reads ALL logs entries fron both collections NonFTP and FTP and saves reports entries for users and domains
API Tags:
Get the connection created to the database (the db, not the server)
API Tags:
array getDomainCollectedData(
string
$domainname, integer
$year, integer
$month
)
|
|
This function returns the domain data from the reports for a year and month specified. If there is no data returns null
Parameters:
string |
$domainname: |
|
integer |
$year: |
|
integer |
$month: |
Number from 1 to 12 |
API Tags:
MongoCollection getDomainCollection(
)
|
|
Get a link to the domains collection
API Tags:
string getDomainFromID(
integer
$id
)
|
|
This function returns the domain searching by the id. If the domain does not exist null is returner
Parameters:
API Tags:
integer getDomainNumber(
)
|
|
This function queries the database to return the domains number (records in Random_DomainsList)
API Tags:
array getOne(
array
$pipeline, string
$collection
)
|
|
Sends an aggregation array of commands to the database and returns the field '_id' of the first document. If no documents are got null is returned
Parameters:
array |
$pipeline: |
|
string |
$collection: |
|
API Tags:
array getRandomFTPLogEntry(
integer
$initial_timestamp, integer
$final_timestamp
)
|
|
Return a random log entry for FTP access. It is very similar to HTTP and tunnel access but with less fields (there is no protocol and return code)
It has two optional arguments, initial and final timestamps, if we want to get a random time in log entry created
Parameters:
integer |
$initial_timestamp: |
|
integer |
$final_timestamp: |
|
array getRandomNonFTPLogEntry(
integer
$initial_timestamp, integer
$final_timestamp
)
|
|
Return a random log entry for non FTP access (http and tunnel)
It has two optional arguments, initial and final timestamps, if we want to get a random time in log entry created
Parameters:
integer |
$initial_timestamp: |
|
integer |
$final_timestamp: |
|
array getResults(
array
$pipeline, [string
$collection = "NonFTP_Access_log"]
)
|
|
Sends an aggregation array of commands to the database and returns the results (array of documents). If no documents are got null is returned
Parameters:
array |
$pipeline: |
|
string |
$collection: |
|
API Tags:
array getRow(
array
$pipeline, [string
$collection = "NonFTP_Access_log"]
)
|
|
Sends an aggregation array of commands to the database and returns the first document. If no documents are got null is returned
Parameters:
array |
$pipeline: |
|
string |
$collection: |
|
API Tags:
array getUserCollectedData(
string
$username, integer
$year, integer
$month
)
|
|
This function returns the user data from the reports for a year and month specified. If there is no data returns null
Parameters:
string |
$username: |
|
integer |
$year: |
|
integer |
$month: |
Number from 1 to 12 |
API Tags:
MongoCollection getUserCollection(
)
|
|
Get a link to the users collection
API Tags:
string getUserFromID(
integer
$userid
)
|
|
This function returns the username searching by the id
Parameters:
API Tags:
This function queries the database to return the users number (records in Random_UsersList)
API Tags:
boolean randomDomains_exists(
)
|
|
Returns true if the random domains collection has at least one domain
boolean randomIPs_exists(
)
|
|
Returns true if the IPs collection has at least one IP
boolean randomUsers_exists(
)
|
|
Returns true if the random users collection has at least one user
void saveRandomFTPLogEntry(
array
$log_entry, [boolean
$create_reports = TRUE]
)
|
|
Receives a FTP log entry and saves the data and, optionally, monthly and daily precalculated values in database.
By default the reports are created. If the second argument is FALSE they will not be generated The id for the document in Mongo is created automatically by MongoDB (as an ObjectID)
Parameters:
void saveRandomNonFTPLogEntry(
array
$log_entry, [boolean
$create_reports = TRUE]
)
|
|
Receives a log entry and saves the data and, optionally, monthly and daily precalculated values in database.
By default the reports are created. If the second argument is FALSE they will not be generated The id for the document in Mongo is created automatically by MongoDB (as an ObjectID)
Parameters:
string searchFTPMethod(
)
|
|
Returns a random FTP method from the generated collection
string searchHTTPMethod(
)
|
|
Returns a random HTTP method from the generated collection
Returns a random IP from the generated collection
Returns a random protocol
integer searchReturnCode(
)
|
|
Returns a random return code
Returns a random user from the generated collection