/** * Retrieves the setting's plaintext value from * the database, for editing * @return mixed Returns value if successful, otherwise null * @version 2013052301 * @since 2012101001 */ public function get_setting() { // Decrypt value to return $encrypter = new MoodletxtEncryption(); $key = get_config('moodletxt', 'EK'); $encrypted = $this->config_read($this->name); return $encrypted !== null ? $encrypter->decrypt($key, $encrypted) : ''; }
/** * Builds authentication block. * Method to build an <Authentication> block for authenticating a request with the API * @param TxttoolsAccount $txttoolsAccount txttools account to authenticate against * @version 2011041501 * @since 2010090101 */ private function buildAuthentication($txttoolsAccount) { $outPass = $this->encrypter->decrypt(get_config('moodletxt', 'EK'), $txttoolsAccount->getEncryptedPassword()); // Set authentication block // Code written this way so the output is all nice and formatted $this->currentAuthentication = ' ' . MoodletxtXMLConstants::$REQUEST_AUTHENTICATION_BLOCK . ' ' . MoodletxtXMLConstants::$REQUEST_AUTHENTICATION_USERNAME . $txttoolsAccount->getUsername() . MoodletxtXMLConstants::$_REQUEST_AUTHENTICATION_USERNAME . ' ' . MoodletxtXMLConstants::$REQUEST_AUTHENTICATION_PASSWORD . $outPass . MoodletxtXMLConstants::$_REQUEST_AUTHENTICATION_PASSWORD . ' ' . MoodletxtXMLConstants::$_REQUEST_AUTHENTICATION_BLOCK; }
require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsSentMessageDAO.php'; require_once $CFG->dirroot . '/blocks/moodletxt/dao/TxttoolsReceivedMessageDAO.php'; require_once $CFG->dirroot . '/blocks/moodletxt/inbound/MoodletxtInboundFilterManager.php'; // Read in POST variables $inPushUser = required_param('u', PARAM_ALPHANUM); $inPushPass = required_param('p', PARAM_ALPHANUM); $inPayload = required_param('x', PARAM_RAW); // Assuming we have the right params, set up for parsing $parser = new MoodletxtXMLParser(); $decrypter = new MoodletxtEncryption(); $sentMessagesDAO = new TxttoolsSentMessageDAO(); $receivedMessagesDAO = new TxttoolsReceivedMessageDAO(); $inboundFilterManager = new MoodletxtInboundFilterManager(); $key = get_config('moodletxt', 'EK'); $pushUsername = get_config('moodletxt', 'Push_Username'); $pushPassword = $decrypter->decrypt($key, get_config('moodletxt', 'Push_Password')); // Check credentials against those stored in Moodle if ($inPushUser === $pushUsername && $inPushPass === $pushPassword) { $parsedInboundMessages = array(); $parsedStatusUpdates = array(); try { $parsedObjects = $parser->parse($inPayload); } catch (Exception $ex) { // Invalid XML from remote system die; } if (is_array($parsedObjects)) { // Filter objects and save accordingly foreach ($parsedObjects as $parsedObject) { if ($parsedObject instanceof MoodletxtInboundMessage) { array_push($parsedInboundMessages, $parsedObject);