This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label Uncategorized. Show all posts
Showing posts with label Uncategorized. Show all posts

Thursday, February 21, 2013

Solved: How to check if memcache or memcached is installed and running or not on Server Using PHP

After doing some R&D I figured out how to fix the issue with memcache installtion or class

many time we got the following message, If memcahed server is not running.

Memcache::connect(): Server localhost (tcp 11211) failed with: Connection refused

To fix the following issue I written the following Code

if(class_exists('Memcache') && extension_loaded('memcache') && function_exists('memcache_<div dir="ltr"><wbr />connect')) { //Checks on Server Memcache is installed or not$memcache = new Memcache();         $connection = @fsockopen('localhost', 11211); //Check port is open and forwarded using fsockopenif (is_resource($connection)) {$isMemcacheAvailable = $memcache->connect('localhost'<wbr />, 11211);             $cache->setMemcache($memcache)<wbr />;} else {error_log('Memcache Server is not running');}} else {error_log('Memcache is not installed on your Server');     }if ($isMemcacheAvailable) {$aData = $memcache->get('data');}

Above code will solve every issue.


Source : digcms[dot]com

Wednesday, February 20, 2013

Solved:codeigniter how to load library class in model

In one of model file I need to load the library class and use there methods.

After struggling I goan through some articles.
Following article I found useful:
http://ellislab.com/codeigniter/user-guide/libraries/loader.html

Assigning a Library to a different object name

If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it will be assigned to a variable named $this->session.

If you prefer to set your own class names you can pass its value to the third parameter: $this->load->library(‘session’, ”, ‘my_session’);

// Session class is now accessed using:

$this->my_session

After this I loaded the Library using following code.

$this->CI = & get_instance();$this->CI->load->library( 'LIB_NAME', '', 'LIB_NAMEInstance' );$RESULT = $this->CI->LIB_NAMEInstance-><wbr />FUNCTION_NAME($PASS_PARAMS);

Source : digcms[dot]com

Saturday, February 16, 2013

Solved:codeigniter how to load library class in model

In one of model file I need to load the library class and use there methods.

After struggling I goan through some articles.
Following article I found useful:
http://ellislab.com/codeigniter/user-guide/libraries/loader.html

Assigning a Library to a different object name

If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it will be assigned to a variable named $this->session.

If you prefer to set your own class names you can pass its value to the third parameter: $this->load->library(‘session’, ”, ‘my_session’);

// Session class is now accessed using:

$this->my_session

After this I loaded the Library using following code.

$this->CI = & get_instance();$this->CI->load->library( 'LIB_NAME', '', 'LIB_NAMEInstance' );$RESULT = $this->CI->LIB_NAMEInstance-><wbr />FUNCTION_NAME($PASS_PARAMS);

Source : digcms[dot]com

Wednesday, February 13, 2013

PHP background process with Gearman :how to use

What is Gearman?

Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages. It can be used in a variety of applications, from high-availability web sites to the transport of database replication events. In other words, it is the nervous system for how distributed processing communicates. A few strong points about Gearman:

Open Source – It’s free! (in both meanings of the word) Gearman has an active open source community that is easy to get involved with if you need help or want to contribute.
Multi-language – There are interfaces for a number of languages, and this list is growing. You also have the option to write heterogeneous applications with clients submitting work in one language and workers performing that work in another.
Flexible – You are not tied to any specific design pattern. You can quickly put together distributed applications using any model you choose, one of those options being Map/Reduce.
Fast – Gearman has a simple protocol and interface with a new optimized server in C to minimize your application overhead.
Embeddable – Since Gearman is fast and lightweight, it is great for applications of all sizes. It is also easy to introduce into existing applications with minimal overhead.
No single point of failure – Gearman can not only help scale systems, but can do it in a fault tolerant way.

For more information read following:
http://php.net/manual/en/book.gearman.php

For installing gearman use following commands.
#yum install gearmand
#yum install php-pecl-gearman

For starting the gearman deamon use following command.
#gearmand -vvvv

For Checking the gearman services use following commands (Gearman Admin Commands.)
#gearadmin –workers
#gearadmin –status

We recommend to Use:
GearmanManager- https://github.com/brianlmoon/GearmanManager

Why use GearmanManager

Running Gearman workers can be a tedious task. Many many files with the same lines of code over and over for creating a worker, connecting to a server, adding functions to the worker, etc. etc. The aim of GearmanManager is to make running workers more of an operational task and less of a development task.

The basic idea is that once deployed, all you need to do is write the code that actually does the work and not all the repetative worker setup. We do this by creating files that contain functions in a specified directory. The file names determine what functions are registered with the gearmand server. This greatly simplifies the function registration.


Source : digcms[dot]com

Best images of bob marley in 2013

Bob Marley is my Favorite Singer. I collected some wallpapers of Bob Marley,.


Source : digcms[dot]com

Monday, January 28, 2013

how to take filesystem and mysql backup on shared hosting

Many people are using the shared hosting for hosting there site. When you want to take filesystem and mysql backup with zip format.

You can use my script. Create two php files and upload to server. Following script will compress your files and able to take mysql backup in gzip format. Before this create phpinfo.php file and add following code.

<?phpphpinfo();?>Get your server's "DOCUMENT_ROOT " and use in command variable.create backup.php file and add following lines.1<?php$Command = 'tar -czf /home/content/html/website.tgz /home/content/html';exec($Command, $output, $result);if($result > 0) {echo 'Command not executed. ';echo 'Error Details:'.$output;} else {echo 'Command executed sucesfully.';}?>

create mysqlbackup.php  file and add following lines.

<?php$Command = 'mysqldump -udbusername -pdbpassword -hyour_database_hostname databasename | gzip > databasename.gz';exec($Command, $output, $result);if($result > 0) {echo 'Command not executed. ';echo 'Error Details:'.$output;} else {echo 'Command executed sucesfully.';}?>

Source : digcms[dot]com

Wednesday, December 26, 2012

How to Create Symfony project on linux box

install symfony on linux box
pear channel-discover pear.symfony-project.com
pear install symfony/symfony

Create
#mkdir -p lib/vendor
cd lib/vendor
$wget http://pear.symfony-project.com/get/symfony-1.4.20.tgz
$ tar zxpf symfony-1.4.20.tgz
$ mv symfony-1.4.20 symfony
$ rm symfony-1.4.20.tgz
$ php lib/vendor/symfony/data/bin/symfony generate:project solrtest

php symfony configure:database “mysql:host=localhost;dbname=symfony” root password
php symfony generate:app frontend

./symfony lucene:initialize frontend
./symfony lucene:create-solr-config frontend

./symfony lucene:service frontend stop
./symfony lucene:service frontend start

add entry in hosts
127.0.0.1    symfony.digcms.com

Add entry in httpd.conf
#symfony.digcms.com
<VirtualHost *:80>
ServerAdmin digcms@test.com
Servername symfony.digcms.com

DocumentRoot “/var/www/html/phptest/sfproject/web”
DirectoryIndex index.php
<Directory “/var/www/html/phptest/sfproject/web”>
AllowOverride All
Allow from All
</Directory>

Alias /sf /var/www/html/phptest/sfproject/lib/vendor/symfony/data/web/sf
<Directory “/var/www/html/phptest/sfproject/lib/vendor/symfony/data/web/sf”>
AllowOverride All
Allow from All
</Directory>
</VirtualHost>


Source : digcms[dot]com

Sunday, November 18, 2012

Find geolocation in mobile browser (android, iphone, blackberry)

You can find the latitude and longitude using jquery mobile js library.

Using following code you can get the latitude and longitude.

Add following script in your document

<script type=”text/javascript” src=”http://code.jquery.com/jquery-1.4.3.min.js”></script>;
<script type=”text/javascript” src=”http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js”></script>;
Then use the following code for

$(document).ready(function() {if (navigator.geolocation) {navigator.geolocation.getCurrentPosition(success, error);} else {error('Geolocation not supported');}});function success(position) {var latt = position.coords.latitudevar long = position.coords.longitude}

I created full example with fetching the city, state, country and region data.

Here is example.

<!DOCTYPE html><html><head><title>My Location</title><link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css"; /><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>;<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>;<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>;<script type="text/javascript">var geocoder;$(document).ready(function() {geocoder = new google.maps.Geocoder();if (navigator.geolocation) {navigator.geolocation.getCurrentPosition(success, error);} else {error('Geolocation not supported');}});function success(position) {var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);geocoder.geocode({'latLng': latlng}, function(results, status) {for (var ik = 0; ik < results[0].address_components.length; ik++) {var addr = results[0].address_components[ik];var getCountry;var getlocality;var getpostal_code;var getState;var getstreet_address;var getcity;var getadministrative_area_level_2;var getadministrative_area_level_3;if (addr.types[0] == 'country')getCountry = addr.long_name;if (addr.types[0] == 'locality')getlocality = addr.long_name; //Cityif (addr.types[0] == 'postal_code')getpostal_code = addr.long_name;if (addr.types[0] == 'administrative_area_level_1')getState = addr.short_name; //Stateif (addr.types[0] == 'street_address')getstreet_address = addr.long_name;if (addr.types[0] == 'sublocality')getcity = addr.long_name; //under City - city sublevelif (addr.types[0] == 'administrative_area_level_2')getadministrative_area_level_2 = addr.long_name; //city levelif (addr.types[0] == 'administrative_area_level_3')getadministrative_area_level_3 = addr.long_name; //sub city level}//alert(getlocality);});var myOptions = {zoom: 15,center: latlng,mapTypeControl: false,navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},mapTypeId: google.maps.MapTypeId.ROADMAP};var mapcanvas = $('#mapcanvas');var map = new google.maps.Map(mapcanvas[0], myOptions);var marker = new google.maps.Marker({position: latlng,map: map,title:"I am here!"});}function error(msg) {var errMsg = typeof msg == 'string' ? msg : "Geolocation failed";$('#msg').html(errMsg);}</script></head><body><div data-role="page"><div data-role="header"><h1>My Location</h1></div><div data-role="content"><input id="findme" type="button" value="Find Me" /><div id="msg"></div><div id="mapcanvas" style="height: 400px; width: 560px;"></div></div></div></body></html>

Incoming search terms:


Source : digcms[dot]com