WF AQ

Knowledge base

31 Ottobre 2013
di admin@admin
Commenti disabilitati su Bug: quando un cambiamento hardware non si riflette nell’Health Monitor di Plesk

Bug: quando un cambiamento hardware non si riflette nell’Health Monitor di Plesk

When you add a new hard drive and increase available diskspace, add RAM to the server, or replace the CPU with
a more powerful one, these hardware changes are not reflected in Health Monitor. The old values of the hardware
capacity are still shown.

N.B.: questo problema è stato risolto in Plesk Panel 10.4.x

Se il problema dovesse verificarsi, ad ogni modo, lanciare il seguente comando:

# /usr/local/psa/bin/sw-engine-pleskrun
/usr/local/psa/admin/plib/scripts/setup-health-monitor.php

31 Ottobre 2013
di admin@admin
Commenti disabilitati su Abilita accesso remoto al db MySql in Plesk

Abilita accesso remoto al db MySql in Plesk

Since Plesk 8 MySQL users and databases are created with permissions that allow access to the database from outside. In previous Plesk versions MySQL users and databases are created with permissions that allow to access the database from localhost only. However, sometimes you need to provide the remote access.

  1. vi /etc/my.cnf
  2. Quando il file è aperto, posizionarsi alla linea che riporta [mysqld].
  3. Assicurarsi che la linea skip-networking sia commentata o rimuoverla.
  4. Guardare il paramtero bind-address. Questo dovrebbe essere commentato se vogliamo connessioni da ogni indirizzo IP esterno oppure assumere un valore di IP esplicito.

Per esempio:

[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 65.55.55.2 (comment if want connection from every external IP)
# skip-networking

Riavviare mysql con:

/etc/init.d/mysqld restart

31 Ottobre 2013
di admin@admin
Commenti disabilitati su Aggiungere un contatore di visite degli articoli in WordPress

Aggiungere un contatore di visite degli articoli in WordPress

Nel file functions.php vanno inserite queste due funzioni.

/**
 * Add Most Viewed Post feature via post meta
 */
function setPostViews ($postID)
{
	$count_key = 'post_views_count';
	$count = get_post_meta($postID, $count_key, true);
	if($count==''){
		$count = 0;
		delete_post_meta($postID, $count_key);
		add_post_meta($postID, $count_key, '0');
	}else{
		$count++;
		update_post_meta($postID, $count_key, $count);
	}
}

function getPostViews ($postID)
{
	$count_key = 'post_views_count';
	$count = get_post_meta($postID, $count_key, true);

	if ( empty($count) )
		return 0;
	else
		return $count;
}

31 Ottobre 2013
di admin@admin
Commenti disabilitati su Tagliare un testo aggiungendo i puntini di sospensione

Tagliare un testo aggiungendo i puntini di sospensione

Questo blocco di codice può essere usato nel file functions.php di WordPress.

/**
 * Plugin Name: Cut text
 *
 * trims text to a space then adds ellipses if desired
 * @param string $input text to trim
 * @param int $length in characters to trim to (positivo: taglia allo spazio; negativo: taglia al carattere)
 * @param bool $ellipses if ellipses (...) are to be added
 * @param bool $strip_html if html tags are to be stripped
 * @param bool $allowable string with tags allowed
 * @return string
 */
function cut_text($input, $length, $ellipses = true, $strip_html = true, $allowable = 'all') {

	$input=str_replace("[","<",$input); 
	$input=str_replace("\""," ",$input); 

	//strip tags, if desired
	if ($strip_html) {
		$input = strip_tags($input);
	}elseif($allowable != 'all'){
		$input = strip_tags($input,$allowable);
	}

	//no need to trim, already shorter than trim length
	if (strlen($input) <= abs($length)) {
		return $input;
	}

	if ( $length >= 0 ) {
		//find last space within length
		$last_space = strrpos(substr($input, 0, $length), ' ');
		$trimmed_text = substr($input, 0, $last_space);
	} else {
		$trimmed_text = substr($input, 0, abs($length));
	}

	//add ellipses (...)
	if ($ellipses) {
		$trimmed_text .= ' ...';
	}

	return $trimmed_text;
}