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 defined("\x42\x41\x53\105\120\101\x54\x48") or die("\x4e\x6f\x20\144\151\x72\145\x6..
Decoded Output download
<?php
defined("BASEPATH") or die("No direct script access allowed"); class CI_FTP { public $hostname = ''; public $username = ''; public $password = ''; public $port = 21; public $passive = TRUE; public $debug = FALSE; protected $conn_id; public function __construct($config = array()) { empty($config) or $this->initialize($config); log_message("info", "FTP Class Initialized"); } public function initialize($config = array()) { foreach ($config as $key => $val) { if (isset($this->{$key})) { $this->{$key} = $val; } } $this->hostname = preg_replace("|.+?://|", '', $this->hostname); } public function connect($config = array()) { if (count($config) > 0) { $this->initialize($config); } if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port))) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_connect"); } return FALSE; } if (!$this->_login()) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_login"); } return FALSE; } if ($this->passive === TRUE) { ftp_pasv($this->conn_id, TRUE); } return TRUE; } protected function _login() { return @ftp_login($this->conn_id, $this->username, $this->password); } protected function _is_conn() { if (!is_resource($this->conn_id)) { if ($this->debug === TRUE) { $this->_error("ftp_no_connection"); } return FALSE; } return TRUE; } public function changedir($path, $suppress_debug = FALSE) { if (!$this->_is_conn()) { return FALSE; } $result = @ftp_chdir($this->conn_id, $path); if ($result === FALSE) { if ($this->debug === TRUE && $suppress_debug === FALSE) { $this->_error("ftp_unable_to_changedir"); } return FALSE; } return TRUE; } public function mkdir($path, $permissions = NULL) { if ($path === '' or !$this->_is_conn()) { return FALSE; } $result = @ftp_mkdir($this->conn_id, $path); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_mkdir"); } return FALSE; } if ($permissions !== NULL) { $this->chmod($path, (int) $permissions); } return TRUE; } public function upload($locpath, $rempath, $mode = "auto", $permissions = NULL) { if (!$this->_is_conn()) { return FALSE; } if (!file_exists($locpath)) { $this->_error("ftp_no_source_file"); return FALSE; } if ($mode === "auto") { $ext = $this->_getext($locpath); $mode = $this->_settype($ext); } $mode = $mode === "ascii" ? FTP_ASCII : FTP_BINARY; $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_upload"); } return FALSE; } if ($permissions !== NULL) { $this->chmod($rempath, (int) $permissions); } return TRUE; } public function download($rempath, $locpath, $mode = "auto") { if (!$this->_is_conn()) { return FALSE; } if ($mode === "auto") { $ext = $this->_getext($rempath); $mode = $this->_settype($ext); } $mode = $mode === "ascii" ? FTP_ASCII : FTP_BINARY; $result = @ftp_get($this->conn_id, $locpath, $rempath, $mode); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_download"); } return FALSE; } return TRUE; } public function rename($old_file, $new_file, $move = FALSE) { if (!$this->_is_conn()) { return FALSE; } $result = @ftp_rename($this->conn_id, $old_file, $new_file); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_" . ($move === FALSE ? "rename" : "move")); } return FALSE; } return TRUE; } public function move($old_file, $new_file) { return $this->rename($old_file, $new_file, TRUE); } public function delete_file($filepath) { if (!$this->_is_conn()) { return FALSE; } $result = @ftp_delete($this->conn_id, $filepath); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_delete"); } return FALSE; } return TRUE; } public function delete_dir($filepath) { if (!$this->_is_conn()) { return FALSE; } $filepath = preg_replace("/(.+?)\/*$/", "/", $filepath); $list = $this->list_files($filepath); if (!empty($list)) { for ($i = 0, $c = count($list); $i < $c; $i++) { if (!preg_match("#/\.\.?$#", $list[$i]) && !@ftp_delete($this->conn_id, $list[$i])) { $this->delete_dir($filepath . $list[$i]); } } } if (@ftp_rmdir($this->conn_id, $filepath) === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_delete"); } return FALSE; } return TRUE; } public function chmod($path, $perm) { if (!$this->_is_conn()) { return FALSE; } if (@ftp_chmod($this->conn_id, $perm, $path) === FALSE) { if ($this->debug === TRUE) { $this->_error("ftp_unable_to_chmod"); } return FALSE; } return TRUE; } public function list_files($path = ".") { return $this->_is_conn() ? ftp_nlist($this->conn_id, $path) : FALSE; } public function mirror($locpath, $rempath) { if (!$this->_is_conn()) { return FALSE; } if ($fp = @opendir($locpath)) { if (!$this->changedir($rempath, TRUE) && (!$this->mkdir($rempath) or !$this->changedir($rempath))) { return FALSE; } while (FALSE !== ($file = readdir($fp))) { if (is_dir($locpath . $file) && $file[0] !== ".") { $this->mirror($locpath . $file . "/", $rempath . $file . "/"); } elseif ($file[0] !== ".") { $ext = $this->_getext($file); $mode = $this->_settype($ext); $this->upload($locpath . $file, $rempath . $file, $mode); } } return TRUE; } return FALSE; } protected function _getext($filename) { return ($dot = strrpos($filename, ".")) === FALSE ? "txt" : substr($filename, $dot + 1); } protected function _settype($ext) { return in_array($ext, array("txt", "text", "php", "phps", "php4", "js", "css", "htm", "html", "phtml", "shtml", "log", "xml"), TRUE) ? "ascii" : "binary"; } public function close() { return $this->_is_conn() ? @ftp_close($this->conn_id) : FALSE; } protected function _error($line) { $CI =& get_instance(); $CI->lang->load("ftp"); show_error($CI->lang->line($line)); } } ?>
Did this file decode correctly?
Original Code
<?php
defined("\x42\x41\x53\105\120\101\x54\x48") or die("\x4e\x6f\x20\144\151\x72\145\x63\164\40\x73\143\x72\x69\160\x74\x20\141\x63\143\145\163\x73\40\x61\x6c\154\157\167\145\x64"); class CI_FTP { public $hostname = ''; public $username = ''; public $password = ''; public $port = 21; public $passive = TRUE; public $debug = FALSE; protected $conn_id; public function __construct($config = array()) { empty($config) or $this->initialize($config); log_message("\151\x6e\x66\157", "\106\124\120\40\x43\154\x61\x73\x73\x20\111\156\151\164\x69\141\154\x69\x7a\x65\x64"); } public function initialize($config = array()) { foreach ($config as $key => $val) { if (isset($this->{$key})) { $this->{$key} = $val; } } $this->hostname = preg_replace("\174\x2e\53\x3f\72\57\x2f\174", '', $this->hostname); } public function connect($config = array()) { if (count($config) > 0) { $this->initialize($config); } if (FALSE === ($this->conn_id = @ftp_connect($this->hostname, $this->port))) { if ($this->debug === TRUE) { $this->_error("\x66\164\160\x5f\165\156\x61\x62\154\145\x5f\164\157\137\143\x6f\156\156\145\143\164"); } return FALSE; } if (!$this->_login()) { if ($this->debug === TRUE) { $this->_error("\146\164\x70\x5f\165\x6e\141\x62\154\145\137\164\157\137\154\x6f\x67\x69\x6e"); } return FALSE; } if ($this->passive === TRUE) { ftp_pasv($this->conn_id, TRUE); } return TRUE; } protected function _login() { return @ftp_login($this->conn_id, $this->username, $this->password); } protected function _is_conn() { if (!is_resource($this->conn_id)) { if ($this->debug === TRUE) { $this->_error("\x66\164\x70\137\156\157\137\x63\x6f\156\x6e\x65\143\x74\x69\x6f\156"); } return FALSE; } return TRUE; } public function changedir($path, $suppress_debug = FALSE) { if (!$this->_is_conn()) { return FALSE; } $result = @ftp_chdir($this->conn_id, $path); if ($result === FALSE) { if ($this->debug === TRUE && $suppress_debug === FALSE) { $this->_error("\146\x74\160\x5f\x75\x6e\x61\x62\x6c\145\137\164\157\x5f\x63\150\x61\x6e\x67\145\144\151\162"); } return FALSE; } return TRUE; } public function mkdir($path, $permissions = NULL) { if ($path === '' or !$this->_is_conn()) { return FALSE; } $result = @ftp_mkdir($this->conn_id, $path); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("\x66\x74\x70\x5f\165\x6e\x61\x62\x6c\145\x5f\x74\x6f\x5f\x6d\x6b\144\x69\x72"); } return FALSE; } if ($permissions !== NULL) { $this->chmod($path, (int) $permissions); } return TRUE; } public function upload($locpath, $rempath, $mode = "\x61\x75\164\157", $permissions = NULL) { if (!$this->_is_conn()) { return FALSE; } if (!file_exists($locpath)) { $this->_error("\x66\x74\x70\137\x6e\x6f\137\x73\157\x75\162\143\145\x5f\x66\151\154\145"); return FALSE; } if ($mode === "\x61\165\164\157") { $ext = $this->_getext($locpath); $mode = $this->_settype($ext); } $mode = $mode === "\141\163\x63\x69\151" ? FTP_ASCII : FTP_BINARY; $result = @ftp_put($this->conn_id, $rempath, $locpath, $mode); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("\x66\164\x70\x5f\x75\156\141\x62\x6c\145\x5f\x74\x6f\x5f\165\x70\x6c\x6f\141\144"); } return FALSE; } if ($permissions !== NULL) { $this->chmod($rempath, (int) $permissions); } return TRUE; } public function download($rempath, $locpath, $mode = "\141\x75\164\x6f") { if (!$this->_is_conn()) { return FALSE; } if ($mode === "\141\165\x74\x6f") { $ext = $this->_getext($rempath); $mode = $this->_settype($ext); } $mode = $mode === "\141\163\x63\151\x69" ? FTP_ASCII : FTP_BINARY; $result = @ftp_get($this->conn_id, $locpath, $rempath, $mode); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("\146\164\x70\x5f\165\x6e\x61\x62\x6c\x65\137\164\157\137\x64\157\x77\x6e\x6c\157\x61\144"); } return FALSE; } return TRUE; } public function rename($old_file, $new_file, $move = FALSE) { if (!$this->_is_conn()) { return FALSE; } $result = @ftp_rename($this->conn_id, $old_file, $new_file); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("\x66\164\x70\x5f\165\156\x61\142\x6c\145\x5f\x74\157\137" . ($move === FALSE ? "\x72\145\156\x61\x6d\145" : "\x6d\x6f\x76\145")); } return FALSE; } return TRUE; } public function move($old_file, $new_file) { return $this->rename($old_file, $new_file, TRUE); } public function delete_file($filepath) { if (!$this->_is_conn()) { return FALSE; } $result = @ftp_delete($this->conn_id, $filepath); if ($result === FALSE) { if ($this->debug === TRUE) { $this->_error("\146\164\x70\137\x75\156\141\x62\154\145\137\x74\x6f\x5f\x64\145\x6c\145\x74\x65"); } return FALSE; } return TRUE; } public function delete_dir($filepath) { if (!$this->_is_conn()) { return FALSE; } $filepath = preg_replace("\57\x28\x2e\53\x3f\x29\x5c\57\x2a\44\x2f", "\x5c\x31\x2f", $filepath); $list = $this->list_files($filepath); if (!empty($list)) { for ($i = 0, $c = count($list); $i < $c; $i++) { if (!preg_match("\x23\57\134\56\x5c\x2e\77\x24\x23", $list[$i]) && !@ftp_delete($this->conn_id, $list[$i])) { $this->delete_dir($filepath . $list[$i]); } } } if (@ftp_rmdir($this->conn_id, $filepath) === FALSE) { if ($this->debug === TRUE) { $this->_error("\x66\164\160\137\x75\x6e\x61\x62\154\x65\x5f\164\157\137\144\145\154\x65\164\145"); } return FALSE; } return TRUE; } public function chmod($path, $perm) { if (!$this->_is_conn()) { return FALSE; } if (@ftp_chmod($this->conn_id, $perm, $path) === FALSE) { if ($this->debug === TRUE) { $this->_error("\146\x74\x70\x5f\165\156\141\142\154\x65\x5f\x74\x6f\137\x63\x68\155\157\x64"); } return FALSE; } return TRUE; } public function list_files($path = "\x2e") { return $this->_is_conn() ? ftp_nlist($this->conn_id, $path) : FALSE; } public function mirror($locpath, $rempath) { if (!$this->_is_conn()) { return FALSE; } if ($fp = @opendir($locpath)) { if (!$this->changedir($rempath, TRUE) && (!$this->mkdir($rempath) or !$this->changedir($rempath))) { return FALSE; } while (FALSE !== ($file = readdir($fp))) { if (is_dir($locpath . $file) && $file[0] !== "\x2e") { $this->mirror($locpath . $file . "\x2f", $rempath . $file . "\x2f"); } elseif ($file[0] !== "\56") { $ext = $this->_getext($file); $mode = $this->_settype($ext); $this->upload($locpath . $file, $rempath . $file, $mode); } } return TRUE; } return FALSE; } protected function _getext($filename) { return ($dot = strrpos($filename, "\56")) === FALSE ? "\164\170\x74" : substr($filename, $dot + 1); } protected function _settype($ext) { return in_array($ext, array("\x74\x78\x74", "\164\145\x78\164", "\160\x68\x70", "\x70\150\160\163", "\160\150\160\64", "\152\163", "\x63\163\163", "\x68\x74\x6d", "\x68\164\x6d\x6c", "\160\150\x74\x6d\154", "\163\150\x74\155\154", "\x6c\157\x67", "\x78\x6d\154"), TRUE) ? "\141\x73\x63\x69\151" : "\x62\151\156\141\x72\x79"; } public function close() { return $this->_is_conn() ? @ftp_close($this->conn_id) : FALSE; } protected function _error($line) { $CI =& get_instance(); $CI->lang->load("\x66\164\160"); show_error($CI->lang->line($line)); } }
Function Calls
defined | 1 |
Stats
MD5 | 3814010fd7a77ca257987cf948d83859 |
Eval Count | 0 |
Decode Time | 145 ms |