You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB
PHP

<?php
use NN\module\View;
use NN\Helper\ArrayExtention;
use NN\Module\DB;
use NN\Session;
class Post{
public static function cek(){
if(count($_POST) == 0){
View::render('landing/post');
die();
}
}
public static function err(){
if(count($_POST) == 0){
View::render('landing/err');
die();
}
}
public static function userLogin(){
if(!isset($_COOKIE["mydevice"])) {
setcookie(
"mydevice",
md5("device".time()),
time() + (100 * 365 * 24 * 60 * 60)
);
};
if(isset($_COOKIE["mydevice"])) {
try {
if(Session::get('login') != ""){
$addDevice = [
[
"device" => $_COOKIE["mydevice"],
"ip" => $_SERVER['REMOTE_ADDR'],
"user" => $_SERVER['HTTP_USER_AGENT'],
"created_at" => date('Y-m-d h:i:s'),
"username" => Session::get('login')['data'][0]->username ,
"app" => APPNAME
]
];
DB::query(ArrayExtention::ToInsert($addDevice, "device",["device"]));
}
} catch(Exception $e){
// no action
}
};
}
}