Esempio n. 1
0
 public function action_index()
 {
     // add
     if (!empty($_FILES["file"]) and is_uploaded_file($_FILES["file"]["tmp_name"])) {
         $ext = explode(".", $_FILES["file"]["name"]);
         if (strtolower($ext[1]) == "pdf" or strtolower($ext[1]) == "doc" or strtolower($ext[1]) == "docx") {
             $filename = str_replace("/", "", $_FILES["file"]["name"]);
             $filepath = DOCROOT . "/contents/" . $filename;
             if (move_uploaded_file($_FILES["file"]["tmp_name"], $filepath)) {
                 chmod($filepath, 0644);
                 // save
                 if (Input::post("doc_type") == 1) {
                     $documents = Model_Document::query()->where('type', 2)->where('deleted_at', 0)->limit(1)->get_one();
                     if (count($documents) < 1) {
                         $document = Model_Document::forge();
                         $document->path = $filename;
                         $document->type = Input::post("doc_type");
                         $document->save();
                     } else {
                         $query = Model_Document::find($documents->id);
                         $query->path = $filename;
                         $query->type = Input::post("doc_type");
                         $query->save();
                     }
                 } else {
                     $document = Model_Document::forge();
                     $document->path = $filename;
                     $document->type = Input::post("doc_type");
                     $document->save();
                 }
                 Response::redirect("/admin/documents/");
             } else {
                 Response::redirect("/admin/documents/?e=1");
             }
         } else {
             Response::redirect("/admin/documents/?e=3");
         }
     }
     $where = [["deleted_at", 0], ["type", 0]];
     $data["documents"] = Model_Document::find("all", ["where" => $where, "order_by" => [["created_at", "desc"]]]);
     $where_online = [["deleted_at", 0], ["type", 1]];
     $data["online"] = Model_Document::find("all", ["where" => $where_online, "order_by" => [["created_at", "desc"]]]);
     $config = array('pagination_url' => "", 'uri_segment' => "p", 'num_links' => 9, 'per_page' => 100, 'total_items' => count($data["documents"]));
     $data["pager"] = Pagination::forge('mypagination', $config);
     $data["documents"] = array_slice($data["documents"], $data["pager"]->offset, $data["pager"]->per_page);
     $view = View::forge("admin/documents/index", $data);
     $this->template->content = $view;
 }
Esempio n. 2
0
 public function action_submit()
 {
     if (!Security::check_token()) {
         Response::redirect('_404_');
     }
     if (Session::get_flash('email')) {
         $email = Session::get_flash("email");
         Auth::create_user($email, Session::get_flash("password"), $email, 1);
         $user = Model_User::find("first", ["where" => [["email", $email]]]);
         if ($user != null) {
             $user->sex = Session::get_flash("sex");
             $user->firstname = Session::get_flash("firstname");
             $user->middlename = Session::get_flash("middlename");
             $user->lastname = Session::get_flash("lastname");
             $user->birthday = Session::get_flash("year") . "-" . Session::get_flash("month") . "-" . Session::get_flash("day");
             $user->google_account = Session::get_flash("google_account");
             $user->need_reservation_email = Session::get_flash("need_reservation_email");
             $user->need_news_email = Session::get_flash("need_news_email");
             $user->timezone = Session::get_flash("timezone");
             $user->place = Session::get_flash("grameen");
             $user->grameen_student = Session::get_flash("grameen_student");
             $user->nationality = Session::get_flash("nationality");
             $user->save();
             // send mail
             $body = View::forge("email/students/signup");
             $body->set("name", $user->firstname);
             $body->set("user", $user);
             $body->set("ymd", explode("-", $user->birthday));
             $sendmail = Email::forge("JIS");
             $sendmail->from(Config::get("statics.info_email"), Config::get("statics.info_name"));
             $sendmail->to($user->email);
             $sendmail->subject("Welcome Aboard! / Game-BootCamp");
             $sendmail->html_body(htmlspecialchars_decode($body));
             $documents = Model_Document::query()->where('type', 1)->where('deleted_at', 0)->limit(1)->get_one();
             if (count($documents) > 0) {
                 $query = Model_Document::find($documents->id);
                 $sendmail->attach(DOCROOT . '/contents/' . $query->path);
             }
             $sendmail->send();
         } else {
             Response::redirect('_404_/?hehe');
         }
     } else {
         Response::redirect('_404_');
     }
     $this->template->content = View::forge('students/signup/finish');
 }
Esempio n. 3
0
<?php

$documents = Model_Document::query()->where('type', 1)->where('deleted_at', 0)->limit(1)->get_one();
$query1 = Model_Document::find($documents->id);
$documents = Model_Document::query()->where('type', 2)->where('deleted_at', 0)->limit(1)->get_one();
$query2 = Model_Document::find($documents->id);
$doc1 = "/contents/" . $query1->path;
$doc2 = "/contents/" . $query2->path;
$open = Input::get('open', NULL);
if (!Auth::check()) {
    if ($open != 0) {
        ?>
			<input type="text" value="<?php 
        if ($open == 1) {
            echo "1";
        } elseif ($open == 2) {
            echo "2";
        }
        ?>
" id="openDoc" hidden/>
	<?php 
    }
} else {
    if (isset($student)) {
        $place = $student->place;
        ?>
			<input type="text" value="<?php 
        if ($place == 0) {
            echo "1";
        } elseif ($place == 1) {
            echo "2";