Exemplo n.º 1
0
 /**
  * @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;
         }
     }
 }
Exemplo n.º 2
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;
             }
         }
     }
 }
Exemplo n.º 3
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));
 }