本文整理汇总了PHP中SessionUtil::getUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionUtil::getUsername方法的具体用法?PHP SessionUtil::getUsername怎么用?PHP SessionUtil::getUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionUtil
的用法示例。
在下文中一共展示了SessionUtil::getUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleForm
public function handleForm($context, $action)
{
if ($action == "createAd") {
if (isset($_POST['start']) && $_POST['start'] != "" && (isset($_POST['size']) && $_POST['size'] != "") && (isset($_POST['name']) && $_POST['name'] != "") && (isset($_POST['url']) && $_POST['url'] != "")) {
$start = $_POST['start'];
$dayOfWeek = date("D", strtotime($start));
if ($dayOfWeek == "Mon") {
$splitStart = explode("/", $start);
$mysqlStart = $splitStart[2] . "-" . $splitStart[0] . "-" . $splitStart[1];
if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
$filename = $this->saveSampleImage($context, $_FILES['image'], SessionUtil::getUsername());
if ($filename != "") {
WebAdDao::createWebAd($_POST['name'], $mysqlStart, $_POST['size'], $filename, $_POST['url']);
} else {
$context->addError("Error Uploading File, Please Try Again.");
}
} else {
$context->addError("No File Uploaded.");
}
} else {
$context->addError("Starting Date Not a Monday.");
}
} else {
$context->addError("Required Field Left Blank.");
}
} else {
$context->addError("Incorrect Action.");
}
}
示例2: handleForm
public function handleForm(Context $context, $action)
{
if ($action == "createReservation") {
if (isset($_POST['equip_id']) && $_POST['equip_id'] != "" && (isset($_POST['start_date']) && $_POST['start_date'] != "") && (isset($_POST['length']) && $_POST['length'] != "")) {
$equipId = $_POST['equip_id'];
$equip = EquipmentDao::getEquipmentByID($equipId);
if ($equip != null) {
if (SessionUtil::getUserlevel() >= $equip->minUserLevel) {
$startDate = $_POST['start_date'];
$endDate = DateUtil::incrementDate($startDate, $_POST['length']);
$reservations = ReservationDao::getReservationsForEquipmentByDate($equipId, $startDate, $endDate);
if (count($reservations) == 0) {
$user = UserDao::getUserByUsername(SessionUtil::getUsername());
$reservation = ReservationDao::createReservation($user->id, $equipId, $_POST['length'], $startDate, $endDate, $_POST['user_comment']);
EmailUtil::sendNewReservationNotices($user, $reservation);
} else {
$context->addError("Reservations already exist during selected dates ({$startDate} and {$endDate}).");
}
} else {
$context->addError("Cannot reserve equipment (User Level).");
}
} else {
$context->addError("No such equipment.");
}
} else {
$context->addError("Required Field Left Blank.");
}
} else {
$context->addError("Incorrect Action.");
}
}
示例3: generateHTML
function generateHTML()
{
$user = UserDao::getUserByUsername(SessionUtil::getUsername());
$changePasswordRows = "";
if (Config::login_type == LOGIN_TYPE_DB) {
$changePasswordRows = "\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td class=\"centeredcellbold\">Change Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">Current Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">New Password</td>\n\t\t\t\t<td class=\"centeredcellbold\">Confirm Password</td>\n\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<form action=\"./index.php?pageid=savepassword\" method=\"POST\"><td class=\"centeredcellbold\"><input type=\"submit\" value=\"Save Password\"></td>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"curpass\"></td>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"newpass\"></th>\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"password\" name=\"confpass\"></td></form>\n\t\t\t\n\t\t\t\t</tr>";
}
return "<center><h3>My Account</h3>" . $this->context->getErrorHTML() . "</center>\n\t\t\t\n\t\t\t<table class=\"myaccount\">\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"header\">Edit User Information</td>\n\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Username</td>\n\t\t\t\t\t<td colspan=3 class=\"centeredcell\">" . $user->username . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t<tr>\n\t\t\n\t\t\t\t\t<td class=\"centeredcellbold\">Name</th>\n\t\t\t\t\t<td colspan=3 class=\"centeredcell\">" . $user->name . "</td>\n\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\n\t\t\t\t" . $changePasswordRows . "\n\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\t\n\t\t\t\t\t<form action=\"./index.php?pageid=saveemail\" method=\"POST\">\n\t\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Email</th><td colspan=3 class=\"centeredcell\"><input type=\"text\" name=\"email\" size=30 value=\"" . $user->email . "\"><input type=\"submit\" value=\"Save Email\"></td></form>\n\t\t\t\t\t\t\n\t\t\t\t</tr>\n\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=1 class=\"centeredcellbold\">Warnings</th>\n\t\t\t\t\t<td class=\"centeredcellbold\" colspan=3><a href=\"./index.php?pageid=viewMyWarnings\">" . WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) . "(" . WarningDao::getWarningCountForUser($user->id) . ")</a></td>\n\t\t\t\t\n\t\t\t\t</tr>\n\t\t\t\t\t\n\t\t\t</table>";
}
示例4: handleClientDesign
public function handleClientDesign(Context $context)
{
$insertDate = explode('/', $_POST['insertdate']);
$mysqlFormattedDate = $insertDate[2] . "-" . $insertDate[1] . "-" . $insertDate[0];
$clientId = ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()))->getID();
$filename = $this->saveSampleImage($context, $_FILES['sampleimage'], $clientId);
if ($filename != "") {
InsertionOrderDao::createForClientWithImage(ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()))->getID(), $mysqlFormattedDate, $_POST['design'], $_POST['color'], $_POST['columns'], $_POST['height'], $_POST['inserts'], $_POST['placements'], $filename);
}
}
示例5: generateHTML
public function generateHTML()
{
$username = SessionUtil::getUsername();
$user = UserDao::getUserByUsername($username);
$reservations = ReservationDao::getReservationsForUser($user->id, 5);
$reservationHTML = "";
foreach ($reservations as $res) {
$status = $res->getModStatusString();
$equipment = EquipmentDao::getEquipmentByID($res->equipId);
$reservationHTML = $reservationHTML . "<tr>\n\t\t\t\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $equipment->name . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $status . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $res->startDate . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\">" . $res->endDate . "</td>\n\t\t\t\t\t<td class=\"myequip" . $status . "\"><a href=\"./index.php?pageid=viewReservation&resid=" . $res->id . "\">View</a></td>\n\t\t\t\t\t\t\n\t\t\t\t</tr>";
}
return OfficeHourCalendar::HTML . "<h3>Your Reservations</h3>\n\t\t\n\t\t<table class=\"myequip\">\n\t\t\n\t\t\t<tr>\n\t\t\n\t\t\t\t<td class=\"header\">Equipment Name</td>\n\t\t\t\t<td class=\"header\">Status</td>\n\t\t\t\t<td class=\"header\">Check-out Date</td>\n\t\t\t\t<td class=\"header\">Due Date</td>\n\t\t\t\t<td class=\"header\">-</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t" . $reservationHTML . "\n\t\n\t\t</table>";
}
示例6: generateClientHTML
public function generateClientHTML()
{
$adRep = new AdRep(1, "Andrew Melton", "apmelton@radford.edu", "804-267-0327");
$status = new Status(1, "Design", "Your ad has been aproved and is being designed.");
$designStatus = new Status(1, "To Be Designed", "A designer is working on your ad.");
$billingStatus = new Status(1, "Paid", "");
$orders = InsertionOrderDao::getOrdersByClientID(ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()))->getID());
$ordersHTML = "";
foreach ($orders as $order) {
$ordersHTML = $ordersHTML . $order->generateDualRowHTML();
}
return "<br />\n\t\t\t\t<div id=\"insertsheader\">\n\t\t\t\t<table id=\"report2\" border=\"0\">\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t\n\t\t\t\t\t\t<th class=\"adrep\">Your Ad Rep</th>\n\t\t\t\t\t\t<th class=\"created\">Created</th>\n\t\t\t\t\t\t<th class=\"updated\">Updated</th>\n\t\t\t\t\t\t<th class=\"issue\">Issue</th>\n\t\t\t\t\t\t<th class=\"status\">Status</th>\n\t\t\t\t\t\t<th class=\"designstatus\">Design-Status</th>\n\t\t\t\t\t\t<th class=\"billingstatus\">Billing</th>\n\t\t\t\t\t\t<!--<th class=\"arrow\"></th>-->\n\t\t\t\t\t\t\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t\t<div id=\"contentdiv\" class=\"scroll\">\n\t\t\t\t\n\t\t\t\t\t<table id=\"report\" border=\"0\">\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . $ordersHTML . "\n\t\t\t\t\t\n\t\t\t\t\t</table>\n\t\t\t\t\n\t\t\t\t</div>";
}
示例7: generateHTML
public function generateHTML()
{
$user = UserDao::getUserByUsername(SessionUtil::getUsername());
$warnings = WarningDao::getAllWarningsForUser($user->id);
$options = "";
foreach ($warnings as $warning) {
$options .= $warning->toOptionHTML();
}
$warningSelect = "You have no warnings. :)";
if ($options != "") {
$warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select name=\"warnid\">" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
}
return "<center><h3>View My Warnings</h3></center>" . $warningSelect;
}
示例8: generateHTML
function generateHTML()
{
$login = LoginDao::getLoginByUsername(SessionUtil::getUsername());
if ($login->getType() == Login::CLIENT) {
$client = ClientDao::getClientByLogin($login);
return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\n\t\t\t\t<h3>Login</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info</h3>\n\t\t\t\t\n\t\t\t\t<div style=\"width: 45%; margin-left: auto; margin-right: auto;\">\n\t\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t\t<div style=\"float: left; text-align: left;\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"updateAccount\" />\n\t\t\t\t\t\t\t<label for=\"name\" class=\"above\">Name</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"name\" placeholder=\"Name\" value=\"" . $client->getName() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"email\" class=\"above\">Email</label>\n\t\t\t\t\t\t\t<input type=\"email\" name=\"email\" placeholder=\"Email\" value=\"" . $client->getEmail() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"phone\" class=\"above\">Phone</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"phone\" placeholder=\"Phone\" value=\"" . $client->getPhone() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div style=\"float: right; text-align: right;\">\n\t\t\t\t\t\t\t<br /><label for=\"address\" class=\"above\">Address</label>\n\t\t\t\t\t\t\t<textarea name=\"address\" rows=\"3\" cols=\"23\" class=\"text bluefocus\">" . $client->getAddress() . "</textarea>\n\t\t\t\t\t\t\t<br /><br /><input type=\"submit\" value=\"Update Account\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>";
} else {
if ($login->getType() == Login::ADREP) {
$adrep = AdRepDao::getAdRepByLogin($login);
return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\n\t\t\t\t<h3>Login Info</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info (Ad Rep)</h3>\n\t\t\t\t\n\t\t\t\t<div style=\"width: 45%; margin-left: auto; margin-right: auto;\">\n\t\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t\t<div style=\"float: left; text-align: left;\">\n\t\t\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"updateAccount\" />\n\t\t\t\t\t\t\t<label for=\"name\" class=\"above\">Name</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"name\" placeholder=\"Name\" value=\"" . $adrep->getName() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<label for=\"email\" class=\"above\">Email</label>\n\t\t\t\t\t\t\t<input type=\"email\" name=\"email\" placeholder=\"Email\" value=\"" . $adrep->getEmail() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div style=\"float: right; text-align: right;\">\n\t\t\t\t\t\t\t<label for=\"phone\" class=\"above\">Phone</label>\n\t\t\t\t\t\t\t<input type=\"text\" name=\"phone\" placeholder=\"Phone\" value=\"" . $adrep->getPhone() . "\" class=\"text bluefocus\"/>\n\t\t\t\t\t\t\t<br /><br /><input type=\"submit\" value=\"Update Account\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t</div>\n\t\t\t\n\t\t\t</div>";
} else {
return $this->context->getErrorHTML() . "<div class=\"centered\">\n\t\t\t\n\t\t\t\t<h3>Login Info</h3>\n\t\t\t\t\n\t\t\t\t<form action=\"./index.php?pageid=myAccount\" method=\"post\">\n\t\t\t\t\t<input type=\"hidden\" name=\"action\" value=\"changePassword\" />\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"password\" placeholder=\"Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<label for=\"password\" class=\"sameline\">Repeat Password</label>\n\t\t\t\t\t<input type=\"password\" name=\"repeatpassword\" placeholder=\"Repeat Password\" class=\"text bluefocus\"/>\n\t\t\t\t\t<input type=\"submit\" value=\"Change Password\" class=\"stdbutton bluefocus\"/>\n\t\t\t\t</form>\n\t\t\t\t\n\t\t\t\t<h3>Account Info</h3>\n\t\t\t\t\n\t\t\t\t<div class=\"centered error\">Unknown Account Type</div>\n\t\t\t\n\t\t\t</div>";
}
}
}
示例9: generateHTML
public function generateHTML()
{
$user = UserDao::getUserByUsername(SessionUtil::getUsername());
if (WarningDao::getWarningCountForUserByType($user->id, RES_WARNING_ACTIVE) > RES_WARNING_MAX_ACTIVE) {
$this->context->addError("You have too many Active Warnings (more than " . RES_WARNING_MAX_ACTIVE . ") on your account to place Reservations.");
return $this->context->getErrorHTML() . $this->context->getMessagesHTML();
}
//TODO: do we need this?
$allEquipment = EquipmentDao::getAllEquipment();
$equipArray = array();
//^^^^^^^^^^^^^^^^^^^^^^^^^^
$page = "";
$success = false;
if (isset($_POST['equip_id']) && $_POST['equip_id'] != "") {
if (count($this->context->getErrors()) == 0) {
$page = "Successfully Created Reservation.";
$success = true;
} else {
$_GET['equipid'] = $_POST['equip_id'];
}
}
if (!$success && isset($_GET['equipid']) && $_GET['equipid'] != "") {
$equip = EquipmentDao::getEquipmentByID($_GET['equipid']);
if ($equip != null) {
if (SessionUtil::getUserlevel() >= $equip->minUserLevel) {
$lengthOptions = "";
for ($i = 1; $i <= $equip->maxLength; $i++) {
if ($i > 1) {
$lengthOptions = $lengthOptions . "<option value=\"" . $i . "\">" . $i . " Days</option>";
} else {
$lengthOptions = $lengthOptions . "<option value=\"" . $i . "\">" . $i . " Day</option>";
}
}
$page = "\n\n\t\t<form name=\"reservation\" action=\"./index.php?pageid=placeReservation\" method=\"POST\" onsubmit=\"return checkDate();\">\n\t\t<input type=\"hidden\" name=\"action\" value=\"createReservation\">\n\t\t<input type=\"hidden\" name=\"equip_id\" value=\"" . $_GET['equipid'] . "\">\n\t\t<table class=\"reservation\">\n\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=4 class=\"header\">Reserve the " . $equip->name . "</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"centeredcellbold\">Date (YYYY-MM-DD)</td>\n\t\t\t\t<td class=\"centeredcell\">\n\t\t\t\t\t<input type=\"text\" readonly name=\"start_date\" id=\"startdate\" class=\"date\" value=\"blah\"/>\n\t\t\t\t</td>\n\t\t\t\t<td class=\"centeredcellbold\">Length</td>\n\t\t\t\t<td class=\"centeredcell\"><select name=\"length\">" . $lengthOptions . "</select></td>\n\t\t\n\t\t\t</tr>\n\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=1 class=\"centeredcellbold\">User Comment</th>\n\t\t\t\t<td class=\"centeredcell\" colspan=3><textarea rows=5 cols=45 name=\"user_comment\"></textarea></td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\t\n\t\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t\t<td colspan=4 class=\"centeredcell\"><input type=\"submit\" value=\"Reserve\"></td>\n\t\t\n\t\t\t\t</tr>\n\t\t\t\t\n\t\t\t</table>\n\t\t\t</form></div>";
} else {
$this->context->addError("Cannot reserve equipment (User Level).");
}
} else {
$this->context->addError("No equipment with ID '" . $_GET['equipid'] . "'.");
}
} else {
if (!$success) {
$this->context->addError("No equipment selected.");
}
}
return "<center><h3>Place Reservation</h3>" . $this->context->getErrorHTML() . "</center>" . $page;
}
示例10: handleForm
public function handleForm(Context $context, $action)
{
if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
if ($action == "deleteWarning") {
$warning = WarningDao::getWarningByID($_POST['warnId']);
if ($warning != null) {
WarningDao::deleteWarning($warning->id);
$context->addMessage("Successfully deleted warning.");
} else {
$context->addError("No such warning.");
}
} else {
$context->addError("Incorrect Action.");
}
} else {
$context->addError("Not Authorized.");
}
}
示例11: generateHTML
public function generateHTML()
{
$myuser = UserDao::getUserByUsername(SessionUtil::getUsername());
$user = UserDao::getUserByID($_GET['userid']);
if ($myuser->userlevel < RES_USERLEVEL_ADMIN) {
$this->context->addError("Not Authorized.");
return $this->context->getErrorHTML();
}
$warnings = WarningDao::getAllWarningsForUser($user->id);
$options = "";
foreach ($warnings as $warning) {
$options .= $warning->toOptionHTML();
}
$warningSelect = $user . " has no warnings.";
if ($options != "") {
$warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select name=\"warnid\">" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
}
return "<center><h3>View Warnings For " . $user . "</h3></center>" . $warningSelect;
}
示例12: handleForm
public function handleForm(Context $context, $action)
{
if ($action == "changePassword") {
if ($_POST['password'] != "" && $_POST['repeatpassword'] != "") {
$sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername());
if ($_POST['password'] == $_POST['repeatpassword']) {
LoginDao::updateUserPassword($sessionLogin, $_POST['password']);
} else {
$context->addError("Passwords don't match.");
}
} else {
$context->addError("Required field left blank.");
}
} else {
if ($action == "updateAccount") {
if ($_POST['name'] != "" && $_POST['email'] != "" && $_POST['phone'] != "") {
$sessionLogin = LoginDao::getLoginByUsername(SessionUtil::getUsername());
if ($sessionLogin->getType() == Login::ADREP) {
$adrep = AdRepDao::getAdRepByLogin($sessionLogin);
AdRepDao::updateAdRep($adrep, $_POST['name'], $_POST['email'], $_POST['phone']);
} else {
if ($sessionLogin->getType() == Login::CLIENT) {
if ($_POST['address'] != "") {
$client = ClientDao::getClientByLogin($sessionLogin);
ClientDao::updateClient($client, $_POST['name'], $_POST['email'], $_POST['phone'], $_POST['address']);
} else {
$context->addError("Required field left blank.");
}
} else {
$context->addError("Unknown Account Type.");
}
}
} else {
$context->addError("Required field left blank.");
}
} else {
$context->addError("Incorrect Action.");
}
}
}
示例13: handleForm
public function handleForm(Context $context, $action)
{
if (UserDao::getUserByUsername(SessionUtil::getUsername())->userlevel == RES_USERLEVEL_ADMIN) {
if ($action == "createWarning") {
if (isset($_POST['userId']) && $_POST['userId'] != "" && (isset($_POST['reason']) && $_POST['reason'] != "") && (isset($_POST['type']) && $_POST['type'] != "")) {
$user = UserDao::getUserByID($_POST['userId']);
if ($user != null) {
$warning = WarningDao::warnUser($_POST['userId'], $_POST['reason'], $_POST['type']);
EmailUtil::sendWarningNoticeToUser($warning);
$context->addMessage("Successfully warned " . $user);
} else {
$context->addError("No such user.");
}
} else {
$context->addError("Required field left blank.");
}
} else {
$context->addError("Incorrect Action.");
}
} else {
$context->addError("Not Authorized.");
}
}
示例14: generateHTML
public function generateHTML()
{
$myuser = UserDao::getUserByUsername(SessionUtil::getUsername());
$warning = WarningDao::getWarningByID($_GET['warnid']);
$user = UserDao::getUserByID($warning->userId);
if ($user->id != $myuser->id && $myuser->userlevel < RES_USERLEVEL_ADMIN) {
$this->context->addError("Not Authorized.");
return $this->context->getErrorHTML();
}
$warnings = WarningDao::getAllWarningsForUser($user->id);
$options = "";
foreach ($warnings as $warning) {
$options .= $warning->toOptionHTML();
}
$warningSelect = $user . " has no warnings.";
if ($options != "") {
$warningSelect = "<form action=\"./index.php\" method=\"GET\">" . "<input type=\"hidden\" name=\"pageid\" value=\"viewWarning\" />" . "<select>" . $options . "</select>" . "<input type=\"submit\" value=\"View\" />" . "</form>";
}
$adminRow = "";
if ($myuser->userlevel >= RES_USERLEVEL_ADMIN) {
$adminRow = "<tr><form action=\"./index.php?pageid=adminWarning\" method=\"POST\">" . "<td colspan=2 class=\"centeredcellbold\">" . "<input type=\"hidden\" name=\"action\" value=\"deleteWarning\" />" . "<input type=\"hidden\" name=\"warnId\" value=\"" . $warning->id . "\" />" . "<input type=\"submit\" value=\"Delete\" /></td></form></tr>";
}
return "<center><h3>View Warning For " . $user . "</h3></center><table class=\"warning\">\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"header\">Type</td>\n\t\t\t\t<td class=\"header\">Time</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td class=\"centeredcell\">" . $warning->getTypeString() . "</td>\n\t\t\t\t<td class=\"centeredcell\">" . $warning->datetime . "</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=2 class=\"header\">Warning Reason</td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\n\t\t\t\t<td colspan=2 class=\"centeredcell\"><textarea cols=\"55\" rows=\"7\" readonly>" . $warning->reason . "</textarea></td>\n\t\t\t\n\t\t\t</tr>\n\t\t\t" . $adminRow . "\n\t\t\n\t\t</table>";
}
示例15: SimpleImage
require_once './lib/Util/SessionUtil.php';
require_once './lib/Util/SimpleImage.php';
if (!SessionUtil::start()) {
echo "Error Starting Session";
}
Database::Open();
if (isset($_GET['insertId'])) {
$insert = InsertionOrderDao::getByID($_GET['insertId']);
if (!$insert) {
$image = new SimpleImage();
$image->load('./images/notfound.png');
header('Content-Type: image/jpeg');
echo $image->output();
exit;
}
$client = ClientDao::getClientByLogin(LoginDao::getLoginByUsername(SessionUtil::getUsername()));
if ($insert->getClient()->getID() == $client->getID() && file_exists($insert->getImageLoc())) {
$image = new SimpleImage();
$image->load($insert->getImageLoc());
$hratio = 150 / $image->getHeight();
$wratio = 150 / $image->getWidth();
$image->scale(min($hratio, $wratio) * 100);
header('Content-Type: image/jpeg');
echo $image->output();
} else {
$image = new SimpleImage();
$image->load('./images/notfound.png');
header('Content-Type: image/jpeg');
echo $image->output();
exit;
}