Turn off Gmail ads or web clips

Gmail by default shows ads also called web clips above the list of emails. It’s easy to switch these off but they’re not intuitively named when looking at Gmail’s settings. This post shows how to switch them off.

To remove the web clips, click the settings cog icon above-right from the message list. This will show a drop down menu where you can select the Settings option.

On the next page along the top of the settings are a series of tabs/options. Open the Web Clips tab and uncheck the Show my web clips above the Inbox checkbox. You don’t need to click a button to save, it immediately takes effect.

Now go back to your inbox and there are no longer any ads above the message list.

MYSQL next increment value or last inserted value

Getting the next auto increment value and last inserted value from a mysql table are both two different things and should not be confused with one another. Next increment value should be the next id to be inserted and last inserted value is the last id inserted. Sometimes I see programmers using former code to get the latter task done and vice-versa. That might do it in some cases, but in the long run will surely fail.

Correct way of getting the value of next to be inserted id, is:

$query_autoinc 		= "SHOW TABLE STATUS LIKE 'table'";
$exec_autoinc 		= mysql_query($query_autoinc);
$row_autoinc 		= mysql_fetch_assoc($exec_autoinc);
$next_insert_id 	= $row_autoinc['Auto_increment'];
Continue reading “MYSQL next increment value or last inserted value”

PHP N-level menu using recursion with DB structure

Recently I needed to come up with a code that would help me create a n-level menu and breadcrumb for that. So for that I wrote this code which works with great ease and provides huge flexibility. Also I kept it really low so that it is easy to embedded it in any kind of design. This is just the half part of my code which prints the menu.

Function:

$table	= 'menu';

/**
 * The showMenu() function prints the menu with all its sub menus
 * @params:	$ulclass  common class to be applied in ul elements
		$liclass  common class to be applied in li elements
		$father   Father of each child menu. Pass '0' to print complete menu.
 * return:	string
 */
function showMenu($ulclass, $liclass, $father) {
	$showmenu_query = "select * from $table where menu_father='" . $father . "' order by menu_order";
	$exec_showmenu = mysql_query($showmenu_query);

	if ( !$exec_showmenu) {
		echo "Query failed. Check your query. Error Returned: " . mysql_error();
		return false;
	}

	$toAppend = '<ul class="' . $ulclass . '">';

	while ($row_showmenu = mysql_fetch_assoc($exec_showmenu)) {
		$toAppend.= '<li class="' . $liclass . ' &nbsp; '. $row_showmenu['menu_class'] . '">';
		$toAppend.= '<a href="' . stripslashes($row_showmenu['menu_slug']) . '">' . stripslashes($row_showmenu['menu_name']);
		$toAppend.= '</a>';

		$submenu_query = "select * from $table where menu_father='" . $row_showmenu['menu_id'] . "'";
		$exec_submenu = mysql_query($submenu_query);

		if (mysql_num_rows($exec_submenu)>0 ) {
			$toAppend.= $showMenu($ulclass, $liclass, $row_showmenu['menu_id']);
		}

		$toAppend.= '</li>';
	}

	$toAppend.= '</ul>';
	return $toAppend;
}
Continue reading “PHP N-level menu using recursion with DB structure”

Concatenate PDF in PHP

As requirement for one of my projects, I needed to concatenate multipe PDF files provided by the user into just one file.

To achieve this, we need the TCPDF and FPDI libraries.

Class to concatenate pdf, Pdf_concat.class.php:

require_once('./includes/tcpdf/config/lang/eng.php');
require_once('./includes/tcpdf/tcpdf.php');
require_once('./includes/fpdi/fpdi.php');

class Pdf_concat extends FPDI {
     var $files = array();
	 
     function setFiles($files) {
          $this->files = $files;
     }
	 
     function concat() {
          foreach($this->files AS $file) {
               $pagecount = $this->setSourceFile($file);
               for ($i = 1; $i <= $pagecount; $i++) {
                    $tplidx = $this->ImportPage($i);
                    $s = $this->getTemplatesize($tplidx);
                    $this->AddPage('P', array($s['w'], $s['h']));
                    $this->useTemplate($tplidx);
               }
          }
     }
}

Usage:

Continue reading “Concatenate PDF in PHP”

HACKERTEST.NET | Level 17: Too easy!

Level 17 is really simple. Just open the source code and you will find how to get the password for this level. You will see something like this in the source code; Password: your IP address, yes this is it.

IP stands for internet protocol address. Every connection has one of its own. You can check your by googling or visiting any of these given sites.
– http://whatismyipaddress.com/
– http://www.ip2location.com/

Continue reading “HACKERTEST.NET | Level 17: Too easy!”