!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/rentals.picotech.app/public_html/server/routes/   drwxr-xr-x
Free 28.55 GB of 117.98 GB (24.2%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     maintenance.js (2.8 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import express from 'express';
import { Maintenance, Building, Floor, Room, Bed } from '../models/index.js';
import { auth, authorize } from '../middleware/auth.js';

const router = express.Router();

// ✅ Create maintenance
router.post('/', auth, authorize(['manage']), async (req, res) => {
  try {
    const maintenance = await Maintenance.create(req.body);
    res.status(201).json(maintenance);
  } catch (err) {
    console.error('Create maintenance error:', err);
    res.status(500).json({ error: 'Failed to create maintenance record' });
  }
});

// ✅ Get all maintenance records (with optional filters)
router.get('/', auth, async (req, res) => {
  try {
    const where = {};
    ['building_id', 'floor_id', 'room_id', 'bed_id', 'status'].forEach(key => {
      if (req.query[key]) where[key] = req.query[key];
    });

    const maintenances = await Maintenance.findAll({
      where,
    });

    res.json(maintenances);
  } catch (err) {
    console.error('Fetch maintenance records error:', err);
    res.status(500).json({ error: 'Failed to fetch maintenance records' });
  }
});

// ✅ Get maintenance record by ID
router.get('/:id', auth, async (req, res) => {
  try {
    const maintenance = await Maintenance.findByPk(req.params.id, {
      include: [
        { model: Building },
        { model: Floor },
        { model: Room },
        { model: Bed }
      ]
    });

    if (!maintenance) {
      return res.status(404).json({ error: 'Maintenance record not found' });
    }

    res.json(maintenance);
  } catch (err) {
    console.error('Get maintenance record error:', err);
    res.status(500).json({ error: 'Failed to fetch maintenance record' });
  }
});

// ✅ Update maintenance record
router.put('/:id', auth, authorize(['manage']), async (req, res) => {
  try {
    const maintenance = await Maintenance.findByPk(req.params.id);

    if (!maintenance) {
      return res.status(404).json({ error: 'Maintenance record not found' });
    }

    await maintenance.update(req.body);
    res.json(maintenance);
  } catch (err) {
    console.error('Update maintenance error:', err);
    res.status(500).json({ error: 'Failed to update maintenance record' });
  }
});

// ✅ Delete maintenance record
router.delete('/:id', auth, authorize(['delete']), async (req, res) => {
  try {
    const maintenance = await Maintenance.findByPk(req.params.id);

    if (!maintenance) {
      return res.status(404).json({ error: 'Maintenance record not found' });
    }

    await maintenance.destroy();
    res.json({ message: 'Maintenance record deleted successfully' });
  } catch (err) {
    console.error('Delete maintenance error:', err);
    res.status(500).json({ error: 'Failed to delete maintenance record' });
  }
});

export default router;

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0037 ]--