August, 2007 » Archiv


Comments Off

Write text to a .png with php

August
31

I just read a wicked tutorial on DiscoMoose on how to add text onto an existing png file and now I’m ready to make my next widget! it’s going to be a custom link box with a variety of button styles to choose from. Choose any text and the button will be displayed with the text on there.

It might save a lot of trouble for newbies who don’t have experience in coding or if someones best image app is MSPaint!

here’s my first test to see if I could run the code..

dynamic button

it is called with http://www.fiddyp.co.uk/internal/testingphp/png.php?text=woot!

here is the code for png.php
[php]
// load the image from the file specified:

$im = imagecreatefrompng(“button.png”);
// if there’s an error, stop processing the page:
if(!$im)
{
die(“”);
}
// define some colours to use with the image
$yellow = imagecolorallocate($im, 255, 255, 0);
$black = imagecolorallocate($im, 0, 0, 0);
// get the width and the height of the image
$width = imagesx($im);
$height = imagesy($im);
// draw a black rectangle across the bottom, say, 20 pixels of the image:
//imagefilledrectangle($im, 0, ($height-20) , $width, $height, $black);
// now we want to write in the centre of the rectangle:
$font = 4; // store the int ID of the system font we’re using in $font
$text = $_GET['text']; // store the text we’re going to write in $text
// calculate the left position of the text:
$leftTextPos = ( $width – imagefontwidth($font)*strlen($text) )/2;
// finally, write the string:
imagestring($im,$font,$leftTextPos-1, $height-35,$text,$black);
imagestring($im, $font, $leftTextPos, $height-36, $text, $yellow);

// output the image
// tell the browser what we’re sending it
Header(‘Content-type: image/png’);
// output the image as a png
imagepng($im);
// tidy up
imagedestroy($im);
[/php]

yey!

Code


Comments Off

A mybloglogdogg – against TOS?

August
31

MyBlogLog DOGGI had some fun today programming a bot, or, I like to call it a dog. More accurately a MyBlogLogDogg.

It’s a php program that has the ability to visit my BlogLog home page and grab all the contacts, it then goes and visits all those contacts pretending to be me, it grabs their contacts and goes and visits them and can continue doing this on multiple levels and threads.

Every single person that the dogg visits will have my profile picture on their profile page as a recent visitor. I’ve only tested it for my own profile pages (mine and my work one) as I don’t think it’s really the sort of thing that MyBlogLog would allow.

Could be cool though to set it off running through the MyBlogLog profile pages and distribute my mugshot on all 2000+ members. People always like to click on the face of their latest profile viewer so I think it’s a pretty cool way to get some social hits to here!

I’m not doing too bad, this blog was born on 26 August 2007 and has averaged 50 hits a day so far, that’s before I add a “blog has moved” sign on my old blog and before I add the link to my other sites. I should be able to get it up to 100 a day using this method, especially if I train the dogg to use other sites that use “people who viewed this page” gadgets…

Go fetch boy! :)

Code


Comments Off

UK Lotto Results and Euromillions Results Widgets

August
30

Lottery Ballsphew! I just made 2 new widgets to show the UK and Euromillions Lottery results, it took all of 20 minutes! hehe, these widgets are getting easier and easier to make!

These ones parse an external site for the results so I think I need to work on a cache type thing so it doesn’t have to go outside every time someone views the site. The site it grabs the results from tends to have them very early and the feed is easy to parse so as long as there’s not too much traffic, it wont place any undue pressure on an external page. oh wait, maybe I could add some php to only parse the site every 10 minutes… 6 times an hour isn’t too much pressure to put on any page!

I’m off to tweak!

Blog News


Comments Off

uVme – A Social Marketing Phenomenon

August
30

With all the hoo-hah being hoo-hah’d on the news and internet about how Facebook, YouTube, BeBo, King.com,Network Marketing, Blogs, Instant Messengers, Multiplayer games and Online Skill Games are growing at a phenomenal rate. Isn’t it about time someone put together an entire package of tools that could tap into that market? If they did, they would be the FIRST company to ever launch a business that encapsulates the top 3 :

  • Online Games Entertainment
  • Social Networking using Web 2.0
  • A new way of network marketing, described as Social Marketing/Network Marketing 2.0
  • Let’s analyze these a little more…

    1. Online Games Entertainment
      • Even in countries where PC ownership is quite small, Internet cafes are commonplace, heavily frequented and affordable to their customers, in many cases open around the clock, 30-40% of their revenue comes from people playing games online.
      • Peoples Productivity at work is improved! A WorldWinner survey (May 2007) showed that 76% of those who play intermittently at work achieve improved job performance.
    2. Social Networking
      • Facebook was founded just 3 years ago by a university student, it is now the 18th most visited web site in the world.
      • The average Westerner has more friends than two years ago, and the rise is attributed to the explosion in Social Networking sites and communication phenomena such as email and Instant Messaging.
      • The Neilsen/Netratings report (May 2006) stated that Social Networking sites grow 47% year over year, reaching 45% of web users
      • Millions of people daily are having fun with Social Networking: it is real, massive and will continue to grow.
    3. Instant Messengers
      • Instant messengers (IMs) such as Windows Live Messenger, AIM (AOL Instant Messenger), Google Talk and Yahoo! Messenger are now commonplace. More than half the UK population regularly use Windows Live Messenger to stay in touch with friends.

      • Windows Live Messenger: 155 Million total users
      • AIM: over 100 Million total users
      • Jabber: 90 Million users
      • Yahoo! Messenger: 22 Million users
      • </ul.

    I’m part of that company… I’ve been part of it for 3 years, I’ve recruited hundreds into it, earned thousands from it and showed others how to the same. I’ve even made entire sites for the team for training and support, I’ve made a popular series of affiliate training videos that continues to train more than just my team (it earns a fair bit in Adsense too!).

    And now, I’m ready to share with you how I will do it with uVme.

    I urge you to download this special insiders report, its completely free. Please visit my company domain www.UKOEM.com and enter your details to see why I’m so excited by this new product coming to the market. After this, network marketing will never be the same again.

    uVme - Social Marketing


    Comments Off

    LOL Cats – the art of badly grammared text over cute cat pictures.

    August
    29

    I’ve been having a right larf at LOL Cats pictures lately, here’s one that made me laugh recently..

    LOLcat Cookie
    Source

    There’s even a whole site dedicated to them… LolCats

    Funnies


    Comments Off

    Widget for hiding an affiliate site cookie on your blog

    August
    29

    I made another widget! I had a hard few hours trying to figure out why my last widget wasn’t saving it’s options, I had to go through every single bit of code to figure it out and it turns out that I had missed an equals sign! just a piddly little character can throw a spanner in the works!

    Now I know whats up, I can churn out widgets left, right and center!

    Here’s my latest one…

    It’s called GetCookie, it’s a widget that can’t be seen.
    Just input your affiliate site URL into the options and save. The widget will add a hidden layer to the html and load the affiliate site in the background without the user knowing.

    What’s the point? hehe, the point being ;

    If someone visits this blog, they will receive the cookie my affiliate site sends when a user surfs there via my affiliate link. They can then go off and carry on surfing, if they come across the site without an affiliate link (ie. if they search Google for the product and click through direct to the company url from the results shown) then the affiliate site will think that they came through my link because of the cookie they got when they visited my blog.

    The widget obfuscates the code so someone looking at the source wont be able to see the call to the affiliate page. (the previous post about decoding bin2hex gives a hint at the obfuscation code)

    Here’s the options on the widget:

    Get Cookie options

    I only wrote it for myself so I didn’t have to manually put the code into the template code. You can download it here:

    GetCookie Widget

    Download and extract file, upload getcookie.php into your plugins directory and activate it. You can then see “get cookie” in your widgets tray, drag it to your sidebar and click the options icon to add your affiliate url (as above) and you should be good to go.

    I’ve tested it with a few different affiliate links in Firefox and it worked. If you have any problems with it, let me know. Note: if your affiliate site has a break frames function on it’s page then this widget wont behave.

    If your affiliate company finds out you’re using a method like this then you’ll probably be banned!!

    Wordpress


    Comments Off

    code to reverse a bin2hex() function

    August
    29

    [php]function hex2bin($data) {
    $len = strlen($data);
    for($i=0;$i<$len;$i+=2) {
    $newdata .= pack(“C”,hexdec(substr($data,$i,2)));
    }
    return $newdata;
    }[/php]

    just pass it the hex string and it will return the decoded data:
    [php]
    $coded=”68656c6c6f”;
    $decoded=hex2bin($coded);[/php]

    Code


    Comments Off

    Stumbleupon widget for wordpress

    August
    28

    AFAIK this is the first stumbleupon widget for wordpress 2.2 and above!

    this post is now here (and so is the widget!)

    Stumbleupon Wordpress Widget – Stumbled

    Wordpress


    Comments Off

    Code to redirect surfer from a no 'www' address

    August
    28

    This bit of code sends everyone to the same address whatever they used (http://fiddyp.co.uk goes to http://www.fiddyp.co.uk, also redirects .com addresses to the .co.uk one)

    
    
    if ($_SERVER["HTTP_HOST"] != "www.fiddyp.co.uk") {
    
      header("Location: http://www.fiddyp.co.uk");
    
    

    pretty sweet little function, put it in your header and google wont think www.you.com is different from you.com and penalize you for having duplicate content.

    Code


    Comments Off

    Text Between Strings PHP

    August
    28

    here’s a useful function that I found in the comments of a php.net function reference to quickly extract the text between two given strings, useful for parsing XML documents or HTML. I’ve used it to parse lotto results, XML favorites and grabbing <img> links by fopen’ing a HTML file.
    $text is the string you want to parse
    $s1 is the start string
    $s2 is the end string

    [php]function get_between ($text, $s1, $s2) {
    $mid_url = “”;
    $pos_s = strpos($text,$s1);
    $pos_e = strpos($text,$s2);
    for ( $i=$pos_s+strlen($s1) ; (( $i<($pos_e)) && $i < strlen($text)) ; $i++ ) {
    $mid_url .= $text[$i];
    }
    return $mid_url;
    }[/php]
    for example if this is a string in the variable $line in a file you are parsing
    “<img>http://www.imageurl.com/image.gif</img>”
    you can extract the url by using the function like this
    [php]$imageurl=get_between($line,”“,”“);[/php]

    Code