Your IP : 216.73.216.54


Current Path : /var/www/html/components/com_jvld/models/
Upload File :
Current File : /var/www/html/components/com_jvld/models/checklinkstatus.php

<?php
/**
 * @version		$Id$
 * @package		JV-LinkDirectory
 * @subpackage	com_jvld
 * @copyright	Copyright 2008-2013 JV-Extensions. All rights reserved
 * @license		GNU General Public License version 3 or later
 * @author		JV-Extensions
 * @link		http://www.jv-extensions.com
 */

// No direct access
defined('_JEXEC') or die('Restricted access');

class JvldModelChecklinkstatus extends JvldFendModel
{
	public function getForm($data = array(), $loadData = false)
	{
		$form = $this->loadForm('com_jvld.checklinkstatus', 'checklinkstatus', array('control' => 'jform', 'load_data' => $loadData), true);
		if (empty($form))
			return false;

		return $form;
	}

	public function process()
	{
		try
		{
			parent::preProcess();

			if ($this->url == '')
				throw new Exception(JText::_("COM_JVLD_ERR_INSUFFINFO"));

			if (\Joomla\String\StringHelper::substr($this->url, 0, 7) == 'http://')
			{
				// normal url
				$s1 = \Joomla\String\StringHelper::substr($this->url, 0, 11);
				if ($s1 == 'http://www.')
				{
					$url_1 = $this->url; // with www
					$url_2 = \Joomla\String\StringHelper::str_ireplace("http://www.", "http://", $this->url); // without www
				}
				else
				{
					$url_1 = $this->url; // without www
					$url_2 = \Joomla\String\StringHelper::str_ireplace("http://", "http://www.", $this->url); // with www
				}
			}
			else if (\Joomla\String\StringHelper::substr($this->url, 0, 8) == 'https://')
			{
				// secure url
				$s1 = \Joomla\String\StringHelper::substr($this->url, 0, 12);
				if ($s1 == 'https://www.')
				{
					$url_1 = $this->url; // with www
					$url_2 = \Joomla\String\StringHelper::str_ireplace("https://www.", "https://", $this->url); // without www
				}
				else
				{
					$url_1 = $this->url; // without www
					$url_2 = \Joomla\String\StringHelper::str_ireplace("https://", "https://www.", $this->url); // with www
				}
			}
			else
				throw new Exception(JText::_("COM_JVLD_INVALID_URL"));

			$langcheckq = (_JVLD_JOOMLA_MLANG) ?  " and (L.language = '".JFactory::getLanguage()->getTag()."' or L.language = '*') " : "";
			$u_alevels = implode(',', JFactory::getUser()->getAuthorisedViewLevels());

			$sql = "select L.id, L.link_status from `#__jvld_links` as L, #__jvld_catlinks as CL, #__categories as JC
					where L.id = CL.lid
					and CL.isprimary = 1
					and CL.cid = JC.id".$langcheckq." 
					and JC.access in (".$u_alevels.") 
					and L.access in (".$u_alevels.") 
					and JC.published = 1 
					and (
							L.partner_url = '".JvldSecure::defendSQL($url_1)."' or
							L.partner_url = '".JvldSecure::defendSQL(JvldUtil::stripLastChar($url_1))."' or
							L.partner_url = '".JvldSecure::defendSQL($url_2)."' or
							L.partner_url = '".JvldSecure::defendSQL(JvldUtil::stripLastChar($url_2))."'
						)
					";

			$row = JvldDb::getRow($sql);
			if (!$row)
				throw new Exception(JText::_("COM_JVLD_LINK_NOT_EXIST"));

			$sts_tmp = JvldUtil::getLinkStatusMessage($row->link_status);

			if ($row->link_status == _JVLD_LINKSTATUS_ESTABLISHED)
			{
				$linkobj = new JvldLinkinfo($row->id, _JVLD_CONTEXT_FLBLOCK);
				$sts_tmp .= $linkobj->showHref(1, 1, 0, 0, 0, 0, 0);
			}

			JvldMsg::display(JText::_("COM_JVLD_LINK_STATUS_TXT").': '.$sts_tmp);
			return;

		}
		catch (Exception $ex)
		{
			JvldMsg::display($ex->getMessage(), _JVLD_NEXT_PAGE_GO_BACK);
			return;
		}
	}
}