public function loginLinkGen($varValue, DataContainer $dc) { if ($varValue) { \Database::getInstance()->prepare('UPDATE tl_member SET loginLink = ? WHERE id = ?')->execute(LoginLink::generateLoginKey(), $dc->id); } return 0; // reset checkbox }
public function generateKeysForAllMembers($intField) { if (!$intField) { return ''; } $objMembers = \Database::getInstance()->execute("SELECT * FROM tl_member WHERE loginLink = ''"); while ($objMembers->next()) { \Database::getInstance()->prepare("UPDATE tl_member %s WHERE id = ?")->set(array('loginLink' => \LoginLink::generateLoginKey()))->execute($objMembers->id); } $_SESSION['TL_INFO'][] = sprintf('LoginKeys für %s Mitglieder generiert und gespeichert!', $objMembers->numRows); \Config::persist('login_link_generateKeysForAllMembers', ''); }
public static function generateLoginKey($intKeyLength = false) { if (!$intKeyLength || !is_int($intKeyLength)) { $intKeyLength = \Config::get('login_link_defaultKeyLength') ? \Config::get('login_link_defaultKeyLength') : 10; } $strKey = substr(sha1(uniqid(mt_rand()) . uniqid(mt_rand())), 0, $intKeyLength); $objMember = \Database::getInstance()->prepare("SELECT id FROM tl_member WHERE loginLink = ?")->execute($strKey); if ($objMember->numRows) { LoginLink::generateLoginKey(); } return $strKey; }