Black iD is changing

18.10.2008 | Author:Black iD Team

Hi,

With our growth, we feel that we have had a kinda stale look now. We are working on a new design. Our new site would be something like this…

Black iD Solutions New Website Design

I hope you all like what we have done… Do comment us up to let us know if you like the new layout!

Thanks in advance…
Black iD Solutions Admin

PHP cURL?

7.06.2008 | Author:Black iD Team

Lately, I have been doing a lot of gimmicks with various things related to sending and receiving data over web pages in the back end, i.e. without the user actually browsing or sending data. I have done quite some research on the subject. I did find some noteworthy things. cURL was the first method that I came accross. Like most of the php guys would do, I jumped on to it. Used cURL for some applications I was developing. These applications required a lot of web page openings.

Now, as most of you experienced users might be knowing, or for the newbies, I found that, many of my scripts, the timed out. And my shared host, at gohindi dot com, that idiot, suspended my account for nothing. He said, he couldn’t take the load of the scripts. So, my site hung up in a stupid suspended page (Sorry guys, you might have missed me :)).

So, I started looking for other options. Changing to a dedicated or a VPS was out of option, as it proved to be too costly. So I decided to change the technology. What I found was fsock was the next best option. Though not pirticularly easy to use, it was something that was useful. Then, this brilliant idea struck me. I explored, file_get_contents function of PHP. It did solve my problem, as long as I didnt have to post any data. So I stuck with it. It was fun. I could get the things done in an instant. And it was pretty safe and easy too.

$google = file_get_contents(”http://www.google.com”);

Thus in a single line statement I could do what required a few lines in fsock as well as cURL. This was a nice method, but had its limitations. I couldn’t post data to these sites. So, I decided to come up with a class. This would surely make an ease. This class is useful for the newbies. It is called pageFetcher. So, ladies and gentlemen, here I present to you,

pageFetcher

Host Change

24.05.2008 | Author:Black iD Team

Hello Friends,

We are glad that we are on a new host. Our old host gohindi.com has proved to be a jerk. They are a shared hosting, and believe me, he suspended my “wordpress” site, saying that the server could not take the load of so many sites. Now this is crazy. He hosts 1000 sites on a single server and then says he wont be able to host it for me. He doesn’t pay me back. This is all crap. Gohindi.com is a complete crap. I would recommend all you hosting on gohindi.com to stop it, because if your site gets traffic, which is why you have put it there, the host is going to ban you. I dont know why this cheap hosting has a page rank of 6. But it is all crap, and believe me, it surely is.

Hope you guys dont fall in the pit as i did.

Thanks

Jyot Vakharia
Black iD Team

Javascript OO Menus Updating

19.03.2008 | Author:Black iD Team

Hello Friends,

We are currently working on a newer version of the javascript menus. We are updating them to be more robust and enjoyable. We will be adding more and more functionalities very soon… So hang on a while.

Thanks

Black iD Labs Team

Content Rewriter Pro

3.02.2008 | Author:Black iD Team

Content Rewriter Pro, a service started by Black iD Solutions to help you rewrite content on the fly. Please go to http://www.rewritecontentonline.com to know more about the Content Rewriter Pro! We have launched this service to provide rewritten content on the fly! Get the most of our content rewriting services.

Content - It drives the forces on the web.

31.01.2008 | Author:Black iD Team

Hi friends,

Here I am to ponder over a small topic, that most of us, in present scenario are tending to forget. Why have we gathered here? What brings you to this post? Why is there internet at all?

The answers to these questions are simple. But, nevertheless, we keep on forgetting them. The internet was created, solely with a purpose of sharing information. Now, with more and more content coming up, and the value of “Information” shooting beyond any bounds, we realize the importance of creation of fresh content. Content has been something that most of the websites are looking for, but alas, not all web developers are well versed with content creation skills.

Well for such web developers, I would advice you to check out different sites that are rich in content. Maybe stir up some article directories like http://www.resourcecity.info, http://www.articlemarketer.com and so on. This is an easy way to collect fresh content. But, remember, rewriting this content is absolutely essential. Duplicate content takes your site into the secondary source list, and this is not good for your rankings. Remember, be innovative and good at rewriting. Look for solutions to rewrite your content.

All the best.

CSS Hacks

14.01.2008 | Author:Black iD Team

Here is the brief list of CSS Hacks. I will be writing more on CSS hacks soon. But this is one of the most regularly used features by me. So i would rather have it stored than search for it everytime :)

E 6 and below
* html {}
IE 7 and below
*:first-child+html {} * html {}
IE 7 only
*:first-child+html {}
IE 7 and modern browsers only
html>body {}
Modern browsers only (not IE 7)
html>/**/body {}
Recent Opera versions 9 and below
html:first-child {}

For now, you can use these as a simple CSS hacks. I will be adding many more hacks later on. These are actually for my colleages to refer when I am not there, but I thought it might as well help you all also. Do remember to bookmark this topic and visit it regularly for updates on new CSS hack techniques. Also coming soon is a way to apply hack without w3c konwing it :)

Finally Coming out with PHP Products

14.01.2008 | Author:Black iD Team

Well,

Finally the wait is over. Black iD is into the final testing of the class we have been working on for the last 6 months. We are running it through the phpDocumentor and trying to make the best for you all. The next releases have been planned already. We will be fully supporting the current release in the next one. So we hope you enjoy this class a lot. The code for this class is available here. We will try to expand this class even more.

Another excellent news is that we are now registered as the developers at PEAR website. We are proud to be supporting a community that has worked so hard thus far to keep up the spirits high. We will try to contribute in each way we can to come up with the best pieces of code. For now please accept this beautiful piece of code

<?php
/* =====================================================================================================================

	MySQL DATABASE ACCESS CLASS
		--> WRITTEN BY JYOT VAKHARIA. [Black iD Solutions(www.blackidsolutions.com)].
		--> Open Source GPL Lisence.
		--> VERSION 1.1 Release 1

		New
			--> Added the insert Method.
			--> Reduced the number of loops to make the class process faster and improve
				upon speed when database size is large.
			-->
===================================================================================================================== */

	class db
		{
			var $uname, $pass, $host, $db, $conn, $con_db;

			/* USEAGE : $db->connect('host','username','password','databasename');
						OR
						$db->connect(array('host','username','password','databasename'));
						OF
						$db->connect(array('host' => 'hostname', 'uname' => 'username', 'pass'=>'password', 'db'=>'db_name'));
			*/
			function connect()
				{
					$args = func_get_args();
					if(is_array($args[0]))
						$args = $args[0];
					if(!($this->uname) || !($this->host) || !($this->db))
						{
							// LOOK OUT FOR CONNECTION SETTINGS IF NOT DEFINED
							$this->host = $args['host'];
							$this->uname = $args['uname'];
							$this->pass = $args['pass'];
							$this->db = $args['db'];
						}
					if(!($this->uname) || !($this->host) || !($this->db))
						{
							// LOOK OUT FOR CONNECTION SETTINGS IF NOT DEFINED
							$this->host = $args[0];
							$this->uname = $args[1];
							$this->pass = $args[2];
							$this->db = $args[3];
						}
					$this->conn = mysql_connect($this->host,$this->uname, $this->pass) or die("Could not connect to the databae");
					$this->conn_db = mysql_select_db($this->db) or die("Could not select the database with the name " . $this->db);
					return $this->conn_db;
				}

			// USAGE $db->query($sql);
			// RETURNS THE RESULTANT DATASET.
			function query($sql)
				{
					return mysql_query($sql);
				}

			// USAGE $db->getFieldsFor('table');
			// RETURNS THE field name list as an array.
			function getFieldsFor($tablename)
				{
					$sql = "Select * From $tablename LIMIT 1";
					$fld = $this->getFieldsForSQL($sql);
					return $fld;
				}
			// USAGE $db->getFieldsForSQL("Select * from foo where bar='foo'");
			// RETURNS THE field name list as an array.
			function getFieldsForSQL($sql)
				{
					$db =  $this->query($sql);
					$i = 0;
					while($i < @mysql_num_fields($db))
						{
							$fld[] = mysql_field_name($db, $i);
							$i++;
						}
					mysql_free_result($db);
					return $fld;
				}
			// USAGE $db->table_array_from_tablename('table');
			// RETURNS THE aray containing the entire table as an array.
			// You can sort it as you like. It is currently keyed array.
			// To get a pirticular field use $tbl = $db->table_array_from_tablename('table'); $fld = $dbl[rowno]['fldname'];
			function table_array_from_tablename($tablename, $conds="1")
				{
					$sql = "Select * from $tablename WHERE $conds";
					$table = $this->table_array_from_sql($sql);
					return $table;
				}

			// USAGE $db->table_array_from_sql('Select * from tablename');
			// RETURNS THE aray containing the entire table as an array.
			// You can sort it as you like. It is currently keyed array.
			// To get a pirticular field use $tbl = $db->table_array_from_sql('table'); $fld = $dbl[rowno]['fldname'];
			function table_array_from_sql($sql)
				{
					$db = $this->query($sql);
					$flds = $this->getFieldsForSQL($sql);
					while($row = mysql_fetch_array($db,1))
						{
							$table[] = $row;
						}
					return $table;
				}
			function table_row_from_tablename($tablename, $conds="1")
				{
					$sql = "Select * from $tablename WHERE $conds";
					$table = $this->table_array_from_sql($sql);
					return $table[0];
				}

			// USAGE $db->table_array_from_sql('Select * from tablename');
			// RETURNS THE aray containing the entire table as an array.
			// You can sort it as you like. It is currently keyed array.
			// To get a pirticular field use $tbl = $db->table_array_from_sql('table'); $fld = $dbl[rowno]['fldname'];
			function table_row_from_sql($sql)
				{
					$row = $this->table_array_from_sql($sql);
					return $row[0];
				}

			function field_val_from_table($table, $field_name, $crit_field, $crit_val)
				{
					$sql = "Select $field_name from $table where $crit_field='$crit_val'";
					$res = $this->field_val_from_sql($sql);
					return $res;
				}
			function field_val_from_sql($sql)
				{
					$res = mysql_fetch_array($this->query($sql));
					return $res[0];
				}
			function flat_field_array($table, $field_name, $cond = " WHERE 1")
				{
					$sql = "SELECT $field_name FROM $table $cond";
					$res = $this->query($sql);
					while($row = mysql_fetch_array($res))
						{
							$arr[] = $row[$field_name];
						}
					return $arr;
				}

			function field_associative_array_from_table($tablename,$condition = "1",$fld_key,$fld_val,$val_seperator="-")
				{
					$tbl = $this->table_array_from_sql("SELECT $fld_key, $fld_val FROM $tablename WHERE $condition");
					$flds = explode(",",$fld_val);
					error_reporting(0);
					foreach($tbl as $row)
						{
							foreach($flds as $fld)
								{
									$row_val .= ($row_val!="") ? " $val_seperator {$row[$fld]}" : $row[$fld] ;
								}
							$retval[$row[$fld_key]] = $row_val;
							$row_val = "";
						}
					error_reporting(1);
					return $retval;
				}
			////////////////////////// USAGE /////////////////////////////////////////////
			//			$db->insert("tablename","field1=value1","field2=value2",...);   //
			//		$db->insert("tablename",array("field1=value1","field2=value2",...));//
			//		$db->insert("tablename","field1=value1;field2=value2;...");         //
			//////////////////////////////////////////////////////////////////////////////
			function insert()
				{
					$args = func_get_args();
					$first_arg = $args[0];
					if(!(is_array($first_arg)))
						$first_arg = split(";", $first_arg);
					$table = $first_arg[0];
					$opts = $first_arg[1];
					$opts = split(":",$opts);
					$ret_fld = $opts[1];
					$field_list = $this->getFieldsFor($table);
					if(is_array($args[1]))
						{
							$args = $args[1];
						}
					elseif(count($args) == 2)
						{
							$args = split(";", $args[1]);
						}
					else
						{
							$args = array_splice($args,1);
							foreach($args as $arg)
								{
									$temp_arg = split("=",$arg);
									$args2[$temp_arg[0]] = $temp_arg[1];
								}
							$args = $args2;
						}
					$flds = "";
					$vals = "";
					if(array_keys($args))
						{
							foreach($args as $fld=>$val)
								{
									if(in_array($fld,$field_list) && (!($_FILES['$fld']['name'])))
										{
									if(is_array($val))
										$val = join(";", $val);
									$flds .= $flds ? ","."`".$fld."`" : "`".$fld."`";
									$vals .= $vals ? ",'".$val."'" : "'".$val."'";
										}
								}
						}
					else
						{
							foreach($args as $arg)
								{
									$temp_arg = split("=",$arg);
									$fld = "`".$temp_arg[0]."`";
									if(in_array($fld,$field_list) && (!($_FILES['$fld']['name'])))
										{
									$val = str_replace("'","",$temp_arg[1]);
									$flds .= $flds ? ",".$fld : $fld;
									$vals .= $vals ? ",'".$val."'" : "'".$val."'";
										}
								}
						}
					$sql = "INSERT INTO $table ($flds) VALUES ($vals)";
					$this->query($sql);
					if(mysql_error())
						{
							return -1;
						}
					elseif($ret_fld)
						{
							$ret_sql = "Select " . str_replace("return","",str_replace("_","",$opts[0]))."($ret_fld) from $table";
							$ret_val = $this->field_val_from_sql($ret_sql);
							return $ret_val;
						}
				}

		////////////////////////// USAGE /////////////////////////////////////////////
			//			$db->update("tablename","updating condition","field1=value1","field2=value2",...);   //
			//		$db->update("tablename","updating condition",array("field1=value1","field2=value2",...));//
			//		$db->update("tablename","updating condition","field1=value1;field2=value2;...");         //
			//////////////////////////////////////////////////////////////////////////////
				function update()
				{
					$args = func_get_args();
					$first_arg = $args[0];
					$condition = $args[1];
					if(!(is_array($first_arg)))
						$first_arg = split(";", $first_arg);
					$table = $first_arg[0];
					$opts = $first_arg[1];
					$opts = split(":",$opts);
					$ret_fld = $opts[1];
					$field_list = $this->getFieldsFor($table);

					if(is_array($args[2]))
						{
							$args = $args[2];
						}
					elseif(count($args) == 2)
						{
							$args = split(";", $args[1]);
						}
					else
						{
							$args = array_splice($args,1);
							foreach($args as $arg)
								{
									$temp_arg = split("=",$arg);
									$args2[$temp_arg[0]] = $temp_arg[1];
								}
							$args = $args2;
						}
					$flds = "";
					$vals = "";
					if(array_keys($args))
						{
							foreach($args as $fld=>$val)
								{
									if(in_array($fld,$field_list) && (!($_FILES['$fld']['name'])))
										{
											if(is_array($val))
												$val = join(";", $val);
											$query .= ($query ? "," : "")."`$fld`='$val'";
										}

								}
						}
					else
						{
							foreach($args as $arg)
								{
									$temp_arg = split("=",$arg);
									$fld = $temp_arg[0];
									if(in_array($fld,$field_list) && (!($_FILES['$fld']['name'])))
										{

											$val = str_replace("'","",$temp_arg[1]);
		//									$flds .= $flds ? ",".$fld : $fld;
											$query .= ($query ? "," : "")."`$fld`='".addslashes($val)."'";
		//									$vals .= $vals ? ",'".$val."'" : "'".$val."'";
										}
								}
						}
					$sql = "UPDATE $table SET $query where $condition";
					$this->query($sql);
					echo mysql_error();
					if($ret_fld)
						{
							//$ret_sql = "Select " . str_replace("return","",str_replace("_","",$opts[0]))."($ret_fld) from $table";
							//$ret_val = $this->field_val_from_sql($ret_sql);
							//return $ret_val;
						}
				}

			// Function to replace a pirticular string in each row in all fields of the table.
		   	// created by binson  asif

	         function replace_string_in_entire_table($tablename,$fields,$existing_string,$replace_string)
			 {

			 		$flds= $this->getFieldsForSQL("SELECT $fields from $tablename");
					echo mysql_error();
					foreach($flds as $fld)
					{
						$sql="update $tablename set $fld = replace ($fld, '$existing_string', '$replace_string')";
						mysql_query($sql);
					}

			  		return mysql_error();
			 }

		}
?>

IP2Country

2.10.2007 | Author:Black iD Team

Hello PHP Developers,

One more innovation from Black iD Solutions. We are developing an IP2Country database. I know this is a very common application. But our target users are those PHP developers who find it difficult to get the IP information for their users. For eg. If you wanted to know the country from the ipaddress, you would have to do either of the 2.

1. Buy a costly subscription from some of the sites
2. Download the entire IP2Country Database from

But now we have come up with a way you can easily get an access of the country information from the IP Address. The method is simple.

<?php
$f = fopen( "http://scripts.blackidsolutions.com/ip2country/?ip=202.186.13.4&get=country","r");
$country = fread($f,40); // Additional reading capability to ensure the country's name is not cut
echo $country; // Displays MALASIA
?>

By using the simple code you can get the country of visitor from the IP address. I will be publishing more information on this too. To get the 2 letter country code simply replace “&get=country” with “&get=ctry“. Also to get the 3 letter country code you can replace it by “cntry”.

Hope this helps.

Thanks

Jyot

Simple Dropdown Menu Example…

2.10.2007 | Author:Black iD Team

Hope you liked this effect.

You can get the source files below:

Simple Dropdown Source Files

Do leave a comment below so as to how you liked the navigations.

Thanks

Jyot