UnknownSec Bypass
403
:
/
mnt
/
lmsestudio-instance-vol002
/
lms_a49dedfd340f
/
app
/
Services
/ [
drwxr-xr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
GitVersionSevice.php
<?php namespace EstudioLMS\Services; use EstudioLMS\Exceptions\Handler; class GitVersionSevice { private $version; private $branch; /** * GitVersionSevice constructor. */ public function __construct() { try { // Obter versão base do git exec('git -C ' . base_path() . ' describe --always', $version_mini_hash); exec('git -C ' . base_path() . ' log -1', $line); // Obter branch atual (compatível com versões antigas do Git) exec('git -C ' . base_path() . ' rev-parse --abbrev-ref HEAD 2>/dev/null', $current_branch); $this->branch = !empty($current_branch) && isset($current_branch[0]) ? trim($current_branch[0]) : 'unknown'; if (!empty($version_mini_hash) && isset($version_mini_hash[0])) { $baseVersion = $version_mini_hash[0]; // Gerar versão customizada com identificador da branch $customVersion = $this->buildCustomVersion($baseVersion); $this->version['short'] = $customVersion; $this->version['long'] = $customVersion; } else { $this->version['short'] = '0.0.1-unknown'; $this->version['long'] = '0.0.1-unknown'; } } catch (\Exception $e) { app(Handler::class)->report($e); $this->version['short'] = '0.0.1-error'; $this->version['long'] = '0.0.1-error'; $this->branch = 'unknown'; } } /** * Construir versão customizada com identificador da branch * Formato: v3.5.1-194-g2d83a-identificador-branch */ private function buildCustomVersion($baseVersion) { // Processar a versão base do git describe if (preg_match('/^(v[\d\.]+)-(\d+)-(g[a-f0-9]+)$/', $baseVersion, $matches)) { // Formato completo: v3.5.1-194-g2d83a44b $tagVersion = $matches[1]; // v3.5.1 $commitCount = $matches[2]; // 194 $gitHash = $matches[3]; // g2d83a44b // Encurtar hash para 5 caracteres (g + 5 chars) $shortHash = substr($gitHash, 0, 6); // g2d83a // Gerar identificador da branch $branchIdentifier = $this->getBranchIdentifier(); return $tagVersion . '-' . $commitCount . '-' . $shortHash . '-' . $branchIdentifier; } elseif (preg_match('/^(g[a-f0-9]+)$/', $baseVersion, $matches)) { // Apenas hash (sem tags): g2d83a44b $gitHash = $matches[1]; $shortHash = substr($gitHash, 0, 6); // g2d83a $branchIdentifier = $this->getBranchIdentifier(); return 'v0.0.0-0-' . $shortHash . '-' . $branchIdentifier; } // Fallback caso não corresponda aos padrões esperados $branchIdentifier = $this->getBranchIdentifier(); return $baseVersion . '-' . $branchIdentifier; } /** * Gerar identificador da branch baseado no nome */ private function getBranchIdentifier() { // Mapeamento de branches para identificadores $branchMappings = [ 'main' => 'MAIN', 'master' => 'MAIN', 'develop' => 'DEV', 'development' => 'DEV', 'homolog' => 'HML', 'homologacao' => 'HML', 'staging' => 'STG', 'production' => 'PROD', 'release' => 'REL', 'hotfix' => 'HFX', 'feature-pagarme-v5' => 'PMV5', ]; // Verificar mapeamento direto if (isset($branchMappings[$this->branch])) { return $branchMappings[$this->branch]; } // Verificar padrões de prefixos foreach ($branchMappings as $pattern => $identifier) { if (strpos($this->branch, $pattern) === 0) { return $identifier; } } // Gerar identificador baseado no nome da branch return $this->generateBranchIdentifier($this->branch); } /** * Gerar identificador automático baseado no nome da branch */ private function generateBranchIdentifier($branchName) { // Remover caracteres especiais e converter para maiúsculo $clean = strtoupper(preg_replace('/[^a-zA-Z0-9]/', '', $branchName)); // Se ficou muito longo, pegar apenas as primeiras letras if (strlen($clean) > 6) { // Pegar primeiras letras de cada "palavra" (separadas por hífen, underscore, etc.) $words = preg_split('/[-_]/', $branchName); $identifier = ''; foreach ($words as $word) { if (strlen($word) > 0) { $identifier .= strtoupper($word[0]); } if (strlen($identifier) >= 4) break; } return $identifier ?: substr($clean, 0, 4); } return $clean ?: 'UNK'; } /** * Obter branch atual */ public function getCurrentBranch() { return $this->branch; } public function short() { return $this->version['short']; } public function long() { return $this->version['long']; } public function show() { $version_number = shell_exec('git -C ' . base_path() . ' rev-list HEAD | wc -l'); if (!empty($version_number)) { return trim($version_number); } return '0'; } }
Copyright © 2026 - UnknownSec