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...

Tuesday, November 27, 2012

Joomla admin side access restrictions

Step : 1 

//Prepare the user restriction code

$userlogin =& JFactory::getUser();
foreach($userlogin as $key=>$value)
{
  if($key=="gid")
  {
  $gid=$value;
//Get the current login user Group id
  }
}


//Add the components folder name you want to restrict in below array
$components=array(com_users, com_content, com_modules, com_installer);

//25 is User Group id. Restriction apply to this User Group.
if(addslashes(in_array($_REQUEST[option],$components) && $gid=="25" )
{
  $mainframe->redirect( 'index.php');
}

Step : 2

Place the above code before "echo"  in [ joomla/administrator/index.php ]


Saturday, November 24, 2012

JavaScript using onload replace ID, Class and Attributes


//Must replace the red colored text 

<script type="text/javascript">
function replaceSrc()
{

    var a= document.getElementsByTagName('TagName');

    for(var i = 0; i < a.length; i++)
    {
        var link= a[i];

        if(link.AttributesName == 'SearchValue')
        {
            link.AttributesName= 'ReplaceValue';
        }
    }
}

window.onload = replaceSrc();
</script>

//Demo code for Replace <a> Title attribute.


<script type="text/javascript">
function replaceSrc()
{

    var a= document.getElementsByTagName('a');

    for(var i = 0; i < a.length; i++)
    {
        var link= a[i];

        if(link.title == 'Publish')
        {
            link.title = 'Active';
        }
    }
}

window.onload = replaceSrc();
</script>

Friday, November 23, 2012

Add/Create New Joomla User using Custom code


Place the below code  in your component files and must change the red colored values 

jimport('joomla.user.helper');

$row1->username ='Username';
$row1->name=$row1->username;
$row1->email='Email';
$password = 'Password';
$salt = JUserHelper::genRandomPassword(32);
$crypt = JUserHelper::getCryptedPassword($password, $salt);
$row1->password= $crypt.':'.$salt;
$row1->usertype='Registered';
$row1->block='0';
$row1->sendEmail='0';
$row1->registerDate=date("m-d-Y");
$row1->gid='18';

$db =& JFactory::getDBO();

 $query = "INSERT INTO #__users (name, username, email, password, usertype, block, sendEmail, gid, registerDate, lastvisitDate, activation, params) VALUES
('$row1->name', '$row1->username', '$row1->email', '$row1->password', '$row1->usertype', $row1->block, $row1->sendEmail, $row1->gid, $row1->registerDate, '', '', 'language=en-GB\ntimezone=-6\n\n')";
$db->setQuery($query);
$db->query();

$primid=$db->insertid();
 $query = "INSERT INTO jos_core_acl_aro (section_value, value, name)
 VALUES('users','$primid','$row1->name')";
 $db->setQuery($query);
$db->query();

$primid=$db->insertid();
$query = "INSERT INTO jos_core_acl_groups_aro_map (group_id, aro_id)
 VALUES($row1->gid,'$primid')";
$db->setQuery($query);
$db->query();

Add Jpanel to Joomla administrator or site


Step:1
Add the below code to you component view page 
(administrator/components/your-component/view/your-view/tmpl/defaul.php)

<?php

JHTML::_('behavior.tooltip');
jimport('joomla.html.pane');

$pane = &JPane::getInstance('sliders', array('allowAllClose' => true));
//sliders (or) tabs

echo $pane->startPane("menu-pane");

echo $pane->startPanel(JText :: _('Slider1 Title'), "param-page");
echo 'slider1 content here';
echo $pane->endPanel();

echo $pane->startPanel(JText :: _('Slider1 Title'), "param-page");
echo 'slider2 content here';
echo $pane->endPanel();

echo $pane->endPane();

?>

Saturday, October 27, 2012

Prestashop get Cookie value (or) Cart value


Step: 1
Create a new file in home directory named as "get_cookie.php"

Step: 2
Add the Below code to "get_cookie.php"

<?php
require_once dirname(__FILE__) . '/config/config.inc.php' ;
require_once(dirname(__FILE__) . '/config/settings.inc.php');
require_once dirname(__FILE__) . '/init.php' ;

function getAllCookies(){
global $cookie ;
// var_dump($cookie);
return $cookie;
}

$cookies = getAllCookies();

$query = "SELECT p.id_product,pp.id_category_default, pl.name, p.quantity, pp.price, p.id_product_attribute, pp.price * cu.conversion_rate AS orderprice, cu.sign, cu.format FROM ps_cart c
LEFT JOIN ps_cart_product p ON (p.id_cart = c.id_cart)
LEFT JOIN ps_product pp ON (pp.id_product = p.id_product)
LEFT JOIN ps_product_lang pl ON (pl.id_product = p.id_product)
LEFT JOIN ps_currency cu ON (cu.id_currency = c.id_currency)

WHERE c.id_cart = " . (int) $cookies->id_cart . " AND pl.id_lang = 1
ORDER BY p.date_add ASC";


$link1 = mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);

if ($link1) {
$db_selecteds = @mysql_select_db(_DB_NAME_, $link1);
$ress = mysql_query($query);
$arrProductss = array();
$sd=0;
while ($rows = mysql_fetch_assoc($ress)) {
 $arrProducts[] = $rows;
 print_r($arrProducts[$sd]);
  $sd++;
}

var_dump($arrProducts); // all products from session cart
}
mysql_close($link1);
?>

Step: 3
Add some product to your website cart. Then Access the get_cookie.php in your browser
"www.yoursite.com/get_cookie.php". It so the product information

Display Product Next/Prev Link in Hikashop


Step:1

Open the file: components/com_hikashop/views/product/tmpl/show_default.php

Step:2 Add the below code to "show_default.php" 

<?php
$prev_itemlink = $this->links->previous;
$next_itemlink = $this->links->next;

echo "<a title='Previous product' style=\"text-decoration:none;\" href='".$prev_itemlink."'>< Previous item</a>";

echo "<a title='Next product' style=\"text-decoration:none;\" href='".$next_itemlink."'>Next item ></a>";

?>

Friday, August 10, 2012

Joomla 2.5 Lightbox Tell a Friend Module [Free]

Feature of Popup Tell a Friend Module
1. Open in Lightbox
2. Change Lightbox width, height, and style
3. Share the current page link


Click to Download [File >>> Download]

Thursday, August 9, 2012

Chronoform dynamic field with validation [Demo Code]

Easy way to add dynamic field validation to chronoform 

<script type="text/javascript">
 function addfieldcat() {
 var comcat= jq("select[name=ComCategory]").val();
if(comcat=="Animation") {
jq('.comcat_ani').toggle({display: 'block'});
 jq('.comcat_arc').css({display: 'none'});
 jq('.comcat_man').css({display: 'none'});
}
 if(comcat=="Manufacturing") {
jq('.comcat_man').toggle({display: 'block'});
jq('.comcat_ani').css({display: 'none'});
jq('.comcat_arc').css({display: 'none'});
}
 if(comcat=="Architecture") {
 jq('.comcat_arc').toggle({display: 'block'});
 jq('.comcat_ani').css({display: 'none'});
 jq('.comcat_man').css({display: 'none'});
 }
if(comcat=="Please Select")
{
jq('.comcat_ani').css({display: 'none'});
jq('.comcat_man').css({display: 'none'});
 jq('.comcat_arc').css({display: 'none'});
 }
 }
 </script>

<div style="background:#fff;color:#000; padding:100px;">
<div style="" id="autoID-ec36e458c4ffaca305dc9310e8acf92c_container_div" class="ccms_form_element cfdiv_select"><label>Competition category : </label><select  name="ComCategory" container_id="0" title="" class="validate['required']" onchange="addfieldcat();" size="1" >
<option value="">Please Select</option>
<option value="Animation">Animation</option>
<option value="Manufacturing">Manufacturing</option>
<option value="Architecture">Architecture</option>
</select>
<div class="clear"></div><div id="error-message-input_select_39"></div></div>



<div class="comcat_ani" style="display:none;">
<div style="" id="autoID-5c2e6f2a9946f83772d6d63d9a774efd_container_div" class="ccms_form_element cfdiv_text"><label>Youtube URL 1 :</label><input type="text" name="YoutubeURL1" value="" container_id="0" title="" class="step2" size="30" maxlength="150">
<div class="clear"></div><div id="error-message-YoutubeURL"></div></div>
</div>

<div class="comcat_man" style="display:none;">
<div style="" id="autoID-5c2e6f2a9946f83772d6d63d9a774efd_container_div" class="ccms_form_element cfdiv_text"><label>Youtube URL 2 :</label><input type="text" name="YoutubeURL2" value="" container_id="0" title="" class="step2" size="30" maxlength="150">
<div class="clear"></div><div id="error-message-YoutubeURL"></div></div>
</div>

<div class="comcat_arc" style="display:none;">
<div style="" id="autoID-5c2e6f2a9946f83772d6d63d9a774efd_container_div" class="ccms_form_element cfdiv_text"><label>Youtube URL 3 :</label><input type="text" name="YoutubeURL3" value="" container_id="0" title="" class="step2" size="30" maxlength="150">
<div class="clear"></div><div id="error-message-YoutubeURL"></div></div>
</div>
<input name="input_submit_11" class="" value="Submit" type="submit" container_id="0">
</div>

Joomla Multilanguage login redirect issue [solved]

Step:1
Open the file: home directory/components/com_users/controllers/user.php

Step:2
Search the below code near line:61

// Perform the log in.
if (true === $app->login($credentials, $options)) {
// Success
$app->setUserState('users.login.form.data', array());
$app->redirect(JRoute::_($app->getUserState('users.login.form.return'), false));
} else {
// Login failed !
$data['remember'] = (int)$options['remember'];
$app->setUserState('users.login.form.data', $data);
$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
}

Step:3
After login  redirect to Home page and same language

$reu=JRequest::getVar('lang', '', 'get', 'lang');
$app->redirect('index.php?lang='.$reu);

Replace the below line with above code

$app->redirect(JRoute::_($app->getUserState('users.login.form.return'), false));


Joomla redirect after login [Custom Url]


Step:1
Open the file: home directory/components/com_users/controllers/user.php


Step:2
Search the below code near line:61

// Perform the log in.
if (true === $app->login($credentials, $options)) {
// Success
$app->setUserState('users.login.form.data', array());
$app->redirect(JRoute::_($app->getUserState('users.login.form.return'), false));
} else {
// Login failed !
$data['remember'] = (int)$options['remember'];
$app->setUserState('users.login.form.data', $data);
$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
}


Step:3

After login set a Custom redirect

$app->redirect('index.php?option=com_chronocontact&chronoformname=Contact&Itemid=5&lang=en');

Replace the below line with above code

$app->redirect(JRoute::_($app->getUserState('users.login.form.return'), false));


Wednesday, August 8, 2012

Store Multi language form to mysql Database Table

1. Create New table to Store Multi language form 

-----Query to create table-----

CREATE TABLE ` TableName ` (

  `user_id` int(20) NOT NULL,
  `permissions` varchar(20) character set utf8 collate  utf8_bin default NULL,
  PRIMARY KEY  (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


2. Store Multi language form to Already Exit mysql table

1. Login to phpmyadmin
2. open the site database
3. Select Structure tab [Right side menu]

4. It show the list of cell in the table
5. Click the Check All link [Bottom of the listed cell ]
6. Click Change icon [right side to the check all link]
7. Change the all Collation column value to uft8_bin then click save [bottom]

Thursday, August 2, 2012

Joomla redirect after email activation

[Note: Tested in Joomla 2.5]
Step:1
Open the file: home directory/components/com_users/controllers/registration.php


Step:2
Search the below code near line:68


if ($useractivation == 0)
{
$this->setMessage(JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS'));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
}
elseif ($useractivation == 1)
{
$this->setMessage(JText::_('COM_USERS_REGISTRATION_ACTIVATE_SUCCESS'));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
}
elseif ($return->getParam('activate'))
{
$this->setMessage(JText::_('COM_USERS_REGISTRATION_VERIFY_SUCCESS'));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
}
else
{
$this->setMessage(JText::_('COM_USERS_REGISTRATION_ADMINACTIVATE_SUCCESS'));
$this->setRedirect(JRoute::_('index.php?option=com_users&view=registration&layout=complete', false));
}

Step:3

After email activation. set Custom redirect to home page

$this->setRedirect('index.php');

Replace the below line with above code

$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));



Monday, July 23, 2012

Multilanguage site in Joomla 2.5 [Install Steps]


Multilanguage site in joomla

Step by step Joomla configuration for Easy Language plugin :

1. Install language packs for your site front end.
(Extensions >>> Extension Manager)

2. Install easy language plugin.
(Extensions >>>  Extension Manager)

3. Enable required plugins and modules.
(Extensions  >>>  Plugin Manager)
Enable : System - Easy Language
Enable : System - Language Filter
(Extensions >>>  Module manager)
Enable : Language Switcher (and publish it to become visible in front page)

4. For languages to appear in Language Switcher on front page,
you must create dummy unpublished menu for EVERY language you want to use.

This is example how to add dummy menu item for English language,
so english language will be available as choice in Language Switcher.
(You should repeat it for every other language you want to add)

(Menus  >>>  Menu manager  >>>   add new menu)
Title : englishmenu (give a name which tell its your languagemenu)
Menu type : englishmenu (give a name which tell its your languagemenu)
- Press Save & Close
- Find your languagemenu in below table and click its name in "title" column.
- Click "New"
Menu Item Type : "Search Form or Search Results"
Menu Title : englishmenu
Status : Unpublished
Default Page : Yes
Language : English (select language you want to appear in Language Switcher)
- Press Save & Close
You will See Flag Appear near menu which meant this language will appear
now as a choice in Language Switcher.

Remember that this menu is unpublished and dont need to have any articles
or content in it, Its dummy menu and its only purpose is to make
related language available as a choice in Language Switcher