Пример #1
0
 public static function authUser($username, $password)
 {
     $login = LoginDao::getLoginByUsername($username);
     if ($login != null && CryptoUtil::encrypt($password) == $login->getEncryptedPassword()) {
         return $login;
     }
     return null;
 }
 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);
     }
 }
Пример #3
0
 public function generateClientHTML()
 {
     $adRep = new AdRep(1, "Andrew Melton", "*****@*****.**", "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>";
 }
Пример #4
0
 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>";
         }
     }
 }
Пример #5
0
 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.");
         }
     }
 }
Пример #6
0
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;
    }