PHP Know

How to install the default LAMP stack in Ubuntu 16.04?

Posted on | June 26, 2016 | Comments Off on How to install the default LAMP stack in Ubuntu 16.04?

First refresh your package index…
$ sudo apt-get update
… and then install the LAMP stack:
$ sudo apt-get install lamp-server^

Mind the caret (^) at the end.

If occers: E: Unable to locate package lamp-server

Try to use:
[code]
sudo apt-get install tasksel
sudo tasksel install lamp-server
[/code]

Done!

About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is already running Ubuntu, the linux part is taken care of.

How to Find All Zen-Cart Deactivated Products?

Posted on | January 20, 2016 | Comments Off on How to Find All Zen-Cart Deactivated Products?

Is there some easy way we can find all products that have been set to deactivated?  Without going through all of them one by one in admin?

We can use the powerful mysql command to achieve this. Go to phpMyAdmin, if you only use the following sql command, you will only get all deactivated products id number, it is still useless.

SELECT products_id FROM products where products_status = 0;

We can use MySQL Join search to meet our demands, we search 2 mysql tables:

select products_description.products_name, products.products_status from products_description, pres_products where products.products_status = 0 and products_description.products_id = products.products_id;

 

Add Banner System at Homepage for X-cart V4.74

Posted on | November 4, 2015 | Comments Off on Add Banner System at Homepage for X-cart V4.74

1. Copy jquery.flexslider.js, jquery.flexslider-min.js, and slide_toggle.js to the folder skin/light_responsive/js/;

2. Copy flexslider.css to the folder skin/light_responsive/css/;

3. Edit altskin.css which is at skin/light_responsive/css/, add the following css code at the end of the file:
.flexslider { Read more

Display latest WordPress Posts at X-cart

Posted on | April 3, 2015 | Comments Off on Display latest WordPress Posts at X-cart

Here’s my solution using RSS and a Smarty plugin to pull the latest posts from any wordpress blog.

Create this file include/templater/plugins/function.sr_wpfeed.php:

##
## {$someposts.title}
##

##

## {$someposts.description}
##
## {/foreach}
##
##
## Parameters
## ----------
## var [string] (required)
## Name for Smarty variable to return feed array in
##
## wpsite [string] (required)
## URL of WordPress site
##
## num [integer] (required)
## number of posts to return
##
##
## -----------------------------------------------------------------------------

function smarty_function_sr_wpfeed($params, &$smarty) {

global $sql_tbl;
global $store_language;

$required_params = array('var','wpsite', 'num');

foreach($required_params as $_key => $reqd_param) {
if (!isset($params[$reqd_param]))
$smarty->trigger_error("sr_wpfeed: required attribute '$reqd_param' not passed", E_USER_ERROR);
}

$var = '';
$wpsite = '';
$num = 0;
foreach($params as $_key => $_val) {
switch($_key) {
case 'wpsite':
case 'var':
if (!is_array($_val)) {
if ($_val <> '')
$$_key = $_val;
else
$smarty->trigger_error("sr_wpfeed: '$_key' cannot be an empty string", E_USER_ERROR);
} else
$smarty->trigger_error("sr_wpfeed: '$_key' cannot be an array", E_USER_ERROR);
break;

case 'num':
if (!is_array($_val)) {
$$_key = (int)$_val;
if ($$_key < 0 || $$_key >25)
$smarty->trigger_error("sr_wpfeed: '$_key' not between 1 and 25", E_USER_ERROR);
} else
$smarty->trigger_error("sr_wpfeed: '$_key' cannot be an array", E_USER_ERROR);
break;

default:
$smarty->trigger_error("sr_wpfeed: attribute '$_key' not recognized", E_USER_NOTICE);
break;
}
}
if(!$xml=simplexml_load_file($wpsite.'/feed')){
$smarty->trigger_error('Error reading XML file',E_USER_ERROR);
}
$posts = array();
foreach($xml as $item){
for($i=0; $iitem); $i++){
if($i<$num){ $posts[] = array('link' => (string)$item->item[$i]->link
, 'title' => htmlentities($item->item[$i]->title,ENT_COMPAT, 'UTF-8')
, 'description' => $item->item[$i]->description
);
}
}
}

$smarty->assign($var, $posts);
}
?>

Then in whatever template you want to display the posts in you can display the posts something like this:

{sr_wpfeed var="someposts" wpsite="http://www.glassespeople.com/blog/feed" num=5}
{foreach from=$someposts item=somepost}


{$somepost.title}

{$somepost.description}

{/foreach}

his should work in any version of X-Cart as it doesn’t use any X-Cart functions. Also there are no modifications to X-Cart php code so it doesn’t get wiped out by upgrades.

How to change permissions for creating articles and blogs for Vbulletin 5.1?

Posted on | July 20, 2014 | Comments Off on How to change permissions for creating articles and blogs for Vbulletin 5.1?

Change the permissions for creating articles:
In the Admin CP of your vbulletin based system where you set permissions for all channels. Go to Channel Management -> Channel Permissions. Scroll to the Articles channel. Edit your usergroups and remove the “Can Post Topic” permission. All sub-channels will inherit those permissions.

Change the permissions for creating blogs:
will add this later.

How to let your html page run php code?

Posted on | May 27, 2014 | Comments Off on How to let your html page run php code?

Do you know that we can add php code at a html page, and run these php code? For different php version, we have to add different code at .htaccess.
For php5, we add the following code:

# Use PHP5 as default
AddHandler application/x-httpd-php5 .html .htm .php
Read more

ERROR 1044 (42000): Access denied for user ‘username1’@’localhost’ to database ‘006’

Posted on | March 25, 2014 | Comments Off on ERROR 1044 (42000): Access denied for user ‘username1’@’localhost’ to database ‘006’

If you get this error, you do not have privileges on user_* to use Create. HostGator needs to correct this issue for you.

If you open your database which you plan to import to your hostgator web hosting, you can find the following mysql commands: Read more

Drupal 7 Skills

Posted on | November 30, 2013 | Comments Off on Drupal 7 Skills

Question 1: Can’t overwrite or delete settings.php
It’s a smart security setting of drupal
You need to add permissions to write not only the settings file but also the folder where it is.
Don’t forget to put the permissions back as they were once you finished editing the file. Read more

2 skills on vbbulletin and vbseo

Posted on | June 13, 2013 | Comments Off on 2 skills on vbbulletin and vbseo

1. How do you change vbulletin’s home page to the forums instead of the default (CMS or Activity Stream)?

For vBulletin versions >= 4.2.
There’s a new “Navigation Manager”. You’ll find the control settings here:
Admin Control Panel -> Settings -> Navigation Manager.

Find the row for the Forum tab.
On the right side of the row is a pull-down selector, click “Set Default” (you may need to click the “Go” button afterwards).

The “Change Site Default” panel will appear.
Verify that the Forum tab is the “Proposed Default” and that “Yes” is selected for “Confirm Change”, then click “Save”. Read more

Displaying Extra Fields using “if” statements

Posted on | March 11, 2013 | Comments Off on Displaying Extra Fields using “if” statements

If anyone else wants to accomplish something similar, I just figured it out. The extra field number needed to be used in “if”statement as well.

Go to cart442\skin\common_files\modules\Extra_Fields, and open product.tpl. Read more

keep looking »