Tuesday, December 18, 2012

Flush drupal cache from code

Hey everyone,

Today I would like to share how to recover a blank drupal website using cache clear. Most of the times we change our websites from one server to another. In drupal when we do that our database tables and files messes the cache settings. But while this is happening in database your websites goes blank or it goes unreachable so in that case you have to run one drupal function which will help you to rebuild the registry, rebuild the menu, rebuild the path.

All you need to do is put the code either on page--front.tpl.php or on page.tpl.php.


<?php
// This will Change query-strings on css/js files to enforce reload for all users. 
  _drupal_flush_css_js(); 

  registry_rebuild();     //To rebuild module data
  drupal_clear_css_cache(); //This will flushes the cached css
  drupal_clear_js_cache(); //This will flushes the cached js
?> 


Remember that do not put this code in any if else condition just put it either on page.tpl.php or on front page of your drupal site. And then hit the URL in any browser. Then our code will get executed. Our code would then flush the js and css for all users. Then it would rebuild the registry of all modules. Then it would clear the css cache and then js cache.
So now this would defiantly bring the drupal site back on its feet. 

Thanks for reading.

Enjoy & Be Open

Saturday, June 2, 2012

copy image using wget PHP

Hello everyone,
I have just written a PHP script to wget any image.
All you need to do is get the full path of your image e.g.
http://www.google.co.in/images/srpr/logo3w.png is path to google logo.
So now lets wget google's logo.


<?php


$mainimage = "http://www.google.co.in/images/srpr/logo3w.png"; //this would be the path of your live image which you want to download

$thebasename =  basename($mainimage); //here we will get logo3w.png i.e. name of file


$filename = explode(".", $thebasename); //explode it with extention
$i=0;
do {
if($i > 0) $filename[0]++;
else $filename[0] = $filename[0].$i;
$i++;
    }while(file_exists("tmp_cover/".$filename[0].".".$filename[1])); //typical do while to check for unique file name
 $image_dir = "tmp_cover/"; //this will be your directory where you want to save your image
 $fresh_file = $filename[0].".".$filename[1]; //this is our renamed file if file already exists
 $image_drs = $image_dir.$fresh_file; //i have concatinated the path so it becomes easier to use in wget function
 system("wget -q \"$mainimage\" -O $image_drs");  //image uploaded with wget -q


 /*
 Notes:
 1)Please check if your wget version is wget v1.12 and php is php v5.3.1 or greater.
 2)Give full permissions to your files (chmod 777 your_dir) or use filezilla client to give full permission to your folder.
 3)I have created tmp_cover folder at /opt/lampp/htdocs with 777 permissions.
/*

?>

Wednesday, March 28, 2012

see the webpage in 3d with firefox 11.0

Hello guys,
I just saw the brand new firefox which is 11.0 for windows. It is really the performance browser.
If you install the new firebug it will allow you to view any webpage in 3d mode. Just right click on webpage and select Inspect Element. After that you will see the new firebug bar at the bottom of your page then click on the 3d button which is at the right bottom. Now you are in 3d mode.
To zoom in or zoom out just use control + mouse scroll or to view from different angle just press control key + left mouse key + move the mouse pointer.

Here are some of the screenshots in 3d mode of my blog.





I think new firebug is kinda cool and really advance. There are lots of new features in it.


Enjoy & be open.
long live linux.

Wednesday, March 14, 2012

How to install xampp on ubuntu

Hello Everyone,
Today we will learn how to install xampp in ubuntu.

1) Simply wget it with this command at terminal
wget http://www.apachefriends.org/download.php?xampp-linux-1.7.3a.tar.gz
I hope you are logged in with root.

2) After downloading the xampp you can cd to desktop with this command
cd Desktop Now you are at the Desktop.

3) Enter this command to install xampp in ubuntu
tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt 

4) Now your xampp is installed in opt folder. Now in order to create files and folders in htdocs you need to resolve the htdocs trouble. to give permession to htdocs enter this command sudo chmod 777 -R /opt/lampp/htdocs/ 

5) Now if everything is fine with no error then it is time to star the xampp in order to start the xampp please enter this command sudo /opt/lampp/lampp start 

6) So here are some important command to operate xampp from terminal
     i) To stop xampp sudo /opt/lampp/lampp stop
    ii) To restart xampp sudo /opt/lampp/lampp restart 


Now your xampp is installed all you need to do is start working. If you are getting any error while migrating the projects you can always check the error logs.

If you have any problem just mail me


Enjoy & be open.
long live linux.

Thursday, February 16, 2012

Download Linux system monitor

Hello All,

Are you looking for a good system monitor? Then I think conky is the best option. It is very lightweight application. Conky can display this info either as text, or using simple progress bars and graph widgets, with different fonts and colours. To install conky on ubuntu use this command sudo apt-get install conky

After installing conky you can run it from ubuntu's Run application. Press alt + f2 and then type conky Now you will see the conky application.

Here's the screenshot of my conky
























Enjoy & be open.
long live linux.

Friday, February 3, 2012

How to check error log on xampp, ubuntu

Hello all,
Many times we face some errors that we dont know the exact reasons so here is one way through which you can able to see the existing errors or previous errors.
Apache maintains error logs in error_log file which is in /opt/lampp/logs
You can open this file with your favourite text editor.



Enjoy & be open.
long live linux.

Wednesday, February 1, 2012

microsoft windows 7 vs Ubuntu
















Be smart & choose wisely 
Fore more infomarmation go here Ubuntu



Enjoy & be open.
long live linux.