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 //Check for config.. if(!file_exists("include/config.php")) { die("<b>There..

Decoded Output download

<?php  
//Check for config.. 
if(!file_exists("include/config.php")) 
{ 
    die("<b>There is an error. Config file not found. Please re-install or contact support.</b>"); 
} 
session_start(); 
 
require_once('include/util.php'); 
require_once('include/Pagination.php'); 
$db = new DB(); 
 
$pagination = new Pagination(); 
$page_n = 1; 
if (isset($_GET['page'])){ 
    $page_n = (int) $_GET['page']; 
} 
if(strpos($_SERVER['REQUEST_URI'],"page") === false) 
{ 
    $url="//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; 
    if(strpos($_SERVER['REQUEST_URI'],"?sel") === false) 
        $pagination->setLink($url."?page=%s"); 
    else 
        $pagination->setLink($url."&page=%s"); 
}else{ 
    $url="//".$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'], 0, -strlen($_REQUEST['page'])); 
    $pagination->setLink($url."%s"); 
} 
$pagination->setPage($page_n); 
$pagination->setSize(20); 
 
// Check if Admin 
if($_SESSION['permission'] == 0) 
{ 
    $companies = $db->getAllCompaniesForUser($_SESSION['user_id'],$pagination,@$_GET['search']); 
    $total_count = $db->getCompanyCountForUser($_SESSION['user_id']); 
}else{ 
    $companies = $db->getAllCompanies($pagination,@$_GET['search']); 
    $total_count = $db->getCompanyCount(); 
} 
if(isset($_REQUEST['search'])) { 
    $companies_count = (string) count( array_keys( $companies ) ); 
    $pagination->setTotalRecords($companies_count); 
}else { 
    $companies_count = $total_count; 
    $pagination->setTotalRecords($total_count); 
} 
 
//Pre-load Checks 
if(!isset($_SESSION['user_id'])) 
{ 
    header("Location: login.php"); 
    exit; 
} 
 
// DISABLE CACHE 
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past 
 
$twilio_numbers=Util::get_all_twilio_numbers(); 
?> 
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html"> 
 
<head> 
 
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
 
    <title><?php echo $title; ?></title> 
 
    <?php include "include/css.php"; ?> 
 
    <!--[if lt IE 8]><style type="text/css" media="all">@import url("css/ie.css");</style><![endif]--> 
 
</head> 
 
 
 
 
 
<body> 
 
<div id="hld"> 
 
<div class="wrapper">		<!-- wrapper begins --> 
 
 
<?php include_once("include/nav.php"); ?> 
<!-- #header ends --> 
 
 
<div class="block"> 
 
    <div class="block_head"> 
        <div class="bheadl"></div> 
        <div class="bheadr"></div> 
 
        <h2> 
            <?php 
            if($companies_count==1) echo ("1 Company &nbsp; &nbsp; "); else 
                echo ($companies_count." Companies &nbsp; &nbsp; "); 
            ?> 
        </h2> 
        <div id="searchbox" style="margin-left: 175px;"> 
            <input type="text" id="search" value="<?php echo @$_GET['search']; ?>" placeholder="Company Name" /> 
            <a href="#" onclick="window.location='companies.php';"><img src="images/ic_cancel.png" width="16" class="search-reset tt" style="<?php echo isset($_GET['search']) ? "display:inline-block !important;":""; ?>" title="Reset"></a> 
        </div> 
    </div>		<!-- .block_head ends --> 
 
    <div class="block_content"> 
 
        <?php if(@$_GET['sel']=="no"){ ?> 
        <div class="message warning" style="width: 93%;margin: 0 auto;margin-top: 8px;"><p>Please select a company to view.</p></div> 
        <?php } ?> 
 
        <table cellpadding="0" cellspacing="0" width="100%" class="companies"> 
 
            <thead> 
            <tr> 
                <th>Company</th> 
                <th>Numbers</th> 
                <th>Calls (Last 7 days)</th> 
                <th>Calls (Total)</th> 
                <th>Calls (Out)</th> 
            </tr> 
            </thead> 
 
            <tbody> 
 
            <?php 
 
            if($_SESSION['permission']==0) 
            { 
                $disabled_numbers = $db->getUserAccessNumbers($_SESSION['user_id']); 
            }else{ 
                $disabled_numbers = array(); 
            } 
            //session_write_close(); 
 
            if (!isset($_SESSION['last_cached_date'])) { 
                $_SESSION['last_cached_date'] = strtotime("now"); 
            } 
 
            foreach ($companies as $key => $company) { 
                global $TIMEZONE; 
                $now = new DateTime_52(); 
                $now->setTimezone(new DateTimeZone($TIMEZONE)); 
 
                $sevendaysago = new DateTime_52(); 
                $sevendaysago->setTimezone(new DateTimeZone($TIMEZONE)); 
                $sevendaysago->modify("-7 days"); 
                $sevendaysago->setTime(0,0,0); 
                 
                if (isset($_SESSION['companies_cached_counts_'.$company['idx']])) { 
                    $cached_counts = json_decode($_SESSION['companies_cached_counts_'.$company['idx']], true); 
                    $numbers = @$cached_counts['numbers']; 
                    $more_calls = $db->getCallsInRangeCount(@$company_id, $_SESSION['last_cached_date'], strtotime("now")); 
 
                    $total_outgoing_calls = $cached_counts['total_outgoing_calls']; 
 
                    $more_calls = $db->getCallsInRangeCount($company['idx'], $_SESSION['last_cached_date'], strtotime("now"), 0, 'all', false, "", true, "", ""); 
                    $total_outgoing_calls = $cached_counts['total_outgoing_calls'] + $more_calls; 
                    $cached_counts['total_outgoing_calls'] = $total_outgoing_calls; 
 
                    $_SESSION['companies_cached_counts_'.$company['idx']] = json_encode($cached_counts); 
                } 
                else { 
                    $c_nums = $db->getCompanyNumIntl($company['idx']); 
                    $numbers = ""; 
                    $last_seven_days_count = 0; 
 
                    if($c_nums!="") 
                    { 
                        foreach($c_nums as $number) 
                        { 
                            $number_disabled = false; 
                            foreach($disabled_numbers as $disabled_number) 
                            { 
                                $number_ = ""; 
                                if(!$number[1]) 
                                    $number_ = "+1".$number[0]; 
 
                                if($disabled_number->number===$number_) 
                                    $number_disabled = true; 
                            } 
 
                            if($number_disabled) 
                                continue; 
 
                            $numbers .= format_phone($number[0]).", "; 
                        } 
                    } 
 
                    if(strlen($numbers)==0) 
                        $numbers = "None"; 
 
                    $total_outgoing_calls = 0; 
 
                    $out_call = $db->cget_outgoing_calls_count($company['idx']); 
                    if(is_array($out_call)) 
                        foreach($out_call as $num){ 
                            $total_outgoing_calls += $num['cnt']; 
                        } 
 
 
                    $_SESSION['companies_cached_counts_'.$company['idx']] = json_encode(array( 
                        'numbers' => $numbers, 
                        'total_outgoing_calls' => $total_outgoing_calls 
                    )); 
                } 
            ?> 
 
                <?php } 
                    $_SESSION['last_cached_date'] = strtotime("now"); 
                ?> 
        </table> 
 
        <?php $navigation = $pagination->create_links(); 
        echo $navigation; ?> 
 
    </div>		<!-- .block_content ends --> 
 
    <div class="bendl"></div> 
    <div class="bendr"></div> 
</div>		<!-- .block ends --> 
 
 
<?php include "include/footer.php"; ?> 
    <script type="text/javascript"> 
        var lastsevenExtract = function(node){ 
            return $(node).children[0].innerHTML; 
        }; 
        $("table.companies").tablesorter({ 
            widgets: ['zebra'], 
            textExtraction: { 2:lastsevenExtract } 
        }); 
        $(document).ready(function(){ 
            $("[id^='last_seven']").each(function(i,v){ 
                var company_id = $(v).attr("data-company-id"); 
                var response = JSONuserajaxCall({ 
                    func: "USR_COMPANY_GET_LAST_SEVEN", 
                    data: company_id 
                }); 
                response.done(function(data) { 
                    $("#last_seven_"+company_id).html(data.last_seven_days_count); 
                    $("#total_calls_"+company_id).html(data.total_incoming_calls); 
                }); 
                $("table.companies").trigger('updateAll'); 
            }); 
        }); 
        $("#search").keyup(function(e){ 
            if(e.which == 13){ 
                var query = $("#search").val(); 
                if(query.length>0) 
                    window.location = "companies.php?search="+encodeURIComponent(query)+"&page=1"; 
                else 
                    window.location = "companies.php"; 
            } 
        }); 
    </script> 
</body> 
</html> ?>

Did this file decode correctly?

Original Code

<?php 
//Check for config..
if(!file_exists("include/config.php"))
{
    die("<b>There is an error. Config file not found. Please re-install or contact support.</b>");
}
session_start();

require_once('include/util.php');
require_once('include/Pagination.php');
$db = new DB();

$pagination = new Pagination();
$page_n = 1;
if (isset($_GET['page'])){
    $page_n = (int) $_GET['page'];
}
if(strpos($_SERVER['REQUEST_URI'],"page") === false)
{
    $url="//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    if(strpos($_SERVER['REQUEST_URI'],"?sel") === false)
        $pagination->setLink($url."?page=%s");
    else
        $pagination->setLink($url."&page=%s");
}else{
    $url="//".$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'], 0, -strlen($_REQUEST['page']));
    $pagination->setLink($url."%s");
}
$pagination->setPage($page_n);
$pagination->setSize(20);

// Check if Admin
if($_SESSION['permission'] == 0)
{
    $companies = $db->getAllCompaniesForUser($_SESSION['user_id'],$pagination,@$_GET['search']);
    $total_count = $db->getCompanyCountForUser($_SESSION['user_id']);
}else{
    $companies = $db->getAllCompanies($pagination,@$_GET['search']);
    $total_count = $db->getCompanyCount();
}
if(isset($_REQUEST['search'])) {
    $companies_count = (string) count( array_keys( $companies ) );
    $pagination->setTotalRecords($companies_count);
}else {
    $companies_count = $total_count;
    $pagination->setTotalRecords($total_count);
}

//Pre-load Checks
if(!isset($_SESSION['user_id']))
{
    header("Location: login.php");
    exit;
}

// DISABLE CACHE
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

$twilio_numbers=Util::get_all_twilio_numbers();
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">

<head>

    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title><?php echo $title; ?></title>

    <?php include "include/css.php"; ?>

    <!--[if lt IE 8]><style type="text/css" media="all">@import url("css/ie.css");</style><![endif]-->

</head>





<body>

<div id="hld">

<div class="wrapper">		<!-- wrapper begins -->


<?php include_once("include/nav.php"); ?>
<!-- #header ends -->


<div class="block">

    <div class="block_head">
        <div class="bheadl"></div>
        <div class="bheadr"></div>

        <h2>
            <?php
            if($companies_count==1) echo ("1 Company &nbsp; &nbsp; "); else
                echo ($companies_count." Companies &nbsp; &nbsp; ");
            ?>
        </h2>
        <div id="searchbox" style="margin-left: 175px;">
            <input type="text" id="search" value="<?php echo @$_GET['search']; ?>" placeholder="Company Name" />
            <a href="#" onclick="window.location='companies.php';"><img src="images/ic_cancel.png" width="16" class="search-reset tt" style="<?php echo isset($_GET['search']) ? "display:inline-block !important;":""; ?>" title="Reset"></a>
        </div>
    </div>		<!-- .block_head ends -->

    <div class="block_content">

        <?php if(@$_GET['sel']=="no"){ ?>
        <div class="message warning" style="width: 93%;margin: 0 auto;margin-top: 8px;"><p>Please select a company to view.</p></div>
        <?php } ?>

        <table cellpadding="0" cellspacing="0" width="100%" class="companies">

            <thead>
            <tr>
                <th>Company</th>
                <th>Numbers</th>
                <th>Calls (Last 7 days)</th>
                <th>Calls (Total)</th>
                <th>Calls (Out)</th>
            </tr>
            </thead>

            <tbody>

            <?php

            if($_SESSION['permission']==0)
            {
                $disabled_numbers = $db->getUserAccessNumbers($_SESSION['user_id']);
            }else{
                $disabled_numbers = array();
            }
            //session_write_close();

            if (!isset($_SESSION['last_cached_date'])) {
                $_SESSION['last_cached_date'] = strtotime("now");
            }

            foreach ($companies as $key => $company) {
                global $TIMEZONE;
                $now = new DateTime_52();
                $now->setTimezone(new DateTimeZone($TIMEZONE));

                $sevendaysago = new DateTime_52();
                $sevendaysago->setTimezone(new DateTimeZone($TIMEZONE));
                $sevendaysago->modify("-7 days");
                $sevendaysago->setTime(0,0,0);
                
                if (isset($_SESSION['companies_cached_counts_'.$company['idx']])) {
                    $cached_counts = json_decode($_SESSION['companies_cached_counts_'.$company['idx']], true);
                    $numbers = @$cached_counts['numbers'];
                    $more_calls = $db->getCallsInRangeCount(@$company_id, $_SESSION['last_cached_date'], strtotime("now"));

                    $total_outgoing_calls = $cached_counts['total_outgoing_calls'];

                    $more_calls = $db->getCallsInRangeCount($company['idx'], $_SESSION['last_cached_date'], strtotime("now"), 0, 'all', false, "", true, "", "");
                    $total_outgoing_calls = $cached_counts['total_outgoing_calls'] + $more_calls;
                    $cached_counts['total_outgoing_calls'] = $total_outgoing_calls;

                    $_SESSION['companies_cached_counts_'.$company['idx']] = json_encode($cached_counts);
                }
                else {
                    $c_nums = $db->getCompanyNumIntl($company['idx']);
                    $numbers = "";
                    $last_seven_days_count = 0;

                    if($c_nums!="")
                    {
                        foreach($c_nums as $number)
                        {
                            $number_disabled = false;
                            foreach($disabled_numbers as $disabled_number)
                            {
                                $number_ = "";
                                if(!$number[1])
                                    $number_ = "+1".$number[0];

                                if($disabled_number->number===$number_)
                                    $number_disabled = true;
                            }

                            if($number_disabled)
                                continue;

                            $numbers .= format_phone($number[0]).", ";
                        }
                    }

                    if(strlen($numbers)==0)
                        $numbers = "None";

                    $total_outgoing_calls = 0;

                    $out_call = $db->cget_outgoing_calls_count($company['idx']);
                    if(is_array($out_call))
                        foreach($out_call as $num){
                            $total_outgoing_calls += $num['cnt'];
                        }


                    $_SESSION['companies_cached_counts_'.$company['idx']] = json_encode(array(
                        'numbers' => $numbers,
                        'total_outgoing_calls' => $total_outgoing_calls
                    ));
                }
            ?>

                <?php }
                    $_SESSION['last_cached_date'] = strtotime("now");
                ?>
        </table>

        <?php $navigation = $pagination->create_links();
        echo $navigation; ?>

    </div>		<!-- .block_content ends -->

    <div class="bendl"></div>
    <div class="bendr"></div>
</div>		<!-- .block ends -->


<?php include "include/footer.php"; ?>
    <script type="text/javascript">
        var lastsevenExtract = function(node){
            return $(node).children[0].innerHTML;
        };
        $("table.companies").tablesorter({
            widgets: ['zebra'],
            textExtraction: { 2:lastsevenExtract }
        });
        $(document).ready(function(){
            $("[id^='last_seven']").each(function(i,v){
                var company_id = $(v).attr("data-company-id");
                var response = JSONuserajaxCall({
                    func: "USR_COMPANY_GET_LAST_SEVEN",
                    data: company_id
                });
                response.done(function(data) {
                    $("#last_seven_"+company_id).html(data.last_seven_days_count);
                    $("#total_calls_"+company_id).html(data.total_incoming_calls);
                });
                $("table.companies").trigger('updateAll');
            });
        });
        $("#search").keyup(function(e){
            if(e.which == 13){
                var query = $("#search").val();
                if(query.length>0)
                    window.location = "companies.php?search="+encodeURIComponent(query)+"&page=1";
                else
                    window.location = "companies.php";
            }
        });
    </script>
</body>
</html> ?>

Function Calls

file_exists 1
session_start 1

Variables

None

Stats

MD5 8b531295069263a68544dbde4397fe93
Eval Count 0
Decode Time 185 ms