Thursday, December 16, 2010

Wordpress: News Icon cannot appear in thumbnail size

After coming back from my long leave, I found all my icon news thumbnails not working as usual, only default icon for news appear for each of them...

Today I found the reason why this happen... its happen because the icon picture size that upload in media library smaller than image size in setting image. It suppose 170 x 56 px.... and the thumbnail function will reduce the image to thumnail size 162 x 56px...

Now all news icon appear again!... hehehe. :)

.

SSO - Tomcat Server

Important!

** After do any changes in SSO code file(deployerConfigContext.xml)
we should restart Tomcat service in CAS Server...

.

Tuesday, December 7, 2010

FreeBSD: How to check file/folder size in console

Use this command

## du -h (namefile/folder)

.

Wordpress- Nextgen Gallery Problem

Issue:

In Nextgen Gallery Plugins..

This error comes up when we want to upload pictures in gallery..
Upload failed! Failed to write file to disk

Upload Media also got Errors
Error saving media attachment.

I do:
Set all permission to all related folders to 777, still get the same errors.
Then I search the same problem in internet, and found this:
Have you exceeded your disk space quota?
http://bytes.com/topic/php/answers/820628-wordpress-image-upload-failed-write-disk-urgent

Then I inform server guy to check on the server space for this issue..


Solution:
Check /var/log/snmpd.log for www server.
Clear all log in the log file. Thats all.

Try back to upload the picture in gallery. See.. it works!
Thanks to all colleagues for helping me overcome this issue.

.

Sunday, November 14, 2010

How to Extract 7-Zip Files?

  1. Download and install 7Zip of course
  2. First of all download all 7zip compress files into the same folder.
  3. Make sure all file names match. in this case WA.7z.001 , WA.7z.002 , WA.7z.003 ...
  4. Right click the first file (WA.7z.001) and if you have the latest version you will see the 7 Zip menu(Pic 2), enter that menu
  5. Click "Extract files" option. A new window will pop up and you will choose where to extract the file.
  6. Then another window will pop up and ask you for the password(If require password).
  7. enter the password as its shown on the pic, which is http://snesorama.us in most cases.. Then sit back and wait for the extracting process to finish..
  8. When all ends, you are ready with your unpack file. Good Luck.

    .

Tuesday, August 31, 2010

Using Tar Command to backup system files in Unix Based Server

# tar -cjf file_aug10.tar.bz2 filename
In the above example command the system would create a tar.bz2 file named home.tar.bz2 in the directory you currently are in of the home directory.

To extract the compress file:

# tar -xjvf file_aug10.tar.bz2

How to upgrade Drupal 6.15 to 6.19 ?

Updated patch files to Drupal 6.18/6.19

Standard procedure to upgrade Drupal:

  1. Download the latest release/patch from drupal.org and follow the included UPGRADE.txt.
    **However,for administrators using the UNIX shell it may be easier using the attached patch files below instead of downloading and installing the newest complete Drupal release.

  2. Download the related patch files from here:
    http://fuerstnet.de/en/drupal-upgrade-easier

  3. Follow UPGRADING.txt up to '5'.
    Let's begin!

    1. Back up your Drupal database and site root directory. Be especially sure to back up your "sites" directory which contains your configuration file, added modules and themes, and your site's uploaded files. If other files have modifications, such as .htaccess or robots.txt, back those up as well.

    Note: for a single site setup, the configuration file is the "settings.php" file located at sites/default/settings.php. The default.settings.php file contains a clean copy for restoration purposes, if required.

    For multisite configurations, the configuration file is located in a
    structure like the following:

    sites/default/settings.php
    sites/example.com/settings.php
    sites/sub.example.com/settings.php
    sites/sub.example.com.path/settings.php


    More information on multisite configuration is located in INSTALL.txt.

    2. If possible, log on as the user with user ID 1, which is the first account created and the main administrator account. User ID 1 will be able to automatically access update.php in step #10. There are special instructions in step #10 if you are unable to log on as user ID 1. Do not close your browser until the final step is complete.

    3. Place the site in "Off-line" mode, to let the database updates run without interruption and avoid displaying errors to end users of the site. This option is at http://www.example.com/?q=admin/settings/site-maintenance (replace www.example.com with your installation's domain name and path).

    4. If using a custom or contributed theme, switch to a core theme, such as Garland or Bluemarine.

    5. Disable all custom and contributed modules.


  4. Remove all of the old files and directories from the Drupal installation directory." Go on using this commands:
    • cd DRUPAL-ROOT
    • Patch: patch -p1 <>
      * Be warned: this may break your Drupal installation , so make sure to have a backup at hand.

  5. Proceed with UPGRADING.txt from '8'. Verify the new configuration file to make sure it has the latest and correct information.

    8. Copy your backed up "files" and "sites" directories to the Drupal installation directory. If other system files such as .htaccess or robots.txt were customized, re-create the modifications in the new versions of the files using the backups taken in step #1.

    9. Verify the new configuration file to make sure it has correct information.

    10. Run update.php by visiting http://www.example.com/update.php (replace www.example.com with your Drupal installation's domain name and path). This step will update the core database tables to the new Drupal installation.

    Note: if you are unable to access update.php do the following:

    - Open your settings.php with a text editor.

    - There is a line that says $update_free_access = FALSE;
    Change it to $update_free_access = TRUE;

    - Once update.php is done, you must change the settings.php file
    back to its original form with $update_free_access = FALSE;

    11. Ensure that the versions of all custom and contributed modules match the new Drupal version to which you have updated. For a major update, such as from 5.x to 6.x, modules from previous versions will not be compatible and updated versions will be required.

    - For contributed modules, check http://drupal.org/project/modules for the version of a module matching your version of Drupal.

    - For custom modules, review http://drupal.org/update/modules to ensure that a custom module is compatible with the current version.

    12. Re-enable custom and contributed modules and re-run update.php to update custom and contributed database tables.

    13. Return the site to its original theme (if you switched to a core theme like Garland or Bluemarine in step #4). If your site uses a custom or contributed theme, make sure it is compatible with your version of Drupal.

    - For contributed themes, check http://drupal.org/project/themes for the version of a theme matching your version of Drupal.

    - For custom themes, review http://drupal.org/update/theme to ensure that a custom theme is compatible with the current version.

    14. Finally, return your site to "Online" mode so your visitors may resume browsing. As in step #3, this option is available in your administration screens at http://www.example.com/?q=admin/settings/site-maintenance (replace www.example.com with your installation's domain name and path).

    **
    Warning

    If you get errors like Reversed (or previously applied) patch detected or 1 out of 2 hunks FAILED while running the patch dry run (second command above) immediately interrupt patching and upgrade following the steps explained in UPGRADING.txt.


Reference Source:
http://fuerstnet.de/en/drupal-upgrade-easier

.

Tuesday, August 17, 2010

CodeIgniter

Introduction to CodeIgniter

CodeIgniter is an Application Development Framework - a toolkit - for people who build web sites using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch, by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by minimizing the amount of code needed for a given task. CodeIgniter (CI) uses the Model-View-Controller (MVC) approach similar to that of Ruby on Rails.

Some people said "Code Igniter is an Open Source Web Application Framework that makes writing kick-ass PHP programs simple as apple pie". Is it true? Lets begin.

1- Download CodeIgniter Current Version from http://codeigniter.com/downloads/
2- Extract the zip file in your root folder in your localhost pc/webserver.
3- Read User Guide or Basic Step on How to use CodeIgniter before you go further in the code.

In my case, I setup xampp server in my local PC.
Next step;
  1. I extract the codeigniter file insite C:\xampp\htdocs\
  2. Rename the folder name CodeIgniter to any name you want like form1.
  3. Inside the form1 folder, there is system and user guide folder, index.php and license.txt file.
  4. Go inside C:\xampp\htdocs\form1\system\application\config\ and open config.php file. At about line 14 you should see:

    $config['base_url'] = "http://www.your-site.com/";

    Edit this url with your URL:

    $config['base_url'] = "http://localhost/form1";
    form1 is refer to the folder name in step 2 above.

  5. Now save that file and open autoload.php. On line 42, let’s add the e-mail core class:

    $autoload['core'] = array('email');

    and database core class:

    $autoload['libraries'] = array('database');

    and on line 54 let’s add the form and url helpers:

    $autoload['helper'] = array('url', 'form');

    Save that file. The reason for adding the e-mail core class is pretty obvious since one of the features of our registration form is to notify the organizers when someone has submitted a completed form. The database core class is use to interact with database operation.

Controllers

With those core classes and helpers loaded, now the time create my first controller.
  1. Go to C:\xampp\htdocs\form1\system\application\controllers
  2. You will see sample controller file welcome.php
    I copy the file and name it home.php . Open the file and edit the function inside.

  3. This function refer to views file(welcome_message.php) in C:\xampp\htdocs\form1\system\application\views\

    function index()
    {
    $this->load->view('welcome_message');
    }

    **If I want to create new view files for the form, just rename welcome_message to a new name.Let say subject.

    function index()
    {
    $this->load->view('subject');
    }


VIEWS
  1. Go to C:\xampp\htdocs\form1\system\application\views\ and open subject.php
    All display setting for my form are formatted in this file. Create the html form here and set the submit function later in controller(home.php).

  2. Open internet browser and type this url to view the page
    http://localhost/form1/index.php/home
    *home is refer to your controller filename (home.php).
    The form will display in your browser as you want.

MODELS

O'o... I forgot to copy models file.
In my case, this is models file we always use.

Open php syntax

class Subject_model extends Model
{
function Subject_model() {
parent::Model();
table_name = 'subject';

}

function check_uid($uid) {
$this->db->where('uid', $uid);
$query = $this->db->get($this->table_name);
return ($query->num_rows() > 0) ? TRUE:FALSE;
}

function check_sem($sem) {
$this->db->where('semester', $sem);
$query = $this->db->get($this->table_name);
return ($query->num_rows() > 0) ? TRUE:FALSE;
}

function check($uid,$sem) {
$this->db->where('uid', $uid);
$this->db->where('semester', $sem);
$query = $this->db->get($this->table_name);
return ($query->num_rows() > 0) ? TRUE:FALSE;
}


function delete($id) {
$this->db->where('id', $id);
$this->db->delete($this->table_name);
return TRUE;
}

function details($uid,$semester) {
$this->db->where('uid', $uid);
$this->db->where('semester', $semester);
$query = $this->db->get($this->table_name);
if($query->num_rows() > 0) {

return $query;
}
else {
return FALSE;
}
}

function details_ref($refno) {
$this->db->where('student_ref_no', $refno);
$query = $this->db->get($this->table_name);
if($query->num_rows() > 0) {
$result = $query->row();
return $result;
}
else {
return FALSE;
}
}

function get_list($currentsem) {
if(!$currentsem) {

$currentsem = '';
}
/*
$this->db->order_by('student_ref_no', 'ASC');
$this->db->order_by('timecreated', 'DESC');
$this->db->order_by('id', 'DESC');
*/
$query = $this->db->query('SELECT *, COUNT(*)-1 as duplicate FROM (SELECT * FROM student '.$currentsem.' ORDER BY id DESC) as student GROUP BY student_ref_no ORDER BY timecreated DESC');
//$query = $this->db->get($this->table_name);
if($query->num_rows() > 0) {
return $query;
}
else {
return FALSE;
}
}

function count_unique() {
$this->db->group_by('student_ref_no');
$query = $this->db->get($this->table_name);
return $query->num_rows();
}

function get_name($id) {
if(!$id) { return FALSE; }

$this->db->where('id', $id);
$query = $this->db->get($this->table_name);
if($query->num_rows() > 0) {
$result = $query->row();
return $result->student_name;
}
else {
return FALSE;
}
}


function get_latest($limit = NULL, $offset = NULL) {
$this->db->limit($limit, $offset);
$this->db->order_by('date', 'DESC');
$query = $this->db->get($this->table_name);
if($query->num_rows() > 0) {

return $query;
}
else {
return FALSE;
}
}

function insert($data) {
$this->db->set($data);
$this->db->insert($this->table_name);

return $this->db->insert_id();
}

function total() {
$this->db->distinct();
$this->db->select('uid');
$query = $this->db->get($this->table_name);
if($query->num_rows() > 0) {
return $query->num_rows();
}
else {
return FALSE;
}
}
function update($uid,$sem,$data) {
$this->db->where('uid', (string)$uid);
$this->db->where('semester', (string)$sem);
$this->db->set($data);
$this->db->update($this->table_name);
}

function update_student($refno, $data) {
$this->db->where('student_ref_no', $refno);
$this->db->set($data);
$this->db->update($this->table_name);
}
function update_printed($id, $data) {
$this->db->where('id', $id);
$this->db->set($data);
$this->db->update($this->table_name);
}

function get_currentsemester() {
$this->db->distinct();
$this->db->select('currentsemester');
$query = $this->db->get($this->table_name);
if($query->num_rows() > 0) {
return $query;
}
else {
return FALSE;
}
}

}
Close php syntax

*The class name must same with models file name. In this case, file name is subject_model.php save in C:\xampp\htdocs\form1\system\application\models


Integrate Form with Database.


Task1: Create subject withdraw form for student
Data input: subject code, subject name, reason.

  1. Create blank database using phpmyadmin ()... to be continue

Sunday, June 27, 2010

Error saving media attachment in WordPress

Error on site: Error saving media attachment

Last week my friend (Arabic webmaster) told me that our site cannot upload picture or any files in media library. It happened since last Thursday. So for the whole Friday I search I have used to search the net for a solution. And I actually found most of the forums & blogs said to do this step:
  1. Go to “Settings” then go to “Miscellaneous” and check that your “Store uploads in this folder” is correct. Is should be something like “wp-content/uploads”.

    Mine was already use it.

  2. Next step is to check the permissions for your “uploads” folder located in “wordpress/wp-content/uploads/” on your server. Changed the whole “uploads” folder with “chmod 777 uploads” without luck.

    Mine also was set to 777 as it, but still cannot work.

So, after check everything here and there, finally our server guy suggest to reboot the www server. It is not the best, but it seems our last choice after checking everything ok. And yahoo!!... it works!. All the media upload function back in media library and post.

I'm feel relief .. Thanks Allah for showing us the way out.. :)

.

Tuesday, June 1, 2010

Wordpress 2.9.2: Install Plugins Problem

Salam,

Last week, I already installed new wordpress 2.9.2 in my dev server. I setup and configure all require file and the site can display well.

But the problem occur when I want to install plugins. The page display box to set connection info by ftp.. I try to check here and there, but still cannot find the setting file.... and finally I found the solution.

After we try to change the ownership of the wordpress folder to www, the plugin can be install without asking any connection setting info...

I'm happy :). Thanks tis guys for lend me yours big hands.:)


.

Thursday, May 6, 2010

Website Issue: Table picture cannot fit in css format for web header

We have been facing this problem since last week. Our designer send us new image link to be place in our website header.. but in table format ... which is different from the previous format where we just use a single picture for link. For the new one, we need to add a curve black background shape with 2 on-off button for link and one static link for pdf. The designer provide us the picture in slices... which formatted in html table. This should be okey if our web page only use simple html. But in our case, we use .php header with .css style file.

We try for a few days, and still cannot get the correct position. After my boss come and ask me today, suddenly I get a a simple idea to solve this problem. Why don't I just compile those slices to a single picture. Then I cut into three and place it in header as three link, formatted the css style and adjust a bit the position part. And finally it works.

Simple way to do:
  1. Display the original .html(given by designer) file in browser.

  2. Print screen and crop the full picture in Photoshop.

  3. Cut the picture into 3 pieces... follow the previous original picture file size(411 x65).
    Then upload those pictures in img folder in the themes folder.

  4. Then edit the header.php file. Add two more link after the original link. Change the image name with the correct path. I use the mouseover link style, where the picture will swap when mouseover.
    .....................
    [link tag]
    ='link address' class="applynow1" title="Apply On Campus">/img/oncampus_1.png" onmouseover="this.src='/img/oncampus_2.png';" onmouseout="this.src='/img/oncampus_1.png';" border="0" alt="" />
    [close link tag]
    .............................

  5. Then edit the css file. Add 2 more class style for 'applynow' > applynow1 and applynow2.
    .header a.applynow { position: absolute; right: 20px; bottom: 0; top: 36px }
    .header a.applynow1 { position: absolute; right: 153px; bottom: 0; top: 36px }
    .header a.applynow2 { position: absolute; right: 60px; bottom: 0; top: 36px }

  6. Save and preview the changes.
  7. Lastly, I edit the bg.png to repair the bg curve in right position. Then upload back and publish. All work just nice. Alhamdulillah.

.

Wednesday, May 5, 2010

Website Issue: Menu hidden behind flash

Everything works fine in Firefox, but in Internet Explorer my menu is hidden behind my Flash movie.
What to do?

Solution:

Try this as your code for the flash.

Code:

It working fine for me. Happy .. :)


.

Monday, February 1, 2010

HOW TO PATCH Drupal 6.14 to Drupal 6.15

In first place, I try to upgrade my drupal follow the instruction in UPGRADE.txt.. but not successful. I try three time and at last I fade up.

Finally I found this easier way to patch Drupal 6.14 to Drupal 6.15. This case is for Unix based server only.

Just Follow this simple steps;

  1. Backup your drupal database and file system first. Store your backup in other folder(/home/user/)

  2. Download patch file (drupal-6.14-to-6.15.patch ) from this site
    http://fuerstnet.de/en/drupal-upgrade-easier

  3. Open your drupal directory
    #cd your drupal directory

  4. Copy the patch file (drupal-6.14-to-6.15.patch ) into this directory.

  5. Login to drupal admin page. Please login as admin.

  6. Set site to off-line mode. Disable all modules that currently enable.

  7. Run this pact command:
    #patch -p1 < drupal-6.14-to-6.15.patch

    ** Be warned: this may break your Drupal installation so make sure to have a backup at hand.

  8. After finished, Verify the new configuration file to make sure it has the latest and correct information.

  9. Run http://your domain/update.php

  10. After finished, Verify in status report page to make sure your Drupal already upgrade to version 6.15.

  11. Enable back all previous active modules.

  12. Set the site back to online mode. See the site live again.

    Good luck!

    * Use this patch files on your own responsibility. I don't guarantee the proper function of the patch files on Drupal installations other than my own. - fuerstnet.de

.

Tuesday, January 12, 2010

WORDPRESS: NextGEN Gallery Not Function after Upgrade!

My Case:
I upgrade Wordpress 2.7 to wordpress 2.9.1.
The I also upgrade all plug-in that we use in the wordpress includes NextGEN Gallery.

All the previous pictures and gallery still there but the slideshow not working in publish news page.

Solution:
  1. Download JW Image Rotator from here.

  2. Unzip and copy the Imagerotator folder in uploads folder.
    Default path is ../wp-content/uploads/

  3. Open the NextGEN Gallery admin panel page. Setting back the NextGEN Gallery Options. Compare the details with the previous gallery setting to get the same effect.

  4. Save all setting. Try refresh the page again. It' s done.

.

WORDPRESS: How to solve ‘You do not have sufficient permission to access this page.'

Case 1:
We install the same wordpress file in new server.
But we change the prefix of the database. After setup everything, the website page cannot be display. Error occur.

Solution:
  1. Open database that have been use for this wordpress using phpmyadmin.
  2. Search url: www.address.edu.my dalam db
  3. Change all address to new address :www4.address.edu.my
    Probably inside:
    wp_options

  4. But after change all the address to the new one, the admin page cannot be open.
    There some error said:'You do not have sufficient permission to access this page.'

How to solve ‘You do not have sufficient permission to access this page.'

After seacrhing all the possible solution from the internet, finally we found the solution in this site: http://beconfused.com

Because we change the prefix of the table names in WordPress after the migration, thats why the error occurs.

In my old database, I used ‘wp_’ as my prefix. As I migrated, I decide to use ‘newprefix_’ instead of ‘wp_’. Unfortunately, the meta_key values are tied down to:
  • wp_user_level
  • wp_capabilities
  • wp_autosave_draft_ids
So, we need to update it to
  • newprefix_user_level
  • newprefix_capabilities
  • newprefix_autosave_draft_ids

The following statements go to ‘meta_key’ and does a string replace from ‘wp_’ to ‘prefix_’.


UPDATE `prefix_usermeta` SET `meta_key` = REPLACE( `meta_key` , 'wp_', 'prefix_' );


(** Dont forget to do backups first! Note that the quotes used for string and field name are different. )


Not finish yet! This another one statement you need to do also.


In the options table, there is ‘wp_user_roles’, make sure you get that changed into ‘prefix_user_roles’.


UPDATE `prefix_options` SET `option_name` = 'prefix_user_roles' WHERE `option_name` ='wp_user_roles' AND `blog_id` =0;



Try it, I tried logging in again and it worked. Thank you very much to http://beconfused.com


After successfully open the admin page, we run the upgrade automatically after deactivate all the current active plugins. All run very well without error.

But after check back all the links inside the website page, we found this error again:

WordPress 404 Not Found Problem

I already post this solution in my last year post. Refer the solution there.
http://salinaitmind.blogspot.com/2009/07/wordpress-move-site-to-new-server-issue.html

After that, every links can work fine. Alhamdulillah...



.