Posts Tagged ‘javascript’

Wordpress theme hacked?

Friday, February 5th, 2010

I’ve been using a WordPress theme created by Jorge Gomez at switchroyale.com and have been very happy with it.  I logged on today to get a bit of info from one of my earlier posts and noticed that after ~5 seconds after the page loaded my site was redirecting to a seemingly random website.

I started some debugging and first deactivated my AdSense plugin thinking that was the culprit.  It turns out that the theme was loading some javascript from an external site and was executing the redirect.

I was using Azul 1.4 and noticed there was an upgrade available and I updated my site to Azul 1.51.  This did not solve my problem.  I’ve reverted back to an old WordPress default theme and the problem went away.  I’ve sent an email to Mr. Gomez to let him know about the issue.  I hope that it’s either a simple error or that his site was hacked (I’m not being mean).  I’d much rather believe that his site got hacked than if he decided to start screwing with people themes out of malicious intent.

I’m happy to give him the benefit of the doubt until I learn otherwise.  I’ve included the email that I sent him below:

Hey I just wanted to let you know that I’ve been using your theme for awhile and have enjoyed it, but today I noticed that there is some javascript coming through on your theme that is causing my site to redirect to a seemingly random website after the site is loaded for ~5 seconds.

I had been using Azul 1.4, but after noticing this issue I upgraded to Azul 1.51 and am still getting this issue.  I’ve reverted back to an old default WP theme and the issue went away and when I reactivated your theme the issue came back.

I don’t know if you are aware of this issue or whether your site might have gotten hacked.

Just wanted to let you know.

Hope this gets resolved.

I’ll update this post as needed.

Till Next Time

Adding javascript to symfony form field

Tuesday, November 17th, 2009

In the users table at my company’s website there are fields for company, division, region, and location. Since each level of the company organization affects all the lower categories I have to filter out the invalid choices when a higher level choice is selected.

I’ve implemented this on some forms that I’ve created manually on the site but not in any forms that I haven’t heavily modified from the stock symfony creation.  I started googling around to find a solution but could not find a simple explanation of how to do it.  I expected to find at least some information in one of symfony’s otherwise excellent tutorials, but alas, no.

I had a minor epiphany and went digging through the forms API that symfony provides and realized that I should easily be able to do this through the sfWidgetFormPropelChoice method.  The second parameter passed is the html attributes for the form field.  I thought I had seen a form post here that said that I could add javascript code to the html attributes and not have it get converted into html entities.

I tried throwing a simple alert() inside the onchange attribute for my company box and wham! it worked!  So simple.  Code below:

new sfWidgetFormPropelChoice(
	array(
		'model' => 'Company',
		'add_empty' => true
	),
	array(
		'onchange' => "filterBy('company', 'division', this.value, 'sf_guard_user_user_division_id');" .
			"filterBy('company', 'region', this.value, 'sf_guard_user_user_region_id');" .
			"filterBy('company', 'location', this.value, 'sf_guard_user_user_location_id');"
	)
)

Till Next Time

IE 7 javascript bug

Friday, November 6th, 2009

In a form that I administer at work I have a javascript filtering function for a few select boxes.  It is called whenever the first select box changes and removes the ineligible options from the second select box.  Simple.  Straight-forward.

It doesn’t work in IE 7, works fine in IE 8, Firefox, Chrome.  But we have many clients that are stuck in IE 7 or even IE 6.  I sat down to figure this out and realized that my IE debugging tools aren’t nearing as good as my Firefox debugging.  In Firefox I use Firebug, but in IE I use the built in Developer Tools (DT).

The one big difference between these two plug-ins for this particular problem is that DT doesn’t live update the code of the page when it is changed with javascript.  You must manually refresh the code inside of DT.  Once I discovered this I was much more productive.

But onto the problem.  I discovered that when I was creating the ‘filtered’ select box, I was actually just wiping the original box out and creating a new one from scratch.  In this new select box all the attributes were correct except for the name.  Instead of the attribute being called ‘name’ it was being called ’submitName’.

I googled that and the only relevant thing that I could get was an experts-exchange link that I refuse to use.  I have a problem with a website charging people for solutions to simple code problems.  Whenever I get google results for that site I remove it from my results.

I ended up reworking my code to actually filter out the unwanted options when the first select box is changed.  But in case someone else has had the problem that I’m having and knows the solution, I will post the code that I was using to create the select box.

function createSelect(parent_cell, name, id, options, option_values, classs, onchange, removeChildren)
{
	// classs is misspelled cause otherwise IE thinks it is a Class
	try
	{
		var par_cell = document.getElementById(parent_cell);
		var sel_box = document.createElement('select');
		sel_box.setAttribute('name', name);
		sel_box.setAttribute('id', id);
		sel_box.setAttribute('onchange', onchange);
		sel_box.setAttribute('class', classs);
 
		var first_opt = document.createElement('option');
		first_opt.value = '';
		first_opt.text = 'Select an Option';
		sel_box.options.add(first_opt);
 
		for(var i=0;i<options.length;i++)
		{
			var opt = document.createElement('option');
			opt.value = option_values[i];
			opt.text = options[i];
			sel_box.options.add(opt);
		}
		if(removeChildren)
			removeAllChildren(parent_cell);
 
		par_cell.appendChild(sel_box);
	}
	catch(err)
	{
		alert("There was an error creating the options menu: " + err);
		return false;
	}
	return true;
}

Till Next Time

soooo, this is like an all new blog

Friday, February 27th, 2009

so it’s been years, literally, not just in a tech sense, since the last time I wrote a blog post.  I have been meaning to start this back up for a little while now that I have a real job and am out of school.  But you know how things always seem to get in the way.  I finally found a nice, new, clean domain name….heehee.  I love my new domain. :-)

 

So, life.

 

Recently have split with my girlfriend of a few months.  Started my third job out of college in the span of 14 months.  Have started doing some web projects for other people, a little money on the side never hurt.  Am getting stoked about the new Palm Pre.  Am living in Decatur, GA, in a 3/1.5 house by myself, waiting for my fantastic sister-in-law to find someone to rent the house so I can move out.  

Current loves:

my car:  2006 VW Golf GLS

my job: web developer 

hometown: atlanta

 

Current non-loves:

my living situation: no cool roommate(s)

computing power:  need a new desktop bbbaaaadddd

friends:  they live too far away

 

So today I bought my first new computer in ~4 years.  A Dell Mini 9.  I saw on engadget that Dell was having a $199 sale on them and that hit my impulse buy price.  I added a integrated webcam and messenger bag for it and off my order went.  It sucks that the estimated ship date is St. Paddy’s day, but oh well, at least I got a great deal on my lappie.  In a few months I plan on completely overhauling my desktop computer.  It’s currently running something like single core 2.4 GHz, 512MB RAM, 32MB Video Card, all from ~4 years ago.  I plan upping the specs to Core i7 920 (2.66GHz quad core), 4-6GB RAM, 512MB Video card.  This should definitely improve my computing experience at home.  I’m also planning on installing the windows 7 beta.  I had installed it on my workhorse laptop, but with it being 4 years old, I don’t think 7 really agreed with it cause it started crashing more than it was running.  But anyway, onwards and upwards!

 

I am really looking forward to the new Palm Pre.  Before it was announced, I felt that Palm was starting it’s death rattle.  They hadn’t put anything exciting out in a few years and was having internal struggles which is indicative of a dying company.  But Palm surprised the entire tech community at CES 2009 when they introduced the Pre and webOS.  No one saw this coming, there weren’t any leaks or buzz surrounding Palm before their keynote.  After the keynote, Palm was all anybody could talk about.  As soon as I heard that there was going to be a development camp in Atlanta, I signed up for it and voluteered.  I figured it was time to get into the tech community in Atlanta and hopefully meet some new people down here.  There is not a date set for preDevCamp yet, but I’m hearing that it will be about a week after the Pre actually launches.

 

Last night I watched the hour long webcast that Palm’s Software CTO Mitch Allen put on.  He only provided general information about the Pre and webOS, but it was encouraging to see how simple it will be to create an app on the Pre.  I need to start brushing up/learning javascript now.  :-)

 

So I’m about out of info for this first post in a while.  Be back more often from now on.

 

Till Next Time