Image Caption

Monday, March 18, 2013

Soap response to php array


//Php Explode is best way to convert the soap response to PHP array

function soaptoarray($response)
{

$search  = array('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','<soapenv:Header/','<soapenv:Body','</', '<');
$replace = array(' ',' ',' ','@end@', '*start*');
$customer=str_replace($search, $replace, $response);
$soapres =explode('*start*',$customer);

foreach($soapres as $key=>$value)
{
$res[$key]=$value;
$temp=explode('@end@',$value);
$tempval=explode('>',$temp[0]);
$tmp=explode("State",$tempval[0]);
}

$resp{$tempval[0]}=$tempval[1];

}

return $resp;
}


//Output php array similar to:


Array
(
    [ ] =>  
    [p711:getDeviceResponse xmlns:p711="http://provision.xbridge.com"] => 
    [getDeviceResult] => 
    [Status Code="0" Message="Done"/] => 
    [Device Id="B0112121" Phone="12312312331" Serial="8901410423121235279"] => 
    [DeviceStatus] => Deactivated
    [State Code="0" Name="Deactivated"/] => 
    [Network Id="1" Name="AT&T" Type="Gold"/] => 
    [Customer] => 00001238
    [Contract Description="FRED SEIFU" Id="43124" Name="FREDS121"/] => 
    [LLI] => B011218
    [APN] => gp102.mo122.net
    [ICCID] => 89022103423295536629
    [MSISDN] => 512233212
    [IMSI] => 310423343553527
    [PIN1] => 1111
    [PUK1] => 412129385
    [PIN2] => 2222
    [PUK2] => 2222
)



Thursday, February 14, 2013

Joomla mass email with attachments [Demo Code]


Step: 1 Create the form 

<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
 <input type="text"   name="emailid" id="emailid"  />
 <input type="text"   name="subject" id="subject"  />
 <input type="text"   name="message" id="message"  />
 <input type="file"   name="attachment" id="attachment"  />
</form>

Step: 2 Get the form value and Call the mail function

$recipient  = JRequest::getVar('emailid', '', 'post', 'string', JREQUEST_ALLOWRAW);
$subject  = JRequest::getVar('subject', '', 'post', 'string', JREQUEST_ALLOWRAW);
$body  = JRequest::getVar('message', '', 'post', 'string', JREQUEST_ALLOWRAW);
$attachment = JRequest::getVar('attachment', null, 'files', 'array');
$attachmentname=$attachment[name];
jimport( 'joomla.utilities.utility' );
JUtility::sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment, $attachmentname, $replyto=null, $replytoname=null);


Step: 3 Replace the function "addAttachment" in libraries/joomla/mail.php

function addAttachment($attachment, $name = '')
{
// If the file attachments is an aray, add each file... otherwise just add the one
if (isset ($attachment))
{
if (is_array($attachment)) {
foreach ($attachment as $file) {
parent::AddAttachment($file, $name);
}
}
else
{
parent::AddAttachment($attachment, $name);
}
}
}

Step: 4 Replace the below code in ( libraries\joomla\utilities\utility.php ) line 44

function sendMail($from, $fromname, $recipient, $subject, $body, $mode=0, $cc=null, $bcc=null, $attachment=null,$attachmentname, $replyto=null, $replytoname=null )

Saturday, February 9, 2013

Chronoform - You are not allowed to access this URL directly, POST array is empty [Solved]

This issue occurred due to some users access site with and without "www" site url 

Check Form action url:
<form name="ChronoContact_Renewal" id="ChronoContact_Renewal" method="post" action="http://website.com/index.php?option=com_chronocontact&task=send&chronoformname=ExamApply&Itemid=119" >

Default Form action url:
http://website.com/index.php?option=com_chronocontact&task=send&chronoformname=ExamApply&Itemid=119


Need to change the Form action url:
index.php?option=com_chronocontact&task=send&chronoformname=ExamApply&Itemid=119

Place the above url in 
Chronoform >>> Forms Managements >>> General  >>> Form submit url

<form name="ChronoContact_Renewal" id="ChronoContact_Renewal" method="post" action="index.php?option=com_chronocontact&task=send&chronoformname=ExamApply&Itemid=119" >




Friday, February 8, 2013

iPhone/iPad Website Icon image and Title


Add the code to head tag

Icon Image:
<link rel="apple-touch-icon" href="images/favicon.png"/>

Icon Text:
<meta name="apple-mobile-web-app-title" content="Site Title">

Thursday, February 7, 2013

Get Radio Button Value in JavaScript

Get Radio Button Value in JavaScript
<script>

function getvalue() {
    var radios = document.getElementsByName("test");

    for (var i = 0; i < radios.length; i++) {      
        if (radios[i].checked) {
            alert(radios[i].value);
            break;
        }
    }
}
</script>
<input type="radio" name="test" value="first" onclick="getvalue();">
<input type="radio" name="test" value="second" onclick="getvalue();">

Logout link for Joomla 1.5, 2.5 and 3.0

[Note: Tested in Joomla 1.5, 2.5, 3.1.5]

Joomla 1.5 Logout Link

<?php
$returnURL = base64_encode(JURI::root() . "");
$user =& JFactory::getUser();
echo 'Hi,'.$user->username;
?>
<a href="index.php?option=com_user&task=logout&return=<?php echo $returnURL; ?>">
<input  type="button" name="Submit" class="button" value="Logout"></a>

Joomla 2.5 Logout Link


<a href="index.php?option=com_users&task=user.logout&<?php echo JUtility::getToken(); ?>=1">
<input  type="button" name="Submit" class="button" value="Logout">
</a>


Joomla 3.1 Logout Link

//JUtility::getToken() has been removed in Joomla 3.0. Use JSession::getFormToken() instead.

<a href="index.php?option=com_users&task=user.logout&<?php echo JSession::getFormToken(); ?>=1">
<input  type="button" name="Submit" class="button" value="Logout">
</a>


Friday, February 1, 2013

Site is down just for me [Solved]

You think your ISP has blocked a website from you. please follow the below step to unblock the site.

Step:1

Install the spotflux to your PC. Click here to download SpotFlux

Step: 2

Spotflux >>> Setting >>> Proxies[Tab] >>> Auto detect proxy setting >>> ok

Step:3

Then check the Blocked website in your browser...