Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php class PIA { static $pdo = null; static $charset = 'UTF8'; static $last_st..
Decoded Output download
<?php
class PIA {
static $pdo = null;
static $charset = 'UTF8';
static $last_stmt = null;
static $requests = [
"1" => "ye",
"2" => "Yazar",
"3" => "Admin"
];
public static function instance(){
return
self::$pdo == null ?
self::init() :
self::$pdo;
}
public static function init(){
self::$pdo = new PDO(
'mysql:host=' . MYSQL_HOST .';dbname=' . MYSQL_DB,
MYSQL_USER,
MYSQL_PASS
);
self::$pdo->exec('SET NAMES `' . self::$charset . '`');
self::$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
return self::$pdo;
}
public static function query($query, $bindings = null){
if(is_null($bindings)){
if(!self::$last_stmt = self::instance()->query($query))
return false;
}else{
self::$last_stmt = self::prepare($query);
if(!self::$last_stmt->execute($bindings))
return false;
}
return self::$last_stmt;
}
public static function get_var($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return $stmt->fetchColumn();
}
public static function get_row($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return $stmt->fetch();
}
public static function get($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
$result = array();
foreach($stmt as $row)
$result[] = $row;
return $result;
}
public static function getRequest($req)
{
return self::$requests[$req];
}
public static function array_files($file_post) {
$file_ary = array();
$file_count = count($file_post['name']);
$file_keys = array_keys($file_post);
for ($i=0; $i<$file_count; $i++) {
foreach ($file_keys as $key) {
$file_ary[$i][$key] = $file_post[$key][$i];
}
}
return $file_ary;
}
public static function exec($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return $stmt->rowCount();
}
public static function insert($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return self::$pdo->lastInsertId();
}
public static function getLastError(){
$error_info = self::$last_stmt->errorInfo();
if($error_info[0] == 00000)
return false;
return $error_info;
}
public static function __callStatic($name, $arguments){
return call_user_func_array(
array(self::instance(), $name),
$arguments
);
}
public static function get_months($value){
$array = array('01' => 'Ocak', '02' => 'ubat', '03' => 'Mart', '04' => 'Nisan', '05' => 'Mays', '06' => 'Haziran', '07' => 'Temmuz', '08' => 'Austos', '09' => 'Eyll', '10' => 'Ekim', '11' => 'Kasm', '12' => 'Aralk');
return $array[$value];
}
public static function get_count($table,$where='1=1'){
return self::get_var("SELECT count(*) as count FROM $table WHERE $where");
}
public static function badge($table,$where='1=1'){
$count = self::get_count($table,$where);
return ($count > 0) ?'<span class="label label-success">'.$count.'</span>' : '';
}
public static function badge_two($count){
return ($count > 0) ?'<span class="label label-success">'.$count.'</span>' : '';
}
public static function nirvana($str){ return md5(md5(md5(trim($str)))); }
public static function control($theValue, $theType, $strip_tags=false) {
$theValue = trim($theValue);
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
}
return $strip_tags==true ? strip_tags($theValue) : $theValue;
}
public static function seo($title){
$TR=array('','','','','','','','','','','','');
$EN=array('c','c','i','i','s','s','g','g','o','o','u','u');
$title= str_replace($TR,$EN,$title);
$title=mb_strtolower($title,'UTF-8');
$title=preg_replace('#[^-a-zA-Z0-9_, ]#','',$title);
$title=trim($title);
$title= preg_replace('#[-_ ]+#','-',$title);
return $title;
}
public static function get_ip(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
return $_SERVER['HTTP_CLIENT_IP'];
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
return $_SERVER['REMOTE_ADDR'];
}
}
public static function base_url($url=null){
if (isset($_SERVER['HTTP_HOST'])) {
$http = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$core = preg_split('@/@', str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath(dirname(__FILE__))), NULL, PREG_SPLIT_NO_EMPTY);
$core = (!empty($core[0]))? $core[0].'/' : '';
$return = sprintf( "%s://%s", $http, $_SERVER['HTTP_HOST'], $core).'/';
}else{
$return = 'http://localhost/';
}
return ($url==null)? $return : $return.$url ;
}
public static function label($class,$text){
return "<label class=\"label label-$class\">$text</label>";
}
public static function redirect($url=null){
$return = ($url==null)? 'location.reload()' : 'window.location.href="'.self::base_url($url).'"';
echo "<script>setInterval(function(){ $return; },1000);</script>";
}
public static function admin_redirect($url=null){
$return = ($url==null)? 'location.reload()' : 'window.location.href="'.self::base_url("admin/".$url).'"';
echo "<script>setInterval(function(){ $return; },1000);</script>";
}
public static function file_upload($file,$name,$target){
$exists = strtolower(substr($file['name'], strrpos($file['name'], ".")));
$avaible = array('.jpg', '.jpeg', '.png', '.bmp', '.gif');
if(in_array($exists, $avaible)){
$new_name = $name.$exists;
$to_location = $target.'/'.$new_name;
return move_uploaded_file($file['tmp_name'], $to_location) ? self::control($new_name,'text') : self::control('NULL','text');
}
}
public static function time_tr( $par ){
$datetime = explode(" ", $par);
$date = explode("-", $datetime[0]);
return substr($datetime[1], 0, 5).", ".$date[2]." ".self::get_months($date[1])." ".$date[0];
}
public static function settings($name){
return self::get_var("SELECT settings_value FROM settings WHERE settings_name='$name'");
}
public static function key($length = 10){
$characters = '0123456789';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
public static function mail($email, $subject, $html){
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = self::settings('smtp_host');
$mail->Port = self::settings('smtp_port');
$mail->SMTPSecure = self::settings('smtp_secure');
$mail->Username = self::settings('smtp_email');
$mail->Password = self::settings('smtp_password');
$mail->SetFrom(self::settings('smtp_email'), self::settings('site_title'));
$mail->AddAddress($email);
$mail->CharSet = 'UTF-8';
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $html;
return ($mail->send())? true : false ;
}
public static function mail_generator($file){
$social = '';
$html = file_get_contents($file, FILE_USE_INCLUDE_PATH);
$html = str_replace('{SITE}', self::base_url(), $html);
$html = str_replace('{TITLE}', self::settings('site_title'), $html);
$html = str_replace('{LOGO}', self::settings('logo'), $html);
return str_replace('{TODAY}', date('Y-m-d H:i:s'), $html);
}
public static function forgot_password($email, $fullname, $code){
$html = self::mail_generator('mail/template/password.html');
$html = str_replace('{CODE}', 'sifre/'.$code, $html);
$html = str_replace('{FULLNAME}', $fullname, $html);
self::mail($email, self::settings('password_title'), $html);
}
public static function activation($email, $fullname, $code){
$html = self::mail_generator('mail/template/activation.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{CODE}', 'aktivasyon/'.$code, $html);
self::mail($email, self::settings('activation_title'), $html);
}
public static function welcome($email, $fullname){
$html = self::mail_generator('mail/template/welcome.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
self::mail($email, self::settings('welcome_title'), $html);
}
public static function ticket($email, $fullname, $title, $description){
$html = self::mail_generator('mail/template/ticket.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
self::mail($email, self::settings('ticket_title'), $html);
}
public static function admin_ticket($fullname, $title, $description){
$html = self::mail_generator('mail/template/admin-ticket.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
$list = self::query("SELECT * FROM users WHERE status=2");
foreach($list as $item){
self::mail($item->email, self::settings('admin_ticket_title'), $html);
}
}
public static function reply($email, $fullname, $no, $title, $description){
$html = self::mail_generator('mail/template/reply.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{NO}', $no, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
self::mail($email, self::settings('reply_title'), $html);
}
public static function admin_reply($fullname, $no, $title, $description){
$html = self::mail_generator('mail/template/admin-reply.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{NO}', $no, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
$list = self::query("SELECT * FROM users WHERE status=2");
foreach($list as $item){
self::mail($item->email, self::settings('admin_reply_title'), $html);
}
}
public static function admin_payment( $fullname, $bank, $price, $description){
$html = self::mail_generator('mail/template/admin-payment.html');
$html = str_replace('{PRICE}', $price, $html);
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{BANK}', $bank, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
$list = self::query("SELECT * FROM users WHERE status=2");
foreach($list as $item){
self::mail($item->email, self::settings('admin_payment_title'), $html);
}
}
public static function sweet($type,$html,$url=null){
$title = array('success' => 'Tebrikler!', 'info' => 'Bilgilendirme', 'error' => 'Hata', 'warning' => 'Dikkat!');
$url = ($url==null)?null:self::base_url($url);
echo json_encode(array('type'=> $type, 'title' => $title[$type], 'html' => $html , 'url' => $url));
}
}
$pia = New PIA;
<?php if(strstr($_SERVER["HTTP_HOST"],'kaliteicerik.com')){}else{ exit(); } ?>
?>
Did this file decode correctly?
Original Code
<?php
class PIA {
static $pdo = null;
static $charset = 'UTF8';
static $last_stmt = null;
static $requests = [
"1" => "ye",
"2" => "Yazar",
"3" => "Admin"
];
public static function instance(){
return
self::$pdo == null ?
self::init() :
self::$pdo;
}
public static function init(){
self::$pdo = new PDO(
'mysql:host=' . MYSQL_HOST .';dbname=' . MYSQL_DB,
MYSQL_USER,
MYSQL_PASS
);
self::$pdo->exec('SET NAMES `' . self::$charset . '`');
self::$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
return self::$pdo;
}
public static function query($query, $bindings = null){
if(is_null($bindings)){
if(!self::$last_stmt = self::instance()->query($query))
return false;
}else{
self::$last_stmt = self::prepare($query);
if(!self::$last_stmt->execute($bindings))
return false;
}
return self::$last_stmt;
}
public static function get_var($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return $stmt->fetchColumn();
}
public static function get_row($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return $stmt->fetch();
}
public static function get($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
$result = array();
foreach($stmt as $row)
$result[] = $row;
return $result;
}
public static function getRequest($req)
{
return self::$requests[$req];
}
public static function array_files($file_post) {
$file_ary = array();
$file_count = count($file_post['name']);
$file_keys = array_keys($file_post);
for ($i=0; $i<$file_count; $i++) {
foreach ($file_keys as $key) {
$file_ary[$i][$key] = $file_post[$key][$i];
}
}
return $file_ary;
}
public static function exec($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return $stmt->rowCount();
}
public static function insert($query, $bindings = null){
if(!$stmt = self::query($query, $bindings))
return false;
return self::$pdo->lastInsertId();
}
public static function getLastError(){
$error_info = self::$last_stmt->errorInfo();
if($error_info[0] == 00000)
return false;
return $error_info;
}
public static function __callStatic($name, $arguments){
return call_user_func_array(
array(self::instance(), $name),
$arguments
);
}
public static function get_months($value){
$array = array('01' => 'Ocak', '02' => 'ubat', '03' => 'Mart', '04' => 'Nisan', '05' => 'Mays', '06' => 'Haziran', '07' => 'Temmuz', '08' => 'Austos', '09' => 'Eyll', '10' => 'Ekim', '11' => 'Kasm', '12' => 'Aralk');
return $array[$value];
}
public static function get_count($table,$where='1=1'){
return self::get_var("SELECT count(*) as count FROM $table WHERE $where");
}
public static function badge($table,$where='1=1'){
$count = self::get_count($table,$where);
return ($count > 0) ?'<span class="label label-success">'.$count.'</span>' : '';
}
public static function badge_two($count){
return ($count > 0) ?'<span class="label label-success">'.$count.'</span>' : '';
}
public static function nirvana($str){ return md5(md5(md5(trim($str)))); }
public static function control($theValue, $theType, $strip_tags=false) {
$theValue = trim($theValue);
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
}
return $strip_tags==true ? strip_tags($theValue) : $theValue;
}
public static function seo($title){
$TR=array('','','','','','','','','','','','');
$EN=array('c','c','i','i','s','s','g','g','o','o','u','u');
$title= str_replace($TR,$EN,$title);
$title=mb_strtolower($title,'UTF-8');
$title=preg_replace('#[^-a-zA-Z0-9_, ]#','',$title);
$title=trim($title);
$title= preg_replace('#[-_ ]+#','-',$title);
return $title;
}
public static function get_ip(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])){
return $_SERVER['HTTP_CLIENT_IP'];
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
return $_SERVER['REMOTE_ADDR'];
}
}
public static function base_url($url=null){
if (isset($_SERVER['HTTP_HOST'])) {
$http = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$core = preg_split('@/@', str_replace($_SERVER['DOCUMENT_ROOT'], '', realpath(dirname(__FILE__))), NULL, PREG_SPLIT_NO_EMPTY);
$core = (!empty($core[0]))? $core[0].'/' : '';
$return = sprintf( "%s://%s", $http, $_SERVER['HTTP_HOST'], $core).'/';
}else{
$return = 'http://localhost/';
}
return ($url==null)? $return : $return.$url ;
}
public static function label($class,$text){
return "<label class=\"label label-$class\">$text</label>";
}
public static function redirect($url=null){
$return = ($url==null)? 'location.reload()' : 'window.location.href="'.self::base_url($url).'"';
echo "<script>setInterval(function(){ $return; },1000);</script>";
}
public static function admin_redirect($url=null){
$return = ($url==null)? 'location.reload()' : 'window.location.href="'.self::base_url("admin/".$url).'"';
echo "<script>setInterval(function(){ $return; },1000);</script>";
}
public static function file_upload($file,$name,$target){
$exists = strtolower(substr($file['name'], strrpos($file['name'], ".")));
$avaible = array('.jpg', '.jpeg', '.png', '.bmp', '.gif');
if(in_array($exists, $avaible)){
$new_name = $name.$exists;
$to_location = $target.'/'.$new_name;
return move_uploaded_file($file['tmp_name'], $to_location) ? self::control($new_name,'text') : self::control('NULL','text');
}
}
public static function time_tr( $par ){
$datetime = explode(" ", $par);
$date = explode("-", $datetime[0]);
return substr($datetime[1], 0, 5).", ".$date[2]." ".self::get_months($date[1])." ".$date[0];
}
public static function settings($name){
return self::get_var("SELECT settings_value FROM settings WHERE settings_name='$name'");
}
public static function key($length = 10){
$characters = '0123456789';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
public static function mail($email, $subject, $html){
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = self::settings('smtp_host');
$mail->Port = self::settings('smtp_port');
$mail->SMTPSecure = self::settings('smtp_secure');
$mail->Username = self::settings('smtp_email');
$mail->Password = self::settings('smtp_password');
$mail->SetFrom(self::settings('smtp_email'), self::settings('site_title'));
$mail->AddAddress($email);
$mail->CharSet = 'UTF-8';
$mail->Subject = $subject;
$mail->isHTML(true);
$mail->Body = $html;
return ($mail->send())? true : false ;
}
public static function mail_generator($file){
$social = '';
$html = file_get_contents($file, FILE_USE_INCLUDE_PATH);
$html = str_replace('{SITE}', self::base_url(), $html);
$html = str_replace('{TITLE}', self::settings('site_title'), $html);
$html = str_replace('{LOGO}', self::settings('logo'), $html);
return str_replace('{TODAY}', date('Y-m-d H:i:s'), $html);
}
public static function forgot_password($email, $fullname, $code){
$html = self::mail_generator('mail/template/password.html');
$html = str_replace('{CODE}', 'sifre/'.$code, $html);
$html = str_replace('{FULLNAME}', $fullname, $html);
self::mail($email, self::settings('password_title'), $html);
}
public static function activation($email, $fullname, $code){
$html = self::mail_generator('mail/template/activation.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{CODE}', 'aktivasyon/'.$code, $html);
self::mail($email, self::settings('activation_title'), $html);
}
public static function welcome($email, $fullname){
$html = self::mail_generator('mail/template/welcome.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
self::mail($email, self::settings('welcome_title'), $html);
}
public static function ticket($email, $fullname, $title, $description){
$html = self::mail_generator('mail/template/ticket.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
self::mail($email, self::settings('ticket_title'), $html);
}
public static function admin_ticket($fullname, $title, $description){
$html = self::mail_generator('mail/template/admin-ticket.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
$list = self::query("SELECT * FROM users WHERE status=2");
foreach($list as $item){
self::mail($item->email, self::settings('admin_ticket_title'), $html);
}
}
public static function reply($email, $fullname, $no, $title, $description){
$html = self::mail_generator('mail/template/reply.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{NO}', $no, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
self::mail($email, self::settings('reply_title'), $html);
}
public static function admin_reply($fullname, $no, $title, $description){
$html = self::mail_generator('mail/template/admin-reply.html');
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{NO}', $no, $html);
$html = str_replace('{TICKET_TITLE}', $title, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
$list = self::query("SELECT * FROM users WHERE status=2");
foreach($list as $item){
self::mail($item->email, self::settings('admin_reply_title'), $html);
}
}
public static function admin_payment( $fullname, $bank, $price, $description){
$html = self::mail_generator('mail/template/admin-payment.html');
$html = str_replace('{PRICE}', $price, $html);
$html = str_replace('{FULLNAME}', $fullname, $html);
$html = str_replace('{BANK}', $bank, $html);
$html = str_replace('{DESCRIPTION}', $description, $html);
$list = self::query("SELECT * FROM users WHERE status=2");
foreach($list as $item){
self::mail($item->email, self::settings('admin_payment_title'), $html);
}
}
public static function sweet($type,$html,$url=null){
$title = array('success' => 'Tebrikler!', 'info' => 'Bilgilendirme', 'error' => 'Hata', 'warning' => 'Dikkat!');
$url = ($url==null)?null:self::base_url($url);
echo json_encode(array('type'=> $type, 'title' => $title[$type], 'html' => $html , 'url' => $url));
}
}
$pia = New PIA;
<?php if(strstr($_SERVER["HTTP_HOST"],'kaliteicerik.com')){}else{ exit(); } ?>
?>
Function Calls
| None |
Stats
| MD5 | 8dce7fca9d69e1b74527ae63d5f54142 |
| Eval Count | 0 |
| Decode Time | 98 ms |