Posted by & filed under article.

During an implementation of vSlider for my wordpress, I discovered later on that it disables the insert new media button when trying to insert a image into a blog post. While it works perfectly to open the add media and upload and browse images, it is not possible to insert the selected image  into the article.

During debugging of the vSlider plugin I discovered where things went wrong. In the file custome.js located in includes/js/custom.js

On the proximate line 210, there is a function assignment to window.send_to_editor that assigns a new callback function. Now this overrides the send_to_editor function that is already assigned when the vSlider plugin is loaded.

window.send_to_editor = function(html) {
  imgurl = jQuery('img',html).attr('src');
  jQuery('#image_path'+id).val(imgurl); /*assign the value to the input*/
  tb_remove();
};

Since this JavaScript is loaded for all the admin-pages, the quick solution would be to restrict the JavaScript to only be loaded when required.

The solution to this, is to locate the register.php in plugins/vslider/includes/. Edit register.php and look for the original line

add_action( ‘admin_footer’, ‘enqueue_vslider_admin_scripts’ );

This function adds all JavaScript functions that vSlider requires on every admin page. Now as mentioned, these files are added to the admin_footer, which is located on every admin page. So when the script custome.js is loaded, it will not work as it is overwritten.

By changing the add_action( ‘admin_footer’, ‘enqueue_vslider_admin_scripts’ ); to add_action( ‘admin_enqueue_scripts’, ‘enqueue_vslider_admin_scripts‘ ); and adding a if statement in top of the function, checking for the plugin page to be vSlider (see code below) we can tell WordPress to only load the vSlider files, when actually needed in WordPress.

function enqueue_vslider_admin_scripts($hook) {
    if( 'toplevel_page_vslider' != $hook )
        return;
    wp_enqueue_script('media-upload');
	wp_enqueue_script('thickbox');
	wp_enqueue_script('jquery-ui-core');
	wp_enqueue_script('jquery-ui-sortable');
	wp_enqueue_script( 'prettyPhoto-js', VSLIDER_URL.'/includes/js/jquery.prettyPhoto.js', array('jquery'));
	wp_enqueue_script( 'flexslider', VSLIDER_URL.'/js/jquery.flexslider-min.js', array('jquery'));
	vslider_global_settings();
	global $vslider_script;
	echo '<script type="text/javascript">'.$vslider_script.'</script>';
	wp_enqueue_script( 'ajax-script', VSLIDER_URL.'/includes/js/custom.js', array('jquery'));
}
add_action( 'admin_enqueue_scripts', 'enqueue_vslider_admin_scripts' );

Hope they make an update for this soon, as vSlider is a great plugin for WordPress.

Posted by & filed under article.

In my latest discovery of web-sockets and its potential I started playing with different ideas build on the Amazon AWS cloud. The resulting idea is to make a quiz where you need to supply the answers in QR fashionable way. You open the quiz on your phone by scanning a QR code taking you to the webpage with the quiz. Once the quiz is loaded, a web-socket connection is established. Continuing to the quiz overview you are allowed to select the first question before you can continue. This question needs to be solved before one can continue. While opening the question you are presented with the question and a text field to make your answer. Once pressing the button to answer your answer is converted to a QR code. This QR code is encoded with a identifying token, the number representing which question you are replying as well as the answer it self. In order to continue the quiz, you will need to scan your QR code in the camera to the hosts machine or the quiz master machine. The QR image is decoded and the answer is checked. The hosts machine will then message the client browser and depending on your answer if it was right or wrong, the browser will then automatically navigate to a response page.

communication

This kind of loop makes it possible for the user to search for the question from anywhere, but in order to check its correctness the user is required to bring the phone back to the hosts machine and get the answer validated. The solution might not be politically correct as the user are allowed to use any form of help to reach the question and it serves more as a playful approach to the way quizzes are held.

desktopscanner

Above is a screenshot from the desktop machine also known as the quiz master. The webcam feed is shown in the upper left corner to help the users to navigate the QR code accordingly to the webcam. To indicate that the QR code is valid and converted, a green box pops up to give a visual feedback that it has successfully got the content from the QR.

 

Posted by & filed under article.

Yeah, seems like we finally got here. Joomla have lost the battle against WordPress, most due to its inconvenient user interface and customization and not to forget the users perspective of whats expected usage. “No need to bring an army to a battle of chess”.

As updates are done and wildly experimenting with rerouting and reorganizing my stuff will show that none of the “casual” links will work any more. The temporary image service has been relocated here: http://upl.olavz.com Enjoy!

For whats to come, my current development evolves C# development in Unity 3D with ReacTIVision integrated user interface. This is extremely exiting and I will make sure to make an update asap!

Posted by & filed under article.

It seems like the user is more willing to click on a link presented on Facebook by “trusted” friends and acquaintances. The tolerance bar is lowered and the level of acceptance for approving and checking out user posted links, seems extremely low. It still baffles me the way some links screams out; “See what this collage student did this summer break”, where it also screams out; “Do not click this, probably a scam”. Although not all people see these warning signs and live in good faith that a friend wont post anything that might harm or abuse your account. I have already mentioned how linked titles may drag people towards clicking them. Further I would like to introduce a second way of deception and make you aware of such challenges you may face when browsing the friends feed.

Back in October I faced a bogus friend request on Facebook. At first it was ignored as the user account had just been created and I did not know this person. Later that month I did recall from one of my classes that certain people with evil intentions would use Facebook to gain personal access. At that point I assumed the unknown Facebook person was a classmate that would like to have fun and prank fellow students. At the end of the month the unknown account had added my school as a network and soon we had 32 friends in common.

In order to figure out who this person was, I would first require their IP address to determine where it was located. At first I made a simple PHP script that extracts location and browser information. I gathered all information segments from $_SERVER. If your interested in what information it contains, just use print_r($_SERVER) to list every thing.

I now had a way of acquire the information that’s easy to extract. However I would need to get the user to access this unique link and I needed an approach that would make it irresistible for the user to access the link. Then I got the idea! Why not use an image? When you add a link to Facebook or include it in a message, Facebook will automatically bring a thumbnail of the image inside with the message. I engineered the file image.php that will output the image itself and extract the location and browser information and serve this information to my mail inbox. Now just linking the full link of my website and image.php might throw the unknown user off and result in a failed attempt, I had to make it more reliable.

Creating a .htaccess document was the solution. By enable the rewrite engine on my server directory I could make fake.jpg point at the file image.php. This will mean that when someone accesses the fake.jpg they will see an image and they will see the file extension .jpg although what the server is presenting is image.php. At this point I am good to go, however I would like to give the user a feedback of, “lol I got you”. To acquire this I decided to figure out what happened when Facebook generates the thumbnail. I quickly learned that by looking for “facebookexternalhit” in the variable $_SERVER[“HTTP_USER_AGENT”] I could know that this is Facebook servers accessing my image. Therefor I decided to present the deceptive image as a thumbnail and when the user actually accesses the image I would present a new image of a troll.

The logic for this is created as follow:

header('Content-Type: image/jpeg');
if(preg_match("/facebookexternalhit/i", $_SERVER["HTTP_USER_AGENT"], $matches)) {
 readfile('fake.jpg');
} else {
 readfile('troll.jpg');
}

 

Finally its time to create the message to go with the image. The final message was saying: “Hey, Is this you from my town?” and the linked image. A screen shot from the original post is seen below.

fb_astrid_fake

After the user clicks the link, it will present the following image:

you_are_a_troll

Feel free to check out the final result for yourself with this link: http://hosting.olavz.com/astrid_ch.jpg Disclaimer: I have removed the data extraction of browser information and emailing.

As you might have observed on the image of the Facebook message, the message was viewed one day later. Not surprisingly the user clicked the link where I achieved the IP address and browser information. After checking the IP address with maxmind.com I could determine that this actually was a user from New York. The browser information slightly confirmed that the the browser used was configured to en-US language and that this probably is a deep cover for identity lurking or some one exploring for the sake of fun.

Posted by & filed under android.

shake_phone_demo

Some people need challenges to do stuff, I am one of them. From the Enigma Android challenge of the month I tested out the sensor technique to act out as an extension of the hand. This month challenge was to make a rock, paper, scissors application. It was quite fun to play with and the implementation was straight forward, tho I do recommend following a tutorial for the initial setup.

From whats worth taking away, the sensor is very sensitive and even if the phone is just flat out on the table it will still compute some very low numbers. You might have to find out what boundaries to act on in your own case. Also the sensor uses a loot of power when its in use, so wort turning it off when application enters onPause etc..

The app it self is uploaded to Google Play and can be accessed here: https://play.google.com/store/apps/details?id=com.olavz.rock.the.paper

Posted by & filed under article.

With already two weeks into my stay in Cambridge I have worked a lot and seen a lot! In the last week, Trond was visiting and we went around on a pub to pub mission in order to see and to taste different beer.trond_at_fitzwilliam

Image above is taken from Fitzwilliam bar. This is acutally a bar on campus where only students has access. Pretty awesome bar on campus. During daytime it serves as a coffee bar and in the evening they open for distribution of beer.

fitzwilliam_playground

From Fitzwilliam playground. This is a normal practice where they serve beer in the local bar that’s open during training and matches. Usually they wait with the beer until practice is over, but the old guys like to enjoy one during the practice as well :)

thirdlight

This is where I work. Far out on the countryside on a large farm actually. Its quiet and nice out here and the offices is really nice as well. Will try to get some photos from inside later on. A lot of people have been asking around what I am doing over here and with all technical questions they are not that easy to answer to the average human with out any technical insight. But I will give it a fair shot here anyways.

ThirdLight develops a product, a quite nice one. Check it out on www.thirdlight.com. Im not going in details what their product is for now and how it works, but imagine a webpage with text and images. See image bellow:

translate_1

What I do replace text selections with references as illustrated in the image bellow.

translate_2

By transforming text to references, these references can be collected with in a file and by duplicating this file and translating the file, our page can have different languages to apply for it. During last week, I believe I had about 1000 text strings converted to keys where we estimate that the whole solution contains about 13 to 15k strings. Relax, I am not to translate 15k strings, since about 12k of them where replaced with script automation and its the remainings that needs special attention to make sure we have a fully converted and translatable solution.

Its more or less a straight forward job, some of the challenges lies within the extension of pluralizing words where the scripts just adds a ‘s’ to the ending of the word. Therefor some scripts needs to be changed in order to support different endings containing whole words.

Cheers