<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>OSTalks &#187; php</title>
	<atom:link href="http://www.ostalks.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ostalks.com</link>
	<description>Open Source, Operating Systems, Offtopic Stuff!</description>
	<lastBuildDate>Fri, 04 Nov 2011 13:16:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to Add a Facebook, Twitter and Google +1 Button to Your WordPress Blog</title>
		<link>http://www.ostalks.com/2011/07/18/how-to-add-a-facebook-twitter-and-google-1-button-to-your-wordpress-blog/</link>
		<comments>http://www.ostalks.com/2011/07/18/how-to-add-a-facebook-twitter-and-google-1-button-to-your-wordpress-blog/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 05:22:12 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[+1]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress plugin]]></category>

		<guid isPermaLink="false">http://www.ostalks.com/?p=630</guid>
		<description><![CDATA[Here's a quickie small tip for wordpress blog users.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a quickie small tip for wordpress blog users.</p>
<p>If you want to add your own facebook, twitter and Google +1 buttons to your blog post, simply add the following code to your functions.php of your current theme:</p>
<p><code>&lt;?php<br />
add_filter ('the_content', 'insertMeShare');<br />
function insertMeShare($content)<br />
{<br />
if(is_single())<br />
{<br />
global $post;<br />
$link = urlencode($post-&gt;guid);<br />
$content.= '&lt;a href="http://twitter.com/share" data-count="horizontal"&gt;Tweet&lt;/a&gt;&lt;script type="text/javascript" src="http://platform.twitter.com/widgets.js"&gt;&lt;/script&gt;';<br />
$content.= '&lt;iframe src="http://www.facebook.com/plugins/like.php?app_id=181276555267890&amp;amp;href='.$link.'&amp;amp;send=false&amp;amp;layout=button_count&amp;amp;width=110&amp;amp;show_faces=false&amp;amp;action=like&amp;amp;colorscheme=light&amp;amp;font&amp;amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:21px; float: relative; " allowTransparency="true"&gt;&lt;/iframe&gt;';<br />
$content.= '&lt;g:plusone&gt;&lt;/g:plusone&gt;&lt;script type="text/javascript" src="https://apis.google.com/js/plusone.js"&gt;&lt;/script&gt;';<br />
}<br />
return $content;<br />
}<br />
?&gt;</code></p>
<p>This code above can be modified further as a wordpress plugin so as to not modify your current theme (especially if your theme is one of those ready made themes which has an update feature). I have made mine to be a wordpress plugin and I am using this now as my current social share buttons &#8211; see the end of my post as an example of these in action. Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2011/07/18/how-to-add-a-facebook-twitter-and-google-1-button-to-your-wordpress-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Putting It All Together: SpellDial php class and Android Application – Part Two</title>
		<link>http://www.ostalks.com/2011/07/10/putting-it-all-together-spelldial-php-class-and-android-application-%e2%80%93-part-two/</link>
		<comments>http://www.ostalks.com/2011/07/10/putting-it-all-together-spelldial-php-class-and-android-application-%e2%80%93-part-two/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 08:54:58 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[phonegap]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[spelldial]]></category>

		<guid isPermaLink="false">http://www.ostalks.com/?p=610</guid>
		<description><![CDATA[Let’s now continue on how to use the spelldial php class now in an android phonegap application.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m back, and I&#8217;ve got a little time on my hands. Let&#8217;s continue on how to use the spelldial php class now in an android phonegap application.</p>
<p>Now, let&#8217;s look at the actual php code that will make the spelldial call based on what your android spelldial app will send:</p>
<p>You can save this code snippet in a file named droidspell.php:</p>
<p><code>include "spelldial.php";<br />
$spell = new Spelldial();<br />
$result = $spell-&gt;get_info($_POST['spelldial'],$_POST['calltype']);<br />
if($result-&gt;error_code !== '0')<br />
{<br />
die("error");<br />
}<br />
echo $result-&gt;content[0]-&gt;info[0]-&gt;uri;</code></p>
<p>This is a typical use of the spelldial class I made (this uses post variables spelldial and calltype, ie. tel or skype to determine what to return as output to the android application).</p>
<p>Now for the html code snippet:</p>
<p><code>&lt;script src="jquery-1.4.2.min.js"&gt;jquery-1.4.2.min.js&lt;/script&gt;<br />
&lt;form id="spellform" name="spellform" method="post" action="http://yoursite/droidspell.php"&gt;<br />
&lt;table width="300" border="0" cellspacing="0" cellpadding="0"&gt;<br />
&lt;tr&gt;<br />
&lt;td height="27" colspan="2"&gt;SpellDial Name&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td height="31" colspan="2"&gt;&lt;label&gt;<br />
&lt;input type="text" name="spelldial" id="spelldial" /&gt;<br />
&lt;/label&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td height="42" colspan="2" valign="top"&gt;&lt;label&gt;<br />
&lt;select name="calltype" id="calltype"&gt;<br />
&lt;option value="TEL"&gt;Telephone&lt;/option&gt;<br />
&lt;option value="SKYPE"&gt;Skype&lt;/option&gt;<br />
&lt;/select&gt;<br />
&lt;/label&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;tr&gt;<br />
&lt;td colspan="2"&gt;&lt;label&gt;<br />
&lt;input type="submit" name="dial" id="dial" value="Call me using SpellDial" /&gt;<br />
&lt;/label&gt;&lt;/td&gt;<br />
&lt;/tr&gt;<br />
&lt;/table&gt;<br />
&lt;/form&gt;<br />
&lt;script&gt;<br />
$("#spellform").submit(function(event) {<br />
event.preventDefault();<br />
var $form = $( this ), spelldial = $form.find( 'input[name="spelldial"]' ).val(), calltype = $form.find( 'select[name="calltype"]' ).val(),<br />
url = $form.attr( 'action' );<br />
$.post( url, { 'spelldial': spelldial, 'calltype': calltype },<br />
function( data ) {<br />
if(data == 'error' || data == '')<br />
{<br />
alert('Spelldial API returned an error: '+data);<br />
} else {<br />
location.href = data;<br />
}<br />
}<br />
);<br />
});<br />
&lt;/script&gt;</code></p>
<p>As you may see, this is typical html form/jquery event code to get the result of the droidspell.php call and then determine if an error occurred and if not, go ahead to the android dialer to make a call.</p>
<p>You&#8217;ll see some stuff like jquery-1.4.2.min.js in the code above. Where is it placed? It is placed where the index.html is placed in the assets/www folder:</p>
<p><a href="http://www.ostalks.com/wp-content/uploads/2011/07/assets.jpg" rel="ibox"><img class="alignnone size-medium wp-image-615" title="assets" src="http://www.ostalks.com/wp-content/uploads/2011/07/assets-174x300.jpg" alt="" width="174" height="300" /></a></p>
<p>If you want to use the phonegap wrapper functions place this snippet in the &lt;head&gt; portion of your index.html file:</p>
<p><code>&lt;script type="text/javascript" charset="utf-8" src="phonegap.0.9.6.js"&gt;&lt;/script&gt;</code></p>
<p>You may rename phonegap.0.9.6.js to phonegap.js if you wish.</p>
<p>This is how a finished phonegap application looks like in the emulator (yeah yeah, ugliness noted, I made this quickly!):</p>
<p><a href="http://www.ostalks.com/wp-content/uploads/2011/07/emulator.jpg" rel="ibox"><img src="http://www.ostalks.com/wp-content/uploads/2011/07/emulator-300x220.jpg" alt="" title="emulator" width="300" height="220" class="alignnone size-medium wp-image-617" /></a></p>
<p><a href="http://www.ostalks.com/wp-content/uploads/2011/07/emulator2.jpg" rel="ibox"><img src="http://www.ostalks.com/wp-content/uploads/2011/07/emulator2-300x225.jpg" alt="" title="emulator2" width="300" height="225" class="alignnone size-medium wp-image-618" /></a></p>
<p>Once you see this application running in your emulator, you might want to package this application into an apk.  Simply right click on your project in the project window and select Android Tools->Export Unsigned Application Package &#8211; once you follow the instructions, this will create an unsigned apk file for you automatically.  </p>
<p><a href="http://www.ostalks.com/wp-content/uploads/2011/07/package.jpg" rel="ibox"><img src="http://www.ostalks.com/wp-content/uploads/2011/07/package-300x124.jpg" alt="" title="package" width="300" height="124" class="alignnone size-medium wp-image-622" /></a></p>
<p>You can also create signed apk files for distribution into the Market.  For further reference, please see <a href="http://developer.android.com/guide/publishing/app-signing.html" target="_blank">http://developer.android.com/guide/publishing/app-signing.html</a> for details.</p>
<p>And there you have it, we have now made an android application in phonegap using the spelldial php class, tested it in an emulator, and published it as an apk file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2011/07/10/putting-it-all-together-spelldial-php-class-and-android-application-%e2%80%93-part-two/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Putting It All Together: SpellDial php class and Android Application &#8211; Part One</title>
		<link>http://www.ostalks.com/2011/06/23/putting-it-all-together-spelldial-php-class-and-android-application-part-one/</link>
		<comments>http://www.ostalks.com/2011/06/23/putting-it-all-together-spelldial-php-class-and-android-application-part-one/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 01:43:01 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[appcelerator]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[phonegap]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ostalks.com/?p=583</guid>
		<description><![CDATA[There are many ways to program in android, ios, symbian, blackberry or winmo phones. There are cross-development frameworks which give you an abstract way to program in these mobile devices without dealing with the underlying phone hardware.]]></description>
			<content:encoded><![CDATA[<p>Ok, I&#8217;ve got a little time on my hand before I start with a wordpress project I am doing (creating wordpress plugins are fun <img src='http://www.ostalks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &#8211; yipee ).</p>
<p>Let&#8217;s try to make a simple Android application using the <a href="http://www.phonegap.com">phonegap</a> cross-development framework calling a php script that uses my spelldial class to return a spelldial uri.  Part one will describe steps on how to make your very first native webapplication in android (simply a hello world android web application).</p>
<p>I assume that you know how to install eclipse, the android sdk and the phonegap framework on your system (I&#8217;ll cover this in small detail, to help you get started).</p>
<p>There are many ways to program in android, ios, symbian, blackberry or winmo phones.  There are cross-development frameworks which give you an abstract way to program in these mobile devices without dealing with the underlying phone hardware.</p>
<p>Two different technologies come to mind (these are the most popular that I&#8217;ve seen):<br />
1. <a href="http://www.appcelerator.com/">Appcelerator Titanium</a> &#8211; this cross development tool allows web developers to quickly go into the mobile application department using what they know.  HTML5, CSS, and a host of web programming languages such as php and ruby are supported.  What is unique about this SDK is that these technologies are then compiled into their native counterparts &#8211; the end result is a native application.  Impressive, actually.  Supports both iOS and Android environments.<br />
2. <a href="http://www.phonegap.com">Phonegap</a> takes a different approach.  This is closest to what you call as a web application encapsulated in the mobile phone&#8217;s browser class.  For example, what this means, in Android, this framework wraps around the <a href="http://developer.android.com/reference/android/webkit/WebView.html">WebView</a> Java class and makes certain native phone functionalities available (like accessing your contacts for example) through javascript.  For flash/flex developers, this is much like the ExternalInterface class that bridges between javascript and the flash application.</p>
<p>Which is more appropriate?  If you&#8217;re a web developer and would like to make your application as close as possible to a native application, your best bet would be Appcelerator.</p>
<p>Why am I using phonegap in this case?  If you just like to quickly develop applications and do not care if they look different from native applications, use phonegap.  By the way, because of how phonegap works, it is available to more mobile environments than Appcelerator.  Symbian, WinMo, Blackberry, iOS and Android mobile environments are supported by phonegap.  No matter what the environment, your application would look the same because it is just practically your html application enclosed in the native phone&#8217;s browser class.</p>
<p>Also, phonegap is supported by the <a href="http://www.adobe.com/devnet/dreamweaver/articles/whats-new-dwcs55.html">Dreamweaver CS 5.5 release</a>, which means if you can afford it, mobile development will be quite simple to do (without using Eclipse as your environment to develop phonegap applications).</p>
<p>Now, lets begin.  Let&#8217;s create a new project in eclipse by selecting File-&gt;New-&gt;Other</p>
<p><a rel="ibox" href="http://www.ostalks.com/wp-content/uploads/2011/06/step1.jpg"><img class="alignnone size-medium wp-image-584" title="step1" src="http://www.ostalks.com/wp-content/uploads/2011/06/step1-300x286.jpg" alt="" width="300" height="286" /></a></p>
<p>We now include our details for the application (Since Froyo or Eclair, the android version before 2.2, runs in 86% of android phones, I choose the lowest common denominator, Eclair), below:</p>
<p><a rel="ibox" href="http://www.ostalks.com/wp-content/uploads/2011/06/step2.jpg"><img class="alignnone size-medium wp-image-587" title="step2" src="http://www.ostalks.com/wp-content/uploads/2011/06/step2-216x300.jpg" alt="" width="216" height="300" /></a></p>
<p>We will have to add the phonegap jar file to the libs folder (which you will have to create) and also create the /assets/www folder where you will place the html files for your application.  In this www folder, you will have also to place the phonegap.js file in there.   This js file contains the functions that you will call to access native mobile phone functions such as accessing your camera, contacts, etc.</p>
<p>In order for Eclipse not to spurt out an error message (having a java class not available for use), we have to add phonegap.jar to the Build Path (Right click on the libs folder, select Build Path-&gt;Configure Build Path):</p>
<p><a rel="ibox" href="http://www.ostalks.com/wp-content/uploads/2011/06/step4.jpg"><img class="alignnone size-medium wp-image-590" title="step4" src="http://www.ostalks.com/wp-content/uploads/2011/06/step4-300x224.jpg" alt="" width="300" height="224" /></a></p>
<p>We will now edit the spelldial.java source code which was created using the New Project Wizard to look like this:</p>
<p><a rel="ibox" href="http://www.ostalks.com/wp-content/uploads/2011/06/step3.jpg"><img class="alignnone size-medium wp-image-588" title="step3" src="http://www.ostalks.com/wp-content/uploads/2011/06/step3-300x144.jpg" alt="" width="300" height="144" /></a></p>
<p>Let&#8217;s look at it line by line:</p>
<p><code>import ...<br />
import com.phonegap.*;</code></p>
<p>The code above imports the phonegap class for use in our application.</p>
<p><code>public class spelldial extends DroidGap</code></p>
<p>Our spelldial class (which was created by the Wizard), extends upon the DroidGap class, which is in fact an extension of the WebView class.</p>
<p>This line below is what runs the web application (sort of like the main() function in your c program):</p>
<p><code>super.loadUrl("file://android_asset/www/index.html");</code></p>
<p>You can change the url to whatever you have placed in the assets/www folder as your starting point.  index.html can simply be text saying &#8220;hello world&#8221; at this point.</p>
<p>One more thing, since phonegap uses certain native phone functions which require explicit permissions for the app to run, we&#8217;ll have to edit our AndroidManifest.xml to allow our app to use these:</p>
<p><a rel="ibox" href="http://www.ostalks.com/wp-content/uploads/2011/06/step5.jpg"><img class="alignnone size-medium wp-image-595" title="step5" src="http://www.ostalks.com/wp-content/uploads/2011/06/step5-300x169.jpg" alt="" width="300" height="169" /></a></p>
<p>These tags are placed below the android:versionName section:</p>
<p><code>&lt;supports-screens<br />
android:largeScreens="true"<br />
android:normalScreens="true"<br />
android:smallScreens="true"<br />
android:resizeable="true"<br />
android:anyDensity="true"<br />
/&gt;<br />
&lt;uses-permission android:name="android.permission.CAMERA" /&gt;<br />
&lt;uses-permission android:name="android.permission.VIBRATE" /&gt;<br />
&lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;<br />
&lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;<br />
&lt;uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /&gt;<br />
&lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;<br />
&lt;uses-permission android:name="android.permission.INTERNET" /&gt;<br />
&lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt;<br />
&lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;<br />
&lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;<br />
&lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;<br />
&lt;uses-permission android:name="android.permission.WRITE_CONTACTS" /&gt;<br />
&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;<br />
&lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;</code></p>
<p>And there you have it, some basic steps on how to set up the phonegap framework in eclipse.  Part 2 will be the actual js code and php code that this web application uses to call a person using the spelldial api php class hosted on a server.</p>
<p>To end this, let&#8217;s take a look at phonegap support in Dreamweaver CS 5.5:</p>
<p><iframe title="AdobeTV Video Player" width="480" height="296" src="http://tv.adobe.com/embed/707/9261/" frameborder="0" allowfullscreen scrolling="no"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2011/06/23/putting-it-all-together-spelldial-php-class-and-android-application-part-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spelldial Class</title>
		<link>http://www.ostalks.com/2011/06/20/spelldial-class/</link>
		<comments>http://www.ostalks.com/2011/06/20/spelldial-class/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 01:11:48 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Off Topic Stuff]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[spelldial]]></category>

		<guid isPermaLink="false">http://www.ostalks.com/?p=569</guid>
		<description><![CDATA[SpellDial is a technology that allows you to dial names instead of numbers.]]></description>
			<content:encoded><![CDATA[<p>Hi guys,</p>
<p>Another short post.  I went to a small group hosted by techtalks (my former boss was one of the co-organizers) in IT Park.  I met a lot of interesting people there, and there were quite a number of foreigners too (having their startups, some in the process of making a startup, etc)!</p>
<p>In short, this was a great experience because I for one dream to make a startup of my own too (poor programmer, no funds to do it &#8211; but the stuff I found there was educational to say the least).</p>
<p>Anyways, I saw a team of young guys (from the looks of it, new graduates, or even maybe in college), who have a startup company named <a href="http://www.spelldial.com">Spelldial</a>.  Well, I maybe an old fart, but I when I see enthusiasm, especially from youth, of course, as heck, I get impressed.</p>
<p>What is SpellDial?  From their website, it says:</p>
<blockquote><p>SpellDial is a technology that allows you to dial names instead of numbers. This is applicable only for those who have setup a spelldial account. Once you have checked the availability of your username you can register it to point to a specific number. So instead of dialing a number, you dial their username.</p></blockquote>
<p>They have a webapp that you can point your android or iphone to, but nevertheless, when you point that url to your desktop browser, it doesn&#8217;t work (obvious reasons).</p>
<p>I then took a quick peek at their api, and made a php wrapper class for it in about an hour (so that you won&#8217;t need to think about the details of calling the api).  It&#8217;s as simple as doing these lines of code:</p>
<p><code><br />
<?<br />
include "spelldial.php";<br />
$spell = new Spelldial();<br />
$result = $spell->get_info("us.example");<br />
print_r($result);<br />
?><br />
</code></p>
<p>I know, the api yet is apparently in their very early stages (some of their api functions return nothing), but considering they are all young guys, it&#8217;s a great start for them <img src='http://www.ostalks.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Get my <a href='http://www.ostalks.com/wp-content/uploads/2011/06/spelldial.zip'>spelldial class here.</a>  I might in the future make an actionscript class (for flash users) and maybe even a java class for this one, but no promises.</p>
<p>Here&#8217;s the <a href="http://ostalks.com/spelldial_example/" target="_blank">spelldial class in action</a> (it&#8217;s a quick hack, so I&#8217;m sorry it&#8217;s ugly) <img src='http://www.ostalks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2011/06/20/spelldial-class/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dream Big &#8211; An Open Source Tale</title>
		<link>http://www.ostalks.com/2010/03/10/dream-big-an-open-source-tale/</link>
		<comments>http://www.ostalks.com/2010/03/10/dream-big-an-open-source-tale/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 02:24:04 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[LAMP]]></category>

		<guid isPermaLink="false">http://www.ostalks.com/?p=339</guid>
		<description><![CDATA[Don't ever let yourself be put down because other people say it can't be done.

This is a simple story of how leveraging open source technologies can bring you to heights and depths you thought you could never reach.]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t ever let yourself be put down because other people say it can&#8217;t be done.</p>
<p>This is a simple story of how leveraging open source technologies can bring you to heights and depths you thought you could never reach.</p>
<p>Around 2002, November, I was asked by one of our ministry head to think of a way to make a new website geared for students.  When I think of now, it was really like a social network on a much much smaller scale.</p>
<p>The situation here on the student network&#8217;s proposed site was this:  they had already searched for a software development firm in Manila and asked for a quotation and timeframe of the work.  They said it would take 3 months, and about a six digit amount to get it done.  Since that was way too much, they decided to look into the outreach here in Cebu and ask around if there were any people somehow knowledgeable enough to take the challenge.</p>
<p>A few months before, where I was working, I had started studying and implementing some LAMP architecture on the corporate website.  Mind you, my skills then were not so mature yet.  PHP was still version 4.x and there were even some 3.x versions around.  You can even call me a greenhorn (newbie) during this time &#8211; on the company I was in, all I had was Dreamweaver 4 to work upon the website, and some tutorials from the web on how to set up and program in php.</p>
<p>To make the long story short, I and two other people from the community (serving in ministry work), were tasked to do what one would have thought to be impossible to do during that time &#8211; make the student network site, complete with interactive forums and one login registrations to be part of the site, and with ALL content in less than one month.  Yes, that&#8217;s right, the site was going to be launched a little bit after Christmas.</p>
<p>Since I was working then, we had to take turns in programming and developing the site.  I was the head then of the 3 person team in Cebu.  The two were not working yet, so I tasked them to make the different sections of the site.  We were working at my home (no problems, I was single then <img src='http://www.ostalks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).  Some people from our main branch in Manila were sending designs for us to cut and slice and place in the site.</p>
<p>After of almost a month of non-stop work on the site.  It was done, and uploaded to a shared server through dialup (it would take 3-4 hours to update the whole site).</p>
<p>What&#8217;s the lesson of this experience?  If I were to use proprietary software and languages it would be a whole lot more expensive (I knew there was asp, and coldfusion, but hosting for that was expensive).  We had to use the one available on most cheap servers at that time, and that was a LAMP based server.  We leveraged free forum software and modified it and integrated it into the site&#8217;s one login and registration.  If we had started from scratch we wouldn&#8217;t have had finished the site on time.  Open Source is all about collaboration, and this experience has taught me a lot about coordinating remotely too.</p>
<p>Looking back, I was to lead the original web team here for about 2 more years, before moving on (by then they had grown to more than 5) &#8211; after which, I was still assigned to the original website which we made, and helped worked on two more sites and administered the ministry&#8217;s server (which was now a dedicated server).  The site which we first started won the Catholic Mass Media Awards for Best Website for 3 straight years before becoming a Hall of Fame Awardee.  I was incidentally there using a borrowed suit during the first time we won (it was held in Ateneo and televised nationwide, hosted by some guy and Donita Rose), and that by itself was an experience I&#8217;ll never forget.  You can get the list of winners during the first time the site won at the cmma foundation website <a href="http://www.cmmafoundation.org/cmma_files/cmma2003winners.pdf">here</a>.</p>
<p>Dream Big.  It can be done.</p>
<p><a href="http://www.ostalks.com/wp-content/uploads/2010/03/genrev.jpg"><img src="http://www.ostalks.com/wp-content/uploads/2010/03/genrev-169x300.jpg" alt="" title="genrev" width="169" height="300" class="alignnone size-medium wp-image-340" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2010/03/10/dream-big-an-open-source-tale/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Facebook: Hiphop for PHP Released As Open Source</title>
		<link>http://www.ostalks.com/2010/02/03/facebook-hiphop-for-php-released-as-open-source/</link>
		<comments>http://www.ostalks.com/2010/02/03/facebook-hiphop-for-php-released-as-open-source/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 07:06:07 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[hiphop]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.ostalks.com/?p=230</guid>
		<description><![CDATA[After spending some weeks in rumor land, Facebook has now released a cross-compiling language converter for PHP as open source (php license), titled Hiphop for PHP.]]></description>
			<content:encoded><![CDATA[<p>After spending some weeks in rumor land, Facebook has now released a cross-compiling language converter for PHP as open source (php license), titled Hiphop for PHP.</p>
<p>What the application does is to programatically convert PHP source code into C++ and compile it with g++.</p>
<p>According to senior engineer Haiping Zhao, Hiphop has now been deployed to 90% of the Facebook traffic, six months after deployment.</p>
<p>For more information, please see the video below:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="386" id="utv509403" name="utv_n_42198"><param name="flashvars" value="loc=%2F&amp;autoplay=false&amp;vid=4409735" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.ustream.tv/flash/video/4409735" /><embed flashvars="loc=%2F&amp;autoplay=false&amp;vid=4409735" width="480" height="386" allowfullscreen="true" allowscriptaccess="always" id="utv509403" name="utv_n_42198" src="http://www.ustream.tv/flash/video/4409735" type="application/x-shockwave-flash" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2010/02/03/facebook-hiphop-for-php-released-as-open-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Import DBF Files To MySQL Using PHP</title>
		<link>http://www.ostalks.com/2009/12/31/import-dbf-files-to-mysql-using-php/</link>
		<comments>http://www.ostalks.com/2009/12/31/import-dbf-files-to-mysql-using-php/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 00:35:35 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[DBase]]></category>
		<category><![CDATA[dbf]]></category>
		<category><![CDATA[FoxPro]]></category>
		<category><![CDATA[import]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[rpm]]></category>

		<guid isPermaLink="false">http://www.ostalks.com/?p=224</guid>
		<description><![CDATA[I recently had a task to do for a friend of mine to migrate Visual FoxPro data into a mysql database.]]></description>
			<content:encoded><![CDATA[<p>I recently had a task to do for a friend of mine to migrate Visual FoxPro data into a mysql database.</p>
<p>As a programmer that doesn&#8217;t like to re-invent the wheel, I tried searching through google, but was only partially successful in getting code to insert dbf data into mysql (it was public domain code, but only had code to insert data into a table that was created earlier).</p>
<p>This is the code modified to work with any dbf file &#8211; it creates the table, then inserts the dbf data into the created table.  The code was further modified to strip whitespaces from the text values (FoxPro/DBase pads text with spaces up to the length of the field).  You may want to change this further, since this is a quick and dirty code for the sole purpose of importing dbf tables.  This works with my rpms at the repository.</p>
<p><code><br />
<?php<br />
/*<br />
 * Part 2 code modified by Clint Christopher Canada from different public domain sources<br />
 * Part 1 code created by Clint Christopher Canada. BSD licensed.<br />
 */</p>
<p>// This is Part I of the code<br />
$tbl = "table to create";<br />
$db_uname = 'mysql username';<br />
$db_passwd = 'mysql password';<br />
$db = 'database';<br />
$conn = mysql_pconnect('localhost',$db_uname, $db_passwd); </p>
<p>// Path to dbase file<br />
$db_path = ".DBF";</p>
<p>// Open dbase file<br />
$dbh = dbase_open($db_path, 0)<br />
  or die("Error! Could not open dbase database file '$db_path'.");</p>
<p>// Get column information<br />
$column_info = dbase_get_header_info($dbh);</p>
<p>// Display information<br />
//print_r($column_info);</p>
<p>$line = array();</p>
<p>foreach($column_info as $col)<br />
{<br />
	switch($col['type'])<br />
	{<br />
		case 'character':<br />
			$line[]= "`$col[name]` VARCHAR( $col[length] )";<br />
			break;<br />
		case 'number':<br />
			$line[]= "`$col[name]` FLOAT";<br />
			break;<br />
		case 'boolean':<br />
			$line[]= "`$col[name]` BOOL";<br />
			break;<br />
		case 'date':<br />
			$line[]= "`$col[name]` DATE";<br />
			break;<br />
		case 'memo':<br />
			$line[]= "`$col[name]` TEXT";<br />
			break;<br />
	}<br />
}<br />
$str = implode(",",$line);<br />
$sql = "CREATE TABLE `$tbl` ( $str );";</p>
<p>mysql_select_db($db,$conn);</p>
<p>mysql_query($sql,$conn);<br />
set_time_limit(0); // I added unlimited time limit here, because the records I imported were in the hundreds of thousands.</p>
<p>// This is part 2 of the code</p>
<p>import_dbf($db, $tbl, $db_path);</p>
<p>function import_dbf($db, $table, $dbf_file)<br />
{<br />
    global $conn;<br />
    if (!$dbf = dbase_open ($dbf_file, 0)){ die("Could not open $dbf_file for import."); }<br />
    $num_rec = dbase_numrecords($dbf);<br />
    $num_fields = dbase_numfields($dbf);<br />
    $fields = array();</p>
<p>    for ($i=1; $i<=$num_rec; $i++){<br />
        $row = @dbase_get_record_with_names($dbf,$i);<br />
        $q = "insert into $db.$table values (";<br />
        foreach ($row as $key => $val){<br />
            if ($key == 'deleted'){ continue; }<br />
            $q .= "'" . addslashes(trim($val)) . "',"; // Code modified to trim out whitespaces<br />
        }<br />
        if (isset($extra_col_val)){ $q .= "'$extra_col_val',"; }<br />
        $q = substr($q, 0, -1);<br />
        $q .= ')';<br />
        //if the query failed - go ahead and print a bunch of debug info<br />
        if (!$result = mysql_query($q, $conn)){<br />
            print (mysql_error() . " SQL: $q<br />\n");<br />
            print (substr_count($q, ',') + 1) . " Fields total.
<p>";<br />
            $problem_q = explode(',', $q);<br />
            $q1 = "desc $db.$table";<br />
            $result1 = mysql_query($q1, $conn);<br />
            $columns = array();<br />
            $i = 1;<br />
            while ($row1 = mysql_fetch_assoc($result1)){<br />
                $columns[$i] = $row1['Field'];<br />
                $i++;<br />
            }<br />
            $i = 1;<br />
            foreach ($problem_q as $pq){<br />
                print "$i column: {$columns[$i]} data: $pq<br />\n";<br />
                $i++;<br />
            }<br />
            die();<br />
        }<br />
    }<br />
}</p>
<p>?><br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2009/12/31/import-dbf-files-to-mysql-using-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Starting a Facebook Application</title>
		<link>http://www.ostalks.com/2009/10/27/starting-a-facebook-application/</link>
		<comments>http://www.ostalks.com/2009/10/27/starting-a-facebook-application/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 10:36:15 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://ostalks.wordpress.com/?p=72</guid>
		<description><![CDATA[One of the most popular social networking sites today is facebook. As of this time, the social networking site boasts of over 300 million users, which is pretty hard to ignore, considering marketing value.]]></description>
			<content:encoded><![CDATA[<p>One of the most popular social networking sites today is facebook.  As of this time, the social networking site boasts of over 300 million users, which is pretty hard to ignore, considering marketing value.</p>
<p>What makes facebook interesting are its applications; which are mostly user created, and add life to the social networking site.</p>
<p>Here&#8217;s how to submit a facebook application to the net:</p>
<p>1. Join as a facebook developer, and on the http://www.facebook.com/developers/ url, click on the Set up new application button</p>
<p><img class="alignnone size-medium wp-image-73" title="Set up new application" src="http://www.ostalks.com/wp-content/uploads/2011/06/pic1.jpg" alt="Set up new application" width="400" height="25" /></p>
<p>2. On the Create App page, type in the name of your application</p>
<p><img class="alignnone size-medium wp-image-74" title="Create App Page" src="http://www.ostalks.com/wp-content/uploads/2011/06/pic2.jpg" alt="Create App Page" width="600" /></p>
<p>3. Take note of the API Key and Secret; you&#8217;ll need these later.  Fill up the necessary items in the Basic Page.</p>
<p><img class="alignnone size-medium wp-image-75" title="pic3" src="http://www.ostalks.com/wp-content/uploads/2011/06/pic3.jpg" alt="pic3" width="600" /></p>
<p>4. Enter the canvas url (where your application will reside in apps.facebook.com), and the content url where your application is hosted.</p>
<p><img class="alignnone size-medium wp-image-76" title="pic4" src="http://www.ostalks.com/wp-content/uploads/2011/06/pic4.jpg" alt="pic4" width="600" /></p>
<p>5. Press Save, and you&#8217;re off to start a brave new world of creating a Facebook Application!</p>
<p>The simplest start for a facebook application looks like this:</p>
<p><code>require_once 'php/facebook.php';<br />
require_once 'config.php';</code></p>
<p>$facebook = new Facebook($api_key, $secret);<br />
$user_id = $facebook-&gt;require_login();</p>
<p>echo &#8220;Hello, $user_id!&#8221;;</p>
<p>facebook.php is the facebook php client which you can download in the developers site.  You can learn more about the api in the http://wiki.developers.facebook.com/ site.</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2009/10/27/starting-a-facebook-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mypodcast.com Feeds and Longtailvideo Media Player</title>
		<link>http://www.ostalks.com/2009/09/20/mypodcast-com-feeds-and-longtailvideo-media-player/</link>
		<comments>http://www.ostalks.com/2009/09/20/mypodcast-com-feeds-and-longtailvideo-media-player/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 07:51:38 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[longtail media player]]></category>
		<category><![CDATA[podcast]]></category>
		<category><![CDATA[simplepie]]></category>

		<guid isPermaLink="false">http://ostalks.wordpress.com/?p=69</guid>
		<description><![CDATA[The religious community that I'm in delves into media. In fact we have a website that showcases video and audio materials for free.

We use the ever popular video/media flash player made by Longtail Video to stream our mp3 and video files to be distributed and seen by people in the web.]]></description>
			<content:encoded><![CDATA[<p>The religious community that I&#8217;m in delves into media.  In fact we have a website that showcases video and audio materials for free.</p>
<p>We use the ever popular video/media flash player made by <a href="http://www.longtailvideo.com/players/jw-flv-player/">Longtail Video</a> to stream our mp3 and video files to be distributed and seen by people in the web.</p>
<p>As we host our mp3 files in mypodcast.com, the rss feed that is delivered my the site isn&#8217;t exactly compatible with the player &#8211; so I had to parse the rss feed and re encode it into an rss feed that the longtail player recognizes.</p>
<p>In order to not reinvent the wheel in reading rss feeds, I used the ever popular open source (BSD-licensed) php feed reader, <a href="http://simplepie.org">simplepie</a>.</p>
<p>Below this page is the quick and dirty code that I used.  I hope this will help you get started in the world of podcasting!</p>
<p><code><br />
&lt;?<br />
require_once('simplepie.inc');</code></p>
<p>$feed = new SimplePie(&#8216;http://host/rss.xml&#8217;);<br />
set_cache_location($_SERVER['DOCUMENT_ROOT'] . &#8216;/cache/&#8217;);</p>
<p>$feed-&gt;handle_content_type();</p>
<p>?&gt;</p>
<p>rss feed name<br />
get_items() as $item)<br />
{<br />
$title = $item-&gt;get_title();<br />
$date = $item-&gt;get_date();<br />
if ($enclosure = $item-&gt;get_enclosure())<br />
{<br />
$media = $enclosure-&gt;get_link();<br />
$length = $enclosure-&gt;get_duration(true);<br />
}<br />
$subtitle = $item-&gt;subtitle;<br />
$description = $item-&gt;get_description();<br />
//print_r($enclosure);<br />
$desc = explode(&#8220;&#8221;,&#8221;",$image);<br />
echo &#8221;</p>
<p>$title<br />
$author</p>
<p>&#8220;;<br />
}<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2009/09/20/mypodcast-com-feeds-and-longtailvideo-media-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heywatch and php</title>
		<link>http://www.ostalks.com/2009/09/07/heywatch-and-php/</link>
		<comments>http://www.ostalks.com/2009/09/07/heywatch-and-php/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 11:20:23 +0000</pubDate>
		<dc:creator>clintcan</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[heywatch]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://ostalks.wordpress.com/?p=61</guid>
		<description><![CDATA[Heywatch is a cool video encoding web service that is being used by different clients like Sony, Fotolia, Kickapps, MTv, among others for their video conversion needs.]]></description>
			<content:encoded><![CDATA[<p>Heywatch is a cool video encoding web service that is being used by different clients like Sony, Fotolia, Kickapps, MTv, among others for their video conversion needs.</p>
<p>One nice thing about this service is that it has a REST based API that is simple to implement in php.  However, the documentation that comes with heywatch shows only how to access the API using PEAR &#8211; this becomes a disadvantage if your shared hosted webhost doesn&#8217;t have PEAR installed.  I also personally think that using PEAR just to call this api is basically overkill.</p>
<p>Why not use curl instead?  I basically changed the PEAR functions in the API documentation to that of php curl functions (which are basically native and available in practically all shared php webhosting)</p>
<p><code><br />
&lt;?<br />
$video_url = "http://osaddict.com/files/elephantsdream-480-h264-st-aac.mov";<br />
$format_id = "1086"; // 1086 for flash h264, 31 for flash flv<br />
$ftp = "ftp://username:password@ftphost.com";<br />
$ping_after_encode = "http://host/heywatch/success.php?myvideoid=5&amp;myuserid=1";<br />
$ping_if_error = "http://host/heywatch/error.php";<br />
$ch = curl_init();<br />
$your_username = "";<br />
$your_password = "";<br />
$arr = array($video_url,"format_id"=&gt;$format_id,"automatic_encode"=&gt;"true","ftp_directive"=&gt;$ftp,"title"=&gt;"My Video Title","keep_video_size"=&gt;"true");<br />
curl_setopt($ch, CURLOPT_USERPWD, $your_username.':'.$your_password);<br />
curl_setopt($ch, CURLOPT_POSTFIELDS,$arr);</code></p>
<p>$data = curl_exec($ch);</p>
<p>if (curl_errno($ch)) {<br />
print curl_error($ch);<br />
exit;<br />
} else {<br />
curl_close($ch);<br />
}</p>
<p>header(&#8220;Content-Type: text/xml;charset=UTF-8&#8243;);<br />
header(&#8220;Pragma: no-cache&#8221;);<br />
echo $data;<br />
?&gt;</p>
<p>What this code does is to download a video, convert it to h264 flash format, then upload it to a select ftp host in just one step (success.php and error.php are ping functions where the developer is notified if conversion was successful or not).</p>
<p>One thing to take note is that heywatch doesn&#8217;t like special characters in the ftp url, if you place such characters in the $ftp variable, heywatch upload fails.</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ostalks.com/2009/09/07/heywatch-and-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
<enclosure url="http://osaddict.com/files/elephantsdream-480-h264-st-aac.mov" length="103636531" type="video/quicktime" />
		</item>
	</channel>
</rss>

