[SR-Users] Calculate ha1 with mysql trigger

Ole Kaas obk at tet.dk
Tue May 18 16:21:34 CEST 2010


Hello,

When editing the subscriber table using phpmyadmin, updating the ha1 fields are no fun and error prone. The trigger below will calculate the hashes if the input fields are left empty. Navigate to the subscriber table in phpmyadmin and drop the code in the query field under the "SQL" tab. Remeber to set the delimiter to //  

/Ole

DROP TRIGGER IF EXISTS calcha1 //
CREATE TRIGGER calcha1 BEFORE INSERT ON subscriber
FOR EACH ROW
BEGIN
IF NEW.ha1 = "" THEN SET NEW.ha1 = MD5(CONCAT(NEW.username,":",NEW.domain,":",NEW.password));
END IF;
IF NEW.ha1b = "" THEN SET NEW.ha1b = MD5(CONCAT(NEW.username,"@",NEW.domain,":",NEW.domain,":",NEW.password));
END IF;
END//


More information about the sr-users mailing list