Jump to content
php.lv forumi
Sign in to follow this  
aika

Procedūra

Recommended Posts

Pirmo reizi ņemos ar ko tādu, lūgums pēc palīdzības.

Uzdevums ir uz laiku nomainīt usera pass, lai apskatītos kas šim tur nestrādā. Pirms tam ar rociņām kopējās parole un repleisojās atpakaļ! Gribās pa smuko, guglējam un taisam workbenčā procedūru:

DELIMITER $$
DROP PROCEDURE IF EXISTS swappass;
CREATE PROCEDURE swappass()
  
BEGIN
	DECLARE passw varchar(128);
	DECLARE uid varchar(20);

	set uid = 64437;

	SELECT passw  = Password FROM m_membership where userid = uid;
	update m_membership set Password = 'rxSBeIf95nEjrYsvuqI1111tORgrsQ+SDcGfTob6pIQ=' where userid = uid; /* prastā parole */ 
	SELECT SLEEP(300); /* gaidam 5min  */
	update m_membership set Password = passw where userid = uid;
END;
$$
DELIMITER ;

Rezultātā pieprasījums aiziet bezgalīgā Running.... un atpakaļ paroli nenomaina.

Kas nav pareizi?!

Edited by aika

Share this post


Link to post
Share on other sites

Viena lieta, kas krīt acī, ir Password, kas idejiski ir MySQL rezervēts vārds.. varbūt jālieto `Password` 

 

 

Otra  - SELECT passw = Password FROM m_membership where userid = uid; sintakse varbūt, ka ir pareiza/ejoša, bet es personīgi esmu pieradis kaut kā lietot SELECT INTO ->

SELECT `Password` INTO passw FROM m_membership where userid = uid;

vai

SET passw := ( SELECT `Password` FROM m_membership where userid = uid );

Share this post


Link to post
Share on other sites

Nezinu, pamēģini.

 

Bet pirms rakstīt procedūras var jau patestēt arī vienkārši ar pašiem SQL kverijiem vai tie izpildās.

Piemēram, no mysql konsoles vai kāda cita rīka (no phpmyadmin visdrīzāk nestrādās, jo nepieciešama nepārtraukta sesija) ar visiem mainīgajiem (@ ir sesijas mainīgie):

SET @uid = 64437;
SELECT `Password` INTO @passw FROM m_membership WHERE userid = @uid;
UPDATE m_membership SET `Password` = 'rxSBeIf95nEjrYsvuqI1111tORgrsQ+SDcGfTob6pIQ=' WHERE  userid = @uid;
UPDATE m_membership SET `Password` = @passw WHERE userid = @uid;

.. un tad skatīties kur un kas izpildās vai nē.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...