phpDocumentor InternetAccessLog
[ class tree: InternetAccessLog ] [ index: InternetAccessLog ] [ all elements ]

Class: MongoRandomElements

Source Location: /MongoRandomElements.class.php

Class MongoRandomElements

Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From RandomElements

RandomElements::getRandomDate()
Return a random date between the two dates passes as parameters. Parameters and return value are English textual datetime descriptions 'Y-m-d H:i:s'
RandomElements::getRandomDomain()
Returns a random Internet domain (a www followed by a random string ended by a valid internet
RandomElements::getRandomFTPMethod()
Returns a semi random HTTP method (90% will be RETR)
RandomElements::getRandomHTTPMethod()
Returns a semi random HTTP method (90% will be GET)
RandomElements::getRandomIP()
Returns a random IP (string with 4 numbers between 0 and 255). No check for validity is made
RandomElements::getRandomProtocol()
Returns a random protocol (90% will be http)
RandomElements::getRandomRetourCode()
Returns a semirandom return code (90% are 200 return code)
RandomElements::getRandomSize()
Return a random size between 0 and 50K
RandomElements::getRandomString()
Returns a random string of the length demanded (10 characters by default)
RandomElements::getRandomUser()
Returns a random user, composed of one letter and 6 numbers

[ Top ]
Constant Summary
DEFAULT_DB   Constants for default connection values
DEFAULT_HOST   Constants for default connection values
DEFAULT_PASSWORD   Constants for default connection values
DEFAULT_SAFEMODE   Constants for default connection values
DEFAULT_USER   Constants for default connection values
DOMAINS_REPORT_PREFIX   Default prefixes for monthly reports
FTPLOG_NAME   Default names for random data collections
NONFTPLOG_NAME   Default names for random data collections
RNDDOMAINSC_NAME   Default names for random data collections
RNDIPSC_NAME   Default names for random data collections
RNDUSERSC_NAME   Default names for random data collections
USERS_REPORT_PREFIX   Default prefixes for monthly reports

[ Top ]
Method Summary
MongoRandomElements   __construct()   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)
void   __destruct()   Destructor. Close the open connection to MongoDB database
boolean   addFakeUser()   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.
void   createDomains()   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).
void   createIPs()   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).
void   createUsers()   Save random users in MongoDB.
boolean   existUser()   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.
void   generateReports()   Reads ALL logs entries fron both collections NonFTP and FTP and saves reports entries for users and domains
MongoDB   getDB()   Get the connection created to the database (the db, not the server)
array   getDomainCollectedData()   This function returns the domain data from the reports for a year and month specified. If there is no data returns null
MongoCollection   getDomainCollection()   Get a link to the domains collection
string   getDomainFromID()   This function returns the domain searching by the id. If the domain does not exist null is returner
integer   getDomainNumber()   This function queries the database to return the domains number (records in Random_DomainsList)
array   getOne()   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
array   getRandomFTPLogEntry()   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)
array   getRandomNonFTPLogEntry()   Return a random log entry for non FTP access (http and tunnel)
array   getResults()   Sends an aggregation array of commands to the database and returns the results (array of documents). If no documents are got null is returned
array   getRow()   Sends an aggregation array of commands to the database and returns the first document. If no documents are got null is returned
array   getUserCollectedData()   This function returns the user data from the reports for a year and month specified. If there is no data returns null
MongoCollection   getUserCollection()   Get a link to the users collection
string   getUserFromID()   This function returns the username searching by the id
integer   getUserNumber()   This function queries the database to return the users number (records in Random_UsersList)
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()   Receives a FTP log entry and saves the data and, optionally, monthly and daily precalculated values in database.
void   saveRandomNonFTPLogEntry()   Receives a log entry and saves the data and, optionally, monthly and daily precalculated values in database.
string   searchDomain()   Returns a random domain
string   searchFTPMethod()   Returns a random FTP method from the generated collection
string   searchHTTPMethod()   Returns a random HTTP method from the generated collection
string   searchIP()   Returns a random IP from the generated collection
string   searchProtocol()   Returns a random protocol
integer   searchReturnCode()   Returns a random return code
integer   searchSize()   Returns a random size
string   searchURI()   Returns a random URI
string   searchUser()   Returns a random user from the generated collection

[ Top ]
Methods
Constructor __construct  [line 196]

  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: 


[ Top ]
Destructor __destruct  [line 222]

  void __destruct( )

Destructor. Close the open connection to MongoDB database



[ Top ]
addFakeUser  [line 158]

  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:
Access:  public


[ Top ]
createDomains  [line 412]

  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: 


[ Top ]
createIPs  [line 358]

  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: 


[ Top ]
createUsers  [line 304]

  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: 


[ Top ]
existUser  [line 177]

  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:
Access:  public


[ Top ]
generateReports  [line 627]

  void generateReports( )

Reads ALL logs entries fron both collections NonFTP and FTP and saves reports entries for users and domains


API Tags:
Access:  public


[ Top ]
getDB  [line 230]

  MongoDB getDB( )

Get the connection created to the database (the db, not the server)


API Tags:
Access:  public


[ Top ]
getDomainCollectedData  [line 141]

  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:
Access:  public


[ Top ]
getDomainCollection  [line 290]

  MongoCollection getDomainCollection( )

Get a link to the domains collection


API Tags:
Access:  public


[ Top ]
getDomainFromID  [line 109]

  string getDomainFromID( integer $id  )

This function returns the domain searching by the id. If the domain does not exist null is returner

Parameters:
integer   $id: 

API Tags:
Access:  public


[ Top ]
getDomainNumber  [line 98]

  integer getDomainNumber( )

This function queries the database to return the domains number (records in Random_DomainsList)


API Tags:
Access:  public


[ Top ]
getOne  [line 272]

  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:
Access:  public


[ Top ]
getRandomFTPLogEntry  [line 686]

  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: 


[ Top ]
getRandomNonFTPLogEntry  [line 555]

  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: 


[ Top ]
getResults  [line 242]

  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:
Access:  public


[ Top ]
getRow  [line 260]

  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:
Access:  public


[ Top ]
getUserCollectedData  [line 125]

  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:
Access:  public


[ Top ]
getUserCollection  [line 281]

  MongoCollection getUserCollection( )

Get a link to the users collection


API Tags:
Access:  public


[ Top ]
getUserFromID  [line 85]

  string getUserFromID( integer $userid  )

This function returns the username searching by the id

Parameters:
integer   $userid: 

API Tags:
Access:  public


[ Top ]
getUserNumber  [line 74]

  integer getUserNumber( )

This function queries the database to return the users number (records in Random_UsersList)


API Tags:
Access:  public


[ Top ]
randomDomains_exists  [line 451]

  boolean randomDomains_exists( )

Returns true if the random domains collection has at least one domain



[ Top ]
randomIPs_exists  [line 397]

  boolean randomIPs_exists( )

Returns true if the IPs collection has at least one IP



[ Top ]
randomUsers_exists  [line 343]

  boolean randomUsers_exists( )

Returns true if the random users collection has at least one user



[ Top ]
saveRandomFTPLogEntry  [line 721]

  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:
array   $log_entry:  log entry as returned by getRandomNonFTPLogEntry
boolean   $create_reports: 


[ Top ]
saveRandomNonFTPLogEntry  [line 655]

  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:
array   $log_entry:  log entry as returned by getRandomNonFTPLogEntry
boolean   $create_reports: 


[ Top ]
searchDomain  [line 506]

  string searchDomain( )

Returns a random domain



[ Top ]
searchFTPMethod  [line 498]

  string searchFTPMethod( )

Returns a random FTP method from the generated collection



[ Top ]
searchHTTPMethod  [line 490]

  string searchHTTPMethod( )

Returns a random HTTP method from the generated collection



[ Top ]
searchIP  [line 461]

  string searchIP( )

Returns a random IP from the generated collection



[ Top ]
searchProtocol  [line 536]

  string searchProtocol( )

Returns a random protocol



[ Top ]
searchReturnCode  [line 544]

  integer searchReturnCode( )

Returns a random return code



[ Top ]
searchSize  [line 528]

  integer searchSize( )

Returns a random size



[ Top ]
searchURI  [line 520]

  string searchURI( )

Returns a random URI



[ Top ]
searchUser  [line 475]

  string searchUser( )

Returns a random user from the generated collection



[ Top ]
Constants
DEFAULT_DB = "InternetAccessLog" [line 42]

Constants for default connection values


[ Top ]
DEFAULT_HOST = "localhost" [line 41]

Constants for default connection values


[ Top ]
DEFAULT_PASSWORD = "mongodb" [line 40]

Constants for default connection values


[ Top ]
DEFAULT_SAFEMODE = false [line 43]

Constants for default connection values


[ Top ]
DEFAULT_USER = "mongodb" [line 39]

Constants for default connection values


[ Top ]
DOMAINS_REPORT_PREFIX = "Domains_Monthly_Report_" [line 33]

Default prefixes for monthly reports


[ Top ]
FTPLOG_NAME = "FTP_Access_log" [line 26]

Default names for random data collections


[ Top ]
NONFTPLOG_NAME = "NonFTP_Access_log" [line 25]

Default names for random data collections


[ Top ]
RNDDOMAINSC_NAME = "Random_DomainsList" [line 24]

Default names for random data collections


[ Top ]
RNDIPSC_NAME = "Random_IPsList" [line 23]

Default names for random data collections


[ Top ]
RNDUSERSC_NAME = "Random_UsersList" [line 22]

Default names for random data collections


[ Top ]
USERS_REPORT_PREFIX = "Users_Monthly_Report_" [line 32]

Default prefixes for monthly reports


[ Top ]

Documentation generated on Fri, 12 Apr 2013 12:02:19 +0200 by phpDocumentor 1.4.4