| Current Path : /home/s/u/n/sunflowe/www2/j15/administrator/components/com_sh404sef/ |
| Current File : /home/s/u/n/sunflowe/www2/j15/administrator/components/com_sh404sef/shMosSEF.class.php |
<?php
/**
* SEF extension for Joomla! 1.5
*
* @author $Author: shumisha $
* @copyright Yannick Gaultier - 2009-2010
* @package sh404SEF-15
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @version $Id: shMosSEF.class.php 1193 2010-04-04 16:18:35Z silianacom-svn $
*/
// Security check to ensure this file is being included by a parent file.
if (!defined('_JEXEC')) die('Direct Access to this location is not allowed.');
class shMosSEF extends JTable // updated to remove legacy mode
{
/**
* Error string
*
* @var string
* @access protected
*/
var $_error = '';
/**
* Error number
*
* @var int
* @access protected
*/
var $_errorNum = 0;
/** @var int */
var $id = null;
/** @var int */
var $cpt = null;
/** @var int */
var $rank = null;
/** @var string */
var $oldurl = null;
/** @var string */
var $newurl = null;
/** @var tinyint */
/** @var date */
var $dateadd = null;
/**
* Constructor
*/
function __construct( &$db)
{
parent::__construct( '#__redirection', 'id', $db );
}
function shMosSEF( &$_db ) {
parent::__construct( '#__redirection', 'id', $_db );
}
function check() {
//initialize
$this->_error = null;
$this->oldurl = JString::trim($this->oldurl);
$this->newurl = JString::trim($this->newurl);
// check for valid URLs
if (($this->oldurl == '')||($this->newurl == '')){
$this->_error .= _COM_SEF_EMPTYURL;
return false;
}
//if (eregi("^\/", $this->oldurl)) {
if( JString::substr( $this->oldurl, 0, 1) == '/') {
$this->_error .= _COM_SEF_NOLEADSLASH;
}
//if ((eregi("^index.php", $this->newurl)) === false ) {
if( JString::substr( $this->newurl, 0, 9) != 'index.php') {
$this->_error .= _COM_SEF_BADURL;
}
// V 1.2.4.t remove this check. We check for pre-existing non-sef instead of SEF
if (is_null($this->_error)) {
// check for existing URLS
$this->_db->setQuery( "SELECT id,oldurl FROM #__redirection WHERE `newurl` LIKE '".$this->newurl."'");
$xid = $this->_db->loadObject();
// V 1.3.1 don't raise error if both newurl and old url are same. It means we may have changed alias list
if ($xid && $xid->id != intval( $this->id )) {
$this->_error = _COM_SEF_URLEXIST;
return false;
}
$identical = $xid->id == intval( $this->id ) && $xid->oldurl == $this->oldurl;
return $identical ? 'identical' : true;
}else{
return false;
}
}
/**
* Legacy Method, use {@link JObject::getError()} instead
* @deprecated As of 1.5
*/
function getError($i = null, $toString = true )
{
return $this->_error;
}
/**
* Legacy Method, use {@link JObject::getError()} instead
* @deprecated As of 1.5
*/
function getErrorNum()
{
return $this->_errorNum;
}
}