How to Drop all Databases from Mysql?

Sometimes I need to clean a mysql server so I can re-import it clean from the backups. A DROP ALL DATABASES; would have been nice, but the following does the trick. It will drop all databases except for mysql, test and information_schema


mysql -uroot -pPASS -e "show databases" | grep -v Database | grep -v mysql| grep -v information_schema| grep -v test | gawk '{print "drop database " $1 ";"}' | mysql -uroot -pPASS

Warning:
It does what it says on the tin. It will DROP all your databases, no warnings, no confirmations!

The syntax of the DROP DATABASE statement supports only a single database name. You will need to execute a separate DROP DATABASE statement for each database.

You can run a query to return a list of database names, or maybe more helpful, to generate the actual statements you need to run. If you want to drop all databases that start with the literal string database_ (including the underscore character), then:


SELECT CONCAT('DROP DATABASE ',schema_name,' ;') AS stmt
FROM information_schema.schemata
WHERE schema_name LIKE 'database\_%' ESCAPE '\\'
ORDER BY schema_name

Copy the results from that query, and you’ve got yourself a SQL script.

(Save the results as plain text file (e.g. dropdbs.sql), review with your favorite text editor to remove any goofy header and footer lines, make sure the script looks right, save it, and then from the mysql command line tool, mysql> source dropdbs.sql.)

Obviously, you could get more sophisticated than that, but for a one-time shot, this is probably the most efficient.)

============================
How I can change prefixes in all tables in my MySQL DB?

SELECT
GROUP_CONCAT('RENAME TABLE `', TABLE_SCHEMA, '`.`', TABLE_NAME, '` TO `', TABLE_SCHEMA, '`.`prefix_', TABLE_NAME, '`;' SEPARATOR ' ')
FROM
`TABLES` WHERE `TABLE_SCHEMA` = "test";

where “test” is expected database name

after this you can long query that will add prefixes if you execute it ūüėČ

Posted in MySQL. Comments Off on How to Drop all Databases from Mysql? »

X-cart Seo For Nginx

Create a file called xcart.conf, and add the following code in this new file:

if ($uri !~ "^/(payment|admin|provider|partner)/"){
set $rule_0 1$rule_0;
}
if ($request_filename !~ "\.(gif|jpe?g|png|js|css|swf|php|ico)$"){
set $rule_0 2$rule_0;
}
if (!-f $request_filename){
set $rule_0 3$rule_0;
}
if (!-d $request_filename){
set $rule_0 4$rule_0;
}
if ($request_filename !~ "-l"){
set $rule_0 5$rule_0;
}
if ($rule_0 = "54321"){
rewrite ^/(.*)$ /dispatcher.php last;
}

Put this new file under /usr/local/nginx/conf/;

Say your domain name is www.cheapglasses.net, and you have created a fold called www.cheapglasses.net, go to /usr/local/nginx/conf/vhost, and edit www.cheapglasses.net.conf, add a line:
include xcart.conf;

Posted in Nginx, X-Cart. Comments Off on X-cart Seo For Nginx »

Zen Cart V1.5.5 Add Extra Text at Category Footer

  1. Modify mysql database, add a field called ‘categories_footer’ at the table of ‘categories_description’, same field names and description of the field called ‘categories_description’.
  2. Add the function at admin panel, to create or modify a category, we need to modify categories.php which is under the admin fold. Within this file we need to add an extra field so that we can fill in the extra text of footer. Take care there are several places need to modify or add.
  3. We need to create a function called “zen_get_category_footer()”, same as¬† the function of “zen_get_category_description()”, add it within the file called general.php, which is under “admin/includes/functions/”.
  4. We also need to add the new extra block name with categories.php, say “define(‘TEXT_CATEGORIES_FOOTER’, ‘Categories Footer Description:’);”, just let this line under “define(‘TEXT_CATEGORIES_DESCRIPTION’, ‘Categories Description:’);”, which will be added within the file called¬† categories.php which is under “admin/includes/languages/english/”.
  5. ¬†Now let’s share how to let the¬† extra text at footer display at front page of a category. We need to modify 2 files. Let modify the first file which is called “tpl_index_product_list.php”, just under “includes/templates/responsive_classic/templates/”. Add the following code just above the last </div> at the end of the file:
    <?php
    // categories_description
    if ($current_categories_footer != ”) {
    ?>
    <div id=”indexProductListCatDescription” class=”content”><?php echo $current_categories_footer;¬† ?></div>
    <?php } // categories_description ?>
    </div>
  6. Modify the last file called “main_template_vars.php”, which is under “includes/modules/pages/index/”. Modify $sql, and add the new field, so that we can¬† use “$current_categories_footer” at “tpl_index_product_list.php”.
Posted in MySQL, Php Study, Zen Cart. Comments Off on Zen Cart V1.5.5 Add Extra Text at Category Footer »

How to modify Contact Us meta tags of X-cart 5?

For seo purpose, we need to modify default contact up page meta tags, follow me, and you will know how I have modified this for  www.cheapglasses.net

First, create a file called ContactUs.php, and place it under classes/XLite/Module/XC/CustomSkin/Controller/Customer, add the following content within this file:

<?php
namespace XLite\Module\XC\CustomSkin\Controller\Customer;
/**
* Decorated controller class.
*
* @LC_Dependencies (“CDev\ContactUs”)
*/
class ContactUs extends \XLite\Module\CDev\ContactUs\Controller\Customer\ContactUs implements \XLite\Base\IDecorator
{/**
* Get meta title
*
* @return string
*/
public function getPageTitle()
{
return ‘Contact Cheapglasses.net’;
}
/**
* Get meta description
*
* @return string
*/
public function getMetaDescription()
{
return ‘Discount prices on prescription eyeglasses and sunglasses online.’;
}

    /**
* Get meta keywords
*
* @return string
*/
public function getKeywords()
{
return ‘eyeglasses,sunglasses,eyeglass lenses,eyeglass,glasses,eye glasses,sun glasses,prescription eyeglasses, prescription eye glasses,cheap eyeglasses,cheap eye glasses,eye doctor,eye doctors,eyeglass prescription,eye glass prescription,prescription glasses,cheap glasses,discount eye glasses,discount eyeglasses,discount eyewear,discount glasses,eyeglass frame,eye glass frame,eyeglasses online,eye glasses online,rimless eyeglasses,rimless eye glasses,progressive lens,progressive lenses,prescription sunglasses,prescription sun glasses, prescription sunglass,prescription sun glass,polarized lens,polarized sunglasses,polarized sun glasses,metal eyeglasses,metal eye glasses,plastic eyeglasses,plastic eye glasses,titanium eyeglasses,titanium eye glasses,bendable eyeglasses,bendable eye glasses,kids eyeglasses,kids eye glasses,child eyeglasses,child eye glasses’;
}
}
Second, create a file called Main.php, and place it under classes/XLite/Module/XC/CustomSkin, add the following code with this new file:
<?php
// vim: set ts=4 sw=4 sts=4 et:
/**
* X-Cart
*
* NOTICE OF LICENSE
*
* This source file is subject to the software license agreement
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.x-cart.com/license-agreement.html
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to licensing@x-cart.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not modify this file if you wish to upgrade X-Cart to newer versions
* in the future. If you wish to customize X-Cart for your needs please
* refer to http://www.x-cart.com/ for more information.
*
* @category  X-Cart 5
* @author    Qualiteam software Ltd <info@x-cart.com>
* @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
* @license   http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement
* @link      http://www.x-cart.com/
*/
namespace XLite\Module\XC\CustomSkin;
/**
* Main module
*/
abstract class Main extends \XLite\Module\AModule
{
/**
* Author name
*
* @return string
*/
public static function getAuthorName()
{
return ‘www.cheapglasses.net’;
}
    /**
* Module name
*
* @return string
*/
public static function getModuleName()
{
return ‘Custom Skin’;
}
    /**
* Module description
*
* @return string
*/
public static function getDescription()
{
return ‘Modify Contat Us meta tags’;
}
    /**
* Get module major version
*
* @return string
*/
public static function getMajorVersion()
{
return ‘5.2’;
}
    /**
* Module version
*
* @return string
*/
public static function getMinorVersion()
{
return ‘9’;
}
    /**
* Display settings form
*
* @return boolean
*/
public static function showSettingsForm()
{
return true;
}
}
Third, upload these two files;
Forth, login your admin panel, active this new module, which name is ‘Custom Skin’;
Fifth,¬† go to ‘System Settings–> Cache management’, and Click ‘Re-deploy the store’.
Done
Many thanks qualiteam gives me the idea how to modify!!!
Posted in X-Cart. Comments Off on How to modify Contact Us meta tags of X-cart 5? »

How to Modify Price Category of Zen-Cart?

How to modify price categories to:  29 Dollar Glasses, 39 Dollar Glasses, 49 Dollar Glasses, 69 Dollar Glasses, and 99 Dollar Glasses, just as www.bestpriceglasses.com?

We should modify the following files:
admin/prodajxdetails.php
admin/seomgmt.php
admin/categories_header_desc.php, modify price related categories header description.
admin/option_metatag.php, modify price related meta tags
includes/modules/left_column.php
includes/modules/meta_tags.php
includes/templates/template_default/templates/tpl_index_product_list.php

At the same time we also should modify price seo related table: prefix_seo_url_1, take care the id arrangement, from small to big id.

Posted in Zen Cart. Comments Off on How to Modify Price Category of Zen-Cart? »

X-cart v4: remove home.php

how to remove home.php of v4.6.4 completely?
If you need to change the link of your web-site’s logo, from /home.php to /, just modify this file:

common_files/customer/head.tpl

– find this code:
<code>
<div class=”logo”><a href=”{$catalogs.customer}/home.php”><img src=”{$ImagesDir}/xlogo.gif” alt=”” /></a></div>
</code>

and change it to:

<code>
<div class=”logo”><a href=”{$catalogs.customer}/”><img src=”{$ImagesDir}/xlogo.gif” alt=”” /></a></div>
</code>

For custom skins, you may also need to modify another template files in a similar way, for example:

2-columns/customer/head.tpl
artistictunes_business/customer/head.tpl
vivid_dreams_lotus/customer/head.tpl

For custom skins, you may also need to modify another template files in a similar way, for example:

2-columns/customer/head.tpl
artistictunes_business/customer/head.tpl
vivid_dreams_lotus/customer/head.tpl

2. if you need to change the link from /home.php to / in bread crumbs, just modify this file:

postauth.php

– find this code:
<code>
if (!empty($lbl_site_path)) {
$location[] = array(
$lbl_site_path,
‘home.php’,
);
}
</code>

and change it to

<code>
if (!empty($lbl_site_path)) {
$location[] = array(
$lbl_site_path,
‘./’,
);
}
</code>

 

Posted in X-Cart. Comments Off on X-cart v4: remove home.php »

Extra Block at Left Bar of X-cart V4.7.4

Sometimes we may need to add a block just as Category Block at the left side bar, here let me share the skills on how to do, I will add a block, just under the big Category block. In the new block I will add some useful links.
(more…)

Posted in X-Cart. Comments Off on Extra Block at Left Bar of X-cart V4.7.4 »

How to Use PHP to Delete All Folders and Files?

Some web hosting companies do not allow us to use “system(‘rm -rf ./*’); ” to delete contents, but we do really need to delete all sub folders and files quickly, how to then?

The follow php code can help us:

<DOCTYPE html>
<meta charset=”utf-8″ />
<?php
function delDirAndFile( $dirName )
{
if ( $handle = opendir( “$dirName” ) ) {
while ( false !== ( $item = readdir( $handle ) ) ) {
if ( $item != “.” && $item != “..” ) {
if ( is_dir( “$dirName/$item” ) ) {
delDirAndFile( “$dirName/$item” );
} else {
if( unlink( “$dirName/$item” ) )echo “Files deleted successfully? $dirName/$item\n”;
}
}
}
closedir( $handle );
if ( rmdir( $dirName ) ) echo “Files deleted successfully: $dirName\n”;
}
}
// delDirAndFile( ‘wap’);¬† del a folder called: wap
delDirAndFile( ‘./’);¬† //del all sub folders and files under the current folder
?>
Posted in Php Code. Comments Off on How to Use PHP to Delete All Folders and Files? »

X-cart V4.7.1 SEO on Customized URLs

If your x-cart based shoping system has thousands of products or many categories, and you need to add a customized word at the end of a detailed product or category url, for example:
Your category name is: Cheap Glasses, default x-cart seo function will generate: Cheap-Glasses;
your product name is: USA, defautl x-cart seo function will generate: USA. (more…)

Posted in Php Skills, X-Cart. Comments Off on X-cart V4.7.1 SEO on Customized URLs »

How to Let X-Cart Display latest WordPress Posts?

This mod assumes that you use the WordPress blogging software and uses the same database as your xcart software.
If your wordpress and x-cart use separate database then use this code for blog_headlines.php (more…)

Posted in MySQL, Php Code, WordPress, X-Cart. Comments Off on How to Let X-Cart Display latest WordPress Posts? »
King Php Science Designed by:KingPhp.com Welcome, you are from: 60.191.123.80