- Open the file
- Click CTRL + F
- Select "Current document" in "Find in" (You can also select the folder if you have multiple files)
- Search in "Source code"
- Tick "Use regular expression"
- Type "[\r\n]{2,}" (without quotes) in "Find"
- Type "\n" (without quotes) in "Replace"
- Press "Replace All"
Tuesday, December 25, 2012
How to remove unnessesary blank lines in your code
In Dreamviewer
Friday, November 30, 2012
50 Extremely Useful PHP Tools
50 Extremely Useful PHP Tools posted at Smashing Magazine
By Jacob Gube
PHP is one of the most widely used open-source server-side scripting languages that exist today. With over 20 million indexed domains using PHP, including major websites like Facebook, Digg and WordPress, there are good reasons why many Web developers prefer it to other server-side scripting languages, such as Python and Ruby.
PHP is faster (updated), and it is the most used scripting language in practice; it has detailed documentation, a huge community, numerous ready-to-use scripts and well-supported frameworks; and most importantly, it’s much easier to get started with PHP than with other scripting languages (Python, for example). That’s why it makes perfect sense to provide the huge community of PHP developers with an overview of useful tools and resources that can make their development process easier and more effective.
This post presents 50 useful PHP tools that can significantly improve your programming workflow. Among other things, you’ll find a plethora of libraries and classes that aid in debugging, testing, profiling and code-authoring in PHP.
Details of Jomres ( joomla hotel reservation component )
If you want to view or custermise booking data, you can edit jomeres/core-minicomponents/j03020insertbooking.class.php file.
Tuesday, November 20, 2012
Authenticating Customer Outside Magento
<?php
/**
* Magento validation starts here
*/
require_once (dirname(dirname(realpath(__FILE__))).'/app/Mage.php');
umask(0);
Mage::app();
//Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
try{
$session->login($_REQUEST['login']['username'],$_REQUEST['login']['password']);
$session->setCustomerAsLoggedIn($session->getCustomer());
//Load the customer modules
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
//Get customer attribbutes
$customer->loadByEmail($_REQUEST['login']['username']);
/**
* Do the stuff you need to when user authenticates
*/
}catch (Exception $e){
$key ="authenticate=N";
}
Friday, November 9, 2012
How to access Magento user's session from outside Magento?
<?php
require_oncedirname(__FILE__).'/app/Mage.php';
umask(0) ;
$_SESSION['wz']['customer_id'] = null;
Mage::app();
// Checking for customer session
Mage::getSingleton('core/session', array('name'=>'frontend') );
$session=Mage::getSingleton('customer/session', array('name'=>'frontend') );
$customer_data = Mage::getModel('customer/customer');
if ($session->isLoggedIn()) {
//echo "Customer is logged in";
$_SESSION['wz']['customer_id'] = $session->getId();
} else {
//echo "Customer is NOT logged in ";
unset($_SESSION['wz']);
header("Location: error.php?mode=unk_user");
}
Unable to login into the Magento backend
When you migrate your Magento website from location to another, or you change the domain-name under which it is running, you might run into the problem that you can't login anymore to the Magento Admin Panel. Here are various solutions to this problem.
Localhost
One reason why the Magento login fails, might be that you're accessing the Magento website through the hostnamelocalhost. Magento checks whether the hostname is a real domainname, and if it isn't, it fails to create the right cookies.
The only workaround is to fool Magento into thinking a real domainname is used. Under Linux or MacOS you could try using localhost.localdomain, but under Windows you will need to modify your hosts-file for this. Easier is just to use the IP-address 127.0.0.1 to access Magento.
If you are using a remote webserver, it's unlikely that this problem occurs.
Cookie domain
Another reason why you fail to login, could be some setting within the Magento configuration. To alter this, you will need to open up the MySQL database - for instance by using phpMyAdmin. Navigate within your Magento database to the MySQL table core_config_data and look for a row with the field path set to the value web/cookie/cookie_domain. There might be multiple entries, but the one with the scope_id set to 0 should be matching the domainname you're using to access Magento.
If the database table core_config_data doesn't contain any row with path set to web/cookie/cookie_domain, don't add it because you don't need it. If you find multiple entries, be careful with what to change because you might break your Magento site completely.
If you use a database table prefix, the table core_config_data might actually be uii44_core_config_data or something alike. This makes it harder for hacker to attack your Magento site (SQL injection attacks).
Secure or unsecure URLs
Another problem could be that the so-called Secure URLs and/or Unsecure URLs do not match the current hostname. In this circumstance, Magento tries to redirect to the original hostname anyway. So watch the hostname in the browsers addressbar closely.
In the same MySQL table core_config_data you might find various entries with path starting with web/secure/base orweb/unsecure/base. These also need to point to the right hostname. Note that the number of occurances could range from 0 (nothing configured) to 10 (everything configured).
Deleting and reconfiguring
Instead of trying to set the values above correctly, which could be a lot of work, you can also delete these entries and have a fresh start. You can use the following SQL-queries for this:
DELETE * FROM `core_config_data` WHERE `path` = "web/cookie/cookie_domain" DELETE * FROM `core_config_data` WHERE `path` LIKE "web/secure/base%" DELETE * FROM `core_config_data` WHERE `path` LIKE "web/unsecure/base%"
Check your file permissions
It's also worth taking a look at the permissions of your hosting environment. The folder var/cache within your Magento installation needs to be writable to the webserver, so new session-files can be created. If the folder is not writable, nobody is able to login.
Save sessions in the database
Instead of fixing the file permissions, you can also store the sessions in the database instead. You can accomplish this by editing the file app/etc/local.xml. Make sure you have a good backup of this file, and follow the exact syntax as below.
Locate the line starting with <session_save> and change the word files into db. So the following:
<session_save><![CDATA[files]]></session_save>
should become:
<session_save><![CDATA[db]]></session_save>
Save the file and sessions will be saved in the database instead. Please note that this change could have consequences regarding performance as well.
Friday, July 20, 2012
Change Your Table Prefix in WordPress
If your table prefix is “wp_” or “wp1_” or even “wordpress_”, then changing it will bring your WordPress site security to a higher level.
By default Fantastico installation sets “wp_” as a prefix for each WordPress table name. Since this is a known vulnerability, malicious users can exploit your data easily.
They specifically look for the wp_options table, because it will alter your WordPress site look. Through wp_options they can set the url to redirect to their sites, leaving you the impression that your site was defaced.
They specifically look for the wp_options table, because it will alter your WordPress site look. Through wp_options they can set the url to redirect to their sites, leaving you the impression that your site was defaced.
If you already have a WordPress site, take a look at either your config.php file or go to phpMyAdmin in cPanel to check your tables names.
// Entry in config.php showing wordpress table prefix used in the installation
$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!
Attackers can easily send malicious code using JavaScript injecting SQL targeting your wp_ based tables. To make your wordpress site really secure, change the prefix to something that is difficult to guess. I would pick something almost like a password, except you are limited here to only numbers, letters, and/or underscores.
You might want to check a plugin “wp prefix changer” written by Philipp Heinze for BlogSecurity.net. It should do the job for you. However, I had problems using it, and prefer the manual way which I already done for 2 blogs.
I strongly recommend you to do change the prefix, if it is plain wp_. Just follow the next 6 steps and you should be in good shape. I have tested these steps already with a WordPress 2.8 installation:
1- Take a backup
Since this is a change in your WordPress table structure, you will have to take a backup first.
In cPanel click on the “Backups” icon and click on “Generate/Download a full Backup” and proceed with a “Home Directory Backup”.
In cPanel click on the “Backups” icon and click on “Generate/Download a full Backup” and proceed with a “Home Directory Backup”.
2- Edit your wp-config.php file and change
$table_prefix = ‘wp_’;
to something like
$table_prefix = ‘op2mro445_’;
3- Change all your your WordPress table names
Go to phpMyAdmin and choose your WordPress database. Click on sql menu item and enter the command to rename all your tables. Do it one table at a time.
Note: You might have more tables that start with “wp_” prefix, change all the tables.
Every time you paste one line into the SQL window, click on GO and see the table name change on your left. Keep changing the table names until all your wordpress tables have the new prefix.
Every time you paste one line into the SQL window, click on GO and see the table name change on your left. Keep changing the table names until all your wordpress tables have the new prefix.
Rename table wp_commentmeta to op2mro445_commentmeta;
Rename table wp_comments to op2mro445_comments;
Rename table wp_links to op2mro445_links;
Rename table wp_options to op2mro445_options;
Rename table wp_postmeta to op2mro445_postmeta;
Rename table wp_posts to op2mro445_posts;
Rename table wp_terms to op2mro445_terms;
Rename table wp_term_relationships to op2mro445_term_relationships;
Rename table wp_term_taxonomy to op2mro445_term_taxonomy;
Rename table wp_usermeta to op2mro445_usermeta;
Rename table wp_users to op2mro445_users;
4- Edit wp_options
Then you need to edit in the op2mro445_options table ( formaly wp_options ) table
Click on the table name link and then click on “Browse” menu item.
You will see all the data stored in that table. Look under the option_name column header and change wp_user_roles to op2mro445_user_roles.
You will be able to change it by clicking on the edit button for that record.
You will see all the data stored in that table. Look under the option_name column header and change wp_user_roles to op2mro445_user_roles.
You will be able to change it by clicking on the edit button for that record.
Note: wp_user_roles might not appear on the 1st page under options. Keep looking for it, otherwise you will not be able to login afterwards.
5- Edit wp_usermeta
And finally apply changes to op2mro445_usermeta formally ( wp_usermeta). Don’t miss any records.
In phpMyAdmin highlight op2mro445_usermeta link and click browse menu.
Change every value under meta_key column header, that starts with the old prefix wp_ to the new prefix op2mro445_ the number or records might be different for your web site.
I have changed the following in my installation:
wp_capabilities to op2mro445_capabilities
wp_autosave_draft_ids to op2mro445_autosave_draft_ids
wp_user_level to op2mro445_user_level
wp_usersettings to op2mro445_usersettings
You can run a query in phpMyAdmin to find out how many records you need to change:
Simply click on the search link, add the following search condition (meta_key like ‘wp_%’ ), and click the GO button. (see image) This will get you the exact number of record you need to update. (Jessi, thanks for the tip)
6- Done! Test your WordPress site now
It should be a lot more secure giving you the peace of mind to focus on blogging.
Oh, one more thing. Do another backup.
If I can be of any help, just let me know.
Popularity: 100% [?]
Subscribe to:
Posts (Atom)