juust ~ php oddities

Unordered list of one element
  • rss
  • begin
  • about
    • vcard
    • WTF is BroJesus
  • php scripts
    • flickr wp widget
    • google multi key serp tool, php script
    • gwt plugin
  • php classes
    • php pagerank class
    • fibonacci class
    • robots.txt parser php class
  • serp
    • serp dashboard wordpress plugin
  • services

pressmark – the social bookmarking fork of wordpress

juust | 25/09/2008

Pressmark :
a 5 minute install social bookmarking website : go check it out on the authors site, or my new subdomain pressmark install).

Why Pressmark ? Because its a social bookmarking fork on Wordpress.

I tried Pligg and I just sat there thinking “this is horrible, I want my Wordpress backend!”. And after scouting around what do I find : Pressmark, a wordpress fork. With Pressmark I get the Wordpress backend and all my favorite plugins and all these thingies I love about Wordpress as CMS, just now for a social bookmarking site.

The strong point is the use of OpenId, where a URL pointing to either a blog or website is your ‘identity’ on the net. If sites use an OpenID plugin your entire profile is readily available (name, email, etc.) on every blog or form you care to place your comments.

OpenID lowers user frustration by letting users have control of their login.

For geeks, OpenId is an open, decentralized, free framework for user-centric digital identity. OpenID takes advantage of already existing internet technology (URI, HTTP, SSL, Diffie-Hellman) and realizes that people are already creating identities for themselves whether it be at their blog, photostream, profile page, etc. With OpenID you can easily transform one of these existing URIs into an account which can be used at sites which support OpenID logins.

OpenID is still in the adoption phase and is becoming more and more popular, as large organizations like AOL, Microsoft, Sun, Novell, etc. begin to accept and provide OpenIDs. Today it is estimated that there are over 160-million OpenID enabled URIs with nearly ten-thousand sites supporting OpenID logins.

In Pressmark, by using a ’submit’ bookmarklet to drag on your browser bar, you can enter any site bookmark into your author’s page with 2 clicks.

Fast, sweet.

Sadly in the current pressmark download there is one function missing which causes a code break in the index.php (I hope the author fixes it in the download), causing it to show only an entry form for bookmarks as front-page and leaves you to figure out what the hell the package is about. If you downloaded it and get the “prologue_get_avatar() is missing” error on your front page, add this function in the themes ‘function.php’ file :

  1. function prologue_get_avatar( $wpcom_user_id, $email, $size, $rating = '', $default = 'http://s.wordpress.com/i/mu.gif' ) {
  2.  if( !empty( $wpcom_user_id ) && $wpcom_user_id !== false && function_exists( 'get_avatar' ) ) {
  3.   return get_avatar( $wpcom_user_id, $size );
  4.  }
  5.  elseif( !empty( $email ) && $email !== false ) {
  6.   $default = urlencode( $default );
  7.  
  8.   $out = 'http://www.gravatar.com/avatar.php?gravatar_id=';
  9.   $out .= md5( $email );
  10.   $out .= "&size={$size}";
  11.   $out .= "&default={$default}";
  12.  
  13.   if( !empty( $rating ) ) {
  14.    $out .= "&rating={$rating}";
  15.   }
  16.  
  17.   return "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />";
  18.  }
  19.  else {
  20.   return "<img alt='' src='{$default}' />";
  21.  }
  22. }

…or sooner grab it from automattic svn, bottom of the file.
(cutting and pasting code from blogs can cause problems with quotes and html markup in php code fragments).

After that it renders a proper index page.

Ofcourse the main advantage : wordpress is a seo killer, nothing performs in google as wordpress does, so a social bookmarking site with a wordpress frame is gonna be a strong competitor for the smaller site segment. It won’t outperform Technorati, but normal people don’t usually want to start Technorati-II, a small well performing easy to maintain bookmarking site will do for most of us :)

Comments
4 Comments »
Categories
links, seo, wordpress
Tags
links, php, wordpress
Comments rss Comments rss
Trackback Trackback

blogger auto-poster

juust | 29/08/2008

I needed to get my new linkdirectory’s pages indexed and crawled and google needs some stimulation.

So I take a blogger subdomain,
and a 700 category php link directory
and make a table PLD_TAGCLOUD(CAT_ID, POSTED, TAG, FULLPATH)

CREATE TABLE `PLD_TAGCLOUD` (
`ID` BIGINT( 11 ) NOT NULL ,
`CAT_ID` DOUBLE NOT NULL ,
`POSTED` DOUBLE NOT NULL ,
`LEVEL` DOUBLE NOT NULL ,
`TAG` VARCHAR( 250 ) NOT NULL ,
`FULLPATH` VARCHAR( 250 ) NOT NULL ,
PRIMARY KEY ( `ID` )
) ENGINE = MYISAM

I fill the table with a recursive tree traversal on the category table where “tag” is the ‘title’ field,
and I get the FULLPATH url by using the domain root and the path generated by traversing the tree :

  1.  
  2. function connect() {
  3.  $DB_USER =  "";
  4.  $DB_PASSWORD = "";
  5.  $DB_HOST = "";
  6.  $DB_DATA = "";
  7.  $link =  mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD) or $error = mysql_error();
  8.  if (!$link) {
  9.      echo $error;
  10.   exit;
  11.  } else {
  12.     mysql_select_db($DB_DATA, $link) or $error = mysql_error();
  13.  return $link;
  14.  }
  15. }
  16.  
  17. $link = connect();
  18. $del="DELETE FROM `PLD_TAGCLOUD`";
  19. $mydel = mysql_query($del, $link) or die(mysql_error());
  20. @mysql_close($link);
  21.  
  22. $root='http://links.trismegistos.net';
  23. $content .= read(0, $root, 1);
  24.  
  25. function read($rootid, $pathid, $thislevel) {
  26.  $link = connect();
  27.  $myqry = "SELECT * FROM `PLD_CATEGORY` WHERE `PARENT_ID`='".$rootid."'";
  28.  $myres = mysql_query($myqry, $link) or die(mysql_error());
  29.  if(mysql_num_rows($myres)&lt;1) return;
  30.  while($row=mysql_fetch_assoc($myres)) {  
  31.   $thispath= $pathid ."/".$row['TITLE_URL'];
  32.   $link2 = connect();
  33.   $add="INSERT INTO `PLD_TAGCLOUD` (`CAT_ID`, `LEVEL`, `TAG`, `FULLPATH`) VALUES ('".$row['ID']."', '".$thislevel."', '".htmlentities($row['TITLE'], ENT_QUOTES)."' ,'".$thispath."/')";
  34.   $addit = mysql_query($add, $link2) or die(mysql_error());
  35.   @mysql_close($link2);
  36.   read($row['ID'], $thispath, $thislevel+1);
  37.  }
  38.  @mysql_close($link);
  39. }

note : I also use a field level to store the depth of a category-page (o for root, 1 for main categories and mine goes down to 4)

Then we make a simple routine to grab the first record for posted=0,
grab the url
grab the title
grab 3 posts off of google-blogsearch on the TITLE, add em to an email,
add a link to the category page url,
mail(email, subject, message-body, headers)

and ofcourse the coupe-de-grace, the cronjob, 700 posts, 4 per hour, so in about 170 hours my entire site is listed on a nice juicy blog. Just for the hell of it i put the links of the blogsearch on ‘follow’ so my poor victims get a link as well.

  1.  
  2. function connect() {
  3.  $DB_USER =  "";
  4.  $DB_PASSWORD = "";
  5.  $DB_HOST = "";
  6.  $DB_DATA = "";
  7.  $link =  mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD) or $error = mysql_error();
  8.  if (!$link) {
  9.      echo $error;
  10.   exit;
  11.  } else {
  12.     mysql_select_db($DB_DATA, $link) or $error = mysql_error();
  13.  return $link;
  14.  }
  15. }
  16.  
  17.  $link = connect();
  18.  $myqry = "SELECT * FROM `PLD_TAGCLOUD` WHERE `POSTED`='0' ORDER BY ID DESC";
  19.  $myres = mysql_query($myqry, $link) or die(mysql_error());
  20.  if(mysql_num_rows($myres)&lt;1) return;
  21.  while($row=mysql_fetch_assoc($myres)) {  
  22.   $myurl = $row['FULLPATH'];
  23.   $mykey = urlencode($row['TAG']);
  24.   $link2 = connect();
  25.   $add="UPDATE `PLD_TAGCLOUD` SET `POSTED`='1' WHERE `ID`='".$row['ID']."'";
  26.   $addit = mysql_query($add, $link2) or die(mysql_error());
  27.   @mysql_close($link2);
  28.   break;
  29.  }
  30.  @mysql_close($link);
  31.  
  32.  
  33. $xmlSource="http://blogsearch.google.com/blogsearch_feeds?hl=en&c2coff=1&lr=&safe=active&as_drrb=q&as_qdr=d&q=".$mykey."&ie=utf-8&num=3&output=rss";
  34. $title="";
  35. $link="";
  36. $description="";
  37. $author="";
  38. $pubDate="";
  39. $currentElement="";
  40. $nieuwsitems = array();
  41.  
  42. function startElement($parser,$name,$attr){
  43.  if(strcmp($name,"item")==0){
  44.  $GLOBALS['title']="";
  45.  $GLOBALS['link']="";
  46.  $GLOBALS['description']="";
  47.  $GLOBALS['author']="";
  48.  $GLOBALS['pubDate']="";
  49.  }
  50.  $GLOBALS['currentElement']=$name;
  51.  if(strcmp($name,"link")==0){ $GLOBALS['href']=$attr["href"]; }
  52.  
  53. }
  54.  
  55. function endElement($parser,$name){
  56.  $elements=array('title','link','description','author','pubDate');    
  57.  if(strcmp($name,"item")==0){
  58.   foreach($elements as $element){
  59.    $temp[$element] = $GLOBALS[$element];      
  60.   }
  61.  $GLOBALS['nieuwsitems'][]=$temp;
  62.  $GLOBALS['title']="";
  63.  $GLOBALS['link']="";
  64.  $GLOBALS['description']="";
  65.  $GLOBALS['author']="";
  66.  $GLOBALS['pubDate']="";
  67.  }
  68.  if(strcmp($name,"item")==0){
  69.   $GLOBALS['title']="";
  70.   $GLOBALS['link']="";
  71.   $GLOBALS['description']="";
  72.   $GLOBALS['author']="";
  73.   $GLOBALS['pubDate']="";
  74.  }
  75. }
  76.  
  77. function characterData($parser, $data) {
  78.  $elements = array ('title', 'link', 'description','author','pubDate');
  79.  foreach ($elements as $element) {
  80.   if ($GLOBALS["currentElement"] == $element) {
  81.    $GLOBALS[$element] .= $data;
  82.   }
  83.  }
  84. }
  85.  
  86. function parseFile(){
  87.  global $xmlSource,$nieuwsitems;
  88.  $xml_parser=xml_parser_create();
  89.  xml_set_element_handler($xml_parser,"startElement","endElement");
  90.  xml_set_character_data_handler($xml_parser,"characterData");
  91.  xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,false);
  92.  if(!($fp=fopen($xmlSource,"r"))){
  93.   die("Cannot open  $xmlSource  ");
  94.  }
  95.  while(($data=fread($fp,4096))){
  96.   if(!xml_parse($xml_parser,$data,feof($fp))){
  97.    die(sprintf("XML error at line %d column %d ",
  98.    xml_get_current_line_number($xml_parser),
  99.    xml_get_current_column_number($xml_parser)));
  100.   }
  101.  }
  102.  xml_parser_free($xml_parser);
  103.  return $nieuwsitems;
  104. }
  105.  
  106. $result = parseFile();
  107.  
  108. foreach($result as $arr){
  109.  $strResult .= '< hr />';
  110.  $strResult .= '< h4>'.$arr["title"].'< /h4>'.$arr["description"].'< br /><a href="'.$arr["link"].'" title="'.$arr["title"].' ('.parse_url($arr["link"], PHP_URL_HOST).')">"'.$arr["title"].' ('.parse_url($arr["link"], PHP_URL_HOST).')</a>< br />< br />';
  111. }
  112.  
  113. $strResult .= '< br /> < a href="'.$myurl.'" title="'.$mykey.'">trismegistos links : '.$mykey.'< /a>< br />';
  114.  
  115. $email='juustout.linkdirectory@blogger.com';
  116. $subject = $mykey;
  117. mail($email,$subject,$strResult, "MIME-Version: 1.0\n"."Content-type: text/html; charset=iso-8859-1");
  118.  
  119. echo $strResult;

(note the html markup in the last lines is < br />, if you cut and paste it, remove the space or you get a mess, also note the extra header in the php mail function, makes it possible to post html-marked up text (otherwise you get flat text posted and your site looks like ****).

Comments
2 Comments »
Categories
links, php, seo
Tags
php, seo, tool
Comments rss Comments rss
Trackback Trackback

phpLD mod : context sensitive RSS

juust | 21/08/2008

(in case you’re wondering : this is about a small rss plugin for a php link directory site I am setting up, see example : links.trismegistos.net/blogs/).

I tried some free RSS mod but that dont work, I get the same yahoo rss feed on every page. I want context sensitive rss.

Why ? to improve my keyword/content ratio per page and get more pages indexed. I hear 2-5% (1 in 50/20 words) is the ideal ratio if you want to be considered a highly relevant result page on the keyword-content ratio. A list with website links in the category ‘music – classic’ has a very high ratio keyword/content and google won’t index the page. Adding a pot-luck grab of google blogsearch results might level that a little.

So I am gonna add some relevant fresh rss feeds from google blogsearch.

Same trick as the pagerank plug-in, the last part of the url contains the subcategory, I can use these as keywords for google blogsearch :

  1. $PT = $_SERVER["REQUEST_URI"];
  2. $ttl = explode('/', $PT);
  3. $mykeys = $ttl[count($ttl)-2];
  4. $mykey=trim(preg_replace('/_/', ' ', $mykeys));
  5. $xmlSource="http://blogsearch.google.com/blogsearch_feeds?hl=en&c2coff=1&lr=&safe=active&as_drrb=q&as_qdr=d&q=".urlencode($mykey)."&ie=utf-8&num=5&output=rss";
  • I take the URI
  • explode it on the / slashes
  • take the last text
  • replace ‘_’ with spaces
  • and urlencode the keywords for google blog-search.

A generic rss parser handles the xml file, i delimit it to 5 results to keep traffic down. I add some class markers in the script to be able to add extra markup in a .css file, and I save the result to $thisfeed.

  1.  foreach($result as $arr){
  2.  $strResult .= '<div class="rssdiv">';
  3.  $strResult .= '<div class="rss_title"><h3>'.$arr["title"].'</h3></div>';
  4.  $strResult .= '<div class="rss_description">'.$arr["description"].'</div><br />';
  5.  
  6.  $strResult .= '<div class="rss_link"><a href="'.$arr["link"].'" rel="nofollow" title="'.$arr["title"].'">more: "'.$arr["title"].'"</a></div>';
  7.  $strResult .= '</div>';
  8. }
  9.  
  10. $tpl->assign('thisfeed', $strResult);

I call the store feed in the footer with {$thisfeed}
and include the sourcefile in index.php with
require_once ‘readrss.php’;
just below require_once ‘init.php’;

See example : links.trismegistos.net/blogs/

Now I am going to add a single google adsense slot, not too loud, just enough to get Google to come crawl the pages to assert the context. Then I need to resubmit the sitemap. And that’ll be all for today.

(readrss.php text source)
for the record, consider it GPL’ed (it ain’t exactly rocket science)

Comments
No Comments »
Categories
links, optimization, php
Tags
links, php, seo
Comments rss Comments rss
Trackback Trackback

« Previous Entries Next Entries »

Recent Posts

  • geert wilders
  • gone till september
  • socialize me
  • Pagerank sculpting session
  • wish you were here

click me!
rss
Comments rss
Blog Directory
Web Developement Blogs - BlogCatalog Blog Directory
Listed in LS Blogs the Blog Directory and Blog Search Engine
Blog Flux Directory
joopita.com free web directory and search engine
design by jide
sitemap
22258 confirmed spam kills