public static function registration() { SystemEvent::raise(SystemEvent::DEBUG, "Called.", __METHOD__); // // Check for validity // if (empty($_POST['registrationForm']['name']['value']) || empty($_POST['registrationForm']['email']['value']) || empty($_POST['registrationForm']['username']['value']) || empty($_POST['registrationForm']['password']['value']) || empty($_POST['registrationForm']['password2']['value'])) { SystemEvent::raise(SystemEvent::DEBUG, "User registration failed, required attributes were empty.", __METHOD__); echo json_encode(array('success' => false, 'error' => 'Please fill in all input fields.')); exit; } else { if ($_POST['registrationForm']['password']['value'] != $_POST['registrationForm']['password2']['value']) { SystemEvent::raise(SystemEvent::DEBUG, "Passwords don't match.", __METHOD__); echo json_encode(array('success' => false, 'error' => "The passwords don't match.")); exit; } else { $user = User::getByUsername($_POST['registrationForm']['username']['value']); if ($user instanceof User) { SystemEvent::raise(SystemEvent::DEBUG, "Username already taken.", __METHOD__); echo json_encode(array('success' => false, 'error' => 'The username you provided is already taken.')); exit; } $user = null; unset($user); } } // // Everything ok, let's register the new user // $user = new User(); $user->setEmail($_POST['registrationForm']['email']['value']); //$user->setNotificationEmails($_POST['registrationForm']['email']['value']); $user->setName($_POST['registrationForm']['name']['value']); $user->setUsername($_POST['registrationForm']['username']['value']); $user->setCos(UserCos::USER); $user->init(); $user->setPassword($_POST['registrationForm']['password']['value']); // // Log the user in // /* Auth::authenticate(); */ SystemEvent::raise(SystemEvent::INFO, "New user created. [USERNAME={$user->getUsername()}]", __METHOD__); echo json_encode(array('success' => true, 'error' => 'Registration was successful, taking you to the login prompt. Stand by...')); exit; }
$msg = "Problems commiting all changes to the database."; SystemEvent::raise(CINTIENT_LOG_SEVERITY_ERROR, $msg, "Installer"); sendResponse($ok, $msg); } $settings = SystemSettings::load(); $settings->setSetting(SystemSettings::VERSION, CINTIENT_INSTALLER_VERSION); if (!$upgrade) { // // Root user account // $user = new User(); $user->setEmail($get['email']); $user->setNotificationEmails($get['email'] . ','); $user->setName('Administrative Account'); $user->setUsername('root'); $user->setCos(2); $user->init(); $user->setPassword($get['password']); } // Just to make sure everything's neat and tidy, especially after // an upgrade. Database::execute('VACUUM'); // // Last step: remove the installation file // if (!@unlink(__FILE__)) { $ok = false; $msg = "Couldn't remove the installation 'index.php' file. You need " . "to remove this manually before refreshing this page, or else" . " Cintient won't be able to start"; sendResponse($ok, $msg); } //
public static function install() { session_destroy(); // // Create necessary dirs // if (!file_exists(CINTIENT_WORK_DIR) && !mkdir(CINTIENT_WORK_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create working dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_PROJECTS_DIR) && !mkdir(CINTIENT_PROJECTS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create projects dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_ASSETS_DIR) && !mkdir(CINTIENT_ASSETS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create assets dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!file_exists(CINTIENT_AVATARS_DIR) && !mkdir(CINTIENT_AVATARS_DIR, DEFAULT_DIR_MASK, true)) { SystemEvent::raise(SystemEvent::ERROR, "Could not create avatars dir. Check your permissions.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } // // Setup all objects // if (!User::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup User object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!Project::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup Project object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } if (!SystemSettings::install()) { SystemEvent::raise(SystemEvent::ERROR, "Could not setup SystemSettings object.", __METHOD__); echo "Error"; // TODO: treat this properly exit; } // // Test user setup // $user = new User(); $user->setEmail('*****@*****.**'); $user->setNotificationEmails('pedro.matamouros@gmail.com,'); $user->setName('Pedro Mata-Mouros'); $user->setUsername('matamouros'); $user->setCos(UserCos::ROOT); $user->init(); $user->setPassword('pedro'); header('Location: ' . UrlManager::getForDashboard()); exit; }
/** * * @param unknown_type $rs */ private static function _getObject($rs) { $ret = new User(); $ret->setAvatar($rs->getAvatar()); $ret->setCos($rs->getCos()); $ret->setCreationDate($rs->getCreationDate()); $ret->setEmail($rs->getEmail()); $ret->setEnabled($rs->getEnabled()); $ret->setId($rs->getId()); $ret->setName($rs->getName()); $ret->setUsername($rs->getUsername()); // // The following is a workaround on the fact that the translation of this // serialized object to the database gets all broken, due to the fact of PHP // introducing NULL bytes around the '*' that is prepended before protected // variable members, in the serialized mode. This method replaces those // problematic NULL bytes with an identifier string '~~NULL_BYTE~~', // rendering serialization and unserialization of these specific kinds of // object safe. Credits to travis@travishegner.com on: // http://pt.php.net/manual/en/function.serialize.php#96504 // $unsafeSerializedNotifications = str_replace(CINTIENT_NULL_BYTE_TOKEN, "", $rs->getNotifications()); if (($notifications = unserialize($unsafeSerializedNotifications)) === false) { $notifications = array(); } $ret->setNotifications($notifications); $ret->resetSignature(); return $ret; }