MySQLRandomElements __construct(
[string
$user = self::DEFAULT_USER], [string
$password = self::DEFAULT_PASSWORD], [string
$host = self::DEFAULT_HOST], [string
$database = self::DEFAULT_DB]
)
|
|
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 default user and password will be mysqldb
- The default host will be localhost
- The default database name will be InternetAccessLog
Parameters:
string |
$user: |
|
string |
$password: |
|
string |
$host: |
|
string |
$database: |
|
Destructor. Close the open connection to MySQL database
boolean addFakeUser(
string
$username, [string
$tablename = self::DATA_RNDUSERSC_NAME]
)
|
|
This function add a user to the table 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 use. The id is autonumeric Returns true if the user has been succesfull added, false if not
Parameters:
string |
$username: |
|
string |
$tablename: |
|
API Tags:
void createDomains(
integer
$number, [boolean
$use_index = TRUE], [boolean
$dont_repeat = TRUE]
)
|
|
Save random domains in MySQL.
The parameters are the number of domains to create and two 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 itis 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: |
|
void createIPs(
integer
$number, [boolean
$use_index = TRUE], [boolean
$dont_repeat = TRUE]
)
|
|
Save random IPs in MySQL.
The parameters are the number of IPs to create and two 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 itis 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: |
|
filehandle createRandomNonFTPLogEntryCSV(
[string
$filename = "CSV/NonFTP_Access_log.csv"]
)
|
|
Writes the first line (title) of a CSV file for non ftp log entry (NonFTP_Access_log.csv under CSV directory by default). If it exist it will be truncated. Returns the file handle
Parameters:
string |
$filename: |
filename |
API Tags:
void createURIs(
integer
$number
)
|
|
Save random URIs in MySQL.
The parameter is the number of URIs to create. The id will be autonumeric (1, 2, 3 ....)
Parameters:
void createUsers(
integer
$number, [boolean
$use_index = TRUE], [boolean
$dont_repeat = TRUE]
)
|
|
Save random users in MySQL.
The parameters are the number of users two 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 dropTable(
string
$tablename
)
|
|
This function deletes a table if it exists in MySQL. If the table does not exists returns false (and does nothing)
Parameters:
string |
$tablename: |
tablename |
API Tags:
boolean dropTableNonFTPLogEntry(
string
0
)
|
|
This function deletes the table used for saving NonFTP logs. If the table does not exists returns false (and does nothing)
Parameters:
API Tags:
boolean existUser(
string
$username, [string
$tablename = self::RNDUSERSC_NAME]
)
|
|
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: |
|
API Tags:
void exportDomainsToCSV(
[string
$filename = "CSV/Domains.csv"]
)
|
|
Export domains table in CSV format saving it in path passed as parameter (Domains.csv under CSV directory by default)
Parameters:
API Tags:
void exportIPsToCSV(
[string
$filename = "CSV/IPs.csv"]
)
|
|
Export ip's table in CSV format saving it in path passed as parameter (IPs.csv under CSV directory by default)
Parameters:
API Tags:
void exportURIsToCSV(
[string
$filename = "CSV/URIs.csv"]
)
|
|
Export URIs table in CSV format saving it in path passed as parameter (URIs.csv under CSV directory by default)
Parameters:
API Tags:
void exportUsersToCSV(
[string
$filename = "CSV/Users.csv"]
)
|
|
Export user table in CSV format saving it in path passed as parameter (Users.csv under CSV directory by default)
Parameters:
API Tags:
Gets the connection to MySQL
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:
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(
string
$query
)
|
|
Sends a query to the database and returns the first field of the first row. If no rows are got null is returned
Parameters:
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: |
|
mixed getResults(
string
$query
)
|
|
Sends a query to the database and returns the results. If no rows are got null is returned
Parameters:
API Tags:
array getRow(
string
$query
)
|
|
Sends a query to the database and returns the first row as an associative array. If no rows are got null is returned
Parameters:
API Tags:
array getUserCollectedData(
string
$username, integer
$year, integer
$month
)
|
|
This function returns the user data from the raports 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:
string getUserFromID(
integer
$userid
)
|
|
This function returns the username searching by the id. If the user does not exist null is returner
Parameters:
API Tags:
This function queries the database to return the users number (records in Random_UsersList)
API Tags:
void importDomainsFromCSV(
[string
$filename = "CSV/Domains.csv"]
)
|
|
Import Domains data in a CSV file to a MySQL table (if the table already exist it will be deleted)
The MySQL user must have the global privilege FILE!
Parameters:
API Tags:
void importIPsFromCSV(
[string
$filename = "CSV/IPs.csv"]
)
|
|
Import IPs data in a CSV file to a MySQL table (if the table already exist it will be deleted)
The MySQL user must have the global privilege FILE!
Parameters:
API Tags:
void importURIsFromCSV(
[string
$filename = "CSV/URIs.csv"]
)
|
|
Import URIs data in a CSV file to a MySQL table (if the table already exist it will be deleted)
The MySQL user must have the global privilege FILE!
Parameters:
API Tags:
void importUsersFromCSV(
[string
$filename = "CSV/Users.csv"]
)
|
|
Import users data in a CSV file to a MySQL table (if the table already exist it will be deleted)
The MySQL user must have the global privilege FILE!
Parameters:
API Tags:
Create in memory tables and loads user, ips and domains data from persitent ones
boolean randomDomains_exists(
)
|
|
Returns true if the "Random_DomainsList" table has records
boolean randomIPs_exists(
)
|
|
Returns true if the "Random_IPsList" table has records
boolean randomUser_exists(
)
|
|
Returns true if the "Random_UsersList" table has records
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 A id field autonumeric will be created.
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. A id field autonumeric will be created.
Parameters:
void saveRandomNonFTPLogEntryToCSV(
array
$log_entry, [string
$filename = "CSV/NonFTP_Access_log.csv"], [filehandle
$fh = NULL]
)
|
|
Adds the non ftp log entry passed as parameter to a CSV file (NonFTP_Access_log.csv under CSV directory by default).
A third optional parameter is the file handle (to not open and close the file in a for loop which calls this function)
Parameters:
API Tags:
void saveRandomNonFTPLogEntry_fromCSV(
string
$line, [boolean
$create_reports = TRUE]
)
|
|
Gets a line with a log entry in CSV format 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. A id field autonumeric will be created.
Parameters:
string |
$line: |
Line in CSV format (clientip, user, datetime, method, protocol, domain, uri, return_code, size) |
boolean |
$create_reports: |
|
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