Ejemplo n.º 1
0
 public function index()
 {
     // require_once(MODPATH . "aws_s3/lib/s3.php");
     $form = $this->_get_s3_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             module::set_var("aws_s3", "enabled", isset($_POST['enabled']) ? true : false);
             module::set_var("aws_s3", "access_key", $_POST['access_key']);
             module::set_var("aws_s3", "secret_key", $_POST['secret_key']);
             module::set_var("aws_s3", "bucket_name", $_POST['bucket_name']);
             module::set_var("aws_s3", "g3id", $_POST['g3id']);
             module::set_var("aws_s3", "url_str", $_POST['url_str']);
             module::set_var("aws_s3", "sig_exp", $_POST['sig_exp']);
             module::set_var("aws_s3", "use_ssl", isset($_POST['use_ssl']) ? true : false);
             if (module::get_var("aws_s3", "enabled") && !module::get_var("aws_s3", "synced", false)) {
                 site_status::warning(t('Your site has not yet been syncronised with your Amazon S3 bucket. Content will not appear correctly until you perform syncronisation. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/aws_s3_task::sync?csrf=__CSRF__")))), "aws_s3_not_synced");
             }
             message::success(t("Settings have been saved"));
             url::redirect("admin/aws_s3");
         } else {
             message::error(t("There was a problem with the submitted form. Please check your values and try again."));
         }
     }
     $v = new Admin_View("admin.html");
     $v->page_title = t("Amazon S3 Configuration");
     $v->content = new View("admin_aws_s3.html");
     $v->content->form = $form;
     $v->content->end = "";
     echo $v;
 }
 public function index()
 {
     if ($this->auth->logged_in()) {
         $this->template->title = 'Already Logged In';
         $this->template->content = new View('login/login_message');
         $this->template->content->message = 'You are already logged in.<br />';
         $this->template->content->link_to_home = 'YES';
         $this->template->content->link_to_logout = 'YES';
         return;
     }
     $this->template->title = 'Forgotten Password Email Request';
     $this->template->content = new View('login/forgotten_password');
     if (request::method() == 'post') {
         $post = new Validation($_POST);
         $post->pre_filter('trim', TRUE);
         $post->add_rules('UserID', 'required');
         $returned = $this->auth->user_and_person_by_username_or_email($_POST['UserID']);
         if (array_key_exists('error_message', $returned)) {
             $this->template->content->error_message = $returned['error_message'];
             return;
         }
         $user = $returned['user'];
         $person = $returned['person'];
         if (!$this->check_can_login($user)) {
             return;
         }
         $this->auth->send_forgotten_password_mail($user, $person);
         $this->template->title = 'Email Sent';
         $this->template->content = new View('login/login_message');
         $this->template->content->message = 'An email providing a link which will allow your password to be reset has been sent to the specified email address, or if a username was provided, to the registered email address for that user.<br />';
     }
 }
 public function single()
 {
     // Check auth here
     if (intval(Router::$arguments[0])) {
         $id = intval(Router::$arguments[0]);
     } else {
         throw new Kohana_Exception();
     }
     switch (strtoupper(request::method())) {
         case "GET":
             echo json_encode($this->get_messages_array($id));
             break;
         case "POST":
             $this->rest_error(501);
             break;
         case "PUT":
             // Messages are read-only
             $this->rest_error(405);
             break;
         case "DELETE":
             $message = ORM::factory('message', $id);
             if ($message->loaded) {
                 $message->delete();
             } else {
                 $this->rest_error(404);
             }
             break;
     }
 }
 public function single()
 {
     // Check auth here
     if (intval(Router::$arguments[0])) {
         $id = intval(Router::$arguments[0]);
     } else {
         throw new Kohana_Exception();
     }
     switch (strtoupper(request::method())) {
         case "GET":
             echo json_encode($this->get_categories_array($id));
             break;
         case "POST":
             // Not sure what this would do
             $this->rest_error(405);
             break;
         case "PUT":
             if (!$this->admin) {
                 $this->rest_error(401);
             }
             $this->rest_error(501);
             break;
         case "DELETE":
             if (!$this->admin) {
                 $this->rest_error(401);
             }
             $category = ORM::factory('category', $id);
             if ($category->loaded) {
                 $category->delete();
             } else {
                 $this->rest_error(404);
             }
             break;
     }
 }
Ejemplo n.º 5
0
 public function profile_pic()
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $client_id = $this->auth->get_user()->id;
         //print_r($_FILES['profile-image']);exit;
         if (!empty($_FILES['profile-image']['name'])) {
             $tempFile = $_FILES["profile-image"]["tmp_name"];
             $filename = $_FILES["profile-image"]["name"];
             $targetPath = 'assets/uploads/';
             $temp = explode(".", $filename);
             $extension = end($temp);
             if (!is_dir($targetPath)) {
                 mkdir($targetPath, 0700);
                 $salt = 'user-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetPath, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             } else {
                 $salt = 'user-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetFile, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             }
         } else {
             $json = $this->auth->get_user()->user_avatar;
         }
         $data_profile_pic = array("user_avatar" => $json);
         log_helper::add("2", $this->user_log, $this->user_id, "Profile Picture was Successfully Updated");
         $this->setting_model->update_user($this->auth->get_user()->id, $data_profile_pic);
     }
 }
Ejemplo n.º 6
0
 /**
  * bit.ly module's settings
  * @todo Show default tweet value after resetting it!
  */
 public function index()
 {
     $form = twitter::get_configure_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             $consumer_key = $form->twitter_oauth->consumer_key->value;
             $consumer_secret = $form->twitter_oauth->consumer_secret->value;
             $reset_tweet = $form->twitter_message->reset_tweet->value;
             if ($reset_tweet) {
                 $default_tweet = twitter::reset_default_tweet();
             } else {
                 $default_tweet = $form->twitter_message->default_tweet->value;
             }
             $shorten_urls = $form->urls->shorten_urls->value;
             module::set_var("twitter", "consumer_key", $consumer_key);
             module::set_var("twitter", "consumer_secret", $consumer_secret);
             module::set_var("twitter", "default_tweet", $default_tweet);
             module::set_var("twitter", "shorten_urls", $shorten_urls);
             message::success("Twitter settings saved");
             url::redirect("admin/twitter");
         }
     }
     $is_registered = twitter::is_registered();
     $v = new Admin_View("admin.html");
     $v->page_title = t("Twitter");
     $v->content = new View("admin_twitter.html");
     $v->content->form = $form;
     $v->content->is_registered = $is_registered;
     print $v;
 }
 public function __toString()
 {
     /**
      * poa = product options atributes
      */
     //     echo Kohana::debug(@$_POST);
     $opa = new fpp_product_has_attributes_product_Model();
     $orm = $opa->db2cls();
     $uri = URI::Instance();
     $id = (int) $uri->segment("edit");
     if (request::method() == 'post' and is_array(@$_POST['opt'])) {
         $orm->delete(array('product_id_product' => $id));
         foreach ($_POST['opt'] as $key => $value) {
             $orm = $opa->db2cls();
             $data['product_id_product'] = $id;
             //         $data['ap_id_attributes_product']            = @$_POST['atr'][$key];
             $data['prefix'] = @$_POST['prefix'][$key];
             $data['vap_id_values_atributtes_product'] = @$_POST['opt'][$key];
             $data['value'] = @$_POST['val'][$key];
             $data['extra'] = @$_POST['extra'][$key];
             $orm->set_fields($data);
             $orm->save();
         }
     }
     $results = $this->GetAttr($id);
     //     fetch_where(array('product_id_product'=> ) );
     $atr_p = new fpp_attributes_product_Model();
     $orm_atrp = $atr_p->db2cls();
     $attributes = form::dropdown("poa_id", $orm_atrp->select_list('id_attributes_product', 'name_attributes_product'));
     $string = View::factory("extras/ajaxattributes")->set("attributes", $attributes)->set("results", $results)->render();
     return $string;
 }
 public function index()
 {
     $form = $this->_get_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             module::set_var("strip_exif", "exiv_path", $_POST['exiv_path']);
             if ($_POST['exif_tags'] != "") {
                 module::set_var("strip_exif", "exif_remove", isset($_POST['exif_remove']) ? $_POST['exif_remove'] : false);
                 module::set_var("strip_exif", "exif_tags", $_POST['exif_tags']);
             } else {
                 module::set_var("strip_exif", "exif_remove", false);
                 module::set_var("strip_exif", "exif_tags", self::$defExifTags);
             }
             if ($_POST['iptc_tags'] != "") {
                 module::set_var("strip_exif", "iptc_remove", isset($_POST['iptc_remove']) ? $_POST['iptc_remove'] : false);
                 module::set_var("strip_exif", "iptc_tags", $_POST['iptc_tags']);
             } else {
                 module::set_var("strip_exif", "iptc_remove", false);
                 module::set_var("strip_exif", "iptc_tags", self::$defIptcTags);
             }
             if (isset($_POST['verbose'])) {
                 module::set_var("strip_exif", "verbose", $_POST['verbose']);
             }
             message::success(t("Settings have been saved"));
             url::redirect("admin/strip_exif");
         } else {
             message::error(t("There was a problem with the submitted form. Please check your values and try again."));
         }
     }
     print $this->_get_view();
 }
Ejemplo n.º 9
0
 public function index()
 {
     if (request::method() == "post") {
         $this->_try_login();
     } else {
         print $this->_login_form();
     }
 }
Ejemplo n.º 10
0
 public function getOne()
 {
     if (request::is_ajax() and request::method() == 'get') {
         $this->auto_render = FALSE;
         $setting = $this->setting_model->getOne();
         echo json_encode($setting);
     }
 }
Ejemplo n.º 11
0
 private static function _prompt_for_reauth($controller_name, $args)
 {
     if (request::method() == "get" && !request::is_ajax()) {
         // Avoid anti-phishing protection by passing the url as session variable.
         Session::instance()->set("continue_url", url::current(true));
     }
     url::redirect("reauthenticate");
 }
Ejemplo n.º 12
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $category = $this->category_model->find($id);
         echo $this->category_model->delete($category->id);
         log_helper::add("1", $this->user_log, $this->user_id, "Deleted Category named " . $category->name . ".");
     }
 }
 public function delete($id)
 {
     if (request::is_ajax() and request::method() === 'post') {
         $this->auto_render = FALSE;
         $officeBudget = $this->budget_model->with('office')->find($id);
         log_helper::add("2", $this->user_log, $this->user_id, "Deleted a Office Budget for " . $officeBudget->office->name . ".");
         echo $this->budget_model->delete($id);
     }
 }
Ejemplo n.º 14
0
 public function save()
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $post = security::xss_clean($this->input->post());
         log_helper::add("1", $this->user_log, $this->user_id, "Added New Purchase");
         $this->purchase_model->insert($post);
     }
 }
Ejemplo n.º 15
0
 public function save()
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $post = security::xss_clean($this->input->post());
         $latest = json_helper::convert($this->district_model->insert($post));
         echo json_encode($latest);
     }
 }
Ejemplo n.º 16
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $supplier = $this->supplier_model->find($id);
         log_helper::add("1", $this->user_log, $this->user_id, "Deleted Supplier named " . $supplier->name . ".");
         echo $this->supplier_model->delete($id);
     }
 }
Ejemplo n.º 17
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $office = $this->office_model->with('district')->find($id);
         log_helper::add("1", $this->user_log, $this->user_id, "Deleted Office named " . $office->name . ".");
         echo $this->office_model->delete($id);
     }
 }
Ejemplo n.º 18
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $request = $this->request_model->find($id);
         log_helper::add("1", $this->user_log, $this->user_id, "Request deleted with reference no. " . $request->reference_no . ".");
         echo $this->request_model->delete($id);
     }
 }
Ejemplo n.º 19
0
 private static function _prompt_for_reauth($controller_name, $args)
 {
     if (request::method() == "get") {
         // Avoid anti-phishing protection by passing the url as session variable.
         Session::instance()->set("continue_url", url::abs_current(true));
     }
     // Save the is_ajax value as we lose it, if set, when we redirect
     Session::instance()->set("is_ajax_request", request::is_ajax());
     url::redirect("reauthenticate");
 }
Ejemplo n.º 20
0
 public function do_reset()
 {
     if (request::method() == "post") {
         $this->_change_password();
     } else {
         $user = user::lookup_by_hash(Input::instance()->get("key"));
         if (!empty($user)) {
             print $this->_new_password_form($user->hash);
         } else {
             throw new Exception("@todo FORBIDDEN", 503);
         }
     }
 }
Ejemplo n.º 21
0
 public function do_reset()
 {
     if (request::method() == "post") {
         $this->_change_password();
     } else {
         $user = ORM::factory("user")->where("hash", Input::instance()->get("key"))->find();
         if ($user->loaded) {
             print $this->_new_password_form($user->hash);
         } else {
             throw new Exception("@todo FORBIDDEN", 503);
         }
     }
 }
 /**
  * the index page of the user homes admin
  */
 public function index()
 {
     $form = upload_configuration::get_configure_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             upload_configuration::extractForm($form);
             message::success(t("GWTOrganise Module Configured!"));
         }
     } else {
         upload_configuration::populateForm($form);
     }
     print $form;
 }
Ejemplo n.º 23
0
 public function index()
 {
     $form = $this->_get_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             module::set_var("auto_date", "template", $_POST['template']);
             message::success(t("Settings have been saved"));
             url::redirect("admin/auto_date");
         } else {
             message::error(t("There was a problem with the submitted form. Please check your values and try again."));
         }
     }
     print $this->_get_view();
 }
Ejemplo n.º 24
0
 public function __construct()
 {
     $this->db = Database::instance();
     $this->auth = Auth::instance();
     $this->_login();
     header("Cache-Control: no-cache, must-revalidate");
     // HTTP/1.1
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     // Date in the pass
     // currently always json
     header("Content-type: application/json; charset=utf-8");
     // Parse HTTP put data
     if (strtoupper(request::method()) == 'PUT' or strtoupper(request::method()) == 'POST') {
         $this->data = json_decode(file_get_contents("php://input"));
     }
 }
Ejemplo n.º 25
0
 /**
  * We're expecting to run in an environment that only supports GET/POST, so expect to tunnel
  * PUT and DELETE through POST.
  *
  * Returns the HTTP request method taking into consideration PUT/DELETE tunneling.
  * @return string HTTP request method
  */
 static function request_method()
 {
     if (request::method() == "get") {
         return "get";
     } else {
         $input = Input::instance();
         switch (strtolower($input->post("_method", $input->get("_method", request::method())))) {
             case "put":
                 return "put";
             case "delete":
                 return "delete";
             default:
                 return "post";
         }
     }
 }
Ejemplo n.º 26
0
 public function update($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $changes = "";
         $post = security::xss_clean($this->input->post('name'));
         $district = $this->district_model->find($id);
         $changes .= custom_helper::compare_variable("District Name", $district->name, $post);
         if ($changes != "") {
             $changes = substr($changes, 0, -2) . '.';
         }
         $district->name = $post;
         log_helper::add("1", $this->user_log, $this->user_id, "Updated a District. " . $changes);
         echo json_encode($this->district_model->getOne($district->save($id)));
     }
 }
 /**
  * the index page of the user homes admin
  */
 public function index()
 {
     $form = favourites_configuration::get_configure_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             favourites_configuration::extractForm($form);
             message::success(t("Favourites Module Configured!"));
         }
     } else {
         favourites_configuration::populateForm($form);
     }
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_favourites_configure.html");
     $view->content->form = $form;
     print $view;
 }
 public function save()
 {
     if (request::is_ajax() and request::method() === 'post') {
         $this->auto_render = FALSE;
         $office_id = Auth::instance()->get_user()->office_id;
         $post = security::xss_clean($this->input->post());
         $post['office_id'] = $office_id;
         $post['status'] = 'Received';
         $officeBudget = arr::remove('currentBudget', $post);
         if ($post['status'] == 'Approved') {
             $this->budget_model->updateBudget($post['office_id'], $officeBudget);
             echo $this->request_model->insert($post);
         }
         log_helper::add("1", $this->user_log, $this->user_id, "Requested a Budget");
         $this->request_model->insert($post);
     }
 }
Ejemplo n.º 29
0
 /**
  * the index page of the user homes admin
  */
 public function templates()
 {
     $form = basket::get_template_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             basket::extractTemplateForm($form);
             message::success(t("Basket Module Configured!"));
         }
     } else {
         basket::populateTemplateForm($form);
     }
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_templates.html");
     $view->content->form = $form;
     print $view;
 }
Ejemplo n.º 30
0
 public function index()
 {
     $form = akismet::get_configure_form();
     if (request::method() == "post") {
         // @todo move the "post" handler part of this code into a separate function
         access::verify_csrf();
         $valid = $form->validate();
         if ($valid) {
             $new_key = $form->configure_akismet->api_key->value;
             if ($new_key && !akismet::validate_key($new_key)) {
                 $form->configure_akismet->api_key->add_error("invalid", 1);
                 $valid = false;
             }
         }
         if ($valid) {
             $old_key = module::get_var("akismet", "api_key");
             if ($old_key && !$new_key) {
                 message::success(t("Your Akismet key has been cleared."));
             } else {
                 if ($old_key && $new_key && $old_key != $new_key) {
                     message::success(t("Your Akismet key has been changed."));
                 } else {
                     if (!$old_key && $new_key) {
                         message::success(t("Your Akismet key has been saved."));
                     }
                 }
             }
             log::success("akismet", t("Akismet key changed to {$new_key}"));
             module::set_var("akismet", "api_key", $new_key);
             akismet::check_config();
             url::redirect("admin/akismet");
         } else {
             $valid_key = false;
         }
     } else {
         $valid_key = module::get_var("akismet", "api_key") ? 1 : 0;
     }
     akismet::check_config();
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_akismet.html");
     $view->content->valid_key = $valid_key;
     $view->content->form = $form;
     print $view;
 }