Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/12/2014, 07:30
noticiasb
 
Fecha de Ingreso: diciembre-2014
Mensajes: 2
Antigüedad: 9 años, 10 meses
Puntos: 0
Pregunta Consulta sobre Friendly URLs con PHP 5.3

Saludos señores!
Tengo un problema con mi PHP. Estoy intentando en que mi blog genere urls amistosas para buscadores a traves de los títulos de los posts, pero por más que pruebo alternativas no consigo que funcione. Dado que no soy programador profesional es muy probable que esté haciendo algo mal o que la solución sea más sencilla de lo que, a priori, me parece.

Os pongo a continuación el contenido del fichero que genera las urls en mi PHP:

<?php
if (!defined('BASE_URL')) {
exit ('No direct script access allowed');
}

/**
*--------------------------------------------------------------------------
* === CLASS SOLUTIISOFT ===
*--------------------------------------------------------------------------
* Collection of static methods helpful
*
* PHP version 5.3
*
* @category E-Blog
* @package Core
* @subpackage Libraries
* @filename solutiisoft.php
* @author Solutii Soft <[email protected]>
* @copyright 2013 Solutii Soft
* @license 2013 Solutii Soft
* @link http://www.eblog.solutiisoft.com
* @since File available since Release 1.0
*/
class Solutii_Soft
{

/**
* Create a friendly URL
*
* @param string $str URL which need to be transform
*
* @function friendlyURL
* @access public
* @return string
*/
public static function friendlyURL($str)
{
$delimiter = '-';
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str);
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean);
$clean = strtolower(trim($clean, '-'));
$clean = preg_replace("/[\/_|+ -]+/", $delimiter, $clean);

return $clean;
}

/**
* All characters in the string after the last _, if these numbers will be deleted
*
* @param string $string string which need to be transform
*
* @function slugURL
* @access public
* @return string
*/
public static function slugURL($string)
{
$url = explode('-', $string);

if (is_numeric(end($url))) {
end($url);
unset($url[key($url)]);
}

return self::friendlyURL(implode('-', $url));
}

/**
* Clean all spaces before and after the comma
*
* @param string $string string which need to be transform
*
* @function prepareTags
* @access public
* @return string
*/
public static function prepareTags($string)
{
return implode(",", preg_split('~,\s*~', trim($string)));
}

/**
* One-way string hashing
*
* @param string $string string which need to be hash
*
* @function hashPassword
* @access public
* @return hashed string
*/
public static function hashPassword($string)
{
global $_EBLOG_hash;

$salt = $_EBLOG_hash['salt'];
$strength = "12";

if (CRYPT_BLOWFISH == 1) {
$presalt = (version_compare(PHP_VERSION, '5.3.7', '<')) ? '2a' : '2y';
$blowfish_salt = '$'. $presalt .'$' . $strength . '$'. substr($salt, 0, CRYPT_SALT_LENGTH) .'$';
return crypt($string, $blowfish_salt);
}
return sha1(hash_hmac('sha512', $salt, $string));
}


/**
* Remove all malicious code (better known as XSS)
*
* @param string $dirty_html string that need to be clean
*
* @function cleanXSS
* access public
* @return string
*/
public static function cleanXSS($dirty_html)
{
include_once 'public/vendor/htmlpurifier/htmlpurifier.standalone.php';

$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
return $purifier->purify($dirty_html);
}


/**
* Check if an array is empty
*
* @param array $array array which need to be check
*
* @function isEmptyArray
* @access public
* @return true for empty or false otherwise
*/
public static function isEmptyArray($array)
{
if (array_filter($_FILES['image']['name']) === array()) {
return true;
}
return false;
}

/**
* Remove all characters up to the first _ including this
*
* @param string $imageName name of image
*
* @function altOfImage
* @access public
* @return string
*/
public static function altOfImage($imageName)
{
$name = explode('_', pathinfo($imageName, PATHINFO_FILENAME));
unset($name[0]);
return implode(' ', $name);
}

}

/* end of file solutiisoft.php */