Showing posts with label joomla. Show all posts
Showing posts with label joomla. Show all posts

Wednesday 4 May 2016

Convert PHP, Magento, Joomla, Codeigniter, Cake PHP, Wordpress XML to JSON, XML to Array, JSON to Array

Convert PHP, Magento, Joomla, Codeigniter, Cake PHP, Wordpress XML to JSON, XML to Array, JSON to Array is very difficult task for some people. But, in PHP, believe me it’s very easy. One line of code each! Don’t believe? Just check out the code below and test it yourself!


$xml = simplexml_load_string($xmldata);
$json = json_encode($xml);
$array = json_decode($json,true);

Monday 18 April 2016

How to get user ip in PHP/Codeigniter

$_SERVER['REMOTE_ADDR'] may not actually contain real client IP addresses, as it will give you a proxy address for clients connected through a proxy, for example. That may well be what you really want, though, depending what your doing with the IPs. Someone's private RFC1918 address may not do you any good if you're say, trying to see where your traffic is originating from, or remembering what IP the user last connected from, where the public IP of the proxy or NAT gateway might be the more appropriate to store.

There are several HTTP headers like X-Forwarded-For which may or may not be set by various proxies. The problem is that those are merely HTTP headers which can be set by anyone. There's no guarantee about their content. $_SERVER['REMOTE_ADDR'] is the actual physical IP address that the web server received the connection from and that the response will be sent to. Anything else is just arbitrary and voluntary information. There's only one scenario in which you can trust this information: you are controlling the proxy that sets this header. Meaning only if you know 100% where and how the header was set should you heed it for anything of importance.

For Codeigniter


$this->input->ip_address();

For PHP

if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}
echo $ip;

Thursday 27 August 2015

Redirect all urls exactly, just change domain name

How to change domain using htaccess file

Many times we have a in CMS and Ecommerce website to change the domain due to maintenance or other reason but the main headache is the suburl (categories or collection) should be work as it is other wise we need to write the 301 url redirect for each and every url to not get the SEO errors.
This is tutorial will be help for the following CMS :
  1. wordpress development
  2. Joomal development
  3. Drupal development
There are Ecommerce platform that get help from this
  1. Magento development
  2. Opencart development
  3. Woocommerce
  4. Virtumart
So here is the simple and easy option that will work using the add the few lines in the htaccess file (if file not available create it .htaccess).


RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)domain\.com$ [NC]
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [L,R=301]

Saturday 26 May 2012

Get URL With Id ex : id="1500" in Joomla

JRequest::getVar

<?php $itemid = JRequest::getVar('Itemid');
if($itemid == '50')
{
    echo '<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>';

}
?>