public static function getInstance() { if (self::$theInstance == null) { self::$theInstance = new RegistrationManager(); } return self::$theInstance; }
function loadDataFromStore() { if (file_exists($this->filename)) { $str = file_get_contents($this->filename); $rm = unserialize($str); } else { $rm = RegistrationManager::getInstance(); } return $rm; }
public function testPersistence() { //1.Create test data $rm = RegistrationManager::getInstance(); $participant = new Participant("Frank"); $rm->addParticipant($participant); // 2. Write all of the data $this->pm->writeDataToStore($rm); //3.Clear the data from memory $rm->delete(); //4. Load it back in $rm = $this->pm->loadDataFromStore(); //5. Check that we got it back $this->assertEquals(1, count($rm->getParticipants())); $myParticipant = $rm->getParticipant_index(0); $this->assertEquals("Frank", $myParticipant->getName()); }
public static function register() { date_default_timezone_set('UTC'); $CLIENT_MAC_ADDR = RegistrationManager::getMacAddressForIP($_SERVER['REMOTE_ADDR']); $LOG_DATA = explode("_", trim(shell_exec("grep wifi /home/proximus/config/log.properties"))); $MAC_ADDR = $LOG_DATA[3]; $CAMPAIGN_ID = $LOG_DATA[4]; $timestamp = time(); $filename = "registration_dreamplug_" . $MAC_ADDR . "_" . $CAMPAIGN_ID . "_" . strftime("%Y-%m-%d.%H-%M-%S") . ".log"; $mode = "w"; $handle = fopen(RegistrationManager::$REGISTRATION_LOG_DIR . $filename, $mode); fwrite($handle, "eventDate=" . $timestamp . "\n"); fwrite($handle, "macAddress=" . $CLIENT_MAC_ADDR . "\n"); foreach ($_POST as $key => $val) { fwrite($handle, $key . "=" . $val . "\n"); } fclose($handle); }
public static function RegisterUser($loginID, $password, $longName, $shortName, $emailAddress = null) { $CurrentTenant = Tenant::GetCurrent(); // create an instance of the User object in this tenant $obj = $CurrentTenant->GetObject("User"); // retrieve the salted password from the User object $pwsalt = $obj->GetMethod("SaltPassword")->Execute(); // tell the User object to hash the password $pwhash = $obj->GetMethod("HashPassword")->Execute(array(new TenantObjectMethodParameterValue("input", $pwsalt . $password))); $inst = $obj->CreateInstance(array(new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("LoginID"), $loginID), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("DisplayName"), $longName), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("URL"), $shortName), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("EmailAddress"), $emailAddress), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("PasswordHash"), $pwhash), new TenantObjectInstancePropertyValue($obj->GetInstanceProperty("PasswordSalt"), $pwsalt))); if ($inst != null) { return UserRegistrationStatus::AwaitingVerification; } global $MySQL; RegistrationManager::$ErrorCode = $MySQL->errno; // DataFX::$Errors->Items[0]->Code; RegistrationManager::$ErrorMessage = $MySQL->error; // DataFX::$Errors->Items[0]->Message; return UserRegistrationStatus::GeneralError; }
<?php session_start(); include_once "/home/proximus/bin/php/RegistrationManager.php"; // verify, redirect to form if needed // set to session, incase you send back to form RegistrationManager::register(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, user-scalable=no" /> <meta http-equiv="refresh" content="2;URL='index.html'"> <title>Thanks</title> <link type="text/css" rel="stylesheet" href="prox.css" /> </head> <body> <div id="container"> <div id="header"> #PROX#ImageUploader_logo#PROX# </div> <br /> <div id="header"> <p class="header">THANKS FOR REGISTERING!</p> <br /> </div>
<?php header('Content-type: application/json'); $METHOD = $_SERVER['REQUEST_METHOD']; $APIURI = $_SERVER['REQUEST_URI']; if ($METHOD == 'POST') { $json = file_get_contents('php://input'); $obj = json_decode($json, true); require 'RegistrationManager.php'; $registrationManager = new RegistrationManager(); $registrationManager->registration($obj); } else { header('HTTP/1.1 405 Method Not Allowed'); header('Allow: POST'); }