示例#1
0
文件: create.php 项目: klan1/k1.lib
 /**
  * @return \k1lib\html\div|boolean
  */
 public function exec_board()
 {
     if (!$this->is_enabled) {
         return FALSE;
     }
     if ($this->data_loaded) {
         if ($this->create_object->get_post_data_catched()) {
             $this->create_object->put_post_data_on_table_data();
             if (!$this->skip_form_action) {
                 if ($this->create_object->do_post_data_validation()) {
                     $this->sql_action_result = $this->create_object->do_insert();
                 } else {
                     DOM_notification::queue_mesasage(board_create_strings::$error_form, "warning", $this->notifications_div_id);
                     DOM_notification::queue_title(board_base_strings::$alert_board);
                 }
             }
         }
         if (empty($this->sql_action_result)) {
             if ($this->apply_label_filter) {
                 $this->create_object->apply_label_filter();
             }
             $this->create_object->insert_inputs_on_data_row();
             $create_content_div = $this->create_object->do_html_object();
             $create_content_div->append_to($this->board_content_div);
             return $this->board_content_div;
         }
     } else {
         DOM_notification::queue_mesasage(board_create_strings::$error_no_blank_data, "alert", $this->notifications_div_id);
         DOM_notification::queue_title(board_base_strings::$alert_board);
         $this->create_object->make_invalid();
         $this->is_enabled = FALSE;
         return FALSE;
     }
 }
示例#2
0
文件: delete.php 项目: klan1/k1.lib
 /**
  * @return boolean
  */
 public function exec_board()
 {
     if (!$this->is_enabled) {
         return FALSE;
     }
     if (!empty($this->row_keys_text)) {
         if ($this->read_object->load_db_table_data()) {
             $this->row_keys_text_array = \k1lib\sql\table_url_text_to_keys($this->row_keys_text, $this->controller_object->db_table->get_db_table_config());
             if ($_GET['auth-code'] === $this->read_object->get_auth_code_personal()) {
                 $this->sql_action_result = $this->controller_object->db_table->delete_data($this->row_keys_text_array);
                 if ($this->sql_action_result) {
                     DOM_notification::queue_mesasage(board_delete_strings::$data_deleted, "success", $this->notifications_div_id);
                     return TRUE;
                 } else {
                     DOM_notification::queue_mesasage(board_delete_strings::$error_no_data_deleted, "alert", $this->notifications_div_id, \k1lib\common_strings::$error);
                     return FALSE;
                 }
             } else {
                 if ($_GET['auth-code'] === $this->read_object->get_auth_code()) {
                     DOM_notification::queue_mesasage(board_delete_strings::$error_no_data_deleted_hacker, "alert", $this->notifications_div_id, \k1lib\common_strings::$error_hacker);
                     return FALSE;
                 }
             }
         } else {
             DOM_notification::queue_mesasage(board_base_strings::$error_mysql_table_not_opened, "alert", $this->notifications_div_id, board_base_strings::$error_mysql);
             $this->is_enabled = FALSE;
             return FALSE;
         }
     }
 }
示例#3
0
文件: reading.php 项目: klan1/k1.lib
 public function __construct($db_table, $row_keys_text, $custom_auth_code = "")
 {
     if (!empty($row_keys_text)) {
         parent::__construct($db_table, $row_keys_text, $custom_auth_code);
     } else {
         DOM_notification::queue_mesasage(object_base_strings::$error_no_row_keys_text, "alert", $this->notifications_div_id, \k1lib\common_strings::$error);
     }
     /**
      * Necessary for do not loose the inputs with blank or null data
      */
     $this->skip_blanks_on_filters = TRUE;
 }
示例#4
0
文件: search.php 项目: klan1/k1.lib
 /**
  * @return \k1lib\html\div|boolean
  */
 public function exec_board()
 {
     if (!$this->is_enabled) {
         return FALSE;
     }
     if ($this->data_loaded) {
         return $this->board_content_div;
     } else {
         DOM_notification::queue_mesasage(board_create_strings::$error_no_blank_data, "alert", $this->notifications_div_id);
         DOM_notification::queue_title(board_base_strings::$alert_board);
         $this->search_object->make_invalid();
         $this->is_enabled = FALSE;
         return FALSE;
     }
 }
示例#5
0
文件: updating.php 项目: klan1/k1.lib
 public function do_update()
 {
     //$this->set_back_url("javascript:history.back()");
     $error_data = NULL;
     $this->div_container->set_attrib("class", "k1lib-crudlexs-update");
     $this->post_incoming_array = \k1lib\forms\check_all_incomming_vars($this->post_incoming_array);
     $update_result = $this->db_table->update_data($this->post_incoming_array, $this->db_table_data_keys[1], $error_data);
     if ($update_result !== FALSE) {
         $this->update_perfomed = TRUE;
         $this->updated = TRUE;
         DOM_notification::queue_mesasage(updating_strings::$data_updated, "success", $this->notifications_div_id);
         return TRUE;
     } else {
         $this->update_perfomed = FALSE;
         if (is_array($error_data) && !empty($error_data)) {
             $this->post_validation_errors = array_merge($this->post_validation_errors, $error_data);
         } elseif (is_string($error_data)) {
             DOM_notification::queue_mesasage($error_data, "alert", $this->notifications_div_id);
         }
         $this->updated = FALSE;
         DOM_notification::queue_mesasage(updating_strings::$data_not_updated, "warning", $this->notifications_div_id);
         return FALSE;
     }
 }
示例#6
0
 public function read_url_keys_text_for_list($db_table_name, $is_required = TRUE)
 {
     if (isset($this->board_list_object)) {
         /**
          * URL key text management
          */
         $related_url_keys_text = url::set_url_rewrite_var(url::get_url_level_count(), "related_url_keys_text", FALSE);
         if (!empty($related_url_keys_text)) {
             $related_table = $db_table_name;
             $related_db_table = new \k1lib\crudlexs\class_db_table($this->db_table->db, $related_table);
             $related_url_keys_array = \k1lib\sql\table_url_text_to_keys($related_url_keys_text, $related_db_table->get_db_table_config());
             $related_url_keys_text_auth_code = md5(\k1lib\K1MAGIC::get_value() . $related_url_keys_text);
             if (isset($_GET['auth-code']) && $_GET['auth-code'] === $related_url_keys_text_auth_code) {
                 $this->db_table->set_query_filter($related_url_keys_array, TRUE);
                 return $related_url_keys_text;
             } else {
                 $this->board_list_object->set_is_enabled(FALSE);
                 DOM_notification::queue_mesasage(board_base_strings::$error_url_keys_no_auth, "alert", $this->notifications_div_id, \k1lib\common_strings::$error);
                 return FALSE;
             }
         } else {
             if ($is_required) {
                 $this->board_list_object->set_is_enabled(FALSE);
                 DOM_notification::queue_mesasage(board_base_strings::$error_url_keys_no_keys_text, "alert", $this->notifications_div_id, \k1lib\common_strings::$error);
                 return FALSE;
             }
         }
     }
 }
示例#7
0
文件: list.php 项目: klan1/k1.lib
 /**
  * @return \k1lib\html\div|boolean
  */
 public function start_board()
 {
     if (!parent::start_board()) {
         return FALSE;
     }
     if ($this->list_object->get_state()) {
         /**
          * BACK
          */
         if ($this->back_enable && isset($_GET['back-url'])) {
             $back_url = \k1lib\urlrewrite\get_back_url();
             $back_link = \k1lib\html\get_link_button($back_url, board_read_strings::$button_back);
             $back_link->append_to($this->button_div_tag);
         }
         /**
          * NEW BUTTON
          */
         $related_url_keys_text = url::get_url_level_value_by_name("related_url_keys_text");
         if (empty($related_url_keys_text)) {
             $related_url_keys_text = "";
             $new_link = \k1lib\html\get_link_button(url::do_url("../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new);
         } else {
             $related_url_keys_text .= "/";
             $new_link = \k1lib\html\get_link_button(url::do_url("../../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new);
         }
         if ($this->create_enable) {
             //                $new_link = \k1lib\html\get_link_button(url::do_url("../{$this->controller_object->get_board_create_url_name()}/" . $related_url_keys_text), board_list_strings::$button_new);
             //                $new_link = \k1lib\html\get_link_button("../{$this->controller_object->get_board_create_url_name()}/?back-url={$this_url}", board_list_strings::$button_new);
             $new_link->append_to($this->button_div_tag);
         }
         /**
          * Search
          */
         if ($this->search_enable) {
             $search_iframe = new \k1lib\html\iframe(url::do_url($this->controller_object->get_controller_root_dir() . "search/?just-controller=1&caller-url=" . urlencode($_SERVER['REQUEST_URI'])), 'utility-iframe', "search-iframe");
             //                $this->board_content_div->append_child_tail($search_iframe);
             DOM::html()->body()->append_child_tail($search_iframe);
             //                $search_iframe->append_to($this->board_content_div);
             $search_buttom = new \k1lib\html\a(NULL, " " . board_list_strings::$button_search, "_self");
             $search_buttom->set_id("search-button");
             $search_buttom->set_attrib("class", "button fi-page-search");
             $search_buttom->append_to($this->button_div_tag);
             if (isset($_POST) && isset($_POST['from-search']) && urldecode($_POST['from-search']) == $_SERVER['REQUEST_URI']) {
                 //                    if ($this->)
                 /**
                  * decrypt post field names
                  */
                 $incomming_search_data = \k1lib\forms\check_all_incomming_vars($_POST);
                 if ($this->list_object->get_do_table_field_name_encrypt()) {
                     $search_data = $this->list_object->decrypt_field_names($incomming_search_data);
                 } else {
                     $search_data = $incomming_search_data;
                 }
                 $this->controller_object->db_table->set_query_filter($search_data);
                 $search_post = \k1lib\common\serialize_var($_POST, urlencode($_SERVER['REQUEST_URI']));
                 /**
                  * Clear search
                  */
                 $clear_search_buttom = new \k1lib\html\a(url::do_url($_SERVER['REQUEST_URI']), board_list_strings::$button_search_cancel, "_self");
                 $search_buttom->set_value(" " . board_list_strings::$button_search_modify);
                 $clear_search_buttom->set_attrib("class", "button warning");
                 $clear_search_buttom->append_to($this->button_div_tag);
             } else {
                 $search_post = \k1lib\common\unset_serialize_var(urlencode($_SERVER['REQUEST_URI']));
             }
         }
         $this->data_loaded = $this->list_object->load_db_table_data($this->show_rule_to_apply);
         return $this->board_content_div;
     } else {
         DOM_notification::queue_mesasage(board_base_strings::$error_mysql_table_not_opened, "alert", $this->notifications_div_id);
         DOM_notification::queue_title(board_base_strings::$error_mysql);
         $this->list_object->make_invalid();
         $this->is_enabled = FALSE;
         return FALSE;
     }
 }
示例#8
0
 public function catch_post()
 {
     if (isset($_POST['magic_value'])) {
         $magic_test = \k1lib\common\check_magic_value("login_form", $_POST['magic_value']);
         if ($magic_test == TRUE) {
             unset($_POST['magic_value']);
             // the form was correct, so lets try to login
             /**
              * Check the _GET incomming vars
              */
             $form_values = \k1lib\forms\check_all_incomming_vars($_POST, "k1lib_login");
             /**
              * Login fields
              */
             if (isset($form_values[$this->user_login_input_name]) && isset($form_values[$this->user_password_input_name])) {
                 $this->user_login_input_value = $form_values[$this->user_login_input_name];
                 $this->user_password_input_value = self::$user_password_use_md5 ? md5($form_values[$this->user_password_input_name]) : $form_values[$this->user_password_input_name];
                 if (isset($form_values[$this->user_remember_me_input])) {
                     $this->user_remember_me_value = $form_values[$this->user_remember_me_input];
                 }
             } else {
                 return NULL;
             }
             //                $filter_array = [
             //                    $this->user_login_input_name => $this->user_login_input_value,
             //                    $this->user_password_input_name => $this->user_password_input_value,
             //                ];
             //                $this->db_table->set_query_filter($filter_array, TRUE);
             return $form_values;
         } else {
             return FALSE;
         }
     } else {
         DOM_notifications::queue_mesasage("There is not magic present here!", "alert");
         return NULL;
     }
 }
示例#9
0
文件: update.php 项目: klan1/k1.lib
 /**
  * @return \k1lib\html\div|boolean
  */
 public function exec_board()
 {
     if (!$this->is_enabled) {
         return FALSE;
     }
     if ($this->update_object->get_state() && !empty($this->row_keys_text)) {
         if ($this->data_loaded) {
             if ($this->update_object->get_post_data_catched()) {
                 $this->update_object->put_post_data_on_table_data();
                 if (!$this->skip_form_action) {
                     if ($this->update_object->do_post_data_validation()) {
                         $this->sql_action_result = $this->update_object->do_update();
                     } else {
                         DOM_notification::queue_mesasage(board_update_strings::$error_form, "alert", $this->notifications_div_id);
                         DOM_notification::queue_title(board_base_strings::$alert_board);
                     }
                 }
             }
             if ($this->apply_label_filter) {
                 $this->update_object->apply_label_filter();
             }
             $this->update_object->insert_inputs_on_data_row();
             /**
              * DELETE BUTTON
              */
             if ($this->controller_object->get_board_delete_enabled()) {
                 $delete_url = $this->controller_object->get_controller_root_dir() . "{$this->controller_object->get_board_delete_url_name()}/{$this->row_keys_text}/";
                 if (\k1lib\urlrewrite\get_back_url(TRUE)) {
                     $get_vars = ["auth-code" => md5(session_plain::get_user_hash() . $this->row_keys_text), "back-url" => \k1lib\urlrewrite\get_back_url(TRUE)];
                 } else {
                     $get_vars = ["auth-code" => md5(session_plain::get_user_hash() . $this->row_keys_text)];
                 }
                 $delete_link = \k1lib\html\get_link_button(url::do_url($delete_url, $get_vars), board_read_strings::$button_delete, "small");
                 $delete_link->append_to($this->button_div_tag);
             }
             $update_content_div = $this->update_object->do_html_object();
             $update_content_div->append_to($this->board_content_div);
             return $this->board_content_div;
         } else {
             DOM_notification::queue_mesasage(board_base_strings::$error_mysql_table_no_data, "alert", $this->notifications_div_id, board_base_strings::$error_mysql);
             $this->update_object->make_invalid();
             $this->is_enabled = FALSE;
             return FALSE;
         }
     }
 }
示例#10
0
 public function start_board()
 {
     if (!$this->is_enabled) {
         DOM_notification::queue_mesasage(board_base_strings::$error_board_disabled, "warning", $this->notifications_div_id);
         DOM_notification::queue_title(board_base_strings::$alert_board);
         return FALSE;
     }
     $this->button_div_tag = $this->board_content_div->append_div($this->button_div_id);
     return TRUE;
 }
示例#11
0
文件: creating.php 项目: klan1/k1.lib
 /**
  * This uses the post_incoming_array (Please verify it first) to make the insert.
  * NOTE: If the table has multiple KEYS the auto_number HAS to be on the first position, if not, the redirection won't works.
  * @param type $url_to_go
  * @return boolean TRUE on sucess or FALSE on error.
  */
 public function do_insert()
 {
     $error_data = NULL;
     $this->post_incoming_array = \k1lib\forms\check_all_incomming_vars($this->post_incoming_array);
     $this->inserted_result = $this->db_table->insert_data($this->post_incoming_array, $error_data);
     if ($this->inserted_result !== FALSE) {
         DOM_notification::queue_mesasage(creating_strings::$data_inserted, "success", $this->notifications_div_id);
         $this->inserted = TRUE;
         return TRUE;
     } else {
         if (is_array($error_data) && !empty($error_data)) {
             $this->post_validation_errors = array_merge($this->post_validation_errors, $error_data);
         }
         DOM_notification::queue_mesasage(creating_strings::$data_not_inserted, "warning", $this->notifications_div_id);
         $this->inserted = FALSE;
         return FALSE;
     }
 }
示例#12
0
 /**
  * Always to create the object you must have a valid DB Table object already 
  * @param \k1lib\crudlexs\class_db_table $db_table DB Table object
  */
 public function __construct(\k1lib\crudlexs\class_db_table $db_table, $row_keys_text = null, $custom_auth_code = null)
 {
     $this->back_url = \k1lib\urlrewrite\get_back_url();
     if (!empty($row_keys_text)) {
         $this->row_keys_text = $row_keys_text;
         if (!$this->skip_auto_code_verification) {
             if (isset($_GET['auth-code']) || !empty($custom_auth_code)) {
                 if (!empty($custom_auth_code)) {
                     $auth_code = $custom_auth_code;
                 } else {
                     $auth_code = $_GET['auth-code'];
                 }
                 $auth_expected = md5(\k1lib\K1MAGIC::get_value() . $this->row_keys_text);
                 $auth_personal_expected = md5(session_plain::get_user_hash() . $this->row_keys_text);
                 if ($auth_code === $auth_expected || $auth_code === $auth_personal_expected) {
                     parent::__construct($db_table);
                     $this->auth_code = $auth_expected;
                     $this->auth_code_personal = $auth_personal_expected;
                     $this->row_keys_array = \k1lib\sql\table_url_text_to_keys($this->row_keys_text, $this->db_table->get_db_table_config());
                     $this->db_table->set_query_filter($this->row_keys_array, TRUE);
                     $this->is_valid = TRUE;
                 } else {
                     DOM_notification::queue_mesasage(object_base_strings::$error_bad_auth_code, "alert", $this->notifications_div_id, common_strings::$error);
                     $this->is_valid = FALSE;
                 }
             } else {
                 DOM_notification::queue_mesasage(object_base_strings::$alert_empty_auth_code, "alert", $this->notifications_div_id, common_strings::$alert);
                 $this->is_valid = FALSE;
             }
         } else {
             parent::__construct($db_table);
         }
     } else {
         parent::__construct($db_table);
     }
     $this->set_object_id(get_class($this));
     $this->set_css_class(get_class($this));
 }
示例#13
0
文件: read.php 项目: klan1/k1.lib
 /**
  * @return \k1lib\html\div|boolean
  */
 public function exec_board()
 {
     if (!$this->is_enabled) {
         return FALSE;
     }
     if ($this->read_object->get_state() && !empty($this->row_keys_text)) {
         if ($this->data_loaded) {
             if ($this->apply_label_filter) {
                 $this->read_object->apply_label_filter();
             }
             if ($this->apply_field_label_filter) {
                 $this->read_object->apply_field_label_filter();
             }
             //                $this->read_object->set_use_read_custom_template();
             if (\k1lib\forms\file_uploads::is_enabled()) {
                 $this->read_object->apply_file_uploads_filter();
             }
             //                $this->board_content_div->set_attrib("class", "row", TRUE);
             $span_tag = new \k1lib\html\span("key-field");
             $this->read_object->apply_html_tag_on_field_filter($span_tag, \k1lib\crudlexs\crudlexs_base::USE_KEY_FIELDS);
             $read_content_div = $this->read_object->do_html_object();
             $read_content_div->append_to($this->board_content_div);
             return $this->board_content_div;
         } else {
             DOM_notification::queue_mesasage(board_base_strings::$error_mysql_table_no_data, "alert", $this->notifications_div_id);
             DOM_notification::queue_title(board_base_strings::$error_mysql);
             $this->read_object->make_invalid();
             $this->is_enabled = FALSE;
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }