<?xml version="1.0"?><phpdoc><class name="Bs_CugDb" extends="Bs_Cug" undoc="false" access="public" package="auth/cug"><file>C:/usr/local/lib/php/blueshoes-4.2/core/auth/cug/Bs_CugDb.class.php</file><doc><author>andrej arn &amp;lt;andrej at blueshoes dot org&amp;gt;</author><inherited src="Array"/><overriden src="Array"/><description>This is a subclass of Bs_Cug and customized for the use with a database.It&amp;apos;s tested and developed for use with MySql as DB. If you want an other DB, you may needto add code or subclass this one.Your users are organized in a DB table. Give the table name and maybe the db namein the vars $userDbName and $userTableName.The structure of that table needs to have the following fields:&amp;apos;user&amp;apos;&amp;apos;pass&amp;apos;It *may* have the following &amp;apos;lifecycle&amp;apos; fields&amp;apos;isActive&amp;apos;&amp;apos;startDatetime&amp;apos;&amp;apos;endDatetime&amp;apos;It&amp;apos;s a good idea to have the &amp;apos;ID&amp;apos; field as well and it may have any other fields.If all the lifecycle fields are there, they will be used.NOTE:  Times are written in GMT, not in any local or server time.Features: (mostly not available in Bs_Cug, only in Bs_CugDb)- hack detection- anti hack mechanism- account lifecycle- automatic password recovery using username/email (todo)- logging (with automatic db-table generation)-Example user-db-table:CREATE TABLE CugSomething (ID            INT UNSIGNED NOT NULL AUTO_INCREMENT DEFAULT 0,user          VARCHAR(20)  NOT NULL DEFAULT &amp;apos;&amp;apos;,pass          VARCHAR(20)  NOT NULL DEFAULT &amp;apos;&amp;apos;,isActive      TINYINT      NOT NULL DEFAULT 0,startDatetime DATETIME     NOT NULL DEFAULT &amp;apos;0000-00-00 00:00:00&amp;apos;,endDatetime   DATETIME     NOT NULL DEFAULT &amp;apos;0000-00-00 00:00:00&amp;apos;,PRIMARY KEY ID (ID),KEY user (user));dependencies: Bs_Cug, Bs_MySql</description><shortdescription>CUG Class using a database. Extended from Bs_Cug, look there too.</shortdescription><version>4.0.$id$</version><copyright>blueshoes.org</copyright></doc><function name="Bs_CugDb" undoc="false" access="public"><doc><parameter name="$cugName" type="string"/><return type="void"/><description/><shortdescription>Constructor.</shortdescription></doc></function><function name="setDbObject" undoc="false" access="public"><doc><parameter name="&amp;$bsDb" type="object [unknown]"/><return type="void"/><description>the global bsdb object that may be set in the constructor won&amp;apos;t be used anymore.</description><shortdescription>sets a db object for this class.</shortdescription></doc></function><function name="_validateLogin" undoc="true" access="private"><doc><return name="" type="bool"> (see above)</return><overriden src="Bs_Cug"/><description>returns boolean that tells if login was ok. sets $this-&amp;gt;errorMsg.*important*: to stop hacks we are doing 2 things here:1) log everything2) unix-like timeout on failed logins.for this to work, we/you may *not* spit out any htmlto the client before this method is run. if you send outsome tags, then timeout 10 seconds, the hacker doesn&amp;apos;t needto wait. he already knows after the first few tags that hislogin failed.note: usernames need to be unique in the database, and there may not be twowith the same letters but different case. otherwise the 2nd user maynot log in. you would notice that quite fast :)could be coded differently, but i don&amp;apos;t feel like doing it.</description><shortdescription>validates the login.</shortdescription></doc></function><function name="_logAttempt" undoc="true" access="private"><doc><parameter name="$isOk" undoc="true"/><parameter name="$failedReason" type="string" undoc="true"/><parameter name="$looksLikeHack" type="string" undoc="true"/><parameter name="$realData" type="string" undoc="true"/><return type="void"/><overriden src="Bs_Cug"/><description>overwrites parent method.params: same as in Bs_Cug-&amp;gt;_prepareLogData() so look there.that function is used here.</description><shortdescription>logs the login attempt if needed.</shortdescription></doc></function><function name="checkLogDbTable" undoc="false" access="public"><doc><return name="" type="bool"> (TRUE if table was ok, FALSE if changes have/had to be made.)</return><throws>bs_exception</throws><description>this is needed if an operation on it failed. maybe the table structure isnot up-to-date or does not exist at all.the needed changes will be made automatically. note that your user needsthe appropriate rights (alter, create, index...)hint: first try your query, if it fails check the table using this method.if this method returns FALSE then try your query again.</description><shortdescription>checks if the log db table is ok.</shortdescription></doc></function><function name="getDbString" undoc="false" access="public"><doc><parameter name="$which" default="&amp;apos;user&amp;apos;" type="string">(one of &amp;apos;user&amp;apos; (default) or &amp;apos;log&amp;apos;.)</parameter><return name="" type="string"/><throws>bool FALSE (if the appropriate table name is not set or empty.)</throws><description>example: &amp;quot;dbname.dbtable&amp;quot; if logDbName/userDbName is set,&amp;quot;dbtable&amp;quot; if not.</description><shortdescription>returns the dbname-dbtable string to use in queries.</shortdescription></doc></function><function name="getNumLoginFailures" undoc="false" access="public"><doc><return name="" type="int"> (number of failed logins in a row for that user. returns int 0 if we dunno.)</return><throws>bs_exception&#x0a;@2do finish code. moved here temporarily. timeout etc does not belong here.</throws><description/><shortdescription>tells how many times this user failed to login in a row.</shortdescription></doc></function><function name="resetPassword" undoc="false" access="public"><doc><parameter name="$userOrMail" type="string"/><parameter name="$automail" default="TRUE" type="string">(default is TRUE, tells if the new password should be mailed to the user automatically.)</parameter><return name="" type="bool"/><description>if that&amp;apos;s desired (see param $automail).</description><shortdescription>resets the users password to a newly created one, and mails it to the user</shortdescription></doc></function><variable name="$_bsDb" access="private" type="object [unknown]"><doc><description/><shortdescription>refenrece to global main db connection (see constructor).</shortdescription></doc></variable><variable name="$userDbName" access="public" type="string"><doc><see type="var">$userTableName</see><description/><shortdescription>the db of the user table.</shortdescription></doc></variable><variable name="$userTableName" access="public" type="string"><doc><see type="var">$userDbName</see><description/><shortdescription>the db table where the users are.</shortdescription></doc></variable><variable name="$logDbName" access="public" type="string"><doc><see type="var">$logTableName</see><description/><shortdescription>the db of the log table.</shortdescription></doc></variable><variable name="$logTableName" access="public" type="string"><doc><see type="var">$logDbName</see><description>a hack attempt. (history)</description><shortdescription>the db table to log to. is also used to determine if it&amp;apos;s</shortdescription></doc></variable><constant name="BS_CUGDB_VERSION" undoc="true" access="private" case="default: case sensitive">4.0.$x$<doc></doc></constant><inherited src="Bs_Cug" type="functions"><element>bs_cug</element><element>letmein</element><element>logout</element><element>getloginform</element><element>treatloginform</element><element>redirect</element><element>_validatelogindata</element><element>lookslikehack</element><element>_preparelogdata</element><element>_hackalert</element><element>_timeoutonloginfailure</element><element>_loadloginform</element></inherited><inherited src="Bs_Object" type="functions"><element>isex</element><element>isexception</element><element>tostring</element><element>tohtml</element><element>persist</element><element>unpersist</element><element>bs_object</element><element>bbsetoutput</element><element>bbawake</element><element>bbisawake</element><element>bbxmsg</element><element>bbxfunctionstart</element><element>bbxfunctionend</element><element>bbxecho</element><element>bbxvar</element><element>bbxvardump</element><element>bbforcetrace</element><element>bbbufferstart</element><element>bbbufferget</element><element>bbbufferendflush</element><element>bbbufferendclean</element></inherited><inherited src="Bs_Cug" type="variables"><element>$_app</element><element>$form</element><element>$bssession</element><element>$_postvars</element><element>$_cugname</element><element>$redirectpage</element><element>$formtarget</element><element>$language</element><element>$maxnumattempts</element><element>$checkforhack</element><element>$actiononhack</element><element>$logattempts</element><element>$checkcasesensitive</element><element>$userfieldnames</element><element>$errormsg</element></inherited><inherited src="Bs_Cug" type="consts"><element>bs_cug_version</element></inherited><inherited src="Bs_Object" type="consts"><element>bs_object_version</element></inherited><path><parent>Bs_Cug</parent><parent>Bs_Object</parent></path><baseclass>Bs_Object</baseclass></class></phpdoc>