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//
Hi Ole,
do you know what is the min mysql version required for trigger support?
It is useful, but I am not sure we can add it to db table definition, being based on a generic xml specification format. maybe the best for now is to add a wiki page for it at: http://www.kamailio.org/dokuwiki/doku.php
Practical examples is a good section (just add under 'example:' namespace).
Thanks, Daniel
On 5/18/10 4:21 PM, Ole Kaas wrote:
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// _______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Tuesday 25 May 2010, Daniel-Constantin Mierla wrote:
do you know what is the min mysql version required for trigger support?
It is useful, but I am not sure we can add it to db table definition, being based on a generic xml specification format.
Hello,
its not possible at the moment to specify database triggers in the XML specification.
maybe the best for now is to add a wiki page for it at: http://www.kamailio.org/dokuwiki/doku.php
Practical examples is a good section (just add under 'example:' namespace).
Yes, it would be nice if you could add it to the wiki.
Regards,
Henning
2010/5/25 Daniel-Constantin Mierla miconda@gmail.com:
It is useful, but I am not sure we can add it to db table definition
I agree. This contribution is very useful in many cases but in case you already have a management interface that calcultes such values you don't need such triggers.
Thanks a lot.