<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>glamanate - php, mysql, jquery, and the web.</title>
	
	<link>http://glamanate.com</link>
	<description>web dev/design</description>
	<lastBuildDate>Sun, 22 Jan 2012 18:13:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Glamanate" /><feedburner:info uri="glamanate" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Simple PHP Calendar Script</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/eAzFng3a0o4/</link>
		<comments>http://glamanate.com/2012/01/simple-php-calendar-script/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 18:13:07 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=251</guid>
		<description><![CDATA[Here is a simple PHP calendar script that can be easily customized and designed with CSS. &#60;?php $time = time(); $numDay = date(&#039;d&#039;, $time); $numMonth = date(&#039;m&#039;, $time); $strMonth = date(&#039;F&#039;, $time); $numYear = date(&#039;Y&#039;, $time); $firstDay = mktime(0,0,0,$numMonth,1,$numYear); $daysInMonth = cal_days_in_month(0, $numMonth, $numYear); $dayOfWeek = date(&#039;w&#039;, $firstDay); ?&#62; &#60;table&#62; &#60;caption&#62;&#60;? echo($strMonth); ?&#62;&#60;/caption&#62; &#60;thead&#62; &#60;tr&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple PHP calendar script that can be easily customized and designed with CSS.<span id="more-251"></span></p>
<pre class="brush: php; gutter: true">&lt;?php

$time = time();

$numDay = date(&#039;d&#039;, $time);
$numMonth = date(&#039;m&#039;, $time);
$strMonth = date(&#039;F&#039;, $time);
$numYear = date(&#039;Y&#039;, $time);
$firstDay = mktime(0,0,0,$numMonth,1,$numYear);
$daysInMonth = cal_days_in_month(0, $numMonth, $numYear);
$dayOfWeek = date(&#039;w&#039;, $firstDay);
?&gt;
&lt;table&gt;
&lt;caption&gt;&lt;? echo($strMonth); ?&gt;&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
	&lt;th abbr=&quot;Sunday&quot; scope=&quot;col&quot; title=&quot;Sunday&quot;&gt;S&lt;/th&gt;
	&lt;th abbr=&quot;Monday&quot; scope=&quot;col&quot; title=&quot;Monday&quot;&gt;M&lt;/th&gt;
	&lt;th abbr=&quot;Tuesday&quot; scope=&quot;col&quot; title=&quot;Tuesday&quot;&gt;T&lt;/th&gt;
	&lt;th abbr=&quot;Wednesday&quot; scope=&quot;col&quot; title=&quot;Wednesday&quot;&gt;W&lt;/th&gt;
	&lt;th abbr=&quot;Thursday&quot; scope=&quot;col&quot; title=&quot;Thursday&quot;&gt;T&lt;/th&gt;
	&lt;th abbr=&quot;Friday&quot; scope=&quot;col&quot; title=&quot;Friday&quot;&gt;F&lt;/th&gt;
	&lt;th abbr=&quot;Saturday&quot; scope=&quot;col&quot; title=&quot;Saturday&quot;&gt;S&lt;/th&gt;

&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;?
if(0 != $dayOfWeek) { echo(&#039;&lt;td colspan=&quot;&#039;.$dayOfWeek.&#039;&quot;&gt; &lt;/td&gt;&#039;); }
for($i=1;$i&lt;=$daysInMonth;$i++) {

	if($i == $numDay) { echo(&#039;&lt;td id=&quot;today&quot;&gt;&#039;); } else { echo(&quot;&lt;td&gt;&quot;); }
	echo($i);
	echo(&quot;&lt;/td&gt;&quot;);
	if(date(&#039;w&#039;, mktime(0,0,0,$numMonth, $i, $numYear)) == 6) {
		echo(&quot;&lt;/tr&gt;&lt;tr&gt;&quot;);
	}
}
?&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;</pre>

<p><a href="http://feedads.g.doubleclick.net/~a/QlzwbeaX9Ajpnh_HnXoDmgfnydM/0/da"><img src="http://feedads.g.doubleclick.net/~a/QlzwbeaX9Ajpnh_HnXoDmgfnydM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/QlzwbeaX9Ajpnh_HnXoDmgfnydM/1/da"><img src="http://feedads.g.doubleclick.net/~a/QlzwbeaX9Ajpnh_HnXoDmgfnydM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/eAzFng3a0o4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2012/01/simple-php-calendar-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2012/01/simple-php-calendar-script/</feedburner:origLink></item>
		<item>
		<title>Bootstrap from Twitter</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/3ALjYRVcoFQ/</link>
		<comments>http://glamanate.com/2011/12/bootstrap-twitter/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 13:50:45 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=239</guid>
		<description><![CDATA[Need to do a quick web site but strapped for time? Twitter has a whole bunch of open source projects they have released, and one of them is called Bootstrap. It comes preloaded with CSS styles and simple JavaScript plugins. I&#8217;d have to say the best part about it is the predefined layouts, or the ability to [...]]]></description>
			<content:encoded><![CDATA[<p>Need to do a quick web site but strapped for time? Twitter has a whole bunch of open source projects they have released, <a title="Bootstrap, from Twitter" href="http://twitter.github.com/bootstrap/" target="_blank">and one of them is called Bootstrap</a>. It comes preloaded with CSS styles and simple JavaScript plugins. I&#8217;d have to say the best part about it is the predefined layouts, or the ability to make them even faster.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/aVnpt7iZtXAvVo7UDYkAq2RdUNM/0/da"><img src="http://feedads.g.doubleclick.net/~a/aVnpt7iZtXAvVo7UDYkAq2RdUNM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/aVnpt7iZtXAvVo7UDYkAq2RdUNM/1/da"><img src="http://feedads.g.doubleclick.net/~a/aVnpt7iZtXAvVo7UDYkAq2RdUNM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/3ALjYRVcoFQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/12/bootstrap-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/12/bootstrap-twitter/</feedburner:origLink></item>
		<item>
		<title>jQuery Rating Script</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/Q7wutQdg7-o/</link>
		<comments>http://glamanate.com/2011/12/jquery-rating-script/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 17:00:09 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=231</guid>
		<description><![CDATA[For KenoBarNight I just added a simple rating system mocking that of YouTube and others; a simple &#8220;I Like It&#8221; or &#8220;I Don&#8217;t Like It&#8221;. Use whatever verbage you&#8217;d like, that is what this script does. The user clicks one of the buttons, and the script POSTs the data to a PHP script which saves [...]]]></description>
			<content:encoded><![CDATA[<p>For KenoBarNight I just added a simple rating system mocking that of YouTube and others; a simple &#8220;I Like It&#8221; or &#8220;I Don&#8217;t Like It&#8221;. Use whatever verbage you&#8217;d like, that is what this script does. The user clicks one of the buttons, and the script POSTs the data to a PHP script which saves a MySQL entry so we can do some math later and find a rating.<span id="more-231"></span></p>
<p>Usually I&#8217;d show the jQuery script first, but this time I&#8217;m detailing the PHP callback script.</p>
<pre class="brush: php; gutter: true">&lt;?php
//You'll need a MySQL conn
require('mysql.php');

//You need to make sure that a rating AND item ID were sent to the script
if(isset($_POST['rate'])  &amp;&amp; isset($_POST['id'])) {

	//Declare 'em
	$rating = $_POST['rate'];
	$bar_id = $_POST['id'];
	$ip_addr = $_SERVER['REMOTE_ADDR'];

	//Check if the IP address has all ready voted, deny if he or she has.
	$check_result = mysql_query('SELECT id FROM ratings WHERE item_id = "'.$bar_id.'" AND ip_addr = "'.$ip_addr.'"');
	if(!mysql_num_rows($check_result)){

		//All clear, insert into MySQL, if insert fails, don't echo; if insert succeed echo true
		$sql = mysql_query('INSERT INTO ratings SET item_id = "'.$bar_id.'", ip_addr = "'.$ip_addr.'", weight = "'.$rating.'"');
		if(!$sql) {
			//echo 'false';
		} else {
			echo 'true';
		}
	} else{
		//echo 'false';
	}
}
?&gt;</pre>
<p>This will insert a new row into our &#8216;ratings&#8217; table which can be used to calculate an items rating. You could, if you wanted, just make &#8216;rating&#8217; a new field on your MySQL table and have each button click +1 or -1 the value, but there is no way to prevent abuse from a specific IP address.</p>
<p>Now for the front-end mix of PHP and jQuery to get your rating system up.</p>
<pre class="brush: actionscript3; gutter: true">&lt;span class="thanks" style="display:none"&gt;Thanks for rating!&lt;/span&gt;
&lt;a class="awesome"&gt;Awesome&lt;/a&gt;
&lt;a class="sucks"&gt;Not For Me.&lt;/a&gt;</pre>
<p>These are the two buttons. Put them where ever, do what you need just be sure to place the following jQuery script anywhere after.</p>
<pre class="brush: php; gutter: true">&lt;?php
	//This script assumes you have pulled the item data from the MySQL and the data is a var called row which is an array

	$ip_addr = $_SERVER['REMOTE_ADDR'];
	$check_result = mysql_query('SELECT id FROM ratings WHERE item_id = "'.$row['id'].'" AND ip_addr = "'.$ip_addr.'"');
	if(mysql_num_rows($check_result) &gt; 0){	?&gt;

			&lt;script&gt;
				$('.thanks').show();
				$('.awesome').hide();
				$('.sucks').hide();
			&lt;/script&gt;

	&lt;?php } ?&gt;
	&lt;script&gt;
		$('.awesome').click( function() {

		$.post("rate_callback.php", {rate: 1, item: "&lt;?php echo $row['id'] ?&gt;"}, function(data){
		if(data.length &gt;0) {
			$('.thanks').show();
			$('.awesome').hide();
			$('.sucks').hide();
		} else {
			//Well they rated all ready so don't do anything, they shouldn't even have gotten this far.
		}
		});							

		});

		$('.sucks').click( function() {
				$('.thanks').show();
				$('.awesome').hide();
				$('.sucks').hide();

		});

		&lt;/script&gt;</pre>
<p>And that&#8217;s it! The script checks to see if the user&#8217;s IP address has rated the item before, if it has jQuery hides the rate buttons and shows the &#8220;Thanks&#8221; message. I originally built this within a <em>while()</em> statement, if  anyone needs the script modified or needs to know how I did it, just drop a comment.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/LmMIGTmomrVXKM4wTOGPWOAWJIw/0/da"><img src="http://feedads.g.doubleclick.net/~a/LmMIGTmomrVXKM4wTOGPWOAWJIw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/LmMIGTmomrVXKM4wTOGPWOAWJIw/1/da"><img src="http://feedads.g.doubleclick.net/~a/LmMIGTmomrVXKM4wTOGPWOAWJIw/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/Q7wutQdg7-o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/12/jquery-rating-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/12/jquery-rating-script/</feedburner:origLink></item>
		<item>
		<title>Achievements – Winning the Internet</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/ilDFtCM1CMI/</link>
		<comments>http://glamanate.com/2011/12/achievements-winning-internet/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 13:51:48 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=228</guid>
		<description><![CDATA[Achievements seem to be popping up in every new web service. Why? Because achievements make you win the Internet. Okay, not really, but it does make your user feel more engaged into your web site. It gives the user a reason to use your site and do more things on your site. The best part [...]]]></description>
			<content:encoded><![CDATA[<p>Achievements seem to be popping up in every new web service. Why? Because achievements make you win the Internet. Okay, not really, but it does make your user feel more engaged into your web site. It gives the user a reason to use your site and do more things on your site. The best part is the achievements do not even need to be all that difficult. Really the hardest part about implementing an achievement system into your web site is finding a good graphic designer to whip up some images.<span id="more-228"></span></p>
<p>Here is a breakdown on how other sites user achievements and ways you can implement achievements into your site</p>
<ul>
<li><strong>Kongregate</strong> is a Flash game portal with an achievement API developers can tap into. Users sign up, play games, win achievements within different Flash games and earn badges. Each badge is worth so many points and the more points you earn the higher level your account becomes. Kongregate even links certain achievements to GameStop rewards for real-life bonuses.</li>
<li><strong>GetGlue </strong>is a social &#8220;check-in&#8221; service based around what you are watching or reading. GetGlue is essentially a great marketing plug for television networks, movie company&#8217;s, and book publishers. GetGlue calls it&#8217;s achievements &#8220;stickers&#8221;, which you earn by checking into a show, movie, or book so many times or on a certain day. For example, if you check into a television show on the airing of a new show, chances are you&#8217;ll earn a sticker to show off you &#8220;were there.&#8221;</li>
<li><strong>Foursquare </strong>is another social &#8220;check-in&#8221; based based around where you are; are you at Starbucks? Or are you at Chili&#8217;s? You earn points by checking in which helps you beat friends in a weekly &#8220;battle&#8221; to see who received the most points.  Achievement&#8217;s on Foursquare range from when you check-in to a certain place (like a bar at 2am) or with a lot of people (swarm badge I believe is 150 people) or by adding a &#8220;shout&#8221; to your check-in (adding &#8220;it&#8217;s a boy&#8221; in a hospital is one achievement.)</li>
<li><strong>Klout </strong>is a service that puts a number to your social influence. In this example, Klout isn&#8217;t an engaging social service per se, but provides achievements to user activity. If you visit the site for a few days in a row, you&#8217;re awarded. If you try out all the different features, you&#8217;re rewarded. As your score goes up, you earn achievements.</li>
</ul>
<div>I&#8217;m sure there are tons of other examples on badges being used in web sites, I think MySpace even adopted some. But, as you can see, achievements are a way to help engage your users into your web site.</div>

<p><a href="http://feedads.g.doubleclick.net/~a/Ani0Q8xy_pEfa-Qpr5iYZ82GxjY/0/da"><img src="http://feedads.g.doubleclick.net/~a/Ani0Q8xy_pEfa-Qpr5iYZ82GxjY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Ani0Q8xy_pEfa-Qpr5iYZ82GxjY/1/da"><img src="http://feedads.g.doubleclick.net/~a/Ani0Q8xy_pEfa-Qpr5iYZ82GxjY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/ilDFtCM1CMI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/12/achievements-winning-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/12/achievements-winning-internet/</feedburner:origLink></item>
		<item>
		<title>Awesome Google Infographic</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/VNT9u2wpz-k/</link>
		<comments>http://glamanate.com/2011/12/awesome-google-infographic/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 14:20:39 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[random]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=224</guid>
		<description><![CDATA[Over at Business MBA, I found this awesome infographic labeled &#8220;Behind the Numbers&#8221; that breaks down some information about one of the largest companies out there, Google. View the whole article to see the infographic. From: BusinessMBA.org]]></description>
			<content:encoded><![CDATA[<p>Over at Business MBA, I found this awesome infographic labeled &#8220;Behind the Numbers&#8221; that breaks down some information about one of the largest companies out there, Google. View the whole article to see the infographic.<span id="more-224"></span></p>
<p><a href="http://www.businessmba.org/google-facts/"><img class="aligncenter" src="http://www.businessmba.org/google-facts/google-numbers.jpg" alt="Google Behind The Numbers" width="500" border="0" /></a><br />
From: <a href="http://www.businessmba.org">BusinessMBA.org</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/yunE7PvXcAVjDOiErWrEkjJ_rHY/0/da"><img src="http://feedads.g.doubleclick.net/~a/yunE7PvXcAVjDOiErWrEkjJ_rHY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/yunE7PvXcAVjDOiErWrEkjJ_rHY/1/da"><img src="http://feedads.g.doubleclick.net/~a/yunE7PvXcAVjDOiErWrEkjJ_rHY/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/VNT9u2wpz-k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/12/awesome-google-infographic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/12/awesome-google-infographic/</feedburner:origLink></item>
		<item>
		<title>Tips for Google Maps and Mobile</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/hTHXBC4ujj0/</link>
		<comments>http://glamanate.com/2011/11/tips-google-maps-mobile/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 03:55:23 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=220</guid>
		<description><![CDATA[When developing web applications it is always wise to use the most up to date APIs and know when to scale back on certain functionality.  Google just posted a blog entry stating four mobile web app tips when using Google Maps. Basically it runs down to use API v3, Static API usage, StreetView Images, and [...]]]></description>
			<content:encoded><![CDATA[<p>When developing web applications it is always wise to use the most up to date APIs and know when to scale back on certain functionality. <a title="Google Mobile Web App Tips" href="http://googlegeodevelopers.blogspot.com/2011/11/four-tips-for-improving-your-mobile-web.html?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+blogspot%2FGkaos+%28Google+Geo+Developers+Blog%29" target="_blank"> Google just posted a blog entry</a> stating four mobile web app tips when using Google Maps. Basically it runs down to use API v3, Static API usage, StreetView Images, and JS Map usage.</p>
<p><span id="more-220"></span>On my<a title="Kenosha Bar Night" href="http://kenobarnight.com" target="_blank"> Kenosha Bar Night</a> project, I use a JS Google Map to provide a visual of all the bars listed. However, when you view a bar&#8217;s listing I only use a static Google Map to demonstrate it&#8217;s location while using less resources.  That is just for the regular desktop version. For the mobile site I only use static maps to shorten render speeds and provide compatibility. Yes, the market is full of smartphones but not all have the same features, certain aspects of the JS Google Maps may not be supported.  You can still place markers on static maps to illustrate your locations.</p>
<p><a title="StreetView Image API" href="http://code.google.com/apis/maps/documentation/streetview/index.html" target="_blank">Integrate the StreetView Image API</a> to help your visitors get an understanding of the locations surroundings instead of providing the interactive map when it isn&#8217;t needed.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/18OtFdpagWfirvKipH-cgSNwy-E/0/da"><img src="http://feedads.g.doubleclick.net/~a/18OtFdpagWfirvKipH-cgSNwy-E/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/18OtFdpagWfirvKipH-cgSNwy-E/1/da"><img src="http://feedads.g.doubleclick.net/~a/18OtFdpagWfirvKipH-cgSNwy-E/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/hTHXBC4ujj0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/11/tips-google-maps-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/11/tips-google-maps-mobile/</feedburner:origLink></item>
		<item>
		<title>Mobile Geolocation</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/qqXFo08BPIA/</link>
		<comments>http://glamanate.com/2011/11/mobile-geolocation/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 15:30:21 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=214</guid>
		<description><![CDATA[With the new wave of mobile devices being a major way to access the Internet, it has become possible to customize web applications based on a user&#8217;s location &#8211; or create web applications based on user location. This example will show you how to get a user&#8217;s location, pull up a static Google Map, and [...]]]></description>
			<content:encoded><![CDATA[<p>With the new wave of mobile devices being a major way to access the Internet, it has become possible to customize web applications based on a user&#8217;s location &#8211; or create web applications based on user location. This example will show you how to get a user&#8217;s location, pull up a static Google Map, and the query a database for locations within one mile of the user&#8217;s location.<span id="more-214"></span></p>
<p><a href="http://www.w3.org/TR/geolocation-API/">W3C released a Geolocation API</a>, which is what browser&#8217;s use to get geolocation information.</p>
<pre class="brush: javascript; gutter: true">&lt;script type="text/javascript"&gt;

//Do we support geolocation

if (navigator.geolocation) {

    //Get the location, requires callback functions for it's parameters
    navigator.geolocation.getCurrentPosition(displayPosition, errorFunction);
} else {
    alert('It seems like Geolocation, which is required for this page, is not enabled in your browser. Please use a browser which supports it.');
}

// Success callback function
function displayPosition(pos) {
    var lat = pos.coords.latitude;
    var lng = pos.coords.longitude;

    //We'll place the code for getting database data here and more.
}

// Error callback function
function errorFunction(pos) {
    alert('Error!');
}
&lt;/script&gt;</pre>
<p>We invoke <em>getCurrentPosition</em> with two callback functions, one on success and one on error.  In the <em>displayFunction</em> we declare the latitude and longitude variables. This function is also where we will put the code to grab locations from the database. Since PHP is a server-side language and JavaScript a client-side language we cannot put PHP within our JavaScript. We&#8217;ll have a different file for the PHP script and grab its contents using some JavaScript. Luckily, there is jQuery and the process is a lot simpler. Place this code within the <em>displayFunction</em>.</p>
<pre class="brush: javascript; gutter: true">//Be sure to add jQuery to your site! Or it won't work
&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;

//Uses jQuery to send an HTTP POST, then grabs the return data.
$.post("library/mobile_callback.php", {lat: ""+mylat+"", lng: ""+mylong+"", dst: 1 }, function(data){
		if(data.length &gt;0) {
					$('#locations').html(data);
		}
	});</pre>
<p>The code uses HTTP POST to send our parameters to the PHP script and will return an HTML unordered list that will be placed into the <em>div</em> field with the id of <em>locations.  </em>The PHP script access a database table which has the fields <em>id, name, lat, lng</em>. It takes the POST parameters and queries up to 20 results.</p>
<p>&nbsp;</p>
<pre class="brush: php; gutter: true">&lt;? require('mysql.php'); 

	//Need to have Latitude and Longitude
	if($_POST["lat"] &amp;&amp; $_POST["lng"]) {

		//Declare variables, make sure we have a distance
		$lat = $_POST['lat'];
		$lng = $_POST['lng'];
		$dst = (empty($_POST['dst']) ? 1 : $_POST['dst'];

		//The query. I did a search for the math equation, this is first one I found from a math site.
		$sql = 'SELECT *, ( 3959 * acos( cos( radians('.$lat.') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('.$lng.') ) + sin( radians('.$lat.') ) * sin( radians( lat ) ) ) ) AS distance
FROM locations HAVING distance &lt; '.$dst.' ORDER BY distance';

		echo '&lt;ul id="locations_list"&gt;';

		$result = mysql_query($sql);
			while($row = mysql_fetch_array($result)) {
				echo '&lt;li&gt;'.$row['name'].'&lt;/a&gt;&lt;/li&gt;';
			}

		echo '&lt;/ul&gt;';
	}
?&gt;</pre>
<p>And that&#8217;s it! If you want to add a Google Map, just add this code in the <em>displayFunction</em>, for myself I put it under the <em>$.post()</em> call.</p>
<pre class="brush: javascript; gutter: true">	 var gCoords = lat + ', ' + long;
	 var gMap = '&lt;img src="http://maps.googleapis.com/maps/api/staticmap?center=' + gCoords;
	 var gMap2 = '&amp;zoom=14&amp;size=320x200&amp;markers=color:red%7Clabel:Your%20Location%7C' + gCoords + '&amp;sensor=false" /&gt;';
	$('#map_canvas').html(gMap+gMap2);</pre>

<p><a href="http://feedads.g.doubleclick.net/~a/KzkCPWFB7amrOYUMtz0UTkHvDYI/0/da"><img src="http://feedads.g.doubleclick.net/~a/KzkCPWFB7amrOYUMtz0UTkHvDYI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/KzkCPWFB7amrOYUMtz0UTkHvDYI/1/da"><img src="http://feedads.g.doubleclick.net/~a/KzkCPWFB7amrOYUMtz0UTkHvDYI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/qqXFo08BPIA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/11/mobile-geolocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/11/mobile-geolocation/</feedburner:origLink></item>
		<item>
		<title>Google+ API and Library</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/CNdFS9SD5b0/</link>
		<comments>http://glamanate.com/2011/11/google-api-library/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 14:45:46 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=212</guid>
		<description><![CDATA[Google+ has released a rough outline on their API for accessing data.  The Google+ API only allows for read-access to data, but this will still allow you to integrate a visitors social features around Google+.  API calls can either be completed via an API key or an OAuth 2.0 token for user data.The Google+ API [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Google+ API" href="https://developers.google.com/+/api/">Google+ has released a rough outline on their API for accessing data</a>.  The Google+ API only allows for read-access to data, but this will still allow you to integrate a visitors social features around Google+.  API calls can either be completed via an API key or an OAuth 2.0 token for user data.The Google+ API follows a typical REST design involving HTTP GET on many API calls and the results are in JSON format.<span id="more-212"></span>Here is an example API call and response from the web site:</p>
<p>Request</p>
<pre class="brush: html; gutter: true">GET https://www.googleapis.com/plus/v1/people/{userId}</pre>
<p>Response</p>
<pre class="brush: javascript; gutter: true">{
  "kind": "plus#person",
  "id": "118051310819094153327",
  "displayName": "Chirag Shah",
  "url": "https://plus.google.com/118051310819094153327",
  "image": {
    "url": "https://lh5.googleusercontent.com/-XnZDEoiF09Y/AAAAAAAAAAI/AAAAAAAAYCI/7fow4a2UTMU/photo.jpg"
  }
}</pre>
<p>For now the Google+ API covers People, Activites, and Commets.  Google has released Google+ API Libraries for <a title="Google+ API Downloads" href="https://developers.google.com/+/downloads" target="_blank">various languages that can be downloaded</a> along with starter scripts.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/d0eFxEe6QeR4l4PzixYRj8gLfyU/0/da"><img src="http://feedads.g.doubleclick.net/~a/d0eFxEe6QeR4l4PzixYRj8gLfyU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/d0eFxEe6QeR4l4PzixYRj8gLfyU/1/da"><img src="http://feedads.g.doubleclick.net/~a/d0eFxEe6QeR4l4PzixYRj8gLfyU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/CNdFS9SD5b0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/11/google-api-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/11/google-api-library/</feedburner:origLink></item>
		<item>
		<title>Google+ Profile and your Blog</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/yqO1i7VSoW0/</link>
		<comments>http://glamanate.com/2011/11/google-profile-blog/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 18:54:47 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web design]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=210</guid>
		<description><![CDATA[Google just made it easy to link your Google+ profile to your blog or other articles. Simply ensure to put a link to your Google+ profile with a rel=&#8221;author&#8221; tag. &#60;a rel="author" href="https://plus.google.com/101530880977549569019/" title="Google+ Profile"&#62;]]></description>
			<content:encoded><![CDATA[<p>Google just made it easy to link your Google+ profile to your blog or other articles. Simply ensure to put a link to your Google+ profile with a rel=&#8221;author&#8221; tag.</p>
<pre class="brush: html; gutter: true">&lt;a rel="author" href="https://plus.google.com/101530880977549569019/" title="Google+ Profile"&gt;</pre>

<p><a href="http://feedads.g.doubleclick.net/~a/eosP071e5sbgYV3SFEnny0k479M/0/da"><img src="http://feedads.g.doubleclick.net/~a/eosP071e5sbgYV3SFEnny0k479M/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/eosP071e5sbgYV3SFEnny0k479M/1/da"><img src="http://feedads.g.doubleclick.net/~a/eosP071e5sbgYV3SFEnny0k479M/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/yqO1i7VSoW0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/11/google-profile-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/11/google-profile-blog/</feedburner:origLink></item>
		<item>
		<title>Sanitize Text for SQL</title>
		<link>http://feedproxy.google.com/~r/Glamanate/~3/nR1uB1ogQIY/</link>
		<comments>http://glamanate.com/2011/11/sanitize-text-mysql/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 16:19:47 +0000</pubDate>
		<dc:creator>mglaman</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://glamanate.com/?p=200</guid>
		<description><![CDATA[Cross Site Scripting (XSS) and SQL Injections are some of the biggest security threats to a PHP application.  Every developer has different ways of preventing SQL Injections or malicious JavaScript from being inserted into the database. Here are some easy solutions to help safeguard your PHP applications. mysql_real_escape_string() mysql_real_escape_string() should always be used on data [...]]]></description>
			<content:encoded><![CDATA[<p>Cross Site Scripting (XSS) and SQL Injections are some of the biggest security threats to a PHP application.  Every developer has different ways of preventing SQL Injections or malicious JavaScript from being inserted into the database. Here are some easy solutions to help safeguard your PHP applications.<span id="more-200"></span></p>
<h3>mysql_real_escape_string()</h3>
<blockquote><p><a href="http://php.net/manual/en/function.mysql-real-escape-string.php" target="_blank">mysql_real_escape_string()</a> should always be used on data being placed into your SQL database.  The function places backslashes before certain characters. That means if someone tried to insert an apostrophe ( &#8216; ) into your SQL a backslash would be added ( \&#8217; )  so the apostrophe would be recognized as a character, not part of the script.</p>
<pre class="brush: php; gutter: false">$input = 'I'll be darned, this would have broke it.';
$data = mysql_real_escape_string($input);</pre>
</blockquote>
<h3>htmlentities()</h3>
<blockquote><p><a href="http://us2.php.net/manual/en/function.htmlentities.php" target="_blank">htmlentities()</a> is one of my best friends. I learned about XSS early when I was a developer when a hacker posted JavaScript into a field and was able to snatch my admin cookie and deface my site. See, mysql_real_escape_string() may prevent SQL Injections but not XSS. htmlentities() will convert characters to their html entities. This will turn &lt; or &gt; into &amp;lt; or &amp;gt; preventing JavaScript from being inserted and executed on viewing.</p>
<pre class="brush: php; gutter: true">$input = '&lt;script&gt;javascript:alert("Alert");&lt;/script&gt;'
$data = htmlentities($input);
//Returns &amp;lt;script&amp;gt;</pre>
</blockquote>
<h3>str_replace()</h3>
<blockquote><p>At first I did not use htmlentities() but made my own function using <a href="http://php.net/manual/en/function.str-replace.php" target="_blank">str_replace()</a> to replace characters to their HTML entities. I had one array containing the specific characters to be converted and the other array contained the HTML entities.  This can be safer as htmlentities() does not convert all characters to HTML entities.</p>
<pre class="brush: php; gutter: true">$html = array("'", '"', '&lt;', '&gt;');
$entities = array(''', '"', '&amp;lt;', '&amp;gt;');
$data = str_replace($html, $entities, $input);</pre>
</blockquote>
<h3>strtr()</h3>
<blockquote><p>strtr() is essentially the same as str_replace() but is faster. Also, instead using two arrays you can use just one array that uses pairs .</p>
<pre class="brush: php; gutter: true">$html = array('&lt;' =&gt; '&amp;lt;', '&gt;' =&gt; '&amp;gt;');
$data = strtr($input, $html);</pre>
</blockquote>

<p><a href="http://feedads.g.doubleclick.net/~a/dNheVD10UL3NmzNS9ObXLva1b-8/0/da"><img src="http://feedads.g.doubleclick.net/~a/dNheVD10UL3NmzNS9ObXLva1b-8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/dNheVD10UL3NmzNS9ObXLva1b-8/1/da"><img src="http://feedads.g.doubleclick.net/~a/dNheVD10UL3NmzNS9ObXLva1b-8/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/Glamanate/~4/nR1uB1ogQIY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://glamanate.com/2011/11/sanitize-text-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://glamanate.com/2011/11/sanitize-text-mysql/</feedburner:origLink></item>
	</channel>
</rss>

