<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>burrellaramone &#187; open_source</title>
	<atom:link href="http://burrellaramone.wordpress.com/category/open_source/feed/" rel="self" type="application/rss+xml" />
	<link>http://burrellaramone.wordpress.com</link>
	<description>Just another WordPress.com site</description>
	<lastBuildDate>Sat, 05 May 2012 14:29:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='burrellaramone.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>burrellaramone &#187; open_source</title>
		<link>http://burrellaramone.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://burrellaramone.wordpress.com/osd.xml" title="burrellaramone" />
	<atom:link rel='hub' href='http://burrellaramone.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Login Script for Your Website</title>
		<link>http://burrellaramone.wordpress.com/2011/11/19/login-script-for-your-website/</link>
		<comments>http://burrellaramone.wordpress.com/2011/11/19/login-script-for-your-website/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 21:12:10 +0000</pubDate>
		<dc:creator>Ramone Burrell</dc:creator>
				<category><![CDATA[open_source]]></category>

		<guid isPermaLink="false">http://burrellaramone.wordpress.com/?p=85</guid>
		<description><![CDATA[One of the biggest challenges i had when first learning PHP was how to create a log in script. I had to get user input, interact with a database, process the user&#8217;s input and return a result. To me at the time this was very difficult. But now that have done it a couple of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burrellaramone.wordpress.com&#038;blog=27504715&#038;post=85&#038;subd=burrellaramone&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="font-size:9pt;">
<p>One of the biggest challenges i had when first learning PHP was how to create a log in script. I had to get user input, interact with a database, process the user&#8217;s input and return a result. To me at the time this was very difficult. But now that have done it a couple of times, it is had become easy. My first approach was to have a PHP page itself that would handle the use case. But then i realized that it would be much easier to design a class to represent the use case. The class i designed is called  login  which extends from another class called signup.</p>
<pre> &lt;?php
require_once("../config.php");
require_once("class_signup.php");
class login  extends signup{

    private $_password;
    private $_username;
    private $_db_link;

  function __construct(){
      $this-&gt;connect_database();  
  }//end class constructor

  function __destruct(){
     $this-&gt;_db_link=NULL;
  }//ebd destructor

  public function connect_database(){

     if(!$link = mysql_connect(_HOST_NAME_,_USERNAME_,_DBS_PASSOWRD_)){             
        print mysql_error();
        $this-&gt;_sign_up_err=TRUE;
        exit;
      }//end if  
      $this-&gt;_db_link=$link;     
  }//end connect_database function

  public function _validate_login($username,$password){

     $this-&gt;_password=base64_encode($password);
     $this-&gt;_username=$username;

     $sql_statement="SELECT * FROM " ._DATABASE_NAME_. "."._USERS_TABLE_.
                   " WHERE username='$this-&gt;_username' AND password='$this-&gt;_password'";

      if(!mysql_query($sql_statement,$this-&gt;_db_link)){//execut the msql query on the database
          print mysql_error();
          exit();
       }

           $sql_result=mysql_query($sql_statement,$this-&gt;_db_link);

      if(mysql_num_rows($sql_result)!=0){
           $sql_result=mysql_query($sql_statement,$this-&gt;_db_link);
        $aRow=mysql_fetch_array($sql_result);

           if($aRow['username']==$this-&gt;_username&amp;&amp;base64_decode($aRow['password'])==base64_decode($this-&gt;_password)){
               $this-&gt;_log_user_in($this-&gt;_username,$this-&gt;_db_link);                           
           }else{    
                 header("Location: ".str_replace("index.php","",$_SERVER['HTTP_REFFERER'])."?error=true");
           }//end else

       }else{
              header("Location: ".str_replace("index.php","",$_SERVER['HTTP_REFFERER'])."?error=true");
       }//end else

  }//end function
}
?&gt;&lt;!--End php script--&gt;</pre>
<p>At the top of your log in page, after including the PHP file that holds the class definition, instantiate a login class like $login = new loin(); After this, you will have access to all the class&#8217;s functionalites. In the log in form, submit the page to itself with the POST method, ( action=&#8221;&lt;?=$_SERVER['PHP_SELF'] ?&gt;&#8221;, method=&#8221;POST&#8221;) . Call the member function _validate_login($username,$password)  and pass it the username and password values that were sent in the $_POST array. Assuming that the u have a operable mysql database, the script will retrieve the values from the database then try to match them with the user&#8217;s inoput. If successful, the script will call a member function which it inherited from its base class &#8216;signup&#8217;. If the login fails for any reason,  the script will  redirect the user to the log in page with the query string &#8220;?error=true&#8221;. In my log in page, there is a script that checks this value and if it is set to true then it will display a message alerting the user that the username and or password were incorrect. Below is the member functin which the clas login has inherited to complete the use case.</p>
<pre>public function _log_user_in($username,$dblink){
    if(isset($dblink)){
        $this-&gt;_db_link=$dblink;
    }//end if

     $sqlStatement="SELECT id FROM " ._DATABASE_NAME_. "."._USERS_TABLE_."
                     WHERE username='$username'";
        if(!mysql_query($sqlStatement,$this-&gt;_db_link)){
               print mysql_error();
               exit;
        }//end if

     $sql_result=mysql_query($sqlStatement,$this-&gt;_db_link);
     $aRow=mysql_fetch_array($sql_result);

     session_save_path(_SESSION_SAVE_PATH_);
     session_start();

     session_set_cookie_params(3600000);//set the time lapse for tht cookies
     $_SESSION['username']=$username;
     $_SESSION['user_id']= $aRow['id'];

     $user = new user();
     $user-&gt;_increment_user_visits();

     header("Location: ../");//rediret user to the homepage now that he r she has logged in successfully
}//end function</pre>
<p>the script will simply set all the session values for the current user by retrieving it from the database and setting them in the $_SESSION array. it then redirects the user to the home page of the websites. I hope this was use full to those new to PHP programming.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/burrellaramone.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/burrellaramone.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/burrellaramone.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/burrellaramone.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/burrellaramone.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/burrellaramone.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/burrellaramone.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/burrellaramone.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/burrellaramone.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/burrellaramone.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/burrellaramone.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/burrellaramone.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/burrellaramone.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/burrellaramone.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burrellaramone.wordpress.com&#038;blog=27504715&#038;post=85&#038;subd=burrellaramone&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://burrellaramone.wordpress.com/2011/11/19/login-script-for-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3924e0f46c705f6310b68ea94797df2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">burrellaramone</media:title>
		</media:content>
	</item>
		<item>
		<title>remove_user_directory($dir_path)</title>
		<link>http://burrellaramone.wordpress.com/2011/11/10/remove_user_directorydir_path/</link>
		<comments>http://burrellaramone.wordpress.com/2011/11/10/remove_user_directorydir_path/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 09:36:44 +0000</pubDate>
		<dc:creator>Ramone Burrell</dc:creator>
				<category><![CDATA[open_source]]></category>

		<guid isPermaLink="false">http://burrellaramone.wordpress.com/?p=51</guid>
		<description><![CDATA[The following is a PHP function that allows u to delete all the files in a specific directory and then the directory itself. Simply pass it the absolute (and i think relative path may work as well, well yeah..) of the directory.I wrote it because i couldn&#8217;t find a function to do exactly that. Its [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burrellaramone.wordpress.com&#038;blog=27504715&#038;post=51&#038;subd=burrellaramone&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following is a PHP function that allows u to delete all the files in a specific directory and then the directory itself. Simply pass it the absolute (and i think relative path may work as well, well yeah..) of the directory.I wrote it because i couldn&#8217;t find a function to do exactly that. Its name is remove_user_directory because i initially wanted it to remove a user&#8217;s files from the system. but you can change the name and modify it if u like. I Will further improve on it so that it removes recursively. That should be somewhat tedious. : (</p>
<pre> function remove_user_directory($dir_path){

    $flag=TRUE;//will be returned

    if(!is_dir($dir_path)){$flag = false;}

    else{
    $dir_path_sub_files = array();
    $dir_path_sub_files = scandir($dir_path);
    $number_of_files = count($dir_path_sub_files);

        if($number_of_files!=0){
             foreach(glob($dir_path . "*.*") as $filename){
               if($filename!="."&amp;&amp;$filename!=".."){ unlink($filename);}
             }
         }//end if

         rmdir($dir_path);//remove the empty directory
    }//end else statement

    return $flag;
 }</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/burrellaramone.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/burrellaramone.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/burrellaramone.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/burrellaramone.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/burrellaramone.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/burrellaramone.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/burrellaramone.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/burrellaramone.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/burrellaramone.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/burrellaramone.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/burrellaramone.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/burrellaramone.wordpress.com/51/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/burrellaramone.wordpress.com/51/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/burrellaramone.wordpress.com/51/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burrellaramone.wordpress.com&#038;blog=27504715&#038;post=51&#038;subd=burrellaramone&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://burrellaramone.wordpress.com/2011/11/10/remove_user_directorydir_path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3924e0f46c705f6310b68ea94797df2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">burrellaramone</media:title>
		</media:content>
	</item>
		<item>
		<title>getElapsedTime($timeStamp)</title>
		<link>http://burrellaramone.wordpress.com/2011/10/31/getelapsedtimetimestamp/</link>
		<comments>http://burrellaramone.wordpress.com/2011/10/31/getelapsedtimetimestamp/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 01:05:32 +0000</pubDate>
		<dc:creator>Ramone Burrell</dc:creator>
				<category><![CDATA[open_source]]></category>

		<guid isPermaLink="false">http://burrellaramone.wordpress.com/?p=20</guid>
		<description><![CDATA[The following is a PHP function i constructed while working on a website. It i used to get the time that has elapsed from a timestamp that is passed to it and the current time-stamp. Fell free to use it in your own projects //return type &#8211; string //return examle &#8211; 3 weeks ago, 1 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burrellaramone.wordpress.com&#038;blog=27504715&#038;post=20&#038;subd=burrellaramone&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The following is a PHP function i constructed while working on a website. It i used to get the time that has elapsed from a timestamp that is passed to it and the current time-stamp. Fell free to use it in your own projects</p>
<p>//return type &#8211; string</p>
<p>//return examle &#8211; 3 weeks ago, 1 day 5 hours ago.</p>
<pre> 

&lt;?
  function getElapsedTime($timeStamp,$precision){
  $anArray = array();
  $anArray[0]['name']="Year";
  $anArray[0]['value']=31556926;
  $anArray[1]['name']="Month";
  $anArray[1]['value']=2629743.83;
  $anArray[2]['name']="Week";
  $anArray[2]['value']=604800;
  $anArray[3]['name']="Day";
  $anArray[3]['value']=86400;
  $anArray[4]['name']="Hour";
  $anArray[4]['value']=3600;
  $anArray[5]['name']="Minute";
  $anArray[5]['value']=60;
  $anArray[6]['name']="Second";
  $anArray[6]['value']=1;

  $elapseArray = array();
  $timeDifference=time()-$timeStamp;
  $tempInt=0;

$i=0;
foreach($anArray as $anElement){
  if(($timeDifference/$anElement['value'])&gt;0){
       $tempInt=$timeDifference/$anElement['value'];  
       $tempInt=(int)$tempInt;   
       if($tempInt==1){
          $elapseArray[$i]['name']=$anElement['name'];
          $elapseArray[$i]['value']=$tempInt;
       }elseif($tempInt&gt;1){
          $elapseArray[$i]['name']=$anElement['name']."s";
          $elapseArray[$i]['value']=$tempInt;
       }        
      $timeDifference -=($tempInt*$anElement['value']);
      $tempInt=0;
  }
  $i++;
} 

$elapseArray["elased_time_string"]="";
$i=0;
   foreach($elapseArray as $anElement){
      $elapseArray["elased_time_string"].=$anElement['value']." 
      ".$anElement['name']." ";
      if($i==$precision){  break; }
      $i++;
   }
  $elapseArray["elased_time_string"].="ago";
 return $elapseArray["elased_time_string"];
}

?&gt;</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/burrellaramone.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/burrellaramone.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/burrellaramone.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/burrellaramone.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/burrellaramone.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/burrellaramone.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/burrellaramone.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/burrellaramone.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/burrellaramone.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/burrellaramone.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/burrellaramone.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/burrellaramone.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/burrellaramone.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/burrellaramone.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=burrellaramone.wordpress.com&#038;blog=27504715&#038;post=20&#038;subd=burrellaramone&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://burrellaramone.wordpress.com/2011/10/31/getelapsedtimetimestamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3924e0f46c705f6310b68ea94797df2?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">burrellaramone</media:title>
		</media:content>
	</item>
	</channel>
</rss>
