Location: PHPKode > projects > MySpace > myspace/myspace.class.php
<?php
/* Created by kambodianboi */
/*   MySpace Basic Class   */

class myspace_profile
{
        var $profile;
        var $data;

        // Build up page data
        function myspace_profile($input)
        {
                $this->profile = $input;
                $dataFile = fopen($this->profile,"r");

                if ($dataFile)
                {
                        while (!feof($dataFile))
                        {
                                $this->data .= fgets($dataFile, 4096);
                        }
                        fclose($dataFile);
                }
                else
                {
                        die( "fopen failed for $filename" ) ;
                }
        }

        // Strip function
        function strip($str, $start, $end)
        {
                if(empty($str))
                {
                        return;
                }
                $str_low = strtolower($str);
                $pos_start = strpos($str_low, $start);
                $pos_end = strpos($str_low, $end, ($pos_start + strlen($start)));
                if ( ($pos_start !== false) && ($pos_end !== false) )
                {
                        $pos1 = $pos_start + strlen($start);
                        $pos2 = $pos_end - $pos1;
                        return substr($str, $pos1, $pos2);
                }
        }

        // Get numbers of friends
        function get_friends()
        {
                return trim($this->strip($this->data, "<span class=\"redbtext\">", "</span>"));
        }

        // Get comments return (array)
        function get_comments()
        {
                $tmp = explode("<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\" bordercolor=\"FFffff\">", $this->data);

                $tmp2 = explode("</table> </td> </tr>", $tmp[1]);

                $tmp3 = explode("<tr>", $tmp2[0]);

                for($i=1;$i<count($tmp3);$i++)
                {
                        $comments_xml .= "<u:break>\r\n";
                        // User Profile Link
                        $comments_xml .= "<u:link>".trim($this->strip($tmp3[$i], "<a href=\"", "\">"))."</u:link>\r\n";

                        // User Profile Name
                        $comments_xml .= "<u:name>".trim($this->strip($tmp3[$i], $this->strip($tmp3[$i], "<a href=\"", "\">")."\">", "</a>"))."</u:name>\r\n";


                        // User Profile Link
                        $comments_xml .= "<c:date>".trim($this->strip($tmp3[$i], "<span class=\"blacktext10\">", "</span>"))."</c:date>\r\n";

                        // Profile Comment
                        $comments_xml .= "<c:comment>".trim($this->strip($tmp3[$i], "</span>", "</td>"))."</c:comment>\r\n";

                        $comments_xml .= "</u:break>\r\n";
                }

                return $comments_xml;
        }
}
?>
Return current item: MySpace