Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

class Datatables { use Privileges; public $filter_model = array(); private $image_checker ..

Decoded Output download

<?  class Datatables { use Privileges; public $filter_model = array(); private $image_checker = array("jpg", "jpeg", "png", "gif"); public function __construct() { } private function setAssetPath($file_path, $http = false, $public_path = "public") { if (true === $http) { $assetsURL = explode("/", url()->asset("assets")); $stringURL = explode("/", $file_path); return implode("/", array_unique(array_merge_recursive($assetsURL, $stringURL))); } $file_path = str_replace($public_path . "/", public_path("\"), $file_path); return $file_path; } private function checkValidImage($string, $local_path = true) { $filePath = $this->setAssetPath($string); if (true === file_exists($filePath)) { foreach ($this->image_checker as $check) { if (false !== strpos($string, $check)) { return true; } else { return false; } } } else { $filePath = explode("/", $string); $lastSrc = array_key_last($filePath); $lastFile = $filePath[$lastSrc]; $info = "This File [ {$lastFile} ] Do Not or Never Exist!"; return "<div class="show-hidden-on-hover missing-file" title="{$info}"><i class="fa fa-warning"></i>&nbsp;{$lastFile}</div><!--div class="hide">{$info}</div-->"; } } public function process($method, $data, $filters = array(), $filter_page = array()) { if (!empty($data->datatables->model[$method["difta"]["name"]])) { $model_type = $data->datatables->model[$method["difta"]["name"]]["type"]; $model_source = $data->datatables->model[$method["difta"]["name"]]["source"]; if ("model" === $model_type) { $model_data = $model_source; $table_name = $model_data->getTable(); } $order_by = array(); if (!empty($data->datatables->columns[$table_name]["orderby"])) { $order_by = $data->datatables->columns[$table_name]["orderby"]; } if ("sql" === $model_type) { $model_data = new DynamicTables($model_source); } } if (!empty($data->datatables->modelProcessing[$table_name])) { diy_model_processing_table($data->datatables->modelProcessing, $table_name); } $privileges = $this->set_module_privileges(); $index_lists = $data->datatables->records["index_lists"]; $column_data = $data->datatables->columns; $action_list = false; $_action_lists = array(); $removed_privileges = array(); $buttonsRemoval = array(); if (!empty($data->datatables->columns[$table_name]["button_removed"])) { $buttonsRemoval = $data->datatables->columns[$table_name]["button_removed"]; } $firstField = "id"; $blacklists = array("password", "action", "no"); if (!in_array("id", $data->datatables->columns[$table_name]["lists"])) { $firstField = $data->datatables->columns[$table_name]["lists"][0]; $blacklists = array("password", "action", "no", "id"); } if (!empty($column_data[$table_name]["actions"]) || is_array($column_data[$table_name]["actions"])) { $action_default = array("view", "insert", "edit", "delete"); if (true === $column_data[$table_name]["actions"]) { $action_list = $action_default; } else { $action_list = array_merge_recursive_distinct($action_default, $column_data[$table_name]["actions"]); } $actions = null; if ($privileges["role_group"] > 1) { if (!empty($privileges["role"])) { if (!empty(strpos(json_encode($privileges["role"]), routelists_info()["base_info"]))) { foreach ($privileges["role"] as $roles) { if (diy_string_contained($roles, routelists_info()["base_info"])) { $routename = routelists_info($roles)["last_info"]; if (in_array($routename, array("index", "show", "view"))) { $actions[routelists_info()["base_info"]]["view"] = "view"; } elseif (in_array($routename, array("create", "insert"))) { $actions[routelists_info()["base_info"]]["insert"] = "insert"; } elseif (in_array($routename, array("edit", "modify", "update"))) { $actions[routelists_info()["base_info"]]["edit"] = "edit"; } elseif (in_array($routename, array("destroy", "delete"))) { $actions[routelists_info()["base_info"]]["delete"] = "delete"; } } } if (!empty($actions)) { foreach ($action_list as $_list) { if (isset($actions[routelists_info()["base_info"]][$_list])) { $_action_lists[] = $actions[routelists_info()["base_info"]][$_list]; } else { if (!in_array($_list, array("view", "insert", "edit", "delete"))) { $_action_lists[] = $_list; } } } } } } } if (!empty(array_diff($action_list, $_action_lists))) { $removed_privileges = array_diff($action_list, $_action_lists); } } if (!empty($column_data[$table_name]["foreign_keys"])) { $fieldsets = array(); $joinFields = array("{$table_name}.*"); foreach ($column_data[$table_name]["foreign_keys"] as $fkey1 => $fkey2) { $ftables = explode(".", $fkey1); $model_data = $model_data->leftJoin($ftables[0], $fkey1, "=", $fkey2); $fieldsets[$ftables[0]] = diy_get_table_columns($ftables[0]); } foreach ($fieldsets as $fstname => $fieldRows) { foreach ($fieldRows as $fieldset) { if ("id" === $fieldset) { $joinFields[] = "{$fstname}.{$fieldset} as {$fstname}_{$fieldset}"; } else { $joinFields[] = "{$fstname}.{$fieldset}"; } } } $model_data = $model_data->select($joinFields); } $limitTotal = 0; $limit = array(); $limit["start"] = 0; $limit["length"] = 10; $model_condition = array(); $where_conditions = array(); if (!empty($data->datatables->conditions[$table_name]["where"])) { foreach ($data->datatables->conditions[$table_name]["where"] as $conditional_where) { if (!is_array($conditional_where["value"])) { $where_conditions["o"][] = array($conditional_where["field_name"], $conditional_where["operator"], $conditional_where["value"]); } else { $where_conditions["i"][$conditional_where["field_name"]] = $conditional_where["value"]; } } if (!empty($where_conditions["o"])) { $model_condition = $model_data->where($where_conditions["o"]); } if (empty($model_condition)) { $model_condition = $model_data; } if (!empty($where_conditions["i"])) { foreach ($where_conditions["i"] as $if => $iv) { $model_condition = $model_condition->whereIn($if, $iv); } } $model = $model_condition; } $fstrings = array(); $_ajax_url = "renderDataTables"; if (!empty($where_conditions)) { $model_filters = $model_condition; } else { $model_filters = $model_data; } if (!empty($filters) && true == $filters) { foreach ($filters as $name => $value) { if ("filters" !== $name && '' !== $value) { if ($name !== $_ajax_url && $name !== "draw" && $name !== "columns" && $name !== "order" && $name !== "start" && $name !== "length" && $name !== "search" && $name !== "difta" && $name !== "_token" && $name !== "_") { if (!is_array($value)) { $fstrings[] = array($name => urldecode($value)); } else { foreach ($value as $val) { $fstrings[] = array($name => urldecode($val)); } } } } } } if (!empty($fstrings)) { $filters = array(); foreach ($fstrings as $fdata) { foreach ($fdata as $fkey => $fvalue) { $filters[$fkey][] = $fvalue; } } if (!empty($filters)) { $fconds = array(); foreach ($filters as $fieldname => $rowdata) { foreach ($rowdata as $dataRow) { $fconds[$fieldname] = $dataRow; } } $model = $model_filters->where($fconds); } $limitTotal = count($model->get()); } else { $model = $model_filters->where("{$table_name}.{$firstField}", "!=", null); $limitTotal = count($model_filters->get()); } $limit["total"] = intval($limitTotal); if (!empty(request()->get("start"))) { $limit["start"] = request()->get("start"); } if (!empty(request()->get("length"))) { $limit["length"] = request()->get("length"); } $model->skip($limit["start"])->take($limit["length"]); $datatables = DataTable::of($model)->setTotalRecords($limit["total"])->setFilteredRecords($limit["total"])->blacklist($blacklists)->smart(true); $is_image = array(); if (!empty($this->form->imageTagFieldsDatatable)) { $is_image = array_keys($this->form->imageTagFieldsDatatable); $datatables->rawColumns(array_merge_recursive(array("action", "flag_status"), $is_image)); } if (!empty($order_by)) { $orderBy = $order_by; $datatables->order(function ($query) use($orderBy) { $query->orderBy($orderBy["column"], $orderBy["order"]); }); } else { $orderBy = array("column" => $data->datatables->columns[$table_name]["lists"][0], "order" => "desc"); } $object_called = get_object_called_name($model); $rowModel = array(); foreach ($model->get() as $modelData) { if ("builder" === $object_called) { $rowModel = (object) $modelData->getAttributes(); } else { $rowModel = $modelData; } $this->imageViewColumn($rowModel, $datatables); if (empty($joinFields)) { if (!empty($column_data[$table_name]["relations"])) { foreach ($column_data[$table_name]["relations"] as $relField => $relData) { $dataRelations = $relData["relation_data"]; $datatables->editColumn($relField, function ($data) use($dataRelations) { $dataID = intval($data["id"]); if (!empty($dataRelations[$dataID]["field_value"])) { return $dataRelations[$dataID]["field_value"]; } else { return null; } }); } } } if (!empty($rowModel->flag_status)) { $datatables->editColumn("flag_status", function ($model) { return diy_unescape_html(diy_form_internal_flag_status($model->flag_status)); }); } if (!empty($rowModel->active)) { $datatables->editColumn("active", function ($model) { return diy_form_set_active_value($model->active); }); } if (!empty($rowModel->update_status)) { $datatables->editColumn("update_status", function ($model) { return diy_form_set_active_value($model->update_status); }); } if (!empty($rowModel->request_status)) { $datatables->editColumn("request_status", function ($model) { return diy_form_request_status(true, $model->request_status); }); } if (!empty($rowModel->ip_address)) { $datatables->editColumn("ip_address", function ($model) { if ("::1" == $model->ip_address) { return diy_form_get_client_ip(); } else { return $model->ip_address; } }); } } if (!empty($data->datatables->formula[$table_name])) { $data_formula = $data->datatables->formula[$table_name]; $data->datatables->columns[$table_name]["lists"] = diy_set_formula_columns($data->datatables->columns[$table_name]["lists"], $data_formula); foreach ($data_formula as $formula) { $datatables->editColumn($formula["name"], function ($data) use($formula) { $logic = new Formula($formula, $data); return $logic->calculate(); }); } } if (!empty($data->datatables->columns[$table_name]["format_data"])) { $data_format = $data->datatables->columns[$table_name]["format_data"]; foreach ($data_format as $field => $format) { $datatables->editColumn($format["field_name"], function ($data) use($field, $format) { if ($field === $format["field_name"]) { $dataValue = $data->getAttributes(); if (!empty($dataValue[$field])) { return diy_format($dataValue[$field], $format["decimal_endpoint"], $format["separator"], $format["format_type"]); } } }); } } $rlp = false; $row_attributes = array(); $row_attributes["class"] = null; $row_attributes["rlp"] = null; if (!empty($column_data[$table_name]["clickable"])) { if (count($column_data[$table_name]["clickable"]) >= 1) { $rlp = function ($model) { return diy_unescape_html(encode_id(intval($model->id))); }; } $row_attributes["class"] = "row-list-url"; $row_attributes["rlp"] = $rlp; } $datatables->setRowAttr($row_attributes); $action_data = array(); $action_data["model"] = $model; $action_data["current_url"] = diy_current_url(); $action_data["action"]["data"] = $action_list; if ($privileges["role_group"] > 1) { if (!empty($removed_privileges)) { $action_data["action"]["removed"] = $removed_privileges; } else { $action_data["action"]["removed"] = $data->datatables->button_removed; } } else { $action_data["action"]["removed"] = $data->datatables->button_removed; } if (!empty($buttonsRemoval)) { $removeActions = $action_data["action"]["removed"]; unset($action_data["action"]["removed"]); $action_data["action"]["removed"] = array_merge_recursive_distinct($buttonsRemoval, $removeActions); } $urlTarget = $data->datatables->useFieldTargetURL; $datatables->addColumn("action", function ($model) use($action_data, $urlTarget) { return $this->setRowActionURLs($model, $action_data, $urlTarget); }); $tableData = array(); if (true === $index_lists) { $tableData = $datatables->addIndexColumn()->make(true); } else { $tableData = $datatables->make(); } return $tableData; } private function setRowActionURLs($model, $data, $field_target = "id") { return diy_table_action_button($model, $field_target, $data["current_url"], $data["action"]["data"], $data["action"]["removed"]); } private function imageViewColumn($model, $datatables) { $imageField = array(); foreach ($model as $field => $strImg) { if (false !== $this->checkValidImage($strImg)) { $checkImage = $this->checkValidImage($strImg); if (true === $checkImage) { $imageField[$field] = $checkImage; } } } foreach ($imageField as $field => $imgSrc) { $imgSrc = "imgsrc::"; if (isset($model->{$field})) { $datatables->editColumn($field, function ($model) use($field, $imgSrc) { $label = ucwords(str_replace("-", " ", diy_clean_strings($field))); $thumb = false; $imgCheck = $this->checkValidImage($model->{$field}); if (false !== $imgCheck) { $filePath = explode("/", $model->{$field}); $lastSrc = array_key_last($filePath); $lastFile = $filePath[$lastSrc]; unset($filePath[$lastSrc]); $thumb = implode("/", $filePath) . "/thumb/tnail_" . $lastFile; $filePath = $model->{$field}; if (!empty($this->setAssetPath($thumb))) { $filePath = $thumb; } if (true === $imgCheck) { $alt = $imgSrc . $label; return diy_unescape_html("<center><img class="cdy-img-thumb" src="{$filePath}" alt="{$alt}" /></center>"); } else { return diy_unescape_html($imgCheck); } } else { $filePath = explode("/", $filePath); $lastSrc = array_key_last($filePath); return $filePath[$lastSrc]; } }); } } } public $filter_datatables = array(); public function filter_datatable($request) { $this->filter_datatables = $request->all(); } public function init_filter_datatables($get = array(), $post = array(), $connection = null) { if (!empty($get["filterDataTables"])) { if (!empty($post["grabCoDIYC"])) { $connection = $post["grabCoDIYC"]; unset($post["grabCoDIYC"]); } $filters = array(); if (!empty($post["_diyF"])) { $filters = $post["_diyF"]; unset($post["_diyF"]); } $fdata = explode("::", $post["_fita"]); $table = $fdata[1]; $target = $fdata[2]; $prev = $fdata[3]; $fKeys = array(); $fKeyQs = array(); if (!empty($post["_forKeys"])) { $fKeys = json_decode($post["_forKeys"]); foreach ($fKeys as $fqs => $fqt) { $tqs = explode(".", $fqs); $tqs = $tqs[0]; $tqt = explode(".", $fqt); $tqt = $tqt[0]; $fKeyQ[] = "LEFT JOIN {$tqs} ON {$fqs} = {$fqt}"; } if (!empty($fKeyQ)) { $fKeyQs = implode(" ", $fKeyQ); } } unset($post["filterDataTables"]); unset($post["_fita"]); unset($post["_token"]); unset($post["_n"]); if (!empty($post["_forKeys"])) { unset($post["_forKeys"]); } if (!empty($filters)) { $filterQueries = array(); foreach ($filters as $n => $filter) { $fqFieldName = $filter["field_name"]; $fqDataValue = $filter["value"]; if (is_array($filter["value"])) { $fQdataValue = implode("', '", $fqDataValue); $filterQueries[$n] = "`{$fqFieldName}` IN ('{$fQdataValue}')"; } else { $filterQueries[$n] = "`{$fqFieldName}` = '{$fqDataValue}'"; } } } $wheres = array(); foreach ($post as $key => $value) { $wheres[] = "`{$key}` = '{$value}'"; } if (!empty($filterQueries)) { $wheres = array_merge_recursive($wheres, $filterQueries); } $wheres = implode(" AND ", $wheres); $wherePrevious = null; if ("#null" !== $prev) { $previous = explode("#", $prev); $preFields = explode("|", $previous[0]); $preFieldt = explode("|", $previous[1]); $prevields = array(); foreach ($preFields as $idf => $prev_field) { $prevields[$idf] = $prev_field; } $previeldt = array(); foreach ($preFieldt as $idd => $prev_field_data) { $previeldt[$idd] = $prev_field_data; } $previousData = array(); foreach ($prevields as $idp => $prev_data) { $previousData[$prev_data] = $previeldt[$idp]; } $previousdata = array(); foreach ($previousData as $_field => $_value) { $previousdata[] = "`{$_field}` = '{$_value}'"; } $wherePrevious = " AND " . implode(" AND ", $previousdata); } if (!empty($fKeys)) { $sql = "SELECT DISTINCT `{$target}` FROM `{$table}` {$fKeyQs} WHERE {$wheres}{$wherePrevious}"; } else { $sql = "SELECT DISTINCT `{$target}` FROM `{$table}` WHERE {$wheres}{$wherePrevious}"; } return diy_query($sql, "SELECT", $connection); } } } ?>

Did this file decode correctly?

Original Code

class Datatables { use Privileges; public $filter_model = array(); private $image_checker = array("\x6a\160\x67", "\152\x70\x65\147", "\x70\x6e\x67", "\x67\151\146"); public function __construct() { } private function setAssetPath($file_path, $http = false, $public_path = "\x70\165\142\154\x69\x63") { if (true === $http) { $assetsURL = explode("\57", url()->asset("\141\x73\163\x65\x74\163")); $stringURL = explode("\57", $file_path); return implode("\57", array_unique(array_merge_recursive($assetsURL, $stringURL))); } $file_path = str_replace($public_path . "\x2f", public_path("\x5c"), $file_path); return $file_path; } private function checkValidImage($string, $local_path = true) { $filePath = $this->setAssetPath($string); if (true === file_exists($filePath)) { foreach ($this->image_checker as $check) { if (false !== strpos($string, $check)) { return true; } else { return false; } } } else { $filePath = explode("\57", $string); $lastSrc = array_key_last($filePath); $lastFile = $filePath[$lastSrc]; $info = "\x54\x68\x69\x73\x20\x46\151\x6c\145\40\133\x20{$lastFile}\x20\x5d\40\104\x6f\x20\116\157\164\40\157\162\40\116\145\x76\145\162\x20\x45\170\151\x73\164\x21"; return "\74\144\x69\x76\40\x63\x6c\x61\x73\163\75\42\x73\x68\157\167\x2d\x68\x69\x64\144\145\156\55\157\156\55\x68\157\166\145\x72\40\155\151\x73\x73\151\156\x67\x2d\146\x69\154\145\x22\x20\164\151\164\x6c\145\75\x22{$info}\x22\76\74\151\x20\143\x6c\x61\163\163\x3d\42\x66\x61\40\x66\x61\x2d\x77\x61\x72\156\151\156\x67\x22\76\74\57\x69\x3e\46\x6e\x62\x73\160\x3b{$lastFile}\x3c\x2f\144\151\x76\x3e\74\41\x2d\55\144\151\x76\x20\x63\154\141\163\x73\75\x22\x68\151\x64\145\42\76{$info}\74\57\144\x69\x76\x2d\x2d\x3e"; } } public function process($method, $data, $filters = array(), $filter_page = array()) { if (!empty($data->datatables->model[$method["\x64\x69\x66\x74\141"]["\x6e\141\x6d\x65"]])) { $model_type = $data->datatables->model[$method["\144\151\146\x74\x61"]["\156\x61\155\x65"]]["\164\x79\x70\145"]; $model_source = $data->datatables->model[$method["\x64\151\146\164\141"]["\x6e\141\155\145"]]["\163\x6f\165\162\143\x65"]; if ("\x6d\x6f\144\x65\154" === $model_type) { $model_data = $model_source; $table_name = $model_data->getTable(); } $order_by = array(); if (!empty($data->datatables->columns[$table_name]["\x6f\162\144\145\x72\142\171"])) { $order_by = $data->datatables->columns[$table_name]["\x6f\x72\x64\145\x72\142\x79"]; } if ("\163\161\154" === $model_type) { $model_data = new DynamicTables($model_source); } } if (!empty($data->datatables->modelProcessing[$table_name])) { diy_model_processing_table($data->datatables->modelProcessing, $table_name); } $privileges = $this->set_module_privileges(); $index_lists = $data->datatables->records["\x69\156\x64\x65\170\137\154\151\163\164\163"]; $column_data = $data->datatables->columns; $action_list = false; $_action_lists = array(); $removed_privileges = array(); $buttonsRemoval = array(); if (!empty($data->datatables->columns[$table_name]["\142\165\164\x74\x6f\156\137\x72\x65\155\157\166\x65\144"])) { $buttonsRemoval = $data->datatables->columns[$table_name]["\x62\x75\x74\x74\x6f\x6e\x5f\x72\145\155\x6f\x76\x65\x64"]; } $firstField = "\x69\144"; $blacklists = array("\x70\x61\163\x73\x77\x6f\x72\144", "\141\143\x74\x69\157\156", "\x6e\x6f"); if (!in_array("\x69\144", $data->datatables->columns[$table_name]["\x6c\151\x73\x74\163"])) { $firstField = $data->datatables->columns[$table_name]["\x6c\151\x73\164\x73"][0]; $blacklists = array("\x70\x61\163\163\x77\157\x72\144", "\141\143\x74\x69\157\x6e", "\156\x6f", "\x69\144"); } if (!empty($column_data[$table_name]["\x61\x63\164\x69\x6f\x6e\163"]) || is_array($column_data[$table_name]["\141\x63\164\151\x6f\x6e\163"])) { $action_default = array("\x76\x69\145\167", "\x69\156\x73\145\x72\x74", "\145\x64\151\x74", "\144\145\154\x65\164\145"); if (true === $column_data[$table_name]["\x61\x63\164\x69\157\156\x73"]) { $action_list = $action_default; } else { $action_list = array_merge_recursive_distinct($action_default, $column_data[$table_name]["\141\x63\x74\151\157\156\x73"]); } $actions = null; if ($privileges["\162\x6f\154\x65\137\x67\x72\157\165\160"] > 1) { if (!empty($privileges["\162\157\154\145"])) { if (!empty(strpos(json_encode($privileges["\162\157\x6c\145"]), routelists_info()["\142\141\163\x65\x5f\151\156\x66\x6f"]))) { foreach ($privileges["\162\157\x6c\145"] as $roles) { if (diy_string_contained($roles, routelists_info()["\142\141\x73\145\x5f\151\x6e\x66\x6f"])) { $routename = routelists_info($roles)["\x6c\x61\163\164\137\151\x6e\x66\157"]; if (in_array($routename, array("\151\156\x64\x65\x78", "\163\150\x6f\167", "\166\x69\x65\x77"))) { $actions[routelists_info()["\x62\141\163\x65\x5f\x69\x6e\146\x6f"]]["\166\x69\x65\x77"] = "\x76\x69\x65\x77"; } elseif (in_array($routename, array("\143\x72\145\141\164\x65", "\x69\156\163\145\162\x74"))) { $actions[routelists_info()["\x62\141\x73\x65\x5f\151\156\146\157"]]["\151\x6e\163\145\x72\x74"] = "\151\x6e\x73\x65\x72\164"; } elseif (in_array($routename, array("\145\x64\151\164", "\155\157\144\x69\146\171", "\x75\160\x64\141\x74\x65"))) { $actions[routelists_info()["\x62\x61\163\145\x5f\151\x6e\146\x6f"]]["\145\144\x69\164"] = "\145\x64\x69\x74"; } elseif (in_array($routename, array("\x64\x65\x73\x74\162\157\x79", "\x64\145\x6c\x65\164\145"))) { $actions[routelists_info()["\x62\x61\163\145\x5f\x69\156\x66\x6f"]]["\144\145\154\145\x74\145"] = "\144\x65\154\x65\164\145"; } } } if (!empty($actions)) { foreach ($action_list as $_list) { if (isset($actions[routelists_info()["\142\x61\163\x65\x5f\151\156\146\x6f"]][$_list])) { $_action_lists[] = $actions[routelists_info()["\142\x61\x73\145\x5f\151\156\146\x6f"]][$_list]; } else { if (!in_array($_list, array("\166\151\x65\x77", "\x69\x6e\163\x65\x72\x74", "\145\x64\151\164", "\144\145\x6c\145\164\145"))) { $_action_lists[] = $_list; } } } } } } } if (!empty(array_diff($action_list, $_action_lists))) { $removed_privileges = array_diff($action_list, $_action_lists); } } if (!empty($column_data[$table_name]["\146\157\x72\x65\x69\147\x6e\137\x6b\x65\171\x73"])) { $fieldsets = array(); $joinFields = array("{$table_name}\56\52"); foreach ($column_data[$table_name]["\146\x6f\162\x65\151\147\x6e\137\153\x65\171\163"] as $fkey1 => $fkey2) { $ftables = explode("\x2e", $fkey1); $model_data = $model_data->leftJoin($ftables[0], $fkey1, "\x3d", $fkey2); $fieldsets[$ftables[0]] = diy_get_table_columns($ftables[0]); } foreach ($fieldsets as $fstname => $fieldRows) { foreach ($fieldRows as $fieldset) { if ("\151\x64" === $fieldset) { $joinFields[] = "{$fstname}\x2e{$fieldset}\x20\x61\x73\40{$fstname}\137{$fieldset}"; } else { $joinFields[] = "{$fstname}\x2e{$fieldset}"; } } } $model_data = $model_data->select($joinFields); } $limitTotal = 0; $limit = array(); $limit["\163\164\x61\162\x74"] = 0; $limit["\154\x65\156\147\x74\150"] = 10; $model_condition = array(); $where_conditions = array(); if (!empty($data->datatables->conditions[$table_name]["\x77\150\x65\162\145"])) { foreach ($data->datatables->conditions[$table_name]["\167\x68\x65\162\145"] as $conditional_where) { if (!is_array($conditional_where["\166\x61\x6c\x75\145"])) { $where_conditions["\157"][] = array($conditional_where["\146\151\x65\154\144\137\x6e\141\x6d\145"], $conditional_where["\157\160\145\162\x61\x74\157\x72"], $conditional_where["\x76\141\x6c\165\x65"]); } else { $where_conditions["\151"][$conditional_where["\x66\x69\x65\x6c\x64\137\156\141\155\x65"]] = $conditional_where["\166\141\x6c\165\145"]; } } if (!empty($where_conditions["\x6f"])) { $model_condition = $model_data->where($where_conditions["\157"]); } if (empty($model_condition)) { $model_condition = $model_data; } if (!empty($where_conditions["\151"])) { foreach ($where_conditions["\151"] as $if => $iv) { $model_condition = $model_condition->whereIn($if, $iv); } } $model = $model_condition; } $fstrings = array(); $_ajax_url = "\162\x65\x6e\x64\x65\x72\x44\141\x74\141\x54\141\142\x6c\x65\x73"; if (!empty($where_conditions)) { $model_filters = $model_condition; } else { $model_filters = $model_data; } if (!empty($filters) && true == $filters) { foreach ($filters as $name => $value) { if ("\146\151\x6c\164\x65\162\x73" !== $name && '' !== $value) { if ($name !== $_ajax_url && $name !== "\144\162\141\x77" && $name !== "\x63\x6f\x6c\165\x6d\156\163" && $name !== "\x6f\162\x64\145\162" && $name !== "\x73\164\141\162\x74" && $name !== "\x6c\x65\x6e\x67\164\x68" && $name !== "\163\145\x61\x72\x63\150" && $name !== "\x64\x69\x66\164\x61" && $name !== "\137\164\157\153\145\x6e" && $name !== "\137") { if (!is_array($value)) { $fstrings[] = array($name => urldecode($value)); } else { foreach ($value as $val) { $fstrings[] = array($name => urldecode($val)); } } } } } } if (!empty($fstrings)) { $filters = array(); foreach ($fstrings as $fdata) { foreach ($fdata as $fkey => $fvalue) { $filters[$fkey][] = $fvalue; } } if (!empty($filters)) { $fconds = array(); foreach ($filters as $fieldname => $rowdata) { foreach ($rowdata as $dataRow) { $fconds[$fieldname] = $dataRow; } } $model = $model_filters->where($fconds); } $limitTotal = count($model->get()); } else { $model = $model_filters->where("{$table_name}\56{$firstField}", "\x21\x3d", null); $limitTotal = count($model_filters->get()); } $limit["\x74\x6f\x74\141\x6c"] = intval($limitTotal); if (!empty(request()->get("\x73\164\141\162\164"))) { $limit["\163\164\x61\162\164"] = request()->get("\x73\164\x61\162\164"); } if (!empty(request()->get("\154\145\156\x67\x74\150"))) { $limit["\154\x65\156\147\x74\x68"] = request()->get("\x6c\145\x6e\147\164\x68"); } $model->skip($limit["\x73\x74\141\162\164"])->take($limit["\154\x65\156\x67\164\150"]); $datatables = DataTable::of($model)->setTotalRecords($limit["\164\157\164\141\x6c"])->setFilteredRecords($limit["\x74\x6f\164\x61\x6c"])->blacklist($blacklists)->smart(true); $is_image = array(); if (!empty($this->form->imageTagFieldsDatatable)) { $is_image = array_keys($this->form->imageTagFieldsDatatable); $datatables->rawColumns(array_merge_recursive(array("\x61\x63\x74\151\x6f\x6e", "\146\154\141\147\x5f\163\164\141\x74\x75\163"), $is_image)); } if (!empty($order_by)) { $orderBy = $order_by; $datatables->order(function ($query) use($orderBy) { $query->orderBy($orderBy["\143\157\154\165\155\x6e"], $orderBy["\157\162\x64\x65\162"]); }); } else { $orderBy = array("\x63\157\x6c\165\155\x6e" => $data->datatables->columns[$table_name]["\154\x69\163\164\163"][0], "\157\x72\x64\x65\x72" => "\x64\145\x73\x63"); } $object_called = get_object_called_name($model); $rowModel = array(); foreach ($model->get() as $modelData) { if ("\142\165\x69\x6c\144\x65\162" === $object_called) { $rowModel = (object) $modelData->getAttributes(); } else { $rowModel = $modelData; } $this->imageViewColumn($rowModel, $datatables); if (empty($joinFields)) { if (!empty($column_data[$table_name]["\x72\145\154\141\164\x69\x6f\x6e\x73"])) { foreach ($column_data[$table_name]["\162\145\154\x61\x74\151\157\156\163"] as $relField => $relData) { $dataRelations = $relData["\162\x65\154\x61\x74\151\157\156\137\144\141\x74\141"]; $datatables->editColumn($relField, function ($data) use($dataRelations) { $dataID = intval($data["\x69\144"]); if (!empty($dataRelations[$dataID]["\146\x69\145\154\144\137\x76\141\x6c\x75\145"])) { return $dataRelations[$dataID]["\x66\151\x65\x6c\x64\x5f\x76\x61\154\165\x65"]; } else { return null; } }); } } } if (!empty($rowModel->flag_status)) { $datatables->editColumn("\146\x6c\141\x67\x5f\x73\164\141\x74\165\163", function ($model) { return diy_unescape_html(diy_form_internal_flag_status($model->flag_status)); }); } if (!empty($rowModel->active)) { $datatables->editColumn("\x61\143\x74\151\166\145", function ($model) { return diy_form_set_active_value($model->active); }); } if (!empty($rowModel->update_status)) { $datatables->editColumn("\165\160\144\141\x74\145\137\163\164\x61\x74\x75\163", function ($model) { return diy_form_set_active_value($model->update_status); }); } if (!empty($rowModel->request_status)) { $datatables->editColumn("\162\x65\161\x75\x65\163\x74\137\163\164\x61\164\x75\163", function ($model) { return diy_form_request_status(true, $model->request_status); }); } if (!empty($rowModel->ip_address)) { $datatables->editColumn("\151\160\x5f\141\144\144\x72\145\x73\x73", function ($model) { if ("\72\72\61" == $model->ip_address) { return diy_form_get_client_ip(); } else { return $model->ip_address; } }); } } if (!empty($data->datatables->formula[$table_name])) { $data_formula = $data->datatables->formula[$table_name]; $data->datatables->columns[$table_name]["\x6c\x69\163\164\163"] = diy_set_formula_columns($data->datatables->columns[$table_name]["\154\x69\163\164\163"], $data_formula); foreach ($data_formula as $formula) { $datatables->editColumn($formula["\156\141\155\145"], function ($data) use($formula) { $logic = new Formula($formula, $data); return $logic->calculate(); }); } } if (!empty($data->datatables->columns[$table_name]["\x66\x6f\162\x6d\141\x74\137\144\141\x74\x61"])) { $data_format = $data->datatables->columns[$table_name]["\146\157\x72\x6d\x61\x74\x5f\144\x61\x74\x61"]; foreach ($data_format as $field => $format) { $datatables->editColumn($format["\x66\151\145\x6c\144\137\156\x61\155\x65"], function ($data) use($field, $format) { if ($field === $format["\x66\151\145\x6c\144\x5f\156\141\155\145"]) { $dataValue = $data->getAttributes(); if (!empty($dataValue[$field])) { return diy_format($dataValue[$field], $format["\144\x65\143\151\x6d\x61\154\137\145\156\x64\160\157\x69\x6e\164"], $format["\163\x65\160\x61\162\x61\164\x6f\x72"], $format["\146\x6f\162\155\x61\x74\x5f\164\x79\160\145"]); } } }); } } $rlp = false; $row_attributes = array(); $row_attributes["\143\x6c\141\x73\163"] = null; $row_attributes["\162\154\160"] = null; if (!empty($column_data[$table_name]["\143\x6c\x69\143\x6b\x61\x62\x6c\x65"])) { if (count($column_data[$table_name]["\143\x6c\151\x63\x6b\x61\142\154\145"]) >= 1) { $rlp = function ($model) { return diy_unescape_html(encode_id(intval($model->id))); }; } $row_attributes["\x63\x6c\141\x73\163"] = "\x72\157\x77\55\154\151\x73\164\x2d\x75\x72\154"; $row_attributes["\162\x6c\160"] = $rlp; } $datatables->setRowAttr($row_attributes); $action_data = array(); $action_data["\155\157\144\145\x6c"] = $model; $action_data["\143\x75\162\x72\x65\x6e\x74\x5f\x75\162\154"] = diy_current_url(); $action_data["\x61\x63\164\151\157\x6e"]["\144\x61\x74\x61"] = $action_list; if ($privileges["\x72\157\x6c\x65\137\x67\162\157\165\x70"] > 1) { if (!empty($removed_privileges)) { $action_data["\x61\x63\164\151\157\x6e"]["\x72\x65\x6d\x6f\166\145\x64"] = $removed_privileges; } else { $action_data["\141\x63\164\x69\x6f\156"]["\162\x65\155\x6f\x76\x65\144"] = $data->datatables->button_removed; } } else { $action_data["\x61\143\x74\x69\x6f\156"]["\162\145\x6d\x6f\x76\145\144"] = $data->datatables->button_removed; } if (!empty($buttonsRemoval)) { $removeActions = $action_data["\141\143\164\151\157\x6e"]["\x72\x65\x6d\x6f\x76\x65\x64"]; unset($action_data["\x61\x63\164\151\x6f\156"]["\162\x65\x6d\x6f\166\145\x64"]); $action_data["\141\143\x74\151\157\x6e"]["\162\x65\155\x6f\166\145\144"] = array_merge_recursive_distinct($buttonsRemoval, $removeActions); } $urlTarget = $data->datatables->useFieldTargetURL; $datatables->addColumn("\x61\x63\164\151\x6f\x6e", function ($model) use($action_data, $urlTarget) { return $this->setRowActionURLs($model, $action_data, $urlTarget); }); $tableData = array(); if (true === $index_lists) { $tableData = $datatables->addIndexColumn()->make(true); } else { $tableData = $datatables->make(); } return $tableData; } private function setRowActionURLs($model, $data, $field_target = "\x69\x64") { return diy_table_action_button($model, $field_target, $data["\x63\x75\162\x72\x65\x6e\164\137\165\x72\154"], $data["\x61\143\x74\151\157\156"]["\x64\x61\164\x61"], $data["\141\x63\x74\151\x6f\156"]["\x72\145\x6d\x6f\166\x65\144"]); } private function imageViewColumn($model, $datatables) { $imageField = array(); foreach ($model as $field => $strImg) { if (false !== $this->checkValidImage($strImg)) { $checkImage = $this->checkValidImage($strImg); if (true === $checkImage) { $imageField[$field] = $checkImage; } } } foreach ($imageField as $field => $imgSrc) { $imgSrc = "\x69\x6d\x67\x73\x72\143\x3a\72"; if (isset($model->{$field})) { $datatables->editColumn($field, function ($model) use($field, $imgSrc) { $label = ucwords(str_replace("\x2d", "\40", diy_clean_strings($field))); $thumb = false; $imgCheck = $this->checkValidImage($model->{$field}); if (false !== $imgCheck) { $filePath = explode("\x2f", $model->{$field}); $lastSrc = array_key_last($filePath); $lastFile = $filePath[$lastSrc]; unset($filePath[$lastSrc]); $thumb = implode("\x2f", $filePath) . "\57\x74\150\165\155\142\x2f\164\x6e\141\x69\154\137" . $lastFile; $filePath = $model->{$field}; if (!empty($this->setAssetPath($thumb))) { $filePath = $thumb; } if (true === $imgCheck) { $alt = $imgSrc . $label; return diy_unescape_html("\x3c\x63\x65\156\164\x65\x72\76\x3c\x69\155\147\x20\143\154\141\163\163\75\42\x63\x64\171\55\151\x6d\147\55\164\150\165\155\142\42\40\x73\162\x63\x3d\x22{$filePath}\42\40\x61\x6c\164\x3d\x22{$alt}\42\40\x2f\76\74\x2f\x63\145\x6e\x74\145\162\x3e"); } else { return diy_unescape_html($imgCheck); } } else { $filePath = explode("\57", $filePath); $lastSrc = array_key_last($filePath); return $filePath[$lastSrc]; } }); } } } public $filter_datatables = array(); public function filter_datatable($request) { $this->filter_datatables = $request->all(); } public function init_filter_datatables($get = array(), $post = array(), $connection = null) { if (!empty($get["\146\x69\154\164\145\x72\104\x61\164\141\x54\141\x62\154\145\163"])) { if (!empty($post["\x67\x72\141\142\x43\157\x44\111\x59\103"])) { $connection = $post["\147\162\141\x62\x43\x6f\104\x49\x59\103"]; unset($post["\147\162\141\142\103\157\104\x49\x59\103"]); } $filters = array(); if (!empty($post["\137\x64\151\x79\106"])) { $filters = $post["\x5f\144\151\x79\106"]; unset($post["\x5f\144\x69\x79\x46"]); } $fdata = explode("\x3a\72", $post["\x5f\x66\151\x74\141"]); $table = $fdata[1]; $target = $fdata[2]; $prev = $fdata[3]; $fKeys = array(); $fKeyQs = array(); if (!empty($post["\x5f\146\x6f\162\113\145\171\x73"])) { $fKeys = json_decode($post["\x5f\x66\x6f\162\113\145\171\163"]); foreach ($fKeys as $fqs => $fqt) { $tqs = explode("\56", $fqs); $tqs = $tqs[0]; $tqt = explode("\56", $fqt); $tqt = $tqt[0]; $fKeyQ[] = "\x4c\x45\106\x54\40\112\117\111\116\40{$tqs}\40\117\116\x20{$fqs}\40\x3d\x20{$fqt}"; } if (!empty($fKeyQ)) { $fKeyQs = implode("\40", $fKeyQ); } } unset($post["\x66\151\154\164\145\x72\104\x61\x74\141\x54\141\142\x6c\x65\163"]); unset($post["\x5f\x66\x69\164\x61"]); unset($post["\x5f\164\157\x6b\145\156"]); unset($post["\x5f\156"]); if (!empty($post["\137\x66\157\x72\x4b\145\x79\x73"])) { unset($post["\x5f\x66\157\x72\113\x65\x79\x73"]); } if (!empty($filters)) { $filterQueries = array(); foreach ($filters as $n => $filter) { $fqFieldName = $filter["\146\x69\145\154\144\x5f\x6e\x61\x6d\x65"]; $fqDataValue = $filter["\x76\x61\154\x75\x65"]; if (is_array($filter["\166\141\154\x75\x65"])) { $fQdataValue = implode("\47\54\40\x27", $fqDataValue); $filterQueries[$n] = "\140{$fqFieldName}\x60\x20\111\116\x20\50\47{$fQdataValue}\47\x29"; } else { $filterQueries[$n] = "\140{$fqFieldName}\x60\x20\75\x20\47{$fqDataValue}\47"; } } } $wheres = array(); foreach ($post as $key => $value) { $wheres[] = "\x60{$key}\140\x20\75\40\47{$value}\47"; } if (!empty($filterQueries)) { $wheres = array_merge_recursive($wheres, $filterQueries); } $wheres = implode("\x20\101\116\104\40", $wheres); $wherePrevious = null; if ("\x23\x6e\x75\x6c\x6c" !== $prev) { $previous = explode("\x23", $prev); $preFields = explode("\174", $previous[0]); $preFieldt = explode("\x7c", $previous[1]); $prevields = array(); foreach ($preFields as $idf => $prev_field) { $prevields[$idf] = $prev_field; } $previeldt = array(); foreach ($preFieldt as $idd => $prev_field_data) { $previeldt[$idd] = $prev_field_data; } $previousData = array(); foreach ($prevields as $idp => $prev_data) { $previousData[$prev_data] = $previeldt[$idp]; } $previousdata = array(); foreach ($previousData as $_field => $_value) { $previousdata[] = "\140{$_field}\x60\x20\75\40\47{$_value}\47"; } $wherePrevious = "\40\x41\116\x44\x20" . implode("\40\x41\x4e\104\x20", $previousdata); } if (!empty($fKeys)) { $sql = "\x53\x45\114\x45\x43\x54\x20\104\x49\x53\x54\111\x4e\x43\x54\40\x60{$target}\140\x20\106\122\117\115\x20\140{$table}\140\x20{$fKeyQs}\40\x57\x48\x45\122\105\x20{$wheres}{$wherePrevious}"; } else { $sql = "\x53\105\114\x45\103\x54\40\x44\x49\x53\x54\111\116\103\x54\40\x60{$target}\140\40\106\122\117\x4d\40\140{$table}\x60\x20\127\110\x45\x52\105\40{$wheres}{$wherePrevious}"; } return diy_query($sql, "\x53\105\x4c\105\103\x54", $connection); } } }

Function Calls

None

Variables

None

Stats

MD5 823af980edc305bb3cc9bb422c32d993
Eval Count 0
Decode Time 52 ms