Esempio n. 1
0
 // ====================================================================
 $table_key = strval(@$_POST['table_key']);
 // New browseStorage\TableClass object
 $tab_obj = new TableClass($table_key);
 $tab =& $tab_obj->tab;
 // shortcut
 // Get configured table primary keys (IDs)
 $config_ids = $tab_obj->config_ids();
 // Retrieve IDs from $_POST into array(column_id => value)
 $req_ids = $tab_obj->req_ids($config_ids);
 $no_req_ids = count($req_ids) <= 0;
 // Get configured table column names
 $config_names = $tab_obj->config_names();
 $auto_cols = count($config_names) <= 0;
 // Prepare list of columns values to write
 $req_col_values = $tab_obj->req_col_values();
 // Security and sanity checks
 // ====================================================================
 // Read-only table security check
 if (!isset($tab['editable']) || $tab['editable'] <= TableClass::NOT_EDITABLE) {
     throw new \Exception(sprintf($tab_obj->error_sprintf, "Data table set as not editable in"));
 }
 // Read-only column security check
 if (!$auto_cols) {
     foreach ($req_col_values as $col => $value) {
         if (!isset($config_names[$col]) || strval(@$config_names[$col][1]) == "label") {
             throw new \Exception("\$_POST['col#']='{$col}' is trying to set a column that cannot be modified, when calling {$tab_obj->error_script}.");
         }
     }
 }
 // Set `$action` to the uppercased first character of the action, and validate each of their arguments