Beispiel #1
0
 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'];
             $end = $_POST['end'];
             $dayOfWeek = date("D", strtotime($start));
             $splitStart = explode("/", $start);
             $mysqlStart = $splitStart[2] . "-" . $splitStart[0] . "-" . $splitStart[1];
             $splitEnd = explode("/", $end);
             $mysqlEnd = $splitEnd[2] . "-" . $splitEnd[0] . "-" . $splitEnd[1];
             if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) {
                 $filename = $this->saveSampleImage($context, $_FILES['image'], SessionUtil::getUsername());
                 if ($filename != "") {
                     WebAdDao::createWebAd($_POST['name'], DateUtil::findPreviousMonday($mysqlStart), $_POST['size'], $filename, $_POST['url'], $mysqlStart, $mysqlEnd);
                 } else {
                     $context->addError("Error Uploading File, Please Try Again.");
                 }
             } else {
                 $context->addError("No File Uploaded.");
             }
         } else {
             $context->addError("Required Field Left Blank.");
         }
     } else {
         $context->addError("Incorrect Action.");
     }
 }
Beispiel #2
0
 public static function getAdsByDay($date)
 {
     $query = "SELECT * FROM " . Database::addPrefix('webads') . " WHERE StartingMonday = '" . DateUtil::findPreviousMonday($date) . "'";
     $result = Database::doQuery($query);
     $webads = array();
     while ($row = mysql_fetch_assoc($result)) {
         $webads[] = WebAdDao::makeAd($row);
     }
     return $webads;
 }
Beispiel #3
0
 public function generateMondaySelectForm()
 {
     $select = "<form action=\"./index.php?pageid=viewAds\" method=\"POST\">\n\t\t\t<input type=\"hidden\" name=\"action\" value=\"setPageVar\">\n\t\t\t<select name=\"monday\" class=\"bluefocus\">";
     $mondays = WebAdDao::getDistinctMondays();
     foreach ($mondays as $monday) {
         if (DateUtil::findPreviousMonday($this->startingMonday) == $monday) {
             $select = $select . "<option value=\"" . $monday . "\" selected=\"selected\">" . $monday . "</option>";
         } else {
             $select = $select . "<option value=\"" . $monday . "\">" . $monday . "</option>";
         }
     }
     $select = $select . "</select> <input type=\"submit\" value=\"Go\" class=\"stdbutton bluefocus\" \\></form>";
     return $select;
 }