Online PHP and Javascript Decoder decode hidden script to uncover its real functionality


namespace App\Http\Controllers; use App\Helpers\Helper; use Illuminate\Support\Facades\DB;
 class DashboardController extends Controller { public function index() { $credentials = Helper::getAuthAvatar();
 $institution = DB::table("institutions")->where("id", 1)
 ->get(array("id", "institution", "logo"))->first();
 $institution->url = $institution->logo == '' ? "https://ui-avatars.com/api/?name={$institution->institution}&rounded=true" : config("global.URI") . "logo/" . $institution->logo; $totalDocuments = DB::table("first_documentary_groups")->get(array(DB::raw("COUNT(id)AS total")))->
 first()->total; $areaDocuments = DB::table("areas AS a")->leftJoin(DB::raw("(\xa                                SELECT c.area_id,COUNT(fdg.id)AS total
                                FROM first_documentary_groups AS fdg\xa                                LEFT JOIN categories AS c ON c.id=fdg.category_id
                                GROUP BY c.area_id\xa                            )AS sc"), "sc.area_id", "=", "a.id")->orderBy("a.area", "ASC")->get(array("a.area", DB::raw("IFNULL(sc.total`)AS total"))); $totalDocuments = $totalDocuments == 0 ? 1 : $totalDocuments; $documents = array(); foreach ($areaDocuments as $document) { $documents[] = array("area" => $document->area, "total" => $document->total, "percentage" => round($document->total / $totalDocuments * 100, 2)); } $users = DB::table("users")->get(array(DB::raw("COUNT(id)AS total")))->first(); $data = array("user" => $credentials, "permissions" => Helper::getObfuscateAreas($credentials), "categories" => Helper::getObfuscateCategories($credentials), "institution" => $institution, "documents" => $documents, "users" => $users); return view("modules.dashboard.index")->with($data); } public function show($id) { $date = date("Y-m-d"); $dates = array(); for ($i = 4; $i >= 0; $i--) { $dates[] = date("Y-m-d", strtotime("{$date}-{$i} day")); } $areas = DB::table("areas")->orderBy("area", "ASC")->get(array("id", "area")); $typesDocuments = array(); $documents = array(); $registers = array(); foreach ($dates as $date) { $typesDocuments[$date] = $this->typesDocuments($date, $areas); $documents[$date] = $this->documents($date, $areas); $registers[$date] = $this->registers($date, $areas); } $data = array("ok" => true, "dates" => $dates, "documents" => $typesDocuments, "registers" => $registers); return response()->json($data, 200); } private function typesDocuments($date, $areas) { $data = array(); foreach ($areas as $area) { $categories = DB::table("categories")->where("state", "Activo")->where("area_id", $area->id)->get(array("id", "category", "structure")); $response = array(); foreach ($categories as $category) { $structure = $this->getStructure($category->id); foreach ($structure as $index => $document) { if ($index[0] === "P") { $archive = substr($index, 2); $count = $this->primaryModel($category->id, $archive, $date); } else { $count = $this->secondaryModel($category->id, $index, $date); } if (isset($response[$document])) { $response[$document] = $response[$document] + $count; } else { $response[$document] = $count; } } } $data = $response; } return $data; } private function documents($date, $areas) { $response = array(); foreach ($areas as $area) { $count = 0; $categories = DB::table("categories")->where("state", "Activo")->where("area_id", $area->id)->get(array("id", "category", "structure")); foreach ($categories as $category) { $formats = $this->getFormat($category->structure); foreach ($formats as $format) { foreach ($format["data"] as $index => $archive) { if ($index[0] === "P") { $archive = substr($index, 2); $count += $this->primaryModel($category->id, $archive, $date); } else { $count += $this->secondaryModel($category->id, $index, $date); } } } } $response[$area->area] = $count; } return $response; } private function registers($date, $areas) { $response = array(); foreach ($areas as $area) { $response[$area->area] = DB::table("first_documentary_groups AS f")->leftJoin("categories AS c", "c.id", "=", "f.category_id")->whereDate("f.created_at", $date)->where("c.area_id", $area->id)->count(); } return $response; } private function getFormat($structure) { $structure = json_decode($structure); $prince = $structure[0]; unset($structure[0]); $structure = array_values($structure); $format = array(); $auxData = array(); $aux = array(); $count = 0; foreach ($prince->files as $data) { $count++; $metadata = "P-archive_" . str_pad((string) $count, 2, "0", STR_PAD_LEFT); $auxData[0][] = $metadata; $aux[$metadata] = $data->metadata; } $format[] = array("title" => $prince->title, "data" => $aux); $count = 0; $countF = 0; foreach ($structure as $index => $dataP) { $aux = array(); foreach ($dataP->files as $data) { $countF++; $metadata = "archive_" . str_pad((string) $countF, 2, "0", STR_PAD_LEFT); $auxData[$index + 1][] = $metadata; $aux[$metadata] = $data->metadata; } $format[] = array("title" => $dataP->title, "data" => $aux); } return $format; } private function primaryModel($id_category, $archive, $date) { return DB::table("fdg_archives AS a")->leftJoin("first_documentary_groups AS f", "f.id", "=", "a.first_documentary_group_id")->where("a.state", "Activo")->where("f.state", "Activo")->where("f.category_id", $id_category)->where("a.{$archive}", "!=", '')->whereDate("a.created_at", $date)->count(); } private function secondaryModel($id_category, $archive, $date) { return DB::table("fdg_registers AS a")->leftJoin("registers AS r", "r.id", "=", "a.register_id")->where("a.state", "Activo")->where("r.state", "Activo")->where("r.category_id", $id_category)->where("a.{$archive}", "!=", '')->whereDate("a.created_at", $date)->count(); } private function getStructure($id_category) { $structure = DB::table("categories")->where("id", $id_category)->get(array("structure"))->first(); $structure = json_decode($structure->structure); $archives = array(); $sw = true; $count = 1; foreach ($structure as $index => $data) { if ($sw && $index != 0) { $count = 1; $sw = false; } foreach ($data->files as $subdata) { $archive = "archive_" . str_pad((string) $count, 2, "0", STR_PAD_LEFT); if ($index == 0) { $archives["P-" . $archive] = $subdata->metadata;
 } else { $archives[$archive] = $subdata->metadata; } $count++; } } return $archives; } }



© 2023 Quttera Ltd. All rights reserved.