Nasel jsem krasnej post:
Use this command:
| |||
|
Use this command:
| |||
|
mb_internal_encoding('UTF-8');
$conn = mysql_connect('localhost','xxxxx','xxxxxxx');
mysql_select_db('xxxxxx');
mysql_query('set names utf8');
$result = mysql_query('select * from j25_content order by id desc');
while ( $record = mysql_fetch_assoc($result) ) {
$found = mysql_query('select count(*) matched from j25_content where `alias`="'.addslashes(seoUrl($record['title'])).'" and id<>'.$record['id']);
$foundM = mysql_fetch_assoc($found);
$alias = seoUrl($record['title']);
if ($foundM['matched']>1)
{
$duplicates++;
$alias.="-".(intval($found['matched'])+1);
echo ('[!!] ' . $record['alias']. 'would be duplicit, changed to: '.$alias."\n");
}
if ($record['alias']!=$alias) {
echo ('[++] ' . $record['alias']. ' changed to '.$alias.' from title "'.$record['title'].'"'."\n");
mysql_query('update j25_content set alias="'.$alias.'" where id='.$record['id']);
$modified++;
} else {
$correct++;
}
}
$result = mysql_query('select * from j25_menu order by id');
while ( $record = mysql_fetch_assoc($result) ) {
$found = mysql_query('select count(*) matched from j25_menu where `link`="'.addslashes(seoUrl($record['title'])).'" and id<>'.$record['id']);
$foundM = mysql_fetch_assoc($found);
$alias = seoUrl($record['title']);
if ($foundM['matched']>1)
{
$duplicates++;
$alias.="-".(intval($foundM['matched'])+1);
echo ('[!!] ' . $record['alias']. 'would be duplicit, changed to: '.$alias."\n");
}
if ($record['link']!=$alias) {
echo ('[++] ' . $record['link']. ' changed to '.$alias.' from title "'.$record['title'].'"'."\n");
mysql_query('update j25_menu set alias="'.$alias.'", path="'.$alias.'" where id='.$record['id']);
$modified++;
} else {
$correct++;
}
}
echo mysql_num_rows($result)." analyzed, $correct was ok, $modified has been modified, $duplicates was duplicate...\n";
/**
* Return URL-Friendly string slug
* @param string $string
* @return string
*/
function seoUrl($string) {
//Unwanted: {UPPERCASE} ; / ? : @ & = + $ , . ! ~ * ' ( )
$string = mb_strtolower($string);
$string = iconv('UTF-8','ASCII//TRANSLIT',$string);
//Strip any unwanted characters
$string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
//Clean multiple dashes or whitespaces
$string = preg_replace("/[\s-]+/", " ", $string);
//Convert whitespaces and underscore to dash
$string = preg_replace("/[\s_]/", "-", $string);
return $string;
}
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) Server VM (build 23.0-b21, mixed mode)
sudo update-java-alternatives -s java-7-oracle