Blog posts by Geekyboy – Adam Culp

  • Plesk backup problem

    I had a problem backing up domains on a server and received the following error message:

    Error: Unable to create backup session: Specified file is not accessible

    Finally i solved this problem!!!! it was all about wrong permission in some folders!

    check that the folders ‘/var/lib/psa/dumps’ and ‘/var/lib/psa/dumps/tmp’ are chmod to 777

  • Change/update time on Linux

    Sets whether the hardware clock is stored as UTC or local time.

    /etc/sysconfig/clock 
    

    Symlink /etc/localtime to /usr/share/zoneinfo/… to set your timezone.

    To set the current system date/time.

    date MMDDhhmm
    

    To set the hardware clock.

    /sbin/hwclock --systohc 
    
  • Javascript disable right click and image tool bar

    A recent request from a client was to make life more difficult for his competitors to steal images from his site. He was worried that they could save the images using the Image Toolbar in newer versions of Internet Explorer, and by using the right click menu on the page. For those of you that wish to stop the right clickers from stealing your code, or from stealing images, here is a quick and easy way to make life more difficult for them.

    To disable the Internet Explorer Image Toolbar for an entire page add this meta tag:

    
    

    To disable the Internet Explorer Image Toolbar for an individual Image do this:

    
    
    

    And for individual images:

    
    
  • CSS style sheet switcher using Prototype

    A recent project had a requirementfor a style switcher allowing a visitor to control font size on the site as needed. (Many do not know how to change it through a browser, and most sites are not designed to allow for font size changes without completely trashing presentation.)

    Because the project in question was a dynamic site I wanted to make a style sheet switcher that didn’t force a page reload and it seemed like most examples on the net required a page to reload with a new stylesheet. (After PHP or some other scripting language decided which css sheet to render the page with.) This meant additional calls to the server to repopulate data grids and other info, after re-running a query and parsing in PHP. To me this was truly unacceptable load on a server to simply change font sizes on a page.

    (more…)

  • PHP failing to upload images on a Plesk managed server

    I recently upgraded a few of my Linux servers from Plesk 7.5 to 8.2. Everything seemed to be fine, however calls started coming in about PHP forms not uploading images correctly.

    My team and I were troubleshooting this problem for a few days trying to narrow down the problem. We looked at folder permissions, script permissions, database connectivity, and almost anything else we could think of. Then we stumbled across the error message given by PHP (who would have thought to look at the error message?) that said function move_uploaded_file will not work in safe_mode.

    Now looking at the PHP info the main php.ini was set with safe_mode off. However, I found that the httpd.conf for the individual domains on a Plesk managed server carries a declaration for PHP safe_mode, and it was turned on. Upon further investigation I found that in the Plesk interface for the domain there is a checkbox beside the PHP setting that allows safe_mode to be turned on and off.

    Mission accomplished!

  • Adding mssql capability to PHP5 on CentOS

    I had a need to connect to MSSQL using PHP version 5 from a CentOS 5 server. To do this I needed FreeTDS and the module mssql in PHP. After a diligent search I found that there was no quick and easy way to install the mssql module, like “up2date install php-gd” to get GD to work from PHP.

    I found a few places that had ideas and hints to make this work, but finally used the directions I found at http://www.howtoforge.com/installing_php_mssql_centos5.0 (slightly altered to fit my means) and will duplicate here so I can easily find it later.

    At first I thought I needed to recompile PHP, but as it turned out I only needed to pre-compile it so that I could fetch the mssql.so, and then manually edit the php.ini to use it.

    (more…)

  • Using JOIN within the Zend Framework

    I found documentation very sparse on the subject of using JOIN with the Zend Framework. So i set out on a quest of many hours figuring out how to get it to work. Here is what I ended up with.

    I do not claim that this is the best way to do it, or that it is correct, but here is how I solved this and got JOIN working within Zend Framework.

    (more…)

  • Apache parse PHP from within files using ‘.html’ extension

    Recently I had someone that needed to move their site to a new server. The site was entirely created with the files using the .html extension, but had embeded inside.

    I simply cleared this up by adding the following line to the httpd.conf, and after a reboot of Apache i was set to go.

    AddType application/x-httpd-php .html
    

    If you were to need this type of action for files using the .htm extension you would do the same thing, but replace the .html to .htm in the line.

  • Apache redirecting to home directory using userdir module

    Development is made easier by running a full development environment on your workstation. I personally run a full LAMP (Linux, Apache, MySQL, PHP) environment that allows me to test what I am developing on my workstation. In this case I am on my new Dell Inspiron E1505n running Ubuntu 7.04 Feisty Fawn.

    One of the problems with doing this is the need to play with permissions on ever site in the server root. So instead I am using ‘userdir’ to keep the sites for easy development and testing. In other words I use apache to pull the site from my home directory for display in my browser. Here is how I did it.

    (more…)

  • Laptop not recovering from suspend mode (Dell with Ubuntu 7.04 Feisty Fawn)

    I am pretty mobile, and find it a pain to boot up my laptop every time I need it. So instead I simply close it to put it into suspend mode, and simply open it and log in without the needed wait for booting up. (Even though Ubuntu loads very quickly.)

    The problem is that sometimes the laptop does not recover, and I am faced with a black screen instead of my login screen. This forces me to force shutdown by hitting the power button, or forcing reboot by hitting Ctrl+Alt+Delete.

    After some searching I found a remedy that seems to have fixed the problem. I simply added ‘noapic nolapic’ to my boot. Here is how I did it:

    $ sudo vi /boot/grub/menu.lst
    

    Then I found the “kernel” line that corresponds with my boot process, and appended ‘noapic nolapic’ to the end of it. Here is how that line looked when I was finished:

    kernel          /vmlinuz-2.6.20-16-generic noapic nolapic
    

    Your line may differ slightly, but simply appending to the end will work fine.