3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php # RightNow Cron Job $url = "http://support-upgrade.infoblox.com/cgi-bin/infoblox.cfg/services/soap?wsdl=typed"; $client = new SoapClient($url, array('classmap' => array('Incident' => 'Incident', 'PersonName' => 'PersonName', 'GenericField' => 'GenericField', 'DataValue' => 'DataValue', 'ObjectType' => 'ObjectType', 'UpdateProcessingOptions' => 'UpdateProcessingOptions', 'BatchRequestItem' => 'BatchRequestItem', 'UpdateMsg' => 'UpdateMsg', 'ID'=>'ID'),"trace" => 1)); $headers = array(); class PersonName { var $First; var $Last; } class RunAnalyticsReportMsg { var $AnalyticsReport; var $Limit; var $Start; var $Delimiter; var $ReturnRawResult; var $DisableMTOM; } class AnalyticsReport { var $ID; } class UpdateMsg { var $RNObjects; var $ProcessingOptions; } class BatchRequestItem { var $UpdateMsg; var $CommitAfter; var $PreserveChainID; } class ID { var $ID; } class RNObject { private $id; function RNObject($id) { $this->id=$id; } } class Incident { var $ID; } class Contact { var $ID; var $Name; } class UpdateProcessingOptions { var $SuppressExternalEvents; var $SuppressRules; } class clsWSSEAuth { private $Username; private $Password; function __construct($username, $password) { $this->Username=$username; $this->Password=$password; } } class clsWSSEToken { private $UsernameToken; function __construct ($innerVal){ $this->UsernameToken = $innerVal; } } class App { private $AppID; function __construct($app) { $this->AppID = $app; } } class RNObjectType { var $Namespace; } class DataValue { var $StringValue; var $ObjectValue; var $DateTimeValue; } class GenericObject { var $ObjectType; var $GenericFields; } class GenericField { var $DataValue; var $dataType; var $name; } date_default_timezone_set("America/Chicago"); print("time = ". date("Y-m-d H:i:s") ."\n\n"); #$logfile = './runCXAutoMessagingLog.log'; $logfile = '/var/www/html/cron-jobs/RightNow/runCXAutoMessagingLog.log'; if(filesize($logfile)>6000) unlink($logfile); if (file_exists($logfile)) { $fh = fopen($logfile, "a"); fputs($fh, sprintf("[%s]Automated processing started\n", date("Y-m-d H:i:s"))); fclose($fh); } else { $fh = fopen($logfile, "a"); if($fh==false) die("unable to create file"); fputs($fh, sprintf("[%s]Automated processing started\n", date("Y-m-d H:i:s"))); fclose($fh); } require_once 'config.default.php'; //Check with your provider which security name-space they are using. $strWSSENS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; $objSoapVarUser = new SoapVar($username, XSD_STRING, NULL, $strWSSENS, NULL, $strWSSENS); $objSoapVarPass = new SoapVar($password, XSD_STRING, NULL, $strWSSENS, NULL, $strWSSENS); $objWSSEAuth = new clsWSSEAuth($objSoapVarUser, $objSoapVarPass); $objSoapVarWSSEAuth = new SoapVar($objWSSEAuth, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'UsernameToken', $strWSSENS); $objWSSEToken = new clsWSSEToken($objSoapVarWSSEAuth); $objSoapVarWSSEToken = new SoapVar($objWSSEToken, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'UsernameToken', $strWSSENS); $objSoapVarHeaderVal=new SoapVar($objSoapVarWSSEToken, SOAP_ENC_OBJECT, NULL, $strWSSENS, 'Security', $strWSSENS); $objSoapVarWSSEHeader = new SoapHeader($strWSSENS, 'Security', $objSoapVarHeaderVal,true, 'http://abce.com'); $objSoapVarAppID = new SoapVar('testcall', XSD_STRING, NULL, $strWSSENS, NULL, $strWSSENS); $paramApp = new App($objSoapVarAppID); try { $objSoapVarClientInfoHeader = new SoapHeader("urn:messages.ws.rightnow.com/v1_3", 'ClientInfoHeader',$paramApp,false); $client->__setSoapHeaders(array($objSoapVarClientInfoHeader,$objSoapVarWSSEHeader)); //report ids processReminders(103247,'notify_rma_21day'); //dev 101381 test 101925 processReminders(103248,'notify_rma_28day'); //dev 101382 test 101926 processReminders(103249,'notify_rma_35day'); //dev 101383 test 101927 processReminders(103250,'queue_rma_followup'); //dev 101386 test processClosedSurveys(103246, date('c')); //dev 101384 test 101924 } catch (SoapFault $sf) { //this code was not reached echo $sf->getMessage(); echo $client->__getLastRequest(); echo $client->__getLastResponse(); } catch (Exception $e) { echo $client->__getLastRequest(); echo $client->__getLastResponse(); echo $e->getMessage(); } function processClosedSurveys($rpt_id, $timestamp) { global $client,$logfile; $rptID = array("id"=>$rpt_id); $rpt = new AnalyticsReport(); $rpt->ID = $rptID; $rpt_msg = new RunAnalyticsReportMsg(); $rpt_msg->AnalyticsReport = $rpt; $result = $client->RunAnalyticsReport($rpt_msg); echo $client->__getLastRequest(); print_r($result); //for the batch $batchArr = array(); if($result && $result->CSVTableSet->CSVTables->CSVTable->Rows) { //need in array form, even when one result $resultArr = array(); if(isset($result->CSVTableSet->CSVTables->CSVTable->Rows->Row) && is_array($result->CSVTableSet->CSVTables->CSVTable->Rows->Row)) { for($i=0; $i<count($result->CSVTableSet->CSVTables->CSVTable->Rows->Row); $i++) { $resultArr[] = $result->CSVTableSet->CSVTables->CSVTable->Rows->Row[$i]; } } else if(isset($result->CSVTableSet->CSVTables->CSVTable->Rows->Row)) { $resultArr[] = $result->CSVTableSet->CSVTables->CSVTable->Rows->Row; } foreach($resultArr as $row) { $incident = new Incident(); $incident->ID = array("id"=>$row); $incident->CustomFields = setCustomField("date_survey_sent", $timestamp, "DATETIME"); $upo = new UpdateProcessingOptions(); $upo->SuppressExternalEvents = true; $upo->SuppressRules = false; $updmsg = new UpdateMsg(); $updmsg->RNObjects = $incident; $updmsg->ProcessingOptions = $upo; $bri = new BatchRequestItem(); $bri->UpdateMsg = $updmsg; $bri->CommitAfter = "false"; $batchArr[] = $bri; //$result = $client->update($updmsg); } // end foreach if(count($batchArr) > 0) { $batchChunks = array_chunk($batchArr,90); foreach($batchChunks as $batch){ $result = $client->Batch($batch); print_r($result); } } } //end if result if (file_exists($logfile)) { $fh = fopen($logfile, "a"); fputs($fh, sprintf("[%s]Process Send Surveys:count=%d\n", date("Y-m-d H:i:s"),count($batchArr))); fclose($fh); } } function processReminders($rpt_id, $trigger_message) { global $client,$logfile; //identify rma returns at 21 days $rptID = array("id"=>$rpt_id); $rpt = new AnalyticsReport(); $rpt->ID = $rptID; $rpt_msg = new RunAnalyticsReportMsg(); $rpt_msg->AnalyticsReport = $rpt; $result = $client->RunAnalyticsReport($rpt_msg); echo $client->__getLastRequest(); print_r($result); //for the batch $batchArr = array(); if($result && $result->CSVTableSet->CSVTables->CSVTable->Rows) { //need in array form, even when one result $resultArr = array(); if(isset($result->CSVTableSet->CSVTables->CSVTable->Rows->Row) && is_array($result->CSVTableSet->CSVTables->CSVTable->Rows->Row)) { for($i=0; $i<count($result->CSVTableSet->CSVTables->CSVTable->Rows->Row); $i++) { $resultArr[] = $result->CSVTableSet->CSVTables->CSVTable->Rows->Row[$i]; } } else if(isset($result->CSVTableSet->CSVTables->CSVTable->Rows->Row)) { $resultArr[] = $result->CSVTableSet->CSVTables->CSVTable->Rows->Row; } foreach($resultArr as $row) { $incident = new Incident(); $incident->ID = array("id"=>$row); $incident->CustomFields = setCustomField("trigger_msg", $trigger_message, "STRING"); $upo = new UpdateProcessingOptions(); $upo->SuppressExternalEvents = true; $upo->SuppressRules = false; $updmsg = new UpdateMsg(); $updmsg->RNObjects = $incident; $updmsg->ProcessingOptions = $upo; $bri = new BatchRequestItem(); $bri->UpdateMsg = $updmsg; $bri->CommitAfter = "false"; $batchArr[] = $bri; //$result = $client->update($updmsg); } // end foreach if(count($batchArr) > 0) { $batchChunks = array_chunk($batchArr,90); foreach($batchChunks as $batch){ $result = $client->Batch($batch); } } } //end if result if (file_exists($logfile)) { $fh = fopen($logfile, "a"); fputs($fh, sprintf("[%s]Process Reminders %s:count=%d\n", date("Y-m-d H:i:s"),$trigger_message ,count($batchArr))); fclose($fh); } } function setCustomField($cf_name, $cf_value, $cf_type) { // //set custom field - admin_last_msg // $objtype = new RNObjectType(); $objtype->TypeName = "IncidentCustomFields"; $genobj = new GenericObject(); $genobj->ObjectType = $objtype; $objtype2 = new RNObjectType(); $objtype2->TypeName = "IncidentCustomFields"; $genobj2 = new GenericObject(); $genobj2->ObjectType = $objtype2; $dv_value = new DataValue(); if($cf_type == 'DATETIME') $dv_value->DateTimeValue = $cf_value; else $dv_value->StringValue = $cf_value; $genfld_cfvalue = new GenericField(); $genfld_cfvalue->name = $cf_name; $genfld_cfvalue->dataType = $cf_type; $genfld_cfvalue->DataValue = $dv_value; $genobj2->GenericFields = $genfld_cfvalue; $dv_container = new DataValue(); $dv_container->ObjectValue = $genobj2; $genfld_cf = new GenericField(); $genfld_cf->name = 'c'; $genfld_cf->dataType = "OBJECT"; $genfld_cf->DataValue = $dv_container; $genobj->GenericFields = $genfld_cf; return $genobj; } ?>
Output for 7.0.0 - 7.2.0
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; RNObject has a deprecated constructor in /in/Kup3t on line 99 Fatal error: Uncaught Error: Class 'SoapClient' not found in /in/Kup3t:9 Stack trace: #0 {main} thrown in /in/Kup3t on line 9
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Fatal error: Class 'SoapClient' not found in /in/Kup3t on line 9
Process exited with code 255.