Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Monthly Archives: December 2010

COMPUTER SWAP MEETS


1ST WEEKEND OF MONTH SWAP MEETS

Malvern Computer Swap Meet
Malvern Town Hall, corner Glenferrie Rd and High St, Malvern
Usually Held 1st Sunday of Month – 9am
Enquiries: 1300 088 858

2ND WEEKEND OF MONTH SWAP MEETS

Springvale Computer Swap Meet
Springvale Town Hall
397 Springvale Rd, Springvale
Usually Held 2nd Sunday of Month – 9am
Enquiries: 1300 088 858

3RD WEEKEND OF MONTH SWAP MEETS
Berwick Computer Swap Meet
Berwick Leisure Centre YMCA
79 Manuka Rd, Berwick
Usually Held 3rd Sunday of Month – 9am

  • NOTE: The Next BERWICK will be on the 21st September at the Berwick Leisure Centre, 79 Manuka rd Berwick
    Enquiries: 1300 088 858

4TH WEEKEND OF MONTH SWAP MEETS

Moorabbin Computer Swap Meet
Moorabbin Town Hall
Corner Nepean Highway & South Rd’s, Moorabbin
Usually Held 4th Sunday of Month – 9am
Enquiries: 1300 088 858

Box Hill Computer Swap Meet
Box Hill Town Hall
1022 Whitehorse Rd, Box Hill
Usually Held 4th Sunday of Month – 9am
Enquiries: 1300 088 858

Creloaded 6.2 – Call for prices with Product Extra Fields


Create an Extra field ‘Call for prices’ through Creloaded 6.2 backend.
Modify the product_listing.php file by adding the following function at the end of the file.

function getProductsExtraFieldValue($extra_fields_id=4, $products_id){
$ef_value = ”;
$ef_query = tep_db_query(“SELECT `products_extra_fields_value` FROM `products_to_products_extra_fields` WHERE `products_extra_fields_id`='”.$extra_fields_id.”‘ AND `products_id`= ‘”.$products_id.”‘ “);
while ($ef_rows = tep_db_fetch_array($ef_query)) {
$ef_value = $ef_rows[‘products_extra_fields_value’];
}
return $ef_value;
}

The call the function getProductsExtraFieldValue() and do the customization in your need.

$call_for_price = getProductsExtraFieldValue(4,$listing[$x][‘products_id’]);

if ($call_for_price ==”){
$lc_text = $pf->getPriceStringShort();
}else{
$lc_text = ”;
}

Cre Loaded 6.2 – Previous – Next – With detailed info Addons


Previous – Next – With detailed info

1. This contribution places previous/next buttons in the product_info.php page which allows you to navigate the products of that category/manufacturer without having to go back to the category/manufacturer.
2. Optional: the name of the category/manufacturer can be displayed. The category name only is linked back to the category.
3. Optional: there can be buttons to link to the first/last product. These buttons are not supplied. You will have to create them. To insert the code look in the install under Bonus Install.

How to use it:
1. Follow the instructions in the Install Guide for installation
2. All files are located in the folder named files
3. Upload the files to the directories listed in the Install Guide
4. To set where the previous/next buttons will be diplayed go Admin–>Configuration–>Product Listing. Select Location of Prev/Next Bar Location (1-top, 2-bottom, 3-both)

Download Link

Handling array of HTML Form Elements in JavaScript and PHP


Today, I would like to share the way of handling array of HTML FORM elements using JavaScript and PHP.Well, it’s very easy to get the data from the array of HTML form elements in PHP and using them but in JavaScript it’s a bit tricky to handle the array of HTML form elements. I had a hard time to handle them via JavaScript in past thats why I’m posting it here so that people will not have hard time to cope with array of form elements in JavaScript and PHP.

Array of HTML form elements

You can create the array of Form Elements for grouping the similar kind of object or data. The array of elements are very useful in the context where you don’t know how many similar kind of data user have to enter. For example, you have a form where user have to enter his education qualification then you might not know how many of the textboxes are required for a person and in such kind situation you can dynamically generate array of the elements in the form for entering such kind of information.

<input name=”education[]” type=”text” size=”20″ maxlength=”40″ />
<input name=”education[]” type=”text” size=”20″ maxlength=”40″ />
<input name=”education[]” type=”text” size=”20″ maxlength=”40″ />

As you can in the above code, there are array element of textbox defined with the name “education”.Now, let’s see how can we handle them via JavaScript and PHP.
How to handle array of HTML form elements using PHP

If you submit the the the form with the above the array of elements then you can assess it via array of $_POST[‘education’] in PHP. You can use foreach() loop to access the value of the value of these form elements via PHP.

foreach($_POST[‘education’] as $key=>$value)
echo $key.’ ‘.$value;

Normally, posted variable are contained within the POST array but when you post the array of Form Elements then at that time the values are contained within the array of array i.e within $_POST[‘education’] in above exmaple.
How to handle array of Form elements using JavaScript

Handling the array of Form element part is a bit tricky. Now, let try to access the values of the above elements using JavaScript. First, let’s store the above object in a JavaScript variable

var mutli_education = document.form_name.elements[“education[]”];

After storing the object in the variable, we can access the individual variables in the following way in JavaScript

for(i=0;i<mutli_education.length;i++)
{
alert(mutli_education[i].value);
}

As you can see, you can get how many elements are there in the array using the lengh property and you can use the value property to get the value of the indivisual element.

Magento 1.4 Localhost Admin login problem and solution


Comment code from starting line 86 to 98 in app/code/core/Mage/Core/Model/Session/Abstract/Varien.php.
e.g.

/*  if (!$cookieParams[‘httponly’]) {
unset($cookieParams[‘httponly’]);
if (!$cookieParams[‘secure’]) {
unset($cookieParams[‘secure’]);
if (!$cookieParams[‘domain’]) {
unset($cookieParams[‘domain’]);
}
}
}

if (isset($cookieParams[‘domain’])) {
$cookieParams[‘domain’] = $cookie->getDomain();
} */

Magento installation problem in localhost – [validate-url] – Please enter a valid URL. Protocol is required…


Replace line no. #500 to #503 in \magento-1.4.2.0\js\prototype\validation.js file by code below:

[‘validate-url’, ‘Please enter a valid URL. Protocol is required (http://, https:// or ftp://)’, function (v) {
//return Validation.get(‘IsEmpty’).test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
return true;
}],

Plesk start-stop command

Linux command for Backup Script


You need to login to the shell and run following commands for both mysql databases and files.

e.g

tar -cvzf absblanksshirts.com.au.tar.gz httpdocs/
mysqldump -u absblank_ssitecms -p absblank_ssitecmsdb >absblanksshirts.sql

To view webalizer stats without login to cpanel


To view webalizer stats without login to cpanel do the following steps using shell :

1.First go to the public_html folder user :
# cd /home/username/public_html
e.g  cd /home/candylip/public_html/

2. Open .htaccess file. Add following code and save it:
Options +FollowSymLinks

You can edit the .htaccess file of the root store via vi editor.

3. Now create syblink for weblizer. Replace domainname.stats with name you want in order to access your website statistics. Change the owner to account user and permissions to 755.

#ln -s ../tmp/webalizer domainname.stats
chown username.username domainname.stats
chmod 755 ../tmp/webalizer

e.g:
#ln -s ../tmp/webalizer exclusiv.stats
#chown exclusiv.exclusiv exclusiv.stats
#chmod 755 ../tmp/webalizer

http://125.214.71.444/~exclusiv/exclusiv.stats

Unblocking IP address in Cpanel Server or Linux Command Line


You can unblock if from server shell console or from csf plugin if the serve is running cpanel.

For 125.214.71.115 in WHM under the Plugins section go to ConfigServer Security&Firewall.
Quick Allow tool should solve any blocking issues.

If the server is not running Cpane then from linux console run :
csf -a $IP
where $IP is IP you want to unblock and whitelist.

e.g:

root@secure [~]# csf -a 110.174.81.206
Removing 110.174.81.206 from csf.deny and iptables DROP…
DROP  all opt — in !lo out *  110.174.81.206  -> 0.0.0.0/0
DROP  all opt — in * out !lo  0.0.0.0/0  -> 110.174.81.206
Adding 110.174.81.206 to csf.allow and iptables ACCEPT…
ACCEPT  all opt — in !lo out *  110.174.81.206  -> 0.0.0.0/0
ACCEPT  all opt — in * out !lo  0.0.0.0/0  -> 110.174.81.206
root@secure [~]#

Flex SDK


Flex is a highly productive, open source framework for building and maintaining expressive web applications that deploy consistently on all major browsers, desktops and operating systems.

More to read from Flex SDK – Adobe Open Source