function Puff_Runonce_Create($Connection, $Session = false) { //// Check Session Existence if ($Session) { $Session = htmlentities($Session, ENT_QUOTES, 'UTF-8'); $SessionExists = Puff_Member_Session_Exists($Connection, $Session); if (!$SessionExists) { // Let's just silently agree if the session doesn't exist. $Session = false; } } else { // We won't set a session if it's not checkable. $Session = false; } //// Generate a Runonce // The Runonce will be a 128 character hexidecimal hash from a secure source. // Will return an error if no secure source is available. $Runonce = Puff_SecureRandom(); if (!$Runonce) { return array('error' => 'Error: No secure source was available for Runonce generation. This is not your fault.'); } //// Insert into Database $Result = mysqli_query($Connection, 'INSERT INTO `Runonces` (`Runonce`, `Session`) VALUES (\'' . $Runonce . '\', \'' . $Session . '\');'); $Return['Result'] = $Result; $Return['Runonce'] = $Runonce; return $Return; }
function Puff_Member_Session_Disable($Connection, $Session) { $Session = htmlentities($Session, ENT_QUOTES, 'UTF-8'); $SessionExists = Puff_Member_Session_Exists($Connection, $Session); if (!$SessionExists) { return array('warning' => 'Sorry, that session does not exist. I guess that means it\'s sort of disabled already?'); } //// Disable the Session $Result = mysqli_query($Connection, 'UPDATE `Sessions` SET `Active`=\'0\' WHERE `Session`=\'' . $Session . '\';'); return $Result; }
$Result['Exists'] = Puff_Member_Session_Exists($Connection, $Result['Create']['Session']); var_dump($Result['Exists']); echo 'Puff_Member_Session_Disable' . PHP_EOL; $Result['Disable'] = Puff_Member_Session_Disable($Connection, $Result['Create']['Session']); var_dump($Result['Disable']); echo 'Puff_Member_Session_Exists' . PHP_EOL; $Result['Exists2'] = Puff_Member_Session_Exists($Connection, $Result['Create']['Session']); var_dump($Result['Exists2']); $Result['Exists2'] = !$Result['Exists2']; echo 'Puff_Member_Session_Create' . PHP_EOL; $Result['Create2'] = Puff_Member_Session_Create($Connection, $Username); var_dump($Result['Create2']); echo 'Puff_Member_Session_Exists' . PHP_EOL; $Result['Exists3'] = Puff_Member_Session_Exists($Connection, $Result['Create2']['Session']); var_dump($Result['Exists3']); echo 'Puff_Member_Session_Create' . PHP_EOL; $Result['Create3'] = Puff_Member_Session_Create($Connection, $Username); var_dump($Result['Create3']); echo 'Puff_Member_Session_Disable_All' . PHP_EOL; $Result['DisableAll'] = Puff_Member_Session_Disable_All($Connection, $Username); var_dump($Result['DisableAll']); echo 'Puff_Member_Session_Exists' . PHP_EOL; $Result['Exists4'] = Puff_Member_Session_Exists($Connection, $Result['Create2']['Session']); var_dump($Result['Exists4']); $Result['Exists4'] = !$Result['Exists4']; echo 'Puff_Member_Destroy' . PHP_EOL; $Result['Destroy'] = Puff_Member_Destroy($Connection, $Username); var_dump($Result['Destroy']); if (in_array(false, $Result, true)) { exit(1); }