Archive for January, 2011

Found a work!!

Hi everyone!
Yesterday a company called me and asked me to work with them(PHP and MySQL)
They pay 600 euros each month(80 hours)
I hope I get enough time to keep working for free plugin for you guys 🙂

And btw if you have any idea for plugin don’t hesitate to tell me

p.s:I just added a new option to CustomComment plugin(required fields) check it out:D


1 Comment

Drag Image

Hi everyone
Last week I got my new mac pro and started programming for iphone xcode 3.2
In this tutorial Brandon explains how to drag an image around the screen
In my case there was a problem in simulator(I don’t know if the same happens in real iphone or no)
In Brandon’ tutorial when you try to drag the image it doesn’t work well and the image jumps to the right upper corner of the screen
In jaipn’s comment he makes the code better but with the same problem

So i came up with this code which the image will be dragged perfectly(I used Brandon’s tutorial and jaipn’s improvement)
There is constant(ONLY_ON_OBJECT) that let you chose two different way of dragging
with ONLY_ON_OBJECT = 1 the image will be dragged only when you click on it
with ONLY_ON_OBJECT = 0 the image will be dragged even if you don’t click on the image

I couldn’t find an easy method to take the image’s width and height so I directly used image’s info(100×100)
I hope you enjoy this code

.m file

#import "iDragImageViewController.h"
@implementation iDragImageViewController
@synthesize cloud;
#define ONLY_ON_OBJECT 0
// 1 – drags only if touched location is inside the cloud’s rectangle
// 2 – offset from touched location to cloud center remains constant during the drag
-(BOOL) hitFirstSubview:(CGPoint)location {
BOOL hit = NO;
UIImageView *subview = (UIImageView *)[[[self view] subviews] objectAtIndex:0];
if (subview != nil) {
CGRect rect = [subview frame]; // in view’s coordinates
hit = CGRectContainsPoint(rect, location);
return hit;
// respond to touchesBegan – mouseDown
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.window];
BOOL hit = [self hitFirstSubview:location];
if (( - 50 location.x && - 50 location.y) || ONLY_ON_OBJECT == 0) {
isOnObject = true;
else {
isOnObject = false;
cloudTouchedOffset = CGPointMake(0.0, 0.0);
if (hit) {
CGFloat xPoint =;
CGFloat yPoint =;
cloudTouchedOffset = CGPointMake(xPoint - location.x, yPoint - location.y);
// respond to touchesMoved – mouseMove
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.window];
// in touchesBegan we stored the offset btw location and (if hit)
// and now use it in dragging, so that center does not snap to the location
// move only if touch is inside the subview
if ([self hitFirstSubview:location]) {
// = location; // basic
if (isOnObject) {
CGPoint newLocation = location;
newLocation.x += cloudTouchedOffset.x;
newLocation.y += cloudTouchedOffset.y; = newLocation;
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
- (void)dealloc {
[super dealloc];

.h file

@interface iDragImageViewController : UIViewController {
IBOutlet UIImageView *cloud;
CGPoint cloudTouchedOffset;
BOOL isOnObject;
@property(nonatomic,retain) IBOutlet UIImageView *cloud;

, , ,


More about CustomComment plugin

CustomComment plugin lets you to add more fields to comment form
When a user post a comment the extra fields data will be visible only to admin
In the setting page of the plugin you can add, edit, delete, activate or deactivate extra fields
With deactivating an extra field the data of that field won’t be removed but when you delete an extra field all associated data will be removed from comments.
For adding an extra field there are two input box
Name: is the identifier of the extra fields and you can see it only in the extra fields table(will be used as the key)
It should be unique and can only contain alphabetic letters, space and _
If you enter another character the plugin will remove that character
Description: This part will be visible in the comment form and can contain any character.

In the comments page you can see a link(Info) that will lead you to a page which you can see the value of extra fields of the user(if he has filled them)!

I hope you enjoy this plugin
To support the plugin please consider donation


Custom Comment

I really love programming plugins
It has just been 3 days that I have learned how to program wp-plugins
Yesterday I checked the Ideas page of wordpress and I saw an idea about letting users define more fields for comment form.
So I just tried to do it and after lots of searching I found all of the things i wanted!(What I needed was the actions and filters for comments)

Read more about this plugin.



In following of the last post…
After finishing protect_content function I thought I can use it in wp too
So I tried to learn how to make a plugin for wordpress
At the beginning it was really hard but after an hour I got used to it And i finished writing a simple plugin in 5 hours(lots of time XD)
Download the plugin HERE
I hope you enjoy it
Have a good day

, , , , , ,


Protect Content Function

Hi everyone
Last night I wrote a function to protect content of my site
For whoever has a site and wants to use my function here is the function
* I used simple_html_dom class in this function, you can download it here Simple html DOM

function protect_images($text, $protect_images = true, $protect_text = true){
$html = str_get_html($text);
$image_original = array();
$image_protected = array();
if ($protect_images)
foreach($html->find('img') as $element){
$src = $element->src;
$width = $element->width;
$width_p = $width + 2;
$height = $element->height;
$height_p = $height + 2;
$element->outertext = '

if ($protect_text)
return '


return $html;

, , , ,

Leave a comment