‘ Windows ’ category archive

Pictures partially displayed, tinyMCE problem, lightbox2 problem because of sendfile

July 25, 08 by the programmer

I had this problem a long time, I found a post I wrote from 2007-10-27.

The symptoms are

  1. Pictures displayed from the web server are not complete, only the top part of the picture is displayed, and the rest of the picture is black. This usually happens if the picture is very big (high resolution)
  2. Weird javascript problems. Problems occur only if the Javascript is served by the apache web server. The problem can gennerally occur with every static file.

This is the configuration I have:

Apache 2.0.54 on Windows XP Professional SP2
PHP 4.4.4
MySQL 4.1.12

I noticed the problem once when I was making a picture upload. I noticed that when I try to view the uploaded picture I could see only a part of the image, only the top part and never the full image.

This was pretty weird for me at the time, so I tried to see if the same is going to happen on the production server, because that was on my local server. Everything was ok on the production server so I did not bothered to fix the problem because it did not make any difference for me.


After a while I tried to install TinyMCE, a free HTML WYSIWYG editor, version 2.1.2. I run the examples from the desktop folder before uploading them to the local web server, and they were working great. After I saw that the examples were working I wanted to put them in my project and I copied all the files to the htdocs folder on the apache web server.

After I uploaded the files I tried to run the same example scripts but I noticed that they are not working, and that there was an error in firebug.

This is what the error was:

tinyMCE is not defined
tinyMCE.init({

example_advanced…. (line 8 )

missing : after case label
function TinyMCE_Engine(){var ua;this.majorVersion=”2″;this.minorVersion=”1.2″;t…

At that time I made a post to the tinyMCE support forum. This is the post. Nobody new why this error was appearing because nobody responded to my post.

So I tried to find a solution of the problem on the net, but none was available, at least I could not find it.
I also tried to upload the scritpts to my production server and supprisingly everything worked great there, so the scripts were ok, and I tried to be suspicious of my PHP, Apache confuguration. I thought that this might be some security issue or something similar.

I could not fix the problem so I decided not to use tinyMCE and I worked without a HTML WYSIWYG editor.


2 Days ago I a friend asked me to make him a web page with picture gallery I and I decided to use the lightbox2 javascript picture gallery (version v2.04 Released 3/09/08). It is very nice. It looks great. I downloaded the javascript files on my desktop.
I run the example files from my desktop and they were working great.
Again I copied the same files in the htdocs folder and after I run the examples I got an error in the firebug console.
This is what the error was:

syntax error
if (parent == do

prototype.js (line 4417)

uncaught exception: script.aculo.us requires the Prototype JavaScript framework >= 1.6.0

Object.extend is not a function
}, window.LightboxOptions || {});


lightbox.js (line 63)



I remembered that I had problems with tinyMCE, with the pictures display and now with lightbox2 and I somehow new that all those problems must be related.
I aslo noticed that the problem happens only i the files are static, like .js files of .jpg files, and if the files are big. Both the tinyMCE and lightbox have a lot of lines of javascript code.


At that moment I went to the tinyMCE Web site and downloaded the latest version (v 3_1_0_1_2). I wanted to see if the same problem will appear with the new version again. It did. I After I run the example files from the htdocs folder I got a javascript error in the firebug console.
This was the error:

missing ) in parenthetical
var tinymce={majorVersion:’3′,minorVersion:’1.0.1′,releaseDate:’2008-06-18′,_ini…

tiny_mce.js (line 1)

tinyMCE is not defined
tinyMCE.init({

skins.html (line 10)

Displaying pictures from http
Dispaying half images


I had a filling that the poblem must be in the php, apache configuration. Maybe something with the encodings, or the file size limitation or something similar. But it had to be with some confuration. So I decided that I have to solve this problem. I started to search the net for any similar cases and I found a post that is not very related to this problem but I decided to try.

I found this post: CSS and Javascript files not showing up when running Apache under Ubuntu on a flash drive? Read on. (Many thanks to the writer for writing the solution)

This guy had some similar problem, not displaying images, javascript files problem, so I thought I would give it a try.

As I found out later from the post apache by default uses a system command from the operating system called sendfile.

This command tries to deliver the static files to the browser, but because I am using Windows XP and it is “Windows operating system”, there must be some problem with it.

So I found out that Apache by default checks if the operating system supports sendfile syscall, and if it does then it uses it from the operating system, and if not it uses his own implementation of the functionality. Aslo I found out that there is a configuration property called EnableSendfile in the http.conf file, the Apache configuration file, which by default is on, which means use operating system function.

I set this configuration property to off, restarted Apache and BINGOOOOOOOOOOOOOO.

Everythig worked.

The pictures were showing up, both versions of the tinyMCE editor were working and the lightbox2 script was working. Finally after more that 9 months the problem is resolved :)

So if you have similar problems open httpd.conf, find “EnableSendfile” and set it to off like this:
EnableSendfile off


Dont forget to restart Apache after changing the configuration file

The symptoms as I mentioned before are

  1. Pictures displayed from the web server are not complete, only the top part of the picture is displayed, and the rest of the picture is black. This usually happens if the picture is very big (high resolution)
  2. Weird javascript problems. Problems occur only if the JavaScript is served by the apache web server.



More about EnableSendfile can be found here:

http://wiki.apache.org/httpd/SendfileNotImplemented

http://httpd.apache.org/docs/2.0/mod/core.html#enablesendfile


I hope this post will be useful to somebody with similar problems

Thank you



How to disable autoplay on Windows?

June 18, 08 by the programmer
Whenever you put a USB memory in the USB port or you insert a CD or DVD the Windows attempts to start the content on the medium.
This is a big security hole that some of the viruses use to spread themselves.
This is especially true if it is a USB memory because the viruses can copy themselves on the drive from the infected computer and after that with the autoplay option they can transfer themselves on the other (uninfected) machine, and by doing that they are spreading around
So in order to stop them from spreading around you can disable the autoplay option.
You can do that by following the bellow steps:

  1. Click Start ->Run
  2. Type “gpedit.msc” in the run text field
  3. Open “Computer Configuration -> Administrative Templates -> System “
  4. Find “Turn off AutoPlay”and double click it
  5. Click on the “enabled” radio button
  6. Select all drives from the drop down list bellow
  7. Click “Apply” to apply the changes
  8. That’s it, you are done

How can I disable / enable the internal PC speaker in Windows?

May 25, 08 by the programmer

If you’re running Microsoft Windows you can enable the Internal Speaker or PC speaker by following the below steps.

  1. Open Device Manager
  2. In Device Manager click View and click “Show hidden devices”
  3. This should make “Non-Plug and Play Drivers” visible in Device Manager.
  4. Expand Non-Plug and Play Drivers by clicking the plus and double-click Beep.
  5. Within the “Beep properties” window click the Driver tab.
  6. Under the driver tab if you wish to temporarily enable this device click the Start button. If you wish to permanently enable this device under the Startup Type select System.

What is the nslookup command?

May 18, 08 by the programmer

NSLOOKUP (Name Server Lookup)

is a command that it is used to query DNS (Domain Name System) servers and is embedded in Windows and Unix operating systems. Although nslookup exists in both UNIX and Windows, there are some differences in the way that it behaves in the two operating systems.

This command can be found in the BIND (Berkeley Internet Name Domain) package, the most commonly used DNS server on the Internet, especially on Unix operating systems.

The nslookup can be used to find various details relating to DNS including IP addresses of a particular computer, MX records for a domain or the NS servers of a domain - all using DNS lookups

The following examples are done on Windows platform.

NSLOOKUP common usage

You can use nslookup command by

  • calling it directly or
  • entering the nslookup shell

Direct usage of nslookup

In this example I will try to find out the IP address of my domain using the nslookup directly without entering its shell.

In order to do that I will write the following :

C:\>nslookup minanov.com
Server: locac dns server domain name
Address:
locac dns server IP Address

Non-authoritative answer:
Name: minanov.com
Address: 64.72.119.195

The first two rows in the command colored with light blue are showing the local network DNS server. This information is not correct.

However the other text bellow non-authoritative answer shows the name of the domain and the IP address of the server.

Using nslookup from it’s shell

Note that nslookup is a command that has a lot of possibilities. By entering in the shell all of this possibilities are available.

To enter the nslookup shell all you have to do is write “nslookup on the command prompt. If you want to find out more about all the possibilities just write “?” in the shell and hit enter. All of the available options will be displayed.

C:\>nslookup
>

Note that there is a more modern version of the nslookup command.

The command that will probably replace nslookup is the “dig” program, also embedded in the BIND package. However the dig command is not embedded in Windows operating systems yet. At least not in Windows XP.

Simple folder hiding in windows

May 11, 08 by the programmer

Have you ever wanted to hide some of your folders in Windows XP.

If you did and you does’t know how this is a pretty easy way of hiding a folder that most of the basic computer users wont be able to find and see. It is very simple, all you have to do is change the attributes of the folder that you want to hide. You have to make the folder to be hidden and you have to make it to be a system folder. That way the windows will not show it.

Let’s say that we want to hide the folder c:\my_folder

Open the command prompt and write

attrib +h +s c:\my_folder

This means make this folder to be hidden and system folder, and because by default the windows doesn’t show hidden system folders your folder will disappear immediately .

If you want to restore the folder you need to write

attrib -h -s c:\my_folder

and the folder will show.

That’s it.

HINT

If you want Windows to show the hidden system folders by default you have to go to

Folder Options, select the View tab and unselect the “Hide protected operating system files” checkbox.

After you do that you will be able to see all the hidden system files including our hidden folder.

Note that by default this option is disabled.